Page MenuHomePhabricator

No OneTemporary

This file is larger than 256 KB, so syntax highlighting was skipped.
diff --git a/BlueBerry/Bundles/org.blueberry.compat/berryCTKPluginListener.cpp b/BlueBerry/Bundles/org.blueberry.compat/berryCTKPluginListener.cpp
index 3d6faf1209..716bfc7b09 100644
--- a/BlueBerry/Bundles/org.blueberry.compat/berryCTKPluginListener.cpp
+++ b/BlueBerry/Bundles/org.blueberry.compat/berryCTKPluginListener.cpp
@@ -1,166 +1,166 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryCTKPluginListener_p.h"
#include <ctkPlugin.h>
#include <QSet>
const QString berry::CTKPluginListener::PLUGIN_MANIFEST = "plugin.xml";
namespace berry {
CTKPluginListener::CTKPluginListener(IExtensionPointService::Pointer registry)
: registry(registry)
{
}
void CTKPluginListener::processPlugins(const QList<QSharedPointer<ctkPlugin> >& plugins)
{
// sort the plugins according to their dependencies
const QList<QSharedPointer<ctkPlugin> > sortedPlugins = sortPlugins(plugins);
foreach (QSharedPointer<ctkPlugin> plugin, sortedPlugins)
{
if (isPluginResolved(plugin))
addPlugin(plugin);
else
removePlugin(plugin);
}
}
QList<QSharedPointer<ctkPlugin> >
CTKPluginListener::sortPlugins(const QList<QSharedPointer<ctkPlugin> >& plugins)
{
QList<QSharedPointer<ctkPlugin> > sortedPlugins(plugins);
QSet<QString> installedSymbolicNames;
QHash<long, QStringList> mapPluginIdToDeps;
foreach(QSharedPointer<ctkPlugin> plugin, sortedPlugins)
{
installedSymbolicNames.insert((plugin->getSymbolicName()));
QString requirePlugin = plugin->getHeaders()[ctkPluginConstants::REQUIRE_PLUGIN];
QStringList requiredList = requirePlugin.split(QRegExp("\\s*,\\s*"), QString::SkipEmptyParts);
QStringList requiredSymbolicNames;
foreach(QString require, requiredList)
{
requiredSymbolicNames.append(require.split(';').front());
}
mapPluginIdToDeps[plugin->getPluginId()] = requiredSymbolicNames;
}
QStringList stableSymbolicNames;
for (int i = 0; i < sortedPlugins.size();)
{
QStringList currDeps = mapPluginIdToDeps[sortedPlugins.at(i)->getPluginId()];
bool moved = false;
foreach(QString currDep, currDeps)
{
if (!stableSymbolicNames.contains(currDep) && installedSymbolicNames.contains(currDep))
{
sortedPlugins.move(i, sortedPlugins.size()-1);
moved = true;
break;
}
}
if (!moved)
{
stableSymbolicNames.append(sortedPlugins.at(i)->getSymbolicName());
++i;
}
}
return sortedPlugins;
}
void CTKPluginListener::pluginChanged(const ctkPluginEvent& event)
{
/* Only should listen for RESOLVED and UNRESOLVED events.
*
* When a plugin is updated the Framework will publish an UNRESOLVED and
* then a RESOLVED event which should cause the plugin to be removed
* and then added back into the registry.
*
* When a plugin is uninstalled the Framework should publish an UNRESOLVED
* event and then an UNINSTALLED event so the plugin will have been removed
* by the UNRESOLVED event before the UNINSTALLED event is published.
*/
QSharedPointer<ctkPlugin> plugin = event.getPlugin();
switch (event.getType())
{
case ctkPluginEvent::RESOLVED :
addPlugin(plugin);
break;
case ctkPluginEvent::UNRESOLVED :
removePlugin(plugin);
break;
}
}
bool CTKPluginListener::isPluginResolved(QSharedPointer<ctkPlugin> plugin)
{
return (plugin->getState() & (ctkPlugin::RESOLVED | ctkPlugin::ACTIVE | ctkPlugin::STARTING | ctkPlugin::STOPPING)) != 0;
}
void CTKPluginListener::removePlugin(QSharedPointer<ctkPlugin> plugin)
{
// The BlueBerry extension point registry does not support the removal of contributions
//registry->remove(plugin->getPluginId(), timestamp);
}
QString CTKPluginListener::getExtensionPath(QSharedPointer<ctkPlugin> plugin)
{
// bail out if system plugin
if (plugin->getPluginId() == 0)
return QString();
// bail out if the plugin does not have a symbolic name
if (plugin->getSymbolicName().isEmpty())
return QString();
return PLUGIN_MANIFEST;
}
void CTKPluginListener::addPlugin(QSharedPointer<ctkPlugin> plugin)
{
// if the given plugin already exists in the registry then return.
// note that this does not work for update cases.
std::string contributor = plugin->getSymbolicName().toStdString();
if (registry->HasContributionFrom(contributor))
{
return;
}
QString pluginManifest = getExtensionPath(plugin);
if (pluginManifest.isEmpty())
return;
QByteArray ba = plugin->getResource(pluginManifest);
if (ba.isEmpty())
return;
std::string strContent(ba.data());
std::stringbuf strBuf(strContent, std::ios_base::in);
std::istream is(&strBuf);
registry->AddContribution(is, contributor);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.compat/berryCTKPluginListener_p.h b/BlueBerry/Bundles/org.blueberry.compat/berryCTKPluginListener_p.h
index b1b64585ab..761728d105 100644
--- a/BlueBerry/Bundles/org.blueberry.compat/berryCTKPluginListener_p.h
+++ b/BlueBerry/Bundles/org.blueberry.compat/berryCTKPluginListener_p.h
@@ -1,77 +1,77 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYCTKPLUGINLISTENER_P_H
#define BERRYCTKPLUGINLISTENER_P_H
#include <QObject>
#include <QSharedPointer>
#include <ctkPluginEvent.h>
#include <berryIExtensionPointService.h>
class ctkPlugin;
namespace berry {
/**
* A listener for CTK plugin events. When plugins come and go we look to see
* if there are any extensions or extension points and update the legacy BlueBerry registry accordingly.
* Using a Synchronous listener here is important. If the
* plugin activator code tries to access the registry to get its extension
* points, we need to ensure that they are in the registry before the
* plugin start is called. By listening sync we are able to ensure that
* happens.
*/
class CTKPluginListener : public QObject {
Q_OBJECT
private:
static const QString PLUGIN_MANIFEST; // = "plugin.xml"
IExtensionPointService::Pointer registry;
public:
CTKPluginListener(IExtensionPointService::Pointer registry);
void processPlugins(const QList<QSharedPointer<ctkPlugin> >& plugins);
public slots:
void pluginChanged(const ctkPluginEvent& event);
private:
bool isPluginResolved(QSharedPointer<ctkPlugin> plugin);
void removePlugin(QSharedPointer<ctkPlugin> plugin);
static QString getExtensionPath(QSharedPointer<ctkPlugin> plugin);
void addPlugin(QSharedPointer<ctkPlugin> plugin);
QList<QSharedPointer<ctkPlugin> > sortPlugins(const QList<QSharedPointer<ctkPlugin> >& plugins);
};
}
#endif // BERRYCTKPLUGINLISTENER_P_H
diff --git a/BlueBerry/Bundles/org.blueberry.compat/berryPluginActivator.cpp b/BlueBerry/Bundles/org.blueberry.compat/berryPluginActivator.cpp
index 2c4b80ac5c..3bdd80d4cb 100644
--- a/BlueBerry/Bundles/org.blueberry.compat/berryPluginActivator.cpp
+++ b/BlueBerry/Bundles/org.blueberry.compat/berryPluginActivator.cpp
@@ -1,70 +1,70 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryPluginActivator_p.h"
#include "berryCTKPluginListener_p.h"
#include <berryIExtensionPointService.h>
#include <QtPlugin>
namespace berry {
org_blueberry_compat_Activator::org_blueberry_compat_Activator()
: pluginListener(0)
{
}
org_blueberry_compat_Activator::~org_blueberry_compat_Activator()
{
delete pluginListener;
}
void org_blueberry_compat_Activator::start(ctkPluginContext* context)
{
ctkServiceReference xpRef = context->getServiceReference<IExtensionPointService>();
Q_ASSERT(xpRef);
IExtensionPointService::Pointer xpService(context->getService<IExtensionPointService>(xpRef));
Q_ASSERT(xpService);
delete pluginListener;
// register a listener to catch new plugin installations/resolutions.
pluginListener = new CTKPluginListener(xpService);
context->connectPluginListener(pluginListener, SLOT(pluginChanged(ctkPluginEvent)), Qt::DirectConnection);
// populate the registry with all the currently installed plugins.
// There is a small window here while processPlugins is being
// called where the pluginListener may receive a ctkPluginEvent
// to add/remove a plugin from the registry. This is ok since
// the registry is a synchronized object and will not add the
// same bundle twice.
pluginListener->processPlugins(context->getPlugins());
}
void org_blueberry_compat_Activator::stop(ctkPluginContext* context)
{
Q_UNUSED(context)
}
}
Q_EXPORT_PLUGIN2(org_blueberry_compat, berry::org_blueberry_compat_Activator)
diff --git a/BlueBerry/Bundles/org.blueberry.compat/berryPluginActivator_p.h b/BlueBerry/Bundles/org.blueberry.compat/berryPluginActivator_p.h
index add9647d69..da7f8ba66c 100644
--- a/BlueBerry/Bundles/org.blueberry.compat/berryPluginActivator_p.h
+++ b/BlueBerry/Bundles/org.blueberry.compat/berryPluginActivator_p.h
@@ -1,51 +1,51 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYCOMPATIBILITYACTIVATOR_P_H
#define BERRYCOMPATIBILITYACTIVATOR_P_H
#include <ctkPluginActivator.h>
namespace berry {
class CTKPluginListener;
class org_blueberry_compat_Activator :
public QObject, public ctkPluginActivator
{
Q_OBJECT
Q_INTERFACES(ctkPluginActivator)
public:
org_blueberry_compat_Activator();
~org_blueberry_compat_Activator();
void start(ctkPluginContext* context);
void stop(ctkPluginContext* context);
private:
CTKPluginListener* pluginListener;
}; // org_blueberry_compat_Activator
typedef org_blueberry_compat_Activator PluginActivator;
}
#endif // BERRYCOMPATIBILITYACTIVATOR_P_H
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryAbstractHandler.cpp b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryAbstractHandler.cpp
index c094e31124..de1972742f 100644
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryAbstractHandler.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryAbstractHandler.cpp
@@ -1,48 +1,48 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryAbstractHandler.h"
namespace berry
{
AbstractHandler::AbstractHandler() :
baseEnabled(true)
{
}
bool AbstractHandler::IsEnabled()
{
return baseEnabled;
}
bool AbstractHandler::IsHandled()
{
return true;
}
void AbstractHandler::SetBaseEnabled(bool state)
{
if (baseEnabled == state)
{
return;
}
baseEnabled = state;
//fireHandlerChanged(new HandlerEvent(this, true, false));
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryAbstractHandler.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryAbstractHandler.h
index c76a2402c7..485bf0f46e 100644
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryAbstractHandler.h
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryAbstractHandler.h
@@ -1,172 +1,172 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYABSTRACTHANDLER_H_
#define BERRYABSTRACTHANDLER_H_
#include "berryIHandler.h"
#include <org_blueberry_core_commands_Export.h>
namespace berry {
/**
* <p>
* This class is a partial implementation of <code>IHandler</code>. This
* abstract implementation provides support for handler listeners. You should
* subclass from this class unless you want to implement your own listener
* support. Subclasses should call
* {@link AbstractHandler#fireHandlerChanged(HandlerEvent)}when the handler
* changes. Subclasses can also override {@link AbstractHandler#isEnabled()} and
* {@link AbstractHandler#isHandled()}.
* </p>
*
* @since 3.1
*/
class BERRY_COMMANDS AbstractHandler : public IHandler { // ,public EventManager {
public:
berryObjectMacro(AbstractHandler)
private:
/**
* Track this base class enabled state.
*
* @since 3.4
*/
bool baseEnabled;
public:
AbstractHandler();
/**
* @see IHandler#addHandlerListener(IHandlerListener)
*/
// void AddHandlerListener(final IHandlerListener handlerListener) {
// addListenerObject(handlerListener);
// }
/**
* The default implementation does nothing. Subclasses who attach listeners
* to other objects are encouraged to detach them in this method.
*
* @see org.blueberry.core.commands.IHandler#dispose()
*/
~AbstractHandler() {
// Do nothing.
}
/**
* Whether this handler is capable of executing at this time. Subclasses may
* override this method. If clients override this method they should also
* consider overriding {@link #setEnabled(Object)} so they can be notified
* about framework execution contexts.
*
* @return <code>true</code>
* @see #setEnabled(Object)
* @see #setBaseEnabled(boolean)
*/
bool IsEnabled();
/**
* Whether this handler is capable of handling delegated responsibilities at
* this time. Subclasses may override this method.
*
* @return <code>true</code>
*/
bool IsHandled();
/**
* @see IHandler#removeHandlerListener(IHandlerListener)
*/
// void RemoveHandlerListener(final IHandlerListener handlerListener) {
// removeListenerObject(handlerListener);
// }
protected:
/**
* Fires an event to all registered listeners describing changes to this
* instance.
* <p>
* Subclasses may extend the definition of this method (i.e., if a different
* type of listener can be attached to a subclass). This is used primarily
* for support of <code>AbstractHandler</code> in
* <code>org.blueberry.ui.workbench</code>, and clients should be wary of
* overriding this behaviour. If this method is overridden, then the first
* line of the method should be "<code>super.fireHandlerChanged(handlerEvent);</code>".
* </p>
*
* @param handlerEvent
* the event describing changes to this instance. Must not be
* <code>null</code>.
*/
// void FireHandlerChanged(final HandlerEvent handlerEvent) {
// if (handlerEvent == null) {
// throw new NullPointerException();
// }
//
// final Object[] listeners = getListeners();
// for (int i = 0; i < listeners.length; i++) {
// final IHandlerListener listener = (IHandlerListener) listeners[i];
// listener.handlerChanged(handlerEvent);
// }
// }
/**
* Allow the default {@link #isEnabled()} to answer our enabled state. It
* will fire a HandlerEvent if necessary. If clients use this method they
* should also consider overriding {@link #setEnabled(Object)} so they can
* be notified about framework execution contexts.
*
* @param state
* the enabled state
* @since 3.4
*/
void SetBaseEnabled(bool state);
/**
* <p>
* Returns true iff there is one or more IHandlerListeners attached to this
* AbstractHandler.
* </p>
* <p>
* Subclasses may extend the definition of this method (i.e., if a different
* type of listener can be attached to a subclass). This is used primarily
* for support of <code>AbstractHandler</code> in
* <code>org.blueberry.ui.workbench</code>, and clients should be wary of
* overriding this behaviour. If this method is overridden, then the return
* value should include "<code>super.hasListeners() ||</code>".
* </p>
*
* @return true iff there is one or more IHandlerListeners attached to this
* AbstractHandler
*/
// bool HasListeners() {
// return isListenerAttached();
// }
};
}
#endif /*BERRYABSTRACTHANDLER_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommand.cpp b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommand.cpp
index 141d5f72c0..853769ca65 100644
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommand.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommand.cpp
@@ -1,498 +1,498 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryCommand.h"
#include "berryIParameter.h"
#include "berryITypedParameter.h"
#include "berryIHandler.h"
#include "berryIParameterValueConverter.h"
#include "berryHandlerEvent.h"
#include "berryCommandEvent.h"
#include "berryExecutionEvent.h"
#include "berryCommandCategory.h"
#include "util/berryCommandTracing.h"
#include "internal/berryCommandUtils.h"
#include <sstream>
namespace berry {
bool Command::DEBUG_COMMAND_EXECUTION = false;
bool Command::DEBUG_HANDLERS = false;
std::string Command::DEBUG_HANDLERS_COMMAND_ID = "";
Command::Command(const std::string& id) :
NamedHandleObjectWithState(id)
{
}
void Command::AddCommandListener(const ICommandListener::Pointer commandListener) {
if (!commandListener) {
throw Poco::NullPointerException("Cannot add a null command listener");
}
commandEvents.AddListener(commandListener);
}
void Command::AddExecutionListener(
const IExecutionListener::Pointer executionListener) {
if (!executionListener) {
throw Poco::NullPointerException(
"Cannot add a null execution listener"); //$NON-NLS-1$
}
executionEvents.AddListener(executionListener);
}
void Command::AddState(const std::string& id, const State::Pointer state) {
NamedHandleObjectWithState::AddState(id, state);
state->SetId(id);
if (IObjectWithState::Pointer stateHandler = handler.Cast<IObjectWithState>()) {
stateHandler->AddState(id, state);
}
}
bool Command::operator<(const Object* object) const {
const Command* castedObject = dynamic_cast<const Command*>(object);
int compareTo = CommandUtils::CompareObj(category, castedObject->category);
if (compareTo == 0) {
compareTo = CommandUtils::Compare(defined, castedObject->defined);
if (compareTo == 0) {
compareTo = CommandUtils::Compare(description, castedObject->description);
if (compareTo == 0) {
compareTo = CommandUtils::CompareObj(handler, castedObject->handler);
if (compareTo == 0) {
compareTo = CommandUtils::Compare(id, castedObject->id);
if (compareTo == 0) {
compareTo = CommandUtils::Compare(name, castedObject->name);
if (compareTo == 0) {
compareTo = CommandUtils::Compare(parameters,
castedObject->parameters);
}
}
}
}
}
}
return compareTo < 0;
}
void Command::Define(const std::string& name, const std::string& description,
const CommandCategory::Pointer category, const std::vector<IParameter::Pointer>& parameters,
ParameterType::Pointer returnType, const std::string& helpContextId) {
if (name == "") {
throw Poco::InvalidArgumentException(
"The name of a command cannot be empty"); //$NON-NLS-1$
}
if (!category) {
throw Poco::NullPointerException(
"The category of a command cannot be null"); //$NON-NLS-1$
}
const bool definedChanged = !this->defined;
this->defined = true;
const bool nameChanged = this->name != name;
this->name = name;
const bool descriptionChanged = this->description != description;
this->description = description;
const bool categoryChanged = this->category != category;
this->category = category;
const bool parametersChanged = !CommandUtils::Equals(this->parameters,
parameters);
this->parameters = parameters;
const bool returnTypeChanged = this->returnType != returnType;
this->returnType = returnType;
const bool helpContextIdChanged = this->helpContextId != helpContextId;
this->helpContextId = helpContextId;
CommandEvent::Pointer event(new CommandEvent(Command::Pointer(this), categoryChanged,
definedChanged, descriptionChanged, false, nameChanged,
parametersChanged, returnTypeChanged, helpContextIdChanged));
this->FireCommandChanged(event);
}
Object::Pointer Command::ExecuteWithChecks(const ExecutionEvent::ConstPointer event) {
this->FirePreExecute(event);
const IHandler::Pointer handler(this->handler);
if (!this->IsDefined()) {
const NotDefinedException exception(
"Trying to execute a command that is not defined. " + this->GetId());
this->FireNotDefined(&exception);
throw exception;
}
// Perform the execution, if there is a handler.
if (handler && handler->IsHandled()) {
this->SetEnabled(event->GetApplicationContext());
if (!this->IsEnabled()) {
const NotEnabledException exception(
"Trying to execute the disabled command " + this->GetId());
this->FireNotEnabled(&exception);
throw exception;
}
try {
const Object::Pointer returnValue(handler->Execute(event));
this->FirePostExecuteSuccess(returnValue);
return returnValue;
} catch (const ExecutionException* e) {
this->FirePostExecuteFailure(e);
throw e;
}
}
const NotHandledException e(
"There is no handler to execute for command " + this->GetId()); //$NON-NLS-1$
this->FireNotHandled(&e);
throw e;
}
void Command::FireCommandChanged(const CommandEvent::ConstPointer commandEvent) {
if (!commandEvent) {
throw Poco::NullPointerException("Cannot fire a null event");
}
try
{
commandEvents.commandChanged(commandEvent);
}
catch (...)
{
//TODO log exceptions?
}
}
void Command::FireNotDefined(const NotDefinedException* e) {
// Debugging output
if (DEBUG_COMMAND_EXECUTION) {
CommandTracing::PrintTrace("COMMANDS", "execute" + CommandTracing::SEPARATOR
+ "not defined: id=" + this->GetId() + "; exception=" + e->what());
}
executionEvents.notDefined(this->GetId(), e);
}
void Command::FireNotEnabled(const NotEnabledException* e) {
// Debugging output
if (DEBUG_COMMAND_EXECUTION) {
CommandTracing::PrintTrace("COMMANDS", "execute" + CommandTracing::SEPARATOR
+ "not enabled: id=" + this->GetId() + "; exception=" + e->what());
}
executionEvents.notEnabled(this->GetId(), e);
}
void Command::FireNotHandled(const NotHandledException* e) {
// Debugging output
if (DEBUG_COMMAND_EXECUTION) {
CommandTracing::PrintTrace("COMMANDS", "execute" + CommandTracing::SEPARATOR
+ "not handled: id=" + this->GetId() + "; exception=" + e->what());
}
executionEvents.notHandled(this->GetId(), e);
}
void Command::FirePostExecuteFailure(const ExecutionException* e) {
// Debugging output
if (DEBUG_COMMAND_EXECUTION) {
CommandTracing::PrintTrace("COMMANDS", "execute" + CommandTracing::SEPARATOR
+ "failure: id=" + this->GetId() + "; exception=" + e->what());
}
executionEvents.postExecuteFailure(this->GetId(), e);
}
void Command::FirePostExecuteSuccess(const Object::Pointer returnValue) {
// Debugging output
if (DEBUG_COMMAND_EXECUTION) {
CommandTracing::PrintTrace("COMMANDS", "execute" + CommandTracing::SEPARATOR
+ "success: id=" + this->GetId() + "; returnValue=" + returnValue->ToString());
}
executionEvents.postExecuteSuccess(this->GetId(), returnValue);
}
void Command::FirePreExecute(const ExecutionEvent::ConstPointer event) {
// Debugging output
if (DEBUG_COMMAND_EXECUTION) {
CommandTracing::PrintTrace("COMMANDS", "execute" + CommandTracing::SEPARATOR
+ "starting: id=" + this->GetId() + "; event=" + event->ToString());
}
executionEvents.preExecute(this->GetId(), event);
}
IHandler::Pointer Command::GetHandler() const {
return handler;
}
std::string Command::GetHelpContextId() const {
return helpContextId;
}
IParameter::Pointer Command::GetParameter(const std::string& parameterId) const
{
if (!this->IsDefined()) {
throw NotDefinedException(
"Cannot get a parameter from an undefined command. " + id);
}
for (unsigned int i = 0; i < parameters.size(); i++) {
IParameter::Pointer parameter(parameters[i]);
if (parameter->GetId() == parameterId) {
return parameter;
}
}
return IParameter::Pointer(0);
}
std::vector<IParameter::Pointer> Command::GetParameters() const {
if (!this->IsDefined()) {
throw NotDefinedException(
"Cannot get the parameters from an undefined command. " + id);
}
return parameters;
}
ParameterType::Pointer Command::GetParameterType(const std::string& parameterId) const
{
const IParameter::Pointer parameter(this->GetParameter(parameterId));
if (ITypedParameter::Pointer parameterWithType = parameter.Cast<ITypedParameter>()) {
return parameterWithType->GetParameterType();
}
return ParameterType::Pointer(0);
}
ParameterType::Pointer Command::GetReturnType() const {
if (!this->IsDefined()) {
throw NotDefinedException(
"Cannot get the return type of an undefined command. " + id);
}
return returnType;
}
bool Command::IsEnabled() const {
if (!handler) {
return false;
}
return handler->IsEnabled();
}
void Command::SetEnabled(Object::ConstPointer evaluationContext) {
handler->SetEnabled(evaluationContext);
}
bool Command::IsHandled() const {
if (!handler) {
return false;
}
return handler->IsHandled();
}
void Command::RemoveCommandListener(
const ICommandListener::Pointer commandListener) {
if (!commandListener) {
throw Poco::NullPointerException(
"Cannot remove a null command listener");
}
commandEvents.RemoveListener(commandListener);
}
/**
* Removes a listener from this command.
*
* @param executionListener
* The listener to be removed; must not be <code>null</code>.
*
*/
void Command::RemoveExecutionListener(
const IExecutionListener::Pointer executionListener) {
if (!executionListener) {
throw Poco::NullPointerException(
"Cannot remove a null execution listener"); //$NON-NLS-1$
}
executionEvents.RemoveListener(executionListener);
}
void Command::RemoveState(const std::string& stateId) {
if (IObjectWithState::Pointer stateHandler = handler.Cast<IObjectWithState>()) {
stateHandler->RemoveState(stateId);
}
NamedHandleObjectWithState::RemoveState(stateId);
}
bool Command::SetHandler(const IHandler::Pointer handler) {
if (handler == this->handler) {
return false;
}
// Swap the state around.
const std::vector<std::string> stateIds(this->GetStateIds());
for (unsigned int i = 0; i < stateIds.size(); ++i) {
const std::string stateId = stateIds[i];
if (IObjectWithState::Pointer stateHandler = this->handler.Cast<IObjectWithState>()) {
stateHandler->RemoveState(stateId);
}
if (IObjectWithState::Pointer stateHandler = handler.Cast<IObjectWithState>()) {
const State::Pointer stateToAdd(this->GetState(stateId));
stateHandler->AddState(stateId, stateToAdd);
}
}
bool enabled = this->IsEnabled();
if (this->handler) {
this->handler->RemoveHandlerListener(this->GetHandlerListener());
}
// Update the handler, and flush the string representation.
this->handler = handler;
if (this->handler) {
this->handler->AddHandlerListener(this->GetHandlerListener());
}
this->str = "";
// Debugging output
if ((DEBUG_HANDLERS)
&& ((DEBUG_HANDLERS_COMMAND_ID.empty()) || (DEBUG_HANDLERS_COMMAND_ID == id)))
{
std::string buffer("Command('");
buffer += id + "') has changed to ";
if (!handler) {
buffer += "no handler";
} else {
buffer += "\'" + handler->ToString() + "' as its handler";
}
CommandTracing::PrintTrace("HANDLERS", buffer);
}
// Send notification
CommandEvent::Pointer cmdEvent(new CommandEvent(Command::Pointer(this), false, false, false, true,
false, false, false, false, enabled != this->IsEnabled()));
this->FireCommandChanged(cmdEvent);
return true;
}
Command::HandlerListener::HandlerListener(berry::Command* command) : command(command)
{}
void Command::HandlerListener::HandlerChanged(HandlerEvent::Pointer handlerEvent) {
bool enabledChanged = handlerEvent->IsEnabledChanged();
bool handledChanged = handlerEvent->IsHandledChanged();
CommandEvent::Pointer cmdEvent(new CommandEvent(Command::Pointer(command), false,
false, false, handledChanged, false, false, false,
false, enabledChanged));
command->FireCommandChanged(cmdEvent);
}
/**
* @return the handler listener
*/
SmartPointer<IHandlerListener> Command::GetHandlerListener() {
if (!handlerListener) {
handlerListener = new HandlerListener(this);
}
return handlerListener;
}
std::string Command::ToString() const {
if (str.empty()) {
std::stringstream buffer;
buffer << "Command(" << id << ',' << name << "," << std::endl << "\t\t";
buffer << description << "," << std::endl << "\t\t" << (category ? category->ToString() : "");
buffer << "," << std::endl << "\t\t" << (handler ? handler->ToString() : "");
buffer << "," << std::endl << "\t\t" << "[";
for (unsigned int i = 0; i < parameters.size(); ++i)
{
buffer << parameters[i]->GetId();
}
buffer << "]," << (returnType ? returnType->ToString() : "");
buffer << "," << defined << ")";
str = buffer.str();
}
return str;
}
void Command::Undefine() {
bool enabledChanged = this->IsEnabled();
str = "";
const bool definedChanged = defined;
defined = false;
const bool nameChanged = !name.empty();
name = "";
const bool descriptionChanged = !description.empty();
description = "";
const bool categoryChanged = category;
category = 0;
const bool parametersChanged = !parameters.empty();
parameters.clear();
const bool returnTypeChanged = returnType;
returnType = 0;
const std::vector<std::string> stateIds(this->GetStateIds());
if (IObjectWithState::Pointer handlerWithState = handler.Cast<IObjectWithState>()) {
for (unsigned int i = 0; i < stateIds.size(); i++) {
const std::string stateId(stateIds[i]);
handlerWithState->RemoveState(stateId);
const State::Pointer state(this->GetState(stateId));
this->RemoveState(stateId);
//state.dispose();
}
} else {
for (unsigned int i = 0; i < stateIds.size(); ++i) {
const std::string stateId(stateIds[i]);
const State::Pointer state(this->GetState(stateId));
this->RemoveState(stateId);
//state.dispose();
}
}
CommandEvent::Pointer cmdEvent(new CommandEvent(Command::Pointer(this), categoryChanged,
definedChanged, descriptionChanged, false, nameChanged,
parametersChanged, returnTypeChanged, false, enabledChanged));
this->FireCommandChanged(cmdEvent);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommand.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommand.h
index 8eb131f75f..72e3e6b3a1 100644
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommand.h
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommand.h
@@ -1,544 +1,544 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYCOMMAND_H_
#define BERRYCOMMAND_H_
#include "berryNamedHandleObjectWithState.h"
#include "berryIParameter.h"
#include "berryParameterType.h"
#include "berryIExecutionListenerWithChecks.h"
#include "berryICommandListener.h"
#include "berryIHandlerListener.h"
#include <vector>
namespace berry
{
class CommandCategory;
class ExecutionEvent;
struct IHandler;
/**
* <p>
* A command is an abstract representation for some semantic behaviour. It is
* not the actual implementation of this behaviour, nor is it the visual
* appearance of this behaviour in the user interface. Instead, it is a bridge
* between the two.
* </p>
* <p>
* The concept of a command is based on the command design pattern. The notable
* difference is how the command delegates responsibility for execution. Rather
* than allowing concrete subclasses, it uses a handler mechanism (see the
* <code>handlers</code> extension point). This provides another level of
* indirection.
* </p>
* <p>
* A command will exist in two states: defined and undefined. A command is
* defined if it is declared in the XML of a resolved plug-in. If the plug-in is
* unloaded or the command is simply not declared, then it is undefined. Trying
* to reference an undefined command will succeed, but trying to access any of
* its functionality will fail with a <code>NotDefinedException</code>. If
* you need to know when a command changes from defined to undefined (or vice
* versa), then attach a command listener.
* </p>
* <p>
* Commands are mutable and will change as their definition changes.
* </p>
*
*/
class BERRY_COMMANDS Command: public NamedHandleObjectWithState
{ // implements Comparable {
public:
berryObjectMacro(Command)
/**
* This flag can be set to <code>true</code> if commands should print
* information to <code>System.out</code> when executing.
*/
static bool DEBUG_COMMAND_EXECUTION;
/**
* This flag can be set to <code>true</code> if commands should print
* information to <code>System.out</code> when changing handlers.
*/
static bool DEBUG_HANDLERS;
/**
* This flag can be set to a particular command identifier if only that
* command should print information to <code>System.out</code> when
* changing handlers.
*/
static std::string DEBUG_HANDLERS_COMMAND_ID;
private:
/**
* The category to which this command belongs. This value should not be
* <code>null</code> unless the command is undefined.
*/
SmartPointer<CommandCategory> category;
/**
* A collection of objects listening to the execution of this command.
*/
IExecutionListenerWithChecks::Events executionEvents;
//ListenerList executionListeners;
/**
* A collection of objects listening to changes of this command.
*/
ICommandListener::Events commandEvents;
/**
* The handler currently associated with this command. This value may be
* <code>null</code> if there is no handler currently.
*/
SmartPointer<IHandler> handler;
/**
* The help context identifier for this command. This can be
* <code>null</code> if there is no help currently associated with the
* command.
*
* @since 3.2
*/
std::string helpContextId;
/**
* The ordered array of parameters understood by this command. This value
* may be <code>null</code> if there are no parameters, or if the command
* is undefined. It may also be empty.
*/
std::vector<SmartPointer<IParameter> > parameters;
/**
* The type of the return value of this command. This value may be
* <code>null</code> if the command does not declare a return type.
*
* @since 3.2
*/
SmartPointer<ParameterType> returnType;
/**
* Our command will listen to the active handler for enablement changes so
* that they can be fired from the command itself.
*
* @since 3.3
*/
SmartPointer<IHandlerListener> handlerListener;
protected:
/**
* Constructs a new instance of <code>Command</code> based on the given
* identifier. When a command is first constructed, it is undefined.
* Commands should only be constructed by the <code>CommandManager</code>
* to ensure that the identifier remains unique.
*
* @param id
* The identifier for the command. This value must not be
* <code>null</code>, and must be unique amongst all commands.
*/
Command(const std::string& id);
friend class CommandManager;
public:
/**
* Adds a listener to this command that will be notified when this command's
* state changes.
*
* @param commandListener
* The listener to be added; must not be <code>null</code>.
*/
void AddCommandListener(const ICommandListener::Pointer commandListener);
/**
* Adds a listener to this command that will be notified when this command
* is about to execute.
*
* @param executionListener
* The listener to be added; must not be <code>null</code>.
*/
void AddExecutionListener(
const IExecutionListener::Pointer executionListener);
/**
* <p>
* Adds a state to this command. This will add this state to the active
* handler, if the active handler is an instance of {@link IObjectWithState}.
* </p>
* <p>
* A single instance of {@link State} cannot be registered with multiple
* commands. Each command requires its own unique instance.
* </p>
*
* @param id
* The identifier of the state to add; must not be
* <code>null</code>.
* @param state
* The state to add; must not be <code>null</code>.
* @since 3.2
*/
void AddState(const std::string& id, const State::Pointer state);
/**
* Compares this command with another command by comparing each of its
* non-transient attributes.
*
* @param object
* The object with which to compare; must be an instance of
* <code>Command</code>.
* @return false if the object is
* equal to or greater than this command.
*/
bool operator<(const Object* object) const;
/**
* <p>
* Defines this command by giving it a name, and possibly a description as
* well. The defined property automatically becomes <code>true</code>.
* </p>
* <p>
* Notification is sent to all listeners that something has changed.
* </p>
*
* @param name
* The name of this command; must not be <code>null</code>.
* @param description
* The description for this command; may be <code>null</code>.
* @param category
* The category for this command; must not be <code>null</code>.
* @param parameters
* The parameters understood by this command. This value may be
* either <code>null</code> or empty if the command does not
* accept parameters.
* @param returnType
* The type of value returned by this command. This value may be
* <code>null</code> if the command does not declare a return
* type.
* @param helpContextId
* The identifier of the help context to associate with this
* command; may be <code>null</code> if this command does not
* have any help associated with it.
* @since 3.2
*/
void Define(const std::string& name, const std::string& description,
const SmartPointer<CommandCategory> category,
const std::vector<SmartPointer<IParameter> >& parameters = std::vector<SmartPointer<IParameter> >(),
SmartPointer<ParameterType> returnType = SmartPointer<ParameterType>(0), const std::string& helpContextId = "");
/**
* Executes this command by delegating to the current handler, if any. If
* the debugging flag is set, then this method prints information about
* which handler is selected for performing this command. This does checks
* to see if the command is enabled and defined. If it is not both enabled
* and defined, then the execution listeners will be notified and an
* exception thrown.
*
* @param event
* An event containing all the information about the current
* state of the application; must not be <code>null</code>.
* @return The result of the execution; may be <code>null</code>. This
* result will be available to the client executing the command, and
* execution listeners.
* @throws ExecutionException
* If the handler has problems executing this command.
* @throws NotDefinedException
* If the command you are trying to execute is not defined.
* @throws NotEnabledException
* If the command you are trying to execute is not enabled.
* @throws NotHandledException
* If there is no handler.
* @since 3.2
*/
Object::Pointer ExecuteWithChecks(const SmartPointer<const ExecutionEvent> event);
private:
/**
* Notifies the listeners for this command that it has changed in some way.
*
* @param commandEvent
* The event to send to all of the listener; must not be
* <code>null</code>.
*/
void FireCommandChanged(const SmartPointer<const CommandEvent> commandEvent);
/**
* Notifies the execution listeners for this command that an attempt to
* execute has failed because the command is not defined.
*
* @param e
* The exception that is about to be thrown; never
* <code>null</code>.
* @since 3.2
*/
void FireNotDefined(const NotDefinedException* e);
/**
* Notifies the execution listeners for this command that an attempt to
* execute has failed because there is no handler.
*
* @param e
* The exception that is about to be thrown; never
* <code>null</code>.
* @since 3.2
*/
void FireNotEnabled(const NotEnabledException* e);
/**
* Notifies the execution listeners for this command that an attempt to
* execute has failed because there is no handler.
*
* @param e
* The exception that is about to be thrown; never
* <code>null</code>.
*/
void FireNotHandled(const NotHandledException* e);
/**
* Notifies the execution listeners for this command that an attempt to
* execute has failed during the execution.
*
* @param e
* The exception that has been thrown; never <code>null</code>.
* After this method completes, the exception will be thrown
* again.
*/
void FirePostExecuteFailure(const ExecutionException* e);
/**
* Notifies the execution listeners for this command that an execution has
* completed successfully.
*
* @param returnValue
* The return value from the command; may be <code>null</code>.
*/
void FirePostExecuteSuccess(const Object::Pointer returnValue);
/**
* Notifies the execution listeners for this command that an attempt to
* execute is about to start.
*
* @param event
* The execution event that will be used; never <code>null</code>.
*/
void FirePreExecute(const SmartPointer<const ExecutionEvent> event);
public:
/**
* Returns the current handler for this command. This is used by the command
* manager for determining the appropriate help context identifiers and by
* the command service to allow handlers to update elements.
* <p>
* This value can change at any time and should never be cached.
* </p>
*
* @return The current handler for this command; may be <code>null</code>.
* @since 3.3
*/
SmartPointer<IHandler> GetHandler() const;
/**
* Returns the help context identifier associated with this command. This
* method should not be called by clients. Clients should use
* {@link CommandManager#getHelpContextId(Command)} instead.
*
* @return The help context identifier for this command; may be
* <code>null</code> if there is none.
* @since 3.2
*/
std::string GetHelpContextId() const;
/**
* Returns the parameter with the provided id or <code>null</code> if this
* command does not have a parameter with the id.
*
* @param parameterId
* The id of the parameter to retrieve.
* @return The parameter with the provided id or <code>null</code> if this
* command does not have a parameter with the id.
* @throws NotDefinedException
* If the handle is not currently defined.
* @since 3.2
*/
SmartPointer<IParameter> GetParameter(const std::string& parameterId) const;
/**
* Returns the parameters for this command. This call triggers provides a
* copy of the array, so excessive calls to this method should be avoided.
*
* @return The parameters for this command. This value might be
* <code>null</code>, if the command has no parameters.
* @throws NotDefinedException
* If the handle is not currently defined.
*/
std::vector<SmartPointer<IParameter> > GetParameters() const;
/**
* Returns the {@link ParameterType} for the parameter with the provided id
* or <code>null</code> if this command does not have a parameter type
* with the id.
*
* @param parameterId
* The id of the parameter to retrieve the {@link ParameterType}
* of.
* @return The {@link ParameterType} for the parameter with the provided id
* or <code>null</code> if this command does not have a parameter
* type with the provided id.
* @throws NotDefinedException
* If the handle is not currently defined.
* @since 3.2
*/
SmartPointer<ParameterType> GetParameterType(const std::string& parameterId) const;
/**
* Returns the {@link ParameterType} for the return value of this command or
* <code>null</code> if this command does not declare a return value
* parameter type.
*
* @return The {@link ParameterType} for the return value of this command or
* <code>null</code> if this command does not declare a return
* value parameter type.
* @throws NotDefinedException
* If the handle is not currently defined.
* @since 3.2
*/
SmartPointer<ParameterType> GetReturnType() const;
/**
* Returns whether this command has a handler, and whether this handler is
* also handled and enabled.
*
* @return <code>true</code> if the command is handled; <code>false</code>
* otherwise.
*/
bool IsEnabled() const;
/**
* Called be the framework to allow the handler to update its enabled state.
*
* @param evaluationContext
* the state to evaluate against. May be <code>null</code>
* which indicates that the handler can query whatever model that
* is necessary. This context must not be cached.
* @since 3.4
*/
void SetEnabled(Object::ConstPointer evaluationContext);
/**
* Returns whether this command has a handler, and whether this handler is
* also handled.
*
* @return <code>true</code> if the command is handled; <code>false</code>
* otherwise.
*/
bool IsHandled() const;
/**
* Removes a listener from this command.
*
* @param commandListener
* The listener to be removed; must not be <code>null</code>.
*
*/
void RemoveCommandListener(
const ICommandListener::Pointer commandListener);
/**
* Removes a listener from this command.
*
* @param executionListener
* The listener to be removed; must not be <code>null</code>.
*
*/
void RemoveExecutionListener(
const IExecutionListener::Pointer executionListener);
/**
* <p>
* Removes a state from this command. This will remove the state from the
* active handler, if the active handler is an instance of
* {@link IObjectWithState}.
* </p>
*
* @param stateId
* The identifier of the state to remove; must not be
* <code>null</code>.
* @since 3.2
*/
void RemoveState(const std::string& stateId);
/**
* Changes the handler for this command. This will remove all the state from
* the currently active handler (if any), and add it to <code>handler</code>.
* If debugging is turned on, then this will also print information about
* the change to <code>System.out</code>.
*
* @param handler
* The new handler; may be <code>null</code> if none.
* @return <code>true</code> if the handler changed; <code>false</code>
* otherwise.
*/
bool SetHandler(const SmartPointer<IHandler> handler);
private:
struct HandlerListener : public IHandlerListener
{
HandlerListener(Command* command);
void HandlerChanged(SmartPointer<HandlerEvent> handlerEvent);
private:
Command* command;
};
/**
* @return the handler listener
*/
SmartPointer<IHandlerListener> GetHandlerListener();
public:
/**
* The string representation of this command -- for debugging purposes only.
* This string should not be shown to an end user.
*
* @return The string representation; never <code>null</code>.
*/
std::string ToString() const;
/**
* Makes this command become undefined. This has the side effect of changing
* the name and description to <code>null</code>. This also removes all
* state and disposes of it. Notification is sent to all listeners.
*/
void Undefine();
};
}
#endif /*BERRYCOMMAND_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommandCategory.cpp b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommandCategory.cpp
index ee64233f9c..0e3135d584 100755
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommandCategory.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommandCategory.cpp
@@ -1,102 +1,102 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryCommandCategory.h"
#include "berryCommandCategoryEvent.h"
#include <Poco/Exception.h>
#include <sstream>
namespace berry {
void CommandCategory::AddCategoryListener(
ICommandCategoryListener::Pointer categoryListener) {
if (!categoryListener) {
throw Poco::NullPointerException("Category listener cannot be null");
}
categoryEvents.AddListener(categoryListener);
}
void CommandCategory::Define(const std::string& name, const std::string& description) {
if (name.empty()) {
throw Poco::InvalidArgumentException(
"The name of a command cannot be empty"); //$NON-NLS-1$
}
const bool definedChanged = !this->defined;
this->defined = true;
const bool nameChanged = !(this->name == name);
this->name = name;
const bool descriptionChanged = !(this->description == description);
this->description = description;
const CommandCategoryEvent::Pointer categoryEvent(new CommandCategoryEvent(CommandCategory::Pointer(this), definedChanged,
descriptionChanged, nameChanged));
this->FireCategoryChanged(categoryEvent);
}
void CommandCategory::RemoveCategoryListener(
ICommandCategoryListener::Pointer categoryListener) {
if (!categoryListener) {
throw Poco::NullPointerException("CommandCategory listener cannot be null");
}
categoryEvents.RemoveListener(categoryListener);
}
std::string CommandCategory::ToString() {
if (str.empty()) {
std::stringstream stringBuffer;
stringBuffer << "Category(" << id << "," << name << "," << description << "," << defined << ")";
str = stringBuffer.str();
}
return str;
}
void CommandCategory::Undefine() {
str = "";
const bool definedChanged = defined;
defined = false;
const bool nameChanged = !name.empty();
name = "";
const bool descriptionChanged = !description.empty();
description = "";
const CommandCategoryEvent::Pointer categoryEvent(new CommandCategoryEvent(CommandCategory::Pointer(this), definedChanged,
descriptionChanged, nameChanged));
this->FireCategoryChanged(categoryEvent);
}
CommandCategory::CommandCategory(const std::string& id) :
NamedHandleObject(id)
{
}
void CommandCategory::FireCategoryChanged(const CommandCategoryEvent::Pointer categoryEvent) {
if (!categoryEvent) {
throw Poco::NullPointerException("Command category event cannot be null");
}
categoryEvents.categoryChanged(categoryEvent);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommandCategory.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommandCategory.h
index 401ef2b715..dc675c1f5b 100755
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommandCategory.h
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommandCategory.h
@@ -1,129 +1,129 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYCOMMANDCATEGORY_H_
#define BERRYCOMMANDCATEGORY_H_
#include "common/berryNamedHandleObject.h"
#include "berryICommandCategoryListener.h"
namespace berry
{
/**
* <p>
* A logical group for a set of commands. A command belongs to exactly one
* category. The category has no functional effect, but may be used in graphical
* tools that want to group the set of commands somehow.
* </p>
*
* @since 3.1
*/
class CommandCategory: public NamedHandleObject
{
public:
berryObjectMacro(CommandCategory)
/**
* Adds a listener to this category that will be notified when this
* category's state changes.
*
* @param categoryListener
* The listener to be added; must not be <code>null</code>.
*/
void AddCategoryListener(
ICommandCategoryListener::Pointer categoryListener);
/**
* <p>
* Defines this category by giving it a name, and possibly a description as
* well. The defined property automatically becomes <code>true</code>.
* </p>
* <p>
* Notification is sent to all listeners that something has changed.
* </p>
*
* @param name
* The name of this command; must not be <code>null</code>.
* @param description
* The description for this command; may be <code>null</code>.
*/
void Define(const std::string& name, const std::string& description);
/**
* Removes a listener from this category.
*
* @param categoryListener
* The listener to be removed; must not be <code>null</code>.
*
*/
void RemoveCategoryListener(
ICommandCategoryListener::Pointer categoryListener);
/*
* (non-Javadoc)
*
* @see org.eclipse.core.commands.common.HandleObject#toString()
*/
std::string ToString();
/*
* (non-Javadoc)
*
* @see org.eclipse.core.commands.common.HandleObject#undefine()
*/
void Undefine();
protected:
friend class CommandManager;
/**
* Constructs a new instance of <code>Category</code> based on the given
* identifier. When a category is first constructed, it is undefined.
* Category should only be constructed by the <code>CommandManager</code>
* to ensure that identifier remain unique.
*
* @param id
* The identifier for the category. This value must not be
* <code>null</code>, and must be unique amongst all
* categories.
*/
CommandCategory(const std::string& id);
private:
/**
* Notifies the listeners for this category that it has changed in some way.
*
* @param categoryEvent
* The event to send to all of the listener; must not be
* <code>null</code>.
*/
void FireCategoryChanged(const SmartPointer<CommandCategoryEvent> categoryEvent);
/**
* A collection of objects listening to changes to this category. This
* collection is <code>null</code> if there are no listeners.
*/
ICommandCategoryListener::Events categoryEvents;
};
}
#endif /* BERRYCOMMANDCATEGORY_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommandCategoryEvent.cpp b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommandCategoryEvent.cpp
index 291e9c7f8c..9d5ad7f6f4 100755
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommandCategoryEvent.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommandCategoryEvent.cpp
@@ -1,41 +1,41 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryCommandCategoryEvent.h"
#include "berryCommandCategory.h"
namespace berry
{
CommandCategoryEvent::CommandCategoryEvent(
const SmartPointer<CommandCategory> category, bool definedChanged,
bool descriptionChanged, bool nameChanged) :
AbstractNamedHandleEvent(definedChanged, descriptionChanged, nameChanged),
category(category)
{
if (!category)
{
throw Poco::NullPointerException("CommandCategory cannot be null");
}
}
SmartPointer<CommandCategory> CommandCategoryEvent::GetCategory() const
{
return category;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommandCategoryEvent.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommandCategoryEvent.h
index 8b6ebd8405..6eb9a30385 100755
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommandCategoryEvent.h
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommandCategoryEvent.h
@@ -1,76 +1,76 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYCOMMANDCATEGORYEVENT_H_
#define BERRYCOMMANDCATEGORYEVENT_H_
#include "common/berryAbstractNamedHandleEvent.h"
namespace berry {
class CommandCategory;
/**
* An instance of this class describes changes to an instance of
* <code>Category</code>.
* <p>
* This class is not intended to be extended by clients.
* </p>
*
* @since 3.1
* @see ICategoryListener#categoryChanged(CategoryEvent)
*/
class BERRY_COMMANDS CommandCategoryEvent : public AbstractNamedHandleEvent {
public:
berryObjectMacro(CommandCategoryEvent)
/**
* Creates a new instance of this class.
*
* @param category
* the instance of the interface that changed.
* @param definedChanged
* true, iff the defined property changed.
* @param descriptionChanged
* true, iff the description property changed.
* @param nameChanged
* true, iff the name property changed.
*/
CommandCategoryEvent(const SmartPointer<CommandCategory> category, bool definedChanged,
bool descriptionChanged, bool nameChanged);
/**
* Returns the instance of the interface that changed.
*
* @return the instance of the interface that changed. Guaranteed not to be
* <code>null</code>.
*/
SmartPointer<CommandCategory> GetCategory() const;
private:
/**
* The category that has changed; this value is never <code>null</code>.
*/
const SmartPointer<CommandCategory> category;
};
}
#endif /* BERRYCOMMANDCATEGORYEVENT_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommandEvent.cpp b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommandEvent.cpp
index c49855b8a5..6d23b009b7 100755
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommandEvent.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommandEvent.cpp
@@ -1,109 +1,109 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryCommandEvent.h"
#include "berryCommand.h"
#include "berryCommandCategory.h"
#include "berryIParameterValueConverter.h"
#include "berryIHandler.h"
namespace berry
{
const int CommandEvent::CHANGED_CATEGORY = CommandEvent::LAST_USED_BIT << 1;
const int CommandEvent::CHANGED_HANDLED = CommandEvent::LAST_USED_BIT << 2;
const int CommandEvent::CHANGED_PARAMETERS = CommandEvent::LAST_USED_BIT << 3;
const int CommandEvent::CHANGED_RETURN_TYPE = CommandEvent::LAST_USED_BIT << 4;
const int CommandEvent::CHANGED_HELP_CONTEXT_ID = CommandEvent::LAST_USED_BIT
<< 5;
const int CommandEvent::CHANGED_ENABLED = CommandEvent::LAST_USED_BIT << 6;
CommandEvent::CommandEvent(const Command::Pointer command,
bool categoryChanged, bool definedChanged, bool descriptionChanged,
bool handledChanged, bool nameChanged, bool parametersChanged,
bool returnTypeChanged, bool helpContextIdChanged,
bool enabledChanged) :
AbstractNamedHandleEvent(definedChanged, descriptionChanged, nameChanged),
command(command)
{
if (!command)
{
throw Poco::NullPointerException("The command cannot be null");
}
if (categoryChanged)
{
changedValues |= CHANGED_CATEGORY;
}
if (handledChanged)
{
changedValues |= CHANGED_HANDLED;
}
if (parametersChanged)
{
changedValues |= CHANGED_PARAMETERS;
}
if (returnTypeChanged)
{
changedValues |= CHANGED_RETURN_TYPE;
}
if (helpContextIdChanged)
{
changedValues |= CHANGED_HELP_CONTEXT_ID;
}
if (enabledChanged)
{
changedValues |= CHANGED_ENABLED;
}
}
Command::Pointer CommandEvent::GetCommand() const
{
return command;
}
bool CommandEvent::IsCategoryChanged() const
{
return ((changedValues & CHANGED_CATEGORY) != 0);
}
bool CommandEvent::IsHandledChanged() const
{
return ((changedValues & CHANGED_HANDLED) != 0);
}
bool CommandEvent::IsHelpContextIdChanged() const
{
return ((changedValues & CHANGED_HELP_CONTEXT_ID) != 0);
}
bool CommandEvent::IsParametersChanged() const
{
return ((changedValues & CHANGED_PARAMETERS) != 0);
}
bool CommandEvent::IsReturnTypeChanged() const
{
return ((changedValues & CHANGED_RETURN_TYPE) != 0);
}
bool CommandEvent::IsEnabledChanged() const
{
return ((changedValues & CHANGED_ENABLED) != 0);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommandEvent.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommandEvent.h
index 292acdf1ce..d11acaa88b 100755
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommandEvent.h
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommandEvent.h
@@ -1,182 +1,182 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYCOMMANDEVENT_H_
#define BERRYCOMMANDEVENT_H_
#include "common/berryAbstractNamedHandleEvent.h"
#include <org_blueberry_core_commands_Export.h>
namespace berry {
class Command;
/**
* An instance of this class describes changes to an instance of
* <code>Command</code>.
* <p>
* This class is not intended to be extended by clients.
* </p>
*
* @see ICommandListener#CommandChanged(CommandEvent::Pointer)
*/
class BERRY_COMMANDS CommandEvent : public AbstractNamedHandleEvent {
public:
berryObjectMacro(CommandEvent)
/**
* Creates a new instance of this class.
*
* @param command
* the instance of the interface that changed.
* @param categoryChanged
* <code>true</code>, iff the category property changed.
* @param definedChanged
* <code>true</code>, iff the defined property changed.
* @param descriptionChanged
* <code>true</code>, iff the description property changed.
* @param handledChanged
* <code>true</code>, iff the handled property changed.
* @param nameChanged
* <code>true</code>, iff the name property changed.
* @param parametersChanged
* <code>true</code> if the parameters have changed;
* <code>false</code> otherwise.
* @param returnTypeChanged
* <code>true</code> iff the return type property changed;
* <code>false</code> otherwise.
* @param helpContextIdChanged
* <code>true</code> iff the help context identifier changed;
* <code>false</code> otherwise.
* @param enabledChanged
* <code>true</code> iff the comand enablement changed;
* <code>false</code> otherwise.
* @since 3.3
*/
CommandEvent(const SmartPointer<Command> command, bool categoryChanged,
bool definedChanged, bool descriptionChanged,
bool handledChanged, bool nameChanged,
bool parametersChanged, bool returnTypeChanged = false,
bool helpContextIdChanged = false, bool enabledChanged = false);
/**
* Returns the instance of the interface that changed.
*
* @return the instance of the interface that changed. Guaranteed not to be
* <code>null</code>.
*/
SmartPointer<Command> GetCommand() const;
/**
* Returns whether or not the category property changed.
*
* @return <code>true</code>, iff the category property changed.
*/
bool IsCategoryChanged() const;
/**
* Returns whether or not the handled property changed.
*
* @return <code>true</code>, iff the handled property changed.
*/
bool IsHandledChanged() const;
/**
* Returns whether or not the help context identifier changed.
*
* @return <code>true</code>, iff the help context identifier changed.
* @since 3.2
*/
bool IsHelpContextIdChanged() const;
/**
* Returns whether or not the parameters have changed.
*
* @return <code>true</code>, iff the parameters property changed.
*/
bool IsParametersChanged() const;
/**
* Returns whether or not the return type property changed.
*
* @return <code>true</code>, iff the return type property changed.
* @since 3.2
*/
bool IsReturnTypeChanged() const;
/**
* Return whether the enable property changed.
*
* @return <code>true</code> iff the comand enablement changed
* @since 3.3
*/
bool IsEnabledChanged() const;
private:
/**
* The bit used to represent whether the command has changed its category.
*/
static const int CHANGED_CATEGORY; // = LAST_USED_BIT << 1;
/**
* The bit used to represent whether the command has changed its handler.
*/
static const int CHANGED_HANDLED; // = LAST_USED_BIT << 2;
/**
* The bit used to represent whether the command has changed its parameters.
*/
static const int CHANGED_PARAMETERS; // = LAST_USED_BIT << 3;
/**
* The bit used to represent whether the command has changed its return
* type.
*
* @since 3.2
*/
static const int CHANGED_RETURN_TYPE; // = LAST_USED_BIT << 4;
/**
* The bit used to represent whether the command has changed its help
* context identifier.
*
* @since 3.2
*/
static const int CHANGED_HELP_CONTEXT_ID; // = LAST_USED_BIT << 5;
/**
* The bit used to represent whether this commands active handler has
* changed its enablement state.
*
* @since 3.3
*/
static const int CHANGED_ENABLED; // = LAST_USED_BIT << 6;
/**
* The command that has changed; this value is never <code>null</code>.
*/
const SmartPointer<Command> command;
};
}
#endif /* BERRYCOMMANDEVENT_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommandManager.cpp b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommandManager.cpp
index 1cd0fac419..d75850f09a 100755
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommandManager.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommandManager.cpp
@@ -1,576 +1,576 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryCommandManager.h"
#include "berryIParameter.h"
#include "berryIHandler.h"
#include "berryParameterType.h"
#include "berryParameterizedCommand.h"
#include "berryParameterization.h"
#include "berryCommand.h"
#include "berryCommandCategory.h"
#include "berryExecutionEvent.h"
#include "berryCommandEvent.h"
#include "berryCommandCategoryEvent.h"
#include "berryCommandManagerEvent.h"
#include "berryParameterTypeEvent.h"
namespace berry {
CommandManager::ExecutionListener::ExecutionListener(CommandManager* commandManager) : commandManager(commandManager)
{
}
void CommandManager::ExecutionListener::NotDefined(const std::string& commandId, const NotDefinedException* exception) {
commandManager->executionEvents.notDefined(commandId, exception);
}
void CommandManager::ExecutionListener::NotEnabled(const std::string& commandId, const NotEnabledException* exception) {
commandManager->executionEvents.notEnabled(commandId, exception);
}
void CommandManager::ExecutionListener::NotHandled(const std::string& commandId, const NotHandledException* exception) {
commandManager->executionEvents.notHandled(commandId, exception);
}
void CommandManager::ExecutionListener::PostExecuteFailure(const std::string& commandId,
const ExecutionException* exception) {
commandManager->executionEvents.postExecuteFailure(commandId, exception);
}
void CommandManager::ExecutionListener::PostExecuteSuccess(const std::string& commandId,
const Object::Pointer returnValue) {
commandManager->executionEvents.postExecuteSuccess(commandId, returnValue);
}
void CommandManager::ExecutionListener::PreExecute(const std::string& commandId,
const ExecutionEvent::ConstPointer event) {
commandManager->executionEvents.preExecute(commandId, event);
}
CommandManager::CommandCategoryListener::CommandCategoryListener(CommandManager* commandManager)
: commandManager(commandManager)
{
}
void CommandManager::CommandCategoryListener::CategoryChanged(const CommandCategoryEvent::ConstPointer categoryEvent) {
if (categoryEvent->IsDefinedChanged()) {
const CommandCategory::Pointer category(categoryEvent->GetCategory());
const std::string categoryId(category->GetId());
const bool categoryIdAdded = category->IsDefined();
if (categoryIdAdded) {
commandManager->definedCategoryIds.insert(categoryId);
} else {
commandManager->definedCategoryIds.erase(categoryId);
}
CommandManagerEvent::Pointer event(new CommandManagerEvent(*commandManager, "",
false, false, categoryId, categoryIdAdded, true));
commandManager->FireCommandManagerChanged(event);
}
}
CommandManager::CommandListener::CommandListener(CommandManager* commandManager)
: commandManager(commandManager)
{
}
void CommandManager::CommandListener::CommandChanged(const SmartPointer<const CommandEvent> commandEvent) {
if (commandEvent->IsDefinedChanged()) {
const Command::Pointer command(commandEvent->GetCommand());
const std::string commandId = command->GetId();
const bool commandIdAdded = command->IsDefined();
if (commandIdAdded) {
commandManager->definedHandleObjects.insert(command);
} else {
commandManager->definedHandleObjects.erase(command);
}
CommandManagerEvent::Pointer event(new CommandManagerEvent(*commandManager,
commandId, commandIdAdded, true, "", false, false));
commandManager->FireCommandManagerChanged(event);
}
}
CommandManager::ParameterTypeListener::ParameterTypeListener(CommandManager* commandManager)
: commandManager(commandManager)
{
}
void CommandManager::ParameterTypeListener::ParameterTypeChanged(
const ParameterTypeEvent::ConstPointer parameterTypeEvent) {
if (parameterTypeEvent->IsDefinedChanged()) {
const ParameterType::Pointer parameterType(parameterTypeEvent
->GetParameterType());
const std::string parameterTypeId = parameterType->GetId();
const bool parameterTypeIdAdded = parameterType->IsDefined();
if (parameterTypeIdAdded) {
commandManager->definedParameterTypeIds.insert(parameterTypeId);
} else {
commandManager->definedParameterTypeIds.erase(parameterTypeId);
}
CommandManagerEvent::Pointer event(new CommandManagerEvent(*commandManager,
parameterTypeId, parameterTypeIdAdded, true));
commandManager->FireCommandManagerChanged(event);
}
}
const std::string CommandManager::AUTOGENERATED_CATEGORY_ID = "org.blueberry.core.commands.categories.autogenerated";
const char CommandManager::ESCAPE_CHAR = '%';
const char CommandManager::ID_VALUE_CHAR = '=';
const char CommandManager::PARAMETER_END_CHAR = ')';
const char CommandManager::PARAMETER_SEPARATOR_CHAR = ',';
const char CommandManager::PARAMETER_START_CHAR = '(';
CommandManager::CommandManager()
: categoryListener(new CommandCategoryListener(this)),
commandListener(new CommandListener(this)),
parameterTypeListener(new ParameterTypeListener(this))
{
}
void CommandManager::AddCommandManagerListener(
const SmartPointer<ICommandManagerListener> listener) {
commandManagerEvents.AddListener(listener);
}
void CommandManager::AddExecutionListener(const SmartPointer<IExecutionListener> listener) {
if (!listener) {
throw Poco::NullPointerException(
"Cannot add a null execution listener"); //$NON-NLS-1$
}
if (executionEvents.IsEmpty()) {
// Add an execution listener to every command.
executionListener = new ExecutionListener(this);
for (HandleObjectsByIdMap::Iterator itr = handleObjectsById.begin();
itr != handleObjectsById.end(); ++itr)
{
Command::Pointer command = itr->second.Cast<Command>();
if (command)
{
command->AddExecutionListener(executionListener);
}
}
}
executionEvents.AddListener(listener);
}
void CommandManager::DefineUncategorizedCategory(const std::string& name,
const std::string& description) {
CommandCategory::Pointer category(this->GetCategory(AUTOGENERATED_CATEGORY_ID));
category->Define(name, description);
}
SmartPointer<ParameterizedCommand> CommandManager::Deserialize(
const std::string& serializedParameterizedCommand)
throw(NotDefinedException, SerializationException) {
const int lparenPosition = (int) this->UnescapedIndexOf(
serializedParameterizedCommand, PARAMETER_START_CHAR);
std::string commandIdEscaped;
std::string serializedParameters;
if (lparenPosition == -1) {
commandIdEscaped = serializedParameterizedCommand;
} else {
commandIdEscaped = serializedParameterizedCommand.substr(0,
lparenPosition);
if (serializedParameterizedCommand
.at(serializedParameterizedCommand.size() - 1) != PARAMETER_END_CHAR) {
throw SerializationException(
"Parentheses must be balanced in serialized ParameterizedCommand"); //$NON-NLS-1$
}
serializedParameters = serializedParameterizedCommand.substr(
lparenPosition + 1, // skip PARAMETER_START_CHAR
serializedParameterizedCommand.size() - 1); // skip
// PARAMETER_END_CHAR
}
const std::string commandId(this->Unescape(commandIdEscaped));
Command::Pointer command(this->GetCommand(commandId));
const std::vector<IParameter::Pointer> parameters(command->GetParameters());
const std::vector<Parameterization>parameterizations(this->GetParameterizations(
serializedParameters, parameters));
ParameterizedCommand::Pointer pCmd(new ParameterizedCommand(command, parameterizations));
return pCmd;
}
std::vector<SmartPointer<Command> > CommandManager::GetAllCommands() const {
std::vector<Command::Pointer> result;
for (HandleObjectsByIdMap::ConstIterator itr = handleObjectsById.begin();
itr != handleObjectsById.end(); ++itr)
{
if (Command::Pointer cmd = itr->second.Cast<Command>())
{
result.push_back(cmd);
}
}
return result;
}
SmartPointer<CommandCategory> CommandManager::GetCategory(const std::string& categoryId) {
if (categoryId.empty()) {
return this->GetCategory(AUTOGENERATED_CATEGORY_ID);
}
this->CheckId(categoryId);
CommandCategory::Pointer category(categoriesById[categoryId]);
if (!category) {
category = new CommandCategory(categoryId);
categoriesById[categoryId] = category;
category->AddCategoryListener(categoryListener);
}
return category;
}
SmartPointer<Command> CommandManager::GetCommand(const std::string& commandId) {
this->CheckId(commandId);
Command::Pointer command(handleObjectsById[commandId].Cast<Command>());
if (!command) {
command = new Command(commandId);
handleObjectsById[commandId] = command;
command->AddCommandListener(commandListener);
if (executionListener) {
command->AddExecutionListener(executionListener);
}
}
return command;
}
std::vector<CommandCategory::Pointer> CommandManager::GetDefinedCategories() {
std::vector<CommandCategory::Pointer> categories;
for (Poco::HashSet<std::string>::Iterator itr = definedCategoryIds.begin();
itr != definedCategoryIds.end(); ++itr)
{
categories.push_back(this->GetCategory(*itr));
}
return categories;
}
Poco::HashSet<std::string> CommandManager::GetDefinedCategoryIds() const {
return definedCategoryIds;
}
Poco::HashSet<std::string> CommandManager::GetDefinedCommandIds() const {
return this->GetDefinedHandleObjectIds();
}
std::vector<SmartPointer<Command> > CommandManager::GetDefinedCommands() const {
std::vector<Command::Pointer> result;
for (HandleObjectsSet::ConstIterator itr = definedHandleObjects.begin();
itr != definedHandleObjects.end(); ++itr)
{
if (Command::Pointer cmd = itr->Cast<Command>())
result.push_back(cmd);
}
return result;
}
Poco::HashSet<std::string> CommandManager::GetDefinedParameterTypeIds() const {
return definedParameterTypeIds;
}
std::vector<SmartPointer<ParameterType> > CommandManager::GetDefinedParameterTypes() {
std::vector<ParameterType::Pointer> parameterTypes;
for (Poco::HashSet<std::string>::ConstIterator itr = definedParameterTypeIds.begin();
itr != definedParameterTypeIds.end(); ++itr)
{
parameterTypes.push_back(this->GetParameterType(*itr));
}
return parameterTypes;
}
std::string CommandManager::GetHelpContextId(const SmartPointer<const Command> command) const
throw(NotDefinedException) {
// Check if the command is defined.
if (!command->IsDefined()) {
throw NotDefinedException("The command is not defined. " //$NON-NLS-1$
+ command->GetId());
}
// Check the handler.
const IHandler::Pointer handler(command->GetHandler());
if (handler) {
const IHandler::WeakPtr weakHandler(handler);
Poco::HashMap<WeakPointer<IHandler>, std::string, Object::Hash>::ConstIterator itr =
helpContextIdsByHandler.find(weakHandler);
if (itr != helpContextIdsByHandler.end() && !itr->second.empty())
{
return itr->second;
}
}
// Simply return whatever the command has as a help context identifier.
return command->GetHelpContextId();
}
SmartPointer<ParameterType> CommandManager::GetParameterType(const std::string& parameterTypeId) {
this->CheckId(parameterTypeId);
ParameterType::Pointer parameterType(parameterTypesById[parameterTypeId]);
if (!parameterType) {
parameterType = new ParameterType(parameterTypeId);
parameterTypesById[parameterTypeId] = parameterType;
parameterType->AddListener(parameterTypeListener);
}
return parameterType;
}
void CommandManager::RemoveCommandManagerListener(
const SmartPointer<ICommandManagerListener> listener) {
commandManagerEvents.RemoveListener(listener);
}
void CommandManager::RemoveExecutionListener(const SmartPointer<IExecutionListener> listener) {
if (!listener) {
throw Poco::NullPointerException("Cannot remove a null listener");
}
if (executionEvents.IsEmpty()) {
return;
}
executionEvents.RemoveListener(listener);
if (executionEvents.IsEmpty()) {
// Remove the execution listener to every command.
for (HandleObjectsByIdMap::Iterator commandItr = handleObjectsById.begin();
commandItr != handleObjectsById.end(); ++commandItr)
{
Command::Pointer command(commandItr->second.Cast<Command>());
command->RemoveExecutionListener(executionListener);
}
executionListener = 0;
}
}
void CommandManager::SetHandlersByCommandId(const std::map<std::string, SmartPointer<IHandler> >& handlersByCommandId) {
// Make that all the reference commands are created.
for (std::map<std::string, SmartPointer<IHandler> >::const_iterator commandItr = handlersByCommandId.begin();
commandItr != handlersByCommandId.end(); ++commandItr)
{
this->GetCommand(commandItr->first);
}
// Now, set-up the handlers on all of the existing commands.
for (HandleObjectsByIdMap::Iterator commandItr = handleObjectsById.begin();
commandItr != handleObjectsById.end(); ++commandItr)
{
const Command::Pointer command(commandItr->second.Cast<Command>());
const std::string commandId(command->GetId());
std::map<std::string, SmartPointer<IHandler> >::const_iterator handlerItr = handlersByCommandId.find(commandId);
if (handlerItr != handlersByCommandId.end())
{
command->SetHandler(handlerItr->second);
}
else
{
command->SetHandler(IHandler::Pointer(0));
}
}
}
void CommandManager::SetHelpContextId(const SmartPointer<IHandler> handler,
const std::string& helpContextId) {
if (!handler) {
throw Poco::NullPointerException("The handler cannot be null");
}
IHandler::WeakPtr weakHandler(handler);
if (helpContextId.empty()) {
helpContextIdsByHandler.erase(weakHandler);
} else {
helpContextIdsByHandler[weakHandler] = helpContextId;
}
}
void CommandManager::FireNotEnabled(const std::string& commandId, const NotEnabledException* exception) {
executionEvents.notEnabled(commandId, exception);
}
void CommandManager::FireNotDefined(const std::string& commandId, const NotDefinedException* exception) {
executionEvents.notDefined(commandId, exception);
}
void CommandManager::FirePreExecute(const std::string& commandId, const SmartPointer<const ExecutionEvent> event) {
executionEvents.preExecute(commandId, event);
}
void CommandManager::FirePostExecuteSuccess(const std::string& commandId, Object::Pointer returnValue) {
executionEvents.postExecuteSuccess(commandId, returnValue);
}
void CommandManager::FirePostExecuteFailure(const std::string& commandId,
const ExecutionException* exception) {
executionEvents.postExecuteFailure(commandId, exception);
}
std::string CommandManager::Unescape(const std::string& escapedText)
throw(SerializationException) {
// defer initialization of a StringBuffer until we know we need one
std::string buffer;
for (std::string::const_iterator itr = escapedText.begin();
itr != escapedText.end(); ++itr) {
std::string::value_type c = *itr;
if (c != ESCAPE_CHAR) {
// normal unescaped character
if (!buffer.empty()) {
buffer += c;
}
} else {
if (buffer.empty()) {
buffer.assign(escapedText.begin(), itr);
}
if (++itr != escapedText.end()) {
c = *itr;
if (c == PARAMETER_START_CHAR || c == PARAMETER_END_CHAR ||
c == ID_VALUE_CHAR || c == PARAMETER_SEPARATOR_CHAR ||
c == ESCAPE_CHAR)
{
buffer += c;
}
else
{
std::string msg("Invalid character '");
msg += c;
msg += "' in escape sequence";
throw SerializationException(msg);
}
} else {
throw SerializationException(
"Unexpected termination of escape sequence"); //$NON-NLS-1$
}
}
}
if (buffer.empty()) {
return escapedText;
}
return buffer;
}
void CommandManager::FireCommandManagerChanged(const SmartPointer<const CommandManagerEvent> event) {
if (!event) {
throw Poco::NullPointerException();
}
commandManagerEvents.commandManagerChanged(event);
}
std::vector<Parameterization> CommandManager::GetParameterizations(
const std::string& serializedParams, const std::vector<SmartPointer<IParameter> >& parameters) const
throw(SerializationException) {
std::string serializedParameters(serializedParams);
if (serializedParameters.empty() || parameters.empty()) {
return std::vector<Parameterization>();
}
std::vector<Parameterization> paramList;
std::string::size_type commaPosition; // split off each param by looking for ','
do {
commaPosition = this->UnescapedIndexOf(serializedParameters, ',');
std::string idEqualsValue;
if (commaPosition == std::string::npos) {
// no more parameters after this
idEqualsValue = serializedParameters;
} else {
// take the first parameter...
idEqualsValue = serializedParameters.substr(0, commaPosition);
// ... and put the rest back into serializedParameters
serializedParameters = serializedParameters.substr(commaPosition + 1);
}
const std::string::size_type equalsPosition = this->UnescapedIndexOf(idEqualsValue, '=');
std::string parameterId;
std::string parameterValue;
if (equalsPosition == std::string::npos) {
// missing values are null
parameterId = this->Unescape(idEqualsValue);
} else {
parameterId = this->Unescape(idEqualsValue.substr(0, equalsPosition));
parameterValue = this->Unescape(idEqualsValue.substr(equalsPosition + 1));
}
for (unsigned int i = 0; i < parameters.size(); i++) {
const IParameter::Pointer parameter(parameters[i]);
if (parameter->GetId() == parameterId) {
paramList.push_back(Parameterization(parameter,
parameterValue));
break;
}
}
} while (commaPosition != std::string::npos);
return paramList;
}
std::string::size_type CommandManager::UnescapedIndexOf(const std::string& escapedText, const char ch) const {
std::string::size_type pos = escapedText.find_first_of(ch);
// first char can't be escaped
if (pos == 0) {
return pos;
}
while (pos != std::string::npos) {
// look back for the escape character
if (escapedText.at(pos - 1) != ESCAPE_CHAR) {
return pos;
}
// scan for the next instance of ch
pos = escapedText.find_first_of(ch, pos + 1);
}
return pos;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommandManager.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommandManager.h
index f05756d61d..0228f37094 100755
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommandManager.h
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommandManager.h
@@ -1,666 +1,666 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYCOMMANDMANAGER_H_
#define BERRYCOMMANDMANAGER_H_
#include "common/berryHandleObjectManager.h"
#include "berryIExecutionListenerWithChecks.h"
#include "berryICommandListener.h"
#include "berryIParameterTypeListener.h"
#include "berryICommandCategoryListener.h"
#include "berryICommandManagerListener.h"
#include <map>
namespace berry
{
struct IParameter;
struct IHandler;
class ParameterType;
class ParameterizedCommand;
class Parameterization;
class Command;
class CommandCategory;
/**
* <p>
* A central repository for commands -- both in the defined and undefined
* states. Commands can be created and retrieved using this manager. It is
* possible to listen to changes in the collection of commands by attaching a
* listener to the manager.
* </p>
*
* @see CommandManager#getCommand(String)
* @since 3.1
*/
class BERRY_COMMANDS CommandManager: public HandleObjectManager
{
private:
typedef HandleObjectManager::HandleObjectsSet HandleObjectsSet;
typedef HandleObjectManager::HandleObjectsByIdMap HandleObjectsByIdMap;
/**
* A listener that forwards incoming execution events to execution listeners
* on this manager. The execution events will come from any command on this
* manager.
*
* @since 3.1
*/
struct ExecutionListener: public IExecutionListenerWithChecks
{
ExecutionListener(CommandManager* commandManager);
void NotDefined(const std::string& commandId,
const NotDefinedException* exception);
void NotEnabled(const std::string& commandId,
const NotEnabledException* exception);
void NotHandled(const std::string& commandId,
const NotHandledException* exception);
void PostExecuteFailure(const std::string& commandId,
const ExecutionException* exception);
void PostExecuteSuccess(const std::string& commandId,
const Object::Pointer returnValue);
void PreExecute(const std::string& commandId, const SmartPointer<
const ExecutionEvent> event);
private:
CommandManager* commandManager;
};
struct CommandCategoryListener: public ICommandCategoryListener
{
CommandCategoryListener(CommandManager* commandManager);
void CategoryChanged(
const SmartPointer<const CommandCategoryEvent> categoryEvent);
private:
CommandManager* commandManager;
};
ICommandCategoryListener::Pointer categoryListener;
struct CommandListener: public ICommandListener
{
CommandListener(CommandManager* commandManager);
void CommandChanged(const SmartPointer<const CommandEvent> commandEvent);
private:
CommandManager* commandManager;
};
ICommandListener::Pointer commandListener;
struct ParameterTypeListener: public IParameterTypeListener
{
ParameterTypeListener(CommandManager* commandManager);
void ParameterTypeChanged(
const SmartPointer<const ParameterTypeEvent> parameterTypeEvent);
private:
CommandManager* commandManager;
};
IParameterTypeListener::Pointer parameterTypeListener;
public:
/**
* The identifier of the category in which all auto-generated commands will
* appear. This value must never be <code>null</code>.
*
* @since 3.2
*/
static const std::string AUTOGENERATED_CATEGORY_ID; // = "org.blueberry.core.commands.categories.autogenerated";
/**
* The default constructor
*/
CommandManager();
/**
* Adds a listener to this command manager. The listener will be notified
* when the set of defined commands changes. This can be used to track the
* global appearance and disappearance of commands.
*
* @param listener
* The listener to attach; must not be <code>null</code>.
*/
void AddCommandManagerListener(
const SmartPointer<ICommandManagerListener> listener);
/**
* Adds an execution listener to this manager. This listener will be
* notified if any of the commands controlled by this manager execute. This
* can be used to support macros and instrumentation of commands.
*
* @param listener
* The listener to attach; must not be <code>null</code>.
*/
void AddExecutionListener(const SmartPointer<IExecutionListener> listener);
/**
* Sets the name and description of the category for uncategorized commands.
* This is the category that will be returned if
* {@link #getCategory(String)} is called with <code>null</code>.
*
* @param name
* The name of the category for uncategorized commands; must not
* be <code>null</code>.
* @param description
* The description of the category for uncategorized commands;
* may be <code>null</code>.
* @since 3.2
*/
void DefineUncategorizedCategory(const std::string& name,
const std::string& description);
/**
* <p>
* Returns a {@link ParameterizedCommand} with a command and
* parameterizations as specified in the provided
* <code>serializedParameterizedCommand</code> string. The
* <code>serializedParameterizedCommand</code> must use the format
* returned by {@link ParameterizedCommand#serialize()} and described in the
* Javadoc for that method.
* </p>
* <p>
* If a parameter id encoded in the
* <code>serializedParameterizedCommand</code> does not exist in the
* encoded command, that parameter id and value are ignored. A given
* parameter id should not be used more than once in
* <code>serializedParameterizedCommand</code>. This will not result in
* an exception, but in this case the value of the parameter when the
* command is executed is unspecified.
* </p>
* <p>
* This method will never return <code>null</code>, however it may throw
* an exception if there is a problem processing the serialization string or
* the encoded command is undefined.
* </p>
*
* @param serializedParameterizedCommand
* a string representing a command id and parameter ids and
* values; must not be <code>null</code>
* @return a {@link ParameterizedCommand} with the command and
* parameterizations encoded in the
* <code>serializedParameterizedCommand</code>; never
* <code>null</code>.
* @throws NotDefinedException
* if the command indicated in
* <code>serializedParameterizedCommand</code> is not defined
* @throws SerializationException
* if there is an error deserializing
* <code>serializedParameterizedCommand</code>
* @see ParameterizedCommand#serialize()
* @since 3.2
*/
SmartPointer<ParameterizedCommand> Deserialize(
const std::string& serializedParameterizedCommand)
throw(NotDefinedException, SerializationException);
/**
* Returns all of the commands known by this manager -- defined and
* undefined.
*
* @return All of the commands; may be empty, but never <code>null</code>.
* @since 3.2
*/
std::vector<SmartPointer<Command> > GetAllCommands() const;
/**
* Gets the category with the given identifier. If no such category
* currently exists, then the category will be created (but be undefined).
*
* @param categoryId
* The identifier to find; must not be <code>null</code>. If
* the category is <code>null</code>, then a category suitable
* for uncategorized items is defined and returned.
* @return The category with the given identifier; this value will never be
* <code>null</code>, but it might be undefined.
* @see Category
*/
SmartPointer<CommandCategory> GetCategory(const std::string& categoryId);
/**
* Gets the command with the given identifier. If no such command currently
* exists, then the command will be created (but will be undefined).
*
* @param commandId
* The identifier to find; must not be <code>null</code> and
* must not be zero-length.
* @return The command with the given identifier; this value will never be
* <code>null</code>, but it might be undefined.
* @see Command
*/
SmartPointer<Command> GetCommand(const std::string& commandId);
/**
* Returns the categories that are defined.
*
* @return The defined categories; this value may be empty, but it is never
* <code>null</code>.
* @since 3.2
*/
std::vector<SmartPointer<CommandCategory> > GetDefinedCategories();
/**
* Returns the set of identifiers for those category that are defined.
*
* @return The set of defined category identifiers; this value may be empty,
* but it is never <code>null</code>.
*/
Poco::HashSet<std::string> GetDefinedCategoryIds() const;
/**
* Returns the set of identifiers for those commands that are defined.
*
* @return The set of defined command identifiers; this value may be empty,
* but it is never <code>null</code>.
*/
Poco::HashSet<std::string> GetDefinedCommandIds() const;
/**
* Returns the commands that are defined.
*
* @return The defined commands; this value may be empty, but it is never
* <code>null</code>.
* @since 3.2
*/
std::vector<SmartPointer<Command> > GetDefinedCommands() const;
/**
* Returns the set of identifiers for those parameter types that are
* defined.
*
* @return The set of defined command parameter type identifiers; this value
* may be empty, but it is never <code>null</code>.
* @since 3.2
*/
Poco::HashSet<std::string> GetDefinedParameterTypeIds() const;
/**
* Returns the command parameter types that are defined.
*
* @return The defined command parameter types; this value may be empty, but
* it is never <code>null</code>.
* @since 3.2
*/
std::vector<SmartPointer<ParameterType> > GetDefinedParameterTypes();
/**
* Gets the help context identifier for a particular command. The command's
* handler is first checked for a help context identifier. If the handler
* does not have a help context identifier, then the help context identifier
* for the command is returned. If neither has a help context identifier,
* then <code>null</code> is returned.
*
* @param command
* The command for which the help context should be retrieved;
* must not be <code>null</code>.
* @return The help context identifier to use for the given command; may be
* <code>null</code>.
* @throws NotDefinedException
* If the given command is not defined.
* @since 3.2
*/
std::string GetHelpContextId(const SmartPointer<const Command> command) const
throw(NotDefinedException);
/**
* Gets the command {@link ParameterType} with the given identifier. If no
* such command parameter type currently exists, then the command parameter
* type will be created (but will be undefined).
*
* @param parameterTypeId
* The identifier to find; must not be <code>null</code> and
* must not be zero-length.
* @return The {@link ParameterType} with the given identifier; this value
* will never be <code>null</code>, but it might be undefined.
* @since 3.2
*/
SmartPointer<ParameterType> GetParameterType(
const std::string& parameterTypeId);
/**
* Removes a listener from this command manager.
*
* @param listener
* The listener to be removed; must not be <code>null</code>.
*/
void RemoveCommandManagerListener(
const SmartPointer<ICommandManagerListener> listener);
/**
* Removes an execution listener from this command manager.
*
* @param listener
* The listener to be removed; must not be <code>null</code>.
*/
void RemoveExecutionListener(const SmartPointer<IExecutionListener> listener);
/**
* Block updates all of the handlers for all of the commands. If the handler
* is <code>null</code> or the command id does not exist in the map, then
* the command becomes unhandled. Otherwise, the handler is set to the
* corresponding value in the map.
*
* @param handlersByCommandId
* A map of command identifiers (<code>String</code>) to
* handlers (<code>IHandler</code>). This map may be
* <code>null</code> if all handlers should be cleared.
* Similarly, if the map is empty, then all commands will become
* unhandled.
*/
void SetHandlersByCommandId(
const std::map<std::string, SmartPointer<IHandler> >& handlersByCommandId);
/**
* Sets the help context identifier to associate with a particular handler.
*
* @param handler
* The handler with which to register a help context identifier;
* must not be <code>null</code>.
* @param helpContextId
* The help context identifier to register; may be
* <code>null</code> if the help context identifier should be
* removed.
* @since 3.2
*/
void SetHelpContextId(const SmartPointer<IHandler> handler,
const std::string& helpContextId);
/**
* Fires the <code>notEnabled</code> event for
* <code>executionListeners</code>.
* <p>
* <b>Note:</b> This supports bridging actions to the command framework,
* and should not be used outside the framework.
* </p>
*
* @param commandId
* The command id of the command about to execute, never
* <code>null</code>.
* @param exception
* The exception, never <code>null</code>.
* @since 3.4
*/
void FireNotEnabled(const std::string& commandId,
const NotEnabledException* exception);
/**
* Fires the <code>notDefined</code> event for
* <code>executionListeners</code>.
* <p>
* <b>Note:</b> This supports bridging actions to the command framework,
* and should not be used outside the framework.
* </p>
*
* @param commandId
* The command id of the command about to execute, never
* <code>null</code>.
* @param exception
* The exception, never <code>null</code>.
* @since 3.4
*/
void FireNotDefined(const std::string& commandId,
const NotDefinedException* exception);
/**
* Fires the <code>preExecute</code> event for
* <code>executionListeners</code>.
* <p>
* <b>Note:</b> This supports bridging actions to the command framework,
* and should not be used outside the framework.
* </p>
*
* @param commandId
* The command id of the command about to execute, never
* <code>null</code>.
* @param event
* The event that triggered the command, may be <code>null</code>.
* @since 3.4
*/
void FirePreExecute(const std::string& commandId, const SmartPointer<
const ExecutionEvent> event);
/**
* Fires the <code>postExecuteSuccess</code> event for
* <code>executionListeners</code>.
* <p>
* <b>Note:</b> This supports bridging actions to the command framework,
* and should not be used outside the framework.
* </p>
*
* @param commandId
* The command id of the command executed, never
* <code>null</code>.
* @param returnValue
* The value returned from the command, may be <code>null</code>.
* @since 3.4
*/
void FirePostExecuteSuccess(const std::string& commandId,
Object::Pointer returnValue);
/**
* Fires the <code>postExecuteFailure</code> event for
* <code>executionListeners</code>.
* <p>
* <b>Note:</b> This supports bridging actions to the command framework,
* and should not be used outside the framework.
* </p>
*
* @param commandId
* The command id of the command executed, never
* <code>null</code>.
* @param exception
* The exception, never <code>null</code>.
* @since 3.4
*/
void FirePostExecuteFailure(const std::string& commandId,
const ExecutionException* exception);
protected:
/**
* The escape character to use for serialization and deserialization of
* parameterized commands.
*/
static const char ESCAPE_CHAR; // = '%';
/**
* The character that separates a parameter id from its value.
*/
static const char ID_VALUE_CHAR; // = '=';
/**
* The character that indicates the end of a list of parameters.
*/
static const char PARAMETER_END_CHAR; // = ')';
/**
* The character that separators parameters from each other.
*/
static const char PARAMETER_SEPARATOR_CHAR; // = ',';
/**
* The character that indicates the start of a list of parameters.
*/
static const char PARAMETER_START_CHAR; // = '(';
friend class ParameterizedCommand;
private:
/**
* Unescapes special characters in the command id, parameter ids and
* parameter values for {@link #deserialize(String)}. The special characters
* {@link #PARAMETER_START_CHAR}, {@link #PARAMETER_END_CHAR},
* {@link #ID_VALUE_CHAR}, {@link #PARAMETER_SEPARATOR_CHAR} and
* {@link #ESCAPE_CHAR} are escaped by prepending an {@link #ESCAPE_CHAR}
* character.
* <p>
* See also ParameterizedCommand.escape(String)
* </p>
*
* @param escapedText
* a <code>String</code> that may contain escaped special
* characters for command serialization.
* @return a <code>String</code> representing <code>escapedText</code>
* with any escaped characters replaced by their literal values
* @throws SerializationException
* if <code>escapedText</code> contains an invalid escape
* sequence
* @since 3.2
*/
static std::string Unescape(const std::string& escapedText)
throw(SerializationException);
/**
* The map of category identifiers (<code>String</code>) to categories (
* <code>Category</code>). This collection may be empty, but it is never
* <code>null</code>.
*/
Poco::HashMap<std::string, SmartPointer<CommandCategory> > categoriesById;
/**
* The set of identifiers for those categories that are defined. This value
* may be empty, but it is never <code>null</code>.
*/
Poco::HashSet<std::string> definedCategoryIds;
/**
* The set of identifiers for those command parameter types that are
* defined. This value may be empty, but it is never <code>null</code>.
*
* @since 3.2
*/
Poco::HashSet<std::string> definedParameterTypeIds;
/**
* The execution listener for this command manager. This just forwards
* events from commands controlled by this manager to listeners on this
* manager.
*/
SmartPointer<IExecutionListenerWithChecks> executionListener;
/**
* The collection of execution listeners. This collection is
* <code>null</code> if there are no listeners.
*/
IExecutionListenerWithChecks::Events executionEvents;
/**
*
*/
ICommandManagerListener::Events commandManagerEvents;
/**
* The help context identifiers ({@link String}) for a handler ({@link IHandler}).
* This map may be empty, but it is never <code>null</code>. Entries are
* removed if all strong references to the handler are removed.
*
* @since 3.2
*/
Poco::HashMap<WeakPointer<IHandler>, std::string, Object::Hash>
helpContextIdsByHandler;
/**
* The map of parameter type identifiers (<code>String</code>) to
* parameter types ( <code>ParameterType</code>). This collection may be
* empty, but it is never <code>null</code>.
*
* @since 3.2
*/
Poco::HashMap<std::string, SmartPointer<ParameterType> > parameterTypesById;
/**
* Notifies all of the listeners to this manager that the set of defined
* command identifiers has changed.
*
* @param event
* The event to send to all of the listeners; must not be
* <code>null</code>.
*/
void FireCommandManagerChanged(
const SmartPointer<const CommandManagerEvent> event);
/**
* Returns an array of parameterizations for the provided command by
* deriving the parameter ids and values from the provided
* <code>serializedParameters</code> string.
*
* @param serializedParameters
* a String encoding parameter ids and values; must not be
* <code>null</code>.
* @param parameters
* array of parameters of the command being deserialized; may be
* <code>null</code>.
* @return an array of parameterizations; may be <code>null</code>.
* @throws SerializationException
* if there is an error deserializing the parameters
* @since 3.2
*/
std::vector<Parameterization> GetParameterizations(
const std::string& serializedParameters,
const std::vector<SmartPointer<IParameter> >& parameters) const
throw(SerializationException);
/**
* Searches for the index of a <code>char</code> in a <code>String</code>
* but disregards characters prefixed with the {@link #ESCAPE_CHAR} escape
* character. This is used by {@link #deserialize(String)} and
* {@link #getParameterizations(String, IParameter[])} to parse the
* serialized parameterized command string.
*
* @param escapedText
* the string to search for the index of <code>ch</code> in
* @param ch
* a character to search for in <code>escapedText</code>
* @return the index of the first unescaped occurrence of the character in
* <code>escapedText</code>, or <code>-1</code> if the
* character does not occur unescaped.
* @see String#indexOf(int)
*/
std::string::size_type UnescapedIndexOf(const std::string& escapedText, const char ch) const;
};
}
#endif /* BERRYCOMMANDMANAGER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommandManagerEvent.cpp b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommandManagerEvent.cpp
index 6f3a659b62..ef4aaa0119 100755
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommandManagerEvent.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommandManagerEvent.cpp
@@ -1,145 +1,145 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryCommandManagerEvent.h"
#include "berryCommandManager.h"
#include "berryIHandler.h"
#include "berryCommandCategory.h"
#include "berryParameterType.h"
namespace berry
{
const int CommandManagerEvent::CHANGED_CATEGORY_DEFINED = 1;
const int CommandManagerEvent::CHANGED_COMMAND_DEFINED = 1 << 1;
const int CommandManagerEvent::CHANGED_PARAMETER_TYPE_DEFINED = 1 << 2;
CommandManagerEvent::CommandManagerEvent(CommandManager& commandManager,
const std::string& commandId, const bool commandIdAdded,
const bool commandIdChanged, const std::string& categoryId,
const bool categoryIdAdded, const bool categoryIdChanged) :
categoryId(categoryId), commandId(commandId), commandManager(commandManager)
{
// if (!commandManager) {
// throw Poco::NullPointerException(
// "An event must refer to its command manager"); //$NON-NLS-1$
// }
if (commandIdChanged && (commandId.empty()))
{
throw Poco::NullPointerException(
"If the list of defined commands changed, then the added/removed command must be mentioned"); //$NON-NLS-1$
}
if (categoryIdChanged && (categoryId.empty()))
{
throw Poco::NullPointerException(
"If the list of defined categories changed, then the added/removed category must be mentioned"); //$NON-NLS-1$
}
int changedValues = 0;
if (categoryIdChanged && categoryIdAdded)
{
changedValues |= CHANGED_CATEGORY_DEFINED;
}
if (commandIdChanged && commandIdAdded)
{
changedValues |= CHANGED_COMMAND_DEFINED;
}
this->changedValues = changedValues;
}
CommandManagerEvent::CommandManagerEvent(CommandManager& commandManager,
const std::string& parameterTypeId, const bool parameterTypeIdAdded,
const bool parameterTypeIdChanged) :
parameterTypeId(parameterTypeId), commandManager(commandManager)
{
// if (!commandManager) {
// throw Poco::NullPointerException(
// "An event must refer to its command manager"); //$NON-NLS-1$
// }
if (parameterTypeIdChanged && (parameterTypeId.empty()))
{
throw Poco::NullPointerException(
"If the list of defined command parameter types changed, then the added/removed parameter type must be mentioned"); //$NON-NLS-1$
}
int changedValues = 0;
if (parameterTypeIdChanged && parameterTypeIdAdded)
{
changedValues |= CHANGED_PARAMETER_TYPE_DEFINED;
}
this->changedValues = changedValues;
}
std::string CommandManagerEvent::GetCategoryId() const
{
return categoryId;
}
std::string CommandManagerEvent::GetCommandId() const
{
return commandId;
}
CommandManager& CommandManagerEvent::GetCommandManager() const
{
return commandManager;
}
std::string CommandManagerEvent::GetParameterTypeId() const
{
return parameterTypeId;
}
bool CommandManagerEvent::IsCategoryChanged() const
{
return (!categoryId.empty());
}
bool CommandManagerEvent::IsCategoryDefined() const
{
return (((changedValues & CHANGED_CATEGORY_DEFINED) != 0)
&& (!categoryId.empty()));
}
bool CommandManagerEvent::IsCommandChanged() const
{
return (!commandId.empty());
}
bool CommandManagerEvent::IsCommandDefined() const
{
return (((changedValues & CHANGED_COMMAND_DEFINED) != 0)
&& (!commandId.empty()));
}
bool CommandManagerEvent::IsParameterTypeChanged() const
{
return (!parameterTypeId.empty());
}
bool CommandManagerEvent::IsParameterTypeDefined() const
{
return (((changedValues & CHANGED_PARAMETER_TYPE_DEFINED) != 0)
&& (!parameterTypeId.empty()));
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommandManagerEvent.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommandManagerEvent.h
index 7c9c586bf4..e38cde863c 100755
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommandManagerEvent.h
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryCommandManagerEvent.h
@@ -1,256 +1,256 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYCOMMANDMANAGEREVENT_H_
#define BERRYCOMMANDMANAGEREVENT_H_
#include <org_blueberry_core_commands_Export.h>
#include <berryObject.h>
#include <berryMacros.h>
namespace berry
{
class CommandManager;
/**
* <p>
* An event indicating that the set of defined command identifiers has changed.
* </p>
*
* @since 3.1
* @see ICommandManagerListener#commandManagerChanged(CommandManagerEvent)
*/
class BERRY_COMMANDS CommandManagerEvent: public Object
{
public:
berryObjectMacro(CommandManagerEvent)
/**
* Creates a new <code>CommandManagerEvent</code> instance to describe
* changes to commands and/or categories.
*
* @param commandManager
* the instance of the interface that changed; must not be
* <code>null</code>.
* @param commandId
* The command identifier that was added or removed; must not be
* <code>null</code> if commandIdChanged is <code>true</code>.
* @param commandIdAdded
* Whether the command identifier became defined (otherwise, it
* became undefined).
* @param commandIdChanged
* Whether the list of defined command identifiers has changed.
* @param categoryId
* The category identifier that was added or removed; must not be
* <code>null</code> if categoryIdChanged is <code>true</code>.
* @param categoryIdAdded
* Whether the category identifier became defined (otherwise, it
* became undefined).
* @param categoryIdChanged
* Whether the list of defined category identifiers has changed.
*/
CommandManagerEvent (CommandManager& commandManager,
const std::string& commandId, const bool commandIdAdded,
const bool commandIdChanged, const std::string& categoryId,
const bool categoryIdAdded, const bool categoryIdChanged);
/**
* Creates a new <code>CommandManagerEvent</code> instance to describe
* changes to command parameter types.
*
* @param commandManager
* the instance of the interface that changed; must not be
* <code>null</code>.
* @param parameterTypeId
* The command parameter type identifier that was added or
* removed; must not be <code>null</code> if
* parameterTypeIdChanged is <code>true</code>.
* @param parameterTypeIdAdded
* Whether the parameter type identifier became defined
* (otherwise, it became undefined).
* @param parameterTypeIdChanged
* Whether the list of defined parameter type identifiers has
* changed.
*
* @since 3.2
*/
CommandManagerEvent(CommandManager& commandManager,
const std::string& parameterTypeId, const bool parameterTypeIdAdded,
const bool parameterTypeIdChanged);
/**
* Returns the category identifier that was added or removed.
*
* @return The category identifier that was added or removed; may be
* <code>null</code>.
*/
std::string GetCategoryId() const;
/**
* Returns the command identifier that was added or removed.
*
* @return The command identifier that was added or removed; may be
* <code>null</code>.
*/
std::string GetCommandId() const;
/**
* Returns the instance of the interface that changed.
*
* @return the instance of the interface that changed. Guaranteed not to be
* <code>null</code>.
*/
CommandManager& GetCommandManager() const;
/**
* Returns the command parameter type identifier that was added or removed.
*
* @return The command parameter type identifier that was added or removed;
* may be <code>null</code>.
*
* @since 3.2
*/
std::string GetParameterTypeId() const;
/**
* Returns whether the list of defined category identifiers has changed.
*
* @return <code>true</code> if the list of category identifiers has
* changed; <code>false</code> otherwise.
*/
bool IsCategoryChanged() const;
/**
* Returns whether the category identifier became defined. Otherwise, the
* category identifier became undefined.
*
* @return <code>true</code> if the category identifier became defined;
* <code>false</code> if the category identifier became undefined.
*/
bool IsCategoryDefined() const;
/**
* Returns whether the list of defined command identifiers has changed.
*
* @return <code>true</code> if the list of command identifiers has
* changed; <code>false</code> otherwise.
*/
bool IsCommandChanged() const;
/**
* Returns whether the command identifier became defined. Otherwise, the
* command identifier became undefined.
*
* @return <code>true</code> if the command identifier became defined;
* <code>false</code> if the command identifier became undefined.
*/
bool IsCommandDefined() const;
/**
* Returns whether the list of defined command parameter type identifiers
* has changed.
*
* @return <code>true</code> if the list of command parameter type
* identifiers has changed; <code>false</code> otherwise.
*
* @since 3.2
*/
bool IsParameterTypeChanged() const;
/**
* Returns whether the command parameter type identifier became defined.
* Otherwise, the command parameter type identifier became undefined.
*
* @return <code>true</code> if the command parameter type identifier
* became defined; <code>false</code> if the command parameter
* type identifier became undefined.
*
* @since 3.2
*/
bool IsParameterTypeDefined() const;
private:
/**
* The bit used to represent whether the given category has become defined.
* If this bit is not set and there is no category id, then no category has
* become defined nor undefined. If this bit is not set and there is a
* category id, then the category has become undefined.
*/
static const int CHANGED_CATEGORY_DEFINED; // = 1;
/**
* The bit used to represent whether the given command has become defined.
* If this bit is not set and there is no command id, then no command has
* become defined nor undefined. If this bit is not set and there is a
* command id, then the command has become undefined.
*/
static const int CHANGED_COMMAND_DEFINED; // = 1 << 1;
/**
* The bit used to represent whether the given command parameter type has
* become defined. If this bit is not set and there is no parameter type id,
* then no parameter type has become defined nor undefined. If this bit is
* not set and there is a parameter type id, then the parameter type has
* become undefined.
*
* @since 3.2
*/
static const int CHANGED_PARAMETER_TYPE_DEFINED; // = 1 << 2;
/**
* The category identifier that was added or removed from the list of
* defined category identifiers. This value is <code>null</code> if the
* list of defined category identifiers did not change.
*/
const std::string categoryId;
/**
* A collection of bits representing whether certain values have changed. A
* bit is set (i.e., <code>1</code>) if the corresponding property has
* changed.
*/
int changedValues;
/**
* The command identifier that was added or removed from the list of defined
* command identifiers. This value is <code>null</code> if the list of
* defined command identifiers did not change.
*/
const std::string commandId;
/**
* The command parameter type identifier that was added or removed from the
* list of defined parameter type identifiers. This value is
* <code>null</code> if the list of defined parameter type identifiers did
* not change.
*/
const std::string parameterTypeId;
/**
* The command manager that has changed.
*/
CommandManager& commandManager;
};
}
#endif /* BERRYCOMMANDMANAGEREVENT_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryExecutionEvent.cpp b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryExecutionEvent.cpp
index ab93d9226d..c3d70e3217 100644
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryExecutionEvent.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryExecutionEvent.cpp
@@ -1,122 +1,122 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryExecutionEvent.h"
#include "common/berryCommandExceptions.h"
#include "berryIParameterValueConverter.h"
#include "berryCommandCategory.h"
#include "berryIHandler.h"
#include <berryObjectString.h>
#include <sstream>
namespace berry
{
ExecutionEvent::ExecutionEvent()
{
}
ExecutionEvent::ExecutionEvent(const Command::ConstPointer cmd,
const ParameterMap& params, const Object::ConstPointer trg,
const Object::ConstPointer appContext)
: applicationContext(appContext), command(cmd), parameters(params), trigger(trg)
{
}
const Object::ConstPointer ExecutionEvent::GetApplicationContext() const
{
return applicationContext;
}
const Command::ConstPointer ExecutionEvent::GetCommand() const
{
return command;
}
const Object::ConstPointer ExecutionEvent::GetObjectParameterForExecution(
const std::string& parameterId) const
{
if (command.IsNull())
{
throw ExecutionException(
"No command is associated with this execution event"); //$NON-NLS-1$
}
try
{
// const ParameterType parameterType = command
// .getParameterType(parameterId);
// if (parameterType == null)
// {
// throw new ExecutionException(
// "Command does not have a parameter type for the given parameter"); //$NON-NLS-1$
// }
// const AbstractParameterValueConverter valueConverter = parameterType
// .getValueConverter();
// if (valueConverter == null)
// {
// throw new ExecutionException(
// "Command does not have a value converter"); //$NON-NLS-1$
// }
const std::string stringValue = this->GetParameter(parameterId);
ObjectString::Pointer objectValue(new ObjectString(stringValue));
// const Object objectValue = valueConverter
// .convertToObject(stringValue);
return objectValue;
}
catch (NotDefinedException e)
{
throw ExecutionException("Command is not defined", e); //$NON-NLS-1$
}
// catch (ParameterValueConversionException e)
// {
// throw new ExecutionException(
// "The parameter string could not be converted to an object", e); //$NON-NLS-1$
// }
}
std::string ExecutionEvent::GetParameter(const std::string parameterId) const
{
ParameterMap::const_iterator res = parameters.find(parameterId);
if (res != parameters.end())
return res->second;
else return "";
}
const ExecutionEvent::ParameterMap& ExecutionEvent::GetParameters() const
{
return parameters;
}
const Object::ConstPointer ExecutionEvent::GetTrigger() const
{
return trigger;
}
std::string ExecutionEvent::ToString() const
{
std::stringstream str;
str << "ExecutionEvent(" << command->ToString() << ',' << parameters.size() << ','
<< trigger->ToString() << ',' << applicationContext->ToString() << ')';
return str.str();
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryExecutionEvent.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryExecutionEvent.h
index 674575a698..51c40d5176 100644
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryExecutionEvent.h
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryExecutionEvent.h
@@ -1,180 +1,180 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYEXECUTIONEVENT_H_
#define BERRYEXECUTIONEVENT_H_
#include <berryMacros.h>
#include "berryCommand.h"
#include <map>
namespace berry {
/**
* <p>
* The data object to pass to the command (and its handler) as it executes. This
* carries information about the current state of the application, and the
* application context in which the command was executed.
* </p>
* <p>
* An execution event carries three blocks of data: the parameters, the trigger,
* and the application context. How these blocks are used is application
* dependent. In the BlueBerry workbench, the trigger is an SWT event, and the
* application context contains information about the selection and active part.
* </p>
*
* @since 3.1
*/
class BERRY_COMMANDS ExecutionEvent : public Object {
public:
berryObjectMacro(ExecutionEvent)
typedef std::map<std::string, std::string> ParameterMap;
private:
/**
* The state of the application at the time the execution was triggered. In
* the BlueBerry workbench, this might contain information about the active
* part of the active selection (for example). This value may be
* <code>null</code>.
*/
const Object::ConstPointer applicationContext;
/**
* The command being executed. This value may be <code>null</code>.
*/
const Command::ConstPointer command;
/**
* The parameters to qualify the execution. For handlers that normally
* prompt for additional information, these can be used to avoid prompting.
* This value may be empty, but it is never <code>null</code>.
*/
const ParameterMap parameters;
/**
* The object that triggered the execution. In an event-driven architecture,
* this is typically just another event. In the BlueBerry workbench, this is
* typically an SWT event. This value may be <code>null</code>.
*/
const Object::ConstPointer trigger;
public:
/**
* Constructs a new instance of <code>ExecutionEvent</code> with no
* parameters, no trigger and no application context. This is just a
* convenience method.
*
* @since 3.2
*/
ExecutionEvent();
/**
* Constructs a new instance of <code>ExecutionEvent</code>.
*
* @param command
* The command being executed; may be <code>null</code>.
* @param parameters
* The parameters to qualify the execution; must not be
* <code>null</code>. This must be a map of parameter ids (<code>String</code>)
* to parameter values (<code>String</code>).
* @param trigger
* The object that triggered the execution; may be
* <code>null</code>.
* @param applicationContext
* The state of the application at the time the execution was
* triggered; may be <code>null</code>.
* @since 3.2
*/
ExecutionEvent(const Command::ConstPointer command, const ParameterMap& parameters,
const Object::ConstPointer trigger, const Object::ConstPointer applicationContext);
/**
* Returns the state of the application at the time the execution was
* triggered.
*
* @return The application context; may be <code>null</code>.
*/
const Object::ConstPointer GetApplicationContext() const;
/**
* Returns the command being executed.
*
* @return The command being executed.
* @since 3.2
*/
const Command::ConstPointer GetCommand() const;
/**
* Returns the object represented by the string value of the parameter with
* the provided id.
* <p>
* This is intended to be used in the scope of an
* {@link IHandler#execute(ExecutionEvent)} method, so any problem getting
* the object value causes <code>ExecutionException</code> to be thrown.
* </p>
*
* @param parameterId
* The id of a parameter to retrieve the object value of.
* @return The object value of the parameter with the provided id.
* @throws ExecutionException
* if the parameter object value could not be obtained for any
* reason
* @since 3.2
*/
const Object::ConstPointer GetObjectParameterForExecution(const std::string& parameterId) const;
/**
* Returns the value of the parameter with the given id.
*
* @param parameterId
* The id of the parameter to retrieve; may be <code>null</code>.
* @return The parameter value; <code>null</code> if the parameter cannot
* be found.
*/
std::string GetParameter(const std::string parameterId) const;
/**
* Returns all of the parameters.
*
* @return The parameters; never <code>null</code>, but may be empty.
*/
const ParameterMap& GetParameters() const;
/**
* Returns the object that triggered the execution
*
* @return The trigger; <code>null</code> if there was no trigger.
*/
const Object::ConstPointer GetTrigger() const;
/**
* The string representation of this execution event -- for debugging
* purposes only. This string should not be shown to an end user.
*/
std::string ToString() const;
};
}
#endif /*BERRYEXECUTIONEVENT_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryHandlerEvent.cpp b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryHandlerEvent.cpp
index 90ce0ceeee..bc72eefc1d 100755
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryHandlerEvent.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryHandlerEvent.cpp
@@ -1,61 +1,61 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryHandlerEvent.h"
#include "berryIHandler.h"
namespace berry
{
const int HandlerEvent::CHANGED_ENABLED = 1;
const int HandlerEvent::CHANGED_HANDLED = 1 << 1;
HandlerEvent::HandlerEvent(const IHandler::Pointer handler, bool enabledChanged,
bool handledChanged) :
handler(handler)
{
if (!handler)
{
throw Poco::NullPointerException("Handler cannot be null");
}
if (enabledChanged)
{
changedValues |= CHANGED_ENABLED;
}
if (handledChanged)
{
changedValues |= CHANGED_HANDLED;
}
}
SmartPointer<IHandler> HandlerEvent::GetHandler() const
{
return handler;
}
bool HandlerEvent::IsEnabledChanged() const
{
return ((changedValues & CHANGED_ENABLED) != 0);
}
bool HandlerEvent::IsHandledChanged() const
{
return ((changedValues & CHANGED_HANDLED) != 0);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryHandlerEvent.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryHandlerEvent.h
index a3188cfb7e..0cd3b526da 100755
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryHandlerEvent.h
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryHandlerEvent.h
@@ -1,104 +1,104 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYHANDLEREVENT_H_
#define BERRYHANDLEREVENT_H_
#include "common/berryAbstractBitSetEvent.h"
#include <org_blueberry_core_commands_Export.h>
namespace berry {
struct IHandler;
/**
* An instance of this class describes changes to an instance of
* <code>IHandler</code>.
* <p>
* This class is not intended to be extended by clients.
* </p>
*
* @see IHandlerListener#HandlerChanged(HandlerEvent)
*/
class BERRY_COMMANDS HandlerEvent : public AbstractBitSetEvent {
public:
berryObjectMacro(HandlerEvent)
/**
* Creates a new instance of this class.
*
* @param handler
* the instance of the interface that changed; must not be
* <code>null</code>.
* @param enabledChanged
* Whether the enabled state of the handler has changed.
* @param handledChanged
* Whether the handled state of the handler has changed.
*/
HandlerEvent(const SmartPointer<IHandler> handler, bool enabledChanged,
bool handledChanged);
/**
* Returns the instance of the interface that changed.
*
* @return the instance of the interface that changed. Guaranteed not to be
* <code>null</code>.
*/
SmartPointer<IHandler> GetHandler() const;
/**
* Returns whether or not the enabled property changed.
*
* @return <code>true</code>, iff the enabled property changed.
*/
bool IsEnabledChanged() const;
/**
* Returns whether or not the handled property changed.
*
* @return <code>true</code>, iff the handled property changed.
*/
bool IsHandledChanged() const ;
private:
/**
* The bit used to represent whether the handler has changed its enabled
* state.
*/
static const int CHANGED_ENABLED; // = 1;
/**
* The bit used to represent whether the handler has changed its handled
* state.
*/
static const int CHANGED_HANDLED; // = 1 << 1;
/**
* The handler that changed; this value is never <code>null</code>.
*/
const SmartPointer<IHandler> handler;
};
}
#endif /* BERRYHANDLEREVENT_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryICommandCategoryListener.cpp b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryICommandCategoryListener.cpp
index e791cf9068..0fe213cca2 100755
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryICommandCategoryListener.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryICommandCategoryListener.cpp
@@ -1,44 +1,44 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryICommandCategoryListener.h"
#include "berryCommandCategory.h"
#include "berryCommandCategoryEvent.h"
namespace berry {
void
ICommandCategoryListener::Events
::AddListener(ICommandCategoryListener::Pointer l)
{
if (l.IsNull()) return;
categoryChanged += Delegate(l.GetPointer(), &ICommandCategoryListener::CategoryChanged);
}
void
ICommandCategoryListener::Events
::RemoveListener(ICommandCategoryListener::Pointer l)
{
if (l.IsNull()) return;
categoryChanged -= Delegate(l.GetPointer(), &ICommandCategoryListener::CategoryChanged);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryICommandCategoryListener.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryICommandCategoryListener.h
index 43c4509da4..a4337297cf 100755
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryICommandCategoryListener.h
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryICommandCategoryListener.h
@@ -1,71 +1,71 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYICOMMANDCATEGORYLISTENER_H_
#define BERRYICOMMANDCATEGORYLISTENER_H_
#include <berryObject.h>
#include <berryMacros.h>
#include <berryMessage.h>
namespace berry {
class CommandCategoryEvent;
/**
* An instance of this interface can be used by clients to receive notification
* of changes to one or more instances of <code>Category</code>.
* <p>
* This interface may be implemented by clients.
* </p>
*
* @since 3.1
* @see CommandCategory#AddCategoryListener(ICommandCategoryListener)
* @see CommandCategory#RemoveCategoryListener(ICommandCategoryListener)
*/
struct ICommandCategoryListener : public virtual Object {
berryInterfaceMacro(ICommandCategoryListener, berry)
struct Events {
typedef Message1<const SmartPointer<const CommandCategoryEvent> > Event;
Event categoryChanged;
void AddListener(ICommandCategoryListener::Pointer listener);
void RemoveListener(ICommandCategoryListener::Pointer listener);
typedef MessageDelegate1<ICommandCategoryListener, const SmartPointer<const CommandCategoryEvent> > Delegate;
};
/**
* Notifies that one or more properties of an instance of
* <code>CommandCategory</code> have changed. Specific details are described in
* the <code>CommandCategoryEvent</code>.
*
* @param categoryEvent
* the category event. Guaranteed not to be <code>null</code>.
*/
virtual void CategoryChanged(const SmartPointer<const CommandCategoryEvent> categoryEvent) = 0;
};
}
#endif /* BERRYICOMMANDCATEGORYLISTENER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryICommandListener.cpp b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryICommandListener.cpp
index 3284ce8754..ba79b023f1 100755
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryICommandListener.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryICommandListener.cpp
@@ -1,47 +1,47 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryICommandListener.h"
#include "berryCommand.h"
#include "berryCommandEvent.h"
#include "berryCommandCategory.h"
#include "berryIHandler.h"
namespace berry {
void
ICommandListener::Events
::AddListener(ICommandListener::Pointer l)
{
if (l.IsNull()) return;
commandChanged += Delegate(l.GetPointer(), &ICommandListener::CommandChanged);
}
void
ICommandListener::Events
::RemoveListener(ICommandListener::Pointer l)
{
if (l.IsNull()) return;
commandChanged -= Delegate(l.GetPointer(), &ICommandListener::CommandChanged);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryICommandListener.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryICommandListener.h
index 15a806558c..77d6b6a675 100755
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryICommandListener.h
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryICommandListener.h
@@ -1,70 +1,70 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYICOMMANDLISTENER_H_
#define BERRYICOMMANDLISTENER_H_
#include <berryObject.h>
#include <berryMacros.h>
#include <berryMessage.h>
namespace berry {
class CommandEvent;
/**
* An instance of this interface can be used by clients to receive notification
* of changes to one or more instances of <code>Command</code>.
* <p>
* This interface may be implemented by clients.
* </p>
*
* @since 3.1
* @see Command#addCommandListener(ICommandListener)
* @see Command#removeCommandListener(ICommandListener)
*/
struct ICommandListener : public virtual Object {
berryInterfaceMacro(ICommandListener, berry)
struct Events {
typedef Message1<const SmartPointer<const CommandEvent> > Event;
Event commandChanged;
void AddListener(ICommandListener::Pointer listener);
void RemoveListener(ICommandListener::Pointer listener);
private:
typedef MessageDelegate1<ICommandListener, const SmartPointer<const CommandEvent> > Delegate;
};
/**
* Notifies that one or more properties of an instance of
* <code>Command</code> have changed. Specific details are described in
* the <code>CommandEvent</code>.
*
* @param commandEvent
* the command event. Guaranteed not to be <code>null</code>.
*/
virtual void CommandChanged(const SmartPointer<const CommandEvent> commandEvent) = 0;
};
}
#endif /* BERRYICOMMANDLISTENER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryICommandManagerListener.cpp b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryICommandManagerListener.cpp
index 57d43c4350..6fbe567a09 100755
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryICommandManagerListener.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryICommandManagerListener.cpp
@@ -1,45 +1,45 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryICommandManagerListener.h"
#include "berryCommandManagerEvent.h"
namespace berry
{
void ICommandManagerListener::Events::AddListener(
ICommandManagerListener::Pointer l)
{
if (l.IsNull())
return;
commandManagerChanged += Delegate(l.GetPointer(),
&ICommandManagerListener::CommandManagerChanged);
}
void ICommandManagerListener::Events::RemoveListener(
ICommandManagerListener::Pointer l)
{
if (l.IsNull())
return;
commandManagerChanged -= Delegate(l.GetPointer(),
&ICommandManagerListener::CommandManagerChanged);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryICommandManagerListener.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryICommandManagerListener.h
index b054353d9f..6056b7912d 100755
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryICommandManagerListener.h
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryICommandManagerListener.h
@@ -1,73 +1,73 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYICOMMANDMANAGERLISTENER_H_
#define BERRYICOMMANDMANAGERLISTENER_H_
#include <org_blueberry_core_commands_Export.h>
#include <berryObject.h>
#include <berryMacros.h>
namespace berry
{
class CommandManagerEvent;
/**
* An instance of this interface can be used by clients to receive notification
* of changes to one or more instances of <code>ICommandManager</code>.
* <p>
* This interface may be implemented by clients.
* </p>
*
* @since 3.1
* @see CommandManager#addCommandManagerListener(ICommandManagerListener)
* @see CommandManager#removeCommandManagerListener(ICommandManagerListener)
*/
struct BERRY_COMMANDS ICommandManagerListener: public virtual Object
{
berryInterfaceMacro(ICommandManagerListener, berry)
struct Events {
typedef Message1<const SmartPointer<const CommandManagerEvent> > Event;
Event commandManagerChanged;
void AddListener(ICommandManagerListener::Pointer listener);
void RemoveListener(ICommandManagerListener::Pointer listener);
private:
typedef MessageDelegate1<ICommandManagerListener, const SmartPointer<const CommandManagerEvent> > Delegate;
} ;
/**
* Notifies that one or more properties of an instance of
* <code>ICommandManager</code> have changed. Specific details are
* described in the <code>CommandManagerEvent</code>.
*
* @param commandManagerEvent
* the commandManager event. Guaranteed not to be
* <code>null</code>.
*/
virtual void CommandManagerChanged(const SmartPointer<const CommandManagerEvent> commandManagerEvent) = 0;
};
}
#endif /* BERRYICOMMANDMANAGERLISTENER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIExecutionListener.cpp b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIExecutionListener.cpp
index bd7169cfc3..b71beb20ba 100755
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIExecutionListener.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIExecutionListener.cpp
@@ -1,77 +1,77 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryIExecutionListener.h"
#include "berryIParameterValueConverter.h"
#include "berryExecutionEvent.h"
#include "berryCommandCategory.h"
#include "berryIHandler.h"
namespace berry {
IExecutionListener::Events::~Events()
{
}
void
IExecutionListener::Events
::AddListener(IExecutionListener::Pointer l)
{
if (l.IsNull()) return;
notHandled += NotHandledDelegate(l.GetPointer(), &IExecutionListener::NotHandled);
postExecuteFailure += PostExecuteFailureDelegate(l.GetPointer(), &IExecutionListener::PostExecuteFailure);
postExecuteSuccess += PostExecuteSuccessDelegate(l.GetPointer(), &IExecutionListener::PostExecuteSuccess);
preExecute += PreExecuteDelegate(l.GetPointer(), &IExecutionListener::PreExecute);
}
void
IExecutionListener::Events
::RemoveListener(IExecutionListener::Pointer l)
{
if (l.IsNull()) return;
notHandled -= NotHandledDelegate(l.GetPointer(), &IExecutionListener::NotHandled);
postExecuteFailure -= PostExecuteFailureDelegate(l.GetPointer(), &IExecutionListener::PostExecuteFailure);
postExecuteSuccess -= PostExecuteSuccessDelegate(l.GetPointer(), &IExecutionListener::PostExecuteSuccess);
preExecute -= PreExecuteDelegate(l.GetPointer(), &IExecutionListener::PreExecute);
}
bool
IExecutionListener::Events
::HasListeners() const
{
return notHandled.HasListeners() || postExecuteFailure.HasListeners() ||
postExecuteSuccess.HasListeners() || preExecute.HasListeners();
}
bool
IExecutionListener::Events
::IsEmpty() const
{
return !this->HasListeners();
}
IExecutionListener::~IExecutionListener()
{
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIExecutionListener.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIExecutionListener.h
index 76cbbe8980..91d1593d2b 100755
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIExecutionListener.h
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIExecutionListener.h
@@ -1,119 +1,119 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIEXECUTIONLISTENER_H_
#define BERRYIEXECUTIONLISTENER_H_
#include <berryObject.h>
#include <berryMacros.h>
#include <berryMessage.h>
#include <org_blueberry_core_commands_Export.h>
#include "common/berryCommandExceptions.h"
namespace berry {
class ExecutionEvent;
/**
* <p>
* A listener to the execution of commands. This listener will be notified if a
* command is about to execute, and when that execution completes. It is not
* possible for the listener to prevent the execution, only to respond to it in
* some way.
* </p>
*
* @since 3.1
*/
struct BERRY_COMMANDS IExecutionListener : public virtual Object {
berryInterfaceMacro(IExecutionListener, berry)
struct Events {
Message2<const std::string&, const NotHandledException*> notHandled;
Message2<const std::string&, const ExecutionException*> postExecuteFailure;
Message2<const std::string&, Object::Pointer> postExecuteSuccess;
Message2<const std::string&, const SmartPointer<const ExecutionEvent> > preExecute;
virtual ~Events();
virtual void AddListener(IExecutionListener::Pointer listener);
virtual void RemoveListener(IExecutionListener::Pointer listener);
virtual bool HasListeners() const;
virtual bool IsEmpty() const;
typedef MessageDelegate2<IExecutionListener, const std::string&, const NotHandledException* > NotHandledDelegate;
typedef MessageDelegate2<IExecutionListener, const std::string&, const ExecutionException*> PostExecuteFailureDelegate;
typedef MessageDelegate2<IExecutionListener, const std::string&, Object::Pointer> PostExecuteSuccessDelegate;
typedef MessageDelegate2<IExecutionListener, const std::string&, const SmartPointer<const ExecutionEvent> > PreExecuteDelegate;
};
virtual ~IExecutionListener();
/**
* Notifies the listener that an attempt was made to execute a command with
* no handler.
*
* @param commandId
* The identifier of command that is not handled; never
* <code>null</code>
* @param exception
* The exception that occurred; never <code>null</code>.
*/
virtual void NotHandled(const std::string& commandId, const NotHandledException* exception) = 0;
/**
* Notifies the listener that a command has failed to complete execution.
*
* @param commandId
* The identifier of the command that has executed; never
* <code>null</code>.
* @param exception
* The exception that occurred; never <code>null</code>.
*/
virtual void PostExecuteFailure(const std::string& commandId,
const ExecutionException* exception) = 0;
/**
* Notifies the listener that a command has completed execution
* successfully.
*
* @param commandId
* The identifier of the command that has executed; never
* <code>null</code>.
* @param returnValue
* The return value from the command; may be <code>null</code>.
*/
virtual void PostExecuteSuccess(const std::string& commandId, const Object::Pointer returnValue) = 0;
/**
* Notifies the listener that a command is about to execute.
*
* @param commandId
* The identifier of the command that is about to execute, never
* <code>null</code>.
* @param event
* The event that will be passed to the <code>execute</code>
* method; never <code>null</code>.
*/
virtual void PreExecute(const std::string& commandId, const SmartPointer<const ExecutionEvent> event) = 0;
};
}
#endif /* BERRYIEXECUTIONLISTENER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIExecutionListenerWithChecks.cpp b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIExecutionListenerWithChecks.cpp
index 25432b5b02..ea260eec1e 100755
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIExecutionListenerWithChecks.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIExecutionListenerWithChecks.cpp
@@ -1,71 +1,71 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryIExecutionListenerWithChecks.h"
#include "berryExecutionEvent.h"
#include "berryIParameterValueConverter.h"
#include "berryCommandCategory.h"
#include "berryIHandler.h"
namespace berry {
void
IExecutionListenerWithChecks::Events
::AddListener(IExecutionListener::Pointer l)
{
if (l.IsNull()) return;
IExecutionListener::Events::AddListener(l);
if (IExecutionListenerWithChecks::Pointer cl = l.Cast<IExecutionListenerWithChecks>())
{
notDefined += NotDefinedDelegate(cl.GetPointer(), &IExecutionListenerWithChecks::NotDefined);
notEnabled += NotEnabledDelegate(cl.GetPointer(), &IExecutionListenerWithChecks::NotEnabled);
}
}
void
IExecutionListenerWithChecks::Events
::RemoveListener(IExecutionListener::Pointer l)
{
if (l.IsNull()) return;
IExecutionListener::Events::RemoveListener(l);
if (IExecutionListenerWithChecks::Pointer cl = l.Cast<IExecutionListenerWithChecks>())
{
notDefined -= NotDefinedDelegate(cl.GetPointer(), &IExecutionListenerWithChecks::NotDefined);
notEnabled -= NotEnabledDelegate(cl.GetPointer(), &IExecutionListenerWithChecks::NotEnabled);
}
}
bool
IExecutionListenerWithChecks::Events
::HasListeners() const
{
return IExecutionListener::Events::HasListeners() || notDefined.HasListeners() ||
notEnabled.HasListeners();
}
bool
IExecutionListenerWithChecks::Events
::IsEmpty() const
{
return !this->HasListeners();
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIExecutionListenerWithChecks.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIExecutionListenerWithChecks.h
index de6f0ee149..5fe0444fb3 100755
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIExecutionListenerWithChecks.h
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIExecutionListenerWithChecks.h
@@ -1,85 +1,85 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIEXECUTIONLISTENERWITHCHECKS_H_
#define BERRYIEXECUTIONLISTENERWITHCHECKS_H_
#include "berryIExecutionListener.h"
#include "common/berryCommandExceptions.h"
namespace berry {
/**
* <p>
* A listener to the execution of commands. This listener will be notified if
* someone tries to execute a command and it is not enabled or not defined. The
* listener also be notified if a command is about to execute, and when that
* execution completes. It is not possible for the listener to prevent the
* execution, only to respond to it in some way.
* </p>
* <p>
* Clients may implement.
* </p>
*
* @since 3.2
*/
struct IExecutionListenerWithChecks : public IExecutionListener {
berryInterfaceMacro(IExecutionListenerWithChecks, berry)
struct Events : public IExecutionListener::Events {
Message2<const std::string&, const NotDefinedException*> notDefined;
Message2<const std::string&, const NotEnabledException*> notEnabled;
void AddListener(IExecutionListener::Pointer listener);
void RemoveListener(IExecutionListener::Pointer listener);
bool HasListeners() const;
bool IsEmpty() const;
typedef MessageDelegate2<IExecutionListenerWithChecks, const std::string&, const NotDefinedException* > NotDefinedDelegate;
typedef MessageDelegate2<IExecutionListenerWithChecks, const std::string&, const NotEnabledException*> NotEnabledDelegate;
};
/**
* Notifies the listener that an attempt was made to execute a command that
* is not defined.
*
* @param commandId
* The identifier of command that is not defined; never
* <code>null</code>
* @param exception
* The exception that occurred; never <code>null</code>.
*/
virtual void NotDefined(const std::string& commandId, const NotDefinedException* exception) = 0;
/**
* Notifies the listener that an attempt was made to execute a command that
* is disabled.
*
* @param commandId
* The identifier of command that is not enabled; never
* <code>null</code>
* @param exception
* The exception that occurred; never <code>null</code>.
*/
virtual void NotEnabled(const std::string& commandId, const NotEnabledException* exception) = 0;
};
}
#endif /* BERRYIEXECUTIONLISTENERWITHCHECKS_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIHandler.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIHandler.h
index bab7c034bf..3ab9d04e59 100644
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIHandler.h
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIHandler.h
@@ -1,123 +1,123 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIHANDLER_H_
#define BERRYIHANDLER_H_
#include <berryMacros.h>
#include <berryObject.h>
#include <org_blueberry_core_commands_Export.h>
namespace berry {
struct IHandlerListener;
class ExecutionEvent;
/**
* A handler is the pluggable piece of a command that handles execution. Each
* command can have zero or more handlers associated with it (in general), of
* which only one will be active at any given moment in time. When the command
* is asked to execute, it will simply pass that request on to its active
* handler, if any.
*
* @see AbstractHandler
* @since 3.1
*/
struct BERRY_COMMANDS IHandler : public Object {
berryInterfaceMacro(IHandler, berry)
/**
* Registers an instance of <code>IHandlerListener</code> to listen for
* changes to properties of this instance.
*
* @param handlerListener
* the instance to register. Must not be <code>null</code>. If
* an attempt is made to register an instance which is already
* registered with this instance, no operation is performed.
*/
virtual void AddHandlerListener(SmartPointer<IHandlerListener> handlerListener) = 0;
/**
* Disposes of this handler. This can be used as an opportunity to unhook listeners
* from other objects.
*/
virtual ~IHandler() {}
/**
* Executes with the map of parameter values by name.
*
* @param event
* An event containing all the information about the current
* state of the application; must not be <code>null</code>.
* @return the result of the execution. Reserved for future use, must be
* <code>null</code>.
* @throws ExecutionException
* if an exception occurred during execution.
*/
virtual Object::Pointer Execute(const SmartPointer<const ExecutionEvent> event) = 0;
/**
* Called by the framework to allow the handler to update its enabled state.
*
* @param evaluationContext
* the state to evaluate against. May be <code>null</code>
* which indicates that the handler can query whatever model that
* is necessary. This context must not be cached.
*/
virtual void SetEnabled(Object::ConstPointer evaluationContext) = 0;
/**
* Returns whether this handler is capable of executing at this moment in
* time. If the enabled state is other than true clients should also
* consider implementing IHandler2 so they can be notified about framework
* execution contexts.
*
* @return <code>true</code> if the command is enabled; <code>false</code>
* otherwise.
* @see IHandler2#setEnabled(Object)
*/
virtual bool IsEnabled() const = 0;
/**
* Returns whether this handler is really capable of handling delegation. In
* the case of a handler that is a composition of other handlers, this reply
* is intended to indicate whether the handler is truly capable of receiving
* delegated responsibilities at this time.
*
* @return <code>true</code> if the handler is handled; <code>false</code>
* otherwise.
*/
virtual bool IsHandled() const = 0;
/**
* Unregisters an instance of <code>IHandlerListener</code> listening for
* changes to properties of this instance.
*
* @param handlerListener
* the instance to unregister. Must not be <code>null</code>.
* If an attempt is made to unregister an instance which is not
* already registered with this instance, no operation is
* performed.
*/
virtual void RemoveHandlerListener(SmartPointer<IHandlerListener> handlerListener) = 0;
};
}
#endif /*BERRYIHANDLER_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIHandlerListener.cpp b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIHandlerListener.cpp
index 9d0882341b..058b826a9b 100755
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIHandlerListener.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIHandlerListener.cpp
@@ -1,43 +1,43 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryIHandlerListener.h"
#include "berryIHandler.h"
#include "berryHandlerEvent.h"
namespace berry {
void
IHandlerListener::Events
::AddListener(IHandlerListener::Pointer l)
{
if (l.IsNull()) return;
handlerChanged += Delegate(l.GetPointer(), &IHandlerListener::HandlerChanged);
}
void
IHandlerListener::Events
::RemoveListener(IHandlerListener::Pointer l)
{
if (l.IsNull()) return;
handlerChanged -= Delegate(l.GetPointer(), &IHandlerListener::HandlerChanged);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIHandlerListener.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIHandlerListener.h
index ef60e07122..ca440892e1 100755
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIHandlerListener.h
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIHandlerListener.h
@@ -1,72 +1,72 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIHANDLERLISTENER_H_
#define BERRYIHANDLERLISTENER_H_
#include <berryObject.h>
#include <berryMacros.h>
#include <berryMessage.h>
#include <org_blueberry_core_commands_Export.h>
namespace berry {
class HandlerEvent;
/**
* An instance of this interface can be used by clients to receive notification
* of changes to one or more instances of <code>IHandler</code>.
* <p>
* This interface may be implemented by clients.
* </p>
*
* @since 3.1
* @see IHandler#addHandlerListener(IHandlerListener)
* @see IHandler#removeHandlerListener(IHandlerListener)
*/
struct BERRY_COMMANDS IHandlerListener : public virtual Object {
berryInterfaceMacro(IHandlerListener, berry)
struct Events {
typedef Message1<SmartPointer<HandlerEvent> > Event;
Event handlerChanged;
void AddListener(IHandlerListener::Pointer listener);
void RemoveListener(IHandlerListener::Pointer listener);
private:
typedef MessageDelegate1<IHandlerListener, SmartPointer<HandlerEvent> > Delegate;
};
/**
* Notifies that one or more properties of an instance of
* <code>IHandler</code> have changed. Specific details are described in
* the <code>HandlerEvent</code>.
*
* @param handlerEvent
* the handler event. Guaranteed not to be <code>null</code>.
*/
virtual void HandlerChanged(SmartPointer<HandlerEvent> handlerEvent) = 0;
};
}
#endif /* BERRYIHANDLERLISTENER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryINamedHandleStateIds.cpp b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryINamedHandleStateIds.cpp
index 6e70db9e60..512c448aee 100755
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryINamedHandleStateIds.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryINamedHandleStateIds.cpp
@@ -1,25 +1,25 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryINamedHandleStateIds.h"
namespace berry {
const std::string INamedHandleStateIds::DESCRIPTION = "DESCRIPTION";
const std::string INamedHandleStateIds::NAME = "NAME";
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryINamedHandleStateIds.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryINamedHandleStateIds.h
index efb803422d..7605f9b965 100755
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryINamedHandleStateIds.h
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryINamedHandleStateIds.h
@@ -1,52 +1,52 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYINAMEDHANDLESTATEIDS_H_
#define BERRYINAMEDHANDLESTATEIDS_H_
#include <string>
namespace berry {
/**
* <p>
* State identifiers that are understood by named handle objects that implement
* {@link IObjectWithState}.
* </p>
* <p>
* Clients may implement or extend this class.
* </p>
*
*/
struct INamedHandleStateIds {
/**
* The state id used for overriding the description of a named handle
* object. This state's value must return a {@link String}.
*/
static const std::string DESCRIPTION; // = "DESCRIPTION";
/**
* The state id used for overriding the name of a named handle object. This
* state's value must return a {@link String}.
*/
static const std::string NAME; // = "NAME";
};
}
#endif /* BERRYINAMEDHANDLESTATEIDS_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIObjectWithState.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIObjectWithState.h
index bdc56b7910..b157b7df0a 100644
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIObjectWithState.h
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIObjectWithState.h
@@ -1,86 +1,86 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIOBJECTWITHSTATE_H_
#define BERRYIOBJECTWITHSTATE_H_
#include <org_blueberry_core_commands_Export.h>
#include "berryState.h"
#include <vector>
namespace berry {
/**
* <p>
* An object that holds zero or more state objects. This state information can
* be shared between different instances of <code>IObjectWithState</code>.
* </p>
* <p>
* Clients may implement, but must not extend this interface.
* </p>
*
* @see AbstractHandlerWithState
* @since 3.2
*/
struct BERRY_COMMANDS IObjectWithState : public virtual Object {
berryInterfaceMacro(IObjectWithState, berry)
/**
* Adds state to this object.
*
* @param id
* The identifier indicating the type of state being added; must
* not be <code>null</code>.
* @param state
* The new state to add to this object; must not be
* <code>null</code>.
*/
virtual void AddState(const std::string& id, const State::Pointer state) = 0;
/**
* Gets the state with the given id.
*
* @param stateId
* The identifier of the state to retrieve; must not be
* <code>null</code>.
* @return The state; may be <code>null</code> if there is no state with
* the given id.
*/
virtual State::Pointer GetState(const std::string& stateId) const = 0;
/**
* Gets the identifiers for all of the state associated with this object.
*
* @return All of the state identifiers; may be empty, but never
* <code>null</code>.
*/
virtual std::vector<std::string> GetStateIds() const = 0;
/**
* Removes state from this object.
*
* @param stateId
* The id of the state to remove from this object; must not be
* <code>null</code>.
*/
virtual void RemoveState(const std::string& stateId) = 0;
};
}
#endif /*BERRYIOBJECTWITHSTATE_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIParameter.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIParameter.h
index 0bb0ce00c7..a01eb77201 100644
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIParameter.h
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIParameter.h
@@ -1,79 +1,79 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIPARAMETER_H_
#define BERRYIPARAMETER_H_
#include <berryObject.h>
#include <berryMacros.h>
#include <org_blueberry_core_commands_Export.h>
#include <map>
namespace berry {
/**
* <p>
* A parameter for a command. A parameter identifies a type of information that
* the command might accept. For example, a "Show View" command might accept the
* id of a view for display. This parameter also identifies possible values, for
* display in the user interface.
* </p>
*
* @since 3.1
*/
struct BERRY_COMMANDS IParameter : public virtual Object {
berryInterfaceMacro(IParameter, berry);
typedef std::map<std::string, std::string> ParameterValues;
/**
* Returns the identifier for this parameter.
*
* @return The identifier; never <code>null</code>.
*/
virtual std::string GetId() const = 0;
/**
* Returns the human-readable name for this parameter.
*
* @return The parameter name; never <code>null</code>.
*/
virtual std::string GetName() const = 0;
/**
* Returns the values associated with this parameter.
*
* @return The values associated with this parameter. This must not be
* <code>null</code>.
* @throws ParameterValuesException
* If the values can't be retrieved for some reason.
*/
virtual ParameterValues GetValues() const = 0;
/**
* Returns whether parameter is optional. Otherwise, it is required.
*
* @return <code>true</code> if the parameter is optional;
* <code>false</code> if it is required.
*/
virtual bool IsOptional() const = 0;
};
}
#endif /*BERRYIPARAMETER_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIParameterTypeListener.cpp b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIParameterTypeListener.cpp
index 09bf6d313f..a77a53973b 100755
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIParameterTypeListener.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIParameterTypeListener.cpp
@@ -1,43 +1,43 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryIParameterTypeListener.h"
#include "berryParameterTypeEvent.h"
#include "berryParameterType.h"
namespace berry {
void
IParameterTypeListener::Events
::AddListener(IParameterTypeListener::Pointer l)
{
if (l.IsNull()) return;
parameterTypeChanged += Delegate(l.GetPointer(), &IParameterTypeListener::ParameterTypeChanged);
}
void
IParameterTypeListener::Events
::RemoveListener(IParameterTypeListener::Pointer l)
{
if (l.IsNull()) return;
parameterTypeChanged -= Delegate(l.GetPointer(), &IParameterTypeListener::ParameterTypeChanged);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIParameterTypeListener.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIParameterTypeListener.h
index abd3890408..aec28fd909 100755
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIParameterTypeListener.h
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIParameterTypeListener.h
@@ -1,72 +1,72 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIPARAMETERTYPELISTENER_H_
#define BERRYIPARAMETERTYPELISTENER_H_
#include <berryObject.h>
#include <berryMacros.h>
#include <berryMessage.h>
#include <org_blueberry_core_commands_Export.h>
namespace berry {
class ParameterTypeEvent;
/**
* An instance of this interface can be used by clients to receive notification
* of changes to one or more instances of {@link ParameterType}.
* <p>
* This interface may be implemented by clients.
* </p>
*
* @see ParameterType#AddListener(IParameterTypeListener::Pointer)
* @see ParameterType#RemoveListener(IParameterTypeListener::Pointer)
*/
struct BERRY_COMMANDS IParameterTypeListener : public virtual Object {
berryInterfaceMacro(IParameterTypeListener, berry)
struct Events {
typedef Message1<const SmartPointer<const ParameterTypeEvent> > Event;
Event parameterTypeChanged;
void AddListener(IParameterTypeListener::Pointer listener);
void RemoveListener(IParameterTypeListener::Pointer listener);
typedef MessageDelegate1<IParameterTypeListener, const SmartPointer<const ParameterTypeEvent> > Delegate;
};
/**
* Notifies that one or more properties of an instance of
* {@link ParameterType} have changed. Specific details are described in the
* {@link ParameterTypeEvent}.
*
* @param parameterTypeEvent
* the event. Guaranteed not to be <code>null</code>.
*/
virtual void ParameterTypeChanged(const SmartPointer<const ParameterTypeEvent> parameterTypeEvent) = 0;
};
}
#endif /* BERRYIPARAMETERTYPELISTENER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIParameterValueConverter.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIParameterValueConverter.h
index 649b4b71e0..8993152bcd 100755
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIParameterValueConverter.h
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIParameterValueConverter.h
@@ -1,109 +1,109 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYABSTRACTPARAMETERVALUECONVERTER_H_
#define BERRYABSTRACTPARAMETERVALUECONVERTER_H_
#include <berryObject.h>
#include <berryMacros.h>
#include "common/berryCommandExceptions.h"
#include <org_blueberry_core_commands_Export.h>
namespace berry {
/**
* <p>
* Supports conversion between objects and strings for command parameter values.
* Extenders must produce strings that identify objects (of a specific command
* parameter type) as well as consume the strings to locate and return the
* objects they identify.
* </p>
* <p>
* This class offers multiple handlers of a command a consistent way of
* converting string parameter values into the objects that the handlers would
* prefer to deal with. This class also gives clients a way to serialize
* object parameters as strings so that entire parameterized commands can be
* serialized, stored and later deserialized and executed.
* </p>
* <p>
* This class will typically be extended so the subclass can be referenced from
* the <code>converter</code> attribute of the
* <code>commandParameterType</code> elemement of the
* <code>org.eclipse.ui.commands</code> extension-point. Objects implementing
* this interface may also be passed directly to
* {@link ParameterType#Define(IParameterValueConverter::Pointer)} by
* clients.
* </p>
*
* @see ParameterType#Define(IParameterValueConverter::Pointer)
* @see ParameterizedCommand#Serialize()
*/
struct BERRY_COMMANDS IParameterValueConverter : public virtual Object {
berryInterfaceMacro(IParameterValueConverter, berry)
/**
* Returns whether the provided value is compatible with this parameter
* value converter. An object is compatible with a converter if the object is an
* instance of the class defined in the <code>type</code> attribute of
* the <code>commandParameterType</code> element.
*
* @param value
* an object to check for compatibility with this parameter type;
* may be <code>null</code>.
* @return <code>true</code> if the value is compatible with this converter,
* <code>false</code> otherwise
*/
virtual bool IsCompatible(const Object::ConstPointer value) const = 0;
/**
* Converts a string encoded command parameter value into the parameter
* value object.
*
* @param parameterValue
* a command parameter value string describing an object; may be
* <code>null</code>
* @return the object described by the command parameter value string; may
* be <code>null</code>
* @throws ParameterValueConversionException
* if an object cannot be produced from the
* <code>parameterValue</code> string
*/
virtual Object::Pointer ConvertToObject(const std::string& parameterValue)
throw(ParameterValueConversionException) = 0;
/**
* Converts a command parameter value object into a string that encodes a
* reference to the object or serialization of the object.
*
* @param parameterValue
* an object to convert into an identifying string; may be
* <code>null</code>
* @return a string describing the provided object; may be <code>null</code>
* @throws ParameterValueConversionException
* if a string reference or serialization cannot be provided for
* the <code>parameterValue</code>
*/
virtual std::string ConvertToString(const Object::Pointer parameterValue)
throw(ParameterValueConversionException) = 0;
};
}
#endif /* BERRYABSTRACTPARAMETERVALUECONVERTER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIStateListener.cpp b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIStateListener.cpp
index a784736704..e20ca58341 100755
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIStateListener.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIStateListener.cpp
@@ -1,43 +1,43 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryIStateListener.h"
#include "berryState.h"
namespace berry {
void
IStateListener::Events
::AddListener(IStateListener::Pointer l)
{
if (l.IsNull()) return;
stateChanged += Delegate(l.GetPointer(), &IStateListener::HandleStateChange);
}
void
IStateListener::Events
::RemoveListener(IStateListener::Pointer l)
{
if (l.IsNull()) return;
stateChanged -= Delegate(l.GetPointer(), &IStateListener::HandleStateChange);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIStateListener.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIStateListener.h
index 70dd1f952e..8bc3d62a3e 100755
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIStateListener.h
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryIStateListener.h
@@ -1,72 +1,72 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYISTATELISTENER_H_
#define BERRYISTATELISTENER_H_
#include "berryObject.h"
#include "berryMacros.h"
#include <org_blueberry_core_commands_Export.h>
namespace berry {
class State;
/**
* <p>
* A listener to changes in some state.
* </p>
* <p>
* Clients may implement, but must not extend this interface.
* </p>
*
* @since 3.2
*/
struct BERRY_COMMANDS IStateListener : public virtual Object {
berryInterfaceMacro(IStateListener, berry)
struct Events {
typedef Message2<SmartPointer<State>, Object::Pointer> StateEvent;
StateEvent stateChanged;
void AddListener(IStateListener::Pointer listener);
void RemoveListener(IStateListener::Pointer listener);
private:
typedef MessageDelegate2<IStateListener, SmartPointer<State>, Object::Pointer> Delegate;
};
/**
* Handles a change to the value in some state.
*
* @param state
* The state that has changed; never <code>null</code>. The
* value for this state has been updated to the new value.
* @param oldValue
* The old value; may be anything.
*/
virtual void HandleStateChange(SmartPointer<State> state, Object::Pointer oldValue) = 0;
};
}
#endif /* BERRYISTATELISTENER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryITypedParameter.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryITypedParameter.h
index ad23ff2fe5..018088dbac 100755
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryITypedParameter.h
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryITypedParameter.h
@@ -1,55 +1,55 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYITYPEDPARAMETER_H_
#define BERRYITYPEDPARAMETER_H_
#include <berryObject.h>
#include <berryMacros.h>
#include <org_blueberry_core_commands_Export.h>
namespace berry {
class ParameterType;
/**
* A command parameter that has a declared type. This interface is intended to
* be implemented by implementors of {@link IParameter} that will support
* parameter types.
*
*/
struct BERRY_COMMANDS ITypedParameter : public virtual Object {
berryInterfaceMacro(ITypedParameter, berry)
/**
* Returns the {@link ParameterType} associated with a command parameter or
* <code>null</code> if the parameter does not declare a type.
* <p>
* Note that the parameter type returned may be undefined.
* </p>
*
* @return the parameter type associated with a command parameter or
* <code>null</code> if the parameter does not declare a type
*/
virtual SmartPointer<ParameterType> GetParameterType() = 0;
};
}
#endif /* BERRYITYPEDPARAMETER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryNamedHandleObjectWithState.cpp b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryNamedHandleObjectWithState.cpp
index efcbd8f46e..e1712848dd 100644
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryNamedHandleObjectWithState.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryNamedHandleObjectWithState.cpp
@@ -1,116 +1,116 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryNamedHandleObjectWithState.h"
#include "berryINamedHandleStateIds.h"
#include <Poco/Exception.h>
namespace berry
{
void NamedHandleObjectWithState::AddState(const std::string& stateId,
const State::Pointer state)
{
if (!state)
{
throw Poco::NullPointerException("Cannot add a null state"); //$NON-NLS-1$
}
states[stateId] = state;
}
std::string NamedHandleObjectWithState::GetDescription() const
{
const std::string description(NamedHandleObject::GetDescription()); // Trigger a NDE.
const State::ConstPointer
descriptionState(this->GetState(INamedHandleStateIds::DESCRIPTION));
if (descriptionState.IsNotNull())
{
const Object::ConstPointer value(descriptionState->GetValue());
if (value.IsNotNull())
{
return value->ToString();
}
}
return description;
}
std::string NamedHandleObjectWithState::GetName() const
{
const std::string name(NamedHandleObject::GetName()); // Trigger a NDE, if necessary.
const State::ConstPointer
nameState(this->GetState(INamedHandleStateIds::NAME));
if (nameState.IsNotNull())
{
const Object::ConstPointer value(nameState->GetValue());
if (value.IsNotNull())
{
return value->ToString();
}
}
return name;
}
State::Pointer NamedHandleObjectWithState::GetState(
const std::string& stateId) const
{
if (states.empty())
{
return State::Pointer(0);
}
std::map<std::string, State::Pointer>::const_iterator iter = states.find(stateId);
return iter->second;
}
std::vector<std::string> NamedHandleObjectWithState::GetStateIds() const
{
if (states.empty())
{
return std::vector<std::string>();
}
std::vector<std::string> stateIds;
for (std::map<std::string, State::Pointer>::const_iterator iter = states.begin();
iter != states.end(); ++iter)
{
stateIds.push_back(iter->first);
}
return stateIds;
}
void NamedHandleObjectWithState::RemoveState(const std::string& id)
{
if (id.empty())
{
throw Poco::InvalidArgumentException("Cannot remove an empty id"); //$NON-NLS-1$
}
states.erase(id);
}
NamedHandleObjectWithState::NamedHandleObjectWithState(const std::string& id)
: NamedHandleObject(id)
{
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryNamedHandleObjectWithState.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryNamedHandleObjectWithState.h
index 6f2ada4837..8922b87b88 100644
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryNamedHandleObjectWithState.h
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryNamedHandleObjectWithState.h
@@ -1,79 +1,79 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYNAMEDHANDLEOBJECTWITHSTATE_H_
#define BERRYNAMEDHANDLEOBJECTWITHSTATE_H_
#include "common/berryNamedHandleObject.h"
#include "berryIObjectWithState.h"
#include <vector>
#include <map>
namespace berry {
/**
* <p>
* A named handle object that can carry state with it. This state can be used to
* override the name or description.
* </p>
* <p>
* Clients may neither instantiate nor extend this class.
* </p>
*
* @since 3.2
*/
class BERRY_COMMANDS NamedHandleObjectWithState : public NamedHandleObject, public IObjectWithState {
public:
berryObjectMacro(NamedHandleObjectWithState);
void AddState(const std::string& stateId, const State::Pointer state);
std::string GetDescription() const;
std::string GetName() const;
State::Pointer GetState(const std::string& stateId) const;
std::vector<std::string> GetStateIds() const;
void RemoveState(const std::string& id);
private:
/**
* The map of states currently held by this command. If this command has no
* state, then this will be empty.
*/
std::map<std::string, State::Pointer> states;
protected:
/**
* Constructs a new instance of <code>NamedHandleObject<WithState/code>.
*
* @param id
* The identifier for this handle; must not be empty.
*/
NamedHandleObjectWithState(const std::string& id);
};
}
#endif /*BERRYNAMEDHANDLEOBJECTWITHSTATE_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryParameterType.cpp b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryParameterType.cpp
index d47e38b6a2..a6e027a6ed 100755
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryParameterType.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryParameterType.cpp
@@ -1,128 +1,128 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryParameterType.h"
#include "internal/berryCommandUtils.h"
#include "common/berryCommandExceptions.h"
#include "berryParameterTypeEvent.h"
#include "berryIParameterValueConverter.h"
#include <sstream>
namespace berry
{
void ParameterType::AddListener(const IParameterTypeListener::Pointer listener)
{
parameterTypeEvents.AddListener(listener);
}
bool ParameterType::operator<(const Object* object) const
{
const ParameterType* castedObject = dynamic_cast<const ParameterType*>(object);
int compareTo = CommandUtils::Compare(defined, castedObject->defined);
if (compareTo == 0)
{
compareTo = CommandUtils::Compare(id, castedObject->id);
}
return compareTo < 0;
}
void ParameterType::Define(
const SmartPointer<IParameterValueConverter> parameterTypeConverter)
{
const bool definedChanged = !this->defined;
this->defined = true;
this->parameterTypeConverter = parameterTypeConverter;
ParameterTypeEvent::Pointer event(
new ParameterTypeEvent(ParameterType::Pointer(this), definedChanged));
this->FireParameterTypeChanged(event);
}
SmartPointer<IParameterValueConverter> ParameterType::GetValueConverter() const
{
if (!this->IsDefined())
{
throw NotDefinedException(
"Cannot use GetValueConverter() with an undefined ParameterType"); //$NON-NLS-1$
}
return parameterTypeConverter;
}
bool ParameterType::IsCompatible(const Object::ConstPointer value) const
{
if (!this->IsDefined())
{
throw NotDefinedException(
"Cannot use IsCompatible() with an undefined ParameterType"); //$NON-NLS-1$
}
return parameterTypeConverter->IsCompatible(value);
}
void ParameterType::RemoveListener(
const IParameterTypeListener::Pointer listener)
{
parameterTypeEvents.RemoveListener(listener);
}
std::string ParameterType::ToString() const
{
if (str.empty())
{
std::stringstream stringBuffer;
stringBuffer << "ParameterType(" << id << "," << defined << ")";
str = stringBuffer.str();
}
return str;
}
void ParameterType::Undefine()
{
str = "";
const bool definedChanged = defined;
defined = false;
parameterTypeConverter = 0;
ParameterTypeEvent::Pointer event(
new ParameterTypeEvent(ParameterType::Pointer(this), definedChanged));
this->FireParameterTypeChanged(event);
}
ParameterType::ParameterType(const std::string& id) :
HandleObject(id)
{
}
void ParameterType::FireParameterTypeChanged(const SmartPointer<
ParameterTypeEvent> event)
{
if (!event)
{
throw Poco::NullPointerException("Cannot send a null event to listeners."); //$NON-NLS-1$
}
parameterTypeEvents.parameterTypeChanged(event);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryParameterType.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryParameterType.h
index a52dd07eb2..baaeb6b6ca 100755
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryParameterType.h
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryParameterType.h
@@ -1,193 +1,193 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYPARAMETERTYPE_H_
#define BERRYPARAMETERTYPE_H_
#include "common/berryHandleObject.h"
#include "berryIParameterTypeListener.h"
#include "berryIParameterValueConverter.h"
namespace berry
{
struct IParameterValueConverter;
/**
* <p>
* Provides information about the type of a command parameter. Clients can use a
* parameter type to check if an object matches the type of the parameter with
* {@link #IsCompatible(Object::Pointer)} and can get an
* {@link IParameterValueConverter} to convert between objects matching
* the parameter type and strings that encode the object's identity.
* </p>
* <p>
* A command parameter is not required to declare a type. To determine if a
* given parameter has a type, check if an {@link IParameter} implements
* {@link ITypedParameter} and if so, use
* {@link ITypedParameter#GetParameterType()} like this:
* </p>
*
* <pre>
* IParameter::Pointer parameter = // ... get IParameter from Command
* if (ITypedParameter::Pointer typedParameter = parameter.Cast<ITypedParameter>())
* {
* ParameterType::Pointer type = typedParameter->GetParameterType();
* if (type) {
* // this parameter has a ParameterType
* }
* }
* </pre>
*
* @see IParameter
* @see ITypedParameter#GetParameterType()
*/
class BERRY_COMMANDS ParameterType: public HandleObject
{ //implements Comparable {
public:
berryObjectMacro(ParameterType)
/**
* Adds a listener to this parameter type that will be notified when its
* state changes.
*
* @param listener
* The listener to be added; must not be <code>null</code>.
*/
void AddListener(const IParameterTypeListener::Pointer listener);
/**
* Compares this parameter type with another object by comparing each of the
* non-transient attributes.
*
* @param object
* The object with which to compare; must be an instance of
* {@link ParameterType}.
* @return A negative integer, zero or a positive integer, if the object is
* greater than, equal to or less than this parameter type.
*/
bool operator<(const Object* object) const;
/**
* <p>
* Defines this parameter type, setting the defined property to
* <code>true</code>.
* </p>
* <p>
* Notification is sent to all listeners that something has changed.
* </p>
*
* @param parameterTypeConverter
* an {@link AbstractParameterValueConverter} to perform
* string/object conversions for parameter values; may be
* <code>null</code>
*/
void Define(const SmartPointer<IParameterValueConverter> parameterTypeConverter);
/**
* Returns the value converter associated with this parameter, if any.
*
* @return The parameter value converter, or <code>null</code> if there is
* no value converter for this parameter.
* @throws NotDefinedException
* if the parameter type is not currently defined
*/
SmartPointer<IParameterValueConverter> GetValueConverter() const;
/**
* Returns whether the provided value is compatible with this parameter
* type. An object is compatible with a parameter type if the object is an
* instance of the class defined as the parameter's type class.
*
* @param value
* an object to check for compatibility with this parameter type;
* may be <code>null</code>.
* @return <code>true</code> if the value is compatible with this type,
* <code>false</code> otherwise
* @throws NotDefinedException
* if the parameter type is not currently defined
*/
bool IsCompatible(const Object::ConstPointer value) const;
/**
* Unregisters listener for changes to properties of this parameter type.
*
* @param listener
* the instance to unregister. Must not be <code>null</code>.
* If an attempt is made to unregister an instance which is not
* already registered with this instance, no operation is
* performed.
*/
void RemoveListener(const IParameterTypeListener::Pointer listener);
/**
* The string representation of this parameter type. For debugging purposes
* only. This string should not be shown to an end user.
*
* @return The string representation; never <code>null</code>.
*/
std::string ToString() const;
/**
* Makes this parameter type become undefined. Notification is sent to all
* listeners.
*/
void Undefine();
protected:
friend class CommandManager;
/**
* Constructs a new instance based on the given identifier. When a parameter
* type is first constructed, it is undefined. Parameter types should only
* be constructed by the {@link CommandManager} to ensure that the
* identifier remains unique.
*
* @param id
* The identifier for this type. This value must not be
* <code>null</code>, and must be unique amongst all parameter
* types.
*/
ParameterType(const std::string& id);
private:
/**
* Notifies all listeners that this parameter type has changed. This sends
* the given event to all of the listeners, if any.
*
* @param event
* The event to send to the listeners; must not be
* <code>null</code>.
*/
void FireParameterTypeChanged(const SmartPointer<ParameterTypeEvent> event);
/**
* An {@link AbstractParameterValueConverter} for converting parameter
* values between objects and strings. This may be <code>null</code>.
*/
SmartPointer<IParameterValueConverter> parameterTypeConverter;
IParameterTypeListener::Events parameterTypeEvents;
};
}
#endif /* BERRYPARAMETERTYPE_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryParameterTypeEvent.cpp b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryParameterTypeEvent.cpp
index f473b74b6f..0366f4231c 100755
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryParameterTypeEvent.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryParameterTypeEvent.cpp
@@ -1,38 +1,38 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryParameterTypeEvent.h"
#include "berryParameterType.h"
namespace berry
{
SmartPointer<ParameterType> ParameterTypeEvent::GetParameterType() const
{
return parameterType;
}
ParameterTypeEvent::ParameterTypeEvent(
const SmartPointer<ParameterType> parameterType, bool definedChanged) :
AbstractHandleObjectEvent(definedChanged), parameterType(parameterType)
{
if (!parameterType)
{
throw Poco::NullPointerException("ParameterType cannot be null");
}
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryParameterTypeEvent.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryParameterTypeEvent.h
index 72679f9ef9..f07ee7a1e9 100755
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryParameterTypeEvent.h
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryParameterTypeEvent.h
@@ -1,76 +1,76 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYPARAMETERTYPEEVENT_H_
#define BERRYPARAMETERTYPEEVENT_H_
#include "common/berryAbstractHandleObjectEvent.h"
namespace berry {
class ParameterType;
/**
* An instance of this class describes changes to an instance of
* {@link ParameterType}.
* <p>
* This class is not intended to be extended by clients.
* </p>
*
* @see IParameterTypeListener#ParameterTypeChanged(ParameterTypeEvent::Pointer)
*/
class BERRY_COMMANDS ParameterTypeEvent : public AbstractHandleObjectEvent {
public:
berryObjectMacro(ParameterTypeEvent)
/**
* Returns the instance of the parameter type that changed.
*
* @return the instance of the parameter type that changed. Guaranteed not
* to be <code>null</code>.
*/
SmartPointer<ParameterType> GetParameterType() const;
/**
* Constructs a new instance.
*
* @param parameterType
* The parameter type that changed; must not be <code>null</code>.
* @param definedChanged
* <code>true</code>, iff the defined property changed.
*/
ParameterTypeEvent(const SmartPointer<ParameterType> parameterType,
bool definedChanged);
private:
/**
* The parameter type that has changed. This value is never
* <code>null</code>.
*/
const SmartPointer<ParameterType> parameterType;
};
}
#endif /* BERRYPARAMETERTYPEEVENT_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryParameterization.cpp b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryParameterization.cpp
index bd8578bb65..105e2396a4 100755
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryParameterization.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryParameterization.cpp
@@ -1,125 +1,125 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryParameterization.h"
#include "berryIParameter.h"
#include <Poco/Hash.h>
namespace berry
{
const std::size_t Parameterization::HASH_CODE_NOT_COMPUTED = 0;
const std::size_t Parameterization::HASH_FACTOR = 89;
const std::size_t Parameterization::HASH_INITIAL = Poco::hash("berry::Parameterization");
Parameterization::Parameterization(const SmartPointer<const IParameter> parameter, const std::string& value)
: hashCode(HASH_CODE_NOT_COMPUTED), parameter(parameter), value(value)
{
if (!parameter)
{
throw Poco::NullPointerException(
"You cannot parameterize a null parameter");
}
}
Parameterization::Parameterization(const Parameterization& p)
: hashCode(p.hashCode), parameter(p.parameter), value(p.value)
{
}
Parameterization& Parameterization::operator=(const Parameterization& p)
{
this->hashCode = p.hashCode;
this->parameter = p.parameter;
this->value = p.value;
return *this;
}
bool Parameterization::operator==(const Parameterization& parameterization) const
{
if (this == &parameterization)
{
return true;
}
// if (!(object instanceof Parameterization)) {
// return false;
// }
if (this->parameter->GetId() != parameterization.parameter->GetId())
{
return false;
}
return (this->value == parameterization.value);
}
Parameterization::operator bool() const
{
return true;
}
SmartPointer<const IParameter> Parameterization::GetParameter() const
{
return parameter;
}
std::string Parameterization::GetValue() const
{
return value;
}
#ifdef _MSC_VER
std::string Parameterization::GetValueName() const throw()
#else
std::string Parameterization::GetValueName() const throw(ParameterValuesException)
#endif
{
const IParameter::ParameterValues parameterValues = parameter->GetValues();
std::string returnValue;
for (IParameter::ParameterValues::const_iterator parameterValueItr = parameterValues.begin();
parameterValueItr != parameterValues.end(); ++ parameterValueItr)
{
const std::string currentValue(parameterValueItr->second);
if (value == currentValue)
{
returnValue = parameterValueItr->first;
break;
}
}
return returnValue;
}
std::size_t Parameterization::HashCode() const
{
if (hashCode == HASH_CODE_NOT_COMPUTED)
{
hashCode = HASH_INITIAL * HASH_FACTOR + parameter->HashCode();
hashCode = hashCode * HASH_FACTOR + Poco::hash(value);
if (hashCode == HASH_CODE_NOT_COMPUTED)
{
hashCode++;
}
}
return hashCode;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryParameterization.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryParameterization.h
index 95e267caa3..d89a2622a1 100755
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryParameterization.h
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryParameterization.h
@@ -1,144 +1,144 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYPARAMETERIZATION_H_
#define BERRYPARAMETERIZATION_H_
#include <org_blueberry_core_commands_Export.h>
#include "common/berryCommandExceptions.h"
#include <string>
#include <berrySmartPointer.h>
namespace berry {
struct IParameter;
/**
* <p>
* A parameter with a specific value. This is usually a part of a
* <code>ParameterizedCommand</code>, which is used to refer to a command
* with a collection of parameterizations.
* </p>
*
* @since 3.1
*/
class BERRY_COMMANDS Parameterization {
private:
/**
* The constant integer hash code value meaning the hash code has not yet
* been computed.
*/
static const std::size_t HASH_CODE_NOT_COMPUTED; // = 0;
/**
* A factor for computing the hash code for all parameterized commands.
*/
static const std::size_t HASH_FACTOR; // = 89;
/**
* The seed for the hash code for all parameterized commands.
*/
static const std::size_t HASH_INITIAL;
/**
* The hash code for this object. This value is computed lazily, and marked
* as invalid when one of the values on which it is based changes.
*/
mutable std::size_t hashCode;
/**
* The parameter that is being parameterized. This value is never
* <code>null</code>.
*/
SmartPointer<const IParameter> parameter;
/**
* The value that defines the parameterization. This value may be
* <code>null</code>.
*/
std::string value;
public:
/**
* Constructs a new instance of <code>Parameterization</code>.
*
* @param parameter
* The parameter that is being parameterized; must not be
* <code>null</code>.
* @param value
* The value for the parameter; may be <code>null</code>.
*/
Parameterization(const SmartPointer<const IParameter> parameter, const std::string& value);
/**
* Copy constructor
*/
Parameterization(const Parameterization& p);
Parameterization& operator=(const Parameterization& p);
/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
bool operator==(const Parameterization& parameterization) const;
operator bool() const;
/**
* Returns the parameter that is being parameterized.
*
* @return The parameter; never <code>null</code>.
*/
SmartPointer<const IParameter> GetParameter() const;
/**
* Returns the value for the parameter in this parameterization.
*
* @return The value; may be <code>null</code>.
*/
std::string GetValue() const;
/**
* Returns the human-readable name for the current value, if any. If the
* name cannot be found, then it simply returns the value. It also ensures
* that any <code>null</code> values are converted into an empty string.
*
* @return The human-readable name of the value; never <code>null</code>.
* @throws ParameterValuesException
* If the parameter needed to be initialized, but couldn't be.
*/
#ifdef _MSC_VER
std::string GetValueName() const throw();
#else
std::string GetValueName() const throw(ParameterValuesException);
#endif
/* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
std::size_t HashCode() const;
};
}
#endif /* BERRYPARAMETERIZATION_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryParameterizedCommand.cpp b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryParameterizedCommand.cpp
index e35fa7d6c4..de1afc4c33 100755
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryParameterizedCommand.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryParameterizedCommand.cpp
@@ -1,437 +1,437 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryParameterizedCommand.h"
#include "berryIParameter.h"
#include "berryCommand.h"
#include "berryParameterization.h"
#include "berryExecutionEvent.h"
#include "berryCommandManager.h"
#include "berryCommandCategory.h"
#include "berryIHandler.h"
#include "internal/berryCommandUtils.h"
#include <berryObjectString.h>
#include <sstream>
#include <Poco/Hash.h>
namespace berry
{
const int INDEX_PARAMETER_ID = 0;
const int INDEX_PARAMETER_NAME = 1;
const int INDEX_PARAMETER_VALUE_NAME = 2;
const int INDEX_PARAMETER_VALUE_VALUE = 3;
const std::size_t ParameterizedCommand::HASH_CODE_NOT_COMPUTED = 0;
const std::size_t ParameterizedCommand::HASH_FACTOR = 89;
const std::size_t ParameterizedCommand::HASH_INITIAL = Poco::hash(
"berry::ParameterizedCommand");
ParameterizedCommand::ParameterizedCommand(const SmartPointer<Command> command,
const std::vector<Parameterization>& params) :
command(command), hashCode(HASH_CODE_NOT_COMPUTED)
{
if (!command)
{
throw Poco::NullPointerException(
"A parameterized command cannot have a null command");
}
std::vector<IParameter::Pointer> parameters;
try
{
parameters = command->GetParameters();
} catch (const NotDefinedException* /*e*/)
{
// This should not happen.
}
if (!params.empty() && !parameters.empty())
{
for (unsigned int j = 0; j < parameters.size(); j++)
{
for (unsigned int i = 0; i < params.size(); i++)
{
if (parameters[j] == params[i].GetParameter())
{
this->parameterizations.push_back(params[i]);
}
}
}
}
}
bool ParameterizedCommand::operator<(const Object* object) const
{
const ParameterizedCommand* command = dynamic_cast<const ParameterizedCommand*>(object);
const bool thisDefined = this->command->IsDefined();
const bool otherDefined = command->command->IsDefined();
if (!thisDefined || !otherDefined)
{
return CommandUtils::Compare(thisDefined, otherDefined) < 0;
}
try
{
const int compareTo = this->GetName().compare(command->GetName());
if (compareTo == 0)
{
return (this->GetId() < command->GetId());
}
return compareTo < 0;
}
catch (const NotDefinedException* /*e*/)
{
throw CommandException(
"Concurrent modification of a command's defined state");
}
}
bool ParameterizedCommand::operator==(const Object* object) const
{
if (this == object)
{
return true;
}
if (const ParameterizedCommand* command = dynamic_cast<const ParameterizedCommand*>(object))
{
if (!(this->command == command->command))
{
return false;
}
return CommandUtils::Equals(this->parameterizations, command->parameterizations);
}
return false;
}
Object::Pointer ParameterizedCommand::ExecuteWithChecks(const Object::ConstPointer trigger,
const Object::ConstPointer applicationContext) throw(ExecutionException,
NotDefinedException, NotEnabledException, NotHandledException)
{
ExecutionEvent::Pointer excEvent(new ExecutionEvent(command,
this->GetParameterMap(), trigger, applicationContext));
return command->ExecuteWithChecks(excEvent);
}
SmartPointer<Command> ParameterizedCommand::GetCommand() const
{
return command;
}
std::string ParameterizedCommand::GetId() const
{
return command->GetId();
}
std::string ParameterizedCommand::GetName() const throw(NotDefinedException)
{
if (name.empty())
{
std::stringstream nameBuffer;
nameBuffer << command->GetName() << " (";
const unsigned int parameterizationCount = (unsigned int) parameterizations.size();
for (unsigned int i = 0; i < parameterizationCount; i++)
{
const Parameterization& parameterization = parameterizations[i];
nameBuffer << parameterization.GetParameter()->GetName() << ": ";
try
{
nameBuffer << parameterization.GetValueName();
}
catch (const ParameterValuesException* /*e*/)
{
/*
* Just let it go for now. If someone complains we can
* add more info later.
*/
}
// If there is another item, append a separator.
if (i + 1 < parameterizationCount)
{
nameBuffer << ", ";
}
nameBuffer << ")";
}
name = nameBuffer.str();
}
return name;
}
std::map<std::string, std::string> ParameterizedCommand::GetParameterMap() const
{
std::map<std::string, std::string> parameterMap;
for (unsigned int i = 0; i < parameterizations.size(); i++)
{
const Parameterization& parameterization = parameterizations[i];
parameterMap.insert(std::make_pair(parameterization.GetParameter()->GetId(),
parameterization.GetValue()));
}
return parameterMap;
}
std::size_t ParameterizedCommand::HashCode() const
{
if (hashCode == HASH_CODE_NOT_COMPUTED)
{
hashCode = HASH_INITIAL * HASH_FACTOR + (command ? command->HashCode() : 0);
hashCode = hashCode * HASH_FACTOR;
for (unsigned int i = 0; i < parameterizations.size(); i++)
{
hashCode += parameterizations[i].HashCode();
}
if (hashCode == HASH_CODE_NOT_COMPUTED)
{
hashCode++;
}
}
return hashCode;
}
std::string ParameterizedCommand::Serialize()
{
const std::string escapedId(this->Escape(this->GetId()));
if (parameterizations.empty())
{
return escapedId;
}
std::stringstream buffer;
buffer << CommandManager::PARAMETER_START_CHAR;
for (unsigned int i = 0; i < parameterizations.size(); i++)
{
if (i> 0)
{
// insert separator between parameters
buffer << CommandManager::PARAMETER_SEPARATOR_CHAR;
}
const Parameterization& parameterization = parameterizations[i];
const std::string parameterId(parameterization.GetParameter()->GetId());
const std::string escapedParameterId(this->Escape(parameterId));
buffer << escapedParameterId;
const std::string parameterValue(parameterization.GetValue());
if (!parameterValue.empty())
{
const std::string escapedParameterValue(this->Escape(parameterValue));
buffer << CommandManager::ID_VALUE_CHAR
<< escapedParameterValue;
}
}
buffer << CommandManager::PARAMETER_END_CHAR;
return buffer.str();
}
std::string ParameterizedCommand::ToString() const
{
std::stringstream buffer;
buffer << "ParameterizedCommand(" << command->ToString() << ","
<< CommandUtils::ToString(parameterizations) << ")";
return buffer.str();
}
std::vector<ParameterizedCommand::Pointer>
ParameterizedCommand::GenerateCombinations(const SmartPointer<Command> command)
throw(NotDefinedException)
{
std::vector<IParameter::Pointer> parameters(command->GetParameters());
typedef std::vector<std::list<Parameterization> > ExpandedParamsType;
const ExpandedParamsType expansion(ExpandParameters(0, parameters));
std::vector<ParameterizedCommand::Pointer> combinations;
for (ExpandedParamsType::const_iterator expansionItr = expansion.begin();
expansionItr != expansion.end(); ++expansionItr)
{
std::list<Parameterization> combination(*expansionItr);
std::vector<Parameterization> parameterizations(combination.begin(), combination.end());
ParameterizedCommand::Pointer pCmd(new ParameterizedCommand(command,
parameterizations));
combinations.push_back(pCmd);
}
return combinations;
}
ParameterizedCommand::Pointer ParameterizedCommand::GenerateCommand(const SmartPointer<Command> command,
const std::map<std::string, Object::Pointer>& parameters)
{
// no parameters
if (parameters.empty())
{
ParameterizedCommand::Pointer pCmd(new ParameterizedCommand(command, std::vector<Parameterization>()));
return pCmd;
}
try
{
std::vector<Parameterization> parms;
// iterate over given parameters
for (std::map<std::string, Object::Pointer>::const_iterator i = parameters.begin();
i != parameters.end(); ++i)
{
std::string key(i->first);
// get the parameter from the command
IParameter::Pointer parameter(command->GetParameter(key));
// if the parameter is defined add it to the parameter list
if (!parameter)
{
return ParameterizedCommand::Pointer(0);
}
ParameterType::Pointer parameterType(command->GetParameterType(key));
if (!parameterType)
{
std::string val(*(i->second.Cast<ObjectString>()));
parms.push_back(Parameterization(parameter, val));
}
else
{
IParameterValueConverter::Pointer valueConverter(parameterType
->GetValueConverter());
if (valueConverter)
{
std::string val(valueConverter->ConvertToString(i->second));
parms.push_back(Parameterization(parameter, val));
}
else
{
std::string val(*(i->second.Cast<ObjectString>()));
parms.push_back(Parameterization(parameter, val));
}
}
}
// convert the parameters to an Parameterization array and create
// the command
ParameterizedCommand::Pointer pCmd(new ParameterizedCommand(command, parms));
return pCmd;
}
catch (const NotDefinedException* /*e*/)
{
}
catch (const ParameterValueConversionException* /*e*/)
{
}
return ParameterizedCommand::Pointer(0);
}
std::string ParameterizedCommand::Escape(const std::string& rawText)
{
std::string buffer;
for (std::string::const_iterator i = rawText.begin();
i != rawText.end(); ++i)
{
std::string::value_type c = *i;
if (c == CommandManager::PARAMETER_START_CHAR ||
c == CommandManager::PARAMETER_END_CHAR ||
c == CommandManager::ID_VALUE_CHAR ||
c == CommandManager::PARAMETER_SEPARATOR_CHAR ||
c == CommandManager::ESCAPE_CHAR)
{
buffer += CommandManager::ESCAPE_CHAR;
}
buffer += c;
}
if (buffer.empty())
{
return rawText;
}
return buffer;
}
std::vector<std::list<Parameterization> > ParameterizedCommand::ExpandParameters(
unsigned int startIndex, const std::vector<IParameter::Pointer>& parameters)
{
typedef std::vector<std::list<Parameterization> > ReturnType;
const unsigned int nextIndex = startIndex + 1;
const bool noMoreParameters = (nextIndex >= parameters.size());
const IParameter::Pointer parameter(parameters[startIndex]);
ReturnType parameterizations;
if (parameter->IsOptional())
{
parameterizations.push_back(std::list<Parameterization>());
}
IParameter::ParameterValues parameterValues(parameter->GetValues());
for (IParameter::ParameterValues::iterator parameterValueItr =
parameterValues.begin(); parameterValueItr != parameterValues.end(); ++parameterValueItr)
{
std::list<Parameterization> combination;
combination.push_back(
Parameterization(parameter, parameterValueItr->second));
parameterizations.push_back(combination);
}
// Check if another iteration will produce any more names.
if (noMoreParameters)
{
// This is it, so just return the current parameterizations.
return parameterizations;
}
// Make recursive call
ReturnType suffixes(ExpandParameters(nextIndex, parameters));
if (suffixes.empty())
{
// This is it, so just return the current parameterizations.
return parameterizations;
}
ReturnType returnValue;
for (ReturnType::iterator suffixItr = suffixes.begin(); suffixItr
!= suffixes.end(); ++suffixItr)
{
for (ReturnType::iterator combinationItr = parameterizations.begin(); combinationItr
!= parameterizations.end(); ++combinationItr)
{
std::list<Parameterization> newCombination(*combinationItr);
newCombination.insert(newCombination.end(), suffixItr->begin(),
suffixItr->end());
returnValue.push_back(newCombination);
}
}
return returnValue;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryParameterizedCommand.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryParameterizedCommand.h
index e294fb01c5..15fd93d78c 100755
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryParameterizedCommand.h
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryParameterizedCommand.h
@@ -1,356 +1,356 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYPARAMETERIZEDCOMMAND_H_
#define BERRYPARAMETERIZEDCOMMAND_H_
#include <berryObject.h>
#include <berryMacros.h>
#include "common/berryCommandExceptions.h"
#include <org_blueberry_core_commands_Export.h>
#include <list>
#include <map>
namespace berry
{
struct IParameter;
class Command;
class Parameterization;
/**
* <p>
* A command that has had one or more of its parameters specified. This class
* serves as a utility class for developers that need to manipulate commands
* with parameters. It handles the behaviour of generating a parameter map and a
* human-readable name.
* </p>
*
* @since 3.1
*/
class BERRY_COMMANDS ParameterizedCommand: public Object
{ //implements Comparable {
public:
berryObjectMacro(ParameterizedCommand)
/**
* The index of the parameter id in the parameter values.
*
* @deprecated no longer used
*/
static const int INDEX_PARAMETER_ID; // = 0;
/**
* The index of the human-readable name of the parameter itself, in the
* parameter values.
*
* @deprecated no longer used
*/
static const int INDEX_PARAMETER_NAME; // = 1;
/**
* The index of the human-readable name of the value of the parameter for
* this command.
*
* @deprecated no longer used
*/
static const int INDEX_PARAMETER_VALUE_NAME; // = 2;
/**
* The index of the value of the parameter that the command can understand.
*
* @deprecated no longer used
*/
static const int INDEX_PARAMETER_VALUE_VALUE; // = 3;
/**
* Constructs a new instance of <code>ParameterizedCommand</code> with
* specific values for zero or more of its parameters.
*
* @param command
* The command that is parameterized; must not be
* <code>null</code>.
* @param parameterizations
* An array of parameterizations binding parameters to values for
* the command. This value may be <code>null</code>.
*/
ParameterizedCommand(const SmartPointer<Command> command,
const std::vector<Parameterization>& parameterizations);
bool operator<(const Object* object) const;
/*
* (non-Javadoc)
*
* @see java.lang.Object#equals(java.lang.Object)
*/
bool operator==(const Object* object) const;
/**
* Executes this command with its parameters. This does extra checking to
* see if the command is enabled and defined. If it is not both enabled and
* defined, then the execution listeners will be notified and an exception
* thrown.
*
* @param trigger
* The object that triggered the execution; may be
* <code>null</code>.
* @param applicationContext
* The state of the application at the time the execution was
* triggered; may be <code>null</code>.
* @return The result of the execution; may be <code>null</code>.
* @throws ExecutionException
* If the handler has problems executing this command.
* @throws NotDefinedException
* If the command you are trying to execute is not defined.
* @throws NotEnabledException
* If the command you are trying to execute is not enabled.
* @throws NotHandledException
* If there is no handler.
* @since 3.2
*/
Object::Pointer ExecuteWithChecks(const Object::ConstPointer trigger,
const Object::ConstPointer applicationContext) throw(ExecutionException,
NotDefinedException, NotEnabledException, NotHandledException);
/**
* Returns the base command. It is possible for more than one parameterized
* command to have the same identifier.
*
* @return The command; never <code>null</code>, but may be undefined.
*/
SmartPointer<Command> GetCommand() const;
/**
* Returns the command's base identifier. It is possible for more than one
* parameterized command to have the same identifier.
*
* @return The command id; never <code>null</code>.
*/
std::string GetId() const;
/**
* Returns a human-readable representation of this command with all of its
* parameterizations.
*
* @return The human-readable representation of this parameterized command;
* never <code>null</code>.
* @throws NotDefinedException
* If the underlying command is not defined.
*/
std::string GetName() const throw(NotDefinedException);
/**
* Returns the parameter map, as can be used to construct an
* <code>ExecutionEvent</code>.
*
* @return The map of parameter ids (<code>String</code>) to parameter
* values (<code>String</code>). This map is never
* <code>null</code>, but may be empty.
*/
std::map<std::string, std::string> GetParameterMap() const;
/*
* (non-Javadoc)
*
* @see java.lang.Object#hashCode()
*/
std::size_t HashCode() const;
/**
* Returns a {@link String} containing the command id, parameter ids and
* parameter values for this {@link ParameterizedCommand}. The returned
* {@link String} can be stored by a client and later used to reconstruct an
* equivalent {@link ParameterizedCommand} using the
* {@link CommandManager#deserialize(String)} method.
* <p>
* The syntax of the returned {@link String} is as follows:
* </p>
*
* <blockquote>
* <code>serialization = <u>commandId</u> [ '(' parameters ')' ]</code><br>
* <code>parameters = parameter [ ',' parameters ]</code><br>
* <code>parameter = <u>parameterId</u> [ '=' <u>parameterValue</u> ]</code>
* </blockquote>
*
* <p>
* In the syntax above, sections inside square-brackets are optional. The
* characters in single quotes (<code>(</code>, <code>)</code>,
* <code>,</code> and <code>=</code>) indicate literal characters.
* </p>
* <p>
* <code><u>commandId</u></code> represents the command id encoded with
* separator characters escaped. <code><u>parameterId</u></code> and
* <code><u>parameterValue</u></code> represent the parameter ids and
* values encoded with separator characters escaped. The separator
* characters <code>(</code>, <code>)</code>, <code>,</code> and
* <code>=</code> are escaped by prepending a <code>%</code>. This
* requires <code>%</code> to be escaped, which is also done by prepending
* a <code>%</code>.
* </p>
* <p>
* The order of the parameters is not defined (and not important). A missing
* <code><u>parameterValue</u></code> indicates that the value of the
* parameter is <code>null</code>.
* </p>
* <p>
* For example, the string shown below represents a serialized parameterized
* command that can be used to show the Resource perspective:
* </p>
* <p>
* <code>org.eclipse.ui.perspectives.showPerspective(org.eclipse.ui.perspectives.showPerspective.perspectiveId=org.eclipse.ui.resourcePerspective)</code>
* </p>
* <p>
* This example shows the more general form with multiple parameters,
* <code>null</code> value parameters, and escaped <code>=</code> in the
* third parameter value.
* </p>
* <p>
* <code>command.id(param1.id=value1,param2.id,param3.id=esc%=val3)</code>
* </p>
*
* @return A string containing the escaped command id, parameter ids and
* parameter values; never <code>null</code>.
* @see CommandManager#deserialize(String)
* @since 3.2
*/
std::string Serialize();
std::string ToString() const;
/**
* <p>
* Generates all the possible combinations of command parameterizations for
* the given command. If the command has no parameters, then this is simply
* a parameterized version of that command. If a parameter is optional, both
* the included and not included cases are considered.
* </p>
* <p>
* If one of the parameters cannot be loaded due to a
* <code>ParameterValuesException</code>, then it is simply ignored.
* </p>
*
* @param command
* The command for which the parameter combinations should be
* generated; must not be <code>null</code>.
* @return A collection of <code>ParameterizedCommand</code> instances
* representing all of the possible combinations. This value is
* never empty and it is never <code>null</code>.
* @throws NotDefinedException
* If the command is not defined.
*/
static std::vector<ParameterizedCommand::Pointer>
GenerateCombinations(const SmartPointer<Command> command)
throw(NotDefinedException);
/**
* Take a command and a map of parameter IDs to values, and generate the
* appropriate parameterized command.
*
* @param command
* The command object. Must not be <code>null</code>.
* @param parameters
* A map of String parameter ids to objects. May be
* <code>null</code>.
* @return the parameterized command, or <code>null</code> if it could not
* be generated
* @since 3.4
*/
static ParameterizedCommand::Pointer GenerateCommand(const SmartPointer<Command> command,
const std::map<std::string, Object::Pointer>& parameters);
private:
/**
* The constant integer hash code value meaning the hash code has not yet
* been computed.
*/
static const std::size_t HASH_CODE_NOT_COMPUTED; // = 0;
/**
* A factor for computing the hash code for all parameterized commands.
*/
static const std::size_t HASH_FACTOR; // = 89;
/**
* The seed for the hash code for all parameterized commands.
*/
static const std::size_t HASH_INITIAL;
/**
* Escapes special characters in the command id, parameter ids and parameter
* values for {@link #serialize()}. The special characters
* {@link CommandManager#PARAMETER_START_CHAR},
* {@link CommandManager#PARAMETER_END_CHAR},
* {@link CommandManager#ID_VALUE_CHAR},
* {@link CommandManager#PARAMETER_SEPARATOR_CHAR} and
* {@link CommandManager#ESCAPE_CHAR} are escaped by prepending a
* {@link CommandManager#ESCAPE_CHAR} character.
*
* @param rawText
* a <code>String</code> to escape special characters in for
* serialization.
* @return a <code>String</code> representing <code>rawText</code> with
* special serialization characters escaped
* @since 3.2
*/
static std::string Escape(const std::string& rawText);
/**
* Generates every possible combination of parameter values for the given
* parameters. Parameters values that cannot be initialized are just
* ignored. Optional parameters are considered.
*
* @param startIndex
* The index in the <code>parameters</code> that we should
* process. This must be a valid index.
* @param parameters
* The parameters in to process; must not be <code>null</code>.
* @return A collection (<code>Collection</code>) of combinations (<code>List</code>
* of <code>Parameterization</code>).
*/
static std::vector<std::list<Parameterization> > ExpandParameters(unsigned int startIndex,
const std::vector<SmartPointer<IParameter> >& parameters);
/**
* The base command which is being parameterized. This value is never
* <code>null</code>.
*/
const SmartPointer<Command> command;
/**
* The hash code for this object. This value is computed lazily, and marked
* as invalid when one of the values on which it is based changes.
*/
mutable std::size_t hashCode;
/**
* This is an array of parameterization defined for this command. This value
* may be <code>null</code> if the command has no parameters.
*/
std::vector<Parameterization> parameterizations;
mutable std::string name;
};
}
#endif /* BERRYPARAMETERIZEDCOMMAND_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryState.cpp b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryState.cpp
index 1f56ddfba2..2755bd7964 100644
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryState.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryState.cpp
@@ -1,62 +1,62 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryState.h"
namespace berry
{
void State::AddListener(IStateListener::Pointer listener)
{
stateEvents.AddListener(listener);
}
void State::RemoveListener(IStateListener::Pointer listener)
{
stateEvents.RemoveListener(listener);
}
void State::FireStateChanged(Object::Pointer oldValue)
{
stateEvents.stateChanged(State::Pointer(this), oldValue);
}
std::string State::GetId() const
{
return id;
}
Object::Pointer State::GetValue() const
{
return value;
}
void State::SetId(const std::string& id)
{
this->id = id;
}
void State::SetValue(const Object::Pointer value)
{
if (this->value != value)
{
const Object::Pointer oldValue(this->value);
this->value = value;
//fireStateChanged(oldValue);
}
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryState.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryState.h
index e5ede748b9..6a9c7961e8 100644
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryState.h
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryState.h
@@ -1,133 +1,133 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYSTATE_H_
#define BERRYSTATE_H_
#include <berryMacros.h>
#include <berryObject.h>
#include <org_blueberry_core_commands_Export.h>
#include "berryIStateListener.h"
namespace berry {
/**
* <p>
* A piece of state information that can be shared between objects, and might be
* persisted between sessions. This can be used for commands that toggle between
* two states and wish to pass this state information between different
* handlers.
* </p>
* <p>
* This state object can either be used as a single state object shared between
* several commands, or one state object per command -- depending on the needs
* of the application.
* </p>
* <p>
* Clients may instantiate or extend this class.
* </p>
*
* @since 3.2
*/
class BERRY_COMMANDS State : public Object {
public:
berryObjectMacro(State)
/**
* Adds a listener to changes for this state.
*
* @param listener
* The listener to add; must not be <code>null</code>.
*/
void AddListener(IStateListener::Pointer listener);
/**
* Returns the identifier for this state.
*
* @return The id; may be <code>null</code>.
*/
std::string GetId() const;
/**
* The current value associated with this state. This can be any type of
* object, but implementations will usually restrict this value to a
* particular type.
*
* @return The current value; may be anything.
*/
Object::Pointer GetValue() const;
/**
* Removes a listener to changes from this state.
*
* @param listener
* The listener to remove; must not be <code>null</code>.
*/
void RemoveListener(IStateListener::Pointer listener);
/**
* Sets the identifier for this object. This method should only be called
* by the command framework. Clients should not call this method.
*
* @param id
* The id; must not be <code>null</code>.
*/
void SetId(const std::string& id);
/**
* Sets the value for this state object.
*
* @param value
* The value to set; may be anything.
*/
void SetValue(const Object::Pointer value);
protected:
/**
* Notifies listeners to this state that it has changed in some way.
*
* @param oldValue
* The old value; may be anything.
*/
void FireStateChanged(Object::Pointer oldValue);
private:
/**
* The identifier of the state; may be <code>null</code> if it has not
* been initialized.
*/
std::string id;
/**
* The value held by this state; may be anything at all.
*/
Object::Pointer value;
IStateListener::Events stateEvents;
};
}
#endif /*BERRYSTATE_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryAbstractBitSetEvent.cpp b/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryAbstractBitSetEvent.cpp
index 779f161212..310f7f8ce1 100755
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryAbstractBitSetEvent.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryAbstractBitSetEvent.cpp
@@ -1,27 +1,27 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryAbstractBitSetEvent.h"
namespace berry {
AbstractBitSetEvent::AbstractBitSetEvent()
: changedValues(0)
{
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryAbstractBitSetEvent.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryAbstractBitSetEvent.h
index 353b7ad1d6..cbced427fe 100755
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryAbstractBitSetEvent.h
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryAbstractBitSetEvent.h
@@ -1,57 +1,57 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYABSTRACTBITSETEVENT_H_
#define BERRYABSTRACTBITSETEVENT_H_
#include "berryObject.h"
#include "berryMacros.h"
#include <org_blueberry_core_commands_Export.h>
namespace berry {
/**
* <p>
* An event that carries with it two or more boolean values. This provides a
* single integer value which can then be used as a bit set.
* </p>
*
* @since 3.1
*/
class BERRY_COMMANDS AbstractBitSetEvent : public virtual Object {
public:
berryObjectMacro(AbstractBitSetEvent)
protected:
AbstractBitSetEvent();
/**
* A collection of bits representing whether certain values have changed. A
* bit is set (i.e., <code>1</code>) if the corresponding property has
* changed. It can be assumed that this value will be correctly initialized
* by the superconstructor.
*/
int changedValues;
};
}
#endif /* BERRYABSTRACTBITSETEVENT_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryAbstractHandleObjectEvent.cpp b/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryAbstractHandleObjectEvent.cpp
index 366e3aca7b..f003cf00a0 100755
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryAbstractHandleObjectEvent.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryAbstractHandleObjectEvent.cpp
@@ -1,39 +1,39 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryAbstractHandleObjectEvent.h"
namespace berry
{
const int AbstractHandleObjectEvent::CHANGED_DEFINED = 1;
const int AbstractHandleObjectEvent::LAST_BIT_USED_ABSTRACT_HANDLE =
AbstractHandleObjectEvent::CHANGED_DEFINED;
AbstractHandleObjectEvent::AbstractHandleObjectEvent(bool definedChanged)
{
if (definedChanged)
{
changedValues |= CHANGED_DEFINED;
}
}
bool AbstractHandleObjectEvent::IsDefinedChanged() const
{
return ((changedValues & CHANGED_DEFINED) != 0);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryAbstractHandleObjectEvent.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryAbstractHandleObjectEvent.h
index adcbd2b602..dadcc2dab9 100755
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryAbstractHandleObjectEvent.h
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryAbstractHandleObjectEvent.h
@@ -1,71 +1,71 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYABSTRACTHANDLEOBJECTEVENT_H_
#define BERRYABSTRACTHANDLEOBJECTEVENT_H_
#include "berryAbstractBitSetEvent.h"
namespace berry {
/**
* <p>
* An event fired from a <code>NamedHandleObject</code>. This provides
* notification of changes to the defined state, the name and the description.
* </p>
*
* @since 3.2
*/
class BERRY_COMMANDS AbstractHandleObjectEvent : public AbstractBitSetEvent
{
public:
berryObjectMacro(AbstractHandleObjectEvent)
/**
* Returns whether or not the defined property changed.
*
* @return <code>true</code>, iff the defined property changed.
*/
bool IsDefinedChanged() const;
protected:
/**
* The bit used to represent whether the category has changed its defined
* state.
*/
static const int CHANGED_DEFINED; // = 1;
/**
* The last used bit so that subclasses can add more properties.
*/
static const int LAST_BIT_USED_ABSTRACT_HANDLE; // = CHANGED_DEFINED;
/**
* Constructs a new instance of <code>AbstractHandleObjectEvent</code>.
*
* @param definedChanged
* <code>true</code>, iff the defined property changed.
*/
AbstractHandleObjectEvent(bool definedChanged);
};
}
#endif /* BERRYABSTRACTHANDLEOBJECTEVENT_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryAbstractNamedHandleEvent.cpp b/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryAbstractNamedHandleEvent.cpp
index 921720da01..50e2cf95c1 100755
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryAbstractNamedHandleEvent.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryAbstractNamedHandleEvent.cpp
@@ -1,51 +1,51 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryAbstractNamedHandleEvent.h"
namespace berry
{
const int AbstractNamedHandleEvent::CHANGED_DESCRIPTION = AbstractNamedHandleEvent::LAST_BIT_USED_ABSTRACT_HANDLE << 1;
const int AbstractNamedHandleEvent::CHANGED_NAME = AbstractNamedHandleEvent::LAST_BIT_USED_ABSTRACT_HANDLE << 2;
const int AbstractNamedHandleEvent::LAST_USED_BIT = AbstractNamedHandleEvent::CHANGED_NAME;
bool AbstractNamedHandleEvent::IsDescriptionChanged() const
{
return ((changedValues & CHANGED_DESCRIPTION) != 0);
}
bool AbstractNamedHandleEvent::IsNameChanged() const
{
return ((changedValues & CHANGED_NAME) != 0);
}
AbstractNamedHandleEvent::AbstractNamedHandleEvent(bool definedChanged,
bool descriptionChanged, bool nameChanged) :
AbstractHandleObjectEvent(definedChanged)
{
if (descriptionChanged)
{
changedValues |= CHANGED_DESCRIPTION;
}
if (nameChanged)
{
changedValues |= CHANGED_NAME;
}
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryAbstractNamedHandleEvent.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryAbstractNamedHandleEvent.h
index fe21ebe91d..f9d134f47b 100755
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryAbstractNamedHandleEvent.h
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryAbstractNamedHandleEvent.h
@@ -1,87 +1,87 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYABSTRACTNAMEDHANDLEEVENT_H_
#define BERRYABSTRACTNAMEDHANDLEEVENT_H_
#include "berryAbstractHandleObjectEvent.h"
namespace berry {
/**
* <p>
* An event fired from a <code>NamedHandleObject</code>. This provides
* notification of changes to the defined state, the name and the description.
* </p>
*
*/
class BERRY_COMMANDS AbstractNamedHandleEvent : public AbstractHandleObjectEvent {
public:
berryObjectMacro(AbstractNamedHandleEvent)
/**
* Returns whether or not the description property changed.
*
* @return <code>true</code>, iff the description property changed.
*/
bool IsDescriptionChanged() const;
/**
* Returns whether or not the name property changed.
*
* @return <code>true</code>, iff the name property changed.
*/
bool IsNameChanged() const;
protected:
/**
* The bit used to represent whether the category has changed its
* description.
*/
static const int CHANGED_DESCRIPTION; // = LAST_BIT_USED_ABSTRACT_HANDLE << 1;
/**
* The bit used to represent whether the category has changed its name.
*/
static const int CHANGED_NAME; // = LAST_BIT_USED_ABSTRACT_HANDLE << 2;
/**
* The last used bit so that subclasses can add more properties.
*/
static const int LAST_USED_BIT; // = CHANGED_NAME;
/**
* Constructs a new instance of <code>AbstractHandleObjectEvent</code>.
*
* @param definedChanged
* <code>true</code>, iff the defined property changed.
* @param descriptionChanged
* <code>true</code>, iff the description property changed.
* @param nameChanged
* <code>true</code>, iff the name property changed.
*/
AbstractNamedHandleEvent(bool definedChanged,
bool descriptionChanged, bool nameChanged);
};
}
#endif /* BERRYABSTRACTNAMEDHANDLEEVENT_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryCommandExceptions.cpp b/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryCommandExceptions.cpp
index 3969e79f77..d82c065a3e 100644
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryCommandExceptions.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryCommandExceptions.cpp
@@ -1,32 +1,32 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryCommandExceptions.h"
#include <typeinfo>
namespace berry {
POCO_IMPLEMENT_EXCEPTION(CommandException, Poco::RuntimeException, "Command exception")
POCO_IMPLEMENT_EXCEPTION(ExecutionException, CommandException, "Command execution exception")
POCO_IMPLEMENT_EXCEPTION(NotHandledException, CommandException, "Command not handled exception")
POCO_IMPLEMENT_EXCEPTION(NotDefinedException, CommandException, "Command not defined exception")
POCO_IMPLEMENT_EXCEPTION(NotEnabledException, CommandException, "Command not enabled exception")
POCO_IMPLEMENT_EXCEPTION(ParameterValueConversionException, CommandException, "Parameter value conversion exception");
POCO_IMPLEMENT_EXCEPTION(ParameterValuesException, CommandException, "Parameter values exception")
POCO_IMPLEMENT_EXCEPTION(SerializationException, CommandException, "Serialization exception")
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryCommandExceptions.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryCommandExceptions.h
index 635858575c..d0edce60da 100644
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryCommandExceptions.h
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryCommandExceptions.h
@@ -1,57 +1,57 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYCOMMANDEXCEPTIONS_H_
#define BERRYCOMMANDEXCEPTIONS_H_
#include <org_blueberry_core_commands_Export.h>
#include <Poco/Exception.h>
namespace berry {
POCO_DECLARE_EXCEPTION(BERRY_COMMANDS, CommandException, Poco::RuntimeException);
POCO_DECLARE_EXCEPTION(BERRY_COMMANDS, ExecutionException, CommandException);
POCO_DECLARE_EXCEPTION(BERRY_COMMANDS, NotHandledException, CommandException);
POCO_DECLARE_EXCEPTION(BERRY_COMMANDS, NotDefinedException, CommandException);
POCO_DECLARE_EXCEPTION(BERRY_COMMANDS, NotEnabledException, CommandException);
POCO_DECLARE_EXCEPTION(BERRY_COMMANDS, ParameterValueConversionException, CommandException);
/**
* Signals that a problem has occurred while trying to create an instance of
* <code>IParameterValues</code>. In applications based on the registry
* provided by core, this usually indicates a problem creating an
* <code>IExecutableExtension</code>. For other applications, this exception
* could be used to signify any general problem during initialization.
*
*/
POCO_DECLARE_EXCEPTION(BERRY_COMMANDS, ParameterValuesException, CommandException);
/**
* Signals that an exception occured while serializing a
* {@link ParameterizedCommand} to a string or deserializing a string to a
* {@link ParameterizedCommand}.
*
* This class is not intended to be extended by clients.
*
*/
POCO_DECLARE_EXCEPTION(BERRY_COMMANDS, SerializationException, CommandException);
}
#endif /*BERRYCOMMANDEXCEPTIONS_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryHandleObject.cpp b/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryHandleObject.cpp
index 967b1ed701..36ea420618 100644
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryHandleObject.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryHandleObject.cpp
@@ -1,60 +1,60 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryHandleObject.h"
#include <typeinfo>
namespace berry
{
const std::size_t HandleObject::HASH_CODE_NOT_COMPUTED = 0;
const std::size_t HandleObject::HASH_FACTOR = 89;
const std::size_t HandleObject::HASH_INITIAL = Poco::hash("berry::HandleObject");
HandleObject::HandleObject(const std::string& ID) :
hashCode(HASH_CODE_NOT_COMPUTED), defined(false), id(ID)
{
}
bool HandleObject::operator==(const Object* object) const
{
// Check if they're the same.
if (object == this)
{
return true;
}
// Check if they're the same type.
if (const Self* o = dynamic_cast<const Self*>(object))
{
// Check each property in turn.
return (id == o->id);
}
return false;
}
std::string HandleObject::GetId() const
{
return id;
}
bool HandleObject::IsDefined() const
{
return defined;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryHandleObject.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryHandleObject.h
index f4ad7bbc6e..e4debb11ec 100644
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryHandleObject.h
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryHandleObject.h
@@ -1,165 +1,165 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYHANDLEOBJECT_H_
#define BERRYHANDLEOBJECT_H_
#include <berryMacros.h>
#include <berryObject.h>
#include <org_blueberry_core_commands_Export.h>
#include <Poco/Hash.h>
namespace berry {
/**
* <p>
* An object that can exist in one of two states: defined and undefined. This is
* used by APIs that want to give a handle to an object, even though the object
* does not fully exist yet. This way, users can attach listeners to objects
* before they come into existence. It also protects the API from users that do
* not release references when they should.
* </p>
* <p>
* To enforce good coding practice, all handle objects must implement
* <code>equals</code> and <code>toString</code>. Please use
* <code>string</code> to cache the result for <code>toString</code> once
* calculated.
* </p>
* <p>
* All handle objects are referred to using a single identifier. This identifier
* is a instance of <code>String</code>. It is important that this identifier
* remain unique within whatever context that handle object is being used. For
* example, there should only ever be one instance of <code>Command</code>
* with a given identifier.
* </p>
*
* @since 3.1
*/
class BERRY_COMMANDS HandleObject : public virtual Object { // extends EventManager implements IIdentifiable {
public:
berryObjectMacro(HandleObject)
private:
/**
* The constant integer hash code value meaning the hash code has not yet
* been computed.
*/
static const std::size_t HASH_CODE_NOT_COMPUTED; // = 0;
/**
* A factor for computing the hash code for all schemes.
*/
static const std::size_t HASH_FACTOR; // = 89;
/**
* The seed for the hash code for all schemes.
*/
static const std::size_t HASH_INITIAL;
/**
* The hash code for this object. This value is computed lazily, and marked
* as invalid when one of the values on which it is based changes.
*/
mutable std::size_t hashCode; // = HASH_CODE_NOT_COMPUTED;
protected:
/**
* Whether this object is defined. A defined object is one that has been
* fully initialized. By default, all objects start as undefined.
*/
bool defined;
/**
* The identifier for this object. This identifier should be unique across
* all objects of the same type and should never change. This value will
* never be <code>null</code>.
*/
const std::string id;
/**
* The string representation of this object. This string is for debugging
* purposes only, and is not meant to be displayed to the user. This value
* is computed lazily, and is cleared if one of its dependent values
* changes.
*/
mutable std::string str;
/**
* Constructs a new instance of <code>HandleObject</code>.
*
* @param id
* The id of this handle; must not be <code>null</code>.
*/
HandleObject(const std::string& id);
public:
/**
* Tests whether this object is equal to another object. A handle object is
* only equal to another handle object with the same id and the same class.
*
* @param object
* The object with which to compare; may be <code>null</code>.
* @return <code>true</code> if the objects are equal; <code>false</code>
* otherwise.
*/
bool operator==(const Object* object) const;
virtual std::string GetId() const;
/**
* Computes the hash code for this object based on the id.
*
* @return The hash code for this object.
*/
virtual std::size_t HashCode() const {
if (hashCode == HASH_CODE_NOT_COMPUTED) {
hashCode = HASH_INITIAL * HASH_FACTOR + Poco::hash(id);
if (hashCode == HASH_CODE_NOT_COMPUTED) {
hashCode++;
}
}
return hashCode;
}
/**
* Whether this instance is defined. A defined instance is one that has been
* fully initialized. This allows objects to effectively disappear even
* though other objects may still have references to them.
*
* @return <code>true</code> if this object is defined; <code>false</code>
* otherwise.
*/
virtual bool IsDefined() const;
/**
* Makes this object becomes undefined. This method should make any defined
* properties <code>null</code>. It should also send notification to any
* listeners that these properties have changed.
*/
virtual void Undefine() = 0;
};
}
#endif /*BERRYHANDLEOBJECT_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryHandleObjectManager.cpp b/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryHandleObjectManager.cpp
index 1f7b250137..f7f7fd8480 100755
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryHandleObjectManager.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryHandleObjectManager.cpp
@@ -1,43 +1,43 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryHandleObjectManager.h"
namespace berry
{
void HandleObjectManager::CheckId(const std::string& id) const
{
if (id.empty())
{
throw std::invalid_argument(
"The handle object must not have a zero-length identifier"); //$NON-NLS-1$
}
}
Poco::HashSet<std::string> HandleObjectManager::GetDefinedHandleObjectIds() const
{
Poco::HashSet<std::string> definedHandleObjectIds(definedHandleObjects.size());
for (Poco::HashSet<HandleObject::Pointer, HandleObject::Hash>::ConstIterator iter =
definedHandleObjects.begin(); iter != definedHandleObjects.end(); ++iter)
{
const std::string id((*iter)->GetId());
definedHandleObjectIds.insert(id);
}
return definedHandleObjectIds;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryHandleObjectManager.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryHandleObjectManager.h
index 411cfd6a2b..7c05f19fdc 100755
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryHandleObjectManager.h
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryHandleObjectManager.h
@@ -1,80 +1,80 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYHANDLEOBJECTMANAGER_H_
#define BERRYHANDLEOBJECTMANAGER_H_
#include <Poco/HashSet.h>
#include <Poco/HashMap.h>
#include "berryHandleObject.h"
namespace berry {
/**
* <p>
* A manager of {@link HandleObject} instances. This has some common behaviour
* which is shared between all such managers.
* </p>
* <p>
* Clients may extend.
* </p>
*
* @since 3.2
*/
class BERRY_COMMANDS HandleObjectManager {
protected:
typedef Poco::HashSet<HandleObject::Pointer, HandleObject::Hash> HandleObjectsSet;
typedef Poco::HashMap<std::string, HandleObject::Pointer> HandleObjectsByIdMap;
/**
* The set of handle objects that are defined. This value may be empty, but
* it is never <code>null</code>.
*/
HandleObjectsSet definedHandleObjects;
/**
* The map of identifiers (<code>String</code>) to handle objects (
* <code>HandleObject</code>). This collection may be empty, but it is
* never <code>null</code>.
*/
HandleObjectsByIdMap handleObjectsById;
/**
* Verifies that the identifier is valid. Exceptions will be thrown if the
* identifier is invalid in some way.
*
* @param id
* The identifier to validate; may be anything.
*/
void CheckId(const std::string& id) const;
/**
* Returns the set of identifiers for those handle objects that are defined.
*
* @return The set of defined handle object identifiers; this value may be
* empty, but it is never <code>null</code>.
*/
Poco::HashSet<std::string> GetDefinedHandleObjectIds() const;
};
}
#endif /* BERRYHANDLEOBJECTMANAGER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryNamedHandleObject.cpp b/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryNamedHandleObject.cpp
index 5f6d1f8e4b..6d4fca9c41 100644
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryNamedHandleObject.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryNamedHandleObject.cpp
@@ -1,54 +1,54 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryNamedHandleObject.h"
#include "berryCommandExceptions.h"
namespace berry
{
NamedHandleObject::NamedHandleObject(const std::string& id) :
HandleObject(id)
{
}
std::string NamedHandleObject::GetDescription() const
{
if (!this->IsDefined())
{
throw NotDefinedException(
"Cannot get a description from an undefined object. " //$NON-NLS-1$
+ id);
}
return description;
}
std::string NamedHandleObject::GetName() const
{
if (!this->IsDefined())
{
throw NotDefinedException(
"Cannot get the name from an undefined object. " //$NON-NLS-1$
+ id);
}
return name;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryNamedHandleObject.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryNamedHandleObject.h
index fa4f018d12..b4acb709f8 100644
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryNamedHandleObject.h
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/common/berryNamedHandleObject.h
@@ -1,84 +1,84 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYNAMEDHANDLEOBJECT_H_
#define BERRYNAMEDHANDLEOBJECT_H_
#include "berryHandleObject.h"
namespace berry {
/**
* A handle object that carries with it a name and a description. This type of
* handle object is quite common across the commands code base. For example,
* <code>Command</code>, <code>Context</code> and <code>Scheme</code>.
*
* @since 3.1
*/
class BERRY_COMMANDS NamedHandleObject : public HandleObject {
public:
berryObjectMacro(NamedHandleObject)
protected:
/**
* The description for this handle. This value may be <code>null</code> if
* the handle is undefined or has no description.
*/
std::string description;
/**
* The name of this handle. This valud should not be <code>null</code>
* unless the handle is undefined.
*/
std::string name;
/**
* Constructs a new instance of <code>NamedHandleObject</code>.
*
* @param id
* The identifier for this handle; must not be <code>null</code>.
*/
NamedHandleObject(const std::string& id);
public:
/**
* Returns the description for this handle.
*
* @return The description; may be <code>null</code> if there is no
* description.
* @throws NotDefinedException
* If the handle is not currently defined.
*/
virtual std::string GetDescription() const;
/**
* Returns the name for this handle.
*
* @return The name for this handle; never <code>null</code>.
* @throws NotDefinedException
* If the handle is not currently defined.
*/
virtual std::string GetName() const;
};
}
#endif /*BERRYNAMEDHANDLEOBJECT_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/internal/berryCommandUtils.cpp b/BlueBerry/Bundles/org.blueberry.core.commands/src/internal/berryCommandUtils.cpp
index 0b5437a534..c6b87fa16e 100755
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/internal/berryCommandUtils.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/internal/berryCommandUtils.cpp
@@ -1,53 +1,53 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryCommandUtils.h"
namespace berry
{
int CommandUtils::Compare(const bool left, const bool right)
{
return left == false ? (right == true ? -1 : 0) : (right == true ? 0 : 1);
}
int CommandUtils::Compare(const std::string& left, const std::string& right)
{
return left.compare(right);
}
int CommandUtils::CompareObj(const Object::ConstPointer left,
const Object::ConstPointer right)
{
if (!left && !right)
{
return 0;
}
else if (!left)
{
return -1;
}
else if (!right)
{
return 1;
}
else
{
return left->ToString().compare(right->ToString());
}
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/internal/berryCommandUtils.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/internal/berryCommandUtils.h
index b978df0dea..a7dd432085 100755
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/internal/berryCommandUtils.h
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/internal/berryCommandUtils.h
@@ -1,159 +1,159 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 __BERRY_COMMAND_UTILS_H__
#define __BERRY_COMMAND_UTILS_H__
#include <string>
#include <vector>
#include <sstream>
#include <berryObject.h>
namespace berry
{
/**
* A class providing utility functions for the commands plug-in.
*/
class CommandUtils
{
public:
/**
* Compares two boolean values. <code>false</code> is considered to be
* less than <code>true</code>.
*
* @param left
* The left value to compare.
* @param right
* The right value to compare.
* @return <code>-1</code> if <code>left</code> is <code>false</code>
* and <code>right</code> is <code>true</code>;<code>0</code>
* if they are equal; <code>1</code> if <code>left</code> is
* <code>true</code> and <code>right</code> is
* <code>false</code>
*/
static int Compare(const bool left, const bool right);
static int Compare(const std::string& left, const std::string& right);
/**
* Compares two objects that are not otherwise comparable. If neither object
* is <code>null</code>, then the string representation of each object is
* used.
*
* @param left
* The left value to compare. The string representation of this
* value must not be <code>null</code>.
* @param right
* The right value to compare. The string representation of this
* value must not be <code>null</code>.
* @return <code>-1</code> if <code>left</code> is <code>null</code>
* and <code>right</code> is not <code>null</code>;
* <code>0</code> if they are both <code>null</code>;
* <code>1</code> if <code>left</code> is not <code>null</code>
* and <code>right</code> is <code>null</code>. Otherwise, the
* result of
* <code>left.toString().compareTo(right.toString())</code>.
*/
static int CompareObj(const Object::ConstPointer left,
const Object::ConstPointer right);
/**
* Tests whether two arrays of objects are equal to each other. The arrays
* must not be <code>null</code>, but their elements may be
* <code>null</code>.
*
* @param leftArray
* The left array to compare; may be <code>null</code>, and
* may be empty and may contain <code>null</code> elements.
* @param rightArray
* The right array to compare; may be <code>null</code>, and
* may be empty and may contain <code>null</code> elements.
* @return <code>true</code> if the arrays are equal length and the
* elements at the same position are equal; <code>false</code>
* otherwise.
*/
template<class T>
static int Compare(const std::vector<T>& leftArray,
const std::vector<T>& rightArray) {
int result = (int) (leftArray.size() - rightArray.size());
if (result == 0)
{
for (unsigned int i = 0; i < leftArray.size(); ++i) {
long int diff = (long) (&(leftArray[i]) - &(rightArray[i]));
int result = diff ? (diff < 0 ? -1 : 1) : 0;
if (result != 0) break;
}
}
return result;
}
/**
* Tests whether two arrays of objects are equal to each other. The arrays
* must not be <code>null</code>, but their elements may be
* <code>null</code>.
*
* @param leftArray
* The left array to compare; may be <code>null</code>, and
* may be empty and may contain <code>null</code> elements.
* @param rightArray
* The right array to compare; may be <code>null</code>, and
* may be empty and may contain <code>null</code> elements.
* @return <code>true</code> if the arrays are equal length and the
* elements at the same position are equal; <code>false</code>
* otherwise.
*/
template<class T>
static bool Equals(const std::vector<T>& leftArray,
const std::vector<T>& rightArray) {
if (leftArray.size() != rightArray.size()) {
return false;
}
for (unsigned int i = 0; i < leftArray.size(); i++) {
T left = leftArray[i];
T right = rightArray[i];
const bool equal = left ? !right : (left == right);
if (!equal) {
return false;
}
}
return true;
}
template<class T>
static std::string ToString(const std::vector<T>& vec)
{
std::stringstream str;
std::locale C("C");
str.imbue(C);
str << "[";
for (unsigned int i = 0; i < vec.size(); ++i)
{
if (i > 0) str << ",";
str << &(vec[i]);
}
return str.str();
}
};
}
#endif // __BERRY_COMMAND_UTILS_H__
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/internal/berryPluginActivator.cpp b/BlueBerry/Bundles/org.blueberry.core.commands/src/internal/berryPluginActivator.cpp
index ec8963c043..7483fe58df 100644
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/internal/berryPluginActivator.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/internal/berryPluginActivator.cpp
@@ -1,40 +1,40 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryPluginActivator.h"
#include <QtPlugin>
namespace berry {
org_blueberry_core_commands_Activator::org_blueberry_core_commands_Activator()
{
}
void org_blueberry_core_commands_Activator::start(ctkPluginContext* context)
{
Q_UNUSED(context)
}
void org_blueberry_core_commands_Activator::stop(ctkPluginContext* context)
{
Q_UNUSED(context)
}
}
Q_EXPORT_PLUGIN2(org_blueberry_core_commands, berry::org_blueberry_core_commands_Activator)
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/internal/berryPluginActivator.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/internal/berryPluginActivator.h
index 44daf4fde5..3e13949796 100644
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/internal/berryPluginActivator.h
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/internal/berryPluginActivator.h
@@ -1,42 +1,42 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYPLUGINACTIVATOR_H
#define BERRYPLUGINACTIVATOR_H
#include <ctkPluginActivator.h>
namespace berry {
class org_blueberry_core_commands_Activator :
public QObject, public ctkPluginActivator
{
Q_OBJECT
Q_INTERFACES(ctkPluginActivator)
public:
org_blueberry_core_commands_Activator();
void start(ctkPluginContext* context);
void stop(ctkPluginContext* context);
};
typedef org_blueberry_core_commands_Activator PluginActivator;
}
#endif // BERRYPLUGINACTIVATOR_H
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/util/berryCommandTracing.cpp b/BlueBerry/Bundles/org.blueberry.core.commands/src/util/berryCommandTracing.cpp
index dd47d8aaae..d32cfab73e 100755
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/util/berryCommandTracing.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/util/berryCommandTracing.cpp
@@ -1,47 +1,47 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryLog.h"
#include "berryCommandTracing.h"
#include <iostream>
namespace berry {
const std::string CommandTracing::SEPARATOR = " >>> ";
void CommandTracing::PrintTrace(const std::string& component,
const std::string& message)
{
std::string buffer(component);
if ((!component.empty()) && (!message.empty()))
{
buffer += SEPARATOR;
}
if (!message.empty())
{
buffer += message;
}
BERRY_INFO << buffer;
}
CommandTracing::CommandTracing()
{
// Do nothing.
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/util/berryCommandTracing.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/util/berryCommandTracing.h
index 7ddd26fc5b..db27972854 100755
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/util/berryCommandTracing.h
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/util/berryCommandTracing.h
@@ -1,73 +1,73 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYCOMMANDTRACING_H_
#define BERRYCOMMANDTRACING_H_
#include <string>
namespace berry {
/**
* <p>
* A utility class for printing tracing output to the console.
* </p>
* <p>
* Clients must not extend or instantiate this class.
* </p>
*
* @since 3.2
*/
class CommandTracing {
public:
/**
* The separator to place between the component and the message.
*/
static const std::string SEPARATOR; // = " >>> ";
/**
* <p>
* Prints a tracing message to standard out. The message is prefixed by a
* component identifier and some separator. See the example below.
* </p>
*
* <pre>
* BINDINGS &gt;&gt; There are 4 deletion markers
* </pre>
*
* @param component
* The component for which this tracing applies; may be
* empty
* @param message
* The message to print to standard out; may be empty
*/
static void PrintTrace(const std::string& component,
const std::string& message);
private:
/**
* This class is not intended to be instantiated.
*/
CommandTracing();
};
}
#endif /* BERRYCOMMANDTRACING_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryElementHandler.cpp b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryElementHandler.cpp
index 27edf68005..d7035be8e2 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryElementHandler.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryElementHandler.cpp
@@ -1,51 +1,51 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryElementHandler.h"
#include "internal/berryStandardElementHandler.h"
#include "Poco/Exception.h"
namespace berry {
ElementHandler::Pointer
ElementHandler::GetDefault()
{
static ElementHandler::Pointer instance(new StandardElementHandler());
return instance;
}
Expression::Pointer
ElementHandler::Create(ExpressionConverter* /*converter*/, Poco::XML::Element* /*element*/)
{
throw Poco::NotImplementedException();
}
void
ElementHandler::ProcessChildren(ExpressionConverter* converter, IConfigurationElement::Pointer element, CompositeExpression::Pointer expression)
{
converter->ProcessChildren(element, expression);
}
void
ElementHandler::ProcessChildren(ExpressionConverter* converter, Poco::XML::Element* element, CompositeExpression::Pointer expression)
{
converter->ProcessChildren(element, expression);
}
} // namespace berry
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryElementHandler.h b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryElementHandler.h
index e194496cdb..4719c614b7 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryElementHandler.h
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryElementHandler.h
@@ -1,129 +1,129 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYELEMENTHANDLER_H_
#define BERRYELEMENTHANDLER_H_
#include <Poco/DOM/Element.h>
#include <berryIConfigurationElement.h>
#include <berryMacros.h>
#include "berryExpression.h"
#include <org_blueberry_core_expressions_Export.h>
#include "internal/berryCompositeExpression.h"
namespace berry {
class ExpressionConverter;
/**
* An element handler converts an {@link IConfigurationElement} into a
* corresponding expression object.
* <p>
* The class should be subclassed by clients wishing to provide an element
* handler for special expressions.
* </p>
* @since 3.0
*/
class BERRY_EXPRESSIONS ElementHandler : public Object {
public:
berryObjectMacro(ElementHandler)
virtual ~ElementHandler() {}
/**
* The default element handler which can cope with all XML expression elements
* defined by the common expression language.
*
* @return the default element handler
*/
static ElementHandler::Pointer GetDefault();
/**
* Creates the corresponding expression for the given configuration element.
*
* @param converter the expression converter used to initiate the
* conversion process
*
* @param config the configuration element to convert
*
* @return the corresponding expression
*
* @throws CoreException if the conversion failed
*/
virtual Expression::Pointer Create(ExpressionConverter* converter, SmartPointer<IConfigurationElement> config) = 0;
/**
* Creates the corresponding expression for the given DOM element. This is
* an optional operation that is only required if the handler supports conversion
* of DOM elements.
*
* @param converter the expression converter used to initiate the
* conversion process
*
* @param element the DOM element to convert
*
* @return the corresponding expression
*
* @throws CoreException if the conversion failed
*
* @since 3.3
*/
virtual Expression::Pointer Create(ExpressionConverter* converter, Poco::XML::Element* element);
protected:
/**
* Converts the children of the given configuration element and adds them
* to the given composite expression.
* <p>
* Note this is an internal method and should not be called by clients.
* </p>
* @param converter the converter used to do the actual conversion
* @param element the configuration element for which the children
* are to be processed
* @param expression the composite expression representing the result
* of the conversion
*
* @throws CoreException if the conversion failed
*/
virtual void ProcessChildren(ExpressionConverter* converter, SmartPointer<IConfigurationElement> element, SmartPointer<CompositeExpression> expression);
/**
* Converts the children of the given DOM element and adds them to the
* given composite expression.
* <p>
* Note this is an internal method and should not be called by clients.
* </p>
* @param converter the converter used to do the actual conversion
* @param element the DOM element for which the children are to be processed
* @param expression the composite expression representing the result
* of the conversion
*
* @throws CoreException if the conversion failed
*
* @since 3.3
*/
virtual void ProcessChildren(ExpressionConverter* converter, Poco::XML::Element* element, SmartPointer<CompositeExpression> expression);
};
} // namespace berry
#endif /*BERRYELEMENTHANDLER_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryEvaluationContext.cpp b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryEvaluationContext.cpp
index 5ca8072191..d1b9477887 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryEvaluationContext.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryEvaluationContext.cpp
@@ -1,135 +1,135 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryEvaluationContext.h"
namespace berry {
EvaluationContext::EvaluationContext(IEvaluationContext* parent,
Object::Pointer defaultVariable)
{
poco_assert(defaultVariable.IsNotNull());
fParent = parent;
fDefaultVariable = defaultVariable;
fAllowPluginActivation = parent->GetAllowPluginActivation();
}
EvaluationContext::EvaluationContext(IEvaluationContext* parent,
Object::Pointer defaultVariable,
std::vector<IVariableResolver*> resolvers)
{
poco_assert(defaultVariable.IsNotNull());
poco_assert(resolvers.size() != 0);
fParent= parent;
fDefaultVariable= defaultVariable;
fVariableResolvers= resolvers;
fAllowPluginActivation = parent->GetAllowPluginActivation();
}
IEvaluationContext*
EvaluationContext::GetParent() const
{
return fParent;
}
IEvaluationContext*
EvaluationContext::GetRoot()
{
if (fParent == 0)
return this;
return fParent->GetRoot();
}
Object::Pointer
EvaluationContext::GetDefaultVariable() const
{
return fDefaultVariable;
}
void
EvaluationContext::SetAllowPluginActivation(bool value)
{
fAllowPluginActivation= value;
}
bool
EvaluationContext::GetAllowPluginActivation() const
{
return fAllowPluginActivation;
}
void
EvaluationContext::AddVariable(const std::string& name, Object::Pointer value)
{
poco_assert(name.size() != 0);
poco_assert(value.IsNotNull());
fVariables[name] = value;
}
Object::Pointer
EvaluationContext::RemoveVariable(const std::string& name)
{
poco_assert(name.size() != 0);
Object::Pointer elem(fVariables[name]);
fVariables.erase(name);
return elem;
}
Object::Pointer
EvaluationContext::GetVariable(const std::string& name) const
{
poco_assert(name.size() != 0);
Object::Pointer result;
std::map<std::string, Object::Pointer>::const_iterator iter(fVariables.find(name));
if (iter != fVariables.end()) {
result = iter->second;
}
if (!result.IsNull())
return result;
if (fParent != 0)
return fParent->GetVariable(name);
return result;
}
Object::Pointer
EvaluationContext::ResolveVariable(const std::string& name, std::vector<Object::Pointer>& args)
{
if (fVariableResolvers.size() > 0) {
for (unsigned int i= 0; i < fVariableResolvers.size(); ++i) {
IVariableResolver* resolver = fVariableResolvers[i];
Object::Pointer variable(resolver->Resolve(name, args));
if (!variable.IsNull())
return variable;
}
}
if (fParent != 0)
return fParent->ResolveVariable(name, args);
return Object::Pointer();
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryEvaluationContext.h b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryEvaluationContext.h
index 01d08d7262..24fd3457d7 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryEvaluationContext.h
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryEvaluationContext.h
@@ -1,123 +1,123 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYEVALUATIONCONTEXT_H_
#define BERRYEVALUATIONCONTEXT_H_
#include "berryIEvaluationContext.h"
#include "berryIVariableResolver.h"
#include <org_blueberry_core_expressions_Export.h>
#include "Poco/Any.h"
#include <vector>
#include <map>
namespace berry {
/**
* A default implementation of an evaluation context.
* <p>
* Clients may instantiate this default context. The class is
* not intended to be subclassed by clients.
* </p>
*
* @since 3.0
*/
class BERRY_EXPRESSIONS EvaluationContext : public IEvaluationContext
{
private:
IEvaluationContext* fParent;
Object::Pointer fDefaultVariable;
std::map<std::string, Object::Pointer> fVariables;
std::vector<IVariableResolver*> fVariableResolvers;
bool fAllowPluginActivation;
public:
/**
* Create a new evaluation context with the given parent and default
* variable.
*
* @param parent the parent context. Can be <code>null</code>.
* @param defaultVariable the default variable
*/
EvaluationContext(IEvaluationContext* parent, Object::Pointer defaultVariable);
/**
* Create a new evaluation context with the given parent and default
* variable.
*
* @param parent the parent context. Can be <code>null</code>.
* @param defaultVariable the default variable
* @param resolvers an array of <code>IVariableResolvers</code> to
* resolve additional variables.
*
* @see #resolveVariable(String, Object[])
*/
EvaluationContext(IEvaluationContext* parent, Object::Pointer defaultVariable, std::vector<IVariableResolver*> resolvers);
/**
* {@inheritDoc}
*/
IEvaluationContext* GetParent() const;
/**
* {@inheritDoc}
*/
IEvaluationContext* GetRoot();
/**
* {@inheritDoc}
*/
Object::Pointer GetDefaultVariable() const;
/**
* {@inheritDoc}
*/
void SetAllowPluginActivation(bool value);
/**
* {@inheritDoc}
*/
bool GetAllowPluginActivation() const;
/**
* {@inheritDoc}
*/
void AddVariable(const std::string& name, Object::Pointer value);
/**
* {@inheritDoc}
*/
Object::Pointer RemoveVariable(const std::string& name);
/**
* {@inheritDoc}
*/
Object::Pointer GetVariable(const std::string& name) const;
/**
* {@inheritDoc}
*/
Object::Pointer ResolveVariable(const std::string& name, std::vector<Object::Pointer>& args);
};
} // namespace berry
#endif /*BERRYEVALUATIONCONTEXT_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryEvaluationResult.cpp b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryEvaluationResult.cpp
index 5a481ee4a0..b73f2bf600 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryEvaluationResult.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryEvaluationResult.cpp
@@ -1,108 +1,108 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryEvaluationResult.h"
#include "Poco/Exception.h"
namespace berry {
const int EvaluationResult::FALSE_VALUE= 0;
const int EvaluationResult::TRUE_VALUE= 1;
const int EvaluationResult::NOT_LOADED_VALUE= 2;
const EvaluationResult EvaluationResult::FALSE_EVAL(EvaluationResult::FALSE_VALUE);
const EvaluationResult EvaluationResult::TRUE_EVAL(EvaluationResult::TRUE_VALUE);
const EvaluationResult EvaluationResult::NOT_LOADED(NOT_LOADED_VALUE);
bool EvaluationResult::operator==(const EvaluationResult& result)
{
return this->fValue == result.fValue;
}
bool EvaluationResult::operator!=(const EvaluationResult& result)
{
return this->fValue != result.fValue;
}
const EvaluationResult EvaluationResult::AND[3][3] = {
// FALSE TRUE NOT_LOADED
/* FALSE */ { EvaluationResult::FALSE_EVAL, EvaluationResult::FALSE_EVAL, EvaluationResult::FALSE_EVAL },
/* TRUE */ { EvaluationResult::FALSE_EVAL, EvaluationResult::TRUE_EVAL, EvaluationResult::NOT_LOADED },
/* PNL */ { EvaluationResult::FALSE_EVAL, EvaluationResult::NOT_LOADED, EvaluationResult::NOT_LOADED }
};
const EvaluationResult EvaluationResult::OR[3][3] = {
// FALSE TRUE NOT_LOADED
/* FALSE */ { EvaluationResult::FALSE_EVAL, EvaluationResult::TRUE_EVAL, EvaluationResult::NOT_LOADED },
/* TRUE */ { EvaluationResult::TRUE_EVAL, EvaluationResult::TRUE_EVAL, EvaluationResult::TRUE_EVAL },
/* PNL */ { EvaluationResult::NOT_LOADED, EvaluationResult::TRUE_EVAL, EvaluationResult::NOT_LOADED }
};
const EvaluationResult EvaluationResult::NOT[3] = {
// FALSE TRUE NOT_LOADED
EvaluationResult::TRUE_EVAL, EvaluationResult::FALSE_EVAL, EvaluationResult::NOT_LOADED
};
EvaluationResult::EvaluationResult(int value)
{
fValue= value;
}
EvaluationResult
EvaluationResult::And(EvaluationResult other)
{
return AND[fValue][other.fValue];
}
EvaluationResult
EvaluationResult::Or(EvaluationResult other)
{
return OR[fValue][other.fValue];
}
EvaluationResult
EvaluationResult::Not()
{
return NOT[fValue];
}
EvaluationResult
EvaluationResult::ValueOf(bool b)
{
return b ? TRUE_EVAL : FALSE_EVAL;
}
std::string
EvaluationResult::ToString()
{
switch (fValue) {
case 0:
return "false";
case 1:
return "true";
case 2:
return "not_loaded";
default:
poco_bugcheck();
return "";
}
}
} // namespace berry
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryEvaluationResult.h b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryEvaluationResult.h
index 076b92553f..274d1f0fa6 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryEvaluationResult.h
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryEvaluationResult.h
@@ -1,228 +1,228 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYEVALUATIONRESULT_
#define BERRYEVALUATIONRESULT_
#include <string>
#include <org_blueberry_core_expressions_Export.h>
namespace berry {
/**
* An evaluation result represents the result of an expression
* evaluation. There are exact three instances of evaluation
* result. They are: <code>FALSE_EVAL</code>, <code>TRUE_EVAL</code> and
* <code>NOT_LOADED</code>. <code>NOT_LOADED</code> represents
* the fact that an expression couldn't be evaluated since a
* plug-in providing certain test expressions isn't loaded yet.
* <p>
* In addition the class implements the three operation <code>and
* </code>, <code>or</code> and <code>not</code>. The operation are
* defined as follows:
* </p>
* <p>
* The and operation:
* </p>
* <table border="1" cellpadding="5">
* <colgroup>
* <col width="120">
* <col width="120">
* <col width="120">
* <col width="120">
* </colgroup>
* <tbody>
* <tr>
* <td><em>AND</em></td>
* <td>FALSE_EVAL</td>
* <td>TRUE_EVAL</td>
* <td>NOT_LOADED</td>
* </tr>
* <tr>
* <td>FALSE_EVAL</td>
* <td>FALSE_EVAL</td>
* <td>FALSE_EVAL</td>
* <td>FALSE_EVAL</td>
* </tr>
* <tr>
* <td>TRUE_EVAL</td>
* <td>FALSE_EVAL</td>
* <td>TRUE_EVAL</td>
* <td>NOT_LOADED</td>
* </tr>
* <tr>
* <td>NOT_LOADED</td>
* <td>FALSE_EVAL</td>
* <td>NOT_LOADED</td>
* <td>NOT_LOADED</td>
* </tr>
* </tbody>
* </table>
* <p>
* The or operation:
* </p>
* <table border="1" cellpadding="5">
* <colgroup>
* <col width="120">
* <col width="120">
* <col width="120">
* <col width="120">
* </colgroup>
* <tbody>
* <tr>
* <td><em>OR</em></td>
* <td>FALSE_EVAL</td>
* <td>TRUE_EVAL</td>
* <td>NOT_LOADED</td>
* </tr>
* <tr>
* <td>FALSE_EVAL</td>
* <td>FALSE_EVAL</td>
* <td>TRUE_EVAL</td>
* <td>NOT_LOADED</td>
* </tr>
* <tr>
* <td>TRUE_EVAL</td>
* <td>TRUE_EVAL</td>
* <td>TRUE_EVAL</td>
* <td>TRUE_EVAL</td>
* </tr>
* <tr>
* <td>NOT_LOADED</td>
* <td>NOT_LOADED</td>
* <td>TRUE_EVAL</td>
* <td>NOT_LOADED</td>
* </tr>
* </tbody>
* </table>
* <p>
* The not operation:
* </p>
* <table border="1" cellpadding="5">
* <colgroup>
* <col width="120">
* <col width="120">
* <col width="120">
* <col width="120">
* </colgroup>
* <tbody>
* <tr>
* <td><em>NOT<em></td>
* <td>FALSE_EVAL</td>
* <td>TRUE_EVAL</td>
* <td>NOT_LOADED</td>
* </tr>
* <tr>
* <td></td>
* <td>TRUE_EVAL</td>
* <td>FALSE_EVAL</td>
* <td>NOT_LOADED</td>
* </tr>
* </tbody>
* </table>
*
* <p>
* The class is not intended to be subclassed by clients.
* </p>
* @since 3.0
*/
class BERRY_EXPRESSIONS EvaluationResult {
private:
int fValue;
static const int FALSE_VALUE;
static const int TRUE_VALUE;
static const int NOT_LOADED_VALUE;
public:
/** The evaluation result representing the value FALSE */
static const EvaluationResult FALSE_EVAL;
/** The evaluation result representing the value TRUE */
static const EvaluationResult TRUE_EVAL;
/** The evaluation result representing the value NOT_LOADED */
static const EvaluationResult NOT_LOADED;
private:
static const EvaluationResult AND[3][3];
static const EvaluationResult OR[3][3];
static const EvaluationResult NOT[3];
/*
* No instances outside of <code>EvaluationResult</code>
*/
EvaluationResult(int value);
public:
bool operator==(const EvaluationResult&);
bool operator!=(const EvaluationResult&);
/**
* Returns an <code>EvaluationResult</code> whose value is <code>this &amp;&amp; other)</code>.
*
* @param other the right hand side of the and operation.
*
* @return <code>this &amp;&amp; other</code> as defined by the evaluation result
*/
EvaluationResult And(EvaluationResult other);
/**
* Returns an <code>EvaluationResult</code> whose value is <code>this || other)</code>.
*
* @param other the right hand side of the or operation.
*
* @return <code>this || other</code> as defined by the evaluation result
*/
EvaluationResult Or(EvaluationResult other);
/**
* Returns the inverted value of this evaluation result
*
* @return the inverted value of this evaluation result
*/
EvaluationResult Not();
/**
* Returns an evaluation result instance representing the
* given boolean value. If the given boolean value is
* <code>TRUE_EVAL</code> then <code>ExpressionResult.TRUE_EVAL</code>
* is returned. If the value is <code>FALSE_EVAL</code> then <code>
* ExpressionResult.FALSE_EVAL</code> is returned.
*
* @param b a boolean value
*
* @return the expression result representing the boolean
* value
*/
static EvaluationResult ValueOf(bool b);
/**
* For debugging purpose only
*
* @return a string representing this object. The result is not
* human readable
*/
std::string ToString();
};
} // namespace berry
#endif /*BERRYEVALUATIONRESULT_*/
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryExpression.cpp b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryExpression.cpp
index 5e41125165..eda7ecfa33 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryExpression.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryExpression.cpp
@@ -1,171 +1,171 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryExpression.h"
#include <Poco/Hash.h>
namespace berry {
const std::size_t Expression::HASH_CODE_NOT_COMPUTED = 0;
const std::size_t Expression::HASH_FACTOR = 89;
const std::string Expression::ATT_VALUE= "value"; //$NON-NLS-1$
const Expression::Pointer Expression::TRUE_EVAL(new TRUE_EVALExpression());
const Expression::Pointer Expression::FALSE_EVAL(new FALSE_EVALExpression());
Expression::Expression()
{
fHashCode = HASH_CODE_NOT_COMPUTED;
}
Expression::~Expression()
{
}
bool Expression::Equals(std::vector<Expression::Pointer>& leftArray,
std::vector<Expression::Pointer>& rightArray)
{
if (leftArray == rightArray)
{
return true;
}
if (leftArray.size() != rightArray.size())
{
return false;
}
for (unsigned int i= 0; i < leftArray.size(); ++i)
{
Expression::Pointer left= leftArray[i];
Expression::Pointer right= rightArray[i];
const bool equal = (left.IsNull()) ? (right.IsNull()) : (left == right);
if (!equal)
{
return false;
}
}
return true;
}
bool Expression::Equals(std::vector<Object::Pointer>& leftArray,
std::vector<Object::Pointer>& rightArray)
{
if (leftArray == rightArray)
{
return true;
}
if (leftArray.size() != rightArray.size())
{
return false;
}
for (unsigned int i= 0; i < leftArray.size(); ++i)
{
Object::Pointer left= leftArray[i];
Object::Pointer right= rightArray[i];
const bool equal = (left.IsNull()) ? (right.IsNull()) : (left == right);
if (!equal)
{
return false;
}
}
return true;
}
std::size_t
Expression::HashCode(Expression::Pointer object)
{
return object != 0 ? object->HashCode() : 0;
}
std::size_t
Expression::HashCode(std::vector<Expression::Pointer>& array)
{
if (array.size() == 0) {
return 0;
}
std::size_t hashCode = Poco::hash("std::vector<Expression::Pointer>");
for (unsigned int i= 0; i < array.size(); i++) {
hashCode = hashCode * HASH_FACTOR + HashCode(array[i]);
}
return hashCode;
}
std::size_t
Expression::HashCode(std::vector<Object::Pointer>& array)
{
if (array.size() == 0) {
return 0;
}
int hashCode = (int) Poco::hash("std::vector<Object::Pointer>");
for (unsigned int i= 0; i < array.size(); i++) {
hashCode = hashCode + (int) array[i]->HashCode();
}
return hashCode;
}
const ExpressionInfo*
Expression::ComputeExpressionInfo() const
{
ExpressionInfo* result= new ExpressionInfo();
this->CollectExpressionInfo(result);
return result;
}
void
Expression::CollectExpressionInfo(ExpressionInfo* info) const
{
info->AddMisBehavingExpressionType(typeid(this));
}
std::size_t
Expression::ComputeHashCode() const
{
return reinterpret_cast<std::size_t>(this);
}
std::size_t
Expression::HashCode() const
{
if (fHashCode != HASH_CODE_NOT_COMPUTED)
return fHashCode;
fHashCode= this->ComputeHashCode();
if (fHashCode == HASH_CODE_NOT_COMPUTED)
fHashCode++;
return fHashCode;
}
bool
Expression::operator==(const Object* object) const
{
if (const Expression* other = dynamic_cast<const Expression*>(object))
return this->HashCode() == other->HashCode();
return false;
}
std::string Expression::ToString()
{
return typeid(this).name();
}
} // namespace berry
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryExpression.h b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryExpression.h
index 5c5d5abc52..006c62eecb 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryExpression.h
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryExpression.h
@@ -1,240 +1,240 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYEXPRESSION_H_
#define BERRYEXPRESSION_H_
#include "berryExpressionInfo.h"
#include "berryIEvaluationContext.h"
#include "berryEvaluationResult.h"
#include <org_blueberry_core_expressions_Export.h>
#include <berryMacros.h>
#include <berryObject.h>
#include <string>
namespace berry {
/**
* Abstract base class for all expressions provided by the common
* expression language.
* <p>
* An expression is evaluated by calling {@link #evaluate(IEvaluationContext)}.
* </p>
* <p>
* This class may be subclassed to provide specific expressions.
* </p>
*
* @since 3.0
*/
class BERRY_EXPRESSIONS Expression : public Object {
public:
berryObjectMacro(Expression)
/**
* The constant integer hash code value meaning the hash code has not yet
* been computed.
*/
static const std::size_t HASH_CODE_NOT_COMPUTED;
/**
* A factor for computing the hash code for all expressions.
*/
static const std::size_t HASH_FACTOR;
/**
* Name of the value attribute of an expression (value is <code>value</code>).
*/
static const std::string ATT_VALUE;
private:
/**
* The hash code for this object. This value is computed lazily. If it is
* not yet computed, it is equal to {@link #HASH_CODE_NOT_COMPUTED}.
*/
mutable std::size_t fHashCode;
protected:
/**
* Checks whether two objects are equal using the
* <code>equals(Object)</code> method of the <code>left</code> object.
* This method handles <code>null</code> for either the <code>left</code>
* or <code>right</code> object.
*
* @param left the first object to compare; may be <code>null</code>.
* @param right the second object to compare; may be <code>null</code>.
* @return <code>TRUE_EVAL</code> if the two objects are equivalent;
* <code>FALSE_EVAL</code> otherwise.
*
* @since 3.2
*/
// static bool Equals(final Object left, final Object right);
/**
* Tests whether two arrays of objects are equal to each other. The arrays
* must not be <code>null</code>, but their elements may be
* <code>null</code>.
*
* @param leftArray the left array to compare; may be <code>null</code>, and
* may be empty and may contain <code>null</code> elements.
* @param rightArray the right array to compare; may be <code>null</code>,
* and may be empty and may contain <code>null</code> elements.
*
* @return <code>TRUE_EVAL</code> if the arrays are equal length and the elements
* at the same position are equal; <code>FALSE_EVAL</code> otherwise.
*
* @since 3.2
*/
static bool Equals(std::vector<Expression::Pointer>& leftArray, std::vector<Expression::Pointer>& rightArray);
static bool Equals(std::vector<Object::Pointer>& leftArray, std::vector<Object::Pointer>& rightArray);
/**
* Returns the hash code for the given <code>object</code>. This method
* handles <code>null</code>.
*
* @param object the object for which the hash code is desired; may be
* <code>null</code>.
*
* @return The hash code of the object; zero if the object is
* <code>null</code>.
*
* @since 3.2
*/
static std::size_t HashCode(Expression::Pointer object);
/**
* Returns the hash code for the given array. This method handles
* <code>null</code>.
*
* @param array the array for which the hash code is desired; may be
* <code>null</code>.
* @return the hash code of the array; zero if the object is
* <code>null</code>.
*
* @since 3.2
*/
static std::size_t HashCode(std::vector<Expression::Pointer>& array);
static std::size_t HashCode(std::vector<Object::Pointer>& array);
/**
* Method to compute the hash code for this object. The result
* returned from this method is cached in the <code>fHashCode</code>
* field. If the value returned from the method equals {@link #HASH_CODE_NOT_COMPUTED}
* (e.g. <code>-1</code>) then the value is incremented by one.
* <p>
* This default implementation calls <code>super.hashCode()</code>
* </p>
* @return a hash code for this object.
*
* @since 3.2
*/
virtual std::size_t ComputeHashCode() const;
public:
/**
* The expression corresponding to {@link EvaluationResult#TRUE_EVAL}.
*/
static const Expression::Pointer TRUE_EVAL;
/**
* The expression corresponding to {@link EvaluationResult#FALSE_EVAL}.
*/
static const Expression::Pointer FALSE_EVAL;
Expression();
virtual ~Expression();
virtual std::size_t HashCode() const;
/**
* Evaluates this expression.
*
* @param context an evaluation context providing information like variable,
* name spaces, etc. necessary to evaluate this expression
*
* @return the result of the expression evaluation
*
* @throws CoreException if the evaluation failed. The concrete reason is
* defined by the subclass implementing this method
*/
virtual EvaluationResult Evaluate(IEvaluationContext* context) = 0;
/**
* Computes the expression information for the given expression tree.
* <p>
* This is a convenience method for collecting the expression information
* using {@link Expression#collectExpressionInfo(ExpressionInfo)}.
* </p>
*
* @return the expression information
*
* @since 3.2
*/
virtual const ExpressionInfo* ComputeExpressionInfo() const;
/**
* Collects information about this expression tree. This default
* implementation add the expression's type to the set of misbehaving
* expression types.
*
* @param info the expression information object used
* to collect the information
*
* @since 3.2
*/
virtual void CollectExpressionInfo(ExpressionInfo* info) const;
virtual std::string ToString();
virtual bool operator==(const Object* object) const;
};
class TRUE_EVALExpression : public Expression
{
public:
EvaluationResult Evaluate(IEvaluationContext* /*context*/)
{
return EvaluationResult::TRUE_EVAL;
}
void CollectExpressionInfo(ExpressionInfo* /*info*/) {}
};
class FALSE_EVALExpression : public Expression
{
public:
EvaluationResult Evaluate(IEvaluationContext* /*context*/)
{
return EvaluationResult::FALSE_EVAL;
}
void CollectExpressionInfo(ExpressionInfo* /*info*/) {}
};
} // namespace berry
#endif /*BERRYEXPRESSION_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryExpressionConverter.cpp b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryExpressionConverter.cpp
index b690e55804..759aa7d944 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryExpressionConverter.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryExpressionConverter.cpp
@@ -1,129 +1,129 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryExpressionConverter.h"
#include "berryPlatformException.h"
#include "Poco/DOM/Node.h"
namespace berry {
ExpressionConverter* ExpressionConverter::INSTANCE = 0;
ExpressionConverter*
ExpressionConverter::GetDefault()
{
if (INSTANCE) return INSTANCE;
std::vector<ElementHandler::Pointer> handlers;
handlers.push_back(ElementHandler::GetDefault());
INSTANCE = new ExpressionConverter(handlers);
return INSTANCE;
}
ExpressionConverter::ExpressionConverter(std::vector<ElementHandler::Pointer>& handlers)
{
fHandlers = handlers;
}
Expression::Pointer
ExpressionConverter::Perform(IConfigurationElement::Pointer root)
{
for (unsigned int i = 0; i < fHandlers.size(); i++) {
ElementHandler::Pointer handler = fHandlers[i];
Expression::Pointer result = handler->Create(this, root);
if (!result.IsNull())
return result;
}
return Expression::Pointer();
}
Expression::Pointer
ExpressionConverter::Perform(Poco::XML::Element* root)
{
for (unsigned int i = 0; i < fHandlers.size(); i++) {
ElementHandler::Pointer handler = fHandlers[i];
Expression::Pointer result = handler->Create(this, root);
if (!result.IsNull())
return result;
}
return Expression::Pointer();
}
void
ExpressionConverter::ProcessChildren(IConfigurationElement::Pointer element, CompositeExpression::Pointer result)
{
IConfigurationElement::vector children(element->GetChildren());
IConfigurationElement::vector::iterator iter;
for (iter = children.begin(); iter != children.end(); ++iter)
{
Expression::Pointer child = this->Perform(*iter);
if (child.IsNull())
throw new CoreException("Unknown element", GetDebugPath(*iter));
result->Add(child);
}
}
std::string
ExpressionConverter::GetDebugPath(IConfigurationElement::Pointer configurationElement)
{
std::string buf = "";
buf.append(configurationElement->GetName());
const IConfigurationElement* parent= configurationElement->GetParent();
while (parent) {
if (parent->GetParent())
{
buf.append(" > ");
buf.append(parent->GetName());
parent = parent->GetParent();
}
else
{
buf.append(" : "); //$NON-NLS-1$
std::string point;
parent->GetAttribute("point", point);
buf.append(point);
buf.append(" @ "); //$NON-NLS-1$
buf.append(parent->GetContributor());
parent= 0;
}
}
return buf;
}
void
ExpressionConverter::ProcessChildren(Poco::XML::Element* element, CompositeExpression::Pointer result)
{
Poco::XML::Node* child = element->firstChild();
while (child != 0) {
if (child->nodeType() == Poco::XML::Node::ELEMENT_NODE) {
Poco::XML::Element* elem = static_cast<Poco::XML::Element*>(child);
Expression::Pointer exp = this->Perform(elem);
if (exp.IsNull())
throw CoreException("org.blueberry.core.expressions unknown element", elem->nodeName());
result->Add(exp);
}
child = child->nextSibling();
}
}
} // namespace berry
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryExpressionConverter.h b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryExpressionConverter.h
index 23118d1186..6fbed60ba1 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryExpressionConverter.h
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryExpressionConverter.h
@@ -1,118 +1,118 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYEXPRESSIONCONVERTER_H_
#define BERRYEXPRESSIONCONVERTER_H_
#include "berryElementHandler.h"
#include "berryExpression.h"
#include "internal/berryCompositeExpression.h"
#include "Poco/DOM/Element.h"
#include <string>
#include <vector>
namespace berry {
/**
* An expression converter converts an XML expression represented by an
* {@link IConfigurationElement} or {@link Element} (DOM) subtree into a
* corresponding expression tree.
*
* <p>
* An expression converter manages a list of {@link ElementHandler}s. Element
* handlers are responsible to do the actual conversion. The element handlers
* build a chain of responsibility.
* </p>
*
* @since 3.0
*/
class BERRY_EXPRESSIONS ExpressionConverter {
private:
std::vector<ElementHandler::Pointer> fHandlers;
static ExpressionConverter* INSTANCE;
public:
/**
* Returns the default expression converter. The default expression converter
* can cope with all expression elements defined by the common expression
* language.
*
* @return the default expression converter
*/
static ExpressionConverter* GetDefault();
/**
* Creates a new expression converter with the given list of element
* handlers. The element handlers build a chain of responsibility
* meaning that the first handler in the list is first used to
* convert the configuration element. If this handler isn't able
* to convert the configuration element the next handler in the
* array is used.
*
* @param handlers the array of element handlers
*/
ExpressionConverter(std::vector<ElementHandler::Pointer>& handlers);
/**
* Converts the tree of configuration elements represented by the given
* root element and returns a corresponding expression tree.
*
* @param root the configuration element to be converted
*
* @return the corresponding expression tree or <code>null</code>
* if the configuration element cannot be converted
*
* @throws CoreException if the configuration element can't be
* converted. Reasons include: (a) no handler is available to
* cope with a certain configuration element or (b) the XML
* expression tree is malformed.
*/
Expression::Pointer Perform(SmartPointer<IConfigurationElement> root);
/**
* Converts the tree of DOM elements represented by the given
* root element and returns a corresponding expression tree.
*
* @param root the element to be converted
*
* @return the corresponding expression tree or <code>null</code>
* if the element cannot be converted
*
* @throws CoreException if the element can't be converted.
* Reasons include: (a) no handler is available to cope with
* a certain element or (b) the XML expression tree is malformed.
*
* @since 3.3
*/
Expression::Pointer Perform(Poco::XML::Element* root);
void ProcessChildren(SmartPointer<IConfigurationElement> element, SmartPointer<CompositeExpression> result);
std::string GetDebugPath(SmartPointer<IConfigurationElement> configurationElement);
void ProcessChildren(Poco::XML::Element* element, SmartPointer<CompositeExpression> result);
};
} // namespace berry
#endif /*BERRYEXPRESSIONCONVERTER_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryExpressionInfo.cpp b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryExpressionInfo.cpp
index 97642ddf0c..1e4e7c342e 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryExpressionInfo.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryExpressionInfo.cpp
@@ -1,163 +1,163 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryExpressionInfo.h"
#include <algorithm>
namespace berry {
bool
ExpressionInfo::HasDefaultVariableAccess() const
{
return fHasDefaultVariableAccess;
}
void
ExpressionInfo::MarkDefaultVariableAccessed()
{
fHasDefaultVariableAccess= true;
}
bool
ExpressionInfo::HasSystemPropertyAccess() const
{
return fHasSystemPropertyAccess;
}
void
ExpressionInfo::MarkSystemPropertyAccessed()
{
fHasSystemPropertyAccess= true;
}
std::set<std::string>
ExpressionInfo::GetAccessedVariableNames() const
{
return fAccessedVariableNames;
}
void
ExpressionInfo::AddVariableNameAccess(const std::string& name)
{
fAccessedVariableNames.insert(name);
}
std::set<std::string>
ExpressionInfo::GetAccessedPropertyNames() const
{
return fAccessedPropertyNames;
}
void
ExpressionInfo::AddAccessedPropertyName(const std::string& name)
{
fAccessedPropertyNames.insert(name);
}
std::set<std::string>
ExpressionInfo::GetMisbehavingExpressionTypes() const
{
return fMisbehavingExpressionTypes;
}
void
ExpressionInfo::AddMisBehavingExpressionType(const std::type_info& clazz)
{
fMisbehavingExpressionTypes.insert(clazz.name());
}
void
ExpressionInfo::Merge(ExpressionInfo* other)
{
this->MergeDefaultVariableAccess(other);
this->MergeSystemPropertyAccess(other);
this->MergeAccessedVariableNames(other);
this->MergeAccessedPropertyNames(other);
this->MergeMisbehavingExpressionTypes(other);
}
void
ExpressionInfo::MergeExceptDefaultVariable(ExpressionInfo* other)
{
this->MergeSystemPropertyAccess(other);
this->MergeAccessedVariableNames(other);
this->MergeAccessedPropertyNames(other);
this->MergeMisbehavingExpressionTypes(other);
}
void
ExpressionInfo::MergeDefaultVariableAccess(ExpressionInfo* other)
{
fHasDefaultVariableAccess= fHasDefaultVariableAccess || other->fHasDefaultVariableAccess;
}
void
ExpressionInfo::MergeSystemPropertyAccess(ExpressionInfo* other)
{
fHasSystemPropertyAccess= fHasSystemPropertyAccess || other->fHasSystemPropertyAccess;
}
void
ExpressionInfo::MergeAccessedVariableNames(ExpressionInfo* other)
{
if (fAccessedVariableNames.size() == 0) {
fAccessedVariableNames= other->fAccessedVariableNames;
}
else
{
for (std::set<std::string>::iterator iter = other->fAccessedVariableNames.begin(); iter != other->fAccessedVariableNames.end(); ++iter)
{
fAccessedVariableNames.insert(*iter);
}
}
}
void
ExpressionInfo::MergeAccessedPropertyNames(ExpressionInfo* other)
{
if (fAccessedPropertyNames.size() == 0)
{
fAccessedPropertyNames = other->fAccessedPropertyNames;
}
else
{
for (std::set<std::string>::iterator iter = other->fAccessedPropertyNames.begin(); iter != other->fAccessedPropertyNames.end(); ++iter)
{
fAccessedPropertyNames.insert(*iter);
}
}
}
void
ExpressionInfo::MergeMisbehavingExpressionTypes(ExpressionInfo* other)
{
if (fMisbehavingExpressionTypes.size() == 0)
{
fMisbehavingExpressionTypes= other->fMisbehavingExpressionTypes;
}
else
{
for (std::set<std::string>::iterator iter= other->fMisbehavingExpressionTypes.begin(); iter != other->fMisbehavingExpressionTypes.end(); ++iter)
{
fMisbehavingExpressionTypes.insert(*iter);
}
}
}
} // namespace berry
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryExpressionInfo.h b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryExpressionInfo.h
index 1bffda5621..0c32ceb798 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryExpressionInfo.h
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryExpressionInfo.h
@@ -1,189 +1,189 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYEXPRESSIONINFO_H_
#define BERRYEXPRESSIONINFO_H_
#include <string>
#include <typeinfo>
#include <set>
#include <org_blueberry_core_expressions_Export.h>
namespace berry {
/**
* A status object describing information about an expression tree.
* This information can for example be used to decide whether a
* expression tree as to be reevaluated if the value of some
* variables changes.
* <p>
* This class is not intended to be extended by clients.
* </p>
*
* @since 3.2
*/
class BERRY_EXPRESSIONS ExpressionInfo {
private:
bool fHasDefaultVariableAccess;
bool fHasSystemPropertyAccess;
// Although we are using this as sets we use lists since
// they are faster for smaller numbers of elements
std::set<std::string> fAccessedVariableNames;
std::set<std::string> fMisbehavingExpressionTypes;
std::set<std::string> fAccessedPropertyNames;
public:
/**
* Returns <code>true</code> if the default variable is accessed
* by the expression tree.
*
* @return whether the default variable is accessed or not
*/
bool HasDefaultVariableAccess() const;
/**
* Marks the default variable as accessed.
*/
void MarkDefaultVariableAccessed();
/**
* Returns <code>true</code> if the system property is accessed
* by the expression tree.
*
* @return whether the system property is accessed or not
*/
bool HasSystemPropertyAccess() const;
/**
* Marks the system property as accessed.
*/
void MarkSystemPropertyAccessed();
/**
* Returns the set off accessed variables.
*
* @return the set off accessed variables
*/
std::set<std::string> GetAccessedVariableNames() const;
/**
* Marks the given variable as accessed.
*
* @param name the accessed variable
*/
void AddVariableNameAccess(const std::string& name);
/**
* Returns the set of accessed properties.
*
* @return the set of accessed properties, or an empty array
* @since 3.4
*/
std::set<std::string> GetAccessedPropertyNames() const;
/**
* Marks that this expression access this property. It should be the fully
* qualified property name.
*
* @param name
* the fully qualified property name
* @since 3.4
*/
void AddAccessedPropertyName(const std::string& name);
/**
* Returns the set of expression types which don't implement the
* new (@link Expression#computeReevaluationInfo(IEvaluationContext)}
* method. If one expression didn't implement the method the expression
* tree no optimizations can be done. Returns <code>null</code> if
* all expressions implement the method.
*
* @return the set of expression types which don't implement the
* <code>computeReevaluationInfo</code> method.
*/
std::set<std::string> GetMisbehavingExpressionTypes() const;
/**
* Adds the given class to the list of misbehaving classes.
*
* @param clazz the class to add.
*/
void AddMisBehavingExpressionType(const std::type_info& clazz);
/**
* Merges this reevaluation information with the given info.
*
* @param other the information to merge with
*/
void Merge(ExpressionInfo* other);
/**
* Merges this reevaluation information with the given info
* ignoring the default variable access.
*
* @param other the information to merge with
*/
void MergeExceptDefaultVariable(ExpressionInfo* other);
private:
/**
* Merges only the default variable access.
*
* @param other the information to merge with
*/
void MergeDefaultVariableAccess(ExpressionInfo* other);
/**
* Merges only the system property access.
*
* @param other the information to merge with
*/
void MergeSystemPropertyAccess(ExpressionInfo* other);
/**
* Merges only the accessed variable names.
*
* @param other the information to merge with
*/
void MergeAccessedVariableNames(ExpressionInfo* other);
/**
* Merges only the accessed property names.
*
* @param other the information to merge with
* @since 3.4
*/
void MergeAccessedPropertyNames(ExpressionInfo* other);
/**
* Merges only the misbehaving expression types.
*
* @param other the information to merge with
*/
void MergeMisbehavingExpressionTypes(ExpressionInfo* other);
};
} // namespace berry
#endif /*BERRYEXPRESSIONINFO_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryExpressionTagNames.cpp b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryExpressionTagNames.cpp
index 5490aace15..88df53a279 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryExpressionTagNames.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryExpressionTagNames.cpp
@@ -1,36 +1,36 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryExpressionTagNames.h"
namespace berry {
const std::string ExpressionTagNames::ENABLEMENT= "enablement"; //$NON-NLS-1$
const std::string ExpressionTagNames::AND= "and"; //$NON-NLS-1$
const std::string ExpressionTagNames::OR= "or"; //$NON-NLS-1$
const std::string ExpressionTagNames::NOT= "not"; //$NON-NLS-1$
const std::string ExpressionTagNames::INSTANCEOF= "instanceof"; //$NON-NLS-1$
const std::string ExpressionTagNames::TEST= "test"; //$NON-NLS-1$
const std::string ExpressionTagNames::WITH= "with"; //$NON-NLS-1$
const std::string ExpressionTagNames::ADAPT= "adapt"; //$NON-NLS-1$
const std::string ExpressionTagNames::COUNT= "count"; //$NON-NLS-1$
const std::string ExpressionTagNames::ITERATE= "iterate"; //$NON-NLS-1$
const std::string ExpressionTagNames::RESOLVE= "resolve"; //$NON-NLS-1$
const std::string ExpressionTagNames::SYSTEM_TEST= "systemTest"; //$NON-NLS-1$
const std::string ExpressionTagNames::EQUALS= "equals"; //$NON-NLS-1$
const std::string ExpressionTagNames::REFERENCE= "reference"; //$NON-NLS-1$
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryExpressionTagNames.h b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryExpressionTagNames.h
index 421a9fdd6d..c67875e9ec 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryExpressionTagNames.h
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryExpressionTagNames.h
@@ -1,85 +1,85 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYEXPRESSIONTAGNAMES_H_
#define BERRYEXPRESSIONTAGNAMES_H_
#include <string>
#include <org_blueberry_core_expressions_Export.h>
namespace berry {
/**
* Class defining the tag names of the XML elements of the common
* expression language.
*
* @since 3.0
*/
class BERRY_EXPRESSIONS ExpressionTagNames {
public:
/** The tag name of the enablement expression (value: <code>enablement</code>) */
static const std::string ENABLEMENT;
/** The tag name of the and expression (value: <code>and</code>) */
static const std::string AND;
/** The tag name of the or expression (value: <code>or</code>) */
static const std::string OR;
/** The tag name of the not expression (value: <code>not</code>) */
static const std::string NOT;
/** The tag name of the instanceof expression (value: <code>instanceof</code>) */
static const std::string INSTANCEOF;
/** The tag name of the test expression (value: <code>test</code>) */
static const std::string TEST;
/** The tag name of the with expression (value: <code>with</code>) */
static const std::string WITH;
/** The tag name of the adapt expression (value: <code>adapt</code>) */
static const std::string ADAPT;
/** The tag name of the count expression (value: <code>count</code>) */
static const std::string COUNT;
/** The tag name of the adapt expression (value: <code>iterate</code>) */
static const std::string ITERATE;
/** The tag name of the resolve expression (value: <code>resolve</code>) */
static const std::string RESOLVE;
/** The tag name of the systemTest expression (value: <code>systemTest</code>) */
static const std::string SYSTEM_TEST;
/** The tag name of the equals expression (value: <code>equals</code>) */
static const std::string EQUALS;
/**
* The tag name of the reference expression (value: <code>reference</code>)
*
* @since 3.3
*/
static const std::string REFERENCE;
};
} // namespace berry
#endif /*BERRYEXPRESSIONTAGNAMES_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryICountable.h b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryICountable.h
index 4153e3f9e9..8d662cf731 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryICountable.h
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryICountable.h
@@ -1,53 +1,53 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYICOUNTABLE_H_
#define BERRYICOUNTABLE_H_
#include <berryObject.h>
#include <berryMacros.h>
#include <org_blueberry_core_expressions_Export.h>
namespace berry {
/**
* Objects that are adaptable to <code>ICountable</code> can be used
* as the default variable in a count expression.
*
* @see IAdaptable
* @see IAdapterManager
*
* @since 3.3
*/
struct BERRY_EXPRESSIONS ICountable : public Object {
berryObjectMacro(ICountable)
/**
* Returns the number of elements.
*
* @return the number of elements
*/
virtual int Count() = 0;
virtual ~ICountable() {}
};
}
#endif /*BERRYICOUNTABLE_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryIEvaluationContext.h b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryIEvaluationContext.h
index 4ed6969b3b..583536e897 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryIEvaluationContext.h
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryIEvaluationContext.h
@@ -1,144 +1,144 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIEVALUATIONCONTEXT_H_
#define BERRYIEVALUATIONCONTEXT_H_
#include <string>
#include <vector>
#include <berryMacros.h>
#include <berryObject.h>
#include <org_blueberry_core_expressions_Export.h>
namespace berry {
/**
* An evaluation context is used to manage a set of objects needed during
* XML expression evaluation. A context has a parent context, can manage
* a set of named variables and has a default variable. The default variable
* is used during XML expression evaluation if no explicit variable is
* referenced.
* <p>
* This interface is not intended to be implemented by clients. Clients
* are allowed to instantiate <code>EvaluationContext</code>.
* </p>
*
* @since 3.0
*/
struct BERRY_EXPRESSIONS IEvaluationContext : public Object {
berryInterfaceMacro(IEvaluationContext, berry);
virtual ~IEvaluationContext() {}
/**
* Returns the parent context or <code>null</code> if
* this is the root of the evaluation context hierarchy.
*
* @return the parent evaluation context or <code>null</code>
*/
virtual IEvaluationContext* GetParent() const = 0;
/**
* Returns the root evaluation context.
*
* @return the root evaluation context
*/
virtual IEvaluationContext* GetRoot() = 0;
/**
* Specifies whether this evaluation context allows activation
* of plug-ins for testers used in the expression tree. To actual
* trigger the plug-in loading this flag has to be set to <code>
* true</code> and the actual test expression must have the
* attribute <code>forcePluginActivation</code> set to <code>
* true</code> as well.
*
* @param value whether this evaluation context allows plug-in activation
* @since 3.2
*/
virtual void SetAllowPluginActivation(bool value) = 0;
/**
* Returns whether this evaluation context supports plug-in
* activation. If not set via {@link #setAllowPluginActivation(boolean)}
* the parent value is returned. If no parent is set <code>false</code>
* is returned.
*
* @return whether plug-in activation is supported or not
* @since 3.2
*/
virtual bool GetAllowPluginActivation() const = 0;
/**
* Returns the default variable.
*
* @return the default variable or <code>null</code> if
* no default variable is managed.
*/
virtual Object::Pointer GetDefaultVariable() const = 0;
/**
* Adds a new named variable to this context. If a variable
* with the name already exists the new one overrides the
* existing one.
*
* @param name the variable's name
* @param value the variable's value
*/
virtual void AddVariable(const std::string& name, Object::Pointer value) = 0;
/**
* Removes the variable managed under the given name
* from this evaluation context.
*
* @param name the variable's name
* @return the currently stored value or <code>null</code> if
* the variable doesn't exist
*/
virtual Object::Pointer RemoveVariable(const std::string& name) = 0;
/**
* Returns the variable managed under the given name.
*
* @param name the variable's name
* @return the variable's value or <code>null</code> if the content
* doesn't manage a variable with the given name
*/
virtual Object::Pointer GetVariable(const std::string& name) const = 0;
/**
* Resolves a variable for the given name and arguments. This
* method can be used to dynamically resolve variable such as
* plug-in descriptors, resources, etc. The method is used
* by the <code>resolve</code> expression.
*
* @param name the variable to resolve
* @param args an object array of arguments used to resolve the
* variable
* @return the variable's value or <code>null</code> if no variable
* can be resolved for the given name and arguments
* @exception CoreException if an errors occurs while resolving
* the variable
*/
virtual Object::Pointer ResolveVariable(const std::string& name, std::vector<Object::Pointer>& args) = 0;
};
} // namespace berry
#endif /*BERRYIEVALUATIONCONTEXT_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryIIterable.h b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryIIterable.h
index bfc08a2295..7367f4a477 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryIIterable.h
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryIIterable.h
@@ -1,58 +1,58 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIITERABLE_H_
#define BERRYIITERABLE_H_
#include <berryObject.h>
#include <berryMacros.h>
#include <org_blueberry_core_expressions_Export.h>
#include <vector>
namespace berry {
/**
* Objects that are adaptable to <code>IIterable</code> can be used
* as the default variable in an iterate expression.
*
* @see IAdaptable
* @see IAdapterManager
*
* @since 3.3
*/
struct BERRY_EXPRESSIONS IIterable : public Object {
berryObjectMacro(IIterable)
typedef std::vector<Object::Pointer>::iterator iterator;
virtual ~IIterable() {}
/**
* Returns an iterator to iterate over the elements.
*
* @return an iterator
*/
virtual iterator begin() = 0;
virtual iterator end() = 0;
};
} // namespace berry
#endif /*BERRYIITERABLE_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryIPropertyTester.h b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryIPropertyTester.h
index 3382bce15d..17af2cf7bf 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryIPropertyTester.h
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryIPropertyTester.h
@@ -1,112 +1,112 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIPROPERTYTESTER_H_
#define BERRYIPROPERTYTESTER_H_
#include <berryMacros.h>
#include <berryObject.h>
#include <org_blueberry_core_expressions_Export.h>
#include <Poco/Any.h>
#include <string>
#include <vector>
#include <QObject>
namespace berry {
/**
* A property tester can be used to add additional properties to test to an
* existing type.
* <p>
* This interface is not intended to be implemented by clients. Clients
* should subclass type <code>PropertyTester</code>.
* </p>
*
* @since 3.0
*/
struct BERRY_EXPRESSIONS IPropertyTester : public Object {
berryInterfaceMacro(IPropertyTester, berry)
virtual ~IPropertyTester() {}
/**
* Returns whether the property tester can handle the given
* property or not.
*
* @param namespace the name space to be considered
* @param property the property to test
* @return <code>true</code> if the tester provides an implementation
* for the given property; otherwise <code>false</code> is returned
*/
virtual bool Handles(const std::string& namespaze, const std::string& property) = 0;
/**
* Returns whether the implementation class for this property tester is
* loaded or not.
*
* @return <code>true</code>if the implementation class is loaded;
* <code>false</code> otherwise
*/
virtual bool IsInstantiated() = 0;
/**
* Returns <code>true</code> if the implementation class of this property
* tester can be loaded. This is the case if the plug-in providing
* the implementation class is active. Returns <code>false</code> otherwise.
*
* @return whether the implementation class can be loaded or not
*/
virtual bool IsDeclaringPluginActive() = 0;
/**
* Loads the implementation class for this property tester and returns an
* instance of this class.
*
* @return an instance of the implementation class for this property tester
*
* @throws CoreException if the implementation class cannot be loaded
*/
virtual IPropertyTester* Instantiate() = 0;
/**
* Executes the property test determined by the parameter <code>property</code>.
*
* @param receiver the receiver of the property test
* @param property the property to test
* @param args additional arguments to evaluate the property. If no arguments
* are specified in the <code>test</code> expression an array of length 0
* is passed
* @param expectedValue the expected value of the property. The value is either
* of type <code>java.lang.String</code> or a boxed base type. If no value was
* specified in the <code>test</code> expressions then <code>null</code> is passed
*
* @return returns <code>true<code> if the property is equal to the expected value;
* otherwise <code>false</code> is returned
*/
virtual bool Test(Object::Pointer receiver, const std::string& property, std::vector<Object::Pointer>& args, Object::Pointer expectedValue) = 0;
};
} // namespace berry
Q_DECLARE_INTERFACE(berry::IPropertyTester, "org.blueberry.IPropertyTester")
#endif /*BERRYIPROPERTYTESTER_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryIVariableResolver.h b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryIVariableResolver.h
index 568faf8f69..1fe1ca99fa 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryIVariableResolver.h
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryIVariableResolver.h
@@ -1,54 +1,54 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIVARIABLERESOLVER_H_
#define BERRYIVARIABLERESOLVER_H_
#include <org_blueberry_core_expressions_Export.h>
namespace berry {
/**
* A variable resolver can be used to add additional variable resolving
* strategies to an {@link EvaluationContext}.
*
* @see org.blueberry.core.expressions.EvaluationContext#resolveVariable(String, Object[])
*
* @since 3.0
*/
struct BERRY_EXPRESSIONS IVariableResolver {
virtual ~IVariableResolver() {};
/**
* Resolves a variable for the given name and arguments. The
* handler is allowed to return <code>null</code> to indicate
* that it is not able to resolve the requested variable.
*
* @param name the variable to resolve
* @param args an object array of arguments used to resolve the
* variable
* @return the variable's value or <code>null</code> if no variable
* could be resolved
* @exception CoreException if an errors occurs while resolving
* the variable
*/
virtual Object::Pointer Resolve(const std::string& name, std::vector<Object::Pointer> args) = 0;
};
} // namespace berry
#endif /*BERRYIVARIABLERESOLVER_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryPropertyTester.cpp b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryPropertyTester.cpp
index a388e5c39b..a15c0b9ebb 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryPropertyTester.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryPropertyTester.cpp
@@ -1,61 +1,61 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryPropertyTester.h"
#include "berryPlatform.h"
namespace berry
{
void PropertyTester::InternalInitialize(PropertyTesterDescriptor::Pointer descriptor)
{
fProperties= descriptor->GetProperties();
fNamespace= descriptor->GetNamespace();
fConfigElement= descriptor->GetExtensionElement();
}
PropertyTesterDescriptor::Pointer PropertyTester::InternalCreateDescriptor()
{
PropertyTesterDescriptor::Pointer tester(new PropertyTesterDescriptor(fConfigElement, fNamespace, fProperties));
return tester;
}
bool PropertyTester::Handles(const std::string& namespaze,
const std::string& property)
{
return fNamespace == namespaze && fProperties.find("," + property
+ ",") != std::string::npos;
}
bool PropertyTester::IsInstantiated()
{
return true;
}
bool PropertyTester::IsDeclaringPluginActive()
{
IBundle::Pointer bundle= Platform::GetBundle(fConfigElement->GetContributor());
return bundle->IsActive();
}
IPropertyTester* PropertyTester::Instantiate()
{
return this;
}
} // namespace berry
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryPropertyTester.h b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryPropertyTester.h
index b06c5948bd..84a9c531bd 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryPropertyTester.h
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/berryPropertyTester.h
@@ -1,125 +1,125 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYPROPERTYTESTER_H_
#define BERRYPROPERTYTESTER_H_
#include <berryIConfigurationElement.h>
#include "internal/berryPropertyTesterDescriptor.h"
#include <org_blueberry_core_expressions_Export.h>
#include <string>
namespace berry {
/**
* Abstract superclass of all property testers. Implementation classes of
* the extension point <code>org.blueberry.core.expresssions.propertyTesters
* </code> must extend <code>PropertyTester</code>.
* <p>
* A property tester implements the property tests enumerated in the property
* tester extension point. For the following property test extension
* <pre>
* &lt;propertyTester
* namespace="org.blueberry.jdt.core"
* id="org.blueberry.jdt.core.IPackageFragmentTester"
* properties="isDefaultPackage"
* type="org.blueberry.jdt.core.IPackageFragment"
* class="org.blueberry.demo.MyPackageFragmentTester"&gt;
* &lt;/propertyTester&gt;
* </pre>
* the corresponding implementation class looks like:
* <pre>
* public class MyPackageFragmentTester {
* public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
* IPackageFragment fragement= (IPackageFragment)receiver;
* if ("isDefaultPackage".equals(property)) {
* return expectedValue == null
* ? fragement.isDefaultPackage()
* : fragement.isDefaultPackage() == ((Boolean)expectedValue).booleanValue();
* }
* Assert.isTrue(false);
* return false;
* }
* }
* </pre>
* The property can then be used in a test expression as follows:
* <pre>
* &lt;instanceof value="org.blueberry.core.IPackageFragment"/&gt;
* &lt;test property="org.blueberry.jdt.core.isDefaultPackage"/&gt;
* </pre>
* </p>
* <p>
* There is no guarantee that the same instance of a property tester is used
* to handle &lt;test property="..."/&gt; requests. So property testers
* should always be implemented in a stateless fashion.
* </p>
* @since 3.0
*/
class BERRY_EXPRESSIONS PropertyTester : public IPropertyTester
{
private:
IConfigurationElement::Pointer fConfigElement;
std::string fNamespace;
std::string fProperties;
public:
/**
* Initialize the property tester with the given name space and property.
* <p>
* Note: this method is for internal use only. Clients must not call
* this method.
* </p>
* @param descriptor the descriptor object for this tester
*/
void InternalInitialize(PropertyTesterDescriptor::Pointer descriptor);
/**
* Note: this method is for internal use only. Clients must not call
* this method.
*
* @return the property tester descriptor
*/
PropertyTesterDescriptor::Pointer InternalCreateDescriptor();
/**
* {@inheritDoc}
*/
bool Handles(const std::string& namespaze, const std::string& property);
/**
* {@inheritDoc}
*/
bool IsInstantiated();
/**
* {@inheritDoc}
*/
bool IsDeclaringPluginActive();
/**
* {@inheritDoc}
*/
IPropertyTester* Instantiate();
};
} // namespace berry
#endif /*BERRYPROPERTYTESTER_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryAdaptExpression.cpp b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryAdaptExpression.cpp
index 189963e8f7..f31b19080e 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryAdaptExpression.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryAdaptExpression.cpp
@@ -1,123 +1,123 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryAdaptExpression.h"
#include <berryPlatform.h>
#include <berryRuntime.h>
#include <berryIAdapterManager.h>
#include <berryObject.h>
#include "berryExpressions.h"
#include "berryDefaultVariable.h"
#include <Poco/Hash.h>
#include <Poco/Exception.h>
#include <Poco/Bugcheck.h>
namespace berry {
const std::string AdaptExpression::ATT_TYPE= "type"; //$NON-NLS-1$
/**
* The seed for the hash code for all adapt expressions.
*/
const std::size_t AdaptExpression::HASH_INITIAL = Poco::Hash<std::string>()("berry::AdaptExpression");
AdaptExpression::AdaptExpression(IConfigurationElement::Pointer configElement)
{
bool attr = configElement->GetAttribute(ATT_TYPE, fTypeName);
Expressions::CheckAttribute(ATT_TYPE, attr);
}
AdaptExpression::AdaptExpression(Poco::XML::Node* /*element*/)
{
throw Poco::NotImplementedException();
//fTypeName = element->GetAttribute(ATT_TYPE);
//Expressions::CheckAttribute(ATT_TYPE, fTypeName.length() > 0 ? fTypeName : null);
}
AdaptExpression::AdaptExpression(const std::string& typeName)
{
poco_assert(typeName.size() != 0);
fTypeName= typeName;
}
//bool
//AdaptExpression::equals(final Object object)
//{
// if (!(object instanceof AdaptExpression))
// return FALSE_EVAL;
//
// final AdaptExpression that= (AdaptExpression)object;
// return this.fTypeName.equals(that.fTypeName)
// && equals(this.fExpressions, that.fExpressions);
//}
std::size_t
AdaptExpression::ComputeHashCode()
{
throw Poco::NotImplementedException("ComputeHashCode not implemented");
//return HASH_INITIAL * HASH_FACTOR + HashCode(fExpressions)
// * HASH_FACTOR + fTypeName.hashCode();
}
/* (non-Javadoc)
* @see Expression#evaluate(IVariablePool)
*/
EvaluationResult
AdaptExpression::Evaluate(IEvaluationContext* context)
{
if (fTypeName.size() == 0)
return EvaluationResult::FALSE_EVAL;
Object::Pointer var(context->GetDefaultVariable());
Object::Pointer adapted;
IAdapterManager::Pointer manager = Platform::GetServiceRegistry().GetServiceById<IAdapterManager>(Runtime::ADAPTER_SERVICE_ID);
if (Expressions::IsInstanceOf(var, fTypeName)) {
adapted= var;
} else {
if (!manager->HasAdapter(var->GetClassName(), fTypeName))
return EvaluationResult::FALSE_EVAL;
Poco::Any anyAdapted(manager->GetAdapter(var.GetPointer(), fTypeName));
if (!anyAdapted.empty() && anyAdapted.type() == typeid(Object::Pointer))
{
adapted = Poco::AnyCast<Object::Pointer>(anyAdapted);
}
}
// the adapted result is null but hasAdapter returned TRUE_EVAL check
// if the adapter is loaded.
if (adapted.IsNull()) {
if (manager->QueryAdapter(var->GetClassName(), fTypeName) == IAdapterManager::NOT_LOADED) {
return EvaluationResult::NOT_LOADED;
} else {
return EvaluationResult::FALSE_EVAL;
}
}
return this->EvaluateAnd(new DefaultVariable(context, adapted));
}
void
AdaptExpression::CollectExpressionInfo(ExpressionInfo* info)
{
// Although the default variable is passed to the children of this
// expression as an instance of the adapted type it is OK to only
// mark a default variable access.
info->MarkDefaultVariableAccessed();
CompositeExpression::CollectExpressionInfo(info);
}
} // namespace berry
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryAdaptExpression.h b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryAdaptExpression.h
index 1c400d6a07..c79a41346f 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryAdaptExpression.h
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryAdaptExpression.h
@@ -1,81 +1,81 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYADAPTEXPRESSION_H_
#define BERRYADAPTEXPRESSION_H_
#include "berryCompositeExpression.h"
#include "berryEvaluationContext.h"
#include "berryEvaluationResult.h"
#include "berryExpressionInfo.h"
#include "service/berryIConfigurationElement.h"
#include "Poco/DOM/Node.h"
#include <string>
namespace berry {
class AdaptExpression : public CompositeExpression
{
private:
static const std::string ATT_TYPE;
/**
* The seed for the hash code for all adapt expressions.
*/
static const std::size_t HASH_INITIAL;
std::string fTypeName;
public:
AdaptExpression(SmartPointer<IConfigurationElement> configElement);
AdaptExpression(Poco::XML::Node* element);
AdaptExpression(const std::string& typeName);
// bool equals(final Object object) {
// if (!(object instanceof AdaptExpression))
// return false;
//
// final AdaptExpression that= (AdaptExpression)object;
// return this.fTypeName.equals(that.fTypeName)
// && equals(this.fExpressions, that.fExpressions);
// }
/* (non-Javadoc)
* @see Expression#evaluate(IVariablePool)
*/
EvaluationResult Evaluate(IEvaluationContext* context);
void CollectExpressionInfo(ExpressionInfo* info);
protected:
std::size_t ComputeHashCode();
};
} // namespace berry
#endif /*BERRYADAPTEXPRESSION_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryAndExpression.cpp b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryAndExpression.cpp
index 03de25c5be..b7c0db1d6a 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryAndExpression.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryAndExpression.cpp
@@ -1,42 +1,42 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryAndExpression.h"
namespace berry
{
bool AndExpression::operator==(Expression& object)
{
try
{
AndExpression& that = dynamic_cast<AndExpression&>(object);
return this->Equals(this->fExpressions, that.fExpressions);
}
catch (std::bad_cast exc)
{
return false;
}
}
EvaluationResult
AndExpression::Evaluate(IEvaluationContext* context)
{
return this->EvaluateAnd(context);
}
} // namespace berry
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryAndExpression.h b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryAndExpression.h
index 3de5ed0300..96f5f112bb 100755
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryAndExpression.h
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryAndExpression.h
@@ -1,35 +1,35 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 __BERRY_AND_EXPRESSION_H__
#define __BERRY_AND_EXPRESSION_H__
#include "berryCompositeExpression.h"
namespace berry {
class AndExpression : public CompositeExpression {
public:
bool operator==(Expression& object) ;
EvaluationResult Evaluate(IEvaluationContext* context);
};
} // namespace berry
#endif // __BERRY_AND_EXPRESSION_H__
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryCompositeExpression.cpp b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryCompositeExpression.cpp
index 53c5ff8a3c..4e0ea2e320 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryCompositeExpression.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryCompositeExpression.cpp
@@ -1,85 +1,85 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryCompositeExpression.h"
#include "Poco/Hash.h"
namespace berry
{
const std::size_t CompositeExpression::HASH_INITIAL = Poco::Hash<std::string>()("berry::CompositeExpression");
void CompositeExpression::Add(Expression::Pointer expression)
{
fExpressions.push_back(expression);
}
void CompositeExpression::GetChildren(std::vector<Expression::Pointer>& children)
{
children = fExpressions;
}
EvaluationResult CompositeExpression::EvaluateAnd(IEvaluationContext* scope)
{
if (fExpressions.size() == 0)
return EvaluationResult::TRUE_EVAL;
EvaluationResult result = EvaluationResult::TRUE_EVAL;
std::vector<Expression::Pointer>::iterator iter;
for (iter= fExpressions.begin(); iter != fExpressions.end(); ++iter)
{
result = result.And((*iter)->Evaluate(scope));
// keep iterating even if we have a not loaded found. It can be
// that we find a FALSE_EVAL which will result in a better result.
if (result == EvaluationResult::FALSE_EVAL)
return result;
}
return result;
}
EvaluationResult CompositeExpression::EvaluateOr(IEvaluationContext* scope)
{
if (fExpressions.size() == 0)
return EvaluationResult::TRUE_EVAL;
EvaluationResult result = EvaluationResult::FALSE_EVAL;
std::vector<Expression::Pointer>::iterator iter;
for (iter= fExpressions.begin(); iter != fExpressions.end(); ++iter)
{
result = result.Or((*iter)->Evaluate(scope));
if (result == EvaluationResult::TRUE_EVAL)
return result;
}
return result;
}
void CompositeExpression::CollectExpressionInfo(ExpressionInfo* info)
{
if (fExpressions.size() == 0)
return;
std::vector<Expression::Pointer>::iterator iter;
for (iter= fExpressions.begin(); iter != fExpressions.end(); ++iter)
{
(*iter)->CollectExpressionInfo(info);
}
}
std::size_t CompositeExpression::ComputeHashCode()
{
return HASH_INITIAL * HASH_FACTOR + this->HashCode(fExpressions);
}
} // namespace berry
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryCompositeExpression.h b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryCompositeExpression.h
index 436631d54d..a5445be3a5 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryCompositeExpression.h
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryCompositeExpression.h
@@ -1,63 +1,63 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYCOMPOSITEEXPRESSION_H_
#define BERRYCOMPOSITEEXPRESSION_H_
#include "berryExpression.h"
#include "berryExpressionInfo.h"
#include "berryEvaluationResult.h"
#include "berryIEvaluationContext.h"
#include <vector>
namespace berry
{
class CompositeExpression : public Expression
{
public:
berryObjectMacro(CompositeExpression)
private:
/**
* The seed for the hash code for all composite expressions.
*/
static const std::size_t HASH_INITIAL;
protected:
std::vector<Expression::Pointer> fExpressions;
virtual EvaluationResult EvaluateAnd(IEvaluationContext* scope);
virtual EvaluationResult EvaluateOr(IEvaluationContext* scope);
virtual std::size_t ComputeHashCode();
public:
virtual void Add(Expression::Pointer expression);
virtual void GetChildren(std::vector<Expression::Pointer>& children);
virtual void CollectExpressionInfo(ExpressionInfo* info);
};
} // namespace berry
#endif /*BERRYCOMPOSITEEXPRESSION_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryCountExpression.cpp b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryCountExpression.cpp
index 793eb0e43c..77fba87785 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryCountExpression.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryCountExpression.cpp
@@ -1,147 +1,147 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryCountExpression.h"
#include "berryExpressions.h"
#include <berryObjectVector.h>
#include <Poco/Hash.h>
#include <Poco/NumberParser.h>
namespace berry {
const int CountExpression::ANY_NUMBER= 5;
const int CountExpression::EXACT= 4;
const int CountExpression::ONE_OR_MORE= 3;
const int CountExpression::NONE_OR_ONE= 2;
const int CountExpression::NONE= 1;
const int CountExpression::UNKNOWN= 0;
const std::size_t CountExpression::HASH_INITIAL = Poco::Hash<std::string>()("berry::CountExpression");
void
CountExpression::InitializeSize(std::string size)
{
if (size == "*") //$NON-NLS-1$
fMode= ANY_NUMBER;
else if (size == "?") //$NON-NLS-1$
fMode= NONE_OR_ONE;
else if (size == "!") //$NON-NLS-1$
fMode= NONE;
else if (size == "+") //$NON-NLS-1$
fMode= ONE_OR_MORE;
else
{
try
{
fSize= Poco::NumberParser::parse(size);
fMode= EXACT;
}
catch (Poco::SyntaxException e)
{
fMode= UNKNOWN;
}
}
}
CountExpression::CountExpression(IConfigurationElement::Pointer configElement)
{
std::string size;
if (!configElement->GetAttribute(ATT_VALUE, size))
size = "*";
this->InitializeSize(size);
}
CountExpression::CountExpression(Poco::XML::Element* element)
{
std::string size = element->getAttribute(ATT_VALUE);
this->InitializeSize(size);
}
CountExpression::CountExpression(const std::string& size)
{
this->InitializeSize(size);
}
EvaluationResult
CountExpression::Evaluate(IEvaluationContext* context)
{
Object::Pointer var(context->GetDefaultVariable());
ObjectVector<Object::Pointer>::size_type size;
if(ObjectVector<Object::Pointer>::Pointer coll = var.Cast<ObjectVector<Object::Pointer> >())
{
size = coll->size();
}
else
{
ICountable::Pointer countable = Expressions::GetAsICountable(var, Expression::Pointer(this));
if (!countable)
return EvaluationResult::NOT_LOADED;
size = countable->Count();
}
switch (fMode)
{
case UNKNOWN:
return EvaluationResult::FALSE_EVAL;
case NONE:
return EvaluationResult::ValueOf(size == 0);
case NONE_OR_ONE:
return EvaluationResult::ValueOf(size == 0 || size == 1);
case ONE_OR_MORE:
return EvaluationResult::ValueOf(size >= 1);
case EXACT:
return EvaluationResult::ValueOf( (ObjectVector<Object::Pointer>::size_type) fSize == size);
case ANY_NUMBER:
return EvaluationResult::TRUE_EVAL;
}
return EvaluationResult::FALSE_EVAL;
}
void
CountExpression::CollectExpressionInfo(ExpressionInfo* info)
{
info->MarkDefaultVariableAccessed();
}
bool
CountExpression::operator==(Expression& object)
{
try
{
CountExpression& that = dynamic_cast<CountExpression&>(object);
return (this->fMode == that.fMode) && (this->fSize == that.fSize);
}
catch (std::bad_cast e)
{
return false;
}
}
std::size_t
CountExpression::ComputeHashCode()
{
return HASH_INITIAL * HASH_FACTOR + fMode * HASH_FACTOR + fSize;
}
} // namespace berry
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryCountExpression.h b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryCountExpression.h
index c7ce195836..073a24d347 100755
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryCountExpression.h
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryCountExpression.h
@@ -1,74 +1,74 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 __BERRY_COUNT_EXPRESSION_H__
#define __BERRY_COUNT_EXPRESSION_H__
#include "berryExpression.h"
#include "berryIEvaluationContext.h"
#include "berryExpressionInfo.h"
#include "service/berryIConfigurationElement.h"
#include "Poco/DOM/Element.h"
#include <string>
namespace berry {
class CountExpression : public Expression {
private:
static const int ANY_NUMBER;
static const int EXACT;
static const int ONE_OR_MORE;
static const int NONE_OR_ONE;
static const int NONE;
static const int UNKNOWN;
/**
* The seed for the hash code for all count expressions.
*/
static const std::size_t HASH_INITIAL;
int fMode;
int fSize;
void InitializeSize(std::string size);
public:
CountExpression(SmartPointer<IConfigurationElement> configElement);
CountExpression(Poco::XML::Element* element);
CountExpression(const std::string& size);
EvaluationResult Evaluate(IEvaluationContext* context);
void CollectExpressionInfo(ExpressionInfo* info);
bool operator==(Expression& object);
protected:
std::size_t ComputeHashCode();
};
} // namespace berry
#endif // __BERRY_COUNT_EXPRESSION_H__
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryDefaultVariable.cpp b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryDefaultVariable.cpp
index f28d19e600..a50938d058 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryDefaultVariable.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryDefaultVariable.cpp
@@ -1,85 +1,85 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryDefaultVariable.h"
#include <Poco/Bugcheck.h>
namespace berry {
DefaultVariable::DefaultVariable(IEvaluationContext* parent,
Object::Pointer defaultVariable)
{
poco_check_ptr(parent);
fParent= parent;
while (dynamic_cast<DefaultVariable*>(parent))
{
parent = parent->GetParent();
}
fManagedPool= parent;
fDefaultVariable= defaultVariable;
}
IEvaluationContext* DefaultVariable::GetParent() const
{
return fParent;
}
IEvaluationContext* DefaultVariable::GetRoot()
{
return fParent->GetRoot();
}
Object::Pointer DefaultVariable::GetDefaultVariable() const
{
return fDefaultVariable;
}
void DefaultVariable::SetAllowPluginActivation(bool value)
{
fParent->SetAllowPluginActivation(value);
}
bool DefaultVariable::GetAllowPluginActivation() const
{
return fParent->GetAllowPluginActivation();
}
void DefaultVariable::AddVariable(const std::string& name, Object::Pointer value)
{
fManagedPool->AddVariable(name, value);
}
Object::Pointer DefaultVariable::RemoveVariable(const std::string& name)
{
return fManagedPool->RemoveVariable(name);
}
Object::Pointer DefaultVariable::GetVariable(const std::string& name) const
{
return fManagedPool->GetVariable(name);
}
Object::Pointer DefaultVariable::ResolveVariable(const std::string& name,
std::vector<Object::Pointer>& args)
{
return fManagedPool->ResolveVariable(name, args);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryDefaultVariable.h b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryDefaultVariable.h
index bb80268a9c..046c011207 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryDefaultVariable.h
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryDefaultVariable.h
@@ -1,93 +1,93 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYDEFAULTVARIABLE_H_
#define BERRYDEFAULTVARIABLE_H_
#include "berryIEvaluationContext.h"
#include <vector>
namespace berry {
class DefaultVariable : public IEvaluationContext {
private:
Object::Pointer fDefaultVariable;
IEvaluationContext* fParent;
IEvaluationContext* fManagedPool;
public:
/**
* Constructs a new variable pool for a single default variable.
*
* @param parent the parent context for the default variable. Must not
* be <code>null</code>.
* @param defaultVariable the default variable
*/
DefaultVariable(IEvaluationContext* parent, Object::Pointer defaultVariable);
/**
* {@inheritDoc}
*/
IEvaluationContext* GetParent() const;
/**
* {@inheritDoc}
*/
IEvaluationContext* GetRoot();
/**
* {@inheritDoc}
*/
Object::Pointer GetDefaultVariable() const;
/**
* {@inheritDoc}
*/
void SetAllowPluginActivation(bool value);
/**
* {@inheritDoc}
*/
bool GetAllowPluginActivation() const;
/**
* {@inheritDoc}
*/
void AddVariable(const std::string& name, Object::Pointer value);
/**
* {@inheritDoc}
*/
Object::Pointer RemoveVariable(const std::string& name);
/**
* {@inheritDoc}
*/
Object::Pointer GetVariable(const std::string& name) const;
/**
* {@inheritDoc}
*/
Object::Pointer ResolveVariable(const std::string& name, std::vector<Object::Pointer>& args);
};
} // namespace berry
#endif /*BERRYDEFAULTVARIABLE_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryDefinitionRegistry.cpp b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryDefinitionRegistry.cpp
index 1dae3ccb3a..54d09dc001 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryDefinitionRegistry.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryDefinitionRegistry.cpp
@@ -1,90 +1,90 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryDefinitionRegistry.h"
#include "berryExpressionConverter.h"
#include "berryPlatform.h"
#include "berryPlatformException.h"
#include "service/berryIExtensionPointService.h"
namespace berry {
std::map<std::string, Expression::Pointer>& DefinitionRegistry::GetCache()
{
return cache;
}
DefinitionRegistry::DefinitionRegistry()
{
//Platform.getExtensionRegistry().addRegistryChangeListener(this, "org.blueberry.core.expressions"); //$NON-NLS-1$
}
Expression::Pointer DefinitionRegistry::GetExpression(const std::string& id)
{
Expression::Pointer cachedExpression= this->GetCache()[id];
if (!cachedExpression.IsNull())
{
return cachedExpression;
}
IExtensionPointService::Pointer service = Platform::GetExtensionPointService();
IConfigurationElement::vector ces(
service->GetConfigurationElementsFor("org.blueberry.core.expressions.definitions"));
Expression::Pointer foundExpression;
for (IConfigurationElement::vector::iterator i= ces.begin(); i != ces.end(); ++i)
{
std::string cid;
if ((*i)->GetAttribute("id", cid))
{
if (cid == id)
{
try
{
foundExpression= this->GetExpression(id, *i);
break;
}
catch (InvalidServiceObjectException e)
{
throw CoreException("Missing expression", id);
}
}
}
}
if (foundExpression.IsNull())
{
throw CoreException("Missing expression", id);
}
return foundExpression;
}
Expression::Pointer DefinitionRegistry::GetExpression(const std::string& id,
IConfigurationElement::Pointer element)
{
IConfigurationElement::vector children(element->GetChildren());
Expression::Pointer expr= ExpressionConverter::GetDefault()->Perform(children[0]);
if (!expr.IsNull())
{
this->GetCache()[id] = expr;
}
return expr;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryDefinitionRegistry.h b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryDefinitionRegistry.h
index c9c9d2fd1e..412c7211be 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryDefinitionRegistry.h
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryDefinitionRegistry.h
@@ -1,61 +1,61 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYDEFINITIONREGISTRY_H_
#define BERRYDEFINITIONREGISTRY_H_
#include "berryExpression.h"
#include "service/berryIConfigurationElement.h"
#include <map>
namespace berry {
/**
* This manages the extension point that allows core expression reuse.
*/
class DefinitionRegistry { //implements IRegistryChangeListener {
private:
std::map<std::string, Expression::Pointer> cache;
std::map<std::string, Expression::Pointer>& GetCache();
public:
DefinitionRegistry();
/**
* Get the expression with the id defined by an extension. This class will
* cache the expressions when appropriate, so it's OK to always ask the
* registry.
*
* @param id The unique ID of the expression definition
* @return the expression
* @throws CoreException If the expression cannot be found.
*/
Expression::Pointer GetExpression(const std::string& id);
private:
Expression::Pointer GetExpression(const std::string& id, SmartPointer<IConfigurationElement> element);
};
} // namespace berry
#endif /*BERRYDEFINITIONREGISTRY_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryEnablementExpression.cpp b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryEnablementExpression.cpp
index dbec17a4a3..00d1103333 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryEnablementExpression.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryEnablementExpression.cpp
@@ -1,61 +1,61 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryLog.h"
#include "berryEnablementExpression.h"
#include "berryExpressions.h"
#include <ctime>
namespace berry {
bool
EnablementExpression::operator==(Expression& object)
{
try
{
EnablementExpression& that = dynamic_cast<EnablementExpression&>(object);
return this->Equals(this->fExpressions, that.fExpressions);
}
catch (std::bad_cast)
{
return false;
}
return false;
}
EvaluationResult
EnablementExpression::Evaluate(IEvaluationContext* context)
{
std::clock_t start = 0;
if (Expressions::TRACING)
start = std::clock();
EvaluationResult result = this->EvaluateAnd(context);
if (Expressions::TRACING)
{
BERRY_INFO << "[Enablement Expression] - evaluation time: " <<
(double(std::clock() - start)/(CLOCKS_PER_SEC/1000)) << " ms.";
}
return result;
}
} // namespace berry
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryEnablementExpression.h b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryEnablementExpression.h
index a4def6dd1d..b11c72f43a 100755
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryEnablementExpression.h
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryEnablementExpression.h
@@ -1,61 +1,61 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 __BERRY_ENABLEMENT_EXPRESSION_H__
#define __BERRY_ENABLEMENT_EXPRESSION_H__
#include "berryCompositeExpression.h"
#include "service/berryIConfigurationElement.h"
#include "Poco/DOM/Node.h"
namespace berry {
class EnablementExpression : public CompositeExpression
{
public:
/**
* Creates a {@link EnablementExpression}.
*
* @param configElement the configuration element
*/
EnablementExpression(SmartPointer<IConfigurationElement> /*configElement*/)
{
// config element not used yet.
}
/**
* Creates a {@link EnablementExpression}.
*
* @param element the XML element
*/
EnablementExpression(Poco::XML::Node* /*element*/)
{
// element not used yet.
}
bool operator==(Expression& object);
EvaluationResult Evaluate(IEvaluationContext* context);
};
} // namespace berry
#endif // __BERRY_ENABLEMENT_EXPRESSION_H__
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryEqualsExpression.cpp b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryEqualsExpression.cpp
index c5043c8d40..39a24d4e18 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryEqualsExpression.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryEqualsExpression.cpp
@@ -1,78 +1,78 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryEqualsExpression.h"
#include "berryExpressions.h"
#include <Poco/Hash.h>
#include <Poco/Exception.h>
#include <Poco/Bugcheck.h>
namespace berry {
const std::size_t EqualsExpression::HASH_INITIAL= Poco::Hash<std::string>()("berry::EqualsExpression");
EqualsExpression::EqualsExpression(Object::Pointer expectedValue) {
poco_assert(expectedValue.IsNotNull());
fExpectedValue = expectedValue;
}
EqualsExpression::EqualsExpression(IConfigurationElement::Pointer element) {
std::string value;
bool result = element->GetAttribute(ATT_VALUE, value);
Expressions::CheckAttribute(ATT_VALUE, result);
fExpectedValue = Expressions::ConvertArgument(value, result);
}
EqualsExpression::EqualsExpression(Poco::XML::Element* element) {
std::string value = element->getAttribute(ATT_VALUE);
Expressions::CheckAttribute(ATT_VALUE, value.size() > 0);
fExpectedValue = Expressions::ConvertArgument(value);
}
EvaluationResult
EqualsExpression::Evaluate(IEvaluationContext* context) {
Object::Pointer element= context->GetDefaultVariable();
return EvaluationResult::ValueOf(element == fExpectedValue);
}
void
EqualsExpression::CollectExpressionInfo(ExpressionInfo* info) {
info->MarkDefaultVariableAccessed();
}
bool
EqualsExpression::operator==(Expression& object) {
try {
EqualsExpression& that = dynamic_cast<EqualsExpression&>(object);
return this->fExpectedValue == that.fExpectedValue;
}
catch (std::bad_cast)
{
return false;
}
}
std::size_t
EqualsExpression::ComputeHashCode() {
return HASH_INITIAL * HASH_FACTOR + fExpectedValue->HashCode();
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryEqualsExpression.h b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryEqualsExpression.h
index 9033a7ca76..9273c25f27 100755
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryEqualsExpression.h
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryEqualsExpression.h
@@ -1,61 +1,61 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 __BERRY_EQUALS_EXPRESSION_H__
#define __BERRY_EQUALS_EXPRESSION_H__
#include "berryExpression.h"
#include "berryExpressionInfo.h"
#include "berryIEvaluationContext.h"
#include "service/berryIConfigurationElement.h"
#include "Poco/DOM/Element.h"
namespace berry {
class EqualsExpression : public Expression {
/**
* The seed for the hash code for all equals expressions.
*/
private:
static const std::size_t HASH_INITIAL;
Object::Pointer fExpectedValue;
public:
EqualsExpression(const Object::Pointer expectedValue);
EqualsExpression(SmartPointer<IConfigurationElement> element);
EqualsExpression(Poco::XML::Element* element);
EvaluationResult Evaluate(IEvaluationContext* context);
void CollectExpressionInfo(ExpressionInfo* info);
bool operator==(Expression& object);
protected:
std::size_t ComputeHashCode();
};
} // namespace berry
#endif // __BERRY_EQUALS_EXPRESSION_H__
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryExpressions.cpp b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryExpressions.cpp
index 14cc4093a7..fd579da65e 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryExpressions.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryExpressions.cpp
@@ -1,318 +1,318 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryExpressions.h"
#include <berryPlatform.h>
#include <berryPlatformException.h>
#include <service/berryServiceRegistry.h>
#include <berryIAdapterManager.h>
#include <berryObjects.h>
#include <berryObjectString.h>
#include <berryObjectVector.h>
#include <Poco/String.h>
#include <Poco/NumberParser.h>
#include <deque>
namespace berry
{
const bool Expressions::TRACING = true;
Expressions::Expressions()
{
// no instance
}
bool
Expressions::IsInstanceOf(Object::ConstPointer element, const std::string& type)
{
// null isn't an instanceof of anything.
if (element.IsNull())
return false;
// TODO Reflection
// return IsSubtype(element, type)
return element->GetClassName() == type;
}
void
Expressions::CheckAttribute(const std::string& name, bool value)
{
if (!value)
{
throw CoreException("Missing attribute", name);
}
}
void
Expressions::CheckAttribute(const std::string& name, bool result, const std::string& value, std::vector<std::string>& validValues)
{
CheckAttribute(name, result);
for (unsigned int i= 0; i < validValues.size(); i++)
{
if (value == validValues[i])
return;
}
throw CoreException("Wrong attribute value", value);
}
void
Expressions::CheckCollection(Object::ConstPointer var, Expression::Pointer expression)
{
if (var.Cast<const ObjectVector<Object::Pointer> >())
return;
throw CoreException("Expression variable is not of type ObjectVector", expression->ToString());
}
IIterable::Pointer
Expressions::GetAsIIterable(Object::Pointer var, Expression::Pointer expression)
{
IIterable::Pointer iterable(var.Cast<IIterable>());
if (!iterable.IsNull())
{
return iterable;
}
else
{
IAdapterManager::Pointer manager= Platform::GetServiceRegistry().GetServiceById<IAdapterManager>("org.blueberry.service.adaptermanager");
Object::Pointer result;
Poco::Any any(manager->GetAdapter(var, IIterable::GetStaticClassName()));
if (!any.empty() && any.type() == typeid(Object::Pointer))
{
result = Poco::AnyCast<Object::Pointer>(any);
}
if (result)
{
iterable = result.Cast<IIterable>();
return iterable;
}
if (manager->QueryAdapter(var->GetClassName(), IIterable::GetStaticClassName()) == IAdapterManager::NOT_LOADED)
return IIterable::Pointer();
throw CoreException("The variable is not iterable", expression->ToString());
}
}
ICountable::Pointer
Expressions::GetAsICountable(Object::Pointer var, Expression::Pointer expression)
{
ICountable::Pointer countable(var.Cast<ICountable>());
if (!countable.IsNull())
{
return countable;
}
else
{
IAdapterManager::Pointer manager = Platform::GetServiceRegistry().GetServiceById<IAdapterManager>("org.blueberry.service.adaptermanager");
Object::Pointer result;
Poco::Any any(manager->GetAdapter(var, ICountable::GetStaticClassName()));
if (!any.empty() && any.type() == typeid(Object::Pointer))
{
result = Poco::AnyCast<Object::Pointer>(any);
}
if (result)
{
countable = result.Cast<ICountable>();
}
if (manager->QueryAdapter(var->GetClassName(), ICountable::GetStaticClassName()) == IAdapterManager::NOT_LOADED)
return ICountable::Pointer();
throw CoreException("The variable is not countable", expression->ToString());
}
}
bool
Expressions::GetOptionalBooleanAttribute(IConfigurationElement::Pointer element, const std::string& attributeName)
{
std::string value;
if (element->GetAttribute(attributeName, value))
return Poco::toLower<std::string>(value) == "true";
return false;
}
bool
Expressions::GetOptionalBooleanAttribute(Poco::XML::Element* element, const std::string& attributeName)
{
std::string value = element->getAttribute(attributeName);
if (value.size() == 0)
return false;
return Poco::toLower<std::string>(value) == "true";
}
void
Expressions::GetArguments(std::vector<Object::Pointer>& args, IConfigurationElement::Pointer element, const std::string& attributeName)
{
std::string value;
if (element->GetAttribute(attributeName, value))
{
ParseArguments(args, value);
}
}
void
Expressions::GetArguments(std::vector<Object::Pointer>& args, Poco::XML::Element* element, const std::string& attributeName)
{
std::string value = element->getAttribute(attributeName);
if (value.size()> 0)
{
ParseArguments(args, value);
}
}
void
Expressions::ParseArguments(std::vector<Object::Pointer>& result, const std::string& args)
{
int start= 0;
int comma;
while ((comma = FindNextComma(args, start)) != -1)
{
result.push_back(ConvertArgument(Poco::trim<std::string>(args.substr(start, comma-start))));
start= comma + 1;
}
result.push_back(ConvertArgument(Poco::trim<std::string>(args.substr(start))));
}
int
Expressions::FindNextComma(const std::string& str, int start)
{
bool inString = false;
for (unsigned int i = start; i < str.size(); i++)
{
char ch = str.at(i);
if (ch == ',' && ! inString)
return i;
if (ch == '\'')
{
if (!inString)
{
inString= true;
}
else
{
if (i + 1 < str.size() && str.at(i + 1) == '\'')
{
i++;
}
else
{
inString= false;
}
}
}
else if (ch == ',' && !inString)
{
return i;
}
}
if (inString)
throw CoreException("String not terminated", str);
return -1;
}
Object::Pointer
Expressions::ConvertArgument(const std::string& arg, bool result)
{
if (!result)
{
return Object::Pointer();
}
else if (arg.length() == 0)
{
ObjectString::Pointer var(new ObjectString(arg));
return var;
}
else if (arg.at(0) == '\'' && arg.at(arg.size() - 1) == '\'')
{
ObjectString::Pointer var(new ObjectString(UnEscapeString(arg.substr(1, arg.size() - 2))));
return var;
}
else if ("true" == arg)
{
ObjectBool::Pointer var(new ObjectBool(true));
return var;
}
else if ("false" == arg)
{
ObjectBool::Pointer var(new ObjectBool(false));
return var;
}
else if (arg.find('.') != std::string::npos)
{
try
{
double num = Poco::NumberParser::parseFloat(arg);
ObjectFloat::Pointer var(new ObjectFloat((float) num));
return var;
}
catch (Poco::SyntaxException)
{
ObjectString::Pointer var(new ObjectString(arg));
return var;
}
}
else
{
try
{
int num = Poco::NumberParser::parse(arg);
ObjectInt::Pointer var(new ObjectInt(num));
return var;
}
catch (Poco::SyntaxException e)
{
ObjectString::Pointer var(new ObjectString(arg));
return var;
}
}
}
std::string
Expressions::UnEscapeString(const std::string& str)
{
std::string result = "";
for (unsigned int i= 0; i < str.size(); i++)
{
char ch= str.at(i);
if (ch == '\'')
{
if (i == str.size() - 1 || str.at(i + 1) != '\'')
throw CoreException("String not correctly escaped", str);
result.append(1, '\'');
i++;
}
else
{
result.append(1, ch);
}
}
return result;
}
} // namespace berry
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryExpressions.h b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryExpressions.h
index cd11f9babf..48f662b891 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryExpressions.h
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryExpressions.h
@@ -1,103 +1,103 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYEXPRESSIONS_H_
#define BERRYEXPRESSIONS_H_
#include "Poco/Any.h"
#include "Poco/DOM/Element.h"
#include "service/berryIConfigurationElement.h"
#include "berryExpression.h"
#include "berryIIterable.h"
#include "berryICountable.h"
#include <string>
#include <vector>
#include <typeinfo>
namespace berry
{
class Expressions {
private:
Expressions();
static int FindNextComma(const std::string& str, int start);
public:
/* debugging flag to enable tracing */
static const bool TRACING;
static bool IsInstanceOf(Object::ConstPointer element, const std::string& type);
static void CheckAttribute(const std::string& name, bool value);
static void CheckAttribute(const std::string& name, bool result, const std::string& value, std::vector<std::string>& validValues);
static void CheckCollection(Object::ConstPointer var, Expression::Pointer expression);
/**
* Converts the given variable into an <code>IIterable</code>. If a corresponding adapter can't be found an
* exception is thrown. If the corresponding adapter isn't loaded yet, <code>null</code> is returned.
*
* @param var the variable to turn into an <code>IIterable</code>
* @param expression the expression referring to the variable
*
* @return the <code>IIterable</code> or <code>null<code> if a corresponding adapter isn't loaded yet
*
* @throws CoreException if the var can't be adapted to an <code>IIterable</code>
*/
static IIterable::Pointer GetAsIIterable(Object::Pointer var, Expression::Pointer expression);
/**
* Converts the given variable into an <code>ICountable</code>. If a corresponding adapter can't be found an
* exception is thrown. If the corresponding adapter isn't loaded yet, <code>null</code> is returned.
*
* @param var the variable to turn into an <code>ICountable</code>
* @param expression the expression referring to the variable
*
* @return the <code>ICountable</code> or <code>null<code> if a corresponding adapter isn't loaded yet
*
* @throws CoreException if the var can't be adapted to an <code>ICountable</code>
*/
static ICountable::Pointer GetAsICountable(Object::Pointer var, Expression::Pointer expression);
static bool GetOptionalBooleanAttribute(SmartPointer<IConfigurationElement> element, const std::string& attributeName);
static bool GetOptionalBooleanAttribute(Poco::XML::Element* element, const std::string& attributeName);
//---- Argument parsing --------------------------------------------
static void GetArguments(std::vector<Object::Pointer>& args, SmartPointer<IConfigurationElement> element, const std::string& attributeName);
static void GetArguments(std::vector<Object::Pointer>& args, Poco::XML::Element* element, const std::string& attributeName);
static void ParseArguments(std::vector<Object::Pointer>&, const std::string& args);
static Object::Pointer ConvertArgument(const std::string& arg, bool result = true);
static std::string UnEscapeString(const std::string& str);
};
}
#endif /*BERRYEXPRESSIONS_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryInstanceofExpression.cpp b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryInstanceofExpression.cpp
index 9c81d0d5ce..15e625f3c4 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryInstanceofExpression.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryInstanceofExpression.cpp
@@ -1,84 +1,84 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryInstanceofExpression.h"
#include "berryExpressions.h"
#include "Poco/Hash.h"
namespace berry {
const std::size_t InstanceofExpression::HASH_INITIAL= Poco::Hash<std::string>()("berry::InstanceofExpression");
InstanceofExpression::InstanceofExpression(IConfigurationElement::Pointer element)
{
bool result = element->GetAttribute(ATT_VALUE, fTypeName);
Expressions::CheckAttribute(ATT_VALUE, result);
}
InstanceofExpression::InstanceofExpression(Poco::XML::Element* element)
{
fTypeName = element->getAttribute(ATT_VALUE);
Expressions::CheckAttribute(ATT_VALUE, fTypeName.size() > 0);
}
InstanceofExpression::InstanceofExpression(const std::string& typeName)
: fTypeName(typeName)
{
}
EvaluationResult
InstanceofExpression::Evaluate(IEvaluationContext* context)
{
Object::Pointer element= context->GetDefaultVariable();
return EvaluationResult::ValueOf(Expressions::IsInstanceOf(element, fTypeName));
}
void
InstanceofExpression::CollectExpressionInfo(ExpressionInfo* info)
{
info->MarkDefaultVariableAccessed();
}
bool
InstanceofExpression::operator==(Expression& object)
{
try
{
InstanceofExpression& that = dynamic_cast<InstanceofExpression&>(object);
return this->fTypeName == that.fTypeName;
}
catch (std::bad_cast)
{
return false;
}
}
std::string
InstanceofExpression::ToString()
{
return "<instanceof value=\"" + fTypeName + "\"/>"; ;
}
std::size_t
InstanceofExpression::ComputeHashCode()
{
return HASH_INITIAL * HASH_FACTOR + Poco::Hash<std::string>()(fTypeName);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryInstanceofExpression.h b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryInstanceofExpression.h
index 2f74229ce0..767a6dc595 100755
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryInstanceofExpression.h
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryInstanceofExpression.h
@@ -1,73 +1,73 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 __BERRY_INSTANCEOF_EXPRESSION_H__
#define __BERRY_INSTANCEOF_EXPRESSION_H__
#include "berryExpression.h"
#include "service/berryIConfigurationElement.h"
#include "Poco/DOM/Element.h"
namespace berry {
struct InstanceofExpression : public Expression {
private:
/**
* The seed for the hash code for all instance of expressions.
*/
static const std::size_t HASH_INITIAL;
std::string fTypeName;
public:
InstanceofExpression(SmartPointer<IConfigurationElement> element);
InstanceofExpression(Poco::XML::Element* element);
InstanceofExpression(const std::string& typeName);
/* (non-Javadoc)
* @see org.blueberry.jdt.internal.corext.refactoring.participants.Expression#evaluate(java.lang.Object)
*/
EvaluationResult Evaluate(IEvaluationContext* context);
void CollectExpressionInfo(ExpressionInfo* info);
bool operator==(Expression& object);
//---- Debugging ---------------------------------------------------
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
std::string ToString();
protected:
std::size_t ComputeHashCode();
};
} // namespace berry
#endif // __BERRY_INSTANCEOF_EXPRESSION_H__
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryIterateExpression.cpp b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryIterateExpression.cpp
index 28338f4057..00e3289075 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryIterateExpression.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryIterateExpression.cpp
@@ -1,235 +1,235 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryIterateExpression.h"
#include "berryExpressions.h"
#include "berryDefaultVariable.h"
#include <berryObjectVector.h>
#include <Poco/String.h>
#include <Poco/Hash.h>
namespace berry
{
const std::string IterateExpression::ATT_OPERATOR = "operator"; //$NON-NLS-1$
const std::string IterateExpression::ATT_IF_EMPTY = "ifEmpty"; //$NON-NLS-1$
const int IterateExpression::OR = 1;
const int IterateExpression::AND = 2;
const std::size_t IterateExpression::HASH_INITIAL = Poco::hash(
"berry::IterateExpression");
IterateExpression::IterateExpression(
IConfigurationElement::Pointer configElement)
{
std::string opValue = "";
configElement->GetAttribute(ATT_OPERATOR, opValue);
this->InitializeOperatorValue(opValue);
std::string ifEmpty = "";
configElement->GetAttribute(ATT_IF_EMPTY, ifEmpty);
this->InitializeEmptyResultValue(ifEmpty);
}
IterateExpression::IterateExpression(Poco::XML::Element* element)
{
std::string opValue = element->getAttribute(ATT_OPERATOR);
this->InitializeOperatorValue(opValue);
std::string ifEmpty = element->getAttribute(ATT_IF_EMPTY);
this->InitializeEmptyResultValue(ifEmpty);
}
IterateExpression::IterateExpression(const std::string& opValue)
{
this->InitializeOperatorValue(opValue);
}
IterateExpression::IterateExpression(const std::string& opValue,
const std::string& ifEmpty)
{
this->InitializeOperatorValue(opValue);
this->InitializeEmptyResultValue(ifEmpty);
}
void IterateExpression::InitializeOperatorValue(const std::string& opValue)
{
if (opValue == "")
{
fOperator = AND;
}
else
{
std::vector<std::string> fValidOperators;
fValidOperators.push_back("and");
fValidOperators.push_back("or");
Expressions::CheckAttribute(ATT_OPERATOR, true, opValue, fValidOperators);
if ("and" == opValue)
{
fOperator = AND;
}
else
{
fOperator = OR;
}
}
}
void IterateExpression::InitializeEmptyResultValue(const std::string& value)
{
if (value == "")
{
fEmptyResult = -1;
}
else
{
fEmptyResult = Poco::toLower(value) == "TRUE_EVAL" ? 1 : 0;
}
}
EvaluationResult IterateExpression::Evaluate(IEvaluationContext* context)
{
Object::Pointer var = context->GetDefaultVariable();
ObjectVector<Object::Pointer>::Pointer col = var.Cast<ObjectVector<
Object::Pointer> > ();
if (col)
{
switch (col->size())
{
case 0:
{
if (fEmptyResult == -1)
{
return fOperator == AND ? EvaluationResult::TRUE_EVAL
: EvaluationResult::FALSE_EVAL;
}
else
{
return fEmptyResult == 1 ? EvaluationResult::TRUE_EVAL
: EvaluationResult::FALSE_EVAL;
}
}
case 1:
{
IEvaluationContext::Pointer scope(new DefaultVariable(context,
col->front()));
return this->EvaluateAnd(scope.GetPointer());
}
default:
IteratePool iter(context, col->begin(),
col->end());
EvaluationResult result = fOperator == AND ? EvaluationResult::TRUE_EVAL
: EvaluationResult::FALSE_EVAL;
while (iter.HasNext())
{
switch (fOperator)
{
case OR:
result = result.Or(this->EvaluateAnd(&iter));
if (result == EvaluationResult::TRUE_EVAL)
return result;
break;
case AND:
result = result.And(this->EvaluateAnd(&iter));
if (result != EvaluationResult::TRUE_EVAL)
return result;
break;
}
iter.Next();
}
return result;
}
}
else
{
IIterable::Pointer iterable = Expressions::GetAsIIterable(var,
Expression::Pointer(this));
if (iterable.IsNull())
return EvaluationResult::NOT_LOADED;
int count = 0;
IteratePool iter(context, iterable->begin(), iterable->end());
EvaluationResult result = fOperator == AND ? EvaluationResult::TRUE_EVAL
: EvaluationResult::FALSE_EVAL;
while (iter.HasNext())
{
count++;
switch (fOperator)
{
case OR:
result = result.Or(this->EvaluateAnd(&iter));
if (result == EvaluationResult::TRUE_EVAL)
return result;
break;
case AND:
result = result.And(this->EvaluateAnd(&iter));
if (result != EvaluationResult::TRUE_EVAL)
return result;
break;
}
iter.Next();
}
if (count > 0)
{
return result;
}
else
{
if (fEmptyResult == -1)
{
return fOperator == AND ? EvaluationResult::TRUE_EVAL
: EvaluationResult::FALSE_EVAL;
}
else
{
return fEmptyResult == 1 ? EvaluationResult::TRUE_EVAL
: EvaluationResult::FALSE_EVAL;
}
}
}
}
void IterateExpression::CollectExpressionInfo(ExpressionInfo* info)
{
// Although we access every single variable we only mark the default
// variable as accessed since we don't have single variables for the
// elements.
info->MarkDefaultVariableAccessed();
CompositeExpression::CollectExpressionInfo(info);
}
bool IterateExpression::operator==(Expression& object)
{
try
{
IterateExpression& that = dynamic_cast<IterateExpression&> (object);
return (this->fOperator == that.fOperator) && this->Equals(
this->fExpressions, that.fExpressions);
} catch (std::bad_cast)
{
return false;
}
}
std::size_t IterateExpression::ComputeHashCode()
{
return HASH_INITIAL * HASH_FACTOR + this->HashCode(fExpressions)
* HASH_FACTOR + fOperator;
}
} // namespace berry
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryIterateExpression.h b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryIterateExpression.h
index ab40586790..873098ce1b 100755
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryIterateExpression.h
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryIterateExpression.h
@@ -1,147 +1,147 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 __BERRY_ITERATE_EXPRESSION_H__
#define __BERRY_ITERATE_EXPRESSION_H__
#include "berryCompositeExpression.h"
#include "service/berryIConfigurationElement.h"
#include "Poco/DOM/Element.h"
#include <vector>
namespace berry {
struct IterateExpression : public CompositeExpression {
private:
struct IteratePool : public IEvaluationContext {
private:
std::vector<Object::Pointer>::iterator fIterator;
std::vector<Object::Pointer>::iterator fIterEnd;
Object::Pointer fDefaultVariable;
IEvaluationContext* fParent;
public:
IteratePool(IEvaluationContext* parent, std::vector<Object::Pointer>::iterator begin, std::vector<Object::Pointer>::iterator end)
{
poco_check_ptr(parent);
fParent= parent;
fIterator = begin;
fIterEnd = end;
}
IEvaluationContext* GetParent() const {
return fParent;
}
IEvaluationContext* GetRoot() {
return fParent->GetRoot();
}
Object::Pointer GetDefaultVariable() const {
return fDefaultVariable;
}
bool GetAllowPluginActivation() const {
return fParent->GetAllowPluginActivation();
}
void SetAllowPluginActivation(bool value) {
fParent->SetAllowPluginActivation(value);
}
void AddVariable(const std::string& name, Object::Pointer value) {
fParent->AddVariable(name, value);
}
Object::Pointer RemoveVariable(const std::string& name) {
return fParent->RemoveVariable(name);
}
Object::Pointer GetVariable(const std::string& name) const {
return fParent->GetVariable(name);
}
Object::Pointer ResolveVariable(const std::string& name, std::vector<Object::Pointer>& args) {
return fParent->ResolveVariable(name, args);
}
Poco::Any Next() {
fDefaultVariable = *(++fIterator);
return fDefaultVariable;
}
bool HasNext() {
return (fIterator != fIterEnd);
}
};
static const std::string ATT_OPERATOR;
static const std::string ATT_IF_EMPTY;
static const int OR;
static const int AND;
/**
* The seed for the hash code for all iterate expressions.
*/
static const std::size_t HASH_INITIAL;
int fOperator;
int fEmptyResult;
public:
IterateExpression(SmartPointer<IConfigurationElement> configElement);
IterateExpression(Poco::XML::Element* element);
IterateExpression(const std::string& opValue);
IterateExpression(const std::string& opValue, const std::string& ifEmpty);
private: void InitializeOperatorValue(const std::string& opValue);
private: void InitializeEmptyResultValue(const std::string& value);
public:
/* (non-Javadoc)
* @see Expression#evaluate(IVariablePool)
*/
EvaluationResult Evaluate(IEvaluationContext* context);
void CollectExpressionInfo(ExpressionInfo* info);
bool operator==(Expression& object);
protected:
std::size_t ComputeHashCode();
};
} // namespace berry
#endif // __BERRY_ITERATE_EXPRESSION_H__
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryNotExpression.cpp b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryNotExpression.cpp
index 6db40c6766..07e6a6998e 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryNotExpression.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryNotExpression.cpp
@@ -1,64 +1,64 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryNotExpression.h"
#include <Poco/Exception.h>
#include <Poco/Hash.h>
namespace berry {
const std::size_t NotExpression::HASH_INITIAL = Poco::hash("berry::NotExpression");
NotExpression::NotExpression(Expression::Pointer expression)
{
poco_assert(expression.IsNotNull());
fExpression= expression;
}
EvaluationResult
NotExpression::Evaluate(IEvaluationContext* context)
{
return fExpression->Evaluate(context).Not();
}
void
NotExpression::CollectExpressionInfo(ExpressionInfo* info)
{
fExpression->CollectExpressionInfo(info);
}
bool
NotExpression::operator==(Expression& object)
{
try {
NotExpression& that = dynamic_cast<NotExpression&>(object);
return this->fExpression == that.fExpression;
}
catch (std::bad_cast)
{
return false;
}
}
std::size_t
NotExpression::ComputeHashCode()
{
return HASH_INITIAL * HASH_FACTOR + fExpression->HashCode();
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryNotExpression.h b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryNotExpression.h
index ca2e81c117..40af19f5ac 100755
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryNotExpression.h
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryNotExpression.h
@@ -1,53 +1,53 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 __BERRY_NOT_EXPRESSION_H__
#define __BERRY_NOT_EXPRESSION_H__
#include "berryExpression.h"
namespace berry {
class NotExpression : public Expression {
private:
/**
* The seed for the hash code for all not expressions.
*/
static const std::size_t HASH_INITIAL;
Expression::Pointer fExpression;
public:
NotExpression(Expression::Pointer expression);
EvaluationResult Evaluate(IEvaluationContext* context);
void CollectExpressionInfo(ExpressionInfo* info);
bool operator==(Expression& object);
protected:
std::size_t ComputeHashCode();
};
} // namespace berry
#endif // __BERRY_NOT_EXPRESSION_H__
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryOrExpression.cpp b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryOrExpression.cpp
index 2fd26a4055..59b5d4512b 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryOrExpression.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryOrExpression.cpp
@@ -1,38 +1,38 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryOrExpression.h"
namespace berry {
EvaluationResult OrExpression::Evaluate(IEvaluationContext* context)
{
return this->EvaluateOr(context);
}
bool OrExpression::operator==(Expression& object)
{
try {
OrExpression& that = dynamic_cast<OrExpression&>(object);
return this->fExpressions == that.fExpressions;
}
catch (std::bad_cast)
{
return false;
}
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryOrExpression.h b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryOrExpression.h
index 2067781b81..f2d6c3eb43 100755
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryOrExpression.h
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryOrExpression.h
@@ -1,35 +1,35 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 __BERRY_OR_EXPRESSION_H__
#define __BERRY_OR_EXPRESSION_H__
#include "berryCompositeExpression.h"
namespace berry {
class OrExpression : public CompositeExpression {
public:
EvaluationResult Evaluate(IEvaluationContext* context);
bool operator==(Expression& object);
};
} // namespace berry
#endif // __BERRY_OR_EXPRESSION_H__
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryPluginActivator.cpp b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryPluginActivator.cpp
index faf8421e35..0c7592ed6f 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryPluginActivator.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryPluginActivator.cpp
@@ -1,40 +1,40 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryPluginActivator.h"
#include <QtPlugin>
namespace berry {
org_blueberry_core_expressions_Activator::org_blueberry_core_expressions_Activator()
{
}
void org_blueberry_core_expressions_Activator::start(ctkPluginContext* context)
{
Q_UNUSED(context)
}
void org_blueberry_core_expressions_Activator::stop(ctkPluginContext* context)
{
Q_UNUSED(context)
}
}
Q_EXPORT_PLUGIN2(org_blueberry_core_expressions, berry::org_blueberry_core_expressions_Activator)
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryPluginActivator.h b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryPluginActivator.h
index 6b420d89c2..5889ca06f5 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryPluginActivator.h
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryPluginActivator.h
@@ -1,42 +1,42 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYPLUGINACTIVATOR_H
#define BERRYPLUGINACTIVATOR_H
#include <ctkPluginActivator.h>
namespace berry {
class org_blueberry_core_expressions_Activator :
public QObject, public ctkPluginActivator
{
Q_OBJECT
Q_INTERFACES(ctkPluginActivator)
public:
org_blueberry_core_expressions_Activator();
void start(ctkPluginContext* context);
void stop(ctkPluginContext* context);
};
typedef org_blueberry_core_expressions_Activator PluginActivator;
}
#endif // BERRYPLUGINACTIVATOR_H
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryProperty.cpp b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryProperty.cpp
index 057415940f..84802dfcbb 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryProperty.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryProperty.cpp
@@ -1,80 +1,80 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryProperty.h"
#include <Poco/Hash.h>
#include <Poco/Bugcheck.h>
namespace berry {
Property::Property(Object::Pointer type,
const std::string& namespaze, const std::string& name)
: fType(type), fNamespace(namespaze), fName(name) {
}
void
Property::SetPropertyTester(IPropertyTester::Pointer tester) {
poco_check_ptr(tester);
fTester= tester;
}
bool
Property::IsInstantiated() {
return fTester->IsInstantiated();
}
bool
Property::IsDeclaringPluginActive() {
return fTester->IsDeclaringPluginActive();
}
bool
Property::IsValidCacheEntry(bool forcePluginActivation) {
if (forcePluginActivation) {
return this->IsInstantiated() && this->IsDeclaringPluginActive();
} else {
return (this->IsInstantiated() && this->IsDeclaringPluginActive()) ||
(!this->IsInstantiated() && !this->IsDeclaringPluginActive());
}
}
bool
Property::Test(Object::Pointer receiver, std::vector<Object::Pointer>& args, Object::Pointer expectedValue) {
return fTester->Test(receiver, fName, args, expectedValue);
}
bool
Property::operator==(Property& obj) {
return fType == obj.fType && fNamespace == obj.fNamespace &&
fName == obj.fName;
}
bool
Property::operator==(Property* obj) {
return this->operator==(*obj);
}
int
Property::HashCode() {
return (int) ((Poco::Hash<std::string>()(typeid(fType).name()) << 16) |
(Poco::Hash<std::string>()(fNamespace) << 8) |
Poco::Hash<std::string>()(fName));
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryProperty.h b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryProperty.h
index 9dc918c4fd..d8e0d84c3d 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryProperty.h
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryProperty.h
@@ -1,70 +1,70 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYPROPERTY_H_
#define BERRYPROPERTY_H_
#include "berryIPropertyTester.h"
#include "berryObject.h"
#include "Poco/SharedPtr.h"
#include "Poco/Any.h"
#include <vector>
#include <typeinfo>
namespace berry {
class Property {
public:
typedef Property Self;
typedef Poco::SharedPtr<Self> Pointer;
typedef Poco::SharedPtr<const Self> ConstPointer;
private:
Object::Pointer fType;
std::string fNamespace;
std::string fName;
IPropertyTester::Pointer fTester;
friend class TypeExtensionManager;
/* package */ Property(Object::Pointer type,
const std::string& namespaze, const std::string& name);
/* package */ void SetPropertyTester(IPropertyTester::Pointer tester);
public:
bool IsInstantiated();
bool IsDeclaringPluginActive();
bool IsValidCacheEntry(bool forcePluginActivation);
bool Test(Object::Pointer receiver, std::vector<Object::Pointer>& args, Object::Pointer expectedValue);
bool operator==(Property& obj);
bool operator==(Property* obj);
int HashCode();
};
} // namespace berry
#endif /*BERRYPROPERTY_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryPropertyCache.h b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryPropertyCache.h
index aa709f67d5..da89c33087 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryPropertyCache.h
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryPropertyCache.h
@@ -1,52 +1,52 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYPROPERTYCACHE_H_
#define BERRYPROPERTYCACHE_H_
#include "Poco/LRUCache.h"
#include "berryProperty.h"
namespace berry {
class PropertyCache {
private:
Poco::LRUCache<Property::Pointer, Property> fCache;
public:
PropertyCache(const int cacheSize) : fCache(cacheSize) {
}
Property::Pointer Get(Property::Pointer key) {
return fCache.get(key);
}
void Put(Property::Pointer method) {
fCache.add(method, method);
}
void Remove(Property::Pointer method) {
fCache.remove(method);
}
};
} // namespace berry
#endif /*BERRYPROPERTYCACHE_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryPropertyTesterDescriptor.cpp b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryPropertyTesterDescriptor.cpp
index 94c4317a37..caac8ad811 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryPropertyTesterDescriptor.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryPropertyTesterDescriptor.cpp
@@ -1,121 +1,121 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryPropertyTesterDescriptor.h"
#include "berryPlatform.h"
#include "berryPlatformException.h"
#include "Poco/String.h"
namespace berry
{
const std::string PropertyTesterDescriptor::PROPERTIES= "properties"; //$NON-NLS-1$
const std::string PropertyTesterDescriptor::NAMESPACE= "namespace"; //$NON-NLS-1$
const std::string PropertyTesterDescriptor::CLASS= "class"; //$NON-NLS-1$
PropertyTesterDescriptor::PropertyTesterDescriptor(IConfigurationElement::Pointer element)
: fConfigElement(element)
{
fNamespace = "";
fConfigElement->GetAttribute(NAMESPACE, fNamespace);
if (fNamespace.size() == 0)
{
throw new CoreException("No namespace");
}
std::string buffer(",");
std::string properties = "";
fConfigElement->GetAttribute(PROPERTIES, properties);
if (properties.size() == 0)
{
throw new CoreException("No properties");
}
Poco::translateInPlace(buffer, "\r\n\t ", "");
// std::string::iterator iter;
// for (iter = properties.begin(); iter != properties.end(); ++iter)
// {
// char ch= properties.charAt(i);
// if (!Character.isWhitespace(ch))
// buffer.append(ch);
// }
// buffer.append(',');
fProperties = buffer;
}
PropertyTesterDescriptor::PropertyTesterDescriptor(IConfigurationElement::Pointer element, const std::string& namespaze, const std::string& properties)
: fConfigElement(element), fNamespace(namespaze), fProperties(properties)
{
}
const std::string&
PropertyTesterDescriptor::GetProperties()
{
return fProperties;
}
const std::string&
PropertyTesterDescriptor::GetNamespace()
{
return fNamespace;
}
IConfigurationElement::Pointer
PropertyTesterDescriptor::GetExtensionElement()
{
return fConfigElement;
}
bool
PropertyTesterDescriptor::Handles(const std::string& namespaze, const std::string& property)
{
return fNamespace == namespaze && fProperties.find("," + property + ",") != std::string::npos;
}
bool
PropertyTesterDescriptor::IsInstantiated()
{
return false;
}
bool
PropertyTesterDescriptor::IsDeclaringPluginActive()
{
IBundle::Pointer fBundle= Platform::GetBundle(fConfigElement->GetContributor());
return fBundle->IsActive();
}
IPropertyTester*
PropertyTesterDescriptor::Instantiate()
{
IPropertyTester* tester = fConfigElement->CreateExecutableExtension<IPropertyTester>(CLASS);
if (tester == 0)
{
// support legacy BlueBerry extension
tester = fConfigElement->CreateExecutableExtension<IPropertyTester>(CLASS, IPropertyTester::GetManifestName());
}
return tester;
}
bool
PropertyTesterDescriptor::Test(Object::Pointer /*receiver*/, const std::string& /*method*/, std::vector<Object::Pointer>& /*args*/, Object::Pointer /*expectedValue*/)
{
poco_bugcheck_msg("Method should never be called");
return false;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryPropertyTesterDescriptor.h b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryPropertyTesterDescriptor.h
index 5728e7f0c2..a61f8df7df 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryPropertyTesterDescriptor.h
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryPropertyTesterDescriptor.h
@@ -1,71 +1,71 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYPROPERTYTESTERDESCRIPTOR_H_
#define BERRYPROPERTYTESTERDESCRIPTOR_H_
#include "service/berryIConfigurationElement.h"
#include "berryIPropertyTester.h"
#include "Poco/Any.h"
#include <vector>
#include <string>
namespace berry
{
class PropertyTesterDescriptor : public IPropertyTester {
public:
berryObjectMacro(PropertyTesterDescriptor)
private:
IConfigurationElement::Pointer fConfigElement;
std::string fNamespace;
std::string fProperties;
static const std::string PROPERTIES;
static const std::string NAMESPACE;
static const std::string CLASS;
public:
PropertyTesterDescriptor(IConfigurationElement::Pointer element);
PropertyTesterDescriptor(IConfigurationElement::Pointer element, const std::string& namespaze, const std::string& properties);
const std::string& GetProperties();
const std::string& GetNamespace();
IConfigurationElement::Pointer GetExtensionElement();
bool Handles(const std::string& namespaze, const std::string& property);
bool IsInstantiated();
bool IsDeclaringPluginActive();
IPropertyTester* Instantiate();
bool Test(Object::Pointer receiver, const std::string& method, std::vector<Object::Pointer>& args, Object::Pointer expectedValue);
};
} // namespace berry
#endif /*BERRYPROPERTYTESTERDESCRIPTOR_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryReferenceExpression.cpp b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryReferenceExpression.cpp
index cd517c49c6..4bdccd2a06 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryReferenceExpression.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryReferenceExpression.cpp
@@ -1,96 +1,96 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryReferenceExpression.h"
#include "berryExpressions.h"
#include "Poco/Hash.h"
namespace berry {
const std::string ReferenceExpression::ATT_DEFINITION_ID= "definitionId";
const std::size_t ReferenceExpression::HASH_INITIAL= Poco::Hash<std::string>()("berry::ReferenceExpression");
DefinitionRegistry ReferenceExpression::fgDefinitionRegistry = DefinitionRegistry();
DefinitionRegistry&
ReferenceExpression::GetDefinitionRegistry()
{
return fgDefinitionRegistry;
}
ReferenceExpression::ReferenceExpression(const std::string& definitionId)
{
fDefinitionId= definitionId;
}
ReferenceExpression::ReferenceExpression(IConfigurationElement::Pointer element)
{
bool result = element->GetAttribute(ATT_DEFINITION_ID, fDefinitionId);
Expressions::CheckAttribute(ATT_DEFINITION_ID, result);
}
ReferenceExpression::ReferenceExpression(Poco::XML::Element* element)
{
fDefinitionId = element->getAttribute(ATT_DEFINITION_ID);
Expressions::CheckAttribute(ATT_DEFINITION_ID, fDefinitionId.size() > 0);
}
EvaluationResult
ReferenceExpression::Evaluate(IEvaluationContext* context)
{
Expression::Pointer expr= GetDefinitionRegistry().GetExpression(fDefinitionId);
return expr->Evaluate(context);
}
void
ReferenceExpression::CollectExpressionInfo(ExpressionInfo* info)
{
Expression::Pointer expr;
try
{
expr= GetDefinitionRegistry().GetExpression(fDefinitionId);
}
catch (CoreException e)
{
// We didn't find the expression definition. So no
// expression info can be collected.
return;
}
expr->CollectExpressionInfo(info);
}
bool
ReferenceExpression::operator==(Expression& object)
{
try {
ReferenceExpression& that = dynamic_cast<ReferenceExpression&>(object);
return this->fDefinitionId == that.fDefinitionId;
}
catch (std::bad_cast)
{
return false;
}
}
std::size_t
ReferenceExpression::ComputeHashCode()
{
return HASH_INITIAL * HASH_FACTOR + Poco::Hash<std::string>()(fDefinitionId);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryReferenceExpression.h b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryReferenceExpression.h
index 89aa6b8e15..0a7a677b14 100755
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryReferenceExpression.h
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryReferenceExpression.h
@@ -1,74 +1,74 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 __BERRY_REFERENCE_EXPRESSION_H__
#define __BERRY_REFERENCE_EXPRESSION_H__
#include "berryDefinitionRegistry.h"
#include "Poco/DOM/Element.h"
namespace berry {
/**
* This class makes use of the <b>org.blueberry.core.expressions.definitions</b>
* extension point to evaluate the current context against pre-defined
* expressions. It provides core expression re-use.
*
* @since 3.3
*/
class ReferenceExpression : public Expression {
private:
// consider making this a more general extension manager
// for now it's just part of the reference expression
static DefinitionRegistry fgDefinitionRegistry;
static DefinitionRegistry& GetDefinitionRegistry();
static const std::string ATT_DEFINITION_ID;
/**
* The seed for the hash code for all equals expressions.
*/
static const std::size_t HASH_INITIAL;
std::string fDefinitionId;
public:
ReferenceExpression(const std::string& definitionId);
ReferenceExpression(SmartPointer<IConfigurationElement> element);
ReferenceExpression(Poco::XML::Element* element);
EvaluationResult Evaluate(IEvaluationContext* context);
void CollectExpressionInfo(ExpressionInfo* info);
bool operator==(Expression& object);
protected:
std::size_t ComputeHashCode();
};
} // namespace berry
#endif // __BERRY_REFERENCE_EXPRESSION_H__
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryResolveExpression.cpp b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryResolveExpression.cpp
index 85f79d34c3..6ffad73837 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryResolveExpression.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryResolveExpression.cpp
@@ -1,98 +1,98 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryResolveExpression.h"
#include "berryExpressions.h"
#include "berryEvaluationContext.h"
#include "Poco/Hash.h"
namespace berry {
const std::string ResolveExpression::ATT_VARIABLE= "variable";
const std::string ResolveExpression::ATT_ARGS= "args";
const std::size_t ResolveExpression::HASH_INITIAL = Poco::Hash<std::string>()("berry::ResolveExpression");
ResolveExpression::ResolveExpression(IConfigurationElement::Pointer configElement)
{
bool result = configElement->GetAttribute(ATT_VARIABLE, fVariable);
Expressions::CheckAttribute(ATT_VARIABLE, result);
Expressions::GetArguments(fArgs, configElement, ATT_ARGS);
}
ResolveExpression::ResolveExpression(Poco::XML::Element* element)
{
fVariable = element->getAttribute(ATT_VARIABLE);
Expressions::CheckAttribute(ATT_VARIABLE, fVariable.size()> 0);
Expressions::GetArguments(fArgs, element, ATT_ARGS);
}
ResolveExpression::ResolveExpression(const std::string& variable, std::vector<Object::Pointer>& args)
: fVariable(variable), fArgs(args)
{
}
EvaluationResult
ResolveExpression::Evaluate(IEvaluationContext* context)
{
Object::Pointer variable= context->ResolveVariable(fVariable, fArgs);
if (variable.IsNull())
{
throw CoreException("Variable not defined", fVariable);
}
EvaluationContext evalContext(context, variable);
return this->EvaluateAnd(&evalContext);
}
void
ResolveExpression::CollectExpressionInfo(ExpressionInfo* info)
{
ExpressionInfo other;
this->CompositeExpression::CollectExpressionInfo(&other);
if (other.HasDefaultVariableAccess())
{
info->AddVariableNameAccess(fVariable);
}
info->MergeExceptDefaultVariable(&other);
}
bool
ResolveExpression::operator==(Expression& object)
{
try
{
ResolveExpression& that = dynamic_cast<ResolveExpression&>(object);
return this->fVariable == that.fVariable
&& this->Equals(this->fArgs, that.fArgs)
&& this->Equals(this->fExpressions, that.fExpressions);
}
catch (std::bad_cast)
{
return false;
}
}
std::size_t
ResolveExpression::ComputeHashCode()
{
return HASH_INITIAL * HASH_FACTOR + this->HashCode(fExpressions)
* HASH_FACTOR + this->HashCode(fArgs)
* HASH_FACTOR + Poco::Hash<std::string>()(fVariable);
}
} // namespace berry
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryResolveExpression.h b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryResolveExpression.h
index e9e2458d7b..d1ecef46c7 100755
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryResolveExpression.h
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryResolveExpression.h
@@ -1,66 +1,66 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 __BERRY_RESOLVE_EXPRESSION_H__
#define __BERRY_RESOLVE_EXPRESSION_H__
#include "berryCompositeExpression.h"
#include "service/berryIConfigurationElement.h"
#include "Poco/DOM/Element.h"
#include <vector>
namespace berry {
class ResolveExpression : public CompositeExpression {
private:
std::string fVariable;
std::vector<Object::Pointer> fArgs;
static const std::string ATT_VARIABLE;
static const std::string ATT_ARGS;
/**
* The seed for the hash code for all resolve expressions.
*/
static const std::size_t HASH_INITIAL;
public:
ResolveExpression(SmartPointer<IConfigurationElement> configElement);
ResolveExpression(Poco::XML::Element* element);
ResolveExpression(const std::string& variable, std::vector<Object::Pointer>& args);
EvaluationResult Evaluate(IEvaluationContext* context);
void CollectExpressionInfo(ExpressionInfo* info);
bool operator==(Expression& object);
protected:
std::size_t ComputeHashCode();
};
} // namespace berry
#endif // __BERRY_RESOLVE_EXPRESSION_H__
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryStandardElementHandler.cpp b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryStandardElementHandler.cpp
index b6dbcd1920..72654d7c20 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryStandardElementHandler.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryStandardElementHandler.cpp
@@ -1,160 +1,160 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryStandardElementHandler.h"
#include "berryExpressionTagNames.h"
#include "berryInstanceofExpression.h"
#include "berryTestExpression.h"
#include "berryOrExpression.h"
#include "berryAndExpression.h"
#include "berryNotExpression.h"
#include "berryWithExpression.h"
#include "berryAdaptExpression.h"
#include "berryIterateExpression.h"
#include "berryCountExpression.h"
#include "berrySystemTestExpression.h"
#include "berryResolveExpression.h"
#include "berryEnablementExpression.h"
#include "berryEqualsExpression.h"
#include "berryReferenceExpression.h"
namespace berry
{
Expression::Pointer
StandardElementHandler::Create(ExpressionConverter* converter, IConfigurationElement::Pointer element)
{
std::string name = element->GetName();
if (ExpressionTagNames::INSTANCEOF == name) {
Expression::Pointer result(new InstanceofExpression(element));
return result;
} else if (ExpressionTagNames::TEST == name) {
Expression::Pointer result(new TestExpression(element));
return result;
} else if (ExpressionTagNames::OR == name) {
CompositeExpression::Pointer result(new OrExpression());
this->ProcessChildren(converter, element, result);
return result;
} else if (ExpressionTagNames::AND == name) {
CompositeExpression::Pointer result(new AndExpression());
this->ProcessChildren(converter, element, result);
return result;
} else if (ExpressionTagNames::NOT == name) {
IConfigurationElement::vector children(element->GetChildren());
Expression::Pointer result(new NotExpression(converter->Perform(children[0])));
return result;
} else if (ExpressionTagNames::WITH == name) {
CompositeExpression::Pointer result(new WithExpression(element));
this->ProcessChildren(converter, element, result);
return result;
} else if (ExpressionTagNames::ADAPT == name) {
CompositeExpression::Pointer result(new AdaptExpression(element));
this->ProcessChildren(converter, element, result);
return result;
} else if (ExpressionTagNames::ITERATE == name) {
CompositeExpression::Pointer result(new IterateExpression(element));
this->ProcessChildren(converter, element, result);
return result;
} else if (ExpressionTagNames::COUNT == name) {
Expression::Pointer result(new CountExpression(element));
return result;
} else if (ExpressionTagNames::SYSTEM_TEST == name) {
Expression::Pointer result(new SystemTestExpression(element));
return result;
} else if (ExpressionTagNames::RESOLVE == name) {
CompositeExpression::Pointer result(new ResolveExpression(element));
this->ProcessChildren(converter, element, result);
return result;
} else if (ExpressionTagNames::ENABLEMENT == name) {
CompositeExpression::Pointer result(new EnablementExpression(element));
this->ProcessChildren(converter, element, result);
return result;
} else if (ExpressionTagNames::EQUALS == name) {
Expression::Pointer result(new EqualsExpression(element));
return result;
} else if (ExpressionTagNames::REFERENCE == name) {
Expression::Pointer result(new ReferenceExpression(element));
return result;
}
return Expression::Pointer();
}
Expression::Pointer
StandardElementHandler::Create(ExpressionConverter* converter, Poco::XML::Element* element)
{
std::string name= element->nodeName();
if (ExpressionTagNames::INSTANCEOF == name) {
Expression::Pointer result(new InstanceofExpression(element));
return result;
} else if (ExpressionTagNames::TEST == name) {
Expression::Pointer result(new TestExpression(element));
return result;
} else if (ExpressionTagNames::OR == name) {
CompositeExpression::Pointer result(new OrExpression());
this->ProcessChildren(converter, element, result);
return result;
} else if (ExpressionTagNames::AND == name) {
CompositeExpression::Pointer result(new AndExpression());
this->ProcessChildren(converter, element, result);
return result;
} else if (ExpressionTagNames::NOT == name) {
Poco::XML::Node* child = element->firstChild();
while (child != 0) {
if (child->nodeType() == Poco::XML::Node::ELEMENT_NODE) {
Expression::Pointer result(new NotExpression(converter->Perform(static_cast<Poco::XML::Element*>(child))));
return result;
}
child = child->nextSibling();
}
} else if (ExpressionTagNames::WITH == name) {
CompositeExpression::Pointer result(new WithExpression(element));
this->ProcessChildren(converter, element, result);
return result;
} else if (ExpressionTagNames::ADAPT == name) {
CompositeExpression::Pointer result(new AdaptExpression(element));
this->ProcessChildren(converter, element, result);
return result;
} else if (ExpressionTagNames::ITERATE == name) {
CompositeExpression::Pointer result(new IterateExpression(element));
this->ProcessChildren(converter, element, result);
return result;
} else if (ExpressionTagNames::COUNT == name) {
Expression::Pointer result(new CountExpression(element));
return result;
} else if (ExpressionTagNames::SYSTEM_TEST == name) {
Expression::Pointer result(new SystemTestExpression(element));
return result;
} else if (ExpressionTagNames::RESOLVE == name) {
CompositeExpression::Pointer result(new ResolveExpression(element));
this->ProcessChildren(converter, element, result);
return result;
} else if (ExpressionTagNames::ENABLEMENT == name) {
CompositeExpression::Pointer result(new EnablementExpression(element));
this->ProcessChildren(converter, element, result);
return result;
} else if (ExpressionTagNames::EQUALS == name) {
Expression::Pointer result(new EqualsExpression(element));
return result;
} else if (ExpressionTagNames::REFERENCE == name) {
Expression::Pointer result(new ReferenceExpression(element));
return result;
}
return Expression::Pointer();
}
} // namespace berry
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryStandardElementHandler.h b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryStandardElementHandler.h
index b0e3489277..047c6718c1 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryStandardElementHandler.h
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryStandardElementHandler.h
@@ -1,40 +1,40 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYSTANDARDELEMENTHANDLER_H_
#define BERRYSTANDARDELEMENTHANDLER_H_
#include "service/berryIConfigurationElement.h"
#include "berryExpression.h"
#include "berryElementHandler.h"
#include "berryExpressionConverter.h"
namespace berry
{
class StandardElementHandler : public ElementHandler
{
public:
Expression::Pointer Create(ExpressionConverter* converter, SmartPointer<IConfigurationElement> element);
Expression::Pointer Create(ExpressionConverter* converter, Poco::XML::Element* element);
};
} // namespace berry
#endif /*BERRYSTANDARDELEMENTHANDLER_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berrySystemTestExpression.cpp b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berrySystemTestExpression.cpp
index 25716f68e3..f5d57194f7 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berrySystemTestExpression.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berrySystemTestExpression.cpp
@@ -1,98 +1,98 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berrySystemTestExpression.h"
#include "berryExpressions.h"
#include <berryPlatform.h>
#include <Poco/Hash.h>
namespace berry {
const std::string SystemTestExpression::ATT_PROPERTY= "property";
const std::size_t SystemTestExpression::HASH_INITIAL = Poco::Hash<std::string>()("berry::SystemTestExpression");
SystemTestExpression::SystemTestExpression(IConfigurationElement::Pointer element)
{
bool result = element->GetAttribute(ATT_PROPERTY, fProperty);
Expressions::CheckAttribute(ATT_PROPERTY, result);
result = element->GetAttribute(ATT_VALUE, fExpectedValue);
Expressions::CheckAttribute(ATT_VALUE, result);
}
SystemTestExpression::SystemTestExpression(Poco::XML::Element* element)
{
fProperty= element->getAttribute(ATT_PROPERTY);
Expressions::CheckAttribute(ATT_PROPERTY, fProperty.length()> 0);
fExpectedValue = element->getAttribute(ATT_VALUE);
Expressions::CheckAttribute(ATT_VALUE, fExpectedValue.length()> 0);
}
SystemTestExpression::SystemTestExpression(const std::string& property, const std::string& expectedValue)
: fProperty(property), fExpectedValue(expectedValue)
{
}
EvaluationResult
SystemTestExpression::Evaluate(IEvaluationContext* /*context*/)
{
std::string str = Platform::GetProperty(fProperty);
if (str.size() == 0)
return EvaluationResult::FALSE_EVAL;
return EvaluationResult::ValueOf(str == fExpectedValue);
}
void
SystemTestExpression::CollectExpressionInfo(ExpressionInfo* info)
{
info->MarkSystemPropertyAccessed();
}
bool
SystemTestExpression::operator==(Expression& object)
{
try {
SystemTestExpression& that = dynamic_cast<SystemTestExpression&>(object);
return this->fProperty == that.fProperty
&& this->fExpectedValue == that.fExpectedValue;
}
catch (std::bad_cast)
{
return false;
}
}
std::size_t
SystemTestExpression::ComputeHashCode()
{
return HASH_INITIAL * HASH_FACTOR + Poco::Hash<std::string>()(fExpectedValue)
* HASH_FACTOR + Poco::Hash<std::string>()(fProperty);
}
std::string
SystemTestExpression::ToString()
{
return "<systemTest property=\"" + fProperty + //$NON-NLS-1$
"\" value=\"" + fExpectedValue + "\""; //$NON-NLS-1$ //$NON-NLS-2$
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berrySystemTestExpression.h b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berrySystemTestExpression.h
index f86b433383..ee6983f8c2 100755
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berrySystemTestExpression.h
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berrySystemTestExpression.h
@@ -1,70 +1,70 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 __BERRY_SYSTEM_TEXT_EXPRESSION_H__
#define __BERRY_SYSTEM_TEXT_EXPRESSION_H__
#include "berryExpression.h"
#include "service/berryIConfigurationElement.h"
#include "Poco/DOM/Element.h"
namespace berry {
class SystemTestExpression : public Expression {
private:
std::string fProperty;
std::string fExpectedValue;
static const std::string ATT_PROPERTY;
/**
* The seed for the hash code for all system test expressions.
*/
static const std::size_t HASH_INITIAL;
public:
SystemTestExpression(SmartPointer<IConfigurationElement> element);
SystemTestExpression(Poco::XML::Element* element);
SystemTestExpression(const std::string& property, const std::string& expectedValue);
EvaluationResult Evaluate(IEvaluationContext* context);
void CollectExpressionInfo(ExpressionInfo* info);
bool operator==(Expression& object);
protected:
std::size_t ComputeHashCode();
// ---- Debugging ---------------------------------------------------
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
public:
std::string ToString();
};
} // namespace berry
#endif // __BERRY_SYSTEM_TEXT_EXPRESSION_H__
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryTestExpression.cpp b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryTestExpression.cpp
index f2c4618cc2..7be202ec80 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryTestExpression.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryTestExpression.cpp
@@ -1,188 +1,188 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryTestExpression.h"
#include "berryExpressions.h"
#include "berryPlatform.h"
#include <berryObjectString.h>
#include <Poco/Hash.h>
namespace berry {
const char TestExpression::PROP_SEP = '.';
const std::string TestExpression::ATT_PROPERTY = "property";
const std::string TestExpression::ATT_ARGS = "args";
const std::string TestExpression::ATT_FORCE_PLUGIN_ACTIVATION = "forcePluginActivation";
TypeExtensionManager TestExpression::fgTypeExtensionManager("propertyTesters");
const std::size_t TestExpression::HASH_INITIAL= Poco::hash("berry::TextExpression");
TestExpression::TestExpression(IConfigurationElement::Pointer element)
{
std::string property;
element->GetAttribute(ATT_PROPERTY, property);
std::size_t pos = property.find_last_of(PROP_SEP);
if (pos == std::string::npos)
{
throw CoreException("No namespace provided");
}
fNamespace = property.substr(0, pos);
fProperty = property.substr(pos + 1);
Expressions::GetArguments(fArgs, element, ATT_ARGS);
std::string arg = "";
bool result = element->GetAttribute(ATT_VALUE, arg);
fExpectedValue = Expressions::ConvertArgument(arg, result);
fForcePluginActivation = Expressions::GetOptionalBooleanAttribute(element, ATT_FORCE_PLUGIN_ACTIVATION);
}
TestExpression::TestExpression(Poco::XML::Element* element)
{
std::string property= element->getAttribute(ATT_PROPERTY);
std::size_t pos = property.find_last_of(PROP_SEP);
if (pos == std::string::npos)
{
throw CoreException("No namespace provided");
}
fNamespace = property.substr(0, pos);
fProperty = property.substr(pos + 1);
Expressions::GetArguments(fArgs, element, ATT_ARGS);
std::string value = element->getAttribute(ATT_VALUE);
fExpectedValue = Expressions::ConvertArgument(value, value.size() > 0);
fForcePluginActivation= Expressions::GetOptionalBooleanAttribute(element, ATT_FORCE_PLUGIN_ACTIVATION);
}
TestExpression::TestExpression(const std::string& namespaze, const std::string& property, std::vector<Object::Pointer>& args, Object::Pointer expectedValue)
{
TestExpression(namespaze, property, args, expectedValue, false);
}
TestExpression::TestExpression(const std::string& namespaze, const std::string& property, std::vector<Object::Pointer>& args, Object::Pointer expectedValue, bool forcePluginActivation)
: fNamespace(namespaze), fProperty(property), fArgs(args),
fExpectedValue(expectedValue), fForcePluginActivation(forcePluginActivation)
{
}
EvaluationResult
TestExpression::Evaluate(IEvaluationContext* context)
{
Object::Pointer element = context->GetDefaultVariable();
if (typeid(Platform) == typeid(element.GetPointer()))
{
std::string str = Platform::GetProperty(fProperty);
if (str.size() == 0)
{
return EvaluationResult::FALSE_EVAL;
}
ObjectString::Pointer var = fArgs[0].Cast<ObjectString>();
if (var)
return EvaluationResult::ValueOf(*var == str);
return EvaluationResult::FALSE_EVAL;
}
Property::Pointer property= fgTypeExtensionManager.GetProperty(element, fNamespace, fProperty, context->GetAllowPluginActivation() && fForcePluginActivation);
if (!property->IsInstantiated())
return EvaluationResult::NOT_LOADED;
return EvaluationResult::ValueOf(property->Test(element, fArgs, fExpectedValue));
}
void
TestExpression::CollectExpressionInfo(ExpressionInfo* info)
{
info->MarkDefaultVariableAccessed();
info->AddAccessedPropertyName(fNamespace + PROP_SEP + fProperty);
}
bool
TestExpression::operator==(Expression& object)
{
try {
TestExpression& that = dynamic_cast<TestExpression&>(object);
return this->fNamespace == that.fNamespace &&
this->fProperty == that.fProperty &&
this->fForcePluginActivation == that.fForcePluginActivation &&
this->Equals(this->fArgs, that.fArgs) &&
this->fExpectedValue == that.fExpectedValue;
}
catch (std::bad_cast)
{
return false;
}
}
std::size_t
TestExpression::ComputeHashCode()
{
return HASH_INITIAL * HASH_FACTOR + this->HashCode(fArgs)
* HASH_FACTOR + fExpectedValue->HashCode()
* HASH_FACTOR + Poco::hash(fNamespace)
* HASH_FACTOR + Poco::hash(fProperty)
* HASH_FACTOR + (fForcePluginActivation ? 1 : 0);
}
std::string
TestExpression::ToString()
{
std::string args("");
for (unsigned int i= 0; i < fArgs.size(); i++)
{
Object::Pointer arg= fArgs[i];
ObjectString::Pointer strarg = arg.Cast<ObjectString>();
if (strarg)
{
args.append(1,'\'');
args.append(*strarg);
args.append(1,'\'');
}
else
{
args.append(arg->ToString());
}
if (i < fArgs.size() - 1)
args.append(", "); //$NON-NLS-1$
}
return "<test property=\"" + fProperty +
(fArgs.size() != 0 ? "\" args=\"" + args + "\"" : "\"") +
(!fExpectedValue.IsNull() ? "\" value=\"" + fExpectedValue->ToString() + "\"" : "\"") +
" plug-in activation: " + (fForcePluginActivation ? "eager" : "lazy") +
"/>"; //$NON-NLS-1$
}
//---- testing ---------------------------------------------------
bool
TestExpression::TestGetForcePluginActivation()
{
return fForcePluginActivation;
}
TypeExtensionManager&
TestExpression::TestGetTypeExtensionManager()
{
return fgTypeExtensionManager;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryTestExpression.h b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryTestExpression.h
index f3598f2fc0..9a702ce70e 100755
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryTestExpression.h
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryTestExpression.h
@@ -1,91 +1,91 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 __BERRY_TEST_EXPRESSION_H__
#define __BERRY_TEST_EXPRESSION_H__
#include "berryExpression.h"
#include "berryTypeExtensionManager.h"
#include "service/berryIConfigurationElement.h"
#include "berryObject.h"
#include "Poco/DOM/Element.h"
namespace berry {
class TestExpression : public Expression {
private:
std::string fNamespace;
std::string fProperty;
std::vector<Object::Pointer> fArgs;
Object::Pointer fExpectedValue;
bool fForcePluginActivation;
static const char PROP_SEP;
static const std::string ATT_PROPERTY;
static const std::string ATT_ARGS;
static const std::string ATT_FORCE_PLUGIN_ACTIVATION;
/**
* The seed for the hash code for all test expressions.
*/
static const std::size_t HASH_INITIAL;
static TypeExtensionManager fgTypeExtensionManager;
public:
TestExpression(SmartPointer<IConfigurationElement> element);
TestExpression(Poco::XML::Element* element);
TestExpression(const std::string& namespaze, const std::string& property,
std::vector<Object::Pointer>& args, Object::Pointer expectedValue);
TestExpression(const std::string& namespaze, const std::string& property,
std::vector<Object::Pointer>& args, Object::Pointer expectedValue, bool forcePluginActivation);
EvaluationResult Evaluate(IEvaluationContext* context);
void CollectExpressionInfo(ExpressionInfo* info);
bool operator==(Expression& object);
protected:
std::size_t ComputeHashCode();
//---- Debugging ---------------------------------------------------
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
public:
std::string ToString();
//---- testing ---------------------------------------------------
bool TestGetForcePluginActivation();
static TypeExtensionManager& TestGetTypeExtensionManager();
};
} // namespace berry
#endif // __BERRY_TEST_EXPRESSION_H__
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryTypeExtension.cpp b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryTypeExtension.cpp
index 9a34247193..97ecf40a6a 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryTypeExtension.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryTypeExtension.cpp
@@ -1,104 +1,104 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryTypeExtension.h"
#include "berryTypeExtensionManager.h"
#include "berryPropertyTesterDescriptor.h"
#include "berryPropertyTester.h"
namespace berry {
TypeExtension::TypeExtension(const std::string& typeInfo)
: fTypeInfo(typeInfo), fExtendersLoaded(false), fExtendsLoaded(false) {
}
IPropertyTester::Pointer
TypeExtension::FindTypeExtender(TypeExtensionManager& manager,
const std::string& namespaze, const std::string& method,
bool staticMethod, bool forcePluginActivation) {
if (!fExtendersLoaded) {
manager.LoadTesters(fExtenders, fTypeInfo);
fExtendersLoaded = true;
}
IPropertyTester::Pointer result;
// handle extenders associated with this type extender
for (unsigned int i= 0; i < fExtenders.size(); i++) {
IPropertyTester::Pointer extender = fExtenders[i];
if (extender.IsNull() || !extender->Handles(namespaze, method))
continue;
if (extender->IsInstantiated()) {
// There is no need to check for an active plug-in here. If a plug-in
// gets uninstalled we receive an registry event which will flush the whole
// type extender cache and will reinstantiate the testers. However Bundle#stop
// isn't handled by this. According to bug https://bugs.blueberry.org/bugs/show_bug.cgi?id=130338
// we don't have to support stop in 3.2. If we have to in the future we have to
// reactivate the stopped plug-in if we are in forcePluginActivation mode.
return extender;
} else {
if (extender->IsDeclaringPluginActive() || forcePluginActivation) {
PropertyTesterDescriptor::Pointer descriptor = extender.Cast<PropertyTesterDescriptor>();
if (!descriptor.IsNull())
{
try {
IPropertyTester::Pointer inst(descriptor->Instantiate());
inst.Cast<PropertyTester>()->InternalInitialize(descriptor);
fExtenders[i]= extender = inst;
return extender;
} catch (CoreException e) {
fExtenders[i] = IPropertyTester::Pointer();
throw e;
}
}
else {
fExtenders[i]= IPropertyTester::Pointer();
throw CoreException("Type extender has incorrect type");
}
} else {
return extender;
}
}
}
// there is no inheritance for static methods
if (staticMethod)
return CONTINUE_::Pointer(new CONTINUE_());
// handle inheritance chain
// TODO Reflection
// if (!fExtendsLoaded) {
// fExtends.clear();
// Object::ExtTypeInfo types(fTypeInfo);
// while (!types.m_TypeNames.empty()) {
// types.m_TypeNames.pop_back();
// types.m_TypeInfos.pop_back();
// fExtends.push_back(manager.Get(types));
// }
// fExtendsLoaded = true;
// }
// for (unsigned int i= 0; i < fExtends.size(); i++) {
// result = fExtends[i]->FindTypeExtender(manager, namespaze, method, staticMethod, forcePluginActivation);
// if (result.Cast<CONTINUE_>().IsNull())
// return result;
// }
return CONTINUE_::Pointer(new CONTINUE_());
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryTypeExtension.h b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryTypeExtension.h
index 40af87e71e..856d9a6a48 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryTypeExtension.h
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryTypeExtension.h
@@ -1,110 +1,110 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYTYPEEXTENSION_H_
#define BERRYTYPEEXTENSION_H_
#include <berryMacros.h>
#include <berryObject.h>
#include "berryIPropertyTester.h"
#include <vector>
namespace berry {
class TypeExtensionManager;
class END_POINT_;
class TypeExtension : public Object {
public:
berryObjectMacro(TypeExtension);
private:
/* the type this extension is extending */
std::string fTypeInfo;
/* the list of associated extenders */
std::vector<IPropertyTester::Pointer> fExtenders;
bool fExtendersLoaded;
/* the extensions associated with <code>fType</code>'s super classes */
std::vector<TypeExtension::Pointer> fExtends;
bool fExtendsLoaded;
TypeExtension() : fExtendersLoaded(false), fExtendsLoaded(false) {
// special constructor to create the CONTINUE instance
}
protected:
friend class TypeExtensionManager;
/* a special property tester instance that is used to signal that method searching has to continue */
/* package */ class CONTINUE_ : public IPropertyTester {
public:
berryObjectMacro(CONTINUE_)
bool Handles(const std::string& /*namespaze*/, const std::string& /*method*/) {
return false;
}
bool IsInstantiated() {
return true;
}
bool IsDeclaringPluginActive() {
return true;
}
IPropertyTester* Instantiate() {
return this;
}
bool Test(Object::Pointer /*receiver*/, const std::string& /*method*/,
std::vector<Object::Pointer>& /*args*/, Object::Pointer /*expectedValue*/) {
return false;
}
};
static const CONTINUE_ CONTINUE;
static const END_POINT_ END_POINT;
/* package */
TypeExtension(const std::string& typeInfo);
/* package */
IPropertyTester::Pointer FindTypeExtender(TypeExtensionManager& manager,
const std::string& namespaze, const std::string& method,
bool staticMethod, bool forcePluginActivation);
};
/* a special type extension instance that marks the end of an evaluation chain */
class END_POINT_ : public TypeExtension
{
protected:
IPropertyTester::Pointer FindTypeExtender(TypeExtensionManager& /*manager*/,
const std::string& /*namespaze*/, const std::string& /*name*/,
bool /*staticMethod*/, bool /*forcePluginActivation*/)
{
return CONTINUE_::Pointer(new CONTINUE_());
}
};
} // namespace berry
#endif /*BERRYTYPEEXTENSION_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryTypeExtensionManager.cpp b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryTypeExtensionManager.cpp
index 662dc0ca8e..0ced85f3ca 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryTypeExtensionManager.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryTypeExtensionManager.cpp
@@ -1,164 +1,164 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryLog.h"
#include "berryTypeExtensionManager.h"
#include "berryExpressions.h"
#include "berryPropertyTesterDescriptor.h"
#include "berryPlatform.h"
#include "service/berryIExtensionPointService.h"
#include <ctime>
namespace berry {
const std::string TypeExtensionManager::TYPE= "type"; //$NON-NLS-1$
TypeExtensionManager::TypeExtensionManager(const std::string& extensionPoint)
: fExtensionPoint(extensionPoint)
{
//Platform.getExtensionRegistry().addRegistryChangeListener(this);
this->InitializeCaches();
}
Property::Pointer TypeExtensionManager::GetProperty(Object::Pointer receiver,
const std::string& namespaze, const std::string& method)
{
return GetProperty(receiver, namespaze, method, false);
}
/*synchronized*/Property::Pointer
TypeExtensionManager::GetProperty(
Object::Pointer receiver, const std::string& namespaze,
const std::string& method, bool forcePluginActivation)
{
std::clock_t start= 0;
if (Expressions::TRACING)
start = std::clock();
// if we call a static method than the receiver is the class object
//Class clazz= receiver instanceof Class ? (Class)receiver : receiver.getClass();
Property::Pointer result(new Property(receiver, namespaze, method));
Property::Pointer cached(fPropertyCache->Get(result));
if (!cached.isNull())
{
if (cached->IsValidCacheEntry(forcePluginActivation))
{
if (Expressions::TRACING)
{
BERRY_INFO << "[Type Extension] - method " <<
receiver->ToString() << "#" << method <<
" found in cache: " <<
(double(std::clock() - start))/(CLOCKS_PER_SEC/1000) << " ms.";
}
return cached;
}
// The type extender isn't loaded in the cached method but can be loaded
// now. So remove method from cache and do the normal look up so that the
// implementation class gets loaded.
fPropertyCache->Remove(cached);
}
TypeExtension::Pointer extension(this->Get(receiver->GetClassName()));
IPropertyTester::Pointer extender(extension->FindTypeExtender(*this, namespaze, method, false /*receiver instanceof Class*/, forcePluginActivation));
if (!extender.Cast<TypeExtension::CONTINUE_>().IsNull() || extender.IsNull())
{
std::string msg("Unknown method for ");
msg.append(receiver->GetClassName());
throw CoreException(msg, method);
}
result->SetPropertyTester(extender);
fPropertyCache->Put(result);
if (Expressions::TRACING)
{
BERRY_INFO << "[Type Extension] - method " <<
typeid(receiver).name() << "#" << method <<
" not found in cache: " <<
(double(std::clock() - start))/(CLOCKS_PER_SEC/1000) << " ms.";
}
return result;
}
/* package */TypeExtension::Pointer
TypeExtensionManager::Get(const std::string& type)
{
TypeExtension::Pointer result(fTypeExtensionMap[type]);
if (result.IsNull())
{
result = new TypeExtension(type);
fTypeExtensionMap[type] = result;
}
return result;
}
/* package */void TypeExtensionManager::LoadTesters(
std::vector<IPropertyTester::Pointer>& result, const std::string& typeName)
{
if (fConfigurationElementMap == 0)
{
fConfigurationElementMap = new std::map<std::string, std::vector<IConfigurationElement::Pointer> >();
IExtensionPointService::Pointer registry(Platform::GetExtensionPointService());
IConfigurationElement::vector ces(
registry->GetConfigurationElementsFor("org.blueberry.core.expressions." + fExtensionPoint));
for (unsigned int i= 0; i < ces.size(); i++)
{
IConfigurationElement::Pointer config(ces[i]);
std::string typeAttr;
config->GetAttribute(TYPE, typeAttr);
std::vector<IConfigurationElement::Pointer> typeConfigs = (*fConfigurationElementMap)[typeAttr];
typeConfigs.push_back(config);
}
}
//std::string typeName= type.getName();
std::vector<IConfigurationElement::Pointer> typeConfigs = (*fConfigurationElementMap)[typeName];
for (unsigned int i= 0; i < typeConfigs.size(); i++)
{
IConfigurationElement::Pointer config(typeConfigs[i]);
try
{
IPropertyTester::Pointer descr(new PropertyTesterDescriptor(config));
result.push_back(descr);
}
catch (CoreException e)
{
//TODO
//ExpressionPlugin.getDefault().getLog().log(e.getStatus());
IPropertyTester::Pointer nullTester(new NULL_PROPERTY_TESTER_());
result.push_back(nullTester);
}
}
fConfigurationElementMap->erase(typeName);
}
/*synchronized*/void TypeExtensionManager::InitializeCaches()
{
fPropertyCache = new PropertyCache(1000);
fConfigurationElementMap = 0;
}
TypeExtensionManager::~TypeExtensionManager()
{
if (fPropertyCache) delete fPropertyCache;
if (fConfigurationElementMap) delete fConfigurationElementMap;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryTypeExtensionManager.h b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryTypeExtensionManager.h
index bdbe5846a3..3f35839d3a 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryTypeExtensionManager.h
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryTypeExtensionManager.h
@@ -1,126 +1,126 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYTYPEEXTENSIONMANAGER_H_
#define BERRYTYPEEXTENSIONMANAGER_H_
#include "berryIPropertyTester.h"
#include "berryTypeExtension.h"
#include "berryPropertyCache.h"
#include "berryProperty.h"
#include <berryIConfigurationElement.h>
#include <string>
#include <typeinfo>
#include <map>
namespace berry {
class TypeExtensionManager { // implements IRegistryChangeListener {
private:
std::string fExtensionPoint;
static const std::string TYPE;
class NULL_PROPERTY_TESTER_ : public IPropertyTester
{
public:
bool Handles(const std::string& /*namespaze*/, const std::string& /*property*/)
{
return false;
}
bool IsInstantiated()
{
return true;
}
bool IsDeclaringPluginActive()
{
return true;
}
IPropertyTester* Instantiate()
{
return this;
}
bool Test(Object::Pointer, const std::string& /*property*/,
std::vector<Object::Pointer>& /*args*/, Object::Pointer /*expectedValue*/)
{
return false;
}
};
static const NULL_PROPERTY_TESTER_ NULL_PROPERTY_TESTER;
/*
* Map containing all already created type extension object.
*/
std::map<std::string, TypeExtension::Pointer> fTypeExtensionMap;
/*
* Table containing mapping of class name to configuration element
*/
std::map<std::string, std::vector<IConfigurationElement::Pointer> >* fConfigurationElementMap;
/*
* A cache to give fast access to the last 1000 method invocations.
*/
PropertyCache* fPropertyCache;
public:
TypeExtensionManager(const std::string& extensionPoint);
~TypeExtensionManager();
Property::Pointer GetProperty(Object::Pointer receiver,
const std::string& namespaze, const std::string& method);
/*synchronized*/Property::Pointer GetProperty(Object::Pointer receiver,
const std::string& namespaze, const std::string& method, bool forcePluginActivation);
protected:
friend class TypeExtension;
/*
* This method doesn't need to be synchronized since it is called
* from withing the getProperty method which is synchronized
*/
/* package */TypeExtension::Pointer Get(const std::string& type);
/*
* This method doesn't need to be synchronized since it is called
* from withing the getProperty method which is synchronized
*/
/* package */void LoadTesters(std::vector<IPropertyTester::Pointer>& result, const std::string& typeName);
// public void registryChanged(IRegistryChangeEvent event) {
// IExtensionDelta[] deltas= event.getExtensionDeltas(ExpressionPlugin.getPluginId(), fExtensionPoint);
// if (deltas.length > 0) {
// initializeCaches();
// }
// }
private:
/*synchronized*/void InitializeCaches();
};
}
#endif /*BERRYTYPEEXTENSIONMANAGER_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryWithExpression.cpp b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryWithExpression.cpp
index 19936ff8e7..84322d56f3 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryWithExpression.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryWithExpression.cpp
@@ -1,93 +1,93 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryWithExpression.h"
#include "berryExpressions.h"
#include "berryEvaluationContext.h"
#include <Poco/Hash.h>
namespace berry {
const std::string WithExpression::ATT_VARIABLE= "variable";
const std::size_t WithExpression::HASH_INITIAL= Poco::hash("berry::WithExpression");
WithExpression::WithExpression(IConfigurationElement::Pointer configElement)
{
bool result = configElement->GetAttribute(ATT_VARIABLE, fVariable);
Expressions::CheckAttribute(ATT_VARIABLE, result);
}
WithExpression::WithExpression(Poco::XML::Element* element)
{
fVariable = element->getAttribute(ATT_VARIABLE);
Expressions::CheckAttribute(ATT_VARIABLE, fVariable.length()> 0);
}
WithExpression::WithExpression(const std::string& variable)
: fVariable(variable)
{
}
bool
WithExpression::operator==(Expression& object)
{
try
{
WithExpression& that = dynamic_cast<WithExpression&>(object);
return this->fVariable == that.fVariable &&
this->Equals(this->fExpressions, that.fExpressions);
}
catch (std::bad_cast)
{
return false;
}
}
EvaluationResult
WithExpression::Evaluate(IEvaluationContext* context)
{
Object::Pointer variable(context->GetVariable(fVariable));
if (variable.IsNull())
{
throw CoreException("Variable not defined", fVariable);
}
return this->EvaluateAnd(new EvaluationContext(context, variable));
}
void
WithExpression::CollectExpressionInfo(ExpressionInfo* info)
{
ExpressionInfo* other = new ExpressionInfo();
CompositeExpression::CollectExpressionInfo(other);
if (other->HasDefaultVariableAccess())
{
info->AddVariableNameAccess(fVariable);
}
info->MergeExceptDefaultVariable(other);
}
std::size_t
WithExpression::ComputeHashCode()
{
return HASH_INITIAL * HASH_FACTOR + this->HashCode(fExpressions)
* HASH_FACTOR + Poco::hash(fVariable);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryWithExpression.h b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryWithExpression.h
index 60ae6f7481..6eae012368 100755
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryWithExpression.h
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryWithExpression.h
@@ -1,62 +1,62 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 __BERRY_WITH_EXPRESSION_H__
#define __BERRY_WITH_EXPRESSION_H__
#include "berryCompositeExpression.h"
#include "service/berryIConfigurationElement.h"
#include "Poco/DOM/Element.h"
namespace berry {
class WithExpression : public CompositeExpression {
private:
std::string fVariable;
static const std::string ATT_VARIABLE;
/**
* The seed for the hash code for all with expressions.
*/
static const std::size_t HASH_INITIAL;
public:
WithExpression(SmartPointer<IConfigurationElement> configElement);
WithExpression(Poco::XML::Element* element);
WithExpression(const std::string& variable);
bool operator==(Expression& object);
EvaluationResult Evaluate(IEvaluationContext* context);
void CollectExpressionInfo(ExpressionInfo* info);
protected:
std::size_t ComputeHashCode();
};
} // namespace berry
#endif // __BERRY_WITH_EXPRESSION_H__
diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryIJobChangeEvent.h b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryIJobChangeEvent.h
index cba2f4ab67..2cf4c3bd39 100644
--- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryIJobChangeEvent.h
+++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryIJobChangeEvent.h
@@ -1,74 +1,74 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIJOBCHANGEEVENT_H_
#define BERRYIJOBCHANGEEVENT_H_
#include <berryObject.h>
#include <berryMacros.h>
#include <berryIStatus.h>
#include <Poco/Timestamp.h>
#include <org_blueberry_core_jobs_Export.h>
namespace berry
{
class Job;
/**
* An event describing a change to the state of a job.
*
* @see IJobChangeListener
* @noimplement This interface is not intended to be implemented by clients.
*/
struct BERRY_JOBS IJobChangeEvent : public Object
{
berryInterfaceMacro(IJobChangeEvent, berry)
/**
* The amount of time in milliseconds to wait after scheduling the job before it
* should be run, or <code>-1</code> if not applicable for this type of event.
* This value is only applicable for the <code>scheduled</code> event.
*
* @return the delay time for this event
*/
virtual Poco::Timestamp::TimeDiff GetDelay() const = 0;
/**
* The job on which this event occurred.
*
* @return the job for this event
*/
virtual SmartPointer<Job> GetJob() const = 0;
/**
* The result returned by the job's run method, or <code>null</code> if
* not applicable. This value is only applicable for the <code>done</code> event.
*
* @return the status for this event
*/
virtual IStatus::Pointer GetResult() const = 0;
};
}
#endif /* BERRYIJOBCHANGEEVENT_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryIJobChangeListener.cpp b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryIJobChangeListener.cpp
index 6baf5dc8a9..e0747c36f2 100644
--- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryIJobChangeListener.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryIJobChangeListener.cpp
@@ -1,73 +1,73 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryIJobChangeListener.h"
namespace berry
{
void IJobChangeListener::Events::AddListener(
IJobChangeListener::Pointer listener)
{
if (!listener)
return;
Types types = listener->GetEventTypes();
if (types & ABOUT_TO_RUN)
jobAboutToRun += Delegate(listener.GetPointer(),
&IJobChangeListener::AboutToRun);
if (types & AWAKE)
jobAwake += Delegate(listener.GetPointer(), &IJobChangeListener::Awake);
if (types & DONE)
jobDone += Delegate(listener.GetPointer(), &IJobChangeListener::Done);
if (types & RUNNING)
jobRunning += Delegate(listener.GetPointer(), &IJobChangeListener::Running);
if (types & SCHEDULED)
jobScheduled += Delegate(listener.GetPointer(),
&IJobChangeListener::Scheduled);
if (types & SLEEPING)
jobSleeping += Delegate(listener.GetPointer(),
&IJobChangeListener::Sleeping);
}
void IJobChangeListener::Events::RemoveListener(
IJobChangeListener::Pointer listener)
{
if (!listener)
return;
jobAboutToRun -= Delegate(listener.GetPointer(),
&IJobChangeListener::AboutToRun);
jobAwake -= Delegate(listener.GetPointer(), &IJobChangeListener::Awake);
jobDone -= Delegate(listener.GetPointer(), &IJobChangeListener::Done);
jobRunning -= Delegate(listener.GetPointer(), &IJobChangeListener::Running);
jobScheduled -= Delegate(listener.GetPointer(),
&IJobChangeListener::Scheduled);
jobSleeping -= Delegate(listener.GetPointer(), &IJobChangeListener::Sleeping);
}
void IJobChangeListener::Events::SetExceptionHandler(const AbstractExceptionHandler& handler)
{
jobAboutToRun.SetExceptionHandler(handler);
jobAwake.SetExceptionHandler(handler);
jobDone.SetExceptionHandler(handler);
jobRunning.SetExceptionHandler(handler);
jobScheduled.SetExceptionHandler(handler);
jobSleeping.SetExceptionHandler(handler);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryIJobChangeListener.h b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryIJobChangeListener.h
index ecf68aa1a6..7897b09d1f 100644
--- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryIJobChangeListener.h
+++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryIJobChangeListener.h
@@ -1,165 +1,165 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIJOBCHANGELISTENER_H_
#define BERRYIJOBCHANGELISTENER_H_
#include "berryIJobChangeEvent.h"
namespace berry
{
/**
* Callback interface for clients interested in being notified when jobs change state.
* <p>
* A single job listener instance can be added either to the job manager, for notification
* of all scheduled jobs, or to any set of individual jobs. A single listener instance should
* not be added to both the job manager, and to individual jobs (such a listener may
* receive duplicate notifications).
* </p><p>
* Clients should not rely on the result of the <code>Job#GetState()</code>
* method on jobs for which notification is occurring. Listeners are notified of
* all job state changes, but whether the state change occurs before, during, or
* after listeners are notified is unspecified.
* </p><p>
* Clients may implement this interface.
* </p>
* @see IJobManager#AddJobChangeListener(IJobChangeListener::Pointer)
* @see IJobManager#RemoveJobChangeListener(IJobChangeListener::Pointer)
* @see Job#AddJobChangeListener(IJobChangeListener::Pointer)
* @see Job#GetState()
* @see Job#RemoveJobChangeListener(IJobChangeListener::Pointer)
*/
struct BERRY_JOBS IJobChangeListener: public Object
{
berryInterfaceMacro(IJobChangeListener, berry)
struct BERRY_JOBS Events
{
typedef Message1<const IJobChangeEvent::ConstPointer> JobChangeEventType;
enum Type
{
NONE = 0x00000000,
ABOUT_TO_RUN = 0x00000001,
AWAKE = 0x00000002,
DONE = 0x00000004,
RUNNING = 0x00000008,
SCHEDULED = 0x00000010,
SLEEPING = 0x00000020,
ALL = 0xffffffff
};
BERRY_DECLARE_FLAGS(Types, Type)
JobChangeEventType jobAboutToRun;
JobChangeEventType jobAwake;
JobChangeEventType jobDone;
JobChangeEventType jobRunning;
JobChangeEventType jobScheduled;
JobChangeEventType jobSleeping;
void AddListener(IJobChangeListener::Pointer listener);
void RemoveListener(IJobChangeListener::Pointer listener);
void SetExceptionHandler(const AbstractExceptionHandler& handler);
typedef MessageDelegate1<IJobChangeListener, const IJobChangeEvent::ConstPointer>
Delegate;
};
virtual Events::Types GetEventTypes() = 0;
/**
* Notification that a job is about to be run. Listeners are allowed to sleep, cancel,
* or change the priority of the job before it is started (and as a result may prevent
* the run from actually occurring).
*
* @param event the event details
*/
virtual void AboutToRun(const IJobChangeEvent::ConstPointer /*event*/)
{
}
;
/**
* Notification that a job was previously sleeping and has now been rescheduled
* to run.
*
* @param event the event details
*/
virtual void Awake(const IJobChangeEvent::ConstPointer /*event*/)
{
}
;
/**
* Notification that a job has completed execution, either due to cancelation, successful
* completion, or failure. The event status object indicates how the job finished,
* and the reason for failure, if applicable.
*
* @param event the event details
*/
virtual void Done(const IJobChangeEvent::ConstPointer /*event*/)
{
}
;
/**
* Notification that a job has started running.
*
* @param event the event details
*/
virtual void Running(const IJobChangeEvent::ConstPointer /*event*/)
{
}
;
/**
* Notification that a job is being added to the queue of scheduled jobs.
* The event details includes the scheduling delay before the job should start
* running.
*
* @param event the event details, including the job instance and the scheduling
* delay
*/
virtual void Scheduled(const IJobChangeEvent::ConstPointer /*event*/)
{
}
;
/**
* Notification that a job was waiting to run and has now been put in the
* sleeping state.
*
* @param event the event details
*/
virtual void Sleeping(const IJobChangeEvent::ConstPointer /*event*/)
{
}
;
};
}
BERRY_DECLARE_OPERATORS_FOR_FLAGS(berry::IJobChangeListener::Events::Types)
#endif /* BERRYIJOBCHANGELISTENER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryIJobManager.cpp b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryIJobManager.cpp
index 131025b35c..604003a433 100644
--- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryIJobManager.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryIJobManager.cpp
@@ -1,25 +1,25 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryIJobManager.h"
namespace berry
{
const std::string IJobManager::PROP_USE_DAEMON_THREADS = "blueberry.jobs.daemon";
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryIJobManager.h b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryIJobManager.h
index c5098136c7..08379f1eaf 100644
--- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryIJobManager.h
+++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryIJobManager.h
@@ -1,440 +1,440 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 _BERRY_IJOBMANAGER_H
#define _BERRY_IJOBMANAGER_H
#include<string>
#include <org_blueberry_core_jobs_Export.h>
#include "berryJob.h"
#include "berryProgressProvider.h"
#include "berryIProgressMonitor.h"
#include "berryIJobChangeListener.h"
#include<Poco/Thread.h>
namespace berry
{
/**
* The job manager provides facilities for scheduling, querying, and maintaining jobs
* and locks. In particular, the job manager provides the following services:
* <ul>
* <li>Maintains a queue of jobs that are waiting to be run. Items can be added to
* the queue using the <code>schedule</code> method.</li>
* <li> @todo Allows manipulation of groups of jobs called job families. } Job families can
* be canceled, put to sleep, or woken up atomically. There is also a mechanism
* for querying the set of known jobs in a given family.> </li>
*
* <li>Allows listeners to find out about progress on running jobs, and to find out
* when jobs have changed states.</li>
* <li> @todo Provides a factory for creating lock objects. Lock objects are smart monitors
* that have strategies for avoiding deadlock. ></li>
*
* <li>Provide feedback to a client that is waiting for a given job or family of jobs
* to complete.</li>
* </ul>
*
* @see Job
* @see ILock
*
* @noimplement This interface is not intended to be implemented by clients.
*/
struct BERRY_JOBS IJobManager: public Object
{
berryInterfaceMacro(IJobManager, berry)
/**
* A system property key indicating whether the job manager should create
* job threads as daemon threads. Set to <code>true</code> to force all worker
* threads to be created as daemon threads. Set to <code>false</code> to force
* all worker threads to be created as non-daemon threads.
*
* not used yet
*/
static const std::string PROP_USE_DAEMON_THREADS ;
/**
* Registers a job listener with the job manager.
* Has no effect if an identical listener is already registered.
*
* @param listener the listener to be added
* @see #removeJobChangeListener(IJobChangeListener)
* @see IJobChangeListener
*/
virtual void AddJobChangeListener(IJobChangeListener::Pointer listener) = 0;
///**
// * Begins applying this rule in the calling thread. If the rule conflicts with another
// * rule currently running in another thread, this method blocks until there are
// * no conflicting rules. Calls to <tt>beginRule</tt> must eventually be followed
// * by a matching call to <tt>endRule</tt> in the same thread and with the identical
// * rule instance.
// * <p>
// * Rules can be nested only if the rule for the inner <tt>beginRule</tt>
// * is contained within the rule for the outer <tt>beginRule</tt>. Rule containment
// * is tested with the API method <tt>ISchedulingRule.contains</tt>. Also, begin/end
// * pairs must be strictly nested. Only the rule that has most recently begun
// * can be ended at any given time.
// * <p>
// * A rule of <code>null</code> can be used, but will be ignored for scheduling
// * purposes. The outermost non-null rule in the thread will be used for scheduling. A
// * <code>null</code> rule that is begun must still be ended.
// * <p>
// * If this method is called from within a job that has a scheduling rule, the
// * given rule must also be contained within the rule for the running job.
// * <p>
// * Note that <tt>endRule</tt> must be called even if <tt>beginRule</tt> fails.
// * The recommended usage is:
// * <pre>
// * final ISchedulingRule rule = ...;
// * try {
// * manager.beginRule(rule, monitor);
// * } finally {
// * manager.endRule(rule);
// * }
// * </pre>
// *
// * @param rule the rule to begin applying in this thread, or <code>null</code>
// * @param monitor a progress monitor, or <code>null</code> if progress
// * reporting and cancellation are not desired
// * @throws IllegalArgumentException if the rule is not strictly nested within
// * all other rules currently active for this thread
// * @throws OperationCanceledException if the supplied monitor reports cancelation
// * before the rule becomes available
// * @see ISchedulingRule#contains(ISchedulingRule)
// */
/// virtual void BeginRule(const ISchedulingRule& rule, const IProgressMonitor& monitor) = 0;
///**
// * Cancels all jobs in the given job family. Jobs in the family that are currently waiting
// * will be removed from the queue. Sleeping jobs will be discarded without having
// * a chance to wake up. Currently executing jobs will be asked to cancel but there
// * is no guarantee that they will do so.
// *
// * @param family the job family to cancel, or <code>null</code> to cancel all jobs
// * @see Job#belongsTo(Object)
// */
/// virtual void Cancel(const Object& family);
/**
* Returns a progress monitor that can be used to provide
* aggregated progress feedback on a set of running jobs. A user
* interface will typically group all jobs in a progress group together,
* providing progress feedback for individual jobs as well as aggregated
* progress for the entire group. Jobs in the group may be run sequentially,
* in parallel, or some combination of the two.
* <p>
* Recommended usage (this snippet runs two jobs in sequence in a
* single progress group):
* <pre>
* Job parseJob, compileJob;
* IProgressMonitor pm = Platform.getJobManager().createProgressGroup();
* try {
* pm.beginTask("Building", 10);
* parseJob.setProgressGroup(pm, 5);
* parseJob.schedule();
* compileJob.setProgressGroup(pm, 5);
* compileJob.schedule();
* parseJob.join();
* compileJob.join();
* } finally {
* pm.done();
* }
* </pre>
*
* @see Job#setProgressGroup(IProgressMonitor, int)
* @see IProgressMonitor
* @return a progress monitor
*/
virtual IProgressMonitor::Pointer CreateProgressGroup() = 0;
///**
// * Returns the job that is currently running in this thread, or <code>null</code> if there
// * is no currently running job.
// *
// * @return the job or <code>null</code>
// */
//// virtual Job CurrentJob() = 0;
///**
// * Ends the application of a rule to the calling thread. Calls to <tt>endRule</tt>
// * must be preceded by a matching call to <tt>beginRule</tt> in the same thread
// * with an identical rule instance.
// * <p>
// * Rules can be nested only if the rule for the inner <tt>beginRule</tt>
// * is contained within the rule for the outer <tt>beginRule</tt>. Also, begin/end
// * pairs must be strictly nested. Only the rule that has most recently begun
// * can be ended at any given time.
// *
// * @param rule the rule to end applying in this thread
// * @throws IllegalArgumentException if this method is called on a rule for which
// * there is no matching begin, or that does not match the most recent begin.
// * @see ISchedulingRule#contains(ISchedulingRule)
// */
/// virtual void EndRule(const ISchedulingRule& rule) = 0;
///**
// * Returns all waiting, executing and sleeping jobs belonging
// * to the given family. If no jobs are found, an empty array is returned.
// *
// * @param family the job family to find, or <code>null</code> to find all jobs
// * @return the job array
// * @see Job#belongsTo(Object)
// */
/// virtual Job[] Find(const Object& family) = 0;
/**
* Returns whether the job manager is currently idle. The job manager is
* idle if no jobs are currently running or waiting to run.
*
* @return <code>true</code> if the job manager is idle, and
* <code>false</code> otherwise
* @since 3.1
*/
virtual bool IsIdle()= 0;
/**
* Returns whether the job manager is currently suspended.
*
* @return <code>true</code> if the job manager is suspended, and
* <code>false</code> otherwise
* @since 3.4
* @see #suspend()
* @see #resume()
*/
virtual bool IsSuspended() = 0;
///**
// * Waits until all jobs of the given family are finished. This method will block the
// * calling thread until all such jobs have finished executing, or until this thread is
// * interrupted. If there are no jobs in
// * the family that are currently waiting, running, or sleeping, this method returns
// * immediately. Feedback on how the join is progressing is provided to a progress
// * monitor.
// * <p>
// * If this method is called while the job manager is suspended, only jobs
// * that are currently running will be joined; Once there are no jobs
// * in the family in the {@link Job#RUNNING} state, this method returns.
// * </p>
// * <p>
// * Note that there is a deadlock risk when using join. If the calling thread owns
// * a lock or object monitor that the joined thread is waiting for, deadlock
// * will occur. This method can also result in starvation of the current thread if
// * another thread continues to add jobs of the given family, or if a
// * job in the given family reschedules itself in an infinite loop.
// * </p>
// *
// * @param family the job family to join, or <code>null</code> to join all jobs.
// * @param monitor Progress monitor for reporting progress on how the
// * wait is progressing, or <code>null</code> if no progress monitoring is required.
// * @exception InterruptedException if this thread is interrupted while waiting
// * @exception OperationCanceledException if the progress monitor is canceled while waiting
// * @see Job#belongsTo(Object)
// * @see #suspend()
// */
/// virtual void Join(const Object& family, const IProgressMonitor& monitor)
/// throw(InterruptedException, OperationCanceledException) = 0;
///**
// * Creates a new lock object. All lock objects supplied by the job manager
// * know about each other and will always avoid circular deadlock amongst
// * themselves.
// *
// * @return the new lock object
// */
/// virtual ILock newLock() = 0;
/**
* Removes a job listener from the job manager.
* Has no effect if an identical listener is not already registered.
*
* @param listener the listener to be removed
* @see #addJobChangeListener(IJobChangeListener)
* @see IJobChangeListener
*/
virtual void RemoveJobChangeListener(IJobChangeListener::Pointer listener) = 0;
///**
// * Resumes execution of jobs after a previous <code>suspend</code>. All
// * jobs that were sleeping or waiting prior to the suspension, or that were
// * scheduled while the job manager was suspended, will now be eligible
// * for execution.
// * <p>
// * Calling this method on a rule that is not suspended has no effect. If another
// * thread also owns the rule at the time this method is called, then the rule will
// * not be resumed until all threads have released the rule.
// *
// * @deprecated This method is not safe and should not be used.
// * Suspending a scheduling rule violates the thread safety
// * of clients that use scheduling rules as a mutual exclusion mechanism,
// * and can result in concurrency problems in all clients that use the suspended rule.
// * @see #suspend(ISchedulingRule, IProgressMonitor)
// */
/// virtual void Resume(const ISchedulingRule& rule) = 0;
///**
// * Resumes execution of jobs after a previous <code>suspend</code>. All
// * jobs that were sleeping or waiting prior to the suspension, or that were
// * scheduled while the job manager was suspended, will now be eligible
// * for execution.
// * <p>
// * Calling <code>resume</code> when the job manager is not suspended
// * has no effect.
// *
// * @see #suspend()
// * @see #isSuspended()
// */
////virtual void Resume() = 0;
///**
// * Provides a hook that is notified whenever a thread is about to wait on a lock,
// * or when a thread is about to release a lock. This hook must only be set once.
// * <p>
// * This method is for internal use by the platform-related plug-ins.
// * Clients should not call this method.
// * </p>
// * @see LockListener
// */
// TODO LockListener .. SetLockListener
/// virtual void SetLockListener(const LockListener& listener) = 0;
/**
* Registers a progress provider with the job manager. If there was a
* provider already registered, it is replaced.
* <p>
* This method is intended for use by the currently executing Eclipse application.
* Plug-ins outside the currently running application should not call this method.
* </p>
*
* @param provider the new provider, or <code>null</code> if no progress
* is needed
*/
virtual void SetProgressProvider(ProgressProvider::Pointer) = 0;
/**
* Suspends execution of all jobs. Jobs that are already running
* when this method is invoked will complete as usual, but all sleeping and
* waiting jobs will not be executed until the job manager is resumed.
* <p>
* The job manager will remain suspended until a subsequent call to
* <code>resume</code>. Further calls to <code>suspend</code>
* when the job manager is already suspended are ignored.
* <p>
* All attempts to join sleeping and waiting jobs while the job manager is
* suspended will return immediately.
* <p>
* Note that this very powerful function should be used with extreme caution.
* Suspending the job manager will prevent all jobs in the system from executing,
* which may have adverse affects on components that are relying on
* execution of jobs. The job manager should never be suspended without intent
* to resume execution soon afterwards.
*
* @see #resume()
* @see #join(Object, IProgressMonitor)
* @see #isSuspended()
*/
// virtual void Suspend() = 0;
///**
// * Defers execution of all jobs with scheduling rules that conflict with the
// * given rule. The caller will be blocked until all currently executing jobs with
// * conflicting rules are completed. Conflicting jobs that are sleeping or waiting at
// * the time this method is called will not be executed until the rule is resumed.
// * <p>
// * While a rule is suspended, all calls to <code>beginRule</code> and
// * <code>endRule</code> on a suspended rule will not block the caller.
// * The rule remains suspended until a subsequent call to
// * <code>resume(ISchedulingRule)</code> with the identical rule instance.
// * Further calls to <code>suspend</code> with an identical rule prior to calling
// * <code>resume</code> are ignored.
// * </p>
// * <p>
// * This method is long-running; progress and cancelation are provided by
// * the given progress monitor. In the case of cancelation, the rule will
// * not be suspended.
// * </p>
// * Note: this very powerful function should be used with extreme caution.
// * Suspending rules will prevent jobs in the system from executing, which may
// * have adverse effects on components that are relying on execution of jobs.
// * The job manager should never be suspended without intent to resume
// * execution soon afterwards. Deadlock will result if the thread responsible
// * for resuming the rule attempts to join a suspended job.
// *
// * @deprecated This method is not safe and should not be used.
// * Suspending a scheduling rule violates the thread safety
// * of clients that use scheduling rules as a mutual exclusion mechanism,
// * and can result in concurrency problems in all clients that use the suspended rule.
// * @param rule The scheduling rule to suspend. Must not be <code>null</code>.
// * @param monitor a progress monitor, or <code>null</code> if progress
// * reporting is not desired
// * @exception OperationCanceledException if the operation is canceled.
// * Cancelation can occur even if no progress monitor is provided.
// * @see #resume(ISchedulingRule)
// */
/// virtual void Suspend(const ISchedulingRule& rule, const IProgressMonitor& monitor) = 0;
///**
// * Requests that all jobs in the given job family be suspended. Jobs currently
// * waiting to be run will be removed from the queue and moved into the
// * <code>SLEEPING</code> state. Jobs that have been put to sleep
// * will remain in that state until either resumed or canceled. This method has
// * no effect on jobs that are not currently waiting to be run.
// * <p>
// * Sleeping jobs can be resumed using <code>wakeUp</code>.
// *
// * @param family the job family to sleep, or <code>null</code> to sleep all jobs.
// * @see Job#belongsTo(Object)
// */
/// virtual void Sleep(const Object& family) = 0;
///**
// * Transfers ownership of a scheduling rule to another thread. The identical
// * scheduling rule must currently be owned by the calling thread as a result of
// * a previous call to <code>beginRule</code>. The destination thread must
// * not already own a scheduling rule.
// * <p>
// * Calling this method is equivalent to atomically calling <code>endRule</code>
// * in the calling thread followed by an immediate <code>beginRule</code> in
// * the destination thread. The destination thread is responsible for subsequently
// * calling <code>endRule</code> when it is finished using the rule.
// * <p>
// * This method has no effect when the destination thread is the same as the
// * calling thread.
// *
// * @param rule The scheduling rule to transfer
// * @param destinationThread The new owner for the transferred rule.
// * @since 3.1
// */
/// virtual void TransferRule(const ISchedulingRule& rule, Poco::Thread* destinationThread) = 0;
///**
// * Resumes scheduling of all sleeping jobs in the given family. This method
// * has no effect on jobs in the family that are not currently sleeping.
// *
// * @param family the job family to wake up, or <code>null</code> to wake up all jobs
// * @see Job#belongsTo(Object)
// */
/// virtual void WakeUp(const Object& family) = 0;
};
}
#endif /* IJOBMANAGER */
diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryILock.h b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryILock.h
index dbd3f2b92a..dde6c8b970 100644
--- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryILock.h
+++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryILock.h
@@ -1,125 +1,125 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 _BERRY_ILOCK_H_
#define _BERRY_ILOCK_H_
#include <berryObject.h>
#include <berryMacros.h>
#include "berryJobExceptions.h"
namespace berry
{
/**
* A lock is used to control access to an exclusive resource.
* <p>
* Locks are reentrant. That is, they can be acquired multiple times by the same thread
* without releasing. Locks are only released when the number of successful acquires
* equals the number of successful releases.
* </p><p>
* Locks are capable of detecting and recovering from programming errors that cause
* circular waiting deadlocks. When a deadlock between two or more <tt>ILock</tt>
* instances is detected, detailed debugging information is printed to the log file. The
* locks will then automatically recover from the deadlock by employing a release
* and wait strategy. One thread will lose control of the locks it owns, thus breaking
* the deadlock and allowing other threads to proceed. Once that thread's locks are
* all available, it will be given exclusive access to all its locks and allowed to proceed.
* A thread can only lose locks while it is waiting on an <tt>acquire()</tt> call.
*
* </p><p>
* Successive acquire attempts by different threads are queued and serviced on
* a first come, first served basis.
* </p><p>
* It is very important that acquired locks eventually get released. Calls to release
* should be done in a finally block to ensure they execute. For example:
* <pre>
* try {
* lock.acquire();
* // ... do work here ...
* } finally {
* lock.release();
* }
* </pre>
* Note: although <tt>lock.acquire</tt> should never fail, it is good practice to place
* it inside the try block anyway. Releasing without acquiring is far less catastrophic
* than acquiring without releasing.
* </p>
*
* @see IJobManager#NewLock()
* @noimplement This interface is not intended to be implemented by clients.
*/
struct BERRY_JOBS ILock: public Object
{
berryInterfaceMacro(ILock, berry)
/**
* Attempts to acquire this lock. If the lock is in use and the specified delay is
* greater than zero, the calling thread will block until one of the following happens:
* <ul>
* <li>This lock is available</li>
* <li>The thread is interrupted</li>
* <li>The specified delay has elapsed</li>
* </ul>
* <p>
* While a thread is waiting, locks it already owns may be granted to other threads
* if necessary to break a deadlock. In this situation, the calling thread may be blocked
* for longer than the specified delay. On returning from this call, the calling thread
* will once again have exclusive access to any other locks it owned upon entering
* the acquire method.
*
* @param delay the number of milliseconds to delay
* @return <code>true</code> if the lock was successfully acquired, and
* <code>false</code> otherwise.
* @exception InterruptedException if the thread was interrupted
*/
virtual bool Acquire(long delay) throw (InterruptedException) = 0;
/**
* Acquires this lock. If the lock is in use, the calling thread will block until the lock
* becomes available. If the calling thread owns several locks, it will be blocked
* until all threads it requires become available, or until the thread is interrupted.
* While a thread is waiting, its locks may be granted to other threads if necessary
* to break a deadlock. On returning from this call, the calling thread will
* have exclusive access to this lock, and any other locks it owned upon
* entering the acquire method.
* <p>
* This implementation ignores attempts to interrupt the thread. If response to
* interruption is needed, use the method <code>acquire(long)</code>
*/
virtual void Acquire();
/**
* Returns the number of nested acquires on this lock that have not been released.
* This is the number of times that release() must be called before the lock is
* freed.
*
* @return the number of nested acquires that have not been released
*/
virtual int GetDepth() = 0;
/**
* Releases this lock. Locks must only be released by the thread that currently
* owns the lock.
*/
virtual void Release() = 0;
};
}
#endif // BERRY_ILOCK_H
diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryIProgressMonitor.h b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryIProgressMonitor.h
index 6c6f9428df..7a414819e4 100644
--- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryIProgressMonitor.h
+++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryIProgressMonitor.h
@@ -1,117 +1,117 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRY_IPROGRESS_MONITOR_H
#define BERRY_IPROGRESS_MONITOR_H
#include <org_blueberry_core_jobs_Export.h>
#include "berryObject.h"
#include <string>
namespace berry
{
struct IProgressMonitor: public Object
{
berryInterfaceMacro(IProgressMonitor, berry)
/** Constant indicating an unknown amount of work. */
static const int UNKNOWN = -1;
/**
* Notifies that the main task is beginning. This must only be called once
* on a given progress monitor instance.
*
* @param name the name (or description) of the main task
* @param totalWork the total number of work units into which
* the main task is been subdivided. If the value is <code>UNKNOWN</code>
* the implementation is free to indicate progress in a way which
* doesn't require the total number of work units in advance.
*/
virtual void BeginTask(const std::string& name, int totalWork) = 0;
/**
* Notifies that the work is done; that is, either the main task is completed
* or the user canceled it. This method may be called more than once
* (implementations should be prepared to handle this case).
*/
virtual void Done() = 0;
/**
* Internal method to handle scaling correctly. This method
* must not be called by a client. Clients should
* always use the method </code>worked(int)</code>.
*
* @param work the amount of work done
*/
virtual void InternalWorked(double work) = 0;
/**
* Returns whether cancellation of current operation has been requested.
* Long-running operations should poll to see if cancellation
* has been requested.
*
* @return <code>true</code> if cancellation has been requested,
* and <code>false</code> otherwise
* @see #setCanceled(bool)
*/
virtual bool IsCanceled() = 0;
/**
* Sets the cancel state to the given value.
*
* @param value <code>true</code> indicates that cancellation has
* been requested (but not necessarily acknowledged);
* <code>false</code> clears this flag
* @see #isCanceled()
*/
virtual void SetCanceled(bool value) = 0;
/**
* Sets the task name to the given value. This method is used to
* restore the task label after a nested operation was executed.
* Normally there is no need for clients to call this method.
*
* @param name the name (or description) of the main task
* @see #beginTask
*/
virtual void SetTaskName(const std::string& name) = 0;
/**
* Notifies that a subtask of the main task is beginning.
* Subtasks are optional; the main task might not have subtasks.
*
* @param name the name (or description) of the subtask
*/
virtual void SubTask(const std::string& name) = 0;
/**
* Notifies that a given number of work unit of the main task
* has been completed. Note that this amount represents an
* installment, as opposed to a cumulative amount of work done
* to date.
*
* @param work a non-negative number of work units just completed
*/
virtual void Worked(int work) = 0;
};
}
#endif /* _BERRY_IPROGRESS_MONITOR_H */
diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryIProgressMonitorWithBlocking.h b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryIProgressMonitorWithBlocking.h
index 700c9c2a45..d61692f925 100644
--- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryIProgressMonitorWithBlocking.h
+++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryIProgressMonitorWithBlocking.h
@@ -1,84 +1,84 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 _BERRY_IPROGRESSMONITORWITHBLOCKING_H
#define _BERRY_IPROGRESSMONITORWITHBLOCKING_H
#include "berryObject.h"
#include <org_blueberry_core_jobs_Export.h>
#include "berryIStatus.h"
#include "berryIProgressMonitor.h"
namespace berry
{
/**
* An extension to the IProgressMonitor interface for monitors that want to
* support feedback when an activity is blocked due to concurrent activity in
* another thread.
* <p>
* When a monitor that supports this extension is passed to an operation, the
* operation should call <code>setBlocked</code> whenever it knows that it
* must wait for a lock that is currently held by another thread. The operation
* should continue to check for and respond to cancellation requests while
* blocked. When the operation is no longer blocked, it must call <code>clearBlocked</code>
* to clear the blocked state.
* <p>
* This interface can be used without OSGi running.
* </p><p>
* Clients may implement this interface.
* </p>
* @see IProgressMonitor
*/
struct BERRY_JOBS IProgressMonitorWithBlocking: public IProgressMonitor
{
berryInterfaceMacro(IProgressMonitorWithBlocking, berry)
/**
* Indicates that this operation is blocked by some background activity. If
* a running operation ever calls <code>setBlocked</code>, it must
* eventually call <code>clearBlocked</code> before the operation
* completes.
* <p>
* If the caller is blocked by a currently executing job, this method will return
* an <code>IJobStatus</code> indicating the job that is currently blocking
* the caller. If this blocking job is not known, this method will return a plain
* informational <code>IStatus</code> object.
* </p>
*
* @param reason an optional status object whose message describes the
* reason why this operation is blocked, or <code>null</code> if this
* information is not available.
* @see #clearBlocked()
*/
virtual void SetBlocked(IStatus::Pointer reason)= 0;
/**
* Clears the blocked state of the running operation. If a running
* operation ever calls <code>setBlocked</code>, it must eventually call
* <code>clearBlocked</code> before the operation completes.
*
* @see #setBlocked(IStatus)
*/
virtual void ClearBlocked() = 0;
};
}
#endif /* _BERRY_IPROGRESSMONITORWITHBLOCKING_H */
diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryISchedulingRule.h b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryISchedulingRule.h
index 7ed513102d..4538feea2e 100644
--- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryISchedulingRule.h
+++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryISchedulingRule.h
@@ -1,93 +1,93 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 _BERRY_ISCHEDULING_RULE_H_
#define _BERRY_ISCHEDULING_RULE_H_
#include <org_blueberry_core_jobs_Export.h>
#include <berryObject.h>
namespace berry
{
/**
* Scheduling rules are used by jobs to indicate when they need exclusive access
* to a resource.
* @todo
* Scheduling rules can also be applied synchronously to a thread
* using <tt>IJobManager.beginRule(ISchedulingRule)</tt> and
* <tt>IJobManager.endRule(ISchedulingRule)</tt>.
*
* The job manager guarantees that
* no two jobs with conflicting scheduling rules will run concurrently.
* @todo
* Multiple rules can be applied to a given thread only if the outer rule explicitly
* allows the nesting as specified by the <code>contains</code> method.
*
* <p>
* Clients may implement this interface.
*
* @see Job#GetRule()
* @see Job#SetRule(ISchedulingRule)
* @see Job#Schedule(long)
* @see IJobManager#BeginRule(ISchedulingRule, org.eclipse.core.runtime.IProgressMonitor)
* @see IJobManager#EndRule(ISchedulingRule)
*/
struct BERRY_JOBS ISchedulingRule: public Object
{
berryInterfaceMacro(ISchedulingRule, berry)
/**
* Returns whether this scheduling rule completely contains another scheduling
* rule. Rules can only be nested within a thread if the inner rule is completely
* contained within the outer rule.
* <p>
* Implementations of this method must obey the rules of a partial order relation
* on the set of all scheduling rules. In particular, implementations must be reflexive
* (a.contains(a) is always true), antisymmetric (a.contains(b) and b.contains(a) iff
* equals(b),
* and transitive (if a.contains(b) and b.contains(c), then a.contains(c)). Implementations
* of this method must return <code>false</code> when compared to a rule they
* know nothing about.
*
* @param rule the rule to check for containment
* @return <code>true</code> if this rule contains the given rule, and
* <code>false</code> otherwise.
*/
virtual bool Contains(ISchedulingRule::Pointer rule) const = 0;
/**
* Returns whether this scheduling rule is compatible with another scheduling rule.
* If <code>true</code> is returned, then no job with this rule will be run at the
* same time as a job with the conflicting rule. If <code>false</code> is returned,
* then the job manager is free to run jobs with these rules at the same time.
* <p>
* Implementations of this method must be reflexive, symmetric, and consistent,
* and must return <code>false</code> when compared to a rule they know
* nothing about.
*
* @param rule the rule to check for conflicts
* @return <code>true</code> if the rule is conflicting, and <code>false</code>
* otherwise.
*/
virtual bool IsConflicting(ISchedulingRule::Pointer myRule) const = 0;
};
}
#endif // _BERRY_ISCHEDULING_RULE_H_
diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryJob.cpp b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryJob.cpp
index ef58803512..32b035d786 100644
--- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryJob.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryJob.cpp
@@ -1,205 +1,205 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryJob.h"
#include "berryIJobManager.h"
#include "internal/berryJobManager.h"
#include "berryIStatus.h"
#include "berryStatus.h"
#include <string>
namespace berry
{
const IStatus::Pointer Job::ASYNC_FINISH(new Status ( IStatus::OK_TYPE, JobManager::PI_JOBS(), 1, "") ) ;
Job::Job(std::string name) :
InternalJob(name)
{
}
const IJobManager* Job::GetJobManager()
{
return ptr_manager;
}
bool Job::BelongsTo(Object::Pointer /*family*/)
{
return false;
}
bool Job::Cancel()
{
return InternalJob::Cancel();
}
void Job::Done(IStatus::Pointer result)
{
InternalJob::Done(result);
}
std::string Job::GetName() const
{
return InternalJob::GetName();
}
int Job::GetPriority() const
{
return InternalJob::GetPriority();
}
// TODO QualifiedName muss noch implementiert werden
// Object Job::GetProperty(QualifiedName key)
// {
// return InternalJob::GetProperty(key);
// }
IStatus::Pointer Job::GetResult() const
{
return InternalJob::GetResult();
}
ISchedulingRule::Pointer Job::GetRule() const
{
return InternalJob::GetRule();
}
int Job::GetState() const
{
return InternalJob::GetState();
}
Poco::Thread*
Job::GetThread() const
{
return InternalJob::GetThread();
}
bool Job::IsBlocking()
{
return InternalJob::IsBlocking();
}
bool Job::IsSystem() const
{
return InternalJob::IsSystem();
}
bool Job::IsUser() const
{
return InternalJob::IsUser();
}
// TODO Join
//void Job::Join()
// throw (InterruptedException)
// {
// InternalJob::Join();
// }
void Job::RemoveJobChangeListener(IJobChangeListener::Pointer listener)
{
InternalJob::RemoveJobChangeListener(listener);
}
void Job::Schedule()
{
Poco::Timestamp::TimeDiff tmpNoDelay = 0;
InternalJob::Schedule(tmpNoDelay);
}
void Job::Schedule(Poco::Timestamp::TimeDiff delay)
{
InternalJob::Schedule(delay);
}
void Job::SetName(std::string name)
{
InternalJob::SetName(name);
}
void Job::SetPriority(int priority)
{
InternalJob::SetPriority(priority);
}
void Job::SetProgressGroup(IProgressMonitor::Pointer group, int ticks)
{
InternalJob::SetProgressGroup(group, ticks);
}
// TODO SetProperty
// void Job::SetProperty(QualifiedName key, Object value)
// {
// InternalJob::SetProperty(key, value);
// }
void Job::SetRule(ISchedulingRule::Pointer rule)
{
InternalJob::SetRule(rule);
}
void Job::SetSystem(bool value)
{
InternalJob::SetSystem(value);
}
void Job::SetUser(bool value)
{
InternalJob::SetUser(value);
}
void Job::SetThread(Poco::Thread* thread)
{
InternalJob::SetThread(thread);
}
bool Job::ShouldRun()
{
return true;
}
bool Job::ShouldSchedule()
{
return true;
}
bool Job::Sleep()
{
return InternalJob::Sleep();
}
void Job::WakeUp()
{
InternalJob::WakeUp(0);
}
void Job::WakeUp(long delay)
{
InternalJob::WakeUp(delay);
}
void Job::Canceling()
{
//default implementation does nothing
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryJob.h b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryJob.h
index da3c2e1c65..0da4f530bc 100644
--- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryJob.h
+++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryJob.h
@@ -1,639 +1,639 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 _BERRY_JOB_H
#define _BERRY_JOB_H
#include <Poco/Thread.h>
#include <org_blueberry_core_jobs_Export.h>
// #include "berryISchedulingRule.h"
#include "berryJobExceptions.h"
#include "internal/berryInternalJob.h"
#include <berryObject.h>
#include <string>
namespace berry
{
struct IJobManager;
/**
* Jobs are units of runnable work that can be scheduled to be run with the job
* manager. Once a job has completed, it can be scheduled to run again (jobs are
* reusable).
* <p>
* Jobs have a state that indicates what they are currently doing. When constructed,
* jobs start with a state value of <code>NONE</code>. When a job is scheduled
* to be run, it moves into the <code>WAITING</code> state. When a job starts
* running, it moves into the <code>RUNNING</code> state. When execution finishes
* (either normally or through cancellation), the state changes back to
* <code>NONE</code>.
* </p><p>
* A job can also be in the <code>SLEEPING</code> state. This happens if a user
* calls Job.sleep() on a waiting job, or if a job is scheduled to run after a specified
* delay. Only jobs in the <code>WAITING</code> state can be put to sleep.
* Sleeping jobs can be woken at any time using Job.wakeUp(), which will put the
* job back into the <code>WAITING</code> state.
* </p><p>
* Jobs can be assigned a priority that is used as a hint about how the job should
* be scheduled. There is no guarantee that jobs of one priority will be run before
* all jobs of lower priority. The documentation of the various priority constants provide
* more detail about what each priority means. By default, jobs start in the
* <code>LONG</code> priority class.
*
* @see IJobManager
*
*/
//TODO struct Job: public InternalJob, public IAdaptable
class BERRY_JOBS Job: public InternalJob
{
public:
berryObjectMacro(Job)
/**
* Job status return value that is used to indicate asynchronous job completion.
* @see Job#Run(IProgressMonitor::Pointer)
* @see Job#Done(IStatus::Pointer)
*/
static const IStatus::Pointer ASYNC_FINISH ;
/* Job priorities */
/**
* Job priority constant (value 10) for interactive jobs.
* Interactive jobs generally have priority over all other jobs.
* Interactive jobs should be either fast running or very low on CPU
* usage to avoid blocking other interactive jobs from running.
*
* @see #GetPriority()
* @see #SetPriority(int)
* @see #Run(IProgressMonitor::Pointer)
*/
static const int INTERACTIVE = 10;
/**
* Job priority constant (value 20) for short background jobs.
* Short background jobs are jobs that typically complete within a second,
* but may take longer in some cases. Short jobs are given priority
* over all other jobs except interactive jobs.
*
* @see #GetPriority()
* @see #SetPriority(int)
* @see #Run(IProgressMonitor::Pointer)
*/
static const int SHORT = 20;
/**
* Job priority constant (value 30) for long-running background jobs.
*
* @see #GetPriority()
* @see #SetPriority(int)
* @see #Run(IProgressMonitor::Pointer)
*/
static const int LONG = 30;
/**
* Job priority constant (value 40) for build jobs. Build jobs are
* generally run after all other background jobs complete.
*
* @see #GetPriority()
* @see #SetPriority(int)
* @see #Run(IProgressMonitor)
*/
static const int BUILD = 40;
/**
* Job priority constant (value 50) for decoration jobs.
* Decoration jobs have lowest priority. Decoration jobs generally
* compute extra information that the user may be interested in seeing
* but is generally not waiting for.
*
* @see #GetPriority()
* @see #SetPriority(int)
* @see #Run(IProgressMonitor)
*/
static const int DECORATE = 50;
/**
* Job state code (value 0) indicating that a job is not
* currently sleeping, waiting, or running (i.e., the job manager doesn't know
* anything about the job).
*
* @see #GetState()
*/
static const int NONE = 0;
/**
* Job state code (value 1) indicating that a job is sleeping.
*
* @see #Run(IProgressMonitor)
* @see #GetState()
*/
static const int SLEEPING = 0x01;
/**
* Job state code (value 2) indicating that a job is waiting to be run.
*
* @see #GetState()
*/
static const int WAITING = 0x02;
/**
* Job state code (value 4) indicating that a job is currently running
*
* @see #GetState()
*/
static const int RUNNING = 0x04;
/**
* Returns the job manager.
*
* @return the job manager
*/
static const IJobManager* GetJobManager();
/**
* Creates a new job with the specified name. The job name is a human-readable
* value that is displayed to users. The name does not need to be unique, but it
* must not be <code>null</code>.
*
* @param name the name of the job.
*/
Job(std::string name);
/**
* Registers a job listener with this job
* Has no effect if an identical listener is already registered.
*
* @param listener the listener to be added.
*/
void AddJobChangeListener(IJobChangeListener::Pointer listener);
/**
* Returns whether this job belongs to the given family. Job families are
* represented as objects that are not interpreted or specified in any way
* by the job manager. Thus, a job can choose to belong to any number of
* families.
* <p>
* Clients may override this method. This default implementation always returns
* <code>false</code>. Overriding implementations must return <code>false</code>
* for families they do not recognize.
* </p>
*
* @param family the job family identifier
* @return <code>true</code> if this job belongs to the given family, and
* <code>false</code> otherwise.
*/
bool BelongsTo(Object::Pointer family);
/**
* Stops the job. If the job is currently waiting,
* it will be removed from the queue. If the job is sleeping,
* it will be discarded without having a chance to resume and its sleeping state
* will be cleared. If the job is currently executing, it will be asked to
* stop but there is no guarantee that it will do so.
*
* @return <code>false</code> if the job is currently running (and thus may not
* respond to cancellation), and <code>true</code> in all other cases.
*/
bool Cancel();
/**
* Jobs that complete their execution asynchronously must indicate when they
* are finished by calling this method. This method must not be called by
* a job that has not indicated that it is executing asynchronously.
* <p>
* This method must not be called from within the scope of a job's <code>run</code>
* method. Jobs should normally indicate completion by returning an appropriate
* status from the <code>run</code> method. Jobs that return a status of
* <code>ASYNC_FINISH</code> from their run method must later call
* <code>done</code> to indicate completion.
*
* @param result a status object indicating the result of the job's execution.
* @see #ASYNC_FINISH
* @see #Run(IProgressMonitor::Pointer)
*/
void Done(IStatus::Pointer result);
/**
* Returns the human readable name of this job. The name is never
* <code>null</code>.
*
* @return the name of this job
*/
std::string GetName() const;
/**
* Returns the priority of this job. The priority is used as a hint when the job
* is scheduled to be run.
*
* @return the priority of the job. One of INTERACTIVE, SHORT, LONG, BUILD,
* or DECORATE.
*/
int GetPriority() const;
/**
* Returns the value of the property of this job identified by the given key,
* or <code>null</code> if this job has no such property.
*
* @param key the name of the property
* @return the value of the property,
* or <code>null</code> if this job has no such property
* @see #SetProperty(QualifiedName, Object)
*/
//TODO QualifiedName GetPropertys
///Object GetProperty(QualifiedName key) const ;
/**
* Returns the result of this job's last run.
*
* @return the result of this job's last run, or <code>null</code> if this
* job has never finished running.
*/
IStatus::Pointer GetResult() const ;
/**
* Returns the scheduling rule for this job. Returns <code>null</code> if this job has no
* scheduling rule.
*
* @return the scheduling rule for this job, or <code>null</code>.
* @see ISchedulingRule
* @see #SetRule(ISchedulingRule::Pointer)
*/
ISchedulingRule::Pointer GetRule() const;
/**
* Returns the state of the job. Result will be one of:
* <ul>
* <li><code>Job.RUNNING</code> - if the job is currently running.</li>
* <li><code>Job.WAITING</code> - if the job is waiting to be run.</li>
* <li><code>Job.SLEEPING</code> - if the job is sleeping.</li>
* <li><code>Job.NONE</code> - in all other cases.</li>
* </ul>
* <p>
* Note that job state is inherently volatile, and in most cases clients
* cannot rely on the result of this method being valid by the time the
* result is obtained. For example, if <tt>getState</tt> returns
* <tt>RUNNING</tt>, the job may have actually completed by the
* time the <tt>getState</tt> method returns. All clients can infer from
* invoking this method is that the job was recently in the returned state.
*
* @return the job state
*/
int GetState() const;
/**
* Returns the thread that this job is currently running in.
*
* @return the thread this job is running in, or <code>null</code>
* if this job is not running or the thread is unknown.
*/
Poco::Thread* GetThread() const;
/**
* Returns whether this job is blocking a higher priority non-system job from
* starting due to a conflicting scheduling rule. Returns <code>false</code>
* if this job is not running, or is not blocking a higher priority non-system job.
*
* @return <code>true</code> if this job is blocking a higher priority non-system
* job, and <code>false</code> otherwise.
* @see #GetRule()
* @see #IsSystem()
*/
bool IsBlocking();
/**
* Returns whether this job is a system job. System jobs are typically not
* revealed to users in any UI presentation of jobs. Other than their UI presentation,
* system jobs act exactly like other jobs. If this value is not explicitly set, jobs
* are treated as non-system jobs. The default value is <code>false</code>.
*
* @return <code>true</code> if this job is a system job, and
* <code>false</code> otherwise.
* @see #SetSystem(bool)
*/
bool IsSystem() const;
/**
* Returns whether this job has been directly initiated by a UI end user.
* These jobs may be presented differently in the UI. The default value
* is <code>false</code>.
*
* @return <code>true</code> if this job is a user-initiated job, and
* <code>false</code> otherwise.
* @see #SetUser(bool)
*/
bool IsUser() const;
/**
* Waits until this job is finished. This method will block the calling thread until the
* job has finished executing, or until this thread has been interrupted. If the job
* has not been scheduled, this method returns immediately. A job must not
* be joined from within the scope of its run method.
* <p>
* If this method is called on a job that reschedules itself from within the
* <tt>run</tt> method, the join will return at the end of the first execution.
* In other words, join will return the first time this job exits the
* {@link #RUNNING} state, or as soon as this job enters the {@link #NONE} state.
* </p>
* <p>
* If this method is called while the job manager is suspended, this job
* will only be joined if it is already running; if this job is waiting or sleeping,
* this method returns immediately.
* </p>
* <p>
* Note that there is a deadlock risk when using join. If the calling thread owns
* a lock or object monitor that the joined thread is waiting for, deadlock
* will occur.
* </p>
*
* @exception InterruptedException if this thread is interrupted while waiting
* @see ILock
* @see IJobManager#Suspend()
*/
//TODO Error Join Problem InterruptedException
/// void Join() ;
/**
* Removes a job listener from this job.
* Has no effect if an identical listener is not already registered.
*
* @param listener the listener to be removed
*/
void RemoveJobChangeListener(IJobChangeListener::Pointer listener);
/**
* Schedules this job to be run. The job is added to a queue of waiting
* jobs, and will be run when it arrives at the beginning of the queue.
* <p>
* This is a convenience method, fully equivalent to
* <code>Schedule(0L)</code>.
* </p>
* @see #Schedule(long)
*/
void Schedule();
/**
* Schedules this job to be run after a specified delay. The job is put in the
* {@link #SLEEPING} state until the specified delay has elapsed, after which
* the job is added to a queue of {@link #WAITING} jobs. Once the job arrives
* at the beginning of the queue, it will be run at the first available opportunity.
* </p><p>
* Jobs of equal priority and <code>delay</code> with conflicting scheduling
* rules are guaranteed to run in the order they are scheduled. No guarantees
* are made about the relative execution order of jobs with unrelated or
* <code>null</code> scheduling rules, or different priorities.
* <p>
* If this job is currently running, it will be rescheduled with the specified
* delay as soon as it finishes. If this method is called multiple times
* while the job is running, the job will still only be rescheduled once,
* with the most recent delay value that was provided.
* </p><p>
* Scheduling a job that is waiting or sleeping has no effect.
* </p>
*
* @param delay a time delay in milliseconds before the job should run
* @see ISchedulingRule
*/
void Schedule(Poco::Timestamp::TimeDiff delay);
/**
* Changes the name of this job. If the job is currently running, waiting,
* or sleeping, the new job name may not take effect until the next time the
* job is scheduled.
* <p>
* The job name is a human-readable value that is displayed to users. The name
* does not need to be unique, but it must not be <code>null</code>.
*
* @param name the name of the job.
*/
void SetName(std::string name);
/**
* Sets the priority of the job. This will not affect the execution of
* a running job, but it will affect how the job is scheduled while
* it is waiting to be run.
*
* @param priority the new job priority. One of
* INTERACTIVE, SHORT, LONG, BUILD, or DECORATE.
*/
void SetPriority(int priority);
/**
* Associates this job with a progress group. Progress feedback
* on this job's next execution will be displayed together with other
* jobs in that group. The provided monitor must be a monitor
* created by the method <tt>IJobManager.createProgressGroup</tt>
* and must have at least <code>ticks</code> units of available work.
* <p>
* The progress group must be set before the job is scheduled.
* The group will be used only for a single invocation of the job's
* <tt>run</tt> method, after which any association of this job to the
* group will be lost.
*
* @see IJobManager#createProgressGroup()
* @param group The progress group to use for this job
* @param ticks the number of work ticks allocated from the
* parent monitor, or {@link IProgressMonitor#UNKNOWN}
*/
void SetProgressGroup(IProgressMonitor::Pointer group, int ticks);
/**
* Sets the value of the property of this job identified
* by the given key. If the supplied value is <code>null</code>,
* the property is removed from this resource.
* <p>
* Properties are intended to be used as a caching mechanism
* by ISV plug-ins. They allow key-object associations to be stored with
* a job instance. These key-value associations are maintained in
* memory (at all times), and the information is never discarded automatically.
* </p><p>
* The qualifier part of the property name must be the unique identifier
* of the declaring plug-in (e.g. <code>"com.example.plugin"</code>).
* </p>
*
* @param key the qualified name of the property
* @param value the value of the property,
* or <code>null</code> if the property is to be removed
* @see #GetProperty(QualifiedName)
*/
//TODO QualifiedName SetProperty
/// void SetProperty(QualifiedName key, Object value);
/**
* Sets the scheduling rule to be used when scheduling this job. This method
* must be called before the job is scheduled.
*
* @param rule the new scheduling rule, or <code>null</code> if the job
* should have no scheduling rule
* @see #GetRule()
*/
void SetRule(ISchedulingRule::Pointer rule);
/**
* Sets whether or not this job is a system job. System jobs are typically not
* revealed to users in any UI presentation of jobs. Other than their UI presentation,
* system jobs act exactly like other jobs. If this value is not explicitly set, jobs
* are treated as non-system jobs. This method must be called before the job
* is scheduled.
*
* @param value <code>true</code> if this job should be a system job, and
* <code>false</code> otherwise.
* @see #IsSystem()
*/
void SetSystem(bool value);
/**
* Sets whether or not this job has been directly initiated by a UI end user.
* These jobs may be presented differently in the UI. This method must be
* called before the job is scheduled.
*
* @param value <code>true</code> if this job is a user-initiated job, and
* <code>false</code> otherwise.
* @see #IsUser()
*/
void SetUser(bool value);
/**
* Sets the thread that this job is currently running in, or <code>null</code>
* if this job is not running or the thread is unknown.
* <p>
* Jobs that use the {@link #ASYNC_FINISH} return code should tell
* the job what thread it is running in. This is used to prevent deadlocks.
*
* @param thread the thread that this job is running in.
*
* @see #ASYNC_FINISH
* @see #Run(IProgressMonitor::Pointer)
*/
void SetThread(Poco::Thread* thread);
/**
* Returns whether this job should be run.
* If <code>false</code> is returned, this job will be discarded by the job manager
* without running.
* <p>
* This method is called immediately prior to calling the job's
* run method, so it can be used for last minute pre-condition checking before
* a job is run. This method must not attempt to schedule or change the
* state of any other job.
* </p><p>
* Clients may override this method. This default implementation always returns
* <code>true</code>.
* </p>
*
* @return <code>true</code> if this job should be run
* and <code>false</code> otherwise
*/
virtual bool ShouldRun();
/**
* Returns whether this job should be scheduled.
* If <code>false</code> is returned, this job will be discarded by the job manager
* without being added to the queue.
* <p>
* This method is called immediately prior to adding the job to the waiting job
* queue.,so it can be used for last minute pre-condition checking before
* a job is scheduled.
* </p><p>
* Clients may override this method. This default implementation always returns
* <code>true</code>.
* </p>
*
* @return <code>true</code> if the job manager should schedule this job
* and <code>false</code> otherwise
*/
virtual bool ShouldSchedule();
/**
* Requests that this job be suspended. If the job is currently waiting to be run, it
* will be removed from the queue move into the {@link #SLEEPING} state.
* The job will remain asleep until either resumed or canceled. If this job is not
* currently waiting to be run, this method has no effect.
* <p>
* Sleeping jobs can be resumed using <code>wakeUp</code>.
*
* @return <code>false</code> if the job is currently running (and thus cannot
* be put to sleep), and <code>true</code> in all other cases
* @see #WakeUp()
*/
bool Sleep();
/**
* Puts this job immediately into the {@link #WAITING} state so that it is
* eligible for immediate execution. If this job is not currently sleeping,
* the request is ignored.
* <p>
* This is a convenience method, fully equivalent to
* <code>wakeUp(0L)</code>.
* </p>
* @see #Sleep()
*/
void WakeUp();
/**
* Puts this job back into the {@link #WAITING} state after
* the specified delay. This is equivalent to canceling the sleeping job and
* rescheduling with the given delay. If this job is not currently sleeping,
* the request is ignored.
*
* @param delay the number of milliseconds to delay
* @see #Sleep()
*/
void WakeUp(long delay);
protected:
/**
* A hook method indicating that this job is running and {@link #cancel()}
* is being called for the first time.
* <p>
* Subclasses may override this method to perform additional work when
* a cancellation request is made. This default implementation does nothing.
*/
virtual void Canceling();
/**
* Executes this job. Returns the result of the execution.
* <p>
* The provided monitor can be used to report progress and respond to
* cancellation. If the progress monitor has been canceled, the job
* should finish its execution at the earliest convenience and return a result
* status of severity {@link IStatus#CANCEL}. The singleton
* cancel status {@link Status#CANCEL_STATUS} can be used for
* this purpose. The monitor is only valid for the duration of the invocation
* of this method.
* <p>
* This method must not be called directly by clients. Clients should call
* <code>schedule</code>, which will in turn cause this method to be called.
* <p>
* Jobs can optionally finish their execution asynchronously (in another thread) by
* returning a result status of {@link #ASYNC_FINISH}. Jobs that finish
* asynchronously <b>must</b> specify the execution thread by calling
* <code>setThread</code>, and must indicate when they are finished by calling
* the method <code>done</code>.
*
* @param monitor the monitor to be used for reporting progress and
* responding to cancellation. The monitor is never <code>null</code>
* @return resulting status of the run. The result must not be <code>null</code>
* @see #ASYNC_FINISH
* @see #Done(IStatus)
*/
virtual IStatus::Pointer Run(IProgressMonitor::Pointer myProgressMonitor) = 0;
};
}
#endif /* BERRY_JOB_H */
diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryJobExceptions.cpp b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryJobExceptions.cpp
index 36f40f70db..0d6743058b 100644
--- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryJobExceptions.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryJobExceptions.cpp
@@ -1,31 +1,31 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryJobExceptions.h"
#include <typeinfo>
namespace berry
{
POCO_IMPLEMENT_EXCEPTION(InterruptedException, Poco::RuntimeException, "Interrupted Exception")
POCO_IMPLEMENT_EXCEPTION(JobRuntimeException, Poco::RuntimeException, "Job Runtime Exception")
POCO_IMPLEMENT_EXCEPTION(IllegalStateException, Poco::RuntimeException, "IllegalState")
POCO_IMPLEMENT_EXCEPTION(FinallyThrowException, Poco::RuntimeException, "FinallyThrow")
POCO_IMPLEMENT_EXCEPTION(IllegalArgumentException, Poco::Exception, "IllegalArgument")
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryJobExceptions.h b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryJobExceptions.h
index d042ef8ef5..9d72d62f16 100644
--- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryJobExceptions.h
+++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryJobExceptions.h
@@ -1,34 +1,34 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYJOBSEXCEPTIONS_H_
#define BERRYJOBSEXCEPTIONS_H_
#include <org_blueberry_core_jobs_Export.h>
#include <Poco/Exception.h>
namespace berry
{
POCO_DECLARE_EXCEPTION(BERRY_JOBS, InterruptedException, Poco::RuntimeException)
POCO_DECLARE_EXCEPTION(BERRY_JOBS, IllegalStateException, Poco::RuntimeException)
POCO_DECLARE_EXCEPTION(BERRY_JOBS, JobRuntimeException, Poco::RuntimeException)
POCO_DECLARE_EXCEPTION(BERRY_JOBS, FinallyThrowException, Poco::RuntimeException)
POCO_DECLARE_EXCEPTION(BERRY_JOBS, IllegalArgumentException, Poco::Exception)
}
#endif /* BERRYJOBSEXCEPTIONS_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryJobStatus.cpp b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryJobStatus.cpp
index c94cc8f48f..2dfc73b223 100644
--- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryJobStatus.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryJobStatus.cpp
@@ -1,82 +1,82 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryJobStatus.h"
#include "internal/berryJobManager.h"
#include <org_blueberry_core_jobs_Export.h>
namespace berry
{
JobStatus::JobStatus(const Status::Severity& serverity, Job::Pointer sptr_job,
const std::string& message) :
m_myJob(sptr_job), m_internalStatus(new Status(serverity,
JobManager::PI_JOBS(), 1, message))
{
}
Job::Pointer JobStatus::GetJob()
{
return m_myJob;
}
std::vector<IStatus::Pointer> JobStatus::GetChildren() const
{
return m_internalStatus->GetChildren();
}
int JobStatus::GetCode() const
{
return m_internalStatus->GetCode();
}
std::exception JobStatus::GetException() const
{
return m_internalStatus->GetException();
}
std::string JobStatus::GetMessage() const
{
return m_internalStatus->GetMessage();
}
std::string JobStatus::GetPlugin() const
{
return m_internalStatus->GetPlugin();
}
IStatus::Severity JobStatus::GetSeverity() const
{
return m_internalStatus->GetSeverity();
}
bool JobStatus::IsMultiStatus() const
{
return m_internalStatus->IsMultiStatus();
}
bool JobStatus::IsOK() const
{
return m_internalStatus->IsOK();
}
bool JobStatus::Matches(const Severities& severityMask) const
{
return m_internalStatus->Matches(severityMask);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryLockListener.h b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryLockListener.h
index 35ed1d6c27..559e6bbfa9 100644
--- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryLockListener.h
+++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryLockListener.h
@@ -1,89 +1,89 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 _BERRY_LOCKLISTENER_H_
#define _BERRY_LOCKLISTENER_H_
#include <org_blueberry_core_jobs_Export.h>
#include <Poco/Thread.h>
#include <berryObject.h>
namespace berry
{
/**
* A lock listener is notified whenever a thread is about to wait
* on a lock, and when a thread is about to release a lock.
* <p>
* This class is for internal use by the platform-related plug-ins.
* Clients outside of the base platform should not reference or subclass this class.
* </p>
*
* @see IJobManager#SetLockListener(LockListener::Pointer)
*/
class LockListener: public Object
{
berryObjectMacro( LockListener)
// LockManager::ConstPointer manager = ((JobManager)Job.getJobManager()).getLockManager();
public:
/**
* Notification that a thread is about to block on an attempt to acquire a lock.
* Returns whether the thread should be granted immediate access to the lock.
* <p>
* This default implementation always returns <code>false</code>.
* Subclasses may override.
*
* @param lockOwner the thread that currently owns the lock this thread is
* waiting for, or <code>null</code> if unknown.
* @return <code>true</code> if the thread should be granted immediate access,
* and <code>false</code> if it should wait for the lock to be available
*/
inline virtual bool AboutToWait(Poco::Thread* lockOwner)
{
return false;
}
/**
* Notification that a thread is about to release a lock.
* <p>
* This default implementation does nothing. Subclasses may override.
*/
inline virtual void AboutToRelease()
{
//do nothing
}
protected:
/**
* Returns whether this thread currently owns any locks
* @return <code>true</code> if this thread owns any locks, and
* <code>false</code> otherwise.
*/
inline bool IsLockOwnerThread() const
{
return manager.isLockOwner();
}
};
}
#endif // _BERRY_LOCKLISTENER_H_
diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryMultiRule.cpp b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryMultiRule.cpp
index 7bd4154512..e44f7b7dac 100644
--- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryMultiRule.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryMultiRule.cpp
@@ -1,33 +1,33 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryMultiRule.h"
namespace berry
{
// this is just a dummy implementation of a MultiRule.
bool MultiRule::IsConflicting(ISchedulingRule::Pointer /*sptr_myRule*/) const
{
return false;
}
bool MultiRule::Contains(ISchedulingRule::Pointer /*sptr_myrule*/) const
{
return false;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryMultiRule.h b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryMultiRule.h
index 8fb67626ab..91386d60a6 100644
--- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryMultiRule.h
+++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryMultiRule.h
@@ -1,48 +1,48 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 _BERRY_MULTIRULE_H
#define _BERRY_MULTIRULE_H
#include "berryISchedulingRule.h"
namespace berry
{
/**
* A MultiRule is a compound scheduling rule that represents a fixed group of child
* scheduling rules. A MultiRule conflicts with another rule if any of its children conflict
* with that rule. More formally, a compound rule represents a logical intersection
* of its child rules with respect to the <code>isConflicting</code> equivalence
* relation.
* <p>
* A MultiRule will never contain other MultiRules as children. If a MultiRule is provided
* as a child, its children will be added instead.
* </p>
*
*/
class MultiRule: public ISchedulingRule
{
bool IsConflicting(ISchedulingRule::Pointer myRule) const;
bool Contains(ISchedulingRule::Pointer rule) const;
};
}
#endif /* _BERRY_MULTIRULE_H */
diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryNullProgressMonitor.cpp b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryNullProgressMonitor.cpp
index e0bc9ed918..47f4c9de58 100644
--- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryNullProgressMonitor.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryNullProgressMonitor.cpp
@@ -1,67 +1,67 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryNullProgressMonitor.h"
namespace berry
{
NullProgressMonitor::NullProgressMonitor() :
m_cancelled(false)
{
}
void NullProgressMonitor::BeginTask(const std::string& /*name*/, int /*totalWork*/)
{
// do nothing
}
void NullProgressMonitor::Done()
{
// do nothing
}
void NullProgressMonitor::InternalWorked(double /*work*/)
{
// do nothing
}
bool NullProgressMonitor::IsCanceled()
{
return m_cancelled;
}
void NullProgressMonitor::SetCanceled(bool newcancelled)
{
this->m_cancelled = newcancelled;
}
void NullProgressMonitor::SetTaskName(const std::string& /*name*/)
{
// do nothing
}
void NullProgressMonitor::SubTask(const std::string& /*name*/)
{
// do nothing
}
void NullProgressMonitor::Worked(int /*work*/)
{
// do nothing
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryNullProgressMonitor.h b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryNullProgressMonitor.h
index 06e5316561..56dbd187e7 100644
--- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryNullProgressMonitor.h
+++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryNullProgressMonitor.h
@@ -1,133 +1,133 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRY_NULLPROGRESSMONITOR_H
#define BERRY_NULLPROGRESSMONITOR_H
#include <string>
#include "berryIProgressMonitor.h"
namespace berry
{
/**
* A default progress monitor implementation suitable for
* subclassing.
* <p>
* This implementation supports cancellation. The default
* implementations of the other methods do nothing.
* </p><p>
* This class can be used without OSGi running.
* </p>
*/
class NullProgressMonitor: public IProgressMonitor
{
public:
berryObjectMacro(NullProgressMonitor)
/**
* Constructs a new progress monitor.
*/
NullProgressMonitor();
/**
* This implementation does nothing.
* Subclasses may override this method to do interesting
* processing when a task begins.
*
* @see IProgressMonitor#BeginTask(std::string, int)
*/
virtual void BeginTask(const std::string& name, int totalWork);
/**
* This implementation does nothing.
* Subclasses may override this method to do interesting
* processing when a task is done.
*
* @see IProgressMonitor#Done()
*/
virtual void Done();
/**
* This implementation does nothing.
* Subclasses may override this method.
*
* @see IProgressMonitor#InternalWorked(double)
*/
virtual void InternalWorked(double work);
/**
* This implementation returns the value of the internal
* state variable set by <code>setCanceled</code>.
* Subclasses which override this method should
* override <code>setCanceled</code> as well.
*
* @see IProgressMonitor#IsCanceled()
* @see IProgressMonitor#SetCanceled(bool)
*/
virtual bool IsCanceled();
/**
* This implementation sets the value of an internal state variable.
* Subclasses which override this method should override
* <code>isCanceled</code> as well.
*
* @see IProgressMonitor#IsCanceled()
* @see IProgressMonitor#SetCanceled(bool)
*/
virtual void SetCanceled(bool cancelled);
/**
* This implementation does nothing.
* Subclasses may override this method to do something
* with the name of the task.
*
* @see IProgressMonitor#SetTaskName(const std::string&)
*/
virtual void SetTaskName(const std::string& name);
/**
* This implementation does nothing.
* Subclasses may override this method to do interesting
* processing when a subtask begins.
*
* @see IProgressMonitor#SubTask(const std::string&)
*/
virtual void SubTask(const std::string& name);
/**
* This implementation does nothing.
* Subclasses may override this method to do interesting
* processing when some work has been completed.
*
* @see IProgressMonitor#Worked(int)
*/
virtual void Worked(int work);
private:
/**
* Indicates whether cancel has been requested.
*/
bool m_cancelled;
};
}
#endif /* BERRY_NULLPROGRESSMONITOR_H */
diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryProgressProvider.cpp b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryProgressProvider.cpp
index 63c5a48fa3..1509ee4ee8 100644
--- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryProgressProvider.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryProgressProvider.cpp
@@ -1,48 +1,48 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryNullProgressMonitor.h"
#include "berryProgressProvider.h"
namespace berry
{
// returns the default NullProgressProvider
IProgressMonitor::Pointer ProgressProvider::CreateProgressGroup()
{
IProgressMonitor::Pointer sptr_progressGroup(new NullProgressMonitor());
return sptr_progressGroup;
}
// returns the default NullProgressProvider
IProgressMonitor::Pointer ProgressProvider::GetDefaultMonitor()
{
IProgressMonitor::Pointer sptr_defaultMonitor(new NullProgressMonitor());
return sptr_defaultMonitor;
}
IProgressMonitor::Pointer ProgressProvider::CreateMonitor(Job::Pointer /*job*/,
IProgressMonitor::Pointer /*group*/, int /*ticks*/)
{
//TODO SubProgressMonitor class
// not implemented yet ( because the subProgressMonitor class is not implemented )returns a dummy null IProgressMonitor
//Pointer
//return IProgressMonitor::Pointer sptr_subProgressMonitor (new SubProgressMonitor()) ;
IProgressMonitor::Pointer dummy(0);
return dummy;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryProgressProvider.h b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryProgressProvider.h
index 1f036b901a..887c15ee32 100644
--- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryProgressProvider.h
+++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryProgressProvider.h
@@ -1,113 +1,113 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 _BERRY_PROGRESSPROVIDER_H
#define _BERRY_PROGRESSPROVIDER_H
#include "berryIProgressMonitor.h"
#include "berryObject.h"
#include "berryJob.h"
namespace berry
{
/**
* The progress provider supplies the job manager with progress monitors for
* running jobs. There can only be one progress provider at any given time.
* <p>
* This class is intended for use by the currently executing Eclipse application.
* Plug-ins outside the currently running application should not reference or
* subclass this class.
* </p>
*
* @see IJobManager#SetProgressProvider(ProgressProvider::Pointer)
*/
struct ProgressProvider: public Object
{
public:
berryObjectMacro(ProgressProvider)
/**
* Provides a new progress monitor instance to be used by the given job.
* This method is called prior to running any job that does not belong to a
* progress group. The returned monitor will be supplied to the job's
* <code>Run</code> method.
*
* @see #CreateProgressGroup()
* @see Job#SetProgressGroup(IProgressMonitor::Pointer, int)
* @param job the job to create a progress monitor for
* @return a progress monitor, or <code>null</code> if no progress monitoring
* is needed.
*/
virtual IProgressMonitor::Pointer CreateMonitor(Job::Pointer job) = 0;
/**
* Returns a progress monitor that can be used to provide
* aggregated progress feedback on a set of running jobs.
* This method implements <code>IJobManager.createProgressGroup</code>,
* and must obey all rules specified in that contract.
* <p>
* This default implementation returns a new
* <code>NullProgressMonitor</code> Subclasses may override.
*
* @see IJobManager#CreateProgressGroup()
* @return a progress monitor
*/
virtual IProgressMonitor::Pointer CreateProgressGroup();
/**
* Returns a progress monitor that can be used by a running job
* to report progress in the context of a progress group. This method
* implements <code>Job.setProgressGroup</code>. One of the
* two <code>createMonitor</code> methods will be invoked
* prior to each execution of a job, depending on whether a progress
* group was specified for the job.
* <p>
* The provided monitor must be a monitor returned by the method
* <code>createProgressGroup</code>. This method is responsible
* for asserting this and throwing an appropriate runtime exception
* if an invalid monitor is provided.
* <p>
* This default implementation returns a new
* <code>SubProgressMonitor</code>. Subclasses may override.
*
* @see IJobManager#CreateProgressGroup()
* @see Job#setProgressGroup(IProgressMonitor, int)
* @param job the job to create a progress monitor for
* @param group the progress monitor group that this job belongs to
* @param ticks the number of ticks of work for the progress monitor
* @return a progress monitor, or <code>null</code> if no progress monitoring
* is needed.
*/
virtual IProgressMonitor::Pointer CreateMonitor(Job::Pointer sptr_job,
IProgressMonitor::Pointer sptr_group, int ticks);
/**
* Returns a progress monitor to use when none has been provided
* by the client running the job.
* <p>
* This default implementation returns a new
* <code>NullProgressMonitor</code> Subclasses may override.
*
* @return a progress monitor
*/
virtual IProgressMonitor::Pointer GetDefaultMonitor();
};
}
#endif /* BERRY_PROGRESSPROVIDER_H */
diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryQualifiedName.cpp b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryQualifiedName.cpp
index e9abe607ae..6f717956d2 100644
--- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryQualifiedName.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryQualifiedName.cpp
@@ -1,84 +1,84 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryQualifiedName.h"
#include <berryObject.h>
#include <Poco/Bugcheck.h>
#include <Poco/Hash.h>
#include <string>
#include <sstream>
namespace berry
{
QualifiedName::QualifiedName(std::string qualifier, std::string localName)
{
poco_assert(!localName.empty());
this->qualifier = qualifier;
this->localName = localName;
}
bool
QualifiedName
::operator==(const QualifiedName& qName) const
{
if (this == &qName) return true;
return qualifier == qName.GetQualifier() && localName == qName.GetLocalName();
}
bool
QualifiedName
::operator<(const QualifiedName& qName) const
{
return qualifier < qName.GetQualifier() ? true : (qualifier == qName.GetQualifier() ? localName < qName.GetLocalName() : false);
}
std::string
QualifiedName
::GetLocalName()const
{
return localName;
}
std::string
QualifiedName
::GetQualifier()const
{
return qualifier;
}
std::size_t
QualifiedName
::HashCode() const
{
return (qualifier.empty() ? 0 : (Poco::Hash<std::string >().operator()(qualifier) + Poco::Hash<std::string>().operator()(localName)));
}
std::string
QualifiedName
::ToString()
{
std::string temp = ( GetQualifier().empty() ? "" : GetQualifier() + ':');
std::stringstream ss;
ss << temp << GetLocalName();
return ss.str();
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryQualifiedName.h b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryQualifiedName.h
index 6cf61c3069..944a0a02c6 100644
--- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryQualifiedName.h
+++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/berryQualifiedName.h
@@ -1,112 +1,112 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 _BERRY_QUALIFIED_NAME_
#define _BERRY_QUALIFIED_NAME_
#include <string>
#include "berryObject.h"
#include <org_blueberry_core_jobs_Export.h>
namespace berry
{
/**
* Qualified names are two-part names: qualifier and local name.
* The qualifier must be in URI form (see RFC2396).
* Note however that the qualifier may be <code>null</code> if
* the default name space is being used. The empty string is not
* a valid local name.
* <p>
* This class can be used without OSGi running.
* </p><p>
* This class is not intended to be subclassed by clients.
* </p>
* @noextend This class is not intended to be subclassed by clients.ds
*/
struct BERRY_JOBS QualifiedName
{
/** Qualifier part (potentially <code>null</code>). */
/*package*/
std::string qualifier;
/** Local name part. */
/*package*/
std::string localName;
/**
* Creates and returns a new qualified name with the given qualifier
* and local name. The local name must not be the empty string.
* The qualifier may be <code>null</code>.
* <p>
* Clients may instantiate.
* </p>
* @param qualifier the qualifier string, or <code>null</code>
* @param localName the local name string
*/
QualifiedName(std::string qualifier, std::string localName);
/**
* Returns whether this qualified name is equivalent to the given object.
* <p>
* Qualified names are equal if and only if they have the same
* qualified parts and local parts.
* Qualified names are not equal to objects other than qualified names.
* </p>
*
* @param obj the object to compare to
* @return <code>true</code> if these are equivalent qualified
* names, and <code>false</code> otherwise
*/
bool operator==(const QualifiedName& qName) const;
bool operator<(const QualifiedName& qName) const;
/**
* Returns the local part of this name.
*
* @return the local name string
*/
std::string GetLocalName() const;
/**
* Returns the qualifier part for this qualified name, or <code>null</code>
* if none.
*
* @return the qualifier string, or <code>null</code>
*/
std::string GetQualifier() const;
/*
* Implements the method <code>Object.hashCode</code>.
*
* Returns the hash code for this qualified name.
*/
std::size_t HashCode() const;
/**
* Converts this qualified name into a string, suitable for
* debug purposes only.
*/
std::string ToString();
};
}
#endif // _BERRY_QUALIFIED_NAME_
diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryInternalJob.cpp b/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryInternalJob.cpp
index ee21504da1..8127823ec9 100644
--- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryInternalJob.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryInternalJob.cpp
@@ -1,445 +1,445 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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.
===================================================================*/
#define NOMINMAX
#include "berryInternalJob.h"
#include <Poco/Thread.h>
#include "berryJob.h"
#include "berryJobManager.h"
#include "berryJobExceptions.h"
#include <string>
#include <sstream>
#include <assert.h>
#include <map>
namespace berry
{
InternalJob::InternalJob(std::string name) :
jobNumber(nextJobNumber++), flags(Job::NONE), name(name), next(0),
previous(0), priority(Job::LONG), sptr_schedulingRule(0),
sptr_monitor(0), m_startTime(), waitQueueStamp(T_NONE), ptr_thread(0)
{
jobEvents.SetExceptionHandler(MessageExceptionHandler<JobListeners>(&ptr_manager->m_JobListeners, &JobListeners::HandleException));
}
JobManager* const InternalJob::ptr_manager = JobManager::GetInstance();
// time_variables definitions
// implemented as TimeDiff, if needed can be used to create a Poco::Timestamp with the given value
const Poco::Timestamp::TimeDiff InternalJob::T_INFINITE = std::numeric_limits<Poco::Timestamp::TimeVal>::max();
// indicates if a job has a scheduling time
// implemented as TimeDiff, if needed can be used to create a Poco::Timestamp with the given value
const Poco::Timestamp::TimeDiff InternalJob::T_NONE = -1;
void InternalJob::AddLast(InternalJob::Pointer entry)
{
InternalJob::Pointer last;
last = this;
//find the end of the queue
while (last->previous)
last = last->previous;
//add the new entry to the end of the queue
last->previous = entry.GetPointer();
entry->next = last;
entry->previous = 0;
}
bool InternalJob::operator==(const Object* otherJob) const
{
if (const InternalJob* temp = dynamic_cast<const InternalJob*>(otherJob))
{
return temp->m_startTime >= m_startTime;
}
else
return false;
}
const IJobChangeListener::Events& InternalJob::GetListeners() const
{
return jobEvents;
}
IProgressMonitor::Pointer InternalJob::GetProgressMonitor() const
{
return sptr_monitor;
}
Poco::Timestamp InternalJob::GetStartTime() const
{
return m_startTime;
}
int InternalJob::InternalGetState() const
{
return flags & M_STATE;
}
void InternalJob::InternalSetPriority(int newPriority)
{
this->priority = newPriority;
}
void InternalJob::InternalSetRule(ISchedulingRule::Pointer rule)
{
sptr_schedulingRule = rule;
}
//TODO InternalSetState
void InternalJob::InternalSetState(int i)
{
flags = (flags & ~M_STATE) | i;
}
bool InternalJob::IsAboutToRunCanceled() const
{
return (flags & M_ABOUT_TO_RUN_CANCELED) != 0;
}
bool InternalJob::IsRunCanceled() const
{
return (flags & M_RUN_CANCELED) != 0;
}
bool InternalJob::IsConflicting(InternalJob::Pointer otherJob) const
{
ISchedulingRule::Pointer otherRule = otherJob->GetRule();
if (sptr_schedulingRule.GetPointer() == 0 || otherRule.GetPointer() == 0)
return false;
// TODO MultiRule: extend the IsConflicting (...) method with MultiRule
// if one of the rules is a compound rule, it must be asked the question.
//if (schedulingRule.GetClass() == MultiRule.class)
// return schedulingRule.IsConflicting(otherRule);
return otherRule->IsConflicting(sptr_schedulingRule);
}
InternalJob::Pointer InternalJob::Next() const
{
return next;
}
InternalJob::Pointer InternalJob::Previous() const
{
return InternalJob::Pointer(previous);
}
InternalJob::Pointer InternalJob::Remove()
{
if (next != 0)
next->SetPrevious(InternalJob::Pointer(previous));
if (previous != 0)
previous->SetNext(next);
next = previous = 0;
return InternalJob::Pointer(this);
}
void InternalJob::SetAboutToRunCanceled(bool value) throw (JobRuntimeException)
{
flags = value ? flags | M_ABOUT_TO_RUN_CANCELED : flags
& ~M_ABOUT_TO_RUN_CANCELED;
}
void InternalJob::SetRunCanceled(bool value)
{
flags = value ? flags | M_RUN_CANCELED : flags & ~M_RUN_CANCELED;
}
void InternalJob::SetNext(InternalJob::Pointer entry)
{
this->next = entry;
}
void InternalJob::SetPrevious(InternalJob::Pointer entry)
{
this->previous = entry.GetPointer();
}
void InternalJob::SetProgressMonitor(IProgressMonitor::Pointer monitor)
{
sptr_monitor = monitor;
}
void InternalJob::SetResult(IStatus::Pointer result)
{
m_result = result;
}
void InternalJob::SetStartTime(Poco::Timestamp::TimeDiff time)
{
m_startTime = m_startTime + time;
}
void InternalJob::SetStartTime(const Poco::Timestamp& newtime)
{
m_startTime = newtime;
}
std::string InternalJob::ToString()
{
std::stringstream ss;
ss << GetName() << "(" << jobNumber << ")";
return ss.str();
}
void InternalJob::SetWaitQueueStamp(Poco::Timestamp waitQueueStamp)
{
this->waitQueueStamp = waitQueueStamp;
}
Poco::Timestamp InternalJob::GetWaitQueueStamp()
{
return waitQueueStamp;
}
int InternalJob::nextJobNumber = 0;
void InternalJob::AddJobChangeListener(IJobChangeListener::Pointer listener)
{
jobEvents.AddListener(listener);
}
bool InternalJob::BelongsTo(Object::Pointer /*family*/)
{
return false;
}
bool InternalJob::Cancel()
{
return ptr_manager->Cancel(InternalJob::Pointer(this));
}
void InternalJob::Canceling()
{
//default implementation does nothing
}
void InternalJob::Done(IStatus::Pointer endResult)
{
ptr_manager->EndJob(InternalJob::Pointer(this),endResult, true);
}
std::string InternalJob::GetName() const
{
return name;
}
int InternalJob::GetPriority() const
{
return priority;
}
//TODO QualifiedName GetProperty
//Object::Pointer
//InternalJob
//::GetProperty(QualifiedName key) {
// // thread safety: (Concurrency001 - copy on write)
// std::map<QualifiedName, Object::Pointer> temp (properties);
// if (temp.empty()) return Object::Pointer(0);
// else return temp[key];
// }
IStatus::Pointer InternalJob::GetResult() const
{
return m_result;
}
ISchedulingRule::Pointer InternalJob::GetRule() const
{
return sptr_schedulingRule;
}
int InternalJob::GetState() const
{
int state = flags & M_STATE;
switch (state)
{
//blocked state is equivalent to waiting state for clients
case BLOCKED:
return Job::WAITING;
case ABOUT_TO_RUN:
return Job::RUNNING;
case ABOUT_TO_SCHEDULE:
return Job::WAITING;
default:
return state;
}
}
Poco::Thread*
InternalJob::GetThread() const
{
return ptr_thread;
}
bool InternalJob::IsSystem() const
{
return (flags & M_SYSTEM) != 0;
}
bool InternalJob::IsBlocking()
{
return ptr_manager->IsBlocking(InternalJob::Pointer(this));
}
bool InternalJob::IsUser() const
{
return (flags & M_USER) != 0;
}
//void
//InternalJob
//::Join() throws InterruptedException {
// manager.join(this);
// }
void InternalJob::RemoveJobChangeListener(IJobChangeListener::Pointer listener)
{
jobEvents.RemoveListener(listener);
}
void InternalJob::Schedule(Poco::Timestamp::TimeDiff delay)
{
if (ShouldSchedule())
ptr_manager->Schedule(InternalJob::Pointer(this), delay, false);
}
void InternalJob::SetName(const std::string& name)
{
assert(!name.empty());
this->name = name;
}
void InternalJob::SetPriority(int newPriority)
{
switch (newPriority)
{
case Job::INTERACTIVE:
case Job::SHORT:
case Job::LONG:
case Job::BUILD:
case Job::DECORATE:
ptr_manager->SetPriority(InternalJob::Pointer(this), newPriority);
break;
default:
throw IllegalArgumentException(newPriority);
}
}
void InternalJob::SetProgressGroup(IProgressMonitor::Pointer group, int ticks)
{
assert(group.GetPointer() != 0);
InternalJob::Pointer sptr_temp(this);
IProgressMonitor::Pointer sptr_pm = ptr_manager->CreateMonitor(sptr_temp,
group, ticks);
if (sptr_pm != 0)
SetProgressMonitor(sptr_pm);
}
//TODO QualifiedName SetProperty
//void
//InternalJob
//::SetProperty(QualifiedName key, Object value) {
// // thread safety: (Concurrency001 - copy on write)
// if (value == NULL) {
// if (properties == NULL)
// return;
// ObjectMap temp = (ObjectMap) properties.Clone();
// temp.Remove(key);
// if (temp.isEmpty())
// properties = NULL;
// else
// properties = temp;
// } else {
// ObjectMap temp = properties;
// if (temp == NULL)
// temp = new ObjectMap(5);
// else
// temp = (ObjectMap) properties.Clone();
// temp.Put(key, value);
// properties = temp;
// }
// }
void InternalJob::SetRule(ISchedulingRule::Pointer rule)
{
ptr_manager->SetRule(InternalJob::Pointer(this), rule);
}
void InternalJob::SetSystem(bool value)
{
//TODO Error Exception Problem IllegalStateException
//if (GetState() != Job.NONE)
//throw IllegalStateException();
flags = value ? flags | M_SYSTEM : flags & ~M_SYSTEM;
}
void InternalJob::SetThread(Poco::Thread* thread)
{
ptr_thread = thread;
}
void InternalJob::SetUser(bool value)
{
//TODO Error Exception Problem IllegalStateException
if (GetState() != Job::NONE)
throw IllegalStateException();
flags = value ? flags | M_USER : flags & ~M_USER;
}
bool InternalJob::ShouldSchedule()
{
return true;
}
bool InternalJob::Sleep()
{
return ptr_manager->Sleep(InternalJob::Pointer(this));
}
void InternalJob::WakeUp(long delay)
{
ptr_manager->WakeUp(InternalJob::Pointer(this), delay);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryInternalJob.h b/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryInternalJob.h
index 877e5429a5..9b42bef940 100644
--- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryInternalJob.h
+++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryInternalJob.h
@@ -1,467 +1,467 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRY_INTERNALJOB_H
#define BERRY_INTERNALJOB_H
#include <Poco/Thread.h>
#include <Poco/Thread.h>
#include <Poco/Timestamp.h>
#include <org_blueberry_core_jobs_Export.h>
#include "berryJobExceptions.h"
#include "berryISchedulingRule.h"
#include "berryIProgressMonitor.h"
#include "berryIJobChangeListener.h"
#include <berryIStatus.h>
#include <berryStatus.h>
#include <berryQualifiedName.h>
#include <string>
#include <map>
#include <limits>
namespace berry
{
struct JobManager;
/**
* Internal implementation class for jobs. Clients must not implement this class
* directly. All jobs must be subclasses of the API <code>org.blueberry_core_jobs.Job</code> class.
*/
// struct BERRY_JOBS InternalJob: public Object, public Comparable
struct BERRY_JOBS InternalJob : public Object
{
friend struct JobQueue;
friend struct JobManager;
berryObjectMacro(InternalJob)
bool operator==(const Object* otherJob) const;
/**
* Adds an entry at the end of the list of which this item is the head.
*/
void AddLast(InternalJob::Pointer entry);
/*
* Returns the job listeners that are only listening to this job.
*/
const IJobChangeListener::Events& GetListeners() const;
/**
* Returns the job's progress monitor, or null if it is not running.
*/
IProgressMonitor::Pointer GetProgressMonitor() const;
/**
* Returns the time that this job should be started, awakened, or
* rescheduled, depending on the current state.
* @return time in milliseconds
*/
Poco::Timestamp GetStartTime() const;
/**
* Returns the raw job state, including internal states no exposed as API.
*/
int InternalGetState() const;
/*
* @see Job#GetState()
*/
int GetState() const;
/**
* @see Job#GetName()
*/
std::string GetName() const;
/*
* @see Job#setRule(ISchedulingRule::Pointer)
*/
void InternalSetRule(ISchedulingRule::Pointer rule);
/**
* Must be called from JobManager#setPriority
*/
void InternalSetPriority(int newPriority);
/**
* Must be called from JobManager#ChangeState
*/
void InternalSetState(int i);
/**
* Returns whether this job was canceled when it was about to run
*/
bool IsAboutToRunCanceled() const;
/**
* Returns whether this job was canceled when it was running.
*/
bool IsRunCanceled() const ;
/**
* Returns true if this job conflicts with the given job, and false otherwise.
*/
bool IsConflicting(InternalJob::Pointer otherJob) const;
/**
* Returns the next entry (ahead of this one) in the list, or null if there is no next entry
*/
InternalJob::Pointer Next() const;
/**
* Returns the previous entry (behind this one) in the list, or null if there is no previous entry
*/
InternalJob::Pointer Previous() const;
/**
* Removes this entry from any list it belongs to. Returns the receiver.
*/
InternalJob::Pointer Remove();
/*
* @see Job#run(IProgressMonitor)
*/
virtual IStatus::Pointer Run(IProgressMonitor::Pointer myProgressMonitor) = 0 ;
/**
* Sets whether this job was canceled when it was about to run
*/
void SetAboutToRunCanceled(bool value) throw (JobRuntimeException);
/**
* Sets the next entry in this linked list of jobs.
* @param entry
*/
/**
* Sets whether this job was canceled when it was running
*/
void SetRunCanceled(bool value) ;
void SetNext(InternalJob::Pointer entry);
/**
* Sets the previous entry in this linked list of jobs.
* @param entry
*/
void SetPrevious(InternalJob::Pointer entry);
/**
* Sets the progress monitor to use for the next execution of this job,
* or for clearing the monitor when a job completes.
* @param monitor a progress monitor
*/
void SetProgressMonitor(IProgressMonitor::Pointer monitor);
/**
* Sets or clears the result of an execution of this job.
* @param result a result status, or <code>null</code>
*/
void SetResult(IStatus::Pointer result) ;
/**
* Sets a time to start, wake up, or schedule this job,
* depending on the current state
* @param time a time in milliseconds
*/
void SetStartTime(Poco::Timestamp::TimeDiff time);
void SetStartTime(const Poco::Timestamp& newtime);
/*
* @see Job.SetThread
*/
void SetThread(Poco::Thread* thread);
/*
* @see Job.GetThread
*/
Poco::Thread* GetThread() const;
/*
* Prints a string-based representation of this job instance.
* For debugging purposes only.
*/
std::string ToString();
/**
* @param waitQueueStamp The waitQueueStamp to set.
*/
void SetWaitQueueStamp(Poco::Timestamp waitQueueStamp);
/**
* @return Returns the waitQueueStamp.
*/
Poco::Timestamp GetWaitQueueStamp();
protected:
InternalJob(std::string name);
/*
* @see Job#AddJobListener(IJobChangeListener::Pointer)
*/
void AddJobChangeListener(IJobChangeListener::Pointer listener);
/*
* @see Job#BelongsTo(Object)
*/
virtual bool BelongsTo(Object::Pointer family);
/*
* @see Job#Cancel()
*/
bool Cancel();
/*
* @see Job#Canceling()
*/
virtual void Canceling();
/*
*
* @see Job#Done(IStatus:.Pointer)
*/
void Done(IStatus::Pointer endResult);
/*
* @see Job#GetPriority()
*/
int GetPriority() const;
/*
* @see Job#GetProperty
*/
/// Object GetProperty(QualifiedName key) ;
/*
* @see Job#GetResult
*/
IStatus::Pointer GetResult() const ;
/*
* @see Job#GetRule
*/
ISchedulingRule::Pointer GetRule() const;
/*
* @see Job.IsSystem()
*/
bool IsSystem() const;
/*
* @see Job.IsUser()
*/
bool IsUser() const;
/*
* @see Job#Join()
*/
/// void Join() throws InterruptedException ;
/*
* @see Job#RemoveJobListener(IJobChangeListener)
*/
void RemoveJobChangeListener(IJobChangeListener::Pointer listener);
/*
* @see Job#Schedule(long)
*/
void Schedule(Poco::Timestamp::TimeDiff delay);
/*
* @see Job#SetName(std::string)
*/
void SetName(const std::string& name);
/*
* @see Job#SetPriority(int)
*/
void SetPriority(int newPriority);
/*
* @see Job#SetProgressGroup(IProgressMonitor::Pointer, int ticks)
*/
void SetProgressGroup(IProgressMonitor::Pointer group, int ticks);
/*
* @see Job#SetProperty(QualifiedName,Object)
*/
/// void SetProperty(QualifiedName key, Object value) ;
/* internalSetRule
* @see Job#SetRule(ISchedulingRule::Pointer)
*/
void SetRule(ISchedulingRule::Pointer rule);
/*
* @see Job.SetSystem
*/
void SetSystem(bool value);
/*
* @see Job.SetUser
*/
void SetUser(bool value);
/*
* @see Job#ShouldSchedule
*/
virtual bool ShouldSchedule();
/*
* @see Job#Sleep()
*/
bool Sleep();
/*
* @see Job#WakeUp(long)
*/
void WakeUp(long delay);
public:
/**
* Flag on a job indicating that it was canceled when running. This flag
* is used to ensure that #canceling is only ever called once on a job in
* case of recursive cancellation attempts.
*/
static const int M_RUN_CANCELED = 0x0800;
/**
* Job state code (value 16) indicating that a job has been removed from
* the wait queue and is about to start running. From an API point of view,
* this is the same as RUNNING.
*/
static const int ABOUT_TO_RUN = 0x10;
/**
* Job state code (value 32) indicating that a job has passed scheduling
* precondition checks and is about to be added to the wait queue. From an API point of view,
* this is the same as WAITING.
*/
static const int ABOUT_TO_SCHEDULE = 0x20;
/**
* Job state code (value 8) indicating that a job is blocked by another currently
* running job. From an API point of view, this is the same as WAITING.
*/
static const int BLOCKED = 0x08;
/**
* Start time constant indicating a job should be started at
* a time in the infinite future, causing it to sleep forever.
*/
static const Poco::Timestamp::TimeDiff T_INFINITE;
/**
* Start time constant indicating that the job has no start time.
*/
static const Poco::Timestamp::TimeDiff T_NONE;
private:
//flag mask bits
static const int M_STATE = 0xFF;
static const int M_SYSTEM = 0x0100;
static const int M_USER = 0x0200;
/**
* flag on a job indicating that it was about to run, but has been canceled
*/
static const int M_ABOUT_TO_RUN_CANCELED = 0x0400;
static int nextJobNumber;
int jobNumber;
volatile int flags;
/// ListenerList listeners ;
std::string name;
/**
* The job ahead of me in a queue or list.
*/
InternalJob::Pointer next;
/**
* The job behind me in a queue or list.
*/
InternalJob* previous;
int priority;
/**
* Arbitrary properties (key,value) pairs, attached
* to a job instance by a third party.
*/
//std::map<QualifiedName, Object::Pointer> properties ;
IStatus::Pointer m_result;
// Pointer to the ISchedulingRule belonging to the particular job
ISchedulingRule::Pointer sptr_schedulingRule;
IProgressMonitor::Pointer sptr_monitor;
/**
* If the job is waiting, this represents the time the job should start by.
* If this job is sleeping, this represents the time the job should wake up.
* If this job is running, this represents the delay automatic rescheduling,
* or -1 if the job should not be rescheduled.
*/
Poco::Timestamp m_startTime;
/**
* Stamp added when a job is added to the wait queue. Used to ensure
* jobs in the wait queue maintain their insertion order even if they are
* removed from the wait queue temporarily while blocked
*/
Poco::Timestamp waitQueueStamp;
/*
* The that is currently running this job
*/
Poco::Thread* ptr_thread;
InternalJob(const Self&);
protected:
static JobManager* const ptr_manager;
IJobChangeListener::Events jobEvents;
/*
* @see Job#isBlocking()
*/
bool IsBlocking();
};
}
#endif /* BERRY_INTERNALJOB_H */
diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryJobChangeEvent.cpp b/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryJobChangeEvent.cpp
index 3ff19e819e..33a2bf2908 100644
--- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryJobChangeEvent.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryJobChangeEvent.cpp
@@ -1,43 +1,43 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryJobChangeEvent.h"
#include "berryJob.h"
namespace berry
{
JobChangeEvent::JobChangeEvent() :
delay(-1), reschedule(false)
{
}
Poco::Timestamp::TimeDiff JobChangeEvent::GetDelay() const
{
return delay;
}
Job::Pointer JobChangeEvent::GetJob() const
{
return job;
}
IStatus::Pointer JobChangeEvent::GetResult() const
{
return result;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryJobChangeEvent.h b/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryJobChangeEvent.h
index aede92c0fd..de48d1defc 100644
--- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryJobChangeEvent.h
+++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryJobChangeEvent.h
@@ -1,79 +1,79 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYJOBCHANGEEVENT_H_
#define BERRYJOBCHANGEEVENT_H_
#include "berryIJobChangeEvent.h"
namespace berry {
class JobChangeEvent : public IJobChangeEvent
{
private:
friend class JobListeners;
/**
* The job on which this event occurred.
*/
SmartPointer<Job> job;
/**
* The result returned by the job's run method, or <code>null</code> if
* not applicable.
*/
IStatus::Pointer result;
/**
* The amount of time to wait after scheduling the job before it should be run,
* or <code>-1</code> if not applicable for this type of event.
*/
Poco::Timestamp::TimeDiff delay;
/**
* Whether this job is being immediately rescheduled.
*/
bool reschedule;
public:
berryObjectMacro(JobChangeEvent)
JobChangeEvent();
/*
* Method declared on IJobChangeEvent
*/
Poco::Timestamp::TimeDiff GetDelay() const;
/*
* Method declared on IJobChangeEvent
*/
SmartPointer<Job> GetJob() const;
/* (
* Method declared on IJobChangeEvent
*/
IStatus::Pointer GetResult() const;
};
}
#endif /* BERRYJOBCHANGEEVENT_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryJobListeners.cpp b/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryJobListeners.cpp
index 63ac0b2913..15b4ae4126 100644
--- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryJobListeners.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryJobListeners.cpp
@@ -1,159 +1,159 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryJobListeners.h"
#include "berryJobManager.h"
#include "berryJob.h"
#include <berrySolsticeExceptions.h>
#include <typeinfo>
namespace berry
{
struct AboutToRunDoit: public JobListeners::IListenerDoit
{
void Notify(const IJobChangeListener::Events& events,
const IJobChangeEvent::ConstPointer event) const
{
events.jobAboutToRun(event);
}
};
struct AwakeDoit: public JobListeners::IListenerDoit
{
void Notify(const IJobChangeListener::Events& events,
const IJobChangeEvent::ConstPointer event) const
{
events.jobAwake(event);
}
};
struct DoneDoit: public JobListeners::IListenerDoit
{
void Notify(const IJobChangeListener::Events& events,
const IJobChangeEvent::ConstPointer event) const
{
events.jobDone(event);
}
};
struct RunningDoit: public JobListeners::IListenerDoit
{
void Notify(const IJobChangeListener::Events& events,
const IJobChangeEvent::ConstPointer event) const
{
events.jobRunning(event);
}
};
struct ScheduledDoit: public JobListeners::IListenerDoit
{
void Notify(const IJobChangeListener::Events& events,
const IJobChangeEvent::ConstPointer event) const
{
events.jobScheduled(event);
}
};
struct SleepingDoit: public JobListeners::IListenerDoit
{
void Notify(const IJobChangeListener::Events& events,
const IJobChangeEvent::ConstPointer event) const
{
events.jobSleeping(event);
}
};
JobListeners::JobListeners() :
aboutToRun(new AboutToRunDoit()), awake(new AwakeDoit()),
done(new DoneDoit()), running(new RunningDoit()), scheduled(
new ScheduledDoit()), sleeping(new SleepingDoit())
{
}
JobListeners::~JobListeners()
{
delete aboutToRun;
delete awake;
delete done;
delete running;
delete scheduled;
delete sleeping;
}
JobChangeEvent::Pointer JobListeners::NewEvent(Job::Pointer job)
{
JobChangeEvent::Pointer instance(new JobChangeEvent());
instance->job = job;
return instance;
}
JobChangeEvent::Pointer JobListeners::NewEvent(Job::Pointer job, IStatus::Pointer result)
{
JobChangeEvent::Pointer instance(new JobChangeEvent());
instance->job = job;
instance->result = result;
return instance;
}
JobChangeEvent::Pointer JobListeners::NewEvent(Job::Pointer job, Poco::Timestamp::TimeDiff delay)
{
JobChangeEvent::Pointer instance(new JobChangeEvent());
instance->job = job;
instance->delay = delay;
return instance;
}
void JobListeners::DoNotify(const IListenerDoit* doit,
const IJobChangeEvent::ConstPointer event)
{
//notify all global listeners
doit->Notify(global, event);
//notify all local listeners
const IJobChangeListener::Events& events =
event->GetJob().Cast<InternalJob> ()->GetListeners();
doit->Notify(events, event);
}
void JobListeners::HandleException(const std::exception& e)
{
//this code is roughly copied from InternalPlatform.run(ISafeRunnable),
//but in-lined here for performance reasons
try
{
dynamic_cast<const OperationCanceledException&> (e);
return;
} catch (const std::bad_cast&)
{
// TODO get bundle id (find a C++ way)
//std::string pluginId = JobOSGiUtils.getDefault().getBundleId(listener);
std::string pluginId;
if (pluginId.empty())
pluginId = JobManager::PI_JOBS();
std::string message = "Problems occurred when invoking code from plug-in: "
+ pluginId;
std::cerr << message << std::endl;
// TODO Logging
// RuntimeLog.log(new Status(IStatus.ERROR, pluginId, JobManager.PLUGIN_ERROR,
// message, e));
}
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryJobListeners.h b/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryJobListeners.h
index a8ee066bb5..3779694fdd 100644
--- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryJobListeners.h
+++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryJobListeners.h
@@ -1,133 +1,133 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYJOBLISTENERS_H_
#define BERRYJOBLISTENERS_H_
#include "berryJobChangeEvent.h"
#include "berryIJobChangeListener.h"
namespace berry
{
/**
* Responsible for notifying all job listeners about job lifecycle events. Uses a
* specialized iterator to ensure the complex iteration logic is contained in one place.
*/
class JobListeners
{
public:
struct IListenerDoit
{
virtual void Notify(const IJobChangeListener::Events& listener,
const IJobChangeEvent::ConstPointer event) const = 0;
virtual ~IListenerDoit() {}
};
private:
friend struct JobManager;
const IListenerDoit* aboutToRun;
const IListenerDoit* awake;
const IListenerDoit* done;
const IListenerDoit* running;
const IListenerDoit* scheduled;
const IListenerDoit* sleeping;
/**
* The global job listeners.
*/
IJobChangeListener::Events global;
/**
* TODO Could use an instance pool to re-use old event objects
*/
static JobChangeEvent::Pointer NewEvent(SmartPointer<Job> job);
static JobChangeEvent::Pointer NewEvent(SmartPointer<Job> job,
IStatus::Pointer result);
static JobChangeEvent::Pointer NewEvent(SmartPointer<Job> job, Poco::Timestamp::TimeDiff delay);
/**
* Process the given doit for all global listeners and all local listeners
* on the given job.
*/
void DoNotify(const IListenerDoit* doit,
const IJobChangeEvent::ConstPointer event);
public:
JobListeners();
~JobListeners();
void HandleException(const std::exception& e);
void Add(IJobChangeListener::Pointer listener)
{
global.AddListener(listener);
}
void Remove(IJobChangeListener::Pointer listener)
{
global.RemoveListener(listener);
}
void AboutToRun(SmartPointer<Job> job)
{
DoNotify(aboutToRun, NewEvent(job));
}
void Awake(SmartPointer<Job> job)
{
DoNotify(awake, NewEvent(job));
}
void Done(SmartPointer<Job> job, IStatus::Pointer result, bool reschedule)
{
JobChangeEvent::Pointer event = NewEvent(job, result);
event->reschedule = reschedule;
DoNotify(done, event);
}
void Running(SmartPointer<Job> job)
{
DoNotify(running, NewEvent(job));
}
void Scheduled(SmartPointer<Job> job, Poco::Timestamp::TimeDiff delay, bool reschedule)
{
JobChangeEvent::Pointer event = NewEvent(job, delay);
event->reschedule = reschedule;
DoNotify(scheduled, event);
}
void Sleeping(SmartPointer<Job> job)
{
DoNotify(sleeping, NewEvent(job));
}
};
}
#endif /* BERRYJOBLISTENERS_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryJobManager.cpp b/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryJobManager.cpp
index 944f47e10b..f38f5bdcc4 100644
--- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryJobManager.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryJobManager.cpp
@@ -1,1200 +1,1200 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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.
===================================================================*/
#define NOMINMAX
#include "berryJobManager.h"
#include "berryIProgressMonitor.h"
#include "berryNullProgressMonitor.h"
#include "berryIStatus.h"
#include "berryJobStatus.h"
#include <iostream>
#include <algorithm>
namespace berry
{
/**
* test class implementing ISchedulingRule to validate client defined rules
*/
struct NullRule: public ISchedulingRule
{
bool Contains(ISchedulingRule::Pointer myRule) const;
bool IsConflicting(ISchedulingRule::Pointer myRule) const;
};
bool NullRule::IsConflicting(ISchedulingRule::Pointer dummyRule) const
{
return dummyRule == this;
}
bool NullRule::Contains(ISchedulingRule::Pointer dummyRule) const
{
return dummyRule == this;
}
JobManager::JobManager() :
sptr_testRule(new NullRule()),m_active(true), m_Pool(new WorkerPool(this)), m_sptr_progressProvider(0),
m_JobQueueSleeping(true), m_JobQueueWaiting(false),m_suspended(false), m_waitQueueCounter(0)
{
m_JobListeners.global.SetExceptionHandler(MessageExceptionHandler<
JobListeners> (&m_JobListeners, &JobListeners::HandleException));
}
// DEBUG VARIABLES
const std::string& JobManager::PI_JOBS()
{
static std::string id("org.blueberry.core.jobs");
return id;
}
bool JobManager::DEBUG = false;
bool JobManager::DEBUG_BEGIN_END = false;
bool JobManager::DEBUG_DEADLOCK = false;
bool JobManager::DEBUG_LOCKS = false;
bool JobManager::DEBUG_TIMING = false;
bool JobManager::DEBUG_SHUTDOWN = false;
const int JobManager::PLUGIN_ERROR = 2;
JobManager*
JobManager::GetInstance()
{
// we don't need to lock the creation of "instance" because GetInstance() is
// called when statically initializing InternalJob::ptr_manager (which happens
// in single-threaded mode)
static JobManager instance;
return &instance;
}
std::string JobManager::PrintState(int state)
{
switch (state)
{
case Job::NONE:
return "NONE";
case Job::WAITING:
return "WAITING";
case Job::SLEEPING:
return "SLEEPING";
case Job::RUNNING:
return "RUNNING";
case InternalJob::BLOCKED:
return "BLOCKED";
case InternalJob::ABOUT_TO_RUN:
return "ABOUT_TO_RUN";
case InternalJob::ABOUT_TO_SCHEDULE:
return "ABOUT_TO_SCHEDULE";
}
return "UNKNOWN";
}
void JobManager::Shutdown()
{
JobManager* ptr_instance(GetInstance());
if (ptr_instance != 0)
{
ptr_instance->DoShutdown();
// ptr_instance = 0; // need to call the destructor of the static object ..
}
}
//void
//JobManager
//::Cancel(Object family) {
// //don't synchronize because cancel calls listeners
// for (Iterator it = select(family).iterator(); it.hasNext();)
// cancel((Job) it.next());
// }
IProgressMonitor::Pointer JobManager::CreateProgressGroup()
{
if (m_sptr_progressProvider != 0)
return (m_sptr_progressProvider->CreateProgressGroup());
NullProgressMonitor::Pointer sptr_defaultProgressMonitor(
new NullProgressMonitor);
return sptr_defaultProgressMonitor;
}
Job*
JobManager::CurrentJob()
{
//Poco::Thread* ptr_current = Poco::Thread::current();
//if (Worker* worker = dynamic_cast<Worker*>(ptr_current) )
// return ((Worker) ptr_current).currentJob();
// {
// Poco::ScopedLock<Poco::Mutex> lockMe (m_mutex);
// Poco::HashSet<InternalJob::Pointer, Object::Hash>::Iterator it ;
// for (it = m_running.begin(); it != m_running.end(); it ++) {
// Job job* = dynamic_cast<Job*> (it);
// if (job->GetThread() == ptr_current)
// return job;
// }
//}
return 0;
}
//void
//JobManager
//::EndRule(ISchedulingRule rule) {
//implicitJobs.end(rule, false);
// }
//Job[]
//JobManager
//::Find(Object family) {
// List members = select(family);
// return (Job[]) members.toArray(new Job[members.size()]);
// }
//
// LockManager GetLockManager() {
// return lockManager;
// }
//
bool JobManager::IsIdle()
{
{
Poco::ScopedLock<Poco::Mutex> m_managerLock(m_mutex);
return m_running.empty() && m_JobQueueWaiting.IsEmpty();
}
}
bool JobManager::IsSuspended()
{
{
Poco::ScopedLock<Poco::Mutex> m_managerLock(m_mutex);
m_suspended = true;
}
return m_suspended;
}
//
// /*
// * @see IJobManager#join(String, IProgressMonitor)
// */
//void
//JobManager
//::Join(final Object family, IProgressMonitor monitor) throws InterruptedException, OperationCanceledException {
// monitor = monitorFor(monitor);
// IJobChangeListener listener = null;
// final Set jobs;
// int jobCount;
// Job blocking = null;
// synchronized (lock) {
// //don't join a waiting or sleeping job when suspended (deadlock risk)
// int states = suspended ? Job.RUNNING : Job.RUNNING | Job.WAITING | Job.SLEEPING;
// jobs = Collections.synchronizedSet(new HashSet(select(family, states)));
// jobCount = jobs.size();
// if (jobCount > 0) {
// //if there is only one blocking job, use it in the blockage callback below
// if (jobCount == 1)
// blocking = (Job) jobs.iterator().next();
// listener = new JobChangeAdapter() {
// public void done(IJobChangeEvent event) {
// //don't remove from list if job is being rescheduled
// if (!((JobChangeEvent) event).reschedule)
// jobs.remove(event.getJob());
// }
//
// //update the list of jobs if new ones are added during the join
// public void scheduled(IJobChangeEvent event) {
// //don't add to list if job is being rescheduled
// if (((JobChangeEvent) event).reschedule)
// return;
// Job job = event.getJob();
// if (job.belongsTo(family))
// jobs.add(job);
// }
// };
// addJobChangeListener(listener);
// }
// }
// if (jobCount == 0) {
// //use up the monitor outside synchronized block because monitors call untrusted code
// monitor.beginTask(JobMessages.jobs_blocked0, 1);
// monitor.done();
// return;
// }
// //spin until all jobs are completed
// try {
// monitor.beginTask(JobMessages.jobs_blocked0, jobCount);
// monitor.subTask(NLS.bind(JobMessages.jobs_waitFamSub, Integer.toString(jobCount)));
// reportBlocked(monitor, blocking);
// int jobsLeft;
// int reportedWorkDone = 0;
// while ((jobsLeft = jobs.size()) > 0) {
// //don't let there be negative work done if new jobs have
// //been added since the join began
// int actualWorkDone = Math.max(0, jobCount - jobsLeft);
// if (reportedWorkDone < actualWorkDone) {
// monitor.worked(actualWorkDone - reportedWorkDone);
// reportedWorkDone = actualWorkDone;
// monitor.subTask(NLS.bind(JobMessages.jobs_waitFamSub, Integer.toString(jobsLeft)));
// }
// if (Thread.interrupted())
// throw new InterruptedException();
// if (monitor.isCanceled())
// throw new OperationCanceledException();
// //notify hook to service pending syncExecs before falling asleep
// lockManager.aboutToWait(null);
// Thread.sleep(100);
// }
// } finally {
// lockManager.aboutToRelease();
// removeJobChangeListener(listener);
// reportUnblocked(monitor);
// monitor.done();
// }
// }
//JobManager
//::NewLock() {
// return lockManager.newLock();
// }
void JobManager::RemoveJobChangeListener(IJobChangeListener::Pointer listener)
{
m_JobListeners.Remove(listener);
}
void JobManager::ReportBlocked(IProgressMonitor::Pointer sptr_monitor, InternalJob::Pointer sptr_blockingJob) const {
if ( sptr_monitor.Cast<IProgressMonitorWithBlocking>() == 0 )
return ;
if (sptr_blockingJob == 0 || sptr_blockingJob->IsSystem())
{
Status::Pointer sptr_reason( new Status(IStatus::INFO_TYPE, JobManager::PI_JOBS(), 1, "the user operation is waiting for background work to complete" ) );
}
else
{
std::stringstream msg ;
msg << "the user operation is waiting for : " << sptr_blockingJob->GetName() << " to complete. " ;
JobStatus::Pointer sptr_reason(new JobStatus(IStatus::INFO_TYPE, sptr_blockingJob.Cast<Job>(), msg.str() ));
}
// ((IProgressmonitorWithBlocking) sptr_monitor)->SetBlocked(sptr_reason);
}
void JobManager::ReportUnblocked(IProgressMonitor::Pointer sptr_monitor) const {
if ( IProgressMonitorWithBlocking::Pointer sptr_monitorWithBlocking = sptr_monitor.Cast<IProgressMonitorWithBlocking>() )
sptr_monitorWithBlocking->ClearBlocked();
}
void JobManager::Resume()
{
{
Poco::ScopedLock<Poco::Mutex> lockMe(m_mutex);
m_suspended = false;
//poke the job pool
m_Pool->JobQueued();
}
}
//TODO implicit Jobs
//void
//JobManager
//::Resume(ISchedulingRule rule)const {
// implicitJobs.resume(rule);
// }
void JobManager::SetProgressProvider(ProgressProvider::Pointer provider)
{
m_sptr_progressProvider = provider;
}
void JobManager::SetRule(InternalJob::Pointer job,
ISchedulingRule::Pointer sptr_rule)
{
Poco::ScopedLock<Poco::Mutex> m_managerLock(m_mutex);
//cannot change the rule of a job that is already running ( GetRule is set to protected which should be
// changed if this assert is needed
// assert(job->GetState() == Job.NONE);
ValidateRule(sptr_rule);
job->InternalSetRule(sptr_rule);
}
//void
//JobManager
//::Sleep(Object family) {
// //don't synchronize because sleep calls listeners
// for (Iterator it = select(family).iterator(); it.hasNext();) {
// sleep((InternalJob) it.next());
// }
// }
void JobManager::Suspend()
{
{
Poco::ScopedLock<Poco::Mutex> lockMe(m_mutex);
m_suspended = true;
}
}
//void
//JobManager
//::Suspend(ISchedulingRule rule, IProgressMonitor monitor)const {
// Assert.isNotNull(rule);
// implicitJobs.suspend(rule, monitorFor(monitor));
// }
//void
//JobManager
//::TransferRule(ISchedulingRule rule, Thread destinationThread) {
// implicitJobs.transfer(rule, destinationThread);
// }
//void
//JobManager
//::SetLockListener(LockListener listener) {
// lockManager.setLockListener(listener);
// }
//void
//JobManager
//::WakeUp(Object family) {
// //don't synchronize because wakeUp calls listeners
// for (Iterator it = select(family).iterator(); it.hasNext();) {
// wakeUp((InternalJob) it.next(), 0L);
// }
// }
void JobManager::AddJobChangeListener(IJobChangeListener::Pointer listener)
{
m_JobListeners.Add(listener);
}
//void
//JobManager
//::BeginRule(ISchedulingRule rule, IProgressMonitor monitor) {
// validateRule(rule);
// implicitJobs.begin(rule, monitorFor(monitor), false);
// }
//
// /**
// * For debugging purposes only
// */
//std::String
//JobManager
//::PrintJobName(Job job) {
// if (job instanceof ThreadJob) {
// Job realJob = ((ThreadJob) job).realJob;
// if (realJob != null)
// return realJob.getClass().getName();
// return "ThreadJob on rule: " + job.getRule(); //$NON-NLS-1$
// }
// return job.getClass().getName();
// }
//
// instance = this;
// initDebugOptions();
// synchronized (lock) {
// running = new HashSet(10);
// }
// pool.setDaemon(JobOSGiUtils.getDefault().useDaemonThreads());
//}
void JobManager::ChangeState(InternalJob::Pointer sptr_job, int newState)
{
bool blockedJobs = false;
{
Poco::ScopedLock<Poco::Mutex> m_managerLock(m_mutex);
int tmp_oldState = sptr_job->InternalGetState();
switch (tmp_oldState)
{
case Job::NONE:
case InternalJob::ABOUT_TO_SCHEDULE:
break;
case InternalJob::BLOCKED:
//remove this job from the linked list of blocked jobs
sptr_job->Remove();
break;
case Job::WAITING:
m_JobQueueWaiting.Remove(sptr_job);
// assert(false, "Tried to remove a job that wasn't in the queue");
break;
case Job::SLEEPING:
m_JobQueueSleeping.Remove(sptr_job);
// assert(false, "Tried to remove a job that wasn't in the queue");
case Job::RUNNING:
case InternalJob::ABOUT_TO_RUN:
m_running.erase(sptr_job);
//add any blocked jobs back to the wait queue
InternalJob::Pointer sptr_blocked(sptr_job->Previous());
sptr_job->Remove();
blockedJobs = sptr_blocked != 0;
while (sptr_blocked != 0)
{
InternalJob::Pointer previous = sptr_blocked->Previous();
ChangeState(sptr_blocked, Job::WAITING);
sptr_blocked = previous;
}
break;
// default :
// Assert.isLegal(false, "Invalid job state: " + job + ", state: " + oldState);
}
sptr_job->InternalSetState(newState);
switch (newState)
{
case Job::NONE:
sptr_job->SetStartTime(InternalJob::T_NONE);
sptr_job->SetWaitQueueStamp(InternalJob::T_NONE);
case InternalJob::BLOCKED:
break;
case Job::WAITING:
m_JobQueueWaiting.Enqueue(sptr_job);
break;
case Job::SLEEPING:
//try {
m_JobQueueSleeping.Enqueue(sptr_job);
//} catch (RuntimeException e) {
// throw new RuntimeException("Error changing from state: " + oldState);
//}
break;
case Job::RUNNING:
case InternalJob::ABOUT_TO_RUN:
sptr_job->SetStartTime(InternalJob::T_NONE);
sptr_job->SetWaitQueueStamp(InternalJob::T_NONE);
m_running.insert(sptr_job);
break;
case InternalJob::ABOUT_TO_SCHEDULE:
break;
// default :
// Assert.isLegal(false, "Invalid job state: " + job + ", state: " + newState);
}
}
//notify queue outside sync block
if (blockedJobs)
m_Pool->JobQueued();
}
Poco::Timestamp::TimeDiff JobManager::DelayFor(int priority)
{
//these values may need to be tweaked based on machine speed
switch (priority)
{
case Job::INTERACTIVE:
return 0;
case Job::SHORT:
return 50;
case Job::LONG:
return 100;
case Job::BUILD:
return 500;
case Job::DECORATE:
return 1000;
default:
// Assert.isTrue(false, "Job has invalid priority: " + priority); //$NON-NLS-1$
return 0;
}
}
void JobManager::DoSchedule(InternalJob::Pointer job,
Poco::Timestamp::TimeDiff delay)
{
Poco::ScopedLock<Poco::Mutex> managerLock(m_mutex);
//job may have been canceled already
int state = job->InternalGetState();
if (state != InternalJob::ABOUT_TO_SCHEDULE && state != Job::SLEEPING)
return;
//if it's a decoration job with no rule, don't run it right now if the system is busy
if (job->GetPriority() == Job::DECORATE && job->GetRule() == 0)
{
Poco::Timestamp::TimeDiff tmp_minDelay = m_running.size() * 100;
delay = std::max(delay, tmp_minDelay);
}
if (delay > 0)
{
job->SetStartTime(Poco::Timestamp() + delay * 100);
InternalJob::Pointer sptr_job(job);
ChangeState(sptr_job, Job::SLEEPING);
}
else
{
job->SetStartTime(Poco::Timestamp() + DelayFor(job->GetPriority()) * 100);
job->SetWaitQueueStamp(m_waitQueueCounter++);
InternalJob::Pointer sptr_job(job);
ChangeState(sptr_job, Job::WAITING);
}
}
void JobManager::DoShutdown()
{
std::vector<InternalJob::Pointer> vec_ToCancel;
{
Poco::ScopedLock<Poco::Mutex> LockMe(m_mutex);
if (m_active)
{
m_active = false;
//cancel all running jobs
vec_ToCancel.assign(m_running.begin(), m_running.end());
//clean up
m_JobQueueSleeping.Clear();
m_JobQueueWaiting.Clear();
m_running.clear();
}
}
// Give running jobs a chance to finish. Wait 0.1 seconds for up to 3 times.
if (!vec_ToCancel.empty())
{
for (std::size_t i = 0; i < vec_ToCancel.size(); i++)
{
// cancel jobs outside sync block to avoid deadlock
Cancel(vec_ToCancel[i]);
}
for (int waitAttempts = 0; waitAttempts < 3; waitAttempts++)
{
Poco::Thread::yield();
{
Poco::ScopedLock<Poco::Mutex> LockMe(m_mutex);
if (m_running.empty())
break;
}
if (DEBUG_SHUTDOWN)
{
// JobManager.debug("Shutdown - job wait cycle #" + (waitAttempts + 1));
std::vector<InternalJob::Pointer> vec_StillRunning;
{
Poco::ScopedLock<Poco::Mutex> LockMe(m_mutex);
vec_StillRunning.assign(m_running.begin(), m_running.end());
// if (!vec_StillRunning.empty()) {
//for (int j = 0; j < stillRunning.length; j++) {
// JobManager.debug("\tJob: " + printJobName(stillRunning[j])); //$NON-NLS-1$
//}
}
}
Poco::Thread::sleep(100);
Poco::Thread::yield();
}
// retrieve list of the jobs that are still running
{
Poco::ScopedLock<Poco::Mutex> LockMe(m_mutex);
vec_ToCancel.assign(m_running.begin(), m_running.end());
}
}
if (!vec_ToCancel.empty())
{
/*for (int i = 0; i < vec_ToCancel.size(); i++) {*/
// std::string tmp_jobName = PrintJobName(toCancel[i]);
// //this doesn't need to be translated because it's just being logged
// String msg = "Job found still running after platform shutdown. Jobs should be canceled by the plugin that
// scheduled them during shutdown: " + jobName;
// RuntimeLog.log(new Status(IStatus.WARNING, JobManager.PI_JOBS, JobManager.PLUGIN_ERROR, msg, null));
//
// // TODO the RuntimeLog.log in its current implementation won't produce a log
// // during this stage of shutdown. For now add a standard error output.
// // One the logging story is improved, the System.err output below can be removed:
// System.err.println(msg);
// }
}
m_Pool->Shutdown();
}
Job::Pointer JobManager::NextJob()
{
{
Poco::ScopedLock<Poco::Mutex> managerLock(m_mutex);
//do nothing if the job manager is suspended
if (m_suspended)
return Job::Pointer(0);
// tickle the sleep queue to see if anyone wakes up
Poco::Timestamp now;
InternalJob::Pointer ptr_job = m_JobQueueSleeping.Peek();
while (ptr_job != 0 && ptr_job->GetStartTime() < now)
{
// a job that slept to long is set a new start time and is put into the waiting queue
ptr_job->SetStartTime(now + DelayFor(ptr_job->GetPriority()));
ptr_job->SetWaitQueueStamp(m_waitQueueCounter++);
InternalJob::Pointer sptr_job(ptr_job);
ChangeState(sptr_job, Job::WAITING);
ptr_job = m_JobQueueSleeping.Peek();
}
//process the wait queue until we find a job whose rules are satisfied.
while ((ptr_job = m_JobQueueWaiting.Peek()) != 0)
{
InternalJob::Pointer sptr_job(ptr_job);
InternalJob::Pointer sptr_blocker = FindBlockingJob(sptr_job);
if (sptr_blocker == 0)
break;
//queue this job after the job that's blocking it
ChangeState(sptr_job, InternalJob::BLOCKED);
//assert job does not already belong to some other data structure
//Assert.isTrue(job.next() == null);
//Assert.isTrue(job.previous() == null);
sptr_blocker->AddLast(ptr_job);
}
// the job to run must be in the running list before we exit
// the sync block, otherwise two jobs with conflicting rules could start at once
if (ptr_job != 0)
{
InternalJob::Pointer sptr_job(ptr_job);
ChangeState(sptr_job, InternalJob::ABOUT_TO_RUN);
}
return ptr_job.Cast<Job> ();
}
}
//TODO Job families
//void
//JobManager
//::Select(List members, Object family, InternalJob firstJob, int stateMask) {
// if (firstJob == null)
// return;
// InternalJob job = firstJob;
// do {
// //note that job state cannot be NONE at this point
// if ((family == null || job.belongsTo(family)) && ((job.getState() & stateMask) != 0))
// members.add(job);
// job = job.previous();
// } while (job != null && job != firstJob);
// }
//List
//JobManager
//::Select(Object family) {
// return select(family, Job.WAITING | Job.SLEEPING | Job.RUNNING);
// }
//List
//JobManager
//::Select(Object family, int stateMask) {
// List members = new ArrayList();
// synchronized (lock) {
// if ((stateMask & Job.RUNNING) != 0) {
// for (Iterator it = running.iterator(); it.hasNext();) {
// select(members, family, (InternalJob) it.next(), stateMask);
// }
// }
// if ((stateMask & Job.WAITING) != 0)
// select(members, family, waiting.peek(), stateMask);
// if ((stateMask & Job.SLEEPING) != 0)
// select(members, family, sleeping.peek(), stateMask);
// }
// return members;
// }
// dummy validateRule implemenation
void JobManager::ValidateRule(ISchedulingRule::Pointer sptr_rule)
{
//null rule always valid
if (sptr_rule == 0)
return;
//contains method must be reflexive
poco_assert(sptr_rule->Contains(sptr_rule))
; //contains method must return false when given an unknown rule
poco_assert(!sptr_rule->Contains(sptr_testRule));
//isConflicting method must be reflexive
poco_assert(sptr_rule->IsConflicting(sptr_rule));
//isConflicting method must return false when given an unknown rule
poco_assert(!sptr_rule->IsConflicting(sptr_testRule));
}
bool JobManager::Cancel(InternalJob::Pointer sptr_job)
{
IProgressMonitor::Pointer sptr_progressMonitor(0);
bool runCanceling = false;
{
Poco::ScopedLock<Poco::Mutex> mangerMutex (m_mutex);
switch (sptr_job->GetState())
{
case Job::NONE :
return true;
case Job::RUNNING :
//cannot cancel a job that has already started (as opposed to ABOUT_TO_RUN)
if (sptr_job->InternalGetState() == Job::RUNNING)
{
sptr_progressMonitor = sptr_job->GetProgressMonitor();
runCanceling = sptr_job->IsRunCanceled();
if(runCanceling)
sptr_job->SetRunCanceled(true);
break ;
}
//signal that the job should be canceled before it gets a chance to run
sptr_job->SetAboutToRunCanceled(true);
return false;
default :
ChangeState(sptr_job, Job::NONE);
}
}
//call monitor outside sync block
if (sptr_progressMonitor != 0)
{
if(runCanceling)
{
if (!sptr_progressMonitor->IsCanceled())
sptr_progressMonitor->SetCanceled(true);
sptr_job->Canceling();
}
return false;
}
//only notify listeners if the job was waiting or sleeping
m_JobListeners.Done(sptr_job.Cast<Job>(), Status::CANCEL_STATUS, false);
return true;
}
IProgressMonitor::Pointer JobManager::CreateMonitor(
Job::Pointer sptr_jobToMonitor)
{
IProgressMonitor::Pointer sptr_monitor(0);
if (m_sptr_progressProvider != 0)
sptr_monitor = m_sptr_progressProvider->CreateMonitor(sptr_jobToMonitor);
if (sptr_monitor == 0)
{
NullProgressMonitor::Pointer sptr_defaultMonitor(new NullProgressMonitor());
return sptr_defaultMonitor;
}
return sptr_monitor ;
}
IProgressMonitor::Pointer JobManager::CreateMonitor(InternalJob::Pointer sptr_job, IProgressMonitor::Pointer group, int ticks)
{
{
Poco::ScopedLock<Poco::Mutex> managerLock(m_mutex);
//group must be set before the job is scheduled
//this includes the ABOUT_TO_SCHEDULE state, during which it is still
//valid to set the progress monitor
if (sptr_job->GetState() != Job::NONE)
{
IProgressMonitor::Pointer dummy(0);
return dummy;
}
IProgressMonitor::Pointer sptr_monitor(0);
if (m_sptr_progressProvider != 0)
sptr_monitor = m_sptr_progressProvider->CreateMonitor(sptr_job.Cast<Job>() , group, ticks);
if (sptr_monitor == 0)
{
// return a default NullprogressMonitor
NullProgressMonitor::Pointer sptr_defaultMonitor(new NullProgressMonitor() );
return sptr_defaultMonitor;
}
return sptr_monitor;
}
}
void JobManager::EndJob(InternalJob::Pointer ptr_job, IStatus::Pointer result, bool notify)
{
Poco::Timestamp::TimeDiff rescheduleDelay(InternalJob::T_NONE);
{
Poco::ScopedLock<Poco::Mutex> lock ( m_mutex);
// if the job is finishing asynchronously, there is nothing more to do for now
if (result == Job::ASYNC_FINISH)
return;
//if job is not known then it cannot be done
if (ptr_job->GetState() == Job::NONE)
return;
ptr_job->SetResult(result);
ptr_job->SetProgressMonitor(IProgressMonitor::Pointer(0));
ptr_job->SetThread(0);
rescheduleDelay = ptr_job->GetStartTime().epochMicroseconds();
InternalJob::Pointer sptr_job(ptr_job);
ChangeState(sptr_job, Job::NONE);
}
//notify listeners outside sync block
bool reschedule = m_active && rescheduleDelay > InternalJob::T_NONE && ptr_job->ShouldSchedule();
if (notify)
m_JobListeners.Done(ptr_job.Cast<Job>(), result, reschedule);
//reschedule the job if requested and we are still active
if (reschedule)
Schedule(ptr_job, rescheduleDelay, reschedule);
}
InternalJob::Pointer JobManager::FindBlockingJob(InternalJob::Pointer waitingJob)
{
if (waitingJob->GetRule() == 0)
return InternalJob::Pointer(0);
{
Poco::ScopedLock<Poco::Mutex> managerLock (m_mutex);
if (m_running.empty() )
{
InternalJob::Pointer dummy;
return (dummy);
}
//check the running jobs
bool hasBlockedJobs = false;
Poco::HashSet<InternalJob::Pointer, Object::Hash>::Iterator it;
for ( it = m_running.begin(); it != m_running.end(); it ++ )
{
InternalJob::Pointer sptr_job = *it ++;
if (waitingJob->IsConflicting(sptr_job))
return sptr_job;
if (!hasBlockedJobs)
hasBlockedJobs = sptr_job->Previous() != 0;
}
// there are no blocked jobs, so we are done
if (!hasBlockedJobs)
{
InternalJob::Pointer dummy;
return (dummy);
}
//check all jobs blocked by running jobs
Poco::HashSet<InternalJob::Pointer, Object::Hash>::Iterator it_blocked;
for( it_blocked = m_running.begin(); it_blocked != m_running.end(); it_blocked ++ )
{
InternalJob::Pointer sptr_job = *it_blocked ++;
while (true)
{
sptr_job = sptr_job->Previous();
if (sptr_job == 0)
break;
if (waitingJob->IsConflicting(sptr_job))
return sptr_job;
}
}
}
InternalJob::Pointer sptr_null;
return (sptr_null);
}
bool JobManager::IsActive()
{
return m_active;
}
bool JobManager::IsBlocking(InternalJob::Pointer sptr_runningJob)
{
{
Poco::ScopedLock<Poco::Mutex> lockMe (m_mutex);
// if this job isn't running, it can't be blocking anyone
if (sptr_runningJob->GetState() != Job::RUNNING)
return false;
// if any job is queued behind this one, it is blocked by it
InternalJob::Pointer ptr_previous = sptr_runningJob->Previous();
while (ptr_previous != 0)
{
// ignore jobs of lower priority (higher priority value means lower priority)
if (ptr_previous->GetPriority() < sptr_runningJob->GetPriority())
{
if (!ptr_previous->IsSystem())
return true;
// TODO Implicit Jobs
// implicit jobs should interrupt unless they act on behalf of system jobs
// if (previous instanceof ThreadJob && ((ThreadJob) previous).shouldInterrupt())
// return true;
}
ptr_previous = ptr_previous->previous;
}
// none found
return false;
}
}
//void
//JobManager
//::Join(InternalJob job) {
// final IJobChangeListener listener;
// final Semaphore barrier;
// synchronized (lock) {
// int state = job.getState();
// if (state == Job.NONE)
// return;
// //don't join a waiting or sleeping job when suspended (deadlock risk)
// if (suspended && state != Job.RUNNING)
// return;
// //it's an error for a job to join itself
// if (state == Job.RUNNING && job.getThread() == Thread.currentThread())
// throw new IllegalStateException("Job attempted to join itself"); //$NON-NLS-1$
// //the semaphore will be released when the job is done
// barrier = new Semaphore(null);
// listener = new JobChangeAdapter() {
// public void done(IJobChangeEvent event) {
// barrier.release();
// }
// };
// job.addJobChangeListener(listener);
// //compute set of all jobs that must run before this one
// //add a listener that removes jobs from the blocking set when they finish
// }
// //wait until listener notifies this thread.
// try {
// while (true) {
// //notify hook to service pending syncExecs before falling asleep
// lockManager.aboutToWait(job.getThread());
// try {
// if (barrier.acquire(Long.MAX_VALUE))
// break;
// } catch (InterruptedException e) {
// //loop and keep trying
// }
// }
// } finally {
// lockManager.aboutToRelease();
// job.removeJobChangeListener(listener);
// }
// }
bool JobManager::RunNow(InternalJob::Pointer sptr_job)
{
{
Poco::ScopedLock<Poco::Mutex> lockMe (m_mutex);
//cannot start if there is a conflicting job
if (FindBlockingJob(sptr_job) != 0)
return false;
ChangeState(sptr_job, Job::RUNNING);
sptr_job->SetProgressMonitor(IProgressMonitor::Pointer(new NullProgressMonitor()));
sptr_job->Run(IProgressMonitor::Pointer(0));
}
return true;
}
void JobManager::Schedule(InternalJob::Pointer job, Poco::Timestamp::TimeDiff delay, bool reschedule)
{
if (!m_active)
throw Poco::IllegalStateException("Job manager has been shut down.");
poco_assert(job); // "Job is null"
poco_assert(delay >= 0); // "Scheduling delay is negative"
{
Poco::ScopedLock<Poco::Mutex> managerLock (m_mutex);
//if the job is already running, set it to be rescheduled when done
if (job->GetState() == Job::RUNNING)
{
job->SetStartTime(delay);
return;
}
//can't schedule a job that is waiting or sleeping
if (job->InternalGetState() != Job::NONE)
return;
//remember that we are about to schedule the job
//to prevent multiple schedule attempts from succeeding (bug 68452)
InternalJob::Pointer sptr_job(job);
ChangeState(sptr_job, InternalJob::ABOUT_TO_SCHEDULE);
}
//notify listeners outside sync block
m_JobListeners.Scheduled(job.Cast<Job>(), delay, reschedule);
//schedule the job
DoSchedule(job, delay);
//call the pool outside sync block to avoid deadlock
m_Pool->JobQueued();
}
bool JobManager::Sleep(InternalJob::Pointer job)
{
{
Poco::ScopedLock<Poco::Mutex> lockMe (m_mutex);
InternalJob::Pointer sptr_job(job);
switch (job->GetState())
{
case Job::RUNNING :
//cannot be paused if it is already running (as opposed to ABOUT_TO_RUN)
if (job->InternalGetState() == Job::RUNNING)
return false;
//job hasn't started running yet (aboutToRun listener)
break;
case Job::SLEEPING :
//update the job wake time
job->SetStartTime(InternalJob::T_INFINITE);
//change state again to re-shuffle the sleep queue
ChangeState(sptr_job, Job::SLEEPING);
return true;
case Job::NONE :
return true;
case Job::WAITING :
//put the job to sleep
break;
}
job->SetStartTime(InternalJob::T_INFINITE);
ChangeState(sptr_job, Job::SLEEPING);
}
m_JobListeners.Sleeping(job.Cast<Job>());
return true;
}
void JobManager::SetPriority(InternalJob::Pointer job, int newPriority)
{
{
Poco::ScopedLock<Poco::Mutex> lockMe (m_mutex);
InternalJob::Pointer sptr_job(job);
int oldPriority = job->GetPriority();
if (oldPriority == newPriority)
return;
job->InternalSetPriority(newPriority);
//if the job is waiting to run, re-shuffle the queue
if (sptr_job->GetState() == Job::WAITING)
{
Poco::Timestamp oldStart = job->GetStartTime();
job->SetStartTime(oldStart += (DelayFor(newPriority) - DelayFor(oldPriority)));
m_JobQueueWaiting.Resort(job);
}
}
}
Poco::Timespan::TimeDiff JobManager::SleepHint()
{
Poco::ScopedLock<Poco::Mutex> managerLock (m_mutex);
// wait forever if job manager is suspended
if (m_suspended)
return InternalJob::T_INFINITE;
if (!m_JobQueueWaiting.IsEmpty())
return 0;
// return the anticipated time that the next sleeping job will wake
InternalJob::Pointer ptr_next(0);
ptr_next = m_JobQueueSleeping.Peek();
if (ptr_next == 0)
return InternalJob::T_INFINITE;
Poco::Timestamp tmp_startTime = ptr_next->GetStartTime();
Poco::Timestamp tmp_currentTime;
Poco::Timestamp::TimeDiff timeToStart = tmp_startTime - tmp_currentTime;
return timeToStart;
}
Job::Pointer JobManager::StartJob()
{
Job::Pointer job(0);
while (true)
{
job = NextJob();
if (!job)
return Job::Pointer(0);
//must perform this outside sync block because it is third party code
bool shouldRun = job->ShouldRun();
//check for listener veto
if (shouldRun)
m_JobListeners.AboutToRun(job);
//listeners may have canceled or put the job to sleep
bool endJob = false;
{
Poco::ScopedLock<Poco::Mutex> lock(m_mutex);
InternalJob::Pointer internal = job;
if (internal->InternalGetState() == InternalJob::ABOUT_TO_RUN)
{
if (shouldRun && !internal->IsAboutToRunCanceled())
{
internal->SetProgressMonitor(CreateMonitor(job));
//change from ABOUT_TO_RUN to RUNNING
internal->InternalSetState(Job::RUNNING);
break;
}
internal->SetAboutToRunCanceled(false);
endJob = true;
//fall through and end the job below
}
}
if (endJob)
{
//job has been vetoed or canceled, so mark it as done
EndJob(job,Status::CANCEL_STATUS, true);
continue;
}
}
m_JobListeners.Running(job);
return job;
}
void JobManager::WakeUp(InternalJob::Pointer job, Poco::Timestamp::TimeDiff delay)
{
poco_assert(delay >= 0); // "Scheduling delay is negative"
{
Poco::ScopedLock<Poco::Mutex> m_managerLock (m_mutex);
//cannot wake up if it is not sleeping
if (job->GetState() != Job::SLEEPING)
return;
DoSchedule(job, delay);
}
//call the pool outside sync block to avoid deadlock
m_Pool->JobQueued();
/// IListenerExtension only notify of wake up if immediate
if (delay == 0)
m_JobListeners.Awake(job.Cast<Job>());
}
IProgressMonitor::Pointer JobManager::MonitorFor(IProgressMonitor::Pointer sptr_monitor)
{
if(sptr_monitor == 0 || sptr_monitor.Cast<NullProgressMonitor>() )
{
if(m_sptr_progressProvider != 0 )
sptr_monitor = m_sptr_progressProvider->GetDefaultMonitor();
}
if(sptr_monitor == 0)
{
IProgressMonitor::Pointer sptr_nullProgressMonitor(new NullProgressMonitor());
return sptr_nullProgressMonitor;
}
return sptr_monitor;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryJobManager.h b/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryJobManager.h
index 9832f47a29..539c9f8aec 100644
--- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryJobManager.h
+++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryJobManager.h
@@ -1,434 +1,434 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 _BERRY_JOBMANAGER_H
#define _BERRY_JOBMANAGER_H
#include "berryInternalJob.h"
#include "berryJobQueue.h"
#include "berryWorkerPool.h"
#include "berryJobListeners.h"
#include "berryJob.h"
#include "berryIProgressMonitorWithBlocking.h"
#include "berryIJobManager.h"
#include "berryISchedulingRule.h"
#include <org_blueberry_core_jobs_Export.h>
#include <Poco/Mutex.h>
#include <Poco/ScopedLock.h>
#include <Poco/HashSet.h>
#include <Poco/Timestamp.h>
#include <Poco/Timespan.h>
#include <string>
#include <sstream>
#include <assert.h>
namespace berry
{
/**
* Implementation of API type IJobManager
*
* Implementation note: all the data structures of this class are protected
* by a single lock object held as a private field in this class. The JobManager
* instance itself is not used because this class is publicly reachable, and third
* party clients may try to synchronize on it.
*
* The WorkerPool class uses its own monitor for synchronizing its data
* structures. To avoid deadlock between the two classes, the JobManager
* must NEVER call the worker pool while its own monitor is held.
*/
struct BERRY_JOBS JobManager: public IJobManager
{
public:
friend class WorkerPool;
friend struct InternalJob;
friend struct NullRule;
berryObjectMacro(JobManager)
/**
* The unique identifier constant of this plug-in.
*/
static const std::string& PI_JOBS();
static bool DEBUG;
static bool DEBUG_BEGIN_END;
static bool DEBUG_DEADLOCK;
static bool DEBUG_LOCKS;
static bool DEBUG_TIMING;
static bool DEBUG_SHUTDOWN;
/**
* Status code constant indicating an error occurred while running a plug-in.
* For backward compatibility with Platform.PLUGIN_ERROR left at (value = 2).
*/
static const int PLUGIN_ERROR;
/// const ImplicitJobs iImplicitJobs = new ImplicitJobs(this);
/**
* The singleton job manager instance. It must be a singleton because
* all job instances maintain a reference (as an optimization) and have no way
* of updating it.
*/
static JobManager* GetInstance();
/**
* For debugging purposes only
*/
static std::string PrintState(int state);
/**
* Note that although this method is not API, clients have historically used
* it to force jobs shutdown in cases where OSGi shutdown does not occur.
* For this reason, this method should be considered near-API and should not
* be changed if at all possible.
*/
static void Shutdown();
// void Cancel(Object family) ;
IProgressMonitor::Pointer CreateProgressGroup();
Job* CurrentJob();
// void EndRule(ISchedulingRule rule) ;
// Job[] Find(Object family) ;
// LockManager GetLockManager() {
// return lockManager;
// }
bool IsIdle();
bool IsSuspended();
// void Join(final Object family, IProgressMonitor monitor) throws InterruptedException, OperationCanceledException );
// ILock NewLock() ;
/**
* @see IJobManager#RemoveChangeListener(IJobChangeListener::Pointer)
*/
void RemoveJobChangeListener(IJobChangeListener::Pointer listener);
// /**
//* report to the progress monitor that this thread is blocked, supplying
//* an information message, and if possible the job that is causing the blockage.
//* important: an invocation of this method must be followed eventually be
//* an invocation of ReportUnblocked.
//* @param monitor the monitor to report blocking to
//* @param BlockingJob the job that is blocking this thread, or <code>null</code>
//* @see #Reportunblocked
//*/
void ReportBlocked( IProgressMonitor::Pointer monitor, InternalJob::Pointer blockingjob) const ;
/**
* Reports that this thread was blocked, but is no longer blocked and is able
* to proceed.
* @param monitor The monitor to report unblocking to.
* @see #ReportBlocked
*/
void ReportUnblocked(IProgressMonitor::Pointer monitor) const ;
/**
* @have a look at IJobManager Resume
*/
void Resume();
// /**
// * @have a look at IJobManager Resume
// */
// void Resume(ISchedulingRule::Pointer rule)const ;
/**
* @have a look at IJobManager SetProgressProvider
*/
void SetProgressProvider(ProgressProvider::Pointer provider);
void SetRule(InternalJob::Pointer job, ISchedulingRule::Pointer rule);
// /*
// * @see IJobManager#sleep(std::string)
// */
// void Sleep(Object family) ;
void Suspend();
/*
* @see schedule(long)
*/
void Schedule(InternalJob::Pointer job, Poco::Timestamp::TimeDiff delay, bool reschedule);
// void Suspend(ISchedulingRule::Pointer rule, IProgressMonitor::Pointer monitor)const ;
// void TransferRule(ISchedulingRule rule, Thread destinationThread) ;
// void SetLockListener(LockListener listener) ;
// /**
// * Puts a job to sleep. Returns true if the job was successfully put to sleep.
// */
// void WakeUp(Object family) ;
void AddJobChangeListener(IJobChangeListener::Pointer listener);
// void beginRule(ISchedulingRule rule, IProgressMonitor monitor) ;
protected:
/**
* Cancels a job
*/
bool Cancel(InternalJob::Pointer job);
/**
* Returns a new progress monitor for this job, belonging to the given
* progress group. Returns null if it is not a valid time to set the job's group.
*/
IProgressMonitor::Pointer CreateMonitor(InternalJob::Pointer job,
IProgressMonitor::Pointer group, int ticks);
/**
* Indicates that a job was running, and has now finished. Note that this method
* can be called under OutOfMemoryError conditions and thus must be paranoid
* about allocating objects.
*/
/// optional Extension IStatus for implementation help have a look at the Java JobAPI
void EndJob(InternalJob::Pointer job,IStatus::Pointer result, bool notify);
/**
* Returns a running or blocked job whose scheduling rule conflicts with the
* scheduling rule of the given waiting job. Returns null if there are no
* conflicting jobs. A job can only run if there are no running jobs and no blocked
* jobs whose scheduling rule conflicts with its rule.
*/
InternalJob::Pointer FindBlockingJob(InternalJob::Pointer waitingJob);
/**
* Returns whether the job manager is active (has not been shutdown).
*/
bool IsActive();
/**
* Returns true if the given job is blocking the execution of a non-system
* job.
*/
bool IsBlocking(InternalJob::Pointer runningJob);
// void Join(InternalJob job) ;
/**
* Attempts to immediately start a given job. Returns true if the job was
* successfully started, and false if it could not be started immediately
* due to a currently running job with a conflicting rule. Listeners will never
* be notified of jobs that are run in this way.
*/
bool RunNow(InternalJob::Pointer sptr_job);
/**
* Puts a job to sleep. Returns true if the job was successfully put to sleep.
*/
bool Sleep(InternalJob::Pointer job);
/**
* Changes a job priority.
*/
void SetPriority(InternalJob::Pointer job, int newPriority);
/**
* Returns the estimated time in milliseconds before the next job is scheduled
* to wake up. The result may be negative. Returns InternalJob.T_INFINITE if
* there are no sleeping or waiting jobs.
*/
Poco::Timespan::TimeDiff SleepHint();
/**
* Returns the next job to be run, or null if no jobs are waiting to run.
* The worker must call endJob when the job is finished running.
*/
Job::Pointer StartJob();
/*
* @see Job#WakeUp(long)
*/
void WakeUp(InternalJob::Pointer job, Poco::Timestamp::TimeDiff delay);
private:
JobManager();
/* Poco Mutex for synchronizing purposes */
Poco::Mutex m_mutex;
// Dummy Null rule to validate SchedulingRules implemented by clients
SmartPointer<ISchedulingRule> sptr_testRule;
// //ToDO static const ISchedulingRule nullRule = new ISchedulingRule() {
// public bool Contains(ISchedulingRule rule) ;
// public boolean IsConflicting(ISchedulingRule rule) ;
/**
* True if this manager is active, and false otherwise. A job manager
* starts out active, and becomes inactive if it has been shutdown
* and not restarted.
*/
volatile bool m_active;
JobListeners m_JobListeners;
//
// /**
// * The lock for synchronizing all activity in the job manager. To avoid deadlock,
// * this lock must never be held for extended periods, and must never be
// * held while third party code is being called.
// */
// // private final Object lock = new Object();
// static const Object lock ;
//
// //private LockManager lockManager = new LockManager();
// static const LockManger lockManager;
/**
* The pool of worker threads.
*/
WorkerPool::Pointer m_Pool;
ProgressProvider::Pointer m_sptr_progressProvider;
/**
* Jobs that are currently running. Should only be modified from changeState
*/
Poco::HashSet<InternalJob::Pointer, Object::Hash> m_running;
/**
* Jobs that are sleeping. Some sleeping jobs are scheduled to wake
* up at a given start time, while others will sleep indefinitely until woken.
* Should only be modified from changeState
*/
JobQueue m_JobQueueSleeping;
/**
* jobs that are waiting to be run. Should only be modified from changeState
*/
JobQueue m_JobQueueWaiting;
/**
* True if this manager has been suspended, and false otherwise. A job manager
* starts out not suspended, and becomes suspended when <code>suspend</code>
* is invoked. Once suspended, no jobs will start running until <code>resume</code>
* is cancelled.
*/
bool m_suspended;
/**
* Counter to record wait queue insertion order.
*/
long long m_waitQueueCounter;
// /**
// * For debugging purposes only
// */
// const std::string PrintJobName(Job job);
/**
* Atomically updates the state of a job, adding or removing from the
* necessary queues or sets.
*/
void ChangeState(InternalJob::Pointer job, int newState);
/**
* Returns a new progress monitor for this job. Never returns null.
*/
IProgressMonitor::Pointer CreateMonitor(Job::Pointer sptr_jobToMonitor);
/**
* Returns the delay in milliseconds that a job with a given priority can
* tolerate waiting.
*/
Poco::Timestamp::TimeDiff DelayFor(int priority);
/**
* Performs the scheduling of a job. Does not perform any notifications.
*/
void DoSchedule(InternalJob::Pointer job, Poco::Timestamp::TimeDiff delay);
/**
* Shuts down the job manager. Currently running jobs will be told
* to stop, but worker threads may still continue processing.
* (note: This implemented IJobManager.Shutdown which was removed
* due to problems caused by premature shutdown)
*/
void DoShutdown();
// void InitDebugOptions() ;
/**
* Removes and returns the first waiting job in the queue. Returns null if there
* are no items waiting in the queue. If an item is removed from the queue,
* it is moved to the running jobs list.
*/
Job::Pointer NextJob();
/**
* Returns a non-null progress monitor instance. If the monitor is null,
* returns the default monitor supplied by the progress provider, or a
* NullProgressMonitor if no default monitor is available.
*/
IProgressMonitor::Pointer MonitorFor(IProgressMonitor::Pointer monitor);
// /**
// * Adds all family members in the list of jobs to the collection
// */
// void Select(List members, Object family, InternalJob firstJob, int stateMask) ;
//
// /**
// * Returns a list of all jobs known to the job manager that belong to the given family.
// */
// List Select(Object family) ;
//
// /**
// * Returns a list of all jobs known to the job manager that belong to the given
// * family and are in one of the provided states.
// */
// List Select(Object family, int stateMask) ;
/**
* Validates that the given scheduling rule obeys the constraints of
* scheduling rules as described in the <code>ISchedulingRule</code>
*/
void ValidateRule(ISchedulingRule::Pointer rule);
};
}
#endif /* _BERRY_TEMPLATE_H */
diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryJobQueue.cpp b/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryJobQueue.cpp
index 0ae1d11cac..9c28386ed3 100644
--- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryJobQueue.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryJobQueue.cpp
@@ -1,146 +1,146 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryJobQueue.h"
// changed Java JobQueue implementation ..
// if only one element is in the queue than InternalJob->next and InternalJob->previous pointer are pointing to 0 and not to the Element itself
// I think its better .. will see
namespace berry
{
class DummyJob: public InternalJob
{
public:
IStatus::Pointer Run(IProgressMonitor::Pointer)
{
return Status::OK_STATUS;
}
DummyJob() :
InternalJob("Queue-Head")
{
}
};
JobQueue::JobQueue(bool allowConflictOvertaking) :
dummy(new DummyJob()), m_allowConflictOvertaking(allowConflictOvertaking)
{
dummy->SetNext(dummy);
dummy->SetPrevious(dummy);
}
//TODO JobQueue Constructor IStatus Implementierung
//TODO Constructor JobQueue IStatus .. implementation
// public JobQueue(boolean allowConflictOvertaking) {
// //compareTo on dummy is never called
// dummy = new InternalJob("Queue-Head") {//$NON-NLS-1$
// public IStatus run(IProgressMonitor m) {
// return Status.OK_STATUS;
// }
// };
// dummy.setNext(dummy);
// dummy.setPrevious(dummy);
// this.allowConflictOvertaking = allowConflictOvertaking;
//}
bool JobQueue::CanOvertake(InternalJob::Pointer newEntry,
InternalJob::Pointer queueEntry)
{
//can never go past the end of the queue
if (queueEntry == dummy.GetPointer())
return false;
//if the new entry was already in the wait queue, ensure it is re-inserted in correct position (bug 211799)
if (newEntry->GetWaitQueueStamp() > 0 && newEntry->GetWaitQueueStamp()
< queueEntry->GetWaitQueueStamp())
return true;
//if the new entry has lower priority, there is no need to overtake the existing entry
if ((queueEntry == newEntry))
return false;
// the new entry has higher priority, but only overtake the existing entry if the queue allows it
InternalJob::Pointer sptr_queueEntry(queueEntry);
return m_allowConflictOvertaking || !newEntry->IsConflicting(sptr_queueEntry);
}
void JobQueue::Clear()
{
dummy->SetNext(dummy);
dummy->SetPrevious(dummy);
}
// notice: important that the first element in the queue is internally set as a dummy element
InternalJob::Pointer JobQueue::Dequeue()
{
InternalJob::Pointer ptr_dummyPrevious = dummy->Previous();
// sets previous pointer to 0 if there is only 1 Element in the queue
if (ptr_dummyPrevious == dummy)
{
dummy->previous = 0;
return dummy;
}
return ptr_dummyPrevious->Remove();
}
void JobQueue::Enqueue(InternalJob::Pointer newEntry)
{
InternalJob::Pointer tail = dummy->Next();
//overtake lower priority jobs. Only overtake conflicting jobs if allowed to
while (CanOvertake(newEntry, tail))
tail = tail->Next();
InternalJob::Pointer tailPrevious = tail->Previous();
newEntry->SetNext(tail);
newEntry->SetPrevious(tailPrevious);
tailPrevious->SetNext(newEntry);
tail->SetPrevious(newEntry);
}
void JobQueue::Remove(InternalJob::Pointer jobToRemove)
{
jobToRemove->Remove();
}
void JobQueue::Resort(InternalJob::Pointer entry)
{
this->Remove(entry);
this->Enqueue(entry);
}
bool JobQueue::IsEmpty()
{
return this->dummy->next == dummy;
}
InternalJob::Pointer JobQueue::Peek()
{
return dummy->Previous() == dummy ? InternalJob::Pointer(0)
: dummy->Previous();
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryJobQueue.h b/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryJobQueue.h
index 8df6b93cac..f4621b239a 100644
--- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryJobQueue.h
+++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryJobQueue.h
@@ -1,106 +1,106 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 _BERRY_JOBQUEUE_H
#define _BERRY_JOBQUEUE_H
#include "berryInternalJob.h"
#include "berryJob.h"
#include <berryObject.h>
#include <org_blueberry_core_jobs_Export.h>
namespace berry
{
/**
* A linked list based priority queue. Either the elements in the queue must
* implement Comparable, or a Comparator must be provided.
*/
struct BERRY_JOBS JobQueue: public Object
{
private:
/**
* The dummy entry sits between the head and the tail of the queue.
* dummy.previous() is the head, and dummy.next() is the tail.
*/
InternalJob::Pointer dummy;
/**
* If true, conflicting jobs will be allowed to overtake others in the
* queue that have lower priority. If false, higher priority jumps can only
* move up the queue by overtaking jobs that they don't conflict with.
*/
bool m_allowConflictOvertaking;
/**
* Returns whether the new entry to overtake the existing queue entry.
* @param newEntry The entry to be added to the queue
* @param queueEntry The existing queue entry
*/
bool CanOvertake(InternalJob::Pointer newEntry,
InternalJob::Pointer queueEntry);
public:
/**
* Create a new job queue.
*/
JobQueue(bool m_allowConflictOvertaking);
/**
* remove all elements
*/
void Clear();
/**
* Return and remove the element with highest priority, or null if empty.
*/
InternalJob::Pointer Dequeue();
/**
* Adds an item to the queue
*/
void Enqueue(InternalJob::Pointer newEntry);
/**
* Removes the given element from the queue.
*/
void Remove(InternalJob::Pointer jobToRemove);
/**
* The given object has changed priority. Reshuffle the heap until it is
* valid.
*/
void Resort(InternalJob::Pointer entry);
/**
* Returns true if the queue is empty, and false otherwise.
*/
bool IsEmpty();
/**
* Return greatest element without removing it, or null if empty
*/
InternalJob::Pointer Peek();
};
}
#endif /* _BERRY_JOBQUEUE_H */
diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryPluginActivator.cpp b/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryPluginActivator.cpp
index 7a5c38770d..a8d9b9b245 100644
--- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryPluginActivator.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryPluginActivator.cpp
@@ -1,40 +1,40 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryPluginActivator.h"
#include <QtPlugin>
namespace berry {
org_blueberry_core_jobs_Activator::org_blueberry_core_jobs_Activator()
{
}
void org_blueberry_core_jobs_Activator::start(ctkPluginContext* context)
{
Q_UNUSED(context)
}
void org_blueberry_core_jobs_Activator::stop(ctkPluginContext* context)
{
Q_UNUSED(context)
}
}
Q_EXPORT_PLUGIN2(org_blueberry_core_jobs, berry::org_blueberry_core_jobs_Activator)
diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryPluginActivator.h b/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryPluginActivator.h
index d496d937dd..0aae8183af 100644
--- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryPluginActivator.h
+++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryPluginActivator.h
@@ -1,42 +1,42 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYPLUGINACTIVATOR_H
#define BERRYPLUGINACTIVATOR_H
#include <ctkPluginActivator.h>
namespace berry {
class org_blueberry_core_jobs_Activator :
public QObject, public ctkPluginActivator
{
Q_OBJECT
Q_INTERFACES(ctkPluginActivator)
public:
org_blueberry_core_jobs_Activator();
void start(ctkPluginContext* context);
void stop(ctkPluginContext* context);
};
typedef org_blueberry_core_jobs_Activator PluginActivator;
}
#endif // BERRYPLUGINACTIVATOR_H
diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryWorker.cpp b/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryWorker.cpp
index 546a258566..9aa5f0d928 100644
--- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryWorker.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryWorker.cpp
@@ -1,138 +1,138 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryWorker.h"
#include "berryWorkerPool.h"
#include <sstream>
#include <exception>
#include "berryJobManager.h"
namespace berry
{
/************************* begin of nested JobRunnable class definition ****************************/
int Worker::m_nextWorkerNumber = 0;
Worker::JobRunnable::JobRunnable(Worker* currentWorker) :
ptr_currentWorker(currentWorker)
{
}
// not a good implementation yet .. without the IStatus it can not be checked if a job has been
// executed correctly
void Worker::JobRunnable::run()
{
ptr_currentWorker->setPriority(PRIO_NORMAL);
try
{
while ((ptr_currentWorker->ptr_currentJob
= ptr_currentWorker->m_wpPool.Lock()->StartJob(ptr_currentWorker)) != 0)
{
IStatus::Pointer result = Status::OK_STATUS ;
try
{
ptr_currentWorker->ptr_currentJob->SetThread(ptr_currentWorker);
ptr_currentWorker->ptr_currentJob->Run(ptr_currentWorker->ptr_currentJob->GetProgressMonitor());
// java thread.interrupted
throw FinallyThrowException();
} catch(FinallyThrowException)
{
RunMethodFinallyExecution(result);
}
// provided an unspecific exception handling, if specific exceptions are added within core job executing methods
// the specific thrown exceptions should be handled below
catch(...)
{
RunMethodFinallyExecution(result);
}
}
throw FinallyThrowException();
} catch (FinallyThrowException&)
{
ptr_currentWorker->ptr_currentJob = 0;
Worker::Pointer sptr_currentWorker(ptr_currentWorker);
ptr_currentWorker->m_wpPool.Lock()->EndWorker(sptr_currentWorker);
} catch (...)
{
ptr_currentWorker->ptr_currentJob = 0;
Worker::Pointer sptr_currentWorker(ptr_currentWorker);
ptr_currentWorker->m_wpPool.Lock()->EndWorker(sptr_currentWorker);
}
}
void Worker::JobRunnable::RunMethodFinallyExecution(IStatus::Pointer sptr_result)
{
//clear interrupted state for this thread
//Thread.interrupted();
//result must not be null
if (sptr_result.IsNull())
{
std::runtime_error tempError("NullPointerException") ;
sptr_result = HandleException( ptr_currentWorker->ptr_currentJob, tempError );
}
ptr_currentWorker->m_wpPool.Lock()->EndJob( ptr_currentWorker->ptr_currentJob, sptr_result );
if ((sptr_result->GetSeverity() & (IStatus::ERROR_TYPE | IStatus::WARNING_TYPE)) != 0)
// TODO Logging RuntimeLog.log(result);
std::cout << " Status after executing the job : " << sptr_result->ToString() ;
ptr_currentWorker->ptr_currentJob = 0;
//reset thread priority in case job changed it
ptr_currentWorker->setPriority(PRIO_NORMAL);
}
IStatus::Pointer Worker::JobRunnable::HandleException(InternalJob::Pointer sptr_job, const std::exception& exception)
{
std::stringstream ss;
ss << "An internal error occurred while executing the job: " << sptr_job->GetName() ;
IStatus::Pointer sptr_errorStatus(new Status(IStatus::ERROR_TYPE, JobManager::PI_JOBS(), JobManager::PLUGIN_ERROR, ss.str(), exception) ) ;
return sptr_errorStatus ;
}
/************************* end of nested JobRunnable class definition ****************************/
Worker::Worker(WeakPointer<WorkerPool> myPool) :
Poco::Thread("Worker-" + m_nextWorkerNumber++), m_Runnable(this), m_wpPool(
myPool), ptr_currentJob(0)
{
}
void Worker::Start()
{
Poco::Thread::start(m_Runnable);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryWorker.h b/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryWorker.h
index b8c61aac9c..5cf11c22ab 100644
--- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryWorker.h
+++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryWorker.h
@@ -1,94 +1,94 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 _BERRY_WORKER_H
#define _BERRY_WORKER_H
#include <Poco/Thread.h>
#include "berryObject.h"
#include <org_blueberry_core_jobs_Export.h>
#include <Poco/Thread.h>
#include <Poco/Runnable.h>
#include "berryInternalJob.h"
#include "berryIStatus.h"
#include "berryStatus.h"
namespace berry
{
class WorkerPool;
/**
* A worker thread processes jobs supplied to it by the worker pool. When
* the worker pool gives it a null job, the worker dies.
*/
class BERRY_JOBS Worker: public Object, public Poco::Thread
{
public:
berryObjectMacro(Worker)
Worker(WeakPointer<WorkerPool> myPool);
void Start();
private:
/****************************** begin nested JobRunnable class ********************/
class JobRunnable: public Poco::Runnable
{
public:
JobRunnable(Worker* currentWorker);
void run();
// code that would be executed in java within a finally statement
void RunMethodFinallyExecution(IStatus::Pointer sptr_result);
IStatus::Pointer HandleException(InternalJob::Pointer sptr_pointer, const std::exception& exception);
private:
Worker* ptr_currentWorker;
};
friend class JobRunnable;
/***************************** end nested class JobRunnable *********************************/
private:
Worker(const Self&);
// worker number used for debugging purposes only
static int m_nextWorkerNumber;
JobRunnable m_Runnable;
WeakPointer<WorkerPool> m_wpPool;
InternalJob::Pointer ptr_currentJob;
};
}
#endif /* _BERRY_WORKER_H */
diff --git a/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryWorkerPool.h b/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryWorkerPool.h
index 95654cfda1..0c5ff98f84 100644
--- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryWorkerPool.h
+++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryWorkerPool.h
@@ -1,146 +1,146 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 _BERRY_WORKERPOOL_H
#define _BERRY_WORKERPOOL_H
#include <berryObject.h>
#include "berryWorker.h"
#include "berryInternalJob.h"
#include "berryJobExceptions.h"
#include <Poco/ScopedLock.h>
#include <Poco/Exception.h>
#include <Poco/Mutex.h>
#include <Poco/SynchronizedObject.h>
namespace berry
{
struct JobManager;
class BERRY_JOBS WorkerPool: public Object, public Poco::SynchronizedObject
{
friend struct JobManager;
public:
berryObjectMacro(WorkerPool)
WorkerPool(JobManager* myManager);
/**
* Signals the death of a worker thread. Note that this method can be called under
* OutOfMemoryError conditions and thus must be paranoid about allocating objects.
*/
void EndWorker(Worker::Pointer sptr_worker);
/**
* Signals the end of a job. Note that this method can be called under
* OutOfMemoryError conditions and thus must be paranoid about allocating objects.
*/
void EndJob(InternalJob::Pointer job, IStatus::Pointer result) ;
/**
* Returns a new job to run. Returns null if the thread should die.
*/
InternalJob::Pointer StartJob(Worker* worker);
protected:
/**
* Notification that a job has been added to the queue. Wake a worker,
* creating a new worker if necessary. The provided job may be null.
*/
void JobQueued();
void Shutdown();
private:
void Add(Worker::Pointer worker);
/** impossible to have less than zero busy threads */
void DecrementBusyThreads();
/** impossible to have more busy threads than there are threads */
void IncrementBusyThreads();
/**
* Remove a worker thread from our list.
* @return true if a worker was removed, and false otherwise.
*/
bool Remove(Worker::Pointer worker);
/**
* Sleep for the given duration or until woken.
*/
void Sleep(long duration);
static const long BEST_BEFORE;
/**
* There will always be at least MIN_THREADS workers in the pool.
*/
static const int MIN_THREADS;
/**
* Mutex (mutual exclusion) is a synchronization mechanism used to control access to a shared resource in
* a concurrent (multithreaded) scenario.
*/
Poco::Mutex m_mutexOne;
//
// /**
// * Records whether new worker threads should be daemon threads.
// */
//
// bool m_isDaemon;
//
JobManager* m_ptrManager;
//
int m_numThreads;
/**
* The number of threads that are currently sleeping
*/
int m_sleepingThreads;
/**
* The living set of workers in this pool.
*/
std::vector<Worker::Pointer> m_threads;
/**
* The number of workers in the threads array
*/
int m_busyThreads;
/**
* The default context class loader to use when creating worker threads.
*/
// const ClassLoader defaultContextLoader;
};
}
#endif /* _BERRY_WORKERPOOL_H */
diff --git a/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryIAdaptable.cpp b/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryIAdaptable.cpp
index 315ee8051b..076b002fd6 100644
--- a/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryIAdaptable.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryIAdaptable.cpp
@@ -1,25 +1,25 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryIAdaptable.h"
namespace berry {
IAdaptable::~IAdaptable()
{
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryIAdaptable.h b/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryIAdaptable.h
index 71d372aca7..df31c35063 100644
--- a/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryIAdaptable.h
+++ b/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryIAdaptable.h
@@ -1,77 +1,77 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 _BERRY_IADAPTABLE_H_
#define _BERRY_IADAPTABLE_H_
#include <org_blueberry_core_runtime_Export.h>
#include <berryMacros.h>
#include <berryObject.h>
#include <Poco/Any.h>
namespace berry {
/**
* An interface for an adaptable object.
* <p>
* Adaptable objects can be dynamically extended to provide different
* interfaces (or "adapters"). Adapters are created by adapter
* factories, which are in turn managed by type by adapter managers.
* </p>
* For example,
* <pre>
* IAdaptable a = [some adaptable];
* IFoo x = (IFoo)a.getAdapter(IFoo.class);
* if (x != null)
* [do IFoo things with x]
* </pre>
* <p>
* This interface can be used without OSGi running.
* </p><p>
* Clients may implement this interface, or obtain a default implementation
* of this interface by subclassing <code>PlatformObject</code>.
* </p>
* @see IAdapterFactory
* @see IAdapterManager
* @see PlatformObject
*/
struct BERRY_RUNTIME IAdaptable {
public:
berryNameMacro(berry::IAdaptable)
/**
* Returns an object which is an instance of the given class
* associated with this object. Returns <code>null</code> if
* no such object can be found.
*
* @param adapterType the adapter class to look up
* @return a object castable to the given class,
* or <code>null</code> if this object does not
* have an adapter for the given class
*/
virtual Poco::Any GetAdapter(const std::string& adapterType) = 0;
virtual ~IAdaptable();
};
} // namespace berry
#endif /*_BERRY_IADAPTABLE_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryIAdapterFactory.h b/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryIAdapterFactory.h
index a2518b967d..9e9b0957d7 100644
--- a/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryIAdapterFactory.h
+++ b/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryIAdapterFactory.h
@@ -1,91 +1,91 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIADAPTERFACTORY_H_
#define BERRYIADAPTERFACTORY_H_
#include <org_blueberry_core_runtime_Export.h>
#include <vector>
#include <typeinfo>
namespace berry {
/**
* An adapter factory defines behavioral extensions for
* one or more classes that implements the <code>IAdaptable</code>
* interface. Adapter factories are registered with an
* adapter manager.
* <p>
* This interface can be used without OSGi running.
* </p><p>
* Clients may implement this interface.
* </p>
* @see IAdapterManager
* @see IAdaptable
*/
struct BERRY_RUNTIME IAdapterFactory {
virtual ~IAdapterFactory() {};
/**
* Returns an object which can be cast to the given adapter type and which is
* associated with the given adaptable object. Returns <code>0</code> if
* no such object can be found.
*
* A typical implementation would look like this:
*
* <code>
* void* GetAdapter(void* adaptableObject, const std::type_info& adaptableType, const std::string& adapterType)
* {
* if (Image* img = CastHelper<Image>(adaptableObject, adaptableType))
* {
* if (adapterType == "berry::IResource")
* {
* return new IResource(img->GetPath());
* }
* }
* return 0;
* }
* </code>
*
* @param adaptableObject the adaptable object being queried
* (usually an instance of <code>IAdaptable</code>)
* @param adaptableType the type information for the adaptable object
* @param adapterType the type of adapter to look up
* @return a object castable to the given adapter type,
* or <code>0</code> if this adapter factory
* does not have an adapter of the given type for the
* given object
*/
virtual Object* GetAdapter(IAdaptable* adaptableObject, const std::string& adapterType) = 0;
/**
* Returns the collection of adapter types handled by this
* factory.
* <p>
* This method is generally used by an adapter manager
* to discover which adapter types are supported, in advance
* of dispatching any actual <code>getAdapter</code> requests.
* </p>
*
* @return the collection of adapter types
*/
virtual void GetAdapterList(std::vector<const std::type_info&>& adapters) = 0;
};
}
#endif /*BERRYIADAPTERFACTORY_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryIAdapterManager.cpp b/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryIAdapterManager.cpp
index bb3e93ae47..faca092711 100644
--- a/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryIAdapterManager.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryIAdapterManager.cpp
@@ -1,27 +1,27 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryIAdapterManager.h"
namespace berry {
const int IAdapterManager::NONE = 0;
const int IAdapterManager::NOT_LOADED = 1;
const int IAdapterManager::LOADED = 2;
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryIAdapterManager.h b/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryIAdapterManager.h
index 7dcc314dc6..9252582a1d 100644
--- a/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryIAdapterManager.h
+++ b/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryIAdapterManager.h
@@ -1,278 +1,278 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIADAPTERMANAGER_H_
#define BERRYIADAPTERMANAGER_H_
#include <berryMacros.h>
#include <org_blueberry_core_runtime_Export.h>
#include "berryPlatformObject.h"
#include "berryIAdapterFactory.h"
#include <Poco/Any.h>
#include <QtPlugin>
#include <typeinfo>
namespace berry
{
/**
* An adapter manager maintains a registry of adapter factories. Clients
* directly invoke methods on an adapter manager to register and unregister
* adapters. All adaptable objects (that is, objects that implement the <code>IAdaptable</code>
* interface) tunnel <code>IAdaptable.getAdapter</code> invocations to their
* adapter manager's <code>IAdapterManger.getAdapter</code> method. The
* adapter manager then forwards this request unmodified to the <code>IAdapterFactory.getAdapter</code>
* method on one of the registered adapter factories.
* <p>
* Adapter factories can be registered programmatically using the <code>registerAdapters</code>
* method. Alternatively, they can be registered declaratively using the
* <code>org.blueberry.core.runtime.adapters</code> extension point. Factories registered
* with this extension point will not be able to provide adapters until their
* corresponding plugin has been activated.
* <p>
* The following code snippet shows how one might register an adapter of type
* <code>com.example.acme.Sticky</code> on resources in the workspace.
* <p>
*
* <pre>
* IAdapterFactory pr = new IAdapterFactory() {
* public Class[] getAdapterList() {
* return new Class[] { com.example.acme.Sticky.class };
* }
* public Object getAdapter(Object adaptableObject, Class adapterType) {
* IResource res = (IResource) adaptableObject;
* QualifiedName key = new QualifiedName(&quot;com.example.acme&quot;, &quot;sticky-note&quot;);
* try {
* com.example.acme.Sticky v = (com.example.acme.Sticky) res.getSessionProperty(key);
* if (v == null) {
* v = new com.example.acme.Sticky();
* res.setSessionProperty(key, v);
* }
* } catch (CoreException e) {
* // unable to access session property - ignore
* }
* return v;
* }
* }
* Platform.getAdapterManager().registerAdapters(pr, IResource.class);
* </pre>
*
* </p><p>
* This interface can be used without OSGi running.
* </p><p>
* This interface is not intended to be implemented by clients.
* </p>
* @see IAdaptable
* @see IAdapterFactory
*/
struct BERRY_RUNTIME IAdapterManager: public Object
{
berryInterfaceMacro(IAdapterManager, berry)
/**
* This value can be returned to indicate that no applicable adapter factory
* was found.
* @since org.blueberry.equinox.common 3.3
*/
static const int NONE;
/**
* This value can be returned to indicate that an adapter factory was found,
* but has not been loaded.
* @since org.blueberry.equinox.common 3.3
*/
static const int NOT_LOADED;
/**
* This value can be returned to indicate that an adapter factory is loaded.
* @since org.blueberry.equinox.common 3.3
*/
static const int LOADED;
/**
* Returns the types that can be obtained by converting <code>adaptableClass</code>
* via this manager. Converting means that subsequent calls to <code>getAdapter()</code>
* or <code>loadAdapter()</code> could result in an adapted object.
* <p>
* Note that the returned types do not guarantee that
* a subsequent call to <code>getAdapter</code> with the same type as an argument
* will return a non-null result. If the factory's plug-in has not yet been
* loaded, or if the factory itself returns <code>null</code>, then
* <code>getAdapter</code> will still return <code>null</code>.
* </p>
* @param adaptableClass the adaptable class being queried
* @return an array of type names that can be obtained by converting
* <code>adaptableClass</code> via this manager. An empty array
* is returned if there are none.
* @since 3.1
*/
virtual std::vector<std::string> ComputeAdapterTypes(
const std::type_info& adaptableClass) = 0;
/**
* Returns the class search order for a given class. The search order from a
* class with the definition <br>
* <code>class X extends Y implements A, B</code><br>
* is as follows:
* <ul>
* <li>the target's class: X
* <li>X's superclasses in order to <code>Object</code>
* <li>a breadth-first traversal of the target class's interfaces in the
* order returned by <code>getInterfaces</code> (in the example, A and its
* superinterfaces then B and its superinterfaces) </li>
* </ul>
*
* @param clazz the class for which to return the class order.
* @return the class search order for the given class. The returned
* search order will minimally contain the target class.
* @since 3.1
*/
//public Class[] computeClassOrder(Class clazz);
/**
* Returns a Poco::Any object which contains an instance of the given name associated
* with the given adaptable. Returns an empty Poco::Any if no such object can
* be found.
* <p>
* Note that this method will never cause plug-ins to be loaded. If the
* only suitable factory is not yet loaded, this method will return an empty Poco::Any.
* If activation of the plug-in providing the factory is required, use the
* <code>LoadAdapter</code> method instead.
*
* @param adaptable the adaptable object being queried (usually an instance
* of <code>IAdaptable</code>)
* @param adapterTypeName the fully qualified name of the type of adapter to look up
* @return a Poco::Any castable to the given adapter type, or empty
* if the given adaptable object does not have an available adapter of the
* given type
*/
template<typename A>
Poco::Any GetAdapter(A adaptable, const std::string& adapterTypeName) {
return this->GetAdapter(Poco::Any(adaptable), adapterTypeName, false);
}
/**
* Returns whether there is an adapter factory registered that may be able
* to convert <code>adaptable</code> to an object of type <code>adapterTypeName</code>.
* <p>
* Note that a return value of <code>true</code> does not guarantee that
* a subsequent call to <code>GetAdapter</code> with the same arguments
* will return a non-empty result. If the factory's plug-in has not yet been
* loaded, or if the factory itself returns nothing, then
* <code>GetAdapter</code> will still return an empty Poco::Any.
*
* @param adaptable the adaptable object being queried (usually an instance
* of <code>IAdaptable</code>)
* @param adapterTypeName the fully qualified class name of an adapter to
* look up
* @return <code>true</code> if there is an adapter factory that claims
* it can convert <code>adaptable</code> to an object of type <code>adapterType</code>,
* and <code>false</code> otherwise.
*/
virtual bool HasAdapter(const std::string& adaptableType, const std::string& adapterType) = 0;
/**
* Returns a status of an adapter factory registered that may be able
* to convert <code>adaptable</code> to an object of type <code>adapterTypeName</code>.
* <p>
* One of the following values can be returned:<ul>
* <li>{@link berry::IAdapterManager::NONE} if no applicable adapter factory was found;</li>
* <li>{@link berry::IAdapterManager::NOT_LOADED} if an adapter factory was found, but has not been loaded;</li>
* <li>{@link berry::IAdapterManager::LOADED} if an adapter factory was found, and it is loaded.</li>
* </ul></p>
* @param adaptable the adaptable object being queried (usually an instance
* of <code>IAdaptable</code>)
* @param adapterTypeName the fully qualified class name of an adapter to
* look up
* @return a status of the adapter
*/
virtual int
QueryAdapter(const std::string& adaptableType, const std::string& adapterType) = 0;
/**
* Returns an object that is an instance of the given class name associated
* with the given object. Returns an empty Poco::Any if no such object can
* be found.
* <p>
* Note that unlike the <code>GetAdapter</code> methods, this method
* will cause the plug-in that contributes the adapter factory to be loaded
* if necessary. As such, this method should be used judiciously, in order
* to avoid unnecessary plug-in activations. Most clients should avoid
* activation by using <code>GetAdapter</code> instead.
*
* @param adaptable the adaptable object being queried (usually an instance
* of <code>IAdaptable</code>)
* @param adapterTypeName the fully qualified name of the type of adapter to look up
* @return a Poco::Any castable to the given adapter type, or empty
* if the given adaptable object does not have an available adapter of the
* given type
*/
template<typename A>
Poco::Any LoadAdapter(A adaptable, const std::string& adapterTypeName) {
return this->GetAdapter(Poco::Any(adaptable), adapterTypeName, true);
}
/**
* Registers the given adapter factory as extending objects of the given
* type.
*
* @param factory the adapter factory
* @param adaptableTypeName the fully qualified typename being extended
* @see #UnregisterAdapters(IAdapterFactory*)
* @see #UnregisterAdapters(IAdapterFactory*, const std::adaptableTypeName&)
*/
virtual void RegisterAdapters(IAdapterFactory* factory,
const std::string& adaptableTypeName) = 0;
/**
* Removes the given adapter factory completely from the list of registered
* factories. Equivalent to calling <code>UnregisterAdapters(IAdapterFactory*, const std::string&)</code>
* on all classes against which it had been explicitly registered. Does
* nothing if the given factory is not currently registered.
*
* @param factory the adapter factory to remove
* @see #RegisterAdapters(IAdapterFactory*, const std::string&)
*/
virtual void UnregisterAdapters(IAdapterFactory* factory) = 0;
/**
* Removes the given adapter factory from the list of factories registered
* as extending the given class. Does nothing if the given factory and type
* combination is not registered.
*
* @param factory the adapter factory to remove
* @param adaptableTypeName one of the type names against which the given factory is
* registered
* @see #RegisterAdapters(IAdapterFactory*, const std::string&)
*/
virtual void UnregisterAdapters(IAdapterFactory* factory,
const std::string& adaptableTypeName) = 0;
protected:
virtual Poco::Any GetAdapter(Poco::Any adaptable, const std::string& adapterType, bool force) = 0;
};
} // namespace berry
Q_DECLARE_INTERFACE(berry::IAdapterManager, "org.blueberry.service.IAdapterManager")
#endif /*BERRYIADAPTERMANAGER_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryPlatformObject.cpp b/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryPlatformObject.cpp
index d5ff9808b0..7e81ee417b 100755
--- a/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryPlatformObject.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryPlatformObject.cpp
@@ -1,40 +1,40 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryPlatformObject.h"
#include <berryPlatform.h>
#include "berryRuntime.h"
#include "berryIAdapterManager.h"
namespace berry {
PlatformObject::PlatformObject()
: Object()
{
}
Poco::Any PlatformObject::GetAdapter(const std::string& adapter)
{
IAdapterManager::Pointer adapterManager = Platform::GetServiceRegistry().GetServiceById<IAdapterManager>(Runtime::ADAPTER_SERVICE_ID);
if (adapterManager)
return adapterManager->GetAdapter(Object::Pointer(this), adapter);
return Poco::Any();
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryPlatformObject.h b/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryPlatformObject.h
index 880539e07c..23f5bb8efa 100755
--- a/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryPlatformObject.h
+++ b/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryPlatformObject.h
@@ -1,84 +1,84 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYPLATFORMOBJECT_H_
#define BERRYPLATFORMOBJECT_H_
#include <org_blueberry_core_runtime_Export.h>
#include <berryObject.h>
#include "berryIAdaptable.h"
namespace berry {
/**
* An abstract superclass implementing the <code>IAdaptable</code>
* interface. <code>getAdapter</code> invocations are directed
* to the platform's adapter manager.
* <p>
* Note: In situations where it would be awkward to subclass this
* class, the same affect can be achieved simply by implementing
* the <code>IAdaptable</code> interface and explicitly forwarding
* the <code>getAdapter</code> request to the platform's
* adapater manager. The method would look like:
* <pre>
* public Object getAdapter(Class adapter) {
* return Platform.getAdapterManager().getAdapter(this, adapter);
* }
* </pre>
* </p>
* <p>
* Clients may subclass.
* </p>
*
* @see Platform#getAdapterManager
*/
class BERRY_RUNTIME PlatformObject : public Object, public IAdaptable {
public:
berryObjectMacro(berry::PlatformObject)
/**
* Constructs a new platform object.
*/
PlatformObject();
/**
* Returns an object which is an instance of the given class
* associated with this object. Returns <code>null</code> if
* no such object can be found.
* <p>
* This implementation of the method declared by <code>IAdaptable</code>
* passes the request along to the platform's adapter manager; roughly
* <code>Platform.getAdapterManager().getAdapter(this, adapter)</code>.
* Subclasses may override this method (however, if they do so, they
* should invoke the method on their superclass to ensure that the
* Platform's adapter manager is consulted).
* </p>
*
* @see IAdaptable#getAdapter
* @see Platform#getAdapterManager
*/
Poco::Any GetAdapter(const std::string& adapter);
};
}
#endif /* BERRYPLATFORMOBJECT_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryRuntime.cpp b/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryRuntime.cpp
index 73130af09d..777a578f01 100644
--- a/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryRuntime.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryRuntime.cpp
@@ -1,23 +1,23 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryRuntime.h"
namespace berry {
const std::string Runtime::ADAPTER_SERVICE_ID = "org.blueberry.service.adapter";
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryRuntime.h b/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryRuntime.h
index 38a5d3141f..f2a5c6543a 100644
--- a/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryRuntime.h
+++ b/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryRuntime.h
@@ -1,33 +1,33 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYRUNTIME_H_
#define BERRYRUNTIME_H_
#include <string>
#include <org_blueberry_core_runtime_Export.h>
namespace berry {
struct BERRY_RUNTIME Runtime
{
static const std::string ADAPTER_SERVICE_ID;
};
}
#endif /*BERRYRUNTIME_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.core.runtime/src/internal/berryAdapterService.cpp b/BlueBerry/Bundles/org.blueberry.core.runtime/src/internal/berryAdapterService.cpp
index 1dc79266db..512fcba1e4 100644
--- a/BlueBerry/Bundles/org.blueberry.core.runtime/src/internal/berryAdapterService.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.runtime/src/internal/berryAdapterService.cpp
@@ -1,382 +1,382 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryAdapterService.h"
namespace berry {
AdapterManager* AdapterService::GetDefault()
{
Poco::Mutex::ScopedLock lock(m_Mutex);
static AdapterService instance;
return &instance;
}
AdapterService::AdapterService() :
factories(5), lazyFactoryProviders(1)
{
}
bool
AdapterService::IsA(const std::type_info& type) const
{
std::string name(GetType().name());
return name == type.name() || Service::IsA(type);
}
const std::type_info&
AdapterService::GetType() const
{
return typeid(IAdapterManager);
}
void AdapterService::AddFactoriesFor(const std::string& typeName,
std::map<std::string, IAdapterFactory*>& table)
{
List factoryList = (List) getFactories().get(typeName);
if (factoryList == null)
return;
for (int i = 0, imax = factoryList.size(); i < imax; i++)
{
IAdapterFactory factory = (IAdapterFactory) factoryList.get(i);
if (factory instanceof IAdapterFactoryExt)
{
String[] adapters = ((IAdapterFactoryExt) factory).getAdapterNames();
for (int j = 0; j < adapters.length; j++)
{
if (table.get(adapters[j]) == null)
table.put(adapters[j], factory);
}
}
else
{
Class[] adapters = factory.getAdapterList();
for (int j = 0; j < adapters.length; j++)
{
String adapterName = adapters[j].getName();
if (table.get(adapterName) == null)
table.put(adapterName, factory);
}
}
}
}
void AdapterService::CacheClassLookup(IAdapterFactory* factory,
const std::type_info& clazz)
{
synchronized(classLookupLock)
{
//cache reference to lookup to protect against concurrent flush
Map lookup = classLookup;
if (lookup == null)
classLookup = lookup = new HashMap(4);
HashMap classes = (HashMap) lookup.get(factory);
if (classes == null)
{
classes = new HashMap(4);
lookup.put(factory, classes);
}
classes.put(clazz.getName(), clazz);
}
}
void* /*Class*/
AdapterService::CachedClassForName(IAdapterFactory* factory,
const std::string& typeName)
{
synchronized(classLookupLock)
{
Class clazz = null;
//cache reference to lookup to protect against concurrent flush
Map lookup = classLookup;
if (lookup != null)
{
HashMap classes = (HashMap) lookup.get(factory);
if (classes != null)
{
clazz = (Class) classes.get(typeName);
}
}
return clazz;
}
}
void* /*Class*/
AdapterService::ClassForName(IAdapterFactory* factory,
const std::string& typeName)
{
Class clazz = cachedClassForName(factory, typeName);
if (clazz == null)
{
if (factory instanceof IAdapterFactoryExt)
factory = ((IAdapterFactoryExt) factory).loadFactory(false);
if (factory != null)
{
try
{
clazz = factory.getClass().getClassLoader().loadClass(typeName);
}
catch (ClassNotFoundException e)
{
// it is possible that the default bundle classloader is unaware of this class
// but the adaptor factory can load it in some other way. See bug 200068.
if (typeName == null)
return null;
Class[] adapterList = factory.getAdapterList();
clazz = null;
for (int i = 0; i < adapterList.length; i++)
{
if (typeName.equals(adapterList[i].getName()))
{
clazz = adapterList[i];
break;
}
}
if (clazz == null)
return null; // class not yet loaded
}
cacheClassLookup(factory, clazz);
}
}
return clazz;
}
void AdapterService::ComputeAdapterTypes(std::vector<std::string>& types,
const std::type_info& adaptable)
{
Set types = getFactories(adaptable).keySet();
return (String[]) types.toArray(new String[types.size()]);
}
void AdapterService::GetFactories(
Poco::HashMap<std::string, IAdapterFactory*> table,
const std::type_info& adaptable)
{
//cache reference to lookup to protect against concurrent flush
Map lookup = adapterLookup;
if (lookup == null)
adapterLookup = lookup = Collections.synchronizedMap(new HashMap(30));
Map table = (Map) lookup.get(adaptable.getName());
if (table == null)
{
// calculate adapters for the class
table = new HashMap(4);
Class[] classes = computeClassOrder(adaptable);
for (int i = 0; i < classes.length; i++)
addFactoriesFor(classes[i].getName(), table);
// cache the table
lookup.put(adaptable.getName(), table);
}
return table;
}
//public: Class[] computeClassOrder(Class adaptable) {
// Class[] classes = null;
// //cache reference to lookup to protect against concurrent flush
// Map lookup = classSearchOrderLookup;
// if (lookup == null)
// classSearchOrderLookup = lookup = Collections.synchronizedMap(new HashMap());
// else
// classes = (Class[]) lookup.get(adaptable);
// // compute class order only if it hasn't been cached before
// if (classes == null) {
// ArrayList classList = new ArrayList();
// computeClassOrder(adaptable, classList);
// classes = (Class[]) classList.toArray(new Class[classList.size()]);
// lookup.put(adaptable, classes);
// }
// return classes;
// }
//private: void computeClassOrder(Class adaptable, Collection classes) {
// Class clazz = adaptable;
// Set seen = new HashSet(4);
// while (clazz != null) {
// classes.add(clazz);
// computeInterfaceOrder(clazz.getInterfaces(), classes, seen);
// clazz = clazz.getSuperclass();
// }
// }
//private: void computeInterfaceOrder(Class[] interfaces, Collection classes, Set seen) {
// List newInterfaces = new ArrayList(interfaces.length);
// for (int i = 0; i < interfaces.length; i++) {
// Class interfac = interfaces[i];
// if (seen.add(interfac)) {
// //note we cannot recurse here without changing the resulting interface order
// classes.add(interfac);
// newInterfaces.add(interfac);
// }
// }
// for (Iterator it = newInterfaces.iterator(); it.hasNext();)
// computeInterfaceOrder(((Class) it.next()).getInterfaces(), classes, seen);
// }
void AdapterService::FlushLookup()
{
Poco::Mutex::ScopedLock lock(m_Mutex);
adapterLookup = null;
classLookup = null;
//classSearchOrderLookup = null;
}
Poco::Any AdapterService::GetAdapter(Poco::Any& adaptable,
const std::type_info& adapterType)
{
IAdapterFactory factory = (IAdapterFactory) getFactories(adaptable.getClass()).get(adapterType.getName());
Object result = null;
if (factory != null)
result = factory.getAdapter(adaptable, adapterType);
if (result == null && adapterType.isInstance(adaptable))
return adaptable;
return result;
}
Poco::Any AdapterService::GetAdapter(Poco::Any& adaptable, const std::string& adapterType)
{
return getAdapter(adaptable, adapterType, false);
}
Poco::Any AdapterService::GetAdapter(Poco::Any& adaptable,
const std::string& adapterType, bool force)
{
IAdapterFactory factory = (IAdapterFactory) getFactories(adaptable.getClass()).get(adapterType);
if (force && factory instanceof IAdapterFactoryExt)
factory = ((IAdapterFactoryExt) factory).loadFactory(true);
Object result = null;
if (factory != null)
{
Class clazz = classForName(factory, adapterType);
if (clazz != null)
result = factory.getAdapter(adaptable, clazz);
}
if (result == null && adaptable.getClass().getName().equals(adapterType))
return adaptable;
return result;
}
bool AdapterService::HasAdapter(Poco::Any& adaptable,
const std::string& adapterTypeName)
{
return getFactories(adaptable.getClass()).get(adapterTypeName) != null;
}
int AdapterService::QueryAdapter(Poco::Any& adaptable,
const std::string& adapterTypeName)
{
IAdapterFactory factory = (IAdapterFactory) getFactories(adaptable.getClass()).get(adapterTypeName);
if (factory == null)
return NONE;
if (factory instanceof IAdapterFactoryExt)
{
factory = ((IAdapterFactoryExt) factory).loadFactory(false); // don't force loading
if (factory == null)
return NOT_LOADED;
}
return LOADED;
}
Poco::Any AdapterService::LoadAdapter(Poco::Any& adaptable,
const std::string& adapterTypeName)
{
return getAdapter(adaptable, adapterTypeName, true);
}
void AdapterService::RegisterAdapters(IAdapterFactory* factory,
const std::type_info& adaptable)
{
Poco::Mutex::ScopeLock lock(m_Mutex);
this->RegisterFactory(factory, adaptable.getName());
this->FlushLookup();
}
void AdapterService::RegisterFactory(IAdapterFactory* factory,
const std::string& adaptableType)
{
List list = (List) factories.get(adaptableType);
if (list == null)
{
list = new ArrayList(5);
factories.put(adaptableType, list);
}
list.add(factory);
}
void AdapterService::UnregisterAdapters(IAdapterFactory* factory)
{
Poco::Mutex::ScopedLock lock(m_Mutex);
for (Iterator it = factories.values().iterator(); it.hasNext();)
((List) it.next()).remove(factory);
flushLookup();
}
void AdapterService::UnregisterAdapters(IAdapterFactory* factory,
const std::type_info& adaptable)
{
Poco::Mutex::ScopedLock lock(m_Mutex);
List factoryList = (List) factories.get(adaptable.getName());
if (factoryList == null)
return;
factoryList.remove(factory);
flushLookup();
}
void AdapterService::UnregisterAllAdapters()
{
Poco::Mutex::ScopedLock lock(m_Mutex);
factories.clear();
flushLookup();
}
void AdapterService::RegisterLazyFactoryProvider(
IAdapterManagerProvider* factoryProvider)
{
synchronized(lazyFactoryProviders)
{
lazyFactoryProviders.add(factoryProvider);
}
}
bool AdapterService::UnregisterLazyFactoryProvider(
IAdapterManagerProvider* factoryProvider)
{
synchronized(lazyFactoryProviders)
{
return lazyFactoryProviders.remove(factoryProvider);
}
}
Poco::HashMap<>& AdapterService::GetFactories()
{
// avoid the synchronize if we don't have to call it
if (lazyFactoryProviders.size() == 0)
return factories;
synchronized(lazyFactoryProviders)
{
while (lazyFactoryProviders.size() > 0)
{
IAdapterServiceProvider provider =
(IAdapterManagerProvider) lazyFactoryProviders.remove(0);
if (provider.addFactories(this))
flushLookup();
}
}
return factories;
}
} // namespace berry
diff --git a/BlueBerry/Bundles/org.blueberry.core.runtime/src/internal/berryAdapterService.h b/BlueBerry/Bundles/org.blueberry.core.runtime/src/internal/berryAdapterService.h
index 9a5ad0f65a..5b0fb7834b 100644
--- a/BlueBerry/Bundles/org.blueberry.core.runtime/src/internal/berryAdapterService.h
+++ b/BlueBerry/Bundles/org.blueberry.core.runtime/src/internal/berryAdapterService.h
@@ -1,233 +1,233 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYADAPTERMANAGER_H_
#define BERRYADAPTERMANAGER_H_
#include <berryService.h>
#include "berryIAdapterManager.h"
#include "berryIAdapterFactory.h"
#include <Poco/HashMap.h>
#include <string>
#include <list>
#include <map>
#include <typeinfo>
namespace berry {
/**
* This class is the standard implementation of <code>IAdapterManager</code>. It provides
* fast lookup of property values with the following semantics:
* <ul>
* <li>At most one factory will be invoked per property lookup
* <li>If multiple installed factories provide the same adapter, only the first found in
* the search order will be invoked.
* <li>The search order from a class with the definition <br>
* <code>class X extends Y implements A, B</code><br> is as follows: <il>
* <li>the target's class: X
* <li>X's superclasses in order to <code>Object</code>
* <li>a breadth-first traversal of the target class's interfaces in the order returned by
* <code>getInterfaces</code> (in the example, A and its superinterfaces then B and its
* superinterfaces) </il>
* </ul>
*
* @see IAdapterFactory
* @see IAdapterManager
*/
class AdapterService : public Service, public IAdapterManager {
/**
* Cache of adapters for a given adaptable class. Maps String -> Map
* (adaptable class name -> (adapter class name -> factory instance))
* Thread safety note: The outer map is synchronized using a synchronized
* map wrapper class. The inner map is not synchronized, but it is immutable
* so synchronization is not necessary.
*/
private:
std::map<std::string, Poco::HashMap<std::string, IAdapterFactory*> > adapterLookup;
/**
* Cache of classes for a given type name. Avoids too many loadClass calls.
* (factory -> (type name -> Class)).
* Thread safety note: Since this structure is a nested hash map, and both
* the inner and outer maps are mutable, access to this entire structure is
* controlled by the classLookupLock field. Note the field can still be
* nulled concurrently without holding the lock.
*/
std::map<IAdapterFactory*, Poco::HashMap<std::string, const std::type_info&> > classLookup;
/**
* The lock object controlling access to the classLookup data structure.
*/
//const Object classLookupLock = new Object();
/**
* Cache of class lookup order (Class -> Class[]). This avoids having to compute often, and
* provides clients with quick lookup for instanceOf checks based on type name.
* Thread safety note: The map is synchronized using a synchronized
* map wrapper class. The arrays within the map are immutable.
*/
//std::map<> classSearchOrderLookup;
/**
* Map of factories, keyed by <code>String</code>, fully qualified class name of
* the adaptable class that the factory provides adapters for. Value is a <code>List</code>
* of <code>IAdapterFactory</code>.
*/
Poco::HashMap<std::string, IAdapterFactory*> factories;
std::list<IAdapterManagerProvider*> lazyFactoryProviders;
public: bool IsA(const std::type_info& type) const;
public: const std::type_info& GetType() const;
public: static AdapterManager GetDefault();
/**
* Private constructor to block instance creation.
*/
private: AdapterManager();
/**
* Given a type name, add all of the factories that respond to those types into
* the given table. Each entry will be keyed by the adapter class name (supplied in
* IAdapterFactory.getAdapterList).
*/
private: void AddFactoriesFor(const std::string& typeName, std::map<std::string, IAdapterFactory*>& table);
private: void CacheClassLookup(IAdapterFactory* factory, const std::type_info& clazz);
private: void* /*Class*/ CachedClassForName(IAdapterFactory* factory, const std::string& typeName);
/**
* Returns the class with the given fully qualified name, or null
* if that class does not exist or belongs to a plug-in that has not
* yet been loaded.
*/
private: void* /*Class*/ ClassForName(IAdapterFactory* factory, const std::string& typeName);
/* (non-Javadoc)
* @see org.blueberry.core.runtime.IAdapterManager#getAdapterTypes(java.lang.Class)
*/
public: void ComputeAdapterTypes(std::vector<std::string>& types, const std::type_info& adaptable);
/**
* Computes the adapters that the provided class can adapt to, along
* with the factory object that can perform that transformation. Returns
* a table of adapter class name to factory object.
* @param adaptable
*/
private: void GetFactories(std::map<std::string, IAdapterFactory*> table, const std::type_info& adaptable);
//public: Class[] computeClassOrder(Class adaptable);
/**
* Builds and returns a table of adapters for the given adaptable type.
* The table is keyed by adapter class name. The
* value is the <b>sole<b> factory that defines that adapter. Note that
* if multiple adapters technically define the same property, only the
* first found in the search order is considered.
*
* Note that it is important to maintain a consistent class and interface
* lookup order. See the class comment for more details.
*/
//private: void computeClassOrder(Class adaptable, Collection classes);
//private: void computeInterfaceOrder(Class[] interfaces, Collection classes, Set seen);
/**
* Flushes the cache of adapter search paths. This is generally required whenever an
* adapter is added or removed.
* <p>
* It is likely easier to just toss the whole cache rather than trying to be smart
* and remove only those entries affected.
* </p>
*/
public: void FlushLookup();
/* (non-Javadoc)
* @see org.blueberry.core.runtime.IAdapterManager#getAdapter(java.lang.Object, java.lang.Class)
*/
public: ExpressionVariable::Ptr GetAdapter(ExpressionVariable::Ptr adaptable, const std::type_info& adapterType);
/* (non-Javadoc)
* @see org.blueberry.core.runtime.IAdapterManager#getAdapter(java.lang.Object, java.lang.Class)
*/
public: ExpressionVariable::Ptr GetAdapter(ExpressionVariable::Ptr adaptable, const std::string& adapterType);
/**
* Returns an adapter of the given type for the provided adapter.
* @param adaptable the object to adapt
* @param adapterType the type to adapt the object to
* @param force <code>true</code> if the plug-in providing the
* factory should be activated if necessary. <code>false</code>
* if no plugin activations are desired.
*/
private: ExpressionVariable::Ptr GetAdapter(ExpressionVariable::Ptr adaptable, const std::string& adapterType, bool force);
public: bool HasAdapter(ExpressionVariable::Ptr adaptable, const std::string& adapterTypeName);
/* (non-Javadoc)
* @see org.blueberry.core.runtime.IAdapterManager#queryAdapter(java.lang.Object, java.lang.String)
*/
public: int QueryAdapter(ExpressionVariable::Ptr adaptable, const std::string& adapterTypeName);
/* (non-Javadoc)
* @see org.blueberry.core.runtime.IAdapterManager#loadAdapter(java.lang.Object, java.lang.String)
*/
public: ExpressionVariable::Ptr LoadAdapter(ExpressionVariable::Ptr adaptable, const std::string& adapterTypeName);
/*
* @see IAdapterManager#registerAdapters
*/
public: void RegisterAdapters(IAdapterFactory* factory, const std::type_info& adaptable);
/*
* @see IAdapterManager#registerAdapters
*/
public: void RegisterFactory(IAdapterFactory* factory, const std::string& adaptableType);
/*
* @see IAdapterManager#unregisterAdapters
*/
public: void UnregisterAdapters(IAdapterFactory* factory);
/*
* @see IAdapterManager#unregisterAdapters
*/
public: void UnregisterAdapters(IAdapterFactory* factory, const std::type_info& adaptable);
/*
* Shuts down the adapter manager by removing all factories
* and removing the registry change listener. Should only be
* invoked during platform shutdown.
*/
public: void UnregisterAllAdapters();
public: void RegisterLazyFactoryProvider(IAdapterManagerProvider* factoryProvider);
public: bool UnregisterLazyFactoryProvider(IAdapterManagerProvider* factoryProvider);
public: Poco::HashMap<>& GetFactories();
};
} // namespace berry
#endif /*BERRYADAPTERMANAGER_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.core.runtime/src/internal/berryIAdapterManagerProvider.h b/BlueBerry/Bundles/org.blueberry.core.runtime/src/internal/berryIAdapterManagerProvider.h
index d6c975d5d5..9a76d53bdc 100644
--- a/BlueBerry/Bundles/org.blueberry.core.runtime/src/internal/berryIAdapterManagerProvider.h
+++ b/BlueBerry/Bundles/org.blueberry.core.runtime/src/internal/berryIAdapterManagerProvider.h
@@ -1,45 +1,45 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIADAPTERMANAGERPROVIDER_H_
#define BERRYIADAPTERMANAGERPROVIDER_H_
namespace berry {
class AdapterManager;
/**
* The callback interface for the elements desiring to lazily supply
* information to the adapter manager.
*
* @since org.blueberry.core.runtime 3.2
*/
struct IAdapterManagerProvider {
/**
* Add factories. The method called before the AdapterManager starts
* using factories.
*
* @param adapterManager the adapter manager that is about to be used
* @return <code>true</code> if factories were added; <code>false</code>
* if no factories were added in this method call.
*/
bool AddFactories(AdapterManager* adapterManager);
};
} // namespace berry
#endif /*BERRYIADAPTERMANAGERPROVIDER_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.core.runtime/src/internal/berryPluginActivator.cpp b/BlueBerry/Bundles/org.blueberry.core.runtime/src/internal/berryPluginActivator.cpp
index 5b446136c2..1be0805b05 100644
--- a/BlueBerry/Bundles/org.blueberry.core.runtime/src/internal/berryPluginActivator.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.runtime/src/internal/berryPluginActivator.cpp
@@ -1,44 +1,44 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryPluginActivator.h"
#include <QtPlugin>
namespace berry {
org_blueberry_core_runtime_Activator::org_blueberry_core_runtime_Activator()
{
}
void org_blueberry_core_runtime_Activator::start(ctkPluginContext* context)
{
m_PreferencesService = new PreferencesService(context->getDataFile("").absolutePath().toStdString());
m_PrefServiceReg = context->registerService<IPreferencesService>(m_PreferencesService.GetPointer());
}
void org_blueberry_core_runtime_Activator::stop(ctkPluginContext* context)
{
m_PrefServiceReg.unregister();
m_PreferencesService->ShutDown();
m_PreferencesService = 0;
m_PrefServiceReg = 0;
}
}
Q_EXPORT_PLUGIN2(org_blueberry_core_runtime, berry::org_blueberry_core_runtime_Activator)
diff --git a/BlueBerry/Bundles/org.blueberry.core.runtime/src/internal/berryPluginActivator.h b/BlueBerry/Bundles/org.blueberry.core.runtime/src/internal/berryPluginActivator.h
index 2dd2b100db..7418f5b4a5 100644
--- a/BlueBerry/Bundles/org.blueberry.core.runtime/src/internal/berryPluginActivator.h
+++ b/BlueBerry/Bundles/org.blueberry.core.runtime/src/internal/berryPluginActivator.h
@@ -1,50 +1,50 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYPLUGINACTIVATOR_H
#define BERRYPLUGINACTIVATOR_H
#include <ctkPluginActivator.h>
#include <ctkServiceRegistration.h>
#include "berryPreferencesService.h"
namespace berry {
class org_blueberry_core_runtime_Activator :
public QObject, public ctkPluginActivator
{
Q_OBJECT
Q_INTERFACES(ctkPluginActivator)
public:
org_blueberry_core_runtime_Activator();
void start(ctkPluginContext* context);
void stop(ctkPluginContext* context);
private:
PreferencesService::Pointer m_PreferencesService;
ctkServiceRegistration m_PrefServiceReg;
};
typedef org_blueberry_core_runtime_Activator PluginActivator;
}
#endif // BERRYPLUGINACTIVATOR_H
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/manifest.cpp b/BlueBerry/Bundles/org.blueberry.osgi/manifest.cpp
index 6352ff20c8..9da9fcc0f5 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/manifest.cpp
+++ b/BlueBerry/Bundles/org.blueberry.osgi/manifest.cpp
@@ -1,23 +1,23 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 <Poco/ClassLibrary.h>
#include "src/internal/berrySystemBundleActivator.h"
POCO_BEGIN_MANIFEST(berry::IBundleActivator)
POCO_EXPORT_CLASS(berry::SystemBundleActivator)
POCO_END_MANIFEST
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/application/berryIApplication.cpp b/BlueBerry/Bundles/org.blueberry.osgi/src/application/berryIApplication.cpp
index 20b231cfa2..0fc137a4eb 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/application/berryIApplication.cpp
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/application/berryIApplication.cpp
@@ -1,30 +1,30 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryIApplication.h"
namespace berry
{
const int IApplication::EXIT_OK = 0;
const int IApplication::EXIT_RESTART = 23;
const int IApplication::EXIT_RELAUNCH = 24;
IApplication::~IApplication()
{
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/application/berryIApplication.h b/BlueBerry/Bundles/org.blueberry.osgi/src/application/berryIApplication.h
index cbfcf76d02..00cc87c5f0 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/application/berryIApplication.h
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/application/berryIApplication.h
@@ -1,102 +1,102 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIAPPLICATION_H_
#define BERRYIAPPLICATION_H_
#include <org_blueberry_osgi_Export.h>
#include "berryMacros.h"
#include <QObject>
namespace berry {
/**
* Bootstrap type for an application. An IApplication represent executable
* entry points into an application. An IApplication can be configured into
* the Platform's <code>org.blueberry.osgi.applications</code> extension-point.
*
* <p>
* Clients may implement this interface.
* </p>
*
* @since 1.0
*/
struct BERRY_OSGI IApplication {
berryManifestMacro(IApplication, berry);
/**
* Exit object indicating normal termination
*/
static const int EXIT_OK;
/**
* Exit object requesting platform restart
*/
static const int EXIT_RESTART;
/**
* Exit object requesting that the command passed back be executed. Typically
* this is used to relaunch BlueBerry with different command line arguments. When the executable is
* relaunched the command line will be retrieved from the <code>BlueBerry.exitdata</code> system property.
*/
static const int EXIT_RELAUNCH;
virtual ~IApplication();
/**
* Starts this application with the given context and returns a result. This
* method must not exit until the application is finished and is ready to exit.
* The content of the context is unchecked and should conform to the expectations of
* the application being invoked.<p>
*
* Applications can return any object they like. If an <code>Integer</code> is returned
* it is treated as the program exit code if BlueBerry is exiting.
* <p>
* Note: This method is called by the platform; it is not intended
* to be called directly by clients.
* </p>
* @return the return value of the application
* @see #EXIT_OK
* @see #EXIT_RESTART
* @see #EXIT_RELAUNCH
* @param context the application context to pass to the application
* @exception Exception if there is a problem running this application.
*/
virtual int Start() = 0;
/**
* Forces this running application to exit. This method should wait until the
* running application is ready to exit. The {@link #start()}
* should already have exited or should exit very soon after this method exits<p>
*
* This method is only called to force an application to exit.
* This method will not be called if an application exits normally from
* the {@link #start()} method.
* <p>
* Note: This method is called by the platform; it is not intended
* to be called directly by clients.
* </p>
*/
virtual void Stop() = 0;
};
}
Q_DECLARE_INTERFACE(berry::IApplication, "org.blueberry.IApplication")
#endif /*BERRYIAPPLICATION_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/application/berryMain.cpp b/BlueBerry/Bundles/org.blueberry.osgi/src/application/berryMain.cpp
index 32dfc1d700..ff127aba43 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/application/berryMain.cpp
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/application/berryMain.cpp
@@ -1,29 +1,29 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryStarter.h"
#include <QCoreApplication>
int main(int argc, char** argv)
{
// Create a QCoreApplication instance first
QCoreApplication app(argc, argv);
app.setApplicationName("solstice");
app.setOrganizationName("DKFZ");
return berry::Starter::Run(argc, argv, 0);
}
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/application/berryMainUI.cpp b/BlueBerry/Bundles/org.blueberry.osgi/src/application/berryMainUI.cpp
index ee9727e45c..16eb218a5b 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/application/berryMainUI.cpp
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/application/berryMainUI.cpp
@@ -1,29 +1,29 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryStarter.h"
#include <QApplication>
int main(int argc, char** argv)
{
// Create a QCoreApplication instance first
QApplication app(argc, argv);
app.setApplicationName("solstice_ui");
app.setOrganizationName("DKFZ");
return berry::Starter::Run(argc, argv, 0);
}
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/application/berryStarter.cpp b/BlueBerry/Bundles/org.blueberry.osgi/src/application/berryStarter.cpp
index acf2e645cc..b09f344236 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/application/berryStarter.cpp
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/application/berryStarter.cpp
@@ -1,175 +1,175 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryLog.h"
#include "berryStarter.h"
#include "berryPlatform.h"
#include "internal/berryInternalPlatform.h"
#include "service/berryIExtensionPointService.h"
#include "service/berryIConfigurationElement.h"
#include "berryIApplication.h"
#include <vector>
#include <QCoreApplication>
namespace berry
{
const std::string Starter::XP_APPLICATIONS = "org.blueberry.osgi.applications";
int Starter::Run(int& argc, char** argv,
Poco::Util::AbstractConfiguration* config)
{
// The CTK PluginFramework needs a QCoreApplication
if (!qApp)
{
BERRY_FATAL << "No QCoreApplication instance found. You need to create one prior to calling Starter::Run()";
}
InternalPlatform* platform = InternalPlatform::GetInstance();
int returnCode = 0;
// startup the internal platform
platform->Initialize(argc, argv, config);
platform->Launch();
bool consoleLog = platform->ConsoleLog();
// run the application
IExtensionPointService::Pointer service =
platform->GetExtensionPointService();
if (service == 0)
{
platform->GetLogger()->log(
Poco::Message(
"Starter",
"The extension point service could not be retrieved. This usually indicates that the BlueBerry OSGi plug-in could not be loaded.",
Poco::Message::PRIO_FATAL));
std::unexpected();
returnCode = 1;
}
else
{
IConfigurationElement::vector extensions(
service->GetConfigurationElementsFor(Starter::XP_APPLICATIONS));
IConfigurationElement::vector::iterator iter;
for (iter = extensions.begin(); iter != extensions.end();)
{
if ((*iter)->GetName() != "application")
iter = extensions.erase(iter);
else
++iter;
}
std::string argApplication = Platform::GetConfiguration().getString(
Platform::ARG_APPLICATION, "");
IApplication* app = 0;
if (extensions.size() == 0)
{
BERRY_FATAL
<< "No extensions configured into extension-point '" << Starter::XP_APPLICATIONS << "' found. Aborting.\n";
returnCode = 0;
}
else if (extensions.size() == 1)
{
if (!argApplication.empty())
BERRY_INFO(consoleLog)
<< "One '" << Starter::XP_APPLICATIONS << "' extension found, ignoring "
<< Platform::ARG_APPLICATION << " argument.\n";
std::vector<IConfigurationElement::Pointer> runs(
extensions[0]->GetChildren("run"));
app = runs.front()->CreateExecutableExtension<IApplication> ("class");
if (app == 0)
{
// support legacy BlueBerry extensions
app = runs.front()->CreateExecutableExtension<IApplication> ("class", IApplication::GetManifestName());
}
}
else
{
if (argApplication.empty())
{
BERRY_WARN << "You must provide an application id via \""
<< Platform::ARG_APPLICATION << "=<id>\"";
BERRY_INFO << "Possible application ids are:";
for (iter = extensions.begin(); iter != extensions.end(); ++iter)
{
std::string appid;
if ((*iter)->GetAttribute("id", appid) && !appid.empty())
{
BERRY_INFO << appid;
}
}
returnCode = 0;
}
else
{
for (iter = extensions.begin(); iter != extensions.end(); ++iter)
{
BERRY_INFO(consoleLog) << "Checking applications extension from: "
<< (*iter)->GetContributor() << std::endl;
std::string appid;
if ((*iter)->GetAttribute("id", appid))
{
BERRY_INFO(consoleLog) << "Found id: " << appid << std::endl;
if (appid.size() > 0 && appid == argApplication)
{
std::vector<IConfigurationElement::Pointer> runs(
(*iter)->GetChildren("run"));
app = runs.front()->CreateExecutableExtension<IApplication> ("class");
if (app == 0)
{
// try legacy BlueBerry extensions
app = runs.front()->CreateExecutableExtension<IApplication> (
"class", IApplication::GetManifestName());
}
break;
}
}
else
throw CoreException("missing attribute", "id");
}
}
}
if (app == 0)
{
BERRY_ERROR
<< "Could not create executable application extension for id: "
<< argApplication << std::endl;
returnCode = 1;
}
else
{
returnCode = app->Start();
}
}
platform->Shutdown();
return returnCode;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/application/berryStarter.h b/BlueBerry/Bundles/org.blueberry.osgi/src/application/berryStarter.h
index 4fa9435363..c9d0f96cae 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/application/berryStarter.h
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/application/berryStarter.h
@@ -1,40 +1,40 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYSTARTER_H_
#define BERRYSTARTER_H_
#include <org_blueberry_osgi_Export.h>
#include "berryPlatform.h"
#include <string>
namespace berry {
class BERRY_OSGI Starter
{
public:
static const std::string XP_APPLICATIONS;
static int Run(int& argc, char** argv, Poco::Util::AbstractConfiguration* config = 0);
};
}
#endif /*BERRYSTARTER_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berryBundleLoader.cpp b/BlueBerry/Bundles/org.blueberry.osgi/src/berryBundleLoader.cpp
index ada14e631b..37185f00cd 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/berryBundleLoader.cpp
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/berryBundleLoader.cpp
@@ -1,504 +1,504 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryLog.h"
#include "berryBundleLoader.h"
#include "internal/berryBundleContext.h"
#include "internal/berryBundleDirectory.h"
#include "event/berryBundleEvents.h"
#include "internal/berryDefaultActivator.h"
#include "internal/berrySystemBundleActivator.h"
#include "internal/berryCodeCache.h"
#include "internal/berryInternalPlatform.h"
#include "berryPlugin.h"
#include "berryPlatform.h"
#include "berryPlatformException.h"
#include "service/berryIExtensionPointService.h"
#include <Poco/Environment.h>
namespace berry {
BundleLoader::BundleLoader(CodeCache* codeCache, Poco::Logger& logger) //, BundleFactory* bundleFactory, BundleContextFactory* bundleContextFactory);
: m_CodeCache(codeCache), m_Logger(logger), m_ConsoleLog(false)
{
m_ConsoleLog = InternalPlatform::GetInstance()->ConsoleLog();
}
BundleLoader::~BundleLoader()
{
}
void BundleLoader::SetCTKPlugins(const QStringList& installedCTKPlugins)
{
this->installedCTKPlugins = installedCTKPlugins;
}
Poco::Logger&
BundleLoader::GetLogger() const
{
return m_Logger;
}
IBundleContext::Pointer
BundleLoader::GetContextForBundle(IBundle::ConstPointer bundle)
{
Poco::Mutex::ScopedLock lock(m_Mutex);
return m_BundleMap[bundle->GetSymbolicName()].m_Context;
}
Bundle::Pointer
BundleLoader::CreateBundle(const Poco::Path& path)
{
BundleDirectory::Pointer bundleStorage(new BundleDirectory(path));
Bundle::Pointer bundle(new Bundle(*this, bundleStorage));
if (bundle->GetState() == IBundle::BUNDLE_INSTALLED &&
installedCTKPlugins.contains(QString::fromStdString(bundle->GetSymbolicName())))
{
BERRY_WARN << "Ignoring legacy BlueBerry bundle " << bundle->GetSymbolicName()
<< " because a CTK plug-in with the same name already exists.";
return Bundle::Pointer(0);
}
if (bundle->GetState() == IBundle::BUNDLE_INSTALLED &&
bundle->IsSystemBundle()) {
bundle = new SystemBundle(*this, bundleStorage);
m_SystemBundle = bundle;
}
//BundleEvent event(bundle, BundleEvent::EV_BUNDLE_INSTALLED);
//m_BundleEvents.bundleInstalled(this, event);
return bundle;
}
BundleEvents&
BundleLoader::GetEvents()
{
return m_BundleEvents;
}
IBundle::Pointer
BundleLoader::FindBundle(const std::string& symbolicName)
{
if (symbolicName == "system.bundle") return m_SystemBundle;
Poco::Mutex::ScopedLock lock(m_Mutex);
BundleMap::const_iterator iter;
iter = m_BundleMap.find(symbolicName);
if (iter == m_BundleMap.end()) return IBundle::Pointer();
return iter->second.m_Bundle;
}
std::vector<IBundle::Pointer> BundleLoader::GetBundles() const
{
std::vector<IBundle::Pointer> result;
BundleMap::const_iterator end = m_BundleMap.end();
for (BundleMap::const_iterator it = m_BundleMap.begin(); it != end; ++it)
{
result.push_back(it->second.m_Bundle);
}
return result;
}
Bundle::Pointer
BundleLoader::LoadBundle(const Poco::Path& path)
{
Bundle::Pointer bundle = this->CreateBundle(path);
if (bundle) this->LoadBundle(bundle);
return bundle;
}
void
BundleLoader::LoadBundle(Bundle::Pointer bundle)
{
if (bundle->GetState() == IBundle::BUNDLE_INSTALLED ||
bundle->GetState() == IBundle::BUNDLE_RESOLVED)
{
Poco::Mutex::ScopedLock lock(m_Mutex);
if (m_BundleMap[bundle->GetSymbolicName()].m_Bundle.IsNull())
{
BundleInfo bundleInfo;
bundleInfo.m_Bundle = bundle;
bundleInfo.m_ClassLoader = new ActivatorClassLoader();
Poco::Path path; Platform::GetStatePath(path, bundle);
bundleInfo.m_Context = new BundleContext(*this, bundle, path);
m_BundleMap[bundle->GetSymbolicName()] = bundleInfo;
this->InstallLibraries(bundle);
//BundleEvent event(bundle, BundleEvent::EV_BUNDLE_LOADED);
//m_BundleEvents.bundleLoaded(this, event);
}
else
{
//TODO version conflict check
}
}
else
{
throw BundleStateException("The bundle must be in state INSTALLED in order to be loaded.");
}
}
Poco::Path
BundleLoader::GetPathForLibrary(const std::string& libraryName)
{
return m_CodeCache->GetPathForLibrary(libraryName);
}
Poco::Path
BundleLoader::GetLibraryPathFor(IBundle::Pointer bundle)
{
std::string libName = bundle->GetActivatorLibrary();
if (libName.empty()) libName = "lib" + bundle->GetSymbolicName();
return this->GetPathForLibrary(libName);
}
std::string
BundleLoader::GetContributionsPathFor(IBundle::Pointer /*bundle*/)
{
return "plugin.xml";
}
void
BundleLoader::ResolveBundle(IBundle::Pointer bundle)
{
try
{
BERRY_INFO(m_ConsoleLog) << "Trying to resolve bundle " << bundle->GetSymbolicName();
bundle->Resolve();
BERRY_INFO(m_ConsoleLog) << "Bundle " << bundle->GetSymbolicName() << ": " << bundle->GetStateString();
}
catch (BundleResolveException exc)
{
BERRY_ERROR << "Bundle resolve failed: " << exc.displayText();
}
// if (bundle->IsResolved())
// {
// BundleEvent event(bundle, BundleEvent::EV_BUNDLE_RESOLVED);
// m_BundleEvents.bundleResolved(this, event);
// }
}
void
BundleLoader::ResolveAllBundles()
{
Poco::Mutex::ScopedLock lock(m_Mutex);
BundleMap::iterator iter;
for (iter = m_BundleMap.begin(); iter != m_BundleMap.end(); iter++)
{
this->ResolveBundle(iter->second.m_Bundle);
}
}
void
BundleLoader::ListLibraries(IBundle::Pointer bundle, std::vector<std::string>& list)
{
ListLibraries(bundle, list, "bin/");
#ifdef CMAKE_INTDIR
ListLibraries(bundle, list, "bin/" CMAKE_INTDIR "/");
#endif
}
void
BundleLoader::ListLibraries(IBundle::Pointer bundle, std::vector<std::string>& list, const std::string& baseDir)
{
std::vector<std::string> tmpList;
bundle->GetStorage().List(baseDir, tmpList);
std::string::size_type suf = Poco::SharedLibrary::suffix().size();
std::vector<std::string>::iterator iter;
for (iter = tmpList.begin(); iter != tmpList.end(); )
{
if (bundle->GetStorage().IsDirectory(baseDir + *iter))
{
// uncomment the following line for a recursive lookup
//this->ListLibraries(bundle, list, baseDir + *iter + "/");
iter = tmpList.erase(iter);
}
else
{
if (iter->substr(iter->size() - suf) == Poco::SharedLibrary::suffix())
{
iter->erase(iter->size() - suf);
iter->insert(0, baseDir);
++iter;
}
else
{
iter = tmpList.erase(iter);
}
}
}
list.insert(list.end(), tmpList.begin(), tmpList.end());
}
void
BundleLoader::InstallLibraries(IBundle::Pointer bundle, bool copy)
{
std::vector<std::string> libraries;
this->ListLibraries(bundle, libraries);
std::vector<std::string>::iterator iter;
for (iter = libraries.begin(); iter != libraries.end(); ++iter)
{
if (iter->empty()) continue;
//BERRY_INFO << "Testing CodeCache for: " << *iter << std::endl;
std::size_t separator = iter->find_last_of("/");
std::string libFileName = *iter;
if (separator != std::string::npos)
libFileName = iter->substr(separator+1);
if (!m_CodeCache->HasLibrary(libFileName))
{
std::string libDir = "";
if (separator != std::string::npos)
libDir += iter->substr(0, separator);
// Check if we should copy the dll (from a ZIP file for example)
if (copy)
{
//TODO This copies all files which start with *iter to the
// plugin cache. This is necessary for Windows, for example,
// where a .dll file is accompanied by a set of other files.
// This should be extended to check for the right dll files, since
// it would be possible (and a good idea anyway) to put multiple
// versions of the same library in the ZIP file, targeting different
// compilers for example.
std::vector<std::string> files;
bundle->GetStorage().List(libDir, files);
for (std::vector<std::string>::iterator fileName = files.begin();
fileName != files.end(); ++fileName)
{
std::size_t size = std::min<std::size_t>(libFileName.size(), fileName->size());
if (fileName->compare(0, size, libFileName) != 0) continue;
std::istream* istr = bundle->GetResource(libDir + *fileName);
m_CodeCache->InstallLibrary(*iter, *istr);
delete istr;
}
}
else
{
Poco::Path bundlePath = bundle->GetStorage().GetPath();
bundlePath.append(Poco::Path::forDirectory(libDir));
// On Windows, we set the path environment variable to include
// the path to the library, so the loader can find it. We do this
// programmatically because otherwise, a user would have to edit
// a batch file every time he adds a new plugin from outside the
// build system.
#ifdef BERRY_OS_FAMILY_WINDOWS
std::string pathEnv = Poco::Environment::get("PATH", "");
if (!pathEnv.empty()) pathEnv += ";";
pathEnv += bundlePath.toString();
Poco::Environment::set("PATH", pathEnv);
#endif
m_CodeCache->InstallLibrary(libFileName, bundlePath);
}
}
}
}
void BundleLoader::ReadAllContributions()
{
Poco::Mutex::ScopedLock lock(m_Mutex);
BundleMap::iterator iter;
for (iter = m_BundleMap.begin(); iter != m_BundleMap.end(); ++iter)
{
if (iter->second.m_Bundle && iter->second.m_Bundle->IsResolved())
this->ReadContributions(iter->second.m_Bundle);
}
}
void BundleLoader::ReadContributions(IBundle::Pointer bundle)
{
this->ReadDependentContributions(bundle);
IExtensionPointService::Pointer service = Platform::GetExtensionPointService();
if (service->HasContributionFrom(bundle->GetSymbolicName())) return;
std::istream* istr = bundle->GetResource(this->GetContributionsPathFor(bundle));
if (istr)
{
service->AddContribution(*istr, bundle->GetSymbolicName());
delete istr;
}
}
void BundleLoader::ReadDependentContributions(IBundle::Pointer bundle)
{
Poco::Mutex::ScopedLock lock(m_Mutex);
const IBundleManifest::Dependencies& deps = bundle->GetRequiredBundles();
IBundleManifest::Dependencies::const_iterator iter;
for (iter = deps.begin(); iter != deps.end(); ++iter)
{
BundleMap::const_iterator depIter = m_BundleMap.find(iter->symbolicName);
if (depIter != m_BundleMap.end())
{
// only read contributions from legacy BlueBerry bundles
if (IBundle::Pointer depBundle = depIter->second.m_Bundle)
{
this->ReadContributions(depBundle);
}
}
}
}
void
BundleLoader::StartAllBundles()
{
Poco::Mutex::ScopedLock lock(m_Mutex);
BundleMap::iterator iter;
for (iter = m_BundleMap.begin(); iter != m_BundleMap.end(); ++iter)
{
try
{
if (iter->second.m_Bundle && iter->second.m_Bundle->GetActivationPolicy() == IBundleManifest::EAGER &&
!iter->second.m_Bundle->IsSystemBundle())
this->StartBundle(iter->second.m_Bundle);
}
catch (Poco::Exception exc)
{
BERRY_ERROR << exc.displayText() << std::endl;
}
}
}
void
BundleLoader::StartBundle(Bundle::Pointer bundle)
{
Poco::Mutex::ScopedLock lock(m_Mutex);
if (bundle->GetState() != IBundle::BUNDLE_RESOLVED) return;
this->StartDependencies(bundle);
BundleInfo info = m_BundleMap[bundle->GetSymbolicName()];
IBundleActivator* activator = this->LoadActivator(info);
Plugin* plugin = dynamic_cast<Plugin*>(activator);
if (plugin) plugin->m_Bundle = bundle;
bundle->SetActivator(activator);
bundle->Start();
}
void
BundleLoader::StartSystemBundle(SystemBundle::Pointer bundle)
{
Poco::Mutex::ScopedLock lock(m_Mutex);
if (bundle->IsStarted()) return;
BundleInfo info = m_BundleMap[bundle->GetSymbolicName()];
//IBundleActivator* activator = this->LoadActivator(info);
IBundleActivator* activator = new SystemBundleActivator();
bundle->SetActivator(activator);
activator->Start(info.m_Context);
}
void
BundleLoader::StartDependencies(Bundle::Pointer bundle)
{
Poco::Mutex::ScopedLock lock(m_Mutex);
const IBundleManifest::Dependencies& deps = bundle->GetRequiredBundles();
IBundleManifest::Dependencies::const_iterator iter;
QList<QSharedPointer<ctkPlugin> > ctkPlugins = CTKPluginActivator::getPluginContext()->getPlugins();
for (iter = deps.begin(); iter != deps.end(); ++iter)
{
BundleMap::const_iterator depIter = m_BundleMap.find(iter->symbolicName);
if (depIter != m_BundleMap.end())
{
if (Bundle::Pointer depBundle = depIter->second.m_Bundle)
{
this->StartBundle(depBundle);
}
}
else
{
foreach (QSharedPointer<ctkPlugin> ctkPlugin, ctkPlugins)
{
if (ctkPlugin->getSymbolicName() == QString::fromStdString(iter->symbolicName))
{
ctkPlugin->start(0);
break;
}
}
}
}
}
IBundleActivator*
BundleLoader::LoadActivator(BundleInfo& bundleInfo)
{
Poco::Mutex::ScopedLock lock(m_Mutex);
std::string activator = bundleInfo.m_Bundle->GetActivatorClass();
if (activator == "") return new DefaultActivator();
Poco::Path libPath = this->GetLibraryPathFor(bundleInfo.m_Bundle);
std::string strLibPath(libPath.toString());
BERRY_INFO(m_ConsoleLog) << "Loading activator library: " << strLibPath;
try
{
/* retrieves only an empty string and its not required
#ifdef BERRY_OS_FAMILY_WINDOWS
char cDllPath[512];
GetDllDirectory(512, cDllPath);
BERRY_INFO << "Dll Path: " << cDllPath << std::endl;
#endif
*/
bundleInfo.m_ClassLoader->loadLibrary(strLibPath);
return bundleInfo.m_ClassLoader->create(activator);
}
catch (Poco::LibraryLoadException exc)
{
BERRY_ERROR << "Could not create Plugin activator. Did you export the class \"" << activator << "\" ?\n"
<< " Exception displayText(): " << exc.displayText();
exc.rethrow();
}
return 0;
}
} // namespace berry
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berryBundleLoader.h b/BlueBerry/Bundles/org.blueberry.osgi/src/berryBundleLoader.h
index 65f2e1470b..9a2084f0f7 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/berryBundleLoader.h
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/berryBundleLoader.h
@@ -1,137 +1,137 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYBUNDLELOADER_H_
#define BERRYBUNDLELOADER_H_
#include "Poco/ClassLoader.h"
#include "Poco/Mutex.h"
#include "Poco/Path.h"
#include "Poco/Any.h"
#include "Poco/SharedPtr.h"
#include "Poco/Logger.h"
#include <typeinfo>
#include <map>
#include <QStringList>
#include "event/berryBundleEvents.h"
#include "berryIBundleActivator.h"
#include "internal/berryBundle.h"
#include "internal/berrySystemBundle.h"
namespace berry {
class CodeCache;
struct IBundleContext;
/**
* Intentionally no BERRY_OSGI macro. This class belongs into "internal" but
* needs to stay here.
*/
class BERRY_OSGI BundleLoader
{
private:
typedef Poco::ClassLoader<IBundleActivator> ActivatorClassLoader;
typedef Poco::SharedPtr<ActivatorClassLoader> ActivatorClassLoaderPtr;
struct BundleInfo {
Bundle::Pointer m_Bundle;
ActivatorClassLoaderPtr m_ClassLoader;
std::map<std::string, Poco::Any*> m_ClassLoaderMap;
SmartPointer<IBundleContext> m_Context;
};
typedef std::map<std::string, BundleInfo> BundleMap;
BundleMap m_BundleMap;
BundleEvents m_BundleEvents;
CodeCache* m_CodeCache;
Poco::Logger& m_Logger;
Bundle::Pointer m_SystemBundle;
mutable Poco::Mutex m_Mutex;
bool m_ConsoleLog;
QStringList installedCTKPlugins;
IBundleActivator* LoadActivator(BundleInfo& bundleInfo);
friend class InternalPlatform;
friend class BundleContext;
void StartSystemBundle(SmartPointer<SystemBundle> bundle);
void ListLibraries(SmartPointer<IBundle> bundle, std::vector<std::string>& list, const std::string& baseDir);
public:
BundleLoader(CodeCache* codeCache, Poco::Logger& logger); //, BundleFactory* bundleFactory, BundleContextFactory* bundleContextFactory);
virtual ~BundleLoader();
void SetCTKPlugins(const QStringList& installedCTKPlugins);
SmartPointer<IBundleContext> GetContextForBundle(IBundle::ConstPointer bundle);
Bundle::Pointer CreateBundle(const Poco::Path& path);
BundleEvents& GetEvents();
IBundle::Pointer FindBundle(const std::string& symbolicName);
std::vector<IBundle::Pointer> GetBundles() const;
Bundle::Pointer LoadBundle(const Poco::Path& path);
void LoadBundle(Bundle::Pointer bundle);
Poco::Path GetPathForLibrary(const std::string& libraryName);
Poco::Path GetLibraryPathFor(SmartPointer<IBundle> bundle);
std::string GetContributionsPathFor(SmartPointer<IBundle> bundle);
Poco::Logger& GetLogger() const;
void ResolveBundle(SmartPointer<IBundle> bundle);
void ResolveAllBundles();
void ReadAllContributions();
void ReadContributions(SmartPointer<IBundle> bundle);
void ReadDependentContributions(SmartPointer<IBundle> bundle);
void ListLibraries(SmartPointer<IBundle> bundle, std::vector<std::string>& list);
void InstallLibraries(SmartPointer<IBundle> bundle, bool copy = false);
// start all resolved bundles, except the system bundle
// (it is assumed, that the system bundle has already
// been started)
void StartAllBundles();
void StartBundle(SmartPointer<Bundle> bundle);
void StartDependencies(SmartPointer<Bundle> bundle);
template<class C>
C* LoadClass(const std::string& bundleName, const std::string& className);
template<class C>
C* LoadClass(const std::string& bundleName, const std::string& className, const std::string& manifestName);
};
} // namespace berry
#include "berryBundleLoader.txx"
#endif /*BERRYBUNDLELOADER_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berryBundleLoader.txx b/BlueBerry/Bundles/org.blueberry.osgi/src/berryBundleLoader.txx
index 58d8d3549c..76d884419e 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/berryBundleLoader.txx
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/berryBundleLoader.txx
@@ -1,85 +1,85 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 __BERRY_BUNDLE_LOADER_TXX__
#define __BERRY_BUNDLE_LOADER_TXX__
#include <iostream>
#include "berryLog.h"
#include "berryIBundleContext.h"
namespace berry {
template<class C>
C* BundleLoader::LoadClass(const std::string& bundleName, const std::string& className)
{
return LoadClass<C>(bundleName, className, C::GetManifestName());
}
template<class C>
C* BundleLoader::LoadClass(const std::string& bundleName, const std::string& className, const std::string& manifestName)
{
BERRY_INFO(m_ConsoleLog) << "Trying to load class " << className << " with manifest name " << manifestName << " from bundle " << bundleName;
BundleMap::iterator bundleIter = m_BundleMap.find(bundleName);
if (bundleIter == m_BundleMap.end())
{
BERRY_INFO(m_ConsoleLog) << "This bundle is not a legacy BlueBerry bundle. Cannot load classes from it.";
return 0;
}
BundleInfo& bundleInfo = bundleIter->second;
// check that bundle is started
if (!bundleInfo.m_Bundle->IsStarted()) this->StartBundle(bundleInfo.m_Bundle);
Poco::Any* any = bundleInfo.m_ClassLoaderMap[typeid(C).name()];
if (any == 0)
{
BERRY_INFO(m_ConsoleLog) << "Creating new classloader for type: " << typeid(C).name() << std::endl;
any = new Poco::Any(Poco::SharedPtr<Poco::ClassLoader<C> >(new Poco::ClassLoader<C>()));
bundleInfo.m_ClassLoaderMap[typeid(C).name()] = any;
}
Poco::SharedPtr<Poco::ClassLoader<C> >& cl =
Poco::RefAnyCast<Poco::SharedPtr<Poco::ClassLoader<C> > >(*any);
std::string libName = "lib" + bundleInfo.m_Bundle->GetSymbolicName();
Poco::Path libPath(bundleInfo.m_Context->GetPathForLibrary(libName));
if (!cl->isLibraryLoaded(libPath.toString()))
{
BERRY_INFO(m_ConsoleLog) << "Loading library: " << libPath.toString();
try {
cl->loadLibrary(libPath.toString(), manifestName);
}
catch (const Poco::LibraryLoadException& e){
BERRY_ERROR << e.displayText();
}
}
else {
BERRY_INFO(m_ConsoleLog) << "Library " << libPath.toString() << " already loaded";
}
return cl->create(className);
}
}
#endif // __BERRY_BUNDLE_LOADER_TXX__
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berryConfig.h.in b/BlueBerry/Bundles/org.blueberry.osgi/src/berryConfig.h.in
index 5c60d5e8b8..7dae4fa872 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/berryConfig.h.in
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/berryConfig.h.in
@@ -1,25 +1,25 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYCONFIG_H_
#define BERRYCONFIG_H_
#cmakedefine BLUEBERRY_DEBUG_SMARTPOINTER
#define QT_ASSISTANT_EXECUTABLE "@QT_ASSISTANT_EXECUTABLE@"
#endif /* BERRYCONFIG_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berryDebugBreakpointManager.cpp b/BlueBerry/Bundles/org.blueberry.osgi/src/berryDebugBreakpointManager.cpp
index 87a1e808eb..545e0240c3 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/berryDebugBreakpointManager.cpp
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/berryDebugBreakpointManager.cpp
@@ -1,237 +1,237 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryDebugBreakpointManager.h"
#include "berryDebugUtil.h"
#include "berryObject.h"
#include "berryLog.h"
#include <Poco/NumberParser.h>
#include <Poco/DOM/NodeList.h>
#include <Poco/DOM/DOMParser.h>
#include <Poco/DOM/Document.h>
#include <Poco/DOM/Element.h>
#include <Poco/DOM/DOMWriter.h>
#include <Poco/SAX/InputSource.h>
#include <Poco/SAX/SAXException.h>
#include <Poco/FileStream.h>
#include <sstream>
namespace berry
{
const std::string DebugBreakpointManager::BREAKPOINTS_XML = "breakpoints.xml";
const std::string DebugBreakpointManager::BREAKPOINTS_TAG = "breakpoints";
const std::string DebugBreakpointManager::OBJECT_TAG = "object";
const std::string DebugBreakpointManager::SMARTPOINTER_TAG = "smartpointer";
const std::string DebugBreakpointManager::ID_ATTR = "id";
const std::string DebugBreakpointManager::CLASSNAME_ATTR = "className";
const std::string DebugBreakpointManager::OBJECTID_ATTR = "objectId";
const std::string DebugBreakpointManager::ENABLED_ATTR = "enabled";
void DebugBreakpointManager::AddSmartpointerBreakpoint(int smartPointerId,
const Object* obj)
{
BERRY_INFO << "Smartpointer breakpoint added: " << smartPointerId;
m_SmartPointerBreakpoints[smartPointerId] = obj;
}
void DebugBreakpointManager::AddObjectBreakpoint(unsigned long objectTraceId)
{
BERRY_INFO << "Object breakpoint added: " << objectTraceId;
m_ObjectBreakpoints.insert(objectTraceId);
}
void DebugBreakpointManager::RemoveSmartpointerBreakpoint(int smartPointerId)
{
m_SmartPointerBreakpoints.erase(smartPointerId);
}
void DebugBreakpointManager::RemoveObjectBreakpoint(unsigned long objectTraceId)
{
m_ObjectBreakpoints.erase(objectTraceId);
}
const std::set<unsigned long>& DebugBreakpointManager::GetObjectBreakpoints() const
{
return m_ObjectBreakpoints;
}
const Poco::HashMap<int, const Object*>& DebugBreakpointManager::GetSmartPointerBreakpoints() const
{
return m_SmartPointerBreakpoints;
}
bool DebugBreakpointManager::BreakAtObject(unsigned long traceId) const
{
return m_ObjectBreakpoints.find(traceId) != m_ObjectBreakpoints.end();
}
bool DebugBreakpointManager::BreakAtSmartpointer(int spId) const
{
return m_SmartPointerBreakpoints.find(spId)
!= m_SmartPointerBreakpoints.end();
}
#ifdef BLUEBERRY_DEBUG_SMARTPOINTER
void DebugBreakpointManager::SaveState(const Poco::Path& path) const
{
Poco::XML::Document* doc = new Poco::XML::Document();
Poco::XML::Element* breakpoints = doc->createElement(BREAKPOINTS_TAG);
doc->appendChild(breakpoints)->release();
for (std::set<unsigned long>::const_iterator i = m_ObjectBreakpoints.begin(); i
!= m_ObjectBreakpoints.end(); ++i)
{
Poco::XML::Element* objectBreakpoint = doc->createElement(OBJECT_TAG);
breakpoints->appendChild(objectBreakpoint)->release();
std::stringstream ss;
ss << *i;
objectBreakpoint->setAttribute(ID_ATTR, ss.str());
const Object* obj = DebugUtil::GetObject(*i);
if (obj)
{
objectBreakpoint->setAttribute(CLASSNAME_ATTR, obj->GetClassName());
}
}
for (Poco::HashMap<int, const Object*>::ConstIterator i =
m_SmartPointerBreakpoints.begin(); i != m_SmartPointerBreakpoints.end(); ++i)
{
Poco::XML::Element* spBreakpoint = doc->createElement(SMARTPOINTER_TAG);
breakpoints->appendChild(spBreakpoint)->release();
std::stringstream ss;
ss << i->first;
spBreakpoint->setAttribute(ID_ATTR, ss.str());
const Object* obj = i->second;
if (i->second)
{
spBreakpoint->setAttribute(CLASSNAME_ATTR, obj->GetClassName());
ss.clear();
ss << obj->GetTraceId();
spBreakpoint->setAttribute(OBJECTID_ATTR, ss.str());
}
}
Poco::FileOutputStream writer(path.toString());
Poco::XML::DOMWriter out;
out.setOptions(3); //write declaration and pretty print
out.writeNode(writer, doc);
doc->release();
}
#else
void DebugBreakpointManager::SaveState(const Poco::Path& /*path*/) const
{}
#endif
#ifdef BLUEBERRY_DEBUG_SMARTPOINTER
void DebugBreakpointManager::RestoreState(const Poco::Path& path)
{
try
{
Poco::XML::DOMParser parser;
Poco::FileInputStream reader(path.toString());
Poco::XML::InputSource source(reader);
//source.setSystemId(baseDir);
Poco::XML::Document* doc = parser.parse(&source);
Poco::XML::Element* breakpoints = doc->documentElement();
if (breakpoints)
{
// restore object breakpoints
Poco::XML::NodeList* elementList = breakpoints->getElementsByTagName(
OBJECT_TAG);
for (std::size_t i = 0; i < elementList->length(); i++)
{
Poco::XML::Element* elem =
dynamic_cast<Poco::XML::Element*> (elementList->item(i));
if (!elem->hasAttribute(ID_ATTR))
continue;
const std::string& attr = elem->getAttribute(ID_ATTR);
int traceId = 0;
try
{
traceId = Poco::NumberParser::parse(attr);
} catch (const Poco::SyntaxException& e)
{
BERRY_WARN << e.displayText();
}
DebugUtil::GetBreakpointManager()->AddObjectBreakpoint(traceId);
}
elementList->release();
// restore smartpointer breakpoints
elementList = breakpoints->getElementsByTagName(SMARTPOINTER_TAG);
for (std::size_t i = 0; i < elementList->length(); i++)
{
Poco::XML::Element* elem =
dynamic_cast<Poco::XML::Element*> (elementList->item(i));
if (!elem->hasAttribute(ID_ATTR))
continue;
const std::string& attr = elem->getAttribute(ID_ATTR);
int spId = 0;
try
{
spId = Poco::NumberParser::parse(attr);
} catch (const Poco::SyntaxException& e)
{
BERRY_WARN << e.displayText();
}
DebugUtil::GetBreakpointManager()->AddSmartpointerBreakpoint(spId);
}
elementList->release();
}
doc->release();
} catch (Poco::XML::SAXParseException& e)
{
BERRY_WARN << e.displayText();
}
catch (Poco::FileNotFoundException& /*e*/)
{
}
catch (Poco::FileException& e)
{
BERRY_WARN << e.displayText();
}
}
#else
void DebugBreakpointManager::RestoreState(const Poco::Path& /*path*/)
{
}
#endif
}
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berryDebugBreakpointManager.h b/BlueBerry/Bundles/org.blueberry.osgi/src/berryDebugBreakpointManager.h
index 70b52f34c6..e364059f85 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/berryDebugBreakpointManager.h
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/berryDebugBreakpointManager.h
@@ -1,74 +1,74 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYDEBUGBREAKPOINTMANAGER_H_
#define BERRYDEBUGBREAKPOINTMANAGER_H_
#include <Poco/Path.h>
#include <Poco/HashMap.h>
#include <set>
#include <org_blueberry_osgi_Export.h>
namespace berry {
class Object;
class BERRY_OSGI DebugBreakpointManager
{
public:
static const std::string BREAKPOINTS_XML;
void AddSmartpointerBreakpoint(int smartPointerId, const Object* obj = 0);
void AddObjectBreakpoint(unsigned long objectTraceId);
void RemoveSmartpointerBreakpoint(int smartPointerId);
void RemoveObjectBreakpoint(unsigned long objectTraceId);
const std::set<unsigned long>& GetObjectBreakpoints() const;
const Poco::HashMap<int, const Object*>& GetSmartPointerBreakpoints() const;
bool BreakAtObject(unsigned long traceId) const;
bool BreakAtSmartpointer(int spId) const;
void SaveState(const Poco::Path& path) const;
void RestoreState(const Poco::Path& path);
private:
friend class DebugUtil;
DebugBreakpointManager() {}
DebugBreakpointManager(const DebugBreakpointManager&) {}
static const std::string BREAKPOINTS_TAG;
static const std::string OBJECT_TAG;
static const std::string SMARTPOINTER_TAG;
static const std::string ID_ATTR;
static const std::string CLASSNAME_ATTR;
static const std::string OBJECTID_ATTR;
static const std::string ENABLED_ATTR;
std::set<unsigned long> m_ObjectBreakpoints;
Poco::HashMap<int, const Object*> m_SmartPointerBreakpoints;
};
}
#endif /* BERRYDEBUGBREAKPOINTMANAGER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berryDebugUtil.cpp b/BlueBerry/Bundles/org.blueberry.osgi/src/berryDebugUtil.cpp
index 1bfca4d018..2ac96aabe3 100755
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/berryDebugUtil.cpp
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/berryDebugUtil.cpp
@@ -1,554 +1,554 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryIDebugObjectListener.h"
#include "berryDebugUtil.h"
#include "berryObject.h"
#include "berryLog.h"
#include "berryPlatform.h"
#include "berryDebugBreakpointManager.h"
#include <Poco/Bugcheck.h>
#include <Poco/NumberParser.h>
#include <Poco/DOM/NodeList.h>
#include <Poco/DOM/DOMParser.h>
#include <Poco/DOM/Document.h>
#include <Poco/DOM/Element.h>
#include <Poco/DOM/DOMWriter.h>
#include <Poco/SAX/InputSource.h>
#include <Poco/SAX/SAXException.h>
#include <Poco/FileStream.h>
#include <sstream>
#include <numeric>
namespace berry
{
static IDebugObjectListener::Events _G_ObjectEvents;
const std::string DebugUtil::DEBUG_UTIL_XML = "debugutil.xml";
const std::string DebugUtil::DEBUGUTIL_TAG = "debugutil";
const std::string DebugUtil::TRACEOBJECT_TAG = "traceObject";
const std::string DebugUtil::TRACECLASS_TAG = "traceClass";
const std::string DebugUtil::ID_ATTR = "id";
const std::string DebugUtil::NAME_ATTR = "name";
Poco::HashMap<Poco::UInt32, std::list<unsigned int> >
DebugUtil::m_TraceIdToSmartPointerMap;
Poco::HashMap<Poco::UInt32, const Object*> DebugUtil::m_TraceIdToObjectMap;
std::set<unsigned int> DebugUtil::m_TracedObjects;
std::set<std::string> DebugUtil::m_TracedClasses;
class NotClassName: public std::unary_function<const Object*, bool>
{
std::string name;
public:
NotClassName(const std::string& s) :
name(s)
{
}
bool operator()(Poco::HashMapEntry<unsigned int, const Object*>& entry) const
{
return name != entry.second->GetClassName();
}
};
class AccumulateClassNames: public std::binary_function<std::set<std::string>*,
Poco::HashMapEntry<unsigned int, const Object*>&, std::set<std::string>*>
{
public:
std::set<std::string>* operator()(std::set<std::string>* names,
Poco::HashMapEntry<unsigned int, const Object*>& entry)
{
names->insert(entry.second->GetClassName());
return names;
}
};
DebugBreakpointManager* DebugUtil::GetBreakpointManager()
{
static DebugBreakpointManager breakpointManager;
return &breakpointManager;
}
#ifdef BLUEBERRY_DEBUG_SMARTPOINTER
void DebugUtil::TraceObject(const Object* object)
{
BERRY_INFO << "Tracing enabled for: " << object->GetTraceId() << std::endl;
m_TracedObjects.insert(object->GetTraceId());
_G_ObjectEvents.objTracingEvent(object->GetTraceId(), true, object);
}
#else
void DebugUtil::TraceObject(const Object* /*object*/)
{
}
#endif
#ifdef BLUEBERRY_DEBUG_SMARTPOINTER
void DebugUtil::TraceObject(unsigned int traceId)
{
BERRY_INFO << "Tracing enabled for: " << traceId << std::endl;
m_TracedObjects.insert(traceId);
TraceIdToObjectType::ConstIterator i = m_TraceIdToObjectMap.find(traceId);
if (i != m_TraceIdToObjectMap.end())
_G_ObjectEvents.objTracingEvent(traceId, true, i->second);
else
_G_ObjectEvents.objTracingEvent(traceId, true, 0);
}
#else
void DebugUtil::TraceObject(unsigned int /*traceId*/)
{
}
#endif
#ifdef BLUEBERRY_DEBUG_SMARTPOINTER
void DebugUtil::TraceClass(const std::string& className)
{
BERRY_INFO << "Tracing enabled for: " << className << std::endl;
m_TracedClasses.insert(className);
//_G_ObjectEvents.objTracingEvent(object->GetTraceId(), true, object);
}
#else
void DebugUtil::TraceClass(const std::string& /*className*/)
{
}
#endif
#ifdef BLUEBERRY_DEBUG_SMARTPOINTER
void DebugUtil::StopTracing(unsigned int traceId)
{
BERRY_INFO << "Tracing stopped for: " << traceId << std::endl;
m_TracedObjects.erase(traceId);
TraceIdToObjectType::ConstIterator i = m_TraceIdToObjectMap.find(traceId);
if (i != m_TraceIdToObjectMap.end())
_G_ObjectEvents.objTracingEvent(traceId, false, i->second);
else
_G_ObjectEvents.objTracingEvent(traceId, false, 0);
}
#else
void DebugUtil::StopTracing(unsigned int /*traceId*/)
{
}
#endif
#ifdef BLUEBERRY_DEBUG_SMARTPOINTER
void DebugUtil::StopTracing(const Object* obj)
{
BERRY_INFO << "Tracing stopped for: " << obj->GetTraceId() << std::endl;
m_TracedObjects.erase(obj->GetTraceId());
_G_ObjectEvents.objTracingEvent(obj->GetTraceId(), false, obj);
}
#else
void DebugUtil::StopTracing(const Object* /*obj*/)
{
}
#endif
#ifdef BLUEBERRY_DEBUG_SMARTPOINTER
void DebugUtil::StopTracing(const std::string& className)
{
BERRY_INFO << "Tracing stopped for: " << className << std::endl;
m_TracedClasses.erase(className);
//_G_ObjectEvents.objTracingEvent(obj->GetTraceId(), false, obj);
}
#else
void DebugUtil::StopTracing(const std::string& /*className*/)
{
}
#endif
#ifdef BLUEBERRY_DEBUG_SMARTPOINTER
bool DebugUtil::IsTraced(const Object* object)
{
if (m_TracedObjects.find(object->GetTraceId()) != m_TracedObjects.end())
return true;
if (m_TracedClasses.find(object->GetClassName()) != m_TracedClasses.end())
return true;
return false;
}
#else
bool DebugUtil::IsTraced(const Object* /*object*/)
{
return false;
}
#endif
#ifdef BLUEBERRY_DEBUG_SMARTPOINTER
bool DebugUtil::IsTraced(unsigned int traceId)
{
if (m_TracedObjects.find(traceId) != m_TracedObjects.end())
return true;
TraceIdToObjectType::Iterator it = m_TraceIdToObjectMap.find(traceId);
if (it != m_TraceIdToObjectMap.end())
{
if (m_TracedClasses.find(it->second->GetClassName()) != m_TracedClasses.end())
return true;
}
return false;
}
#else
bool DebugUtil::IsTraced(unsigned int /*traceId*/)
{
return false;
}
#endif
#ifdef BLUEBERRY_DEBUG_SMARTPOINTER
bool DebugUtil::IsTraced(const std::string& className)
{
return m_TracedClasses.find(className) != m_TracedClasses.end();
}
#else
bool DebugUtil::IsTraced(const std::string& /*className*/)
{
return false;
}
#endif
const std::set<unsigned int>& DebugUtil::GetTracedObjects()
{
return m_TracedObjects;
}
const Object* DebugUtil::GetObject(unsigned int traceId)
{
return m_TraceIdToObjectMap[traceId];
}
#ifdef BLUEBERRY_DEBUG_SMARTPOINTER
std::list<unsigned int> DebugUtil::GetSmartPointerIDs(
const Object* objectPointer, const std::list<unsigned int>& excludeList)
{
poco_assert(objectPointer != 0);
std::list<unsigned int> ids = m_TraceIdToSmartPointerMap[objectPointer->GetTraceId()];
for (std::list<unsigned int>::const_iterator iter = excludeList.begin();
iter != excludeList.end(); ++iter)
ids.remove(*iter);
return ids;
}
#else
std::list<unsigned int> DebugUtil::GetSmartPointerIDs(
const Object* /*objectPointer*/, const std::list<unsigned int>& /*excludeList*/)
{
return std::list<unsigned int>();
}
#endif
void DebugUtil::GetRegisteredObjects(std::vector<const Object*>& list)
{
for (TraceIdToObjectType::ConstIterator i = m_TraceIdToObjectMap.begin();
i != m_TraceIdToObjectMap.end(); ++i)
{
list.push_back(i->second);
}
}
void DebugUtil::PrintSmartPointerIDs(const Object* objectPointer, std::ostream& stream, const std::list<unsigned int>& excludeList)
{
stream << "SmartPointer IDs [ ";
if (IsTraced(objectPointer))
{
std::list<unsigned int> ids = GetSmartPointerIDs(objectPointer, excludeList);
for (std::list<unsigned int>::const_iterator iter = ids.begin();
iter != ids.end(); ++iter)
{
stream << *iter << " ";
}
}
else
{
stream << "n/a ";
}
stream << "]\n";
}
void DebugUtil::AddObjectListener(SmartPointer<IDebugObjectListener> listener)
{
_G_ObjectEvents.AddListener(listener);
}
void DebugUtil::RemoveObjectListener(SmartPointer<IDebugObjectListener> listener)
{
_G_ObjectEvents.RemoveListener(listener);
}
void DebugUtil::ResetObjectSummary()
{
m_TraceIdToObjectMap.clear();
m_TraceIdToSmartPointerMap.clear();
m_TracedObjects.clear();
}
bool DebugUtil::PrintObjectSummary(bool details)
{
std::set<std::string> names;
std::accumulate(m_TraceIdToObjectMap.begin(), m_TraceIdToObjectMap.end(), &names, AccumulateClassNames());
if (!names.empty())
{
std::cout << std::endl << std::endl << "#########################################################" << std::endl;
std::cout << "######## berry::Object leakage summary: ########" << std::endl << std::endl;
for (std::set<std::string>::const_iterator i = names.begin();
i != names.end(); ++i)
{
PrintObjectSummary(*i, details);
if (details) std::cout << std::endl;
}
std::cout << std::endl << "#########################################################" << std::endl << std::endl;
}
return !names.empty();
}
bool DebugUtil::PrintObjectSummary(const std::string& className, bool details)
{
TraceIdToObjectType::ConstIterator endIter =
std::remove_if(m_TraceIdToObjectMap.begin(), m_TraceIdToObjectMap.end(), NotClassName(className));
std::cout << "Class: " << className;
if (details) std::cout << std::endl;
std::size_t count = 0;
for (TraceIdToObjectType::ConstIterator iter = m_TraceIdToObjectMap.begin();
iter != endIter; ++iter, ++count)
{
if (details)
{
std::cout << *(iter->second);
PrintSmartPointerIDs(iter->second, std::cout);
}
}
std::cout << " (" << count << " instances)" << std::endl;
return (count!=0);
}
unsigned int& DebugUtil::GetSmartPointerCounter()
{
static unsigned int counter = 0;
return counter;
}
#ifdef BLUEBERRY_DEBUG_SMARTPOINTER
void DebugUtil::UnregisterSmartPointer(unsigned int smartPointerId, const Object* objectPointer)
{
poco_assert(objectPointer != 0);
m_TraceIdToSmartPointerMap[objectPointer->GetTraceId()].remove(smartPointerId);
_G_ObjectEvents.spDestroyedEvent(smartPointerId, objectPointer);
}
#else
void DebugUtil::UnregisterSmartPointer(unsigned int /*smartPointerId*/, const Object* /*objectPointer*/)
{
}
#endif
#ifdef BLUEBERRY_DEBUG_SMARTPOINTER
void DebugUtil::RegisterSmartPointer(unsigned int smartPointerId, const Object* objectPointer, bool /*recordStack*/)
{
poco_assert(objectPointer != 0);
if (m_TracedClasses.find(objectPointer->GetClassName()) != m_TracedClasses.end() ||
m_TracedObjects.find(objectPointer->GetTraceId()) != m_TracedObjects.end())
{
m_TraceIdToSmartPointerMap[objectPointer->GetTraceId()].push_back(smartPointerId);
_G_ObjectEvents.spCreatedEvent(smartPointerId, objectPointer);
}
if (GetBreakpointManager()->BreakAtSmartpointer(smartPointerId))
poco_debugger_msg("SmartPointer Breakpoint reached");
}
#else
void DebugUtil::RegisterSmartPointer(unsigned int /*smartPointerId*/, const Object* /*objectPointer*/, bool /*recordStack*/)
{
}
#endif
#ifdef BLUEBERRY_DEBUG_SMARTPOINTER
void DebugUtil::RegisterObject(const Object* objectPointer)
{
m_TraceIdToObjectMap.insert(std::make_pair(objectPointer->GetTraceId(), objectPointer));
_G_ObjectEvents.objCreatedEvent(objectPointer);
if (GetBreakpointManager()->BreakAtObject(objectPointer->GetTraceId()))
poco_debugger_msg("SmartPointer Breakpoint reached");
}
#else
void DebugUtil::RegisterObject(const Object* /*objectPointer*/)
{
}
#endif
#ifdef BLUEBERRY_DEBUG_SMARTPOINTER
void DebugUtil::UnregisterObject(const Object* objectPointer)
{
m_TraceIdToObjectMap.erase(objectPointer->GetTraceId());
_G_ObjectEvents.objDestroyedEvent(objectPointer);
}
#else
void DebugUtil::UnregisterObject(const Object* /*objectPointer*/)
{
}
#endif
bool DebugUtil::GetPersistencePath(Poco::Path& path)
{
return Platform::GetStatePath(path, Platform::GetBundle("system.bundle"));
}
void DebugUtil::SaveState()
{
Poco::Path path;
if (!GetPersistencePath(path)) return;
path.setFileName(DEBUG_UTIL_XML);
Poco::XML::Document* doc = new Poco::XML::Document();
Poco::XML::Element* debugutil = doc->createElement(DEBUGUTIL_TAG);
doc->appendChild(debugutil)->release();
for (std::set<unsigned int>::const_iterator i = m_TracedObjects.begin();
i != m_TracedObjects.end(); ++i)
{
Poco::XML::Element* traceObject = doc->createElement(TRACEOBJECT_TAG);
debugutil->appendChild(traceObject)->release();
std::stringstream ss;
ss << *i;
traceObject->setAttribute(ID_ATTR, ss.str());
}
for (std::set<std::string>::const_iterator i = m_TracedClasses.begin();
i != m_TracedClasses.end(); ++i)
{
Poco::XML::Element* traceClass = doc->createElement(TRACECLASS_TAG);
debugutil->appendChild(traceClass)->release();
traceClass->setAttribute(NAME_ATTR, *i);
}
try
{
Poco::FileOutputStream writer(path.toString());
Poco::XML::DOMWriter out;
out.setOptions(3); //write declaration and pretty print
out.writeNode(writer, doc);
doc->release();
// save BreakpointManager
path.setFileName(DebugBreakpointManager::BREAKPOINTS_XML);
GetBreakpointManager()->SaveState(path);
}
catch (Poco::FileException& e)
{
BERRY_WARN << e.displayText();
}
}
void DebugUtil::RestoreState()
{
Poco::Path path;
if (!GetPersistencePath(path)) return;
path.setFileName(DEBUG_UTIL_XML);
try
{
Poco::XML::DOMParser parser;
Poco::FileInputStream reader(path.toString());
Poco::XML::InputSource source(reader);
//source.setSystemId(baseDir);
Poco::XML::Document* doc = parser.parse(&source);
Poco::XML::Element* debugutil = doc->documentElement();
if (debugutil)
{
// restore traced objects
Poco::XML::NodeList* elementList = debugutil->getElementsByTagName(TRACEOBJECT_TAG);
for (std::size_t i = 0; i < elementList->length(); i++)
{
Poco::XML::Element* elem =
dynamic_cast<Poco::XML::Element*> (elementList->item(static_cast<unsigned long>(i)));
if (!elem->hasAttribute(ID_ATTR)) continue;
const std::string& attr = elem->getAttribute(ID_ATTR);
int traceId = 0;
try
{
traceId = Poco::NumberParser::parse(attr);
}
catch (const Poco::SyntaxException& e)
{
BERRY_WARN << e.displayText();
}
DebugUtil::TraceObject(traceId);
}
elementList->release();
// restore traced classes
elementList = debugutil->getElementsByTagName(TRACECLASS_TAG);
for (std::size_t i = 0; i < elementList->length(); i++)
{
Poco::XML::Element* elem =
dynamic_cast<Poco::XML::Element*> (elementList->item(static_cast<unsigned long>(i)));
if (!elem->hasAttribute(NAME_ATTR)) continue;
const std::string& traceClass = elem->getAttribute(NAME_ATTR);
if (!traceClass.empty())
DebugUtil::TraceClass(traceClass);
}
elementList->release();
}
doc->release();
}
catch (Poco::XML::SAXParseException& e)
{
BERRY_WARN << e.displayText();
}
catch (Poco::FileNotFoundException&)
{
}
catch (Poco::FileException& e)
{
BERRY_WARN << e.displayText();
}
// restore BreakpointManager
path.setFileName(DebugBreakpointManager::BREAKPOINTS_XML);
GetBreakpointManager()->RestoreState(path);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berryDebugUtil.h b/BlueBerry/Bundles/org.blueberry.osgi/src/berryDebugUtil.h
index 5d4189658b..c5bfb5fc7f 100755
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/berryDebugUtil.h
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/berryDebugUtil.h
@@ -1,107 +1,107 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYDEBUGUTIL_H_
#define BERRYDEBUGUTIL_H_
#include <map>
#include <list>
#include <set>
#include <iostream>
#include <Poco/HashMap.h>
#include <Poco/Path.h>
#include <org_blueberry_osgi_Export.h>
namespace berry {
class Object;
class DebugBreakpointManager;
struct IDebugObjectListener;
template <class T> class SmartPointer;
class BERRY_OSGI DebugUtil
{
public:
static DebugBreakpointManager* GetBreakpointManager();
static void TraceObject(const Object*);
static void TraceObject(unsigned int traceId);
static void TraceClass(const std::string& className);
static void StopTracing(unsigned int traceId);
static void StopTracing(const Object* obj);
static void StopTracing(const std::string& className);
static bool IsTraced(const Object* object);
static bool IsTraced(unsigned int traceId);
static bool IsTraced(const std::string& className);
static const std::set<unsigned int>& GetTracedObjects();
static const Object* GetObject(unsigned int traceId);
static std::list<unsigned int> GetSmartPointerIDs(const Object* objectPointer, const std::list<unsigned int>& excludeList = std::list<unsigned int>());
static void GetRegisteredObjects(std::vector<const Object*>& list);
static void PrintSmartPointerIDs(const Object* objectPointer, std::ostream& = std::cout, const std::list<unsigned int>& excludeList = std::list<unsigned int>());
static void ResetObjectSummary();
static bool PrintObjectSummary(bool details = false);
static bool PrintObjectSummary(const std::string& className, bool details = false);
static void AddObjectListener(SmartPointer<IDebugObjectListener> listener);
static void RemoveObjectListener(SmartPointer<IDebugObjectListener> listener);
static void SaveState();
static void RestoreState();
// ******* for internal use only *************
static unsigned int& GetSmartPointerCounter();
static void RegisterSmartPointer(unsigned int smartPointerId, const Object* objectPointer, bool recordStack = false);
static void UnregisterSmartPointer(unsigned int smartPointerId, const Object* objectPointer);
static void RegisterObject(const Object* objectPointer);
static void UnregisterObject(const Object* objectPointer);
// *******************************************
private:
static const std::string DEBUG_UTIL_XML;
static const std::string DEBUGUTIL_TAG;
static const std::string TRACEOBJECT_TAG;
static const std::string TRACECLASS_TAG;
static const std::string ID_ATTR;
static const std::string NAME_ATTR;
static bool GetPersistencePath(Poco::Path& path);
static Poco::HashMap<Poco::UInt32, std::list<unsigned int> > m_TraceIdToSmartPointerMap;
typedef Poco::HashMap<Poco::UInt32, const Object* > TraceIdToObjectType;
static TraceIdToObjectType m_TraceIdToObjectMap;
static std::set<unsigned int> m_TracedObjects;
static std::set<std::string> m_TracedClasses;
};
}
#endif /* BERRYDEBUGUTIL_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berryException.cpp b/BlueBerry/Bundles/org.blueberry.osgi/src/berryException.cpp
index 043e38ea96..4ebbac21f6 100755
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/berryException.cpp
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/berryException.cpp
@@ -1,26 +1,26 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryException.h"
#include <typeinfo>
namespace berry {
POCO_IMPLEMENT_EXCEPTION(BadWeakPointerException, Poco::Exception, "Bad WeakPointer exception")
}
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berryException.h b/BlueBerry/Bundles/org.blueberry.osgi/src/berryException.h
index a582be9ad6..b11a318c89 100755
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/berryException.h
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/berryException.h
@@ -1,30 +1,30 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYEXCEPTION_H_
#define BERRYEXCEPTION_H_
#include <org_blueberry_osgi_Export.h>
#include <Poco/Exception.h>
namespace berry {
POCO_DECLARE_EXCEPTION(BERRY_OSGI, BadWeakPointerException, Poco::Exception)
}
#endif /* BERRYEXCEPTION_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berryExtensionType.cpp b/BlueBerry/Bundles/org.blueberry.osgi/src/berryExtensionType.cpp
index 4e39bb5144..9f3bf7de8a 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/berryExtensionType.cpp
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/berryExtensionType.cpp
@@ -1,201 +1,201 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryExtensionType.h"
#include <QVector>
#include <QReadWriteLock>
#include <cstring>
namespace berry {
class CustomTypeInfo
{
public:
CustomTypeInfo() : typeName(), constr(0), destr(0)
{}
QByteArray typeName;
ExtensionType::Constructor constr;
ExtensionType::Destructor destr;
int alias;
};
//Q_DECLARE_TYPEINFO(QCustomTypeInfo, Q_MOVABLE_TYPE);
Q_GLOBAL_STATIC(QVector<CustomTypeInfo>, customTypes)
Q_GLOBAL_STATIC(QReadWriteLock, customTypesLock)
const char* ExtensionType::typeName(int type)
{
const QVector<CustomTypeInfo>* const ct = customTypes();
QReadLocker locker(customTypesLock());
return ct && ct->count() > type && !ct->at(type).typeName.isEmpty()
? ct->at(type).typeName.constData()
: static_cast<const char *>(0);
}
/*! \internal
Similar to ExtensionType::type(), but doesn't lock the mutex.
*/
static int extensionTypeCustomType_unlocked(const char *typeName, int length)
{
const QVector<CustomTypeInfo>* const ct = customTypes();
if (!ct) return 0;
for (int v = 0; v < ct->count(); ++v)
{
const CustomTypeInfo& customInfo = ct->at(v);
if ((length == customInfo.typeName.size())
&& !std::strcmp(typeName, customInfo.typeName.constData()))
{
if (customInfo.alias >= 0)
return customInfo.alias;
return v+1;
}
}
return 0;
}
int ExtensionType::registerType(const char *typeName, Destructor destructor,
Constructor constructor)
{
QVector<CustomTypeInfo>* ct = customTypes();
if (!ct || !typeName || !destructor || !constructor)
return -1;
QByteArray normalizedTypeName = QMetaObject::normalizedType(typeName);
QWriteLocker locker(customTypesLock());
int idx = extensionTypeCustomType_unlocked(normalizedTypeName.constData(),
normalizedTypeName.size());
if (!idx)
{
CustomTypeInfo inf;
inf.typeName = normalizedTypeName;
inf.constr = constructor;
inf.destr = destructor;
inf.alias = -1;
idx = ct->size();
ct->append(inf);
}
return idx;
}
int ExtensionType::registerTypedef(const char* typeName, int aliasId)
{
QVector<CustomTypeInfo>* ct = customTypes();
if (!ct || !typeName) return -1;
QByteArray normalizedTypeName = QMetaObject::normalizedType(typeName);
QWriteLocker locker(customTypesLock());
int idx = extensionTypeCustomType_unlocked(normalizedTypeName.constData(),
normalizedTypeName.size());
if (idx) return idx;
CustomTypeInfo inf;
inf.typeName = normalizedTypeName;
inf.alias = aliasId;
inf.constr = 0;
inf.destr = 0;
ct->append(inf);
return aliasId;
}
void ExtensionType::unregisterType(const char* typeName)
{
QVector<CustomTypeInfo> *ct = customTypes();
if (!ct || !typeName) return;
QByteArray normalizedTypeName = QMetaObject::normalizedType(typeName);
QWriteLocker locker(customTypesLock());
for (int v = 0; v < ct->count(); ++v)
{
if (ct->at(v).typeName == typeName)
{
CustomTypeInfo &inf = (*ct)[v];
inf.typeName.clear();
inf.constr = 0;
inf.destr = 0;
inf.alias = -1;
}
}
}
bool ExtensionType::isRegistered(int type)
{
QReadLocker locker(customTypesLock());
const QVector<CustomTypeInfo>* const ct = customTypes();
return ((type > 0) && (ct && ct->count() > type - 1) &&
!ct->at(type - 1).typeName.isEmpty());
}
int ExtensionType::type(const char *typeName)
{
int length = static_cast<int>(std::strlen(typeName));
if (!length) return 0;
QReadLocker locker(customTypesLock());
int type = extensionTypeCustomType_unlocked(typeName, length);
if (!type)
{
const QByteArray normalizedTypeName = QMetaObject::normalizedType(typeName);
type = extensionTypeCustomType_unlocked(normalizedTypeName.constData(),
normalizedTypeName.size());
}
return type;
}
QObject* ExtensionType::construct(int type)
{
const QVector<CustomTypeInfo> * const ct = customTypes();
Constructor constr = 0;
QReadLocker locker(customTypesLock());
if (!ct || ct->count() <= type - 1)
return 0;
if (ct->at(type - 1).typeName.isEmpty())
return 0;
constr = ct->at(type - 1).constr;
return constr();
}
void ExtensionType::destroy(int type, QObject* data)
{
if (!data) return;
const QVector<CustomTypeInfo> * const ct = customTypes();
if (!ct || ct->count() <= type - 1) return;
Destructor destr = 0;
QReadLocker locker(customTypesLock());
if (ct->at(type - 1).typeName.isEmpty())
return;
destr = ct->at(type - 1).destr;
destr(data);
}
} // end namespace berry
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berryExtensionType.h b/BlueBerry/Bundles/org.blueberry.osgi/src/berryExtensionType.h
index 3d9269a372..4270eb130d 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/berryExtensionType.h
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/berryExtensionType.h
@@ -1,192 +1,192 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRY_EXTENSION_TYPES_H
#define BERRY_EXTENSION_TYPES_H
#include <org_blueberry_osgi_Export.h>
#include <QObject>
namespace berry {
/**
* \brief The ExtensionType class manages named types
* \threadsafe
*
* The class associates a type
* name to a type so that it can be created and destructed
* dynamically at run-time. Call registerExtensionType() to make
* the type known.
*
* Any class or struct that inherits from QObject and has a public
* default constructor, and a public destructor can be registered.
*
*/
class BERRY_OSGI ExtensionType
{
public:
typedef void (*Destructor)(QObject *);
typedef QObject* (*Constructor)();
/**
* \internal
*
* Registers a type with typeName, a destructor, and a constructor.
* Returns the type's handle, or -1 if the type could not be registered.
*/
static int registerType(const char* typeName, Destructor destructor,
Constructor constructor);
/**
* \internal
*
* Registers a type as an alias of another type (typedef)
*/
static int registerTypedef(const char* typeName, int aliasId);
/**
* Unregisters a type with typeName.
*
* \sa type()
* \sa typeName()
*/
static void unregisterType(const char* typeName);
/**
* Returns a handle to the type called typeName, or 0 if there is
* no such type.
*
* \sa isRegistered()
* \sa typeName()
*/
static int type(const char* typeName);
/**
* Returns the type name associated with the given type, or 0 if no
* matching type was found. The returned pointer must not be deleted.
*
* \sa type()
* \sa isRegistered()
*/
static const char* typeName(int type);
/**
* Returns true if the datatype with ID type is registered;
* otherwise returns false.
*
* \sa type()
* \sa typeName()
*/
static bool isRegistered(int type);
/**
* Creates a default type.
*
* \sa destroy()
* \sa isRegistered()
*/
static QObject* construct(int type);
/**
* Destroys the data, assuming it is of the type given.
*
* \sa construct()
* \sa isRegistered()
*/
static void destroy(int type, QObject* data);
};
template <typename T>
void extensionTypeDeleteHelper(T* t)
{
delete t;
}
template <typename T>
QObject* extensionTypeConstructHelper(const T* /*t*/)
{
return new T;
}
template <typename T>
struct ExtensionTypeId
{
enum { Defined = 0 };
};
template <typename T>
struct ExtensionTypeId2
{
enum { Defined = ExtensionTypeId<T>::Defined };
static inline int extensiontype_id() { return ExtensionTypeId<T>::extensiontype_id(); }
};
namespace internal {
template <typename T, bool Defined = ExtensionTypeId2<T>::Defined>
struct ExtensionTypeIdHelper
{
static inline int extensiontype_id()
{ return ExtensionTypeId2<T>::extensiontype_id(); }
};
template <typename T>
struct ExtensionTypeIdHelper<T, false>
{
static inline int extensiontype_id()
{ return -1; }
};
} // end namespace internal
/**
* \threadsafe
*
* Registers the type name typeName for the type T. Returns
* the internal ID used by ExtensionType. Any class or struct that has a
* public default constructor, a public destructor, and a QObject base
* class can be registered.
*
* After a type has been registered, you can create and destroy
* objects of that type dynamically at run-time.
*/
template <typename T>
int registerExtensionType(const char* typeName
#ifndef DOXYGEN_SKIP
, T* dummy = 0
#endif
)
{
const int typedefOf = dummy ? -1 : internal::ExtensionTypeIdHelper<T>::extensiontype_id();
if (typedefOf != -1)
return ExtensionType::registerTypedef(typeName, typedefOf);
typedef QObject*(*ConstructPtr)(const T*);
ConstructPtr cptr = extensionTypeConstructHelper<T>;
typedef void(*DeletePtr)(T*);
DeletePtr dptr = extensionTypeDeleteHelper<T>;
return ExtensionType::registerType(typeName, reinterpret_cast<ExtensionType::Destructor>(dptr),
reinterpret_cast<ExtensionType::Constructor>(cptr));
}
} // end namespace berry
#endif // BERRY_EXTENSION_TYPES_H
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berryFlags.h b/BlueBerry/Bundles/org.blueberry.osgi/src/berryFlags.h
index 646bb8c150..77183b89cc 100755
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/berryFlags.h
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/berryFlags.h
@@ -1,85 +1,85 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYFLAGS_H_
#define BERRYFLAGS_H_
#include <org_blueberry_osgi_Export.h>
namespace berry {
class BERRY_OSGI Flag
{
int i;
public:
inline Flag(int i);
inline operator int() const { return i; }
};
inline Flag::Flag(int ai) : i(ai) {}
class BERRY_OSGI IncompatibleFlag
{
int i;
public:
inline explicit IncompatibleFlag(int i);
inline operator int() const { return i; }
};
inline IncompatibleFlag::IncompatibleFlag(int ai) : i(ai) {}
template<typename Enum>
class Flags
{
typedef void **Zero;
int i;
public:
typedef Enum enum_type;
inline Flags(const Flags &f) : i(f.i) {}
inline Flags(Enum f) : i(f) {}
inline Flags(Zero = 0) : i(0) {}
inline Flags(Flag f) : i(f) {}
inline Flags &operator=(const Flags &f) { i = f.i; return *this; }
inline Flags &operator&=(int mask) { i &= mask; return *this; }
inline Flags &operator&=(unsigned int mask) { i &= mask; return *this; }
inline Flags &operator|=(Flags f) { i |= f.i; return *this; }
inline Flags &operator|=(Enum f) { i |= f; return *this; }
inline Flags &operator^=(Flags f) { i ^= f.i; return *this; }
inline Flags &operator^=(Enum f) { i ^= f; return *this; }
inline operator int() const { return i; }
inline Flags operator|(Flags f) const { Flags g; g.i = i | f.i; return g; }
inline Flags operator|(Enum f) const { Flags g; g.i = i | f; return g; }
inline Flags operator^(Flags f) const { Flags g; g.i = i ^ f.i; return g; }
inline Flags operator^(Enum f) const { Flags g; g.i = i ^ f; return g; }
inline Flags operator&(int mask) const { Flags g; g.i = i & mask; return g; }
inline Flags operator&(unsigned int mask) const { Flags g; g.i = i & mask; return g; }
inline Flags operator&(Enum f) const { Flags g; g.i = i & f; return g; }
inline Flags operator~() const { Flags g; g.i = ~i; return g; }
inline bool operator!() const { return !i; }
inline bool TestFlag(Enum f) const { return (i & f) == f; }
};
} // namespace berry
#endif /* BERRYFLAGS_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berryIBundle.h b/BlueBerry/Bundles/org.blueberry.osgi/src/berryIBundle.h
index 37c747824a..3c4dcca5ce 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/berryIBundle.h
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/berryIBundle.h
@@ -1,87 +1,87 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIBUNDLE_H_
#define BERRYIBUNDLE_H_
#include "Poco/Path.h"
#include "Poco/Mutex.h"
#include "berryMacros.h"
#include "berryIBundleManifest.h"
namespace berry {
struct IBundleStorage;
struct IBundleActivator;
struct BundleEvents;
struct BERRY_OSGI IBundle : public Object
{
berryInterfaceMacro(IBundle, berry);
public:
enum State { BUNDLE_INSTALLED, BUNDLE_UNINSTALLED, BUNDLE_RESOLVED,
BUNDLE_STARTING, BUNDLE_ACTIVE, BUNDLE_STOPPING };
virtual ~IBundle() {};
virtual IBundleActivator* GetActivator() const = 0;
virtual const std::string& GetActivatorClass() const = 0;
virtual const std::string& GetActivatorLibrary() const = 0;
virtual const std::string& GetCopyright() const = 0;
virtual const std::string& GetVendor() const = 0;
virtual IBundleManifest::ActivationPolicy GetActivationPolicy() const = 0;
virtual bool IsSystemBundle() const = 0;
virtual std::istream* GetLocalizedResource(const std::string& name) const = 0;
virtual std::istream* GetResource(const std::string& name) const = 0;
virtual bool IsActive() const = 0;
virtual bool IsResolved() const = 0;
virtual bool IsStarted() const = 0;
virtual const IBundleManifest& GetManifest() const = 0;
virtual const std::string& GetName() const = 0;
virtual const Poco::Path GetPath() const = 0;
virtual IBundleStorage& GetStorage() = 0;
// const Version& GetVersion() const;
virtual const IBundleManifest::Dependencies& GetRequiredBundles() const = 0;
virtual void Resolve() = 0;
virtual void Start() = 0;
virtual void Stop() = 0;
virtual State GetState() const = 0;
virtual std::string GetStateString() const = 0;
virtual BundleEvents& GetEvents() = 0;
virtual const std::string& GetSymbolicName() const = 0;
};
} // namespace berry
#endif /*BERRYIBUNDLE_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berryIBundleActivator.h b/BlueBerry/Bundles/org.blueberry.osgi/src/berryIBundleActivator.h
index 26cfe7b31e..776fe4c184 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/berryIBundleActivator.h
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/berryIBundleActivator.h
@@ -1,38 +1,38 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIBUNDLEACTIVATOR_
#define BERRYIBUNDLEACTIVATOR_
#include <org_blueberry_osgi_Export.h>
#include "berrySmartPointer.h"
namespace berry {
struct IBundleContext;
struct BERRY_OSGI IBundleActivator
{
virtual void Start(SmartPointer<IBundleContext> context) = 0;
virtual void Stop(SmartPointer<IBundleContext> context) = 0;
virtual ~IBundleActivator() {};
};
} // namespace berry
#endif /*BERRYIBUNDLEACTIVATOR_*/
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berryIBundleContext.h b/BlueBerry/Bundles/org.blueberry.osgi/src/berryIBundleContext.h
index 74eca6e00a..dd755cc5f3 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/berryIBundleContext.h
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/berryIBundleContext.h
@@ -1,70 +1,70 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIBUNDLECONTEXT_H_
#define BERRYIBUNDLECONTEXT_H_
#include "berryMacros.h"
#include "Poco/Path.h"
#include "Poco/Logger.h"
#include "service/berryService.h"
namespace berry {
struct BundleEvents;
struct IBundle;
struct BERRY_OSGI IBundleContext : public Object
{
berryInterfaceMacro(IBundleContext, berry);
virtual ~IBundleContext() {};
virtual IBundleContext::Pointer GetContextForBundle(SmartPointer<const IBundle> bundle) const = 0;
virtual BundleEvents& GetEvents() const = 0;
virtual SmartPointer<const IBundle> FindBundle(const std::string& name) const = 0;
virtual void ListBundles(std::vector<SmartPointer<IBundle> >& bundles) const = 0;
virtual Poco::Logger& GetLogger() const = 0;
// Logger& GetLogger() const;
virtual Poco::Path GetPathForLibrary(const std::string& libraryName) const = 0;
virtual Poco::Path GetPersistentDirectory() const = 0;
template<class S>
SmartPointer<S> GetService(const std::string& id) const;
virtual void RegisterService(const std::string& id, Service::Pointer service) const = 0;
virtual SmartPointer<IBundle> GetThisBundle() const = 0;
//static std::string GetLoggerName(const Bundle* bundle);
};
} // namespace berry
#include "berryIBundleContext.txx"
#endif /*BERRYIBUNDLECONTEXT_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berryIBundleContext.txx b/BlueBerry/Bundles/org.blueberry.osgi/src/berryIBundleContext.txx
index a1e7487db2..8e680ef7e8 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/berryIBundleContext.txx
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/berryIBundleContext.txx
@@ -1,34 +1,34 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIBUNDLECONTEXT_TXX_
#define BERRYIBUNDLECONTEXT_TXX_
#include "berryPlatform.h"
#include "service/berryServiceRegistry.h"
namespace berry
{
template<class S>
SmartPointer<S> IBundleContext::GetService(const std::string& id) const
{
return Platform::GetServiceRegistry().GetServiceById<S>(id);
}
}
#endif /*BERRYIBUNDLECONTEXT_TXX_*/
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berryIBundleManifest.cpp b/BlueBerry/Bundles/org.blueberry.osgi/src/berryIBundleManifest.cpp
index 88a9d84470..25bc8a2d2b 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/berryIBundleManifest.cpp
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/berryIBundleManifest.cpp
@@ -1,37 +1,37 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryIBundleManifest.h"
namespace berry {
const std::string IBundleManifest::BUNDLE_ACTIVATOR = "Bundle-Activator";
const std::string IBundleManifest::BUNDLE_COPYRIGHT = "Bundle-Copyright";
const std::string IBundleManifest::BUNDLE_ACTIVATION_POLICY = "Bundle-ActivationPolicy";
const std::string IBundleManifest::BUNDLE_NAME = "Bundle-Name";
const std::string IBundleManifest::BUNDLE_SYMBOLICNAME = "Bundle-SymbolicName";
const std::string IBundleManifest::BUNDLE_VENDOR = "Bundle-Vendor";
const std::string IBundleManifest::BUNDLE_VERSION = "Bundle-Version";
const std::string IBundleManifest::MANIFEST_VERSION = "Manifest-Version";
const std::string IBundleManifest::SYSTEM_BUNDLE = "Berry-SystemBundle";
const std::string IBundleManifest::REQUIRE_BUNDLE = "Require-Bundle";
const std::string IBundleManifest::VERSION = "1.0";
} // namespace berry
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berryIBundleManifest.h b/BlueBerry/Bundles/org.blueberry.osgi/src/berryIBundleManifest.h
index 423a60e32a..e4eb69d087 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/berryIBundleManifest.h
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/berryIBundleManifest.h
@@ -1,72 +1,72 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIBUNDLEMANIFEST_H_
#define BERRYIBUNDLEMANIFEST_H_
#include "berryMacros.h"
#include "berryObject.h"
#include <vector>
namespace berry {
struct BERRY_OSGI IBundleManifest : public Object
{
berryInterfaceMacro(IBundleManifest, berry);
static const std::string BUNDLE_ACTIVATOR;
static const std::string BUNDLE_COPYRIGHT;
static const std::string BUNDLE_ACTIVATION_POLICY;
static const std::string BUNDLE_NAME;
static const std::string BUNDLE_SYMBOLICNAME;
static const std::string BUNDLE_VENDOR;
static const std::string BUNDLE_VERSION;
static const std::string MANIFEST_VERSION;
static const std::string REQUIRE_BUNDLE;
static const std::string SYSTEM_BUNDLE;
static const std::string VERSION;
enum ActivationPolicy { LAZY, EAGER };
struct Dependency {
std::string symbolicName;
// VersionRange versions;
};
typedef std::vector<Dependency> Dependencies;
virtual ~IBundleManifest() {};
virtual const std::string& GetActivatorClass() const = 0;
virtual const std::string& GetActivatorLibrary() const = 0;
virtual const std::string& GetCopyright() const = 0;
virtual ActivationPolicy GetActivationPolicy() const = 0;
virtual bool IsSystemBundle() const = 0;
virtual const std::string& GetName() const = 0;
virtual const Dependencies& GetRequiredBundles() const = 0;
virtual const std::string& GetSymbolicName() const = 0;
virtual const std::string& GetVendor() const = 0;
//const Version& GetVersion() const;
};
} // namespace berry
#endif /*BERRYIBUNDLEMANIFEST_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berryIBundleStorage.h b/BlueBerry/Bundles/org.blueberry.osgi/src/berryIBundleStorage.h
index 7af55342d5..dec1fbb618 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/berryIBundleStorage.h
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/berryIBundleStorage.h
@@ -1,44 +1,44 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIBUNDLESTORAGE_H_
#define BERRYIBUNDLESTORAGE_H_
#include "berryMacros.h"
#include "berryObject.h"
#include "Poco/Path.h"
#include <vector>
namespace berry {
struct BERRY_OSGI IBundleStorage : public Object
{
berryInterfaceMacro(IBundleStorage, berry);
virtual std::istream* GetResource(const std::string& path) const = 0;
virtual void List(const std::string& path, std::vector<std::string>& files, bool quiet=true) const = 0;
virtual bool IsDirectory(const std::string& path) const = 0;
virtual Poco::Path GetPath() const = 0;
virtual ~IBundleStorage() {};
};
} // namespace berry
#endif /*BERRYIBUNDLESTORAGE_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berryIDebugObjectListener.cpp b/BlueBerry/Bundles/org.blueberry.osgi/src/berryIDebugObjectListener.cpp
index 0456f5aeab..d9de522c90 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/berryIDebugObjectListener.cpp
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/berryIDebugObjectListener.cpp
@@ -1,45 +1,45 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryIDebugObjectListener.h"
namespace berry {
void IDebugObjectListener::Events::AddListener(IDebugObjectListener::Pointer l)
{
if (!l) return;
Types t = l->GetEventTypes();
if (t & OBJECT_CREATED) objCreatedEvent += ObjDelegate(l.GetPointer(), &IDebugObjectListener::ObjectCreated);
if (t & OBJECT_DESTROYED) objDestroyedEvent += ObjDelegate(l.GetPointer(), &IDebugObjectListener::ObjectDestroyed);
if (t & OBJECT_TRACING) objTracingEvent += TraceDelegate(l.GetPointer(), &IDebugObjectListener::ObjectTracingChanged);
if (t & SMARTPOINTER_CREATED) spCreatedEvent += SPDelegate(l.GetPointer(), &IDebugObjectListener::SmartPointerCreated);
if (t & SMARTPOINTER_CREATED) spDestroyedEvent += SPDelegate(l.GetPointer(), &IDebugObjectListener::SmartPointerDestroyed);
}
void IDebugObjectListener::Events::RemoveListener(IDebugObjectListener::Pointer l)
{
if (!l) return;
objCreatedEvent -= ObjDelegate(l.GetPointer(), &IDebugObjectListener::ObjectCreated);
objDestroyedEvent -= ObjDelegate(l.GetPointer(), &IDebugObjectListener::ObjectDestroyed);
objTracingEvent -= TraceDelegate(l.GetPointer(), &IDebugObjectListener::ObjectTracingChanged);
spCreatedEvent -= SPDelegate(l.GetPointer(), &IDebugObjectListener::SmartPointerCreated);
spDestroyedEvent -= SPDelegate(l.GetPointer(), &IDebugObjectListener::SmartPointerDestroyed);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berryIDebugObjectListener.h b/BlueBerry/Bundles/org.blueberry.osgi/src/berryIDebugObjectListener.h
index fab1d6af26..88b5174a60 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/berryIDebugObjectListener.h
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/berryIDebugObjectListener.h
@@ -1,99 +1,99 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIDEBUGOBJECTLISTENER_H_
#define BERRYIDEBUGOBJECTLISTENER_H_
#include <berryObject.h>
#include <berryMacros.h>
#include <org_blueberry_osgi_Export.h>
namespace berry
{
struct BERRY_OSGI IDebugObjectListener: public Object
{
berryInterfaceMacro(IDebugObjectListener, berry);
struct BERRY_OSGI Events {
enum Type {
NONE = 0x00000000,
OBJECT_CREATED = 0x00000001,
OBJECT_DESTROYED = 0x00000002,
OBJECT_TRACING = 0x00000004,
SMARTPOINTER_CREATED = 0x00000008,
SMARTPOINTER_DESTROYED = 0x00000010,
ALL = 0xffffffff
};
BERRY_DECLARE_FLAGS(Types, Type)
typedef Message1<const Object*> ObjectEventType;
typedef Message3<unsigned int, bool, const Object*> TracingEventType;
typedef Message2<unsigned int, const Object*> SmartPointerEventType;
ObjectEventType objCreatedEvent;
ObjectEventType objDestroyedEvent;
TracingEventType objTracingEvent;
SmartPointerEventType spCreatedEvent;
SmartPointerEventType spDestroyedEvent;
void AddListener(IDebugObjectListener::Pointer listener);
void RemoveListener(IDebugObjectListener::Pointer listener);
typedef MessageDelegate1<IDebugObjectListener, const Object*> ObjDelegate;
typedef MessageDelegate3<IDebugObjectListener, unsigned int, bool, const Object*> TraceDelegate;
typedef MessageDelegate2<IDebugObjectListener, unsigned int, const Object*> SPDelegate;
};
virtual ~IDebugObjectListener()
{
}
virtual Events::Types GetEventTypes() const = 0;
virtual void ObjectCreated(const Object* /*obj*/)
{
}
virtual void ObjectDestroyed(const Object* /*obj*/)
{
}
virtual void ObjectTracingChanged(unsigned int /*traceId*/, bool /*enabled*/ = true, const Object* /*obj*/ = 0)
{
}
virtual void SmartPointerCreated(unsigned int /*id*/, const Object* /*obj*/)
{
}
virtual void SmartPointerDestroyed(unsigned int /*id*/, const Object* /*obj*/)
{
}
};
}
BERRY_DECLARE_OPERATORS_FOR_FLAGS(berry::IDebugObjectListener::Events::Types)
#endif /* BERRYIDEBUGOBJECTLISTENER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berryLog.h b/BlueBerry/Bundles/org.blueberry.osgi/src/berryLog.h
index d728c04e23..3ec15e656f 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/berryLog.h
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/berryLog.h
@@ -1,29 +1,29 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 __BERRY_LOG_H__
#define __BERRY_LOG_H__
#include <mbilog.h>
#define BERRY_INFO MBI_INFO("BlueBerry")
#define BERRY_WARN MBI_WARN("BlueBerry")
#define BERRY_ERROR MBI_ERROR("BlueBerry")
#define BERRY_FATAL MBI_FATAL("BlueBerry")
#define BERRY_DEBUG MBI_DEBUG("BlueBerry")
#endif /*__BERRY_LOG_H__*/
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berryMacros.h b/BlueBerry/Bundles/org.blueberry.osgi/src/berryMacros.h
index 39d892562e..6ac71edc1c 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/berryMacros.h
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/berryMacros.h
@@ -1,119 +1,119 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 __BERRY_MACROS_H__
#define __BERRY_MACROS_H__
#include "berryWeakPointer.h"
#include "berryExtensionType.h"
#define berryNameMacro(className) \
virtual const char* GetClassName() const \
{ return #className; }\
static const char* GetStaticClassName() \
{ return #className; }\
#define berryManifestMacro(className, namespaze) \
static const char* GetManifestName() \
{ return #namespaze #className; } \
#define berryObjectMacro(className) \
typedef className Self; \
typedef berry::SmartPointer<Self> Pointer; \
typedef berry::SmartPointer<const Self> ConstPointer; \
typedef berry::WeakPointer<Self> WeakPtr; \
typedef berry::WeakPointer<const Self> ConstWeakPtr; \
berryNameMacro(className) \
#define berryInterfaceMacro(className, namespaze) \
public: \
berryObjectMacro(className) \
berryManifestMacro(className, namespaze) \
#define berrySimpleInterfaceMacro(className, namespaze) \
protected: className() {} \
public: \
berryNameMacro(className) \
berryManifestMacro(className, namespaze) \
#define berryNewMacro(x) \
static Pointer New(void) \
{ \
Pointer smartPtr(new x); \
return smartPtr; \
} \
#define berryNewMacro1Param(x, type1) \
static Pointer New(type1 param1) \
{ \
Pointer smartPtr(new x(param1)); \
return smartPtr; \
} \
#define berryNewMacro2Param(x, type1, type2) \
static Pointer New(type1 param1, type2 param2) \
{ \
Pointer smartPtr(new x(param1, param2)); \
return smartPtr; \
} \
#define berryNewMacro3Param(x, type1, type2, type3) \
static Pointer New(type1 param1, type2 param2, type3 param3) \
{ \
Pointer smartPtr (new x(param1, param2, param3)); \
return smartPtr; \
} \
#ifndef BERRY_NO_TYPESAFE_FLAGS
#include "berryFlags.h"
#define BERRY_DECLARE_FLAGS(_Flags, _Enum)\
typedef berry::Flags<_Enum> _Flags;
#if defined _MSC_VER && _MSC_VER < 1300
# define BERRY_DECLARE_INCOMPATIBLE_FLAGS(_Flags)
#else
# define BERRY_DECLARE_INCOMPATIBLE_FLAGS(_Flags) \
inline berry::IncompatibleFlag operator|(_Flags::enum_type f1, int f2) \
{ return berry::IncompatibleFlag(int(f1) | f2); }
#endif
#define BERRY_DECLARE_OPERATORS_FOR_FLAGS(_Flags) \
inline berry::Flags<_Flags::enum_type> operator|(_Flags::enum_type f1, _Flags::enum_type f2) \
{ return berry::Flags<_Flags::enum_type>(f1) | f2; } \
inline berry::Flags<_Flags::enum_type> operator|(_Flags::enum_type f1, berry::Flags<_Flags::enum_type> f2) \
{ return f2 | f1; } BERRY_DECLARE_INCOMPATIBLE_FLAGS(_Flags)
#else /* BERRY_NO_TYPESAFE_FLAGS */
#define BERRY_DECLARE_FLAGS(_Flags, _Enum)\
typedef uint _Flags;
#define BERRY_DECLARE_OPERATORS_FOR_FLAGS(_Flags)
#endif /* BERRY_NO_TYPESAFE_FLAGS */
#define BERRY_REGISTER_EXTENSION_CLASS(_ClassType, _PluginContext)\
{\
QString typeName = _PluginContext->getPlugin()->getSymbolicName();\
typeName = (typeName + "_") + _ClassType::staticMetaObject.className();\
::berry::registerExtensionType<_ClassType>(typeName.toAscii().data());\
}
#endif /*__BERRY_MACROS_H__*/
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berryMessage.h b/BlueBerry/Bundles/org.blueberry.osgi/src/berryMessage.h
index f7f5bfa3ad..810f4208e4 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/berryMessage.h
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/berryMessage.h
@@ -1,1075 +1,1075 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYMESSAGE_H_
#define BERRYMESSAGE_H_
#include <vector>
#include <Poco/Mutex.h>
/**
* Adds a Message<> variable and methods to add/remove message delegates to/from
* this variable.
*/
#define berryNewMessageMacro(msgHandleObject) \
private: Message<> m_ ## msgHandleObject ## Message; \
public: \
inline void Add ## msgHandleObject ## Listener(const MessageAbstractDelegate<>& delegate) \
{ m_ ## msgHandleObject ## Message += delegate; } \
inline void Remove ## msgHandleObject ## Listener(const MessageAbstractDelegate<>& delegate) \
{ m_ ## msgHandleObject ## Message -= delegate; } \
#define berryNewMessageWithReturnMacro(msgHandleObject, returnType) \
private: Message<returnType> m_ ## msgHandleObject ## Message; \
public: \
inline void Add ## msgHandleObject ## Listener(const MessageAbstractDelegate<returnType>& delegate) \
{ m_ ## msgHandleObject ## Message += delegate; } \
inline void Remove ## msgHandleObject ## Listener(const MessageAbstractDelegate<returnType>& delegate) \
{ m_ ## msgHandleObject ## Message -= delegate; } \
#define berryNewMessage1Macro(msgHandleObject, type1) \
private: Message1< type1 > m_msgHandleObject ## Message; \
public: \
void Add ## msgHandleObject ## Listener(const MessageAbstractDelegate1< type1 >& delegate) \
{ m_ ## msgHandleObject ## Message += delegate; } \
void Remove ## msgHandleObject ## Listener(const MessageAbstractDelegate1< type1 >& delegate) \
{ m_ ## msgHandleObject ## Message -= delegate; } \
namespace berry
{
template<typename A = void>
class MessageAbstractDelegate
{
public:
virtual ~MessageAbstractDelegate()
{
}
virtual A Execute() = 0;
virtual bool operator==(const MessageAbstractDelegate* cmd) = 0;
virtual MessageAbstractDelegate* Clone() const = 0;
};
template<typename T, typename A = void>
class MessageAbstractDelegate1
{
public:
virtual ~MessageAbstractDelegate1()
{
}
virtual A Execute(T t) = 0;
virtual bool operator==(const MessageAbstractDelegate1* cmd) = 0;
virtual MessageAbstractDelegate1* Clone() const = 0;
};
template<typename T, typename U, typename A = void>
class MessageAbstractDelegate2
{
public:
virtual ~MessageAbstractDelegate2()
{
}
virtual A Execute(T t, U u) const = 0;
virtual bool operator==(const MessageAbstractDelegate2* cmd) = 0;
virtual MessageAbstractDelegate2* Clone() const = 0;
};
template<typename T, typename U, typename V, typename A = void>
class MessageAbstractDelegate3
{
public:
virtual ~MessageAbstractDelegate3()
{
}
virtual A Execute(T t, U u, V v) const = 0;
virtual bool operator==(const MessageAbstractDelegate3* cmd) = 0;
virtual MessageAbstractDelegate3* Clone() const = 0;
};
template<typename T, typename U, typename V, typename W, typename A = void>
class MessageAbstractDelegate4
{
public:
virtual ~MessageAbstractDelegate4()
{
}
virtual A Execute(T t, U u, V v, W w) const = 0;
virtual bool operator==(const MessageAbstractDelegate4* cmd) = 0;
virtual MessageAbstractDelegate4* Clone() const = 0;
};
template<class R, typename A = void>
class MessageDelegate: public MessageAbstractDelegate<A>
{
public:
// constructor - takes pointer to an object and pointer to a member and stores
// them in two private variables
MessageDelegate(R* object, A(R::*memberFunctionPointer)()) :
m_Object(object), m_MemberFunctionPointer(memberFunctionPointer)
{
}
virtual ~MessageDelegate()
{
}
// override function "Call"
virtual A Execute()
{
return (m_Object->*m_MemberFunctionPointer)(); // execute member function
}
bool operator==(const MessageAbstractDelegate<A>* c)
{
const MessageDelegate<R, A>* cmd =
dynamic_cast<const MessageDelegate<R, A>*> (c);
if (!cmd)
return false;
if ((void*) this->m_Object != (void*) cmd->m_Object)
return false;
if (this->m_MemberFunctionPointer != cmd->m_MemberFunctionPointer)
return false;
return true;
}
MessageAbstractDelegate<A>* Clone() const
{
return new MessageDelegate(m_Object, m_MemberFunctionPointer);
}
private:
R* m_Object; // pointer to object
A (R::*m_MemberFunctionPointer)(); // pointer to member function
};
template<class R, typename T, typename A = void>
class MessageDelegate1: public MessageAbstractDelegate1<T, A>
{
public:
// constructor - takes pointer to an object and pointer to a member and stores
// them in two private variables
MessageDelegate1(R* object, A(R::*memberFunctionPointer)(T)) :
m_Object(object), m_MemberFunctionPointer(memberFunctionPointer)
{
}
virtual ~MessageDelegate1()
{
}
// override function "Call"
virtual A Execute(T t)
{
return (m_Object->*m_MemberFunctionPointer)(t); // execute member function
}
bool operator==(const MessageAbstractDelegate1<T, A>* c)
{
const MessageDelegate1<R, T, A>* cmd = dynamic_cast<const MessageDelegate1<
R, T, A>*> (c);
if (!cmd)
return false;
if ((void*) this->m_Object != (void*) cmd->m_Object)
return false;
if (this->m_MemberFunctionPointer != cmd->m_MemberFunctionPointer)
return false;
return true;
}
MessageAbstractDelegate1<T, A>* Clone() const
{
return new MessageDelegate1(m_Object, m_MemberFunctionPointer);
}
private:
R* m_Object; // pointer to object
A (R::*m_MemberFunctionPointer)(T); // pointer to member function
};
template<class R, typename T, typename U, typename A = void>
class MessageDelegate2: public MessageAbstractDelegate2<T, U, A>
{
public:
// constructor - takes pointer to an object and pointer to a member and stores
// them in two private variables
MessageDelegate2(R* object, A(R::*memberFunctionPointer)(T, U)) :
m_Object(object), m_MemberFunctionPointer(memberFunctionPointer)
{
}
virtual ~MessageDelegate2()
{
}
// override function "Call"
virtual A Execute(T t, U u) const
{
return (m_Object->*m_MemberFunctionPointer)(t, u); // execute member function
}
bool operator==(const MessageAbstractDelegate2<T, U, A>* c)
{
const MessageDelegate2<R, T, U, A>* cmd =
dynamic_cast<const MessageDelegate2<R, T, U, A>*> (c);
if (!cmd)
return false;
if ((void*) this->m_Object != (void*) cmd->m_Object)
return false;
if (this->m_MemberFunctionPointer != cmd->m_MemberFunctionPointer)
return false;
return true;
}
MessageAbstractDelegate2<T, U, A>* Clone() const
{
return new MessageDelegate2(m_Object, m_MemberFunctionPointer);
}
private:
R* m_Object; // pointer to object
A (R::*m_MemberFunctionPointer)(T, U); // pointer to member function
};
template<class R, typename T, typename U, typename V, typename A = void>
class MessageDelegate3: public MessageAbstractDelegate3<T, U, V, A>
{
public:
// constructor - takes pointer to an object and pointer to a member and stores
// them in two private variables
MessageDelegate3(R* object, A(R::*memberFunctionPointer)(T, U, V)) :
m_Object(object), m_MemberFunctionPointer(memberFunctionPointer)
{
}
virtual ~MessageDelegate3()
{
}
// override function "Call"
virtual A Execute(T t, U u, V v) const
{
return (m_Object->*m_MemberFunctionPointer)(t, u, v); // execute member function
}
bool operator==(const MessageAbstractDelegate3<T, U, V, A>* c)
{
const MessageDelegate3<R, T, U, V, A>* cmd =
dynamic_cast<const MessageDelegate3<R, T, U, V, A>*> (c);
if (!cmd)
return false;
if ((void*) this->m_Object != (void*) cmd->m_Object)
return false;
if (this->m_MemberFunctionPointer != cmd->m_MemberFunctionPointer)
return false;
return true;
}
MessageAbstractDelegate3<T, U, V, A>* Clone() const
{
return new MessageDelegate3(m_Object, m_MemberFunctionPointer);
}
private:
R* m_Object; // pointer to object
A (R::*m_MemberFunctionPointer)(T, U, V); // pointer to member function
};
template<class R, typename T, typename U, typename V, typename W,
typename A = void>
class MessageDelegate4: public MessageAbstractDelegate4<T, U, V, W, A>
{
public:
// constructor - takes pointer to an object and pointer to a member and stores
// them in two private variables
MessageDelegate4(R* object, A(R::*memberFunctionPointer)(T, U, V, W)) :
m_Object(object), m_MemberFunctionPointer(memberFunctionPointer)
{
}
virtual ~MessageDelegate4()
{
}
// override function "Call"
virtual A Execute(T t, U u, V v, W w) const
{
return (m_Object->*m_MemberFunctionPointer)(t, u, v, w); // execute member function
}
bool operator==(const MessageAbstractDelegate4<T, U, V, W, A>* c)
{
const MessageDelegate4<R, T, U, V, W, A>* cmd =
dynamic_cast<const MessageDelegate4<R, T, U, V, W, A>*> (c);
if (!cmd)
return false;
if ((void*) this->m_Object != (void*) cmd->m_Object)
return false;
if (this->m_MemberFunctionPointer != cmd->m_MemberFunctionPointer)
return false;
return true;
}
MessageAbstractDelegate4<T, U, V, W, A>* Clone() const
{
return new MessageDelegate4(m_Object, m_MemberFunctionPointer);
}
private:
R* m_Object; // pointer to object
A (R::*m_MemberFunctionPointer)(T, U, V, W); // pointer to member function
};
struct AbstractExceptionHandler
{
virtual void HandleException(const std::exception& exc) = 0;
virtual AbstractExceptionHandler* Clone() const = 0;
virtual ~AbstractExceptionHandler()
{
}
};
template<typename R>
struct MessageExceptionHandler: public AbstractExceptionHandler
{
typedef void (R::*HandleExceptionCallback)(const std::exception&);
MessageExceptionHandler(R* r, HandleExceptionCallback c) :
m_Object(r), m_ExceptionCallback(c)
{
}
void HandleException(const std::exception& exc)
{
(m_Object->*m_ExceptionCallback)(exc);
}
AbstractExceptionHandler* Clone() const
{
if (!m_Object) return 0;
return new MessageExceptionHandler(m_Object, m_ExceptionCallback);
}
private:
R* m_Object;
HandleExceptionCallback m_ExceptionCallback;
};
template<typename D>
class DelegateList
{
public:
typedef D Delegate;
typedef std::vector<Delegate*> ListType;
DelegateList() :
m_ExcHandler(0)
{
}
~DelegateList()
{
for (typename ListType::iterator iter = m_Delegates.begin(); iter
!= m_Delegates.end(); ++iter)
{
delete *iter;
}
delete m_ExcHandler;
}
void Add(const Delegate& d) const
{
Delegate* copy = d.Clone();
Poco::FastMutex::ScopedLock lock(m_Mutex);
for (typename ListType::iterator iter = m_Delegates.begin(); iter
!= m_Delegates.end(); ++iter)
{
if ((*iter)->operator==(copy))
{
delete copy;
return;
}
}
m_Delegates.push_back(copy);
}
void Remove(const Delegate& d) const
{
Poco::FastMutex::ScopedLock lock(m_Mutex);
for (typename ListType::iterator iter = m_Delegates.begin(); iter
!= m_Delegates.end(); ++iter)
{
if ((*iter)->operator==(&d))
{
delete *iter;
m_Delegates.erase(iter);
return;
}
}
}
bool IsEmpty() const
{
return m_Delegates.empty();
}
template<typename Dummy>
void Send0(Dummy) const
{
ListType delegates;
{
Poco::FastMutex::ScopedLock lock(m_Mutex);
delegates.assign(m_Delegates.begin(), m_Delegates.end());
}
for (typename ListType::iterator iter = delegates.begin(); iter
!= delegates.end(); ++iter)
{
try
{
// notify each listener
(*iter)->Execute();
}
catch (const std::exception& e)
{
if (m_ExcHandler)
{
m_ExcHandler->HandleException(e);
}
else
{
throw e;
}
}
catch (...)
{
if (m_ExcHandler)
{
m_ExcHandler->HandleException(std::exception());
}
else
throw ;
}
}
}
template<typename T>
void Send1(T t) const
{
ListType delegates;
{
Poco::FastMutex::ScopedLock lock(m_Mutex);
delegates.assign(m_Delegates.begin(), m_Delegates.end());
}
for (typename ListType::iterator iter = delegates.begin(); iter
!= delegates.end(); ++iter)
{
try
{
// notify each listener
(*iter)->Execute(t);
}
catch (const std::exception& e)
{
if (m_ExcHandler)
{
m_ExcHandler->HandleException(e);
}
else
{
throw e;
}
}
catch (...)
{
if (m_ExcHandler)
{
m_ExcHandler->HandleException(std::exception());
}
else throw;
}
}
}
template<typename T, typename U>
void Send2(T t, U u) const
{
ListType delegates;
{
Poco::FastMutex::ScopedLock lock(m_Mutex);
delegates.assign(m_Delegates.begin(), m_Delegates.end());
}
for (typename ListType::iterator iter = delegates.begin(); iter
!= delegates.end(); ++iter)
{
try
{
// notify each listener
(*iter)->Execute(t, u);
}
catch (const std::exception& e)
{
if (m_ExcHandler)
{
m_ExcHandler->HandleException(e);
}
else
{
throw e;
}
}
catch (...)
{
if (m_ExcHandler)
{
m_ExcHandler->HandleException(std::exception());
}
else throw;
}
}
}
template<typename T, typename U, typename V>
void Send3(T t, U u, V v) const
{
ListType delegates;
{
Poco::FastMutex::ScopedLock lock(m_Mutex);
delegates.assign(m_Delegates.begin(), m_Delegates.end());
}
for (typename ListType::iterator iter = delegates.begin(); iter
!= delegates.end(); ++iter)
{
try
{
// notify each listener
(*iter)->Execute(t, u, v);
}
catch (const std::exception& e)
{
if (m_ExcHandler)
{
m_ExcHandler->HandleException(e);
}
else
{
throw e;
}
}
catch (...)
{
if (m_ExcHandler)
{
m_ExcHandler->HandleException(std::exception());
}
else throw;
}
}
}
template<typename T, typename U, typename V, typename W>
void Send4(T t, U u, V v, W w) const
{
ListType delegates;
{
Poco::FastMutex::ScopedLock lock(m_Mutex);
delegates.assign(m_Delegates.begin(), m_Delegates.end());
}
for (typename ListType::iterator iter = delegates.begin(); iter
!= delegates.end(); ++iter)
{
try
{
// notify each listener
(*iter)->Execute(t, u, v, w);
}
catch (const std::exception& e)
{
if (m_ExcHandler)
{
m_ExcHandler->HandleException(e);
}
else
{
throw e;
}
}
catch (...)
{
if (m_ExcHandler)
{
m_ExcHandler->HandleException(std::exception());
}
else throw;
}
}
}
void SetExceptionHandler(const AbstractExceptionHandler& handler)
{
Poco::FastMutex::ScopedLock lock(m_Mutex);
delete m_ExcHandler;
m_ExcHandler = handler.Clone();
}
AbstractExceptionHandler* GetExceptionHandler() const
{
Poco::FastMutex::ScopedLock lock(m_Mutex);
if (m_ExcHandler) return m_ExcHandler->Clone();
return 0;
}
ListType GetDelegates() const
{
Poco::FastMutex::ScopedLock lock(m_Mutex);
return m_Delegates;
}
private:
/**
* \brief List of listeners.
*
* This is declared mutable for a reason: Imagine an object that sends out notifications, e.g.
*
* \code
class Database {
public:
Message Modified;
};
* \endcode
*
* Now imaginge someone gets a <tt>const Database</tt> object, because he/she should not write to the
* database. He/she should anyway be able to register for notifications about changes in the database
* -- this is why AddListener and RemoveListener are declared <tt>const</tt>. m_Listeners must be
* mutable so that AddListener and RemoveListener can modify it regardless of the object's constness.
*/
mutable std::vector<Delegate*> m_Delegates;
mutable AbstractExceptionHandler* m_ExcHandler;
mutable Poco::FastMutex m_Mutex;
};
/**
* \brief Event/message/notification class.
*
* This class
* allows one class to send out messages and another class to
* receive these message. There are subclasses for sending
* parameters along with the messages.
*
* This is an implementation of the Observer pattern.
*
* \li There is no guarantee about the order of which observer is notified first. At the moment the observers which register first will be notified first.
* \li Notifications are <b>synchronous</b>, by direct method calls. There is no support for asynchronous messages.
*
*/
// message without parameters (pure signals)
template<typename A = void>
class Message
{
public:
typedef Message Self;
typedef MessageAbstractDelegate<A> AbstractDelegate;
typedef typename DelegateList<AbstractDelegate>::ListType ListenerList;
void AddListener(const AbstractDelegate& delegate) const
{
delegates.Add(delegate);
}
void operator +=(const AbstractDelegate& delegate) const
{
this->AddListener(delegate);
}
void RemoveListener(const AbstractDelegate& delegate) const
{
delegates.Remove(delegate);
}
void operator -=(const AbstractDelegate& delegate) const
{
this->RemoveListener(delegate);
}
void Send() const
{
delegates.Send0(0);
}
void operator()() const
{
this->Send();
}
void SetExceptionHandler(const AbstractExceptionHandler& handler)
{
delegates.SetExceptionHandler(handler);
}
AbstractExceptionHandler* GetExceptionHandler() const
{
return delegates.GetExceptionHandler();
}
ListenerList GetListeners() const
{
return delegates.GetDelegates();
}
bool HasListeners() const
{
return !delegates.IsEmpty();
}
bool IsEmpty() const
{
return delegates.IsEmpty();
}
protected:
DelegateList<AbstractDelegate> delegates;
};
// message with 1 parameter and return type
template<typename T, typename A = void>
class Message1
{
public:
typedef Message1 Self;
typedef MessageAbstractDelegate1<T, A> AbstractDelegate;
typedef typename DelegateList<AbstractDelegate>::ListType ListenerList;
void AddListener(const AbstractDelegate& delegate) const
{
delegates.Add(delegate);
}
void operator +=(const AbstractDelegate& delegate) const
{
this->AddListener(delegate);
}
void RemoveListener(const AbstractDelegate& delegate) const
{
delegates.Remove(delegate);
}
void operator -=(const AbstractDelegate& delegate) const
{
this->RemoveListener(delegate);
}
void Send(T t) const
{
delegates.Send1(t);
}
void operator()(T t) const
{
this->Send(t);
}
void SetExceptionHandler(const AbstractExceptionHandler& handler)
{
delegates.SetExceptionHandler(handler);
}
AbstractExceptionHandler* GetExceptionHandler() const
{
return delegates.GetExceptionHandler();
}
ListenerList GetListeners() const
{
return delegates.GetDelegates();
}
bool HasListeners() const
{
return !delegates.IsEmpty();
}
bool IsEmpty() const
{
return delegates.IsEmpty();
}
protected:
DelegateList<AbstractDelegate> delegates;
};
// message with 2 parameters and return type
template<typename T, typename U, typename A = void>
class Message2
{
public:
typedef Message2 Self;
typedef MessageAbstractDelegate2<T, U, A> AbstractDelegate;
typedef typename DelegateList<AbstractDelegate>::ListType ListenerList;
void AddListener(const AbstractDelegate& delegate) const
{
delegates.Add(delegate);
}
void operator +=(const AbstractDelegate& delegate) const
{
this->AddListener(delegate);
}
void RemoveListener(const AbstractDelegate& delegate) const
{
delegates.Remove(delegate);
}
void operator -=(const AbstractDelegate& delegate) const
{
this->RemoveListener(delegate);
}
void Send(T t, U u) const
{
delegates.Send2(t, u);
}
void operator()(T t, U u) const
{
this->Send(t, u);
}
void SetExceptionHandler(const AbstractExceptionHandler& handler)
{
delegates.SetExceptionHandler(handler);
}
AbstractExceptionHandler* GetExceptionHandler() const
{
return delegates.GetExceptionHandler();
}
ListenerList GetListeners() const
{
return delegates.GetDelegates();
}
bool HasListeners() const
{
return !delegates.IsEmpty();
}
bool IsEmpty() const
{
return delegates.IsEmpty();
}
protected:
DelegateList<AbstractDelegate> delegates;
};
// message with 3 parameters and return type
template<typename T, typename U, typename V, typename A = void>
class Message3
{
public:
typedef Message3 Self;
typedef MessageAbstractDelegate3<T, U, V, A> AbstractDelegate;
typedef typename DelegateList<AbstractDelegate>::ListType ListenerList;
void AddListener(const AbstractDelegate& delegate) const
{
delegates.Add(delegate);
}
void operator +=(const AbstractDelegate& delegate) const
{
this->AddListener(delegate);
}
void RemoveListener(const AbstractDelegate& delegate) const
{
delegates.Remove(delegate);
}
void operator -=(const AbstractDelegate& delegate) const
{
this->RemoveListener(delegate);
}
void Send(T t, U u, V v) const
{
delegates.Send3(t, u, v);
}
void operator()(T t, U u, V v) const
{
this->Send(t, u, v);
}
void SetExceptionHandler(const AbstractExceptionHandler& handler)
{
delegates.SetExceptionHandler(handler);
}
AbstractExceptionHandler* GetExceptionHandler() const
{
return delegates.GetExceptionHandler();
}
ListenerList GetListeners() const
{
return delegates.GetDelegates();
}
bool HasListeners() const
{
return !delegates.IsEmpty();
}
bool IsEmpty() const
{
return delegates.IsEmpty();
}
protected:
DelegateList<AbstractDelegate> delegates;
};
// message with 4 parameters and return type
template<typename T, typename U, typename V, typename W, typename A = void>
class Message4
{
public:
typedef Message4 Self;
typedef MessageAbstractDelegate4<T, U, V, W, A> AbstractDelegate;
typedef typename DelegateList<AbstractDelegate>::ListType ListenerList;
void AddListener(const AbstractDelegate& delegate) const
{
delegates.Add(delegate);
}
void operator +=(const AbstractDelegate& delegate) const
{
this->AddListener(delegate);
}
void RemoveListener(const AbstractDelegate& delegate) const
{
delegates.Remove(delegate);
}
void operator -=(const AbstractDelegate& delegate) const
{
this->RemoveListener(delegate);
}
void Send(T t, U u, V v, W w) const
{
delegates.Send4(t, u, v, w);
}
void operator()(T t, U u, V v, W w) const
{
this->Send(t, u , v, w);
}
void SetExceptionHandler(const AbstractExceptionHandler& handler)
{
delegates.SetExceptionHandler(handler);
}
AbstractExceptionHandler* GetExceptionHandler() const
{
return delegates.GetExceptionHandler();
}
ListenerList GetListeners() const
{
return delegates.GetDelegates();
}
bool HasListeners() const
{
return !delegates.IsEmpty();
}
bool IsEmpty() const
{
return delegates.IsEmpty();
}
protected:
DelegateList<AbstractDelegate> delegates;
};
} // namespace berry
#endif /*BERRYMESSAGE_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berryObject.cpp b/BlueBerry/Bundles/org.blueberry.osgi/src/berryObject.cpp
index 57285a6dc5..6d98213c6f 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/berryObject.cpp
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/berryObject.cpp
@@ -1,262 +1,262 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryLog.h"
#include "berryObject.h"
#ifdef BLUEBERRY_DEBUG_SMARTPOINTER
#include "berryDebugUtil.h"
#endif
#include <list>
#include <memory>
#include <exception>
// Better name demangling for gcc
#if __GNUC__ > 3 || ( __GNUC__ == 3 && __GNUC_MINOR__ > 0 )
#define GCC_USEDEMANGLE
#endif
#ifdef GCC_USEDEMANGLE
#include <cstdlib>
#include <cxxabi.h>
#endif
namespace berry
{
void Object::Delete()
{
this->UnRegister();
}
#ifdef _WIN32
void*
Object
::operator new(size_t n)
{
return new char[n];
}
void*
Object
::operator new[](size_t n)
{
return new char[n];
}
void
Object
::operator delete(void* m)
{
delete [] (char*)m;
}
void
Object
::operator delete[](void* m, size_t)
{
delete [] (char*)m;
}
#endif
void Object::Print(std::ostream& os, Indent indent) const
{
this->PrintHeader(os, indent);
this->PrintSelf(os, indent.GetNextIndent());
this->PrintTrailer(os, indent);
}
std::string Object::ToString() const
{
return "";
}
std::size_t Object::HashCode() const
{
return reinterpret_cast<std::size_t> (this);
}
bool Object::operator<(const Object* o) const
{
return this < o;
}
void Object::Register() const
{
Poco::Mutex::ScopedLock lock(m_ReferenceCountLock);
m_ReferenceCount++;
}
void Object::UnRegister(bool del) const
{
m_ReferenceCountLock.lock();
int tmpReferenceCount = --m_ReferenceCount;
m_ReferenceCountLock.unlock();
// ReferenceCount in now unlocked. We may have a race condition
// to delete the object.
if (tmpReferenceCount <= 0 && del)
{
delete this;
}
}
void Object::SetReferenceCount(int ref)
{
m_ReferenceCountLock.lock();
m_ReferenceCount = ref;
m_ReferenceCountLock.unlock();
if (m_ReferenceCount <= 0)
{
delete this;
}
}
bool Object::operator==(const Object* o) const
{
return this == o;
}
#ifdef BLUEBERRY_DEBUG_SMARTPOINTER
unsigned int Object::GetTraceId() const
{
return m_TraceId;
}
unsigned int& Object::GetTraceIdCounter() const
{
static unsigned int traceId = 0;
return traceId;
}
#endif
Object::Object() :
m_ReferenceCount(0)
{
#ifdef BLUEBERRY_DEBUG_SMARTPOINTER
unsigned int& id = GetTraceIdCounter();
m_TraceId = ++id;
DebugUtil::RegisterObject(this);
#endif
}
Object::~Object()
{
/**
* warn user if reference counting is on and the object is being referenced
* by another object.
*/
if (m_ReferenceCount > 0)
{
// A general exception safety rule is that destructors should
// never throw. Something is wrong with a program that reaches
// this point anyway. Also this is the least-derived class so the
// whole object has been destroyed by this point anyway. Just
// issue a warning.
BERRY_WARN << "WARNING: In " __FILE__ ", line " << __LINE__ << "\n"
<< this->GetClassName() << " (" << this
<< "): Trying to delete object with non-zero reference count.";
}
/**
* notifies the registered functions that the object is being destroyed
*/
m_DestroyMessage.Send();
#ifdef BLUEBERRY_DEBUG_SMARTPOINTER
DebugUtil::UnregisterObject(this);
#endif
}
void Object::PrintSelf(std::ostream& os, Indent Indent) const
{
#ifdef GCC_USEDEMANGLE
char const * mangledName = typeid(*this).name();
int status;
char* unmangled = abi::__cxa_demangle(mangledName, 0, 0, &status);
os << Indent << "RTTI typeinfo: ";
if(status == 0)
{
os << unmangled;
free(unmangled);
}
else
{
os << mangledName;
}
os << std::endl;
#else
os << Indent << "RTTI typeinfo: " << typeid( *this ).name() << std::endl;
#endif
os << Indent << "Reference Count: " << m_ReferenceCount << std::endl;
}
/**
* Define a default print header for all objects.
*/
void Object::PrintHeader(std::ostream& os, Indent Indent) const
{
os << Indent << this->GetClassName() << " (" << this << ")\n";
}
/**
* Define a default print trailer for all objects.
*/
void Object::PrintTrailer(std::ostream& /*os*/, Indent /*Indent*/) const
{
}
std::ostream&
operator<<(std::ostream& os, const Object& o)
{
o.Print(os);
return os;
}
// ============== Indent related implementations ==============
static const char blanks[41] = " ";
Indent*
Indent::New()
{
return new Self;
}
Indent Indent::GetNextIndent()
{
int Indent = m_Indent + 2;
if (Indent > 40)
{
Indent = 40;
}
return Indent;
}
std::ostream&
operator<<(std::ostream& os, const Indent& ind)
{
os << blanks + (40 - ind.m_Indent);
return os;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berryObject.h b/BlueBerry/Bundles/org.blueberry.osgi/src/berryObject.h
index 52132eedb3..61ef2558a3 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/berryObject.h
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/berryObject.h
@@ -1,218 +1,218 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYOSGILIGHTOBJECT_H_
#define BERRYOSGILIGHTOBJECT_H_
#include <Poco/Mutex.h>
#include <string>
#include <org_blueberry_osgi_Export.h>
#include "berryMacros.h"
#include "berryMessage.h"
#include <berryConfig.h>
#ifdef _MSC_VER
// disable inheritance by dominance warnings
#pragma warning( disable : 4250 4275 4251 )
// disable warning: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
#pragma warning( disable : 4290 )
#endif
namespace berry {
class BERRY_OSGI Indent
{
public:
/** Standard class typedefs. */
typedef Indent Self;
/** Method for creation through the object factory. */
static Self* New();
/** Destroy this instance. */
void Delete() {delete this;}
/** Construct the object with an initial Indentation level. */
Indent(int ind=0) {m_Indent=ind;}
/** Return the name of the class. */
static const char *GetClassName() {return "Indent";}
/** Determine the next Indentation level. Keep Indenting by two until the
* a maximum of forty spaces is reached. */
Indent GetNextIndent();
/** Print out the Indentation. Basically output a bunch of spaces. */
friend BERRY_OSGI std::ostream& operator<<(std::ostream& os, const Indent& o);
private:
int m_Indent;
};
BERRY_OSGI std::ostream& operator<<(std::ostream& os, const Indent& o);
/** \class Object
* \brief Light weight base class for most BlueBerry classes.
*
* Object is copied from itk::LightObject and is the highest
* level base class for most BlueBerry objects. It
* implements reference counting and the API for object printing.
*
*/
class BERRY_OSGI Object
{
/**
* The message macro is used to create a message object as well as add / remove functions
* (AddDestroyListener, RemoveDestroyListener)
* in order to register functions which will be called when the object is destroyed.
* More information about the NewMessageMacro can be found in @see berryMessage.h
*
*/
berryNewMessageMacro(Destroy)
public:
berryObjectMacro(Object)
struct Hash {
inline std::size_t operator()(const Self* value) const
{
return value->HashCode();
}
inline std::size_t operator()(Self::ConstPointer value) const
{
return value->HashCode();
}
inline std::size_t operator()(Self::WeakPtr value) const
{
try {
const Self::ConstPointer sv(value.Lock());
return sv->HashCode();
}
catch (BadWeakPointerException& /*e*/)
{
return 0;
}
}
};
/** Delete an BlueBerry object. This method should always be used to delete an
* object when the new operator was used to create it. Using the C
* delete method will not work with reference counting. */
virtual void Delete();
#ifdef _WIN32
/** Used to avoid dll boundary problems. */
void* operator new(size_t);
void* operator new[](size_t);
void operator delete(void*);
void operator delete[](void*, size_t);
#endif
/** Cause the object to print itself out. This is usually used to provide
* detailed information about the object's state. It just calls the
* header/self/trailer virtual print methods, which can be overriden by
* subclasses. */
void Print(std::ostream& os, Indent Indent=0) const;
/** Returns a string representation of this object. */
virtual std::string ToString() const;
/** Returns a hash code value for the object. Use the Object::Hash functor
* together with hashtable implementations.
*/
virtual std::size_t HashCode() const;
/**
* Override this method to implement a specific "less than" operator
* for associative STL containers.
*/
virtual bool operator<(const Object*) const;
/** Increase the reference count (mark as used by another object). */
void Register() const;
/** Decrease the reference count (release by another object).
* Set del to false if you do not want the object to be deleted if
* the reference count is zero (use with care!) */
void UnRegister(bool del = true) const;
/** Gets the reference count on this object. */
int GetReferenceCount() const
{return m_ReferenceCount;}
/** Sets the reference count on this object. This is a dangerous
* method, use it with care. */
void SetReferenceCount(int);
/** A generic comparison method. Override this method in subclasses and
* cast to your derived class to provide a more detailed comparison.
*/
virtual bool operator==(const Object*) const;
#ifdef BLUEBERRY_DEBUG_SMARTPOINTER
unsigned int GetTraceId() const;
private:
unsigned int m_TraceId;
unsigned int& GetTraceIdCounter() const;
public:
#endif
protected:
Object();
virtual ~Object();
/** Methods invoked by Print() to print information about the object
* including superclasses. Typically not called by the user (use Print()
* instead) but used in the hierarchical print process to combine the
* output of several classes. */
virtual void PrintSelf(std::ostream& os, Indent indent) const;
virtual void PrintHeader(std::ostream& os, Indent indent) const;
virtual void PrintTrailer(std::ostream& os, Indent indent) const;
/** Number of uses of this object by other objects. */
mutable volatile int m_ReferenceCount;
/** Mutex lock to protect modification to the reference count */
mutable Poco::Mutex m_ReferenceCountLock;
private:
Object(const Self&); //purposely not implemented
void operator=(const Self&); //purposely not implemented
};
/**
* This operator allows all subclasses of Object to be printed via <<.
* It in turn invokes the Print method, which in turn will invoke the
* PrintSelf method that all objects should define, if they have anything
* interesting to print out.
*/
BERRY_OSGI std::ostream& operator<<(std::ostream& os, const Object& o);
}
#endif /*BERRYOSGILIGHTOBJECT_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berryObjectGeneric.h b/BlueBerry/Bundles/org.blueberry.osgi/src/berryObjectGeneric.h
index 7bdb05d27b..2c12dbbb80 100755
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/berryObjectGeneric.h
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/berryObjectGeneric.h
@@ -1,113 +1,113 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYOBJECTGENERIC_H_
#define BERRYOBJECTGENERIC_H_
#include <sstream>
#include <org_blueberry_osgi_Export.h>
#include "berryMacros.h"
#include "berryObject.h"
namespace berry {
template <typename T>
class BERRY_OSGI ObjectGeneric : public Object
{
public:
berryObjectMacro(ObjectGeneric);
typedef T ValueType;
ObjectGeneric() : m_Value(0) {}
ObjectGeneric(T x) : m_Value(x) {}
//ObjectGeneric(const Self& o) { m_Value = o.m_Value; }
virtual ~ObjectGeneric()
{
}
void SetValue(T val) {
m_Value = val;
}
T GetValue() const {
return m_Value;
}
bool operator==(const Object* o) const
{
if(const Self* other = dynamic_cast<const Self*>(o))
return (this->m_Value == other->m_Value);
return false;
}
virtual std::string GetValueAsString() const
{
std::stringstream myStr;
std::locale originalLocale = myStr.getloc();
std::locale C("C");
myStr.imbue(C);
myStr << GetValue() ;
myStr.imbue(originalLocale);
return myStr.str();
}
virtual bool Assignable(Object::ConstPointer other) const
{
return other.Cast<const Self>() != 0;
}
virtual void Assign(Object::ConstPointer other)
{
ConstPointer specOther = other.Cast<const Self>();
if (specOther && this->m_Value != specOther->m_Value)
{
this->m_Value = specOther->m_Value;
}
}
protected:
T m_Value;
};
} // namespace berry
/**
* Generates a specialized subclass of berry::ObjectGeneric.
* This way, GetClassName() returns the value provided by ObjectName.
* Please see berryObjects.h for examples
* @param ObjectName the name of the instantiation of ObjectGeneric
* @param Type the value type
*/
#define berrySpecializeGenericObject(ObjectName,Type,DefaultValue) \
class BERRY_OSGI ObjectName: public ::berry::ObjectGeneric< Type > \
{ \
public: \
berryObjectMacro(ObjectName); \
ObjectName() : ::berry::ObjectGeneric< Type >(DefaultValue) { } \
ObjectName(Type x) : ::berry::ObjectGeneric<Type>(x) {} \
/*ObjectName(const ObjectName& o) : ObjectGeneric< Type >(o) {} */ \
};
#endif /* BERRYOBJECTGENERIC_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berryObjectList.h b/BlueBerry/Bundles/org.blueberry.osgi/src/berryObjectList.h
index 5d4ef28c65..08d06db66c 100755
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/berryObjectList.h
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/berryObjectList.h
@@ -1,35 +1,35 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYOSGIOBJECTLIST_H_
#define BERRYOSGIOBJECTLIST_H_
#include "berryMacros.h"
#include <list>
namespace berry {
template<typename T>
class ObjectList : public Object, public std::list<T>
{
public:
berryObjectMacro(ObjectList<T>);
};
}
#endif /*BERRYOSGIOBJECTLIST_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berryObjectString.h b/BlueBerry/Bundles/org.blueberry.osgi/src/berryObjectString.h
index 32c582c606..d93dc532ca 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/berryObjectString.h
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/berryObjectString.h
@@ -1,47 +1,47 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYOSGISTRING_H_
#define BERRYOSGISTRING_H_
#include "berryMacros.h"
#include <string>
#ifdef org_blueberry_osgi_EXPORTS
#define EXPORT_TEMPLATE
#else
#define EXPORT_TEMPLATE extern
#endif
namespace berry {
//EXPORT_TEMPLATE template class BERRY_OSGI std::basic_string<char, std::char_traits<char>, std::allocator<char> >;
class ObjectString : public std::string, public Object
{
public:
berryObjectMacro(ObjectString);
ObjectString() {}
ObjectString(const std::string& s) : std::string(s) {}
~ObjectString() {}
};
}
#endif /*BERRYOSGISTRING_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berryObjectVector.h b/BlueBerry/Bundles/org.blueberry.osgi/src/berryObjectVector.h
index 7abac97ecc..ab39765d6f 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/berryObjectVector.h
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/berryObjectVector.h
@@ -1,43 +1,43 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYOSGIOBJECTVECTOR_H_
#define BERRYOSGIOBJECTVECTOR_H_
#include "berryMacros.h"
#include <vector>
namespace berry {
template<typename T>
class ObjectVector : public Object, public std::vector<T>
{
public:
berryObjectMacro(ObjectVector<T>);
bool operator==(const Object* obj) const
{
if (const ObjectVector* other = dynamic_cast<const ObjectVector*>(obj))
static_cast<const std::vector<T> &>(*this) == static_cast<const std::vector<T>& >(*other);
return false;
}
};
}
#endif /*BERRYOSGIOBJECTVECTOR_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berryObjects.cpp b/BlueBerry/Bundles/org.blueberry.osgi/src/berryObjects.cpp
index 0c318b4e26..8c26d58c90 100755
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/berryObjects.cpp
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/berryObjects.cpp
@@ -1,22 +1,22 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryObjects.h"
template class berry::ObjectGeneric<bool>;
template class berry::ObjectGeneric<int>;
template class berry::ObjectGeneric<float>;
template class berry::ObjectGeneric<double>;
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berryObjects.h b/BlueBerry/Bundles/org.blueberry.osgi/src/berryObjects.h
index 58b19a99e6..718fdf0bf0 100755
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/berryObjects.h
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/berryObjects.h
@@ -1,32 +1,32 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYOBJECTS_H_
#define BERRYOBJECTS_H_
#include "berryObjectGeneric.h"
namespace berry {
berrySpecializeGenericObject(ObjectBool,bool,false);
berrySpecializeGenericObject(ObjectInt,int,0);
berrySpecializeGenericObject(ObjectFloat,float,0.0f);
berrySpecializeGenericObject(ObjectDouble,double,0.0);
}
#endif /* BERRYOBJECTS_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berryPlatform.cpp b/BlueBerry/Bundles/org.blueberry.osgi/src/berryPlatform.cpp
index e11ec74fbb..e2c2c4d7ab 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/berryPlatform.cpp
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/berryPlatform.cpp
@@ -1,229 +1,229 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 <Poco/Path.h>
#include "berryPlatform.h"
#include "service/berryIExtensionPointService.h"
#include "internal/berryInternalPlatform.h"
namespace berry {
int Platform::OS_FREE_BSD = BERRY_OS_FREE_BSD;
int Platform::OS_AIX = BERRY_OS_AIX;
int Platform::OS_HPUX = BERRY_OS_HPUX;
int Platform::OS_TRU64 = BERRY_OS_TRU64;
int Platform::OS_LINUX = BERRY_OS_LINUX;
int Platform::OS_MAC_OS_X = BERRY_OS_MAC_OS_X;
int Platform::OS_NET_BSD = BERRY_OS_NET_BSD;
int Platform::OS_OPEN_BSD = BERRY_OS_OPEN_BSD;
int Platform::OS_IRIX = BERRY_OS_IRIX;
int Platform::OS_SOLARIS = BERRY_OS_SOLARIS;
int Platform::OS_QNX = BERRY_OS_QNX;
int Platform::OS_VXWORKS = BERRY_OS_VXWORKS;
int Platform::OS_CYGWIN = BERRY_OS_CYGWIN;
int Platform::OS_UNKNOWN_UNIX = BERRY_OS_UNKNOWN_UNIX;
int Platform::OS_WINDOWS_NT = BERRY_OS_WINDOWS_NT;
int Platform::OS_WINDOWS_CE = BERRY_OS_WINDOWS_CE;
int Platform::OS_VMS = BERRY_OS_VMS;
int Platform::ARCH_ALPHA = BERRY_ARCH_ALPHA;
int Platform::ARCH_IA32 = BERRY_ARCH_IA32;
int Platform::ARCH_IA64 = BERRY_ARCH_IA64;
int Platform::ARCH_MIPS = BERRY_ARCH_MIPS;
int Platform::ARCH_HPPA = BERRY_ARCH_HPPA;
int Platform::ARCH_PPC = BERRY_ARCH_PPC;
int Platform::ARCH_POWER = BERRY_ARCH_POWER;
int Platform::ARCH_SPARC = BERRY_ARCH_SPARC;
int Platform::ARCH_AMD64 = BERRY_ARCH_AMD64;
int Platform::ARCH_ARM = BERRY_ARCH_ARM;
std::string Platform::ARG_NEWINSTANCE = "BlueBerry.newInstance";
std::string Platform::ARG_CLEAN = "BlueBerry.clean";
std::string Platform::ARG_APPLICATION = "BlueBerry.application";
std::string Platform::ARG_HOME = "BlueBerry.home";
std::string Platform::ARG_STORAGE_DIR = "BlueBerry.storageDir";
std::string Platform::ARG_PLUGIN_CACHE = "BlueBerry.plugin_cache_dir";
std::string Platform::ARG_PLUGIN_DIRS = "BlueBerry.plugin_dirs";
std::string Platform::ARG_FORCE_PLUGIN_INSTALL = "BlueBerry.forcePlugins";
std::string Platform::ARG_PRELOAD_LIBRARY = "BlueBerry.preloadLibrary";
std::string Platform::ARG_PROVISIONING = "BlueBerry.provisioning";
std::string Platform::ARG_CONSOLELOG = "BlueBerry.consoleLog";
std::string Platform::ARG_TESTPLUGIN = "BlueBerry.testplugin";
std::string Platform::ARG_TESTAPPLICATION = "BlueBerry.testapplication";
std::string Platform::ARG_XARGS = "xargs";
const Poco::Path& Platform::GetConfigurationPath()
{
return InternalPlatform::GetInstance()->GetConfigurationPath();
}
SmartPointer<IExtensionPointService> Platform::GetExtensionPointService()
{
return InternalPlatform::GetInstance()->GetExtensionPointService();
}
PlatformEvents& Platform::GetEvents()
{
return InternalPlatform::GetInstance()->GetEvents();
}
const Poco::Path& Platform::GetInstallPath()
{
return InternalPlatform::GetInstance()->GetInstallPath();
}
const Poco::Path& Platform::GetInstancePath()
{
return InternalPlatform::GetInstance()->GetInstancePath();
}
int Platform::GetOS()
{
return BERRY_OS;
}
int Platform::GetOSArch()
{
return BERRY_ARCH;
}
bool Platform::IsUnix()
{
#ifdef BERRY_OS_FAMILY_UNIX
return true;
#else
return false;
#endif
}
bool Platform::IsWindows()
{
#ifdef BERRY_OS_FAMILY_WINDOWS
return true;
#else
return false;
#endif
}
bool Platform::IsBSD()
{
#ifdef BERRY_OS_FAMILY_BSD
return true;
#else
return false;
#endif
}
bool Platform::IsLinux()
{
#ifdef BERRY_OS_FAMILY_LINUX
return true;
#else
return false;
#endif
}
bool Platform::IsVMS()
{
#ifdef BERRY_OS_FAMILY_VMS
return true;
#else
return false;
#endif
}
bool Platform::GetStatePath(Poco::Path& statePath, IBundle::Pointer bundle, bool create)
{
return InternalPlatform::GetInstance()->GetStatePath(statePath, bundle, create);
}
const Poco::Path& Platform::GetUserPath()
{
return InternalPlatform::GetInstance()->GetUserPath();
}
std::string Platform::GetProperty(const std::string& /*key*/)
{
return "";
}
bool Platform::IsRunning()
{
return InternalPlatform::GetInstance()->IsRunning();
}
int& Platform::GetRawApplicationArgs(char**& argv)
{
return InternalPlatform::GetInstance()->GetRawApplicationArgs(argv);
}
std::vector<std::string> Platform::GetApplicationArgs()
{
return InternalPlatform::GetInstance()->GetApplicationArgs();
}
std::string Platform::GetExtendedApplicationArgs()
{
return InternalPlatform::GetInstance()->GetConfiguration().getString(ARG_XARGS, "");
}
void Platform::GetOptionSet(Poco::Util::OptionSet& os)
{
InternalPlatform::GetInstance()->defineOptions(os);
}
Poco::Util::LayeredConfiguration& Platform::GetConfiguration()
{
return InternalPlatform::GetInstance()->GetConfiguration();
}
ServiceRegistry& Platform::GetServiceRegistry()
{
return InternalPlatform::GetInstance()->GetServiceRegistry();
}
IBundle::Pointer Platform::GetBundle(const std::string& id)
{
return InternalPlatform::GetInstance()->GetBundle(id);
}
std::vector<IBundle::Pointer> Platform::GetBundles()
{
return InternalPlatform::GetInstance()->GetBundles();
}
QSharedPointer<ctkPlugin> Platform::GetCTKPlugin(const QString& symbolicName)
{
QList<QSharedPointer<ctkPlugin> > plugins =
InternalPlatform::GetInstance()->GetCTKPluginFrameworkContext()->getPlugins();
foreach(QSharedPointer<ctkPlugin> plugin, plugins)
{
if (plugin->getSymbolicName() == symbolicName)
return plugin;
}
return QSharedPointer<ctkPlugin>(0);
}
QSharedPointer<ctkPlugin> Platform::GetCTKPlugin(long id)
{
return InternalPlatform::GetInstance()->GetCTKPluginFrameworkContext()->getPlugin(id);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berryPlatform.h b/BlueBerry/Bundles/org.blueberry.osgi/src/berryPlatform.h
index 7e13dbabdb..6bde5fcf81 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/berryPlatform.h
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/berryPlatform.h
@@ -1,359 +1,359 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRY_Platform_INCLUDED
#define BERRY_Platform_INCLUDED
//
// Platform Identification
//
#define BERRY_OS_FREE_BSD 0x0001
#define BERRY_OS_AIX 0x0002
#define BERRY_OS_HPUX 0x0003
#define BERRY_OS_TRU64 0x0004
#define BERRY_OS_LINUX 0x0005
#define BERRY_OS_MAC_OS_X 0x0006
#define BERRY_OS_NET_BSD 0x0007
#define BERRY_OS_OPEN_BSD 0x0008
#define BERRY_OS_IRIX 0x0009
#define BERRY_OS_SOLARIS 0x000a
#define BERRY_OS_QNX 0x000b
#define BERRY_OS_VXWORKS 0x000c
#define BERRY_OS_CYGWIN 0x000d
#define BERRY_OS_UNKNOWN_UNIX 0x00ff
#define BERRY_OS_WINDOWS_NT 0x1001
#define BERRY_OS_WINDOWS_CE 0x1011
#define BERRY_OS_VMS 0x2001
#if defined(__FreeBSD__)
#define BERRY_OS_FAMILY_UNIX 1
#define BERRY_OS_FAMILY_BSD 1
#define BERRY_OS BERRY_OS_FREE_BSD
#elif defined(_AIX) || defined(__TOS_AIX__)
#define BERRY_OS_FAMILY_UNIX 1
#define BERRY_OS BERRY_OS_AIX
#elif defined(hpux) || defined(_hpux)
#define BERRY_OS_FAMILY_UNIX 1
#define BERRY_OS BERRY_OS_HPUX
#elif defined(__digital__) || defined(__osf__)
#define BERRY_OS_FAMILY_UNIX 1
#define BERRY_OS BERRY_OS_TRU64
#elif defined(linux) || defined(__linux) || defined(__linux__) || defined(__TOS_LINUX__)
#define BERRY_OS_FAMILY_UNIX 1
#define BERRY_OS BERRY_OS_LINUX
#elif defined(__APPLE__) || defined(__TOS_MACOS__)
#define BERRY_OS_FAMILY_UNIX 1
#define BERRY_OS_FAMILY_BSD 1
#define BERRY_OS BERRY_OS_MAC_OS_X
#elif defined(__NetBSD__)
#define BERRY_OS_FAMILY_UNIX 1
#define BERRY_OS_FAMILY_BSD 1
#define BERRY_OS BERRY_OS_NET_BSD
#elif defined(__OpenBSD__)
#define BERRY_OS_FAMILY_UNIX 1
#define BERRY_OS_FAMILY_BSD 1
#define BERRY_OS BERRY_OS_OPEN_BSD
#elif defined(sgi) || defined(__sgi)
#define BERRY_OS_FAMILY_UNIX 1
#define BERRY_OS BERRY_OS_IRIX
#elif defined(sun) || defined(__sun)
#define BERRY_OS_FAMILY_UNIX 1
#define BERRY_OS BERRY_OS_SOLARIS
#elif defined(__QNX__)
#define BERRY_OS_FAMILY_UNIX 1
#define BERRY_OS BERRY_OS_QNX
#elif defined(unix) || defined(__unix) || defined(__unix__)
#define BERRY_OS_FAMILY_UNIX 1
#define BERRY_OS BERRY_OS_UNKNOWN_UNIX
#elif defined(_WIN32_WCE)
#define BERRY_OS_FAMILY_WINDOWS 1
#define BERRY_OS BERRY_OS_WINDOWS_CE
#elif defined(_WIN32) || defined(_WIN64)
#define BERRY_OS_FAMILY_WINDOWS 1
#define BERRY_OS BERRY_OS_WINDOWS_NT
#elif defined(__CYGWIN__)
#define BERRY_OS_FAMILY_UNIX 1
#define BERRY_OS BERRY_OS_CYGWIN
#elif defined(__VMS)
#define BERRY_OS_FAMILY_VMS 1
#define BERRY_OS BERRY_OS_VMS
#endif
//
// Hardware Architecture and Byte Order
//
#define BERRY_ARCH_ALPHA 0x01
#define BERRY_ARCH_IA32 0x02
#define BERRY_ARCH_IA64 0x03
#define BERRY_ARCH_MIPS 0x04
#define BERRY_ARCH_HPPA 0x05
#define BERRY_ARCH_PPC 0x06
#define BERRY_ARCH_POWER 0x07
#define BERRY_ARCH_SPARC 0x08
#define BERRY_ARCH_AMD64 0x09
#define BERRY_ARCH_ARM 0x0a
#if defined(__ALPHA) || defined(__alpha) || defined(__alpha__) || defined(_M_ALPHA)
#define BERRY_ARCH BERRY_ARCH_ALPHA
#define BERRY_ARCH_LITTLE_ENDIAN 1
#elif defined(i386) || defined(__i386) || defined(__i386__) || defined(_M_IX86)
#define BERRY_ARCH BERRY_ARCH_IA32
#define BERRY_ARCH_LITTLE_ENDIAN 1
#elif defined(_IA64) || defined(__IA64__) || defined(__ia64__) || defined(__ia64) || defined(_M_IA64)
#define BERRY_ARCH BERRY_ARCH_IA64
#if defined(hpux) || defined(_hpux)
#define BERRY_ARCH_BIG_ENDIAN 1
#else
#define BERRY_ARCH_LITTLE_ENDIAN 1
#endif
#elif defined(__x86_64__)
#define BERRY_ARCH BERRY_ARCH_AMD64
#define BERRY_ARCH_LITTLE_ENDIAN 1
#elif defined(_M_X64)
#define BERRY_ARCH BERRY_ARCH_AMD64
#define BERRY_ARCH_LITTLE_ENDIAN 1
#elif defined(__mips__) || defined(__mips) || defined(__MIPS__) || defined(_M_MRX000)
#define BERRY_ARCH BERRY_ARCH_MIPS
#define BERRY_ARCH_BIG_ENDIAN 1
#elif defined(__hppa) || defined(__hppa__)
#define BERRY_ARCH BERRY_ARCH_HPPA
#define BERRY_ARCH_BIG_ENDIAN 1
#elif defined(__PPC) || defined(__POWERPC__) || defined(__powerpc) || defined(__PPC__) || \
defined(__powerpc__) || defined(__ppc__) || defined(_ARCH_PPC) || defined(_M_PPC)
#define BERRY_ARCH BERRY_ARCH_PPC
#define BERRY_ARCH_BIG_ENDIAN 1
#elif defined(_POWER) || defined(_ARCH_PWR) || defined(_ARCH_PWR2) || defined(_ARCH_PWR3) || \
defined(_ARCH_PWR4) || defined(__THW_RS6000)
#define BERRY_ARCH BERRY_ARCH_POWER
#define BERRY_ARCH_BIG_ENDIAN 1
#elif defined(__sparc__) || defined(__sparc) || defined(sparc)
#define BERRY_ARCH BERRY_ARCH_SPARC
#define BERRY_ARCH_BIG_ENDIAN 1
#elif defined(__arm__) || defined(__arm) || defined(ARM) || defined(_ARM_) || defined(__ARM__) || defined(_M_ARM)
#define BERRY_ARCH BERRY_ARCH_ARM
#if defined(__ARMEB__)
#define BERRY_ARCH_BIG_ENDIAN 1
#else
#define BERRY_ARCH_LITTLE_ENDIAN 1
#endif
#endif
#include <org_blueberry_osgi_Export.h>
#include "event/berryPlatformEvents.h"
#include "service/berryServiceRegistry.h"
#include <Poco/Util/LayeredConfiguration.h>
#include <Poco/Util/OptionSet.h>
namespace berry {
struct IExtensionPointService;
/**
* The central class of the BlueBerry Platform Runtime. This class cannot
* be instantiated or subclassed by clients; all functionality is provided
* by static methods. Features include:
* <ul>
* <li>the platform registry of installed plug-ins</li>
* <li>the platform adapter manager</li>
* <li>the platform log</li>
* </ul>
* <p>
* Most users don't have to worry about Platform's lifecycle. However, if your
* code can call methods of this class when Platform is not running, it becomes
* necessary to check {@link #IsRunning()} before making the call. A runtime
* exception might be thrown or incorrect result might be returned if a method
* from this class is called while Platform is not running.
* </p>
*/
class BERRY_OSGI Platform
{
public:
static int OS_FREE_BSD;
static int OS_AIX;
static int OS_HPUX;
static int OS_TRU64;
static int OS_LINUX;
static int OS_MAC_OS_X;
static int OS_NET_BSD;
static int OS_OPEN_BSD;
static int OS_IRIX;
static int OS_SOLARIS;
static int OS_QNX;
static int OS_VXWORKS;
static int OS_CYGWIN;
static int OS_UNKNOWN_UNIX;
static int OS_WINDOWS_NT;
static int OS_WINDOWS_CE;
static int OS_VMS;
static int ARCH_ALPHA;
static int ARCH_IA32;
static int ARCH_IA64;
static int ARCH_MIPS;
static int ARCH_HPPA;
static int ARCH_PPC;
static int ARCH_POWER;
static int ARCH_SPARC;
static int ARCH_AMD64;
static int ARCH_ARM;
static std::string ARG_NEWINSTANCE;
static std::string ARG_CLEAN;
static std::string ARG_APPLICATION;
static std::string ARG_HOME;
static std::string ARG_STORAGE_DIR;
static std::string ARG_PLUGIN_CACHE;
static std::string ARG_PLUGIN_DIRS;
static std::string ARG_FORCE_PLUGIN_INSTALL;
static std::string ARG_PRELOAD_LIBRARY;
static std::string ARG_PROVISIONING;
static std::string ARG_CONSOLELOG;
static std::string ARG_TESTPLUGIN;
static std::string ARG_TESTAPPLICATION;
static std::string ARG_XARGS;
static SmartPointer<IExtensionPointService> GetExtensionPointService();
// static IPreferenceService GetPreferenceService();
static PlatformEvents& GetEvents();
/**
* Returns the path of the configuration information
* used to run this instance of the BlueBerry platform.
* The configuration area typically
* contains the list of plug-ins available for use, various settings
* (those shared across different instances of the same configuration)
* and any other such data needed by plug-ins.
* An empty path is returned if the platform is running without a configuration location.
*
* @return the location of the platform's configuration data area
*/
static const Poco::Path& GetConfigurationPath();
/**
* Returns the path of the base installation for the running platform
*
* @return the location of the platform's installation area or <code>null</code> if none
*/
static const Poco::Path& GetInstallPath();
/**
* Returns the path of the platform's working directory (also known as the instance data area).
* An empty path is returned if the platform is running without an instance location.
*
* @return the location of the platform's instance data area or <code>null</code> if none
*/
static const Poco::Path& GetInstancePath();
/**
* Returns the path in the local file system of the
* plug-in state area for the given bundle.
* If the plug-in state area did not exist prior to this call,
* it is created.
* <p>
* The plug-in state area is a file directory within the
* platform's metadata area where a plug-in is free to create files.
* The content and structure of this area is defined by the plug-in,
* and the particular plug-in is solely responsible for any files
* it puts there. It is recommended for plug-in preference settings and
* other configuration parameters.
* </p>
*
* @param bundle the bundle whose state location is returned
* @return a local file system path
* TODO Investigate the usage of a service factory
*/
static bool GetStatePath(Poco::Path& statePath, SmartPointer<IBundle> bundle, bool create = true);
/**
* Returns the path of the platform's user data area. The user data area is a location on the system
* which is specific to the system's current user. By default it is located relative to the
* location given by the System property "user.home".
* An empty path is returned if the platform is running without an user location.
*
* @return the location of the platform's user data area or <code>null</code> if none
*/
static const Poco::Path& GetUserPath();
static int GetOS();
static int GetOSArch();
static bool IsUnix();
static bool IsWindows();
static bool IsBSD();
static bool IsLinux();
static bool IsVMS();
static std::string GetProperty(const std::string& key);
static bool IsRunning();
static Poco::Util::LayeredConfiguration& GetConfiguration();
/**
* Returns the unmodified, original command line arguments
*
*/
static int& GetRawApplicationArgs(char**& argv);
/**
* Returns the applications command line arguments which
* have not been consumed by the platform.
*/
static std::vector<std::string> GetApplicationArgs();
/**
* Returns the "extended" command line arguments. This is
* just the string given as argument to the "--xargs" option.
*/
static std::string GetExtendedApplicationArgs();
static void GetOptionSet(Poco::Util::OptionSet &os);
static ServiceRegistry& GetServiceRegistry();
/**
* Returns the resolved bundle with the specified symbolic name that has the
* highest version. If no resolved bundles are installed that have the
* specified symbolic name then null is returned.
*
* @param id the symbolic name of the bundle to be returned.
* @return the bundle that has the specified symbolic name with the
* highest version, or <tt>null</tt> if no bundle is found.
*/
static IBundle::Pointer GetBundle(const std::string& id);
static std::vector<IBundle::Pointer> GetBundles();
static QSharedPointer<ctkPlugin> GetCTKPlugin(const QString& symbolicName);
static QSharedPointer<ctkPlugin> GetCTKPlugin(long id);
private:
Platform();
};
} // namespace
#endif // BERRY_Platform_INCLUDED
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berryPlatformException.cpp b/BlueBerry/Bundles/org.blueberry.osgi/src/berryPlatformException.cpp
index 62d78b46c6..205e462619 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/berryPlatformException.cpp
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/berryPlatformException.cpp
@@ -1,35 +1,35 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryPlatformException.h"
#include <typeinfo>
namespace berry {
POCO_IMPLEMENT_EXCEPTION(PlatformException, Poco::RuntimeException, "Platform exception");
POCO_IMPLEMENT_EXCEPTION(ManifestException, PlatformException, "Manifest syntax error");
POCO_IMPLEMENT_EXCEPTION(BundleException, PlatformException, "Bundle error");
POCO_IMPLEMENT_EXCEPTION(BundleStateException, PlatformException, "Bundle state invalid");
POCO_IMPLEMENT_EXCEPTION(BundleVersionConflictException, PlatformException, "Bundle version conflict");
POCO_IMPLEMENT_EXCEPTION(BundleLoadException, PlatformException, "Bundle load error");
POCO_IMPLEMENT_EXCEPTION(BundleResolveException, PlatformException, "Cannot resolve bundle");
POCO_IMPLEMENT_EXCEPTION(CoreException, PlatformException, "Core exception");
POCO_IMPLEMENT_EXCEPTION(InvalidServiceObjectException, CoreException, "Invalid service object");
}
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berryPlatformException.h b/BlueBerry/Bundles/org.blueberry.osgi/src/berryPlatformException.h
index 41fe42881c..1be092c6ad 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/berryPlatformException.h
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/berryPlatformException.h
@@ -1,39 +1,39 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYPLATFORMEXCEPTION_H_
#define BERRYPLATFORMEXCEPTION_H_
#include <org_blueberry_osgi_Export.h>
#include "Poco/Exception.h"
namespace berry {
POCO_DECLARE_EXCEPTION(BERRY_OSGI, PlatformException, Poco::RuntimeException);
POCO_DECLARE_EXCEPTION(BERRY_OSGI, ManifestException, PlatformException);
POCO_DECLARE_EXCEPTION(BERRY_OSGI, BundleException, PlatformException);
POCO_DECLARE_EXCEPTION(BERRY_OSGI, BundleStateException, PlatformException);
POCO_DECLARE_EXCEPTION(BERRY_OSGI, BundleVersionConflictException, PlatformException);
POCO_DECLARE_EXCEPTION(BERRY_OSGI, BundleLoadException, PlatformException);
POCO_DECLARE_EXCEPTION(BERRY_OSGI, BundleResolveException, PlatformException);
POCO_DECLARE_EXCEPTION(BERRY_OSGI, CoreException, PlatformException);
POCO_DECLARE_EXCEPTION(BERRY_OSGI, InvalidServiceObjectException, CoreException);
}
#endif /*BERRYPLATFORMEXCEPTION_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berryPlugin.cpp b/BlueBerry/Bundles/org.blueberry.osgi/src/berryPlugin.cpp
index 4667d2e33a..ce1a142f08 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/berryPlugin.cpp
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/berryPlugin.cpp
@@ -1,47 +1,47 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryPlugin.h"
#include "internal/berryInternalPlatform.h"
namespace berry {
void
Plugin::Start(IBundleContext::Pointer context)
{
m_Bundle = context->GetThisBundle();
}
void
Plugin::Stop(IBundleContext::Pointer /*context*/)
{
m_Bundle = 0;
}
IBundle::Pointer
Plugin::GetBundle()
{
return m_Bundle;
}
bool
Plugin::GetStatePath(Poco::Path& path)
{
return InternalPlatform::GetInstance()->GetStatePath(path, m_Bundle, true);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berryPlugin.h b/BlueBerry/Bundles/org.blueberry.osgi/src/berryPlugin.h
index d9f7abf6f7..b4260b5faa 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/berryPlugin.h
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/berryPlugin.h
@@ -1,55 +1,55 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYPLUGIN_H_
#define BERRYPLUGIN_H_
#include <org_blueberry_osgi_Export.h>
#include "berryIBundleActivator.h"
#include "berryIBundleContext.h"
#include "Poco/Logger.h"
#include "Poco/Path.h"
struct IBundle;
class BundleLoader;
namespace berry {
class BERRY_OSGI Plugin : public IBundleActivator
{
public:
void Start(IBundleContext::Pointer context);
void Stop(IBundleContext::Pointer context);
SmartPointer<IBundle> GetBundle();
//Poco::Logger& GetLog();
bool GetStatePath(Poco::Path& path);
protected:
friend class BundleLoader;
//TODO WeakPointer!!!
SmartPointer<IBundle> m_Bundle;
};
}
#endif /*BERRYPLUGIN_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berrySmartPointer.h b/BlueBerry/Bundles/org.blueberry.osgi/src/berrySmartPointer.h
index 673ca9b31c..8dd6a08c3a 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/berrySmartPointer.h
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/berrySmartPointer.h
@@ -1,383 +1,383 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYOSGISMARTPOINTER_H_
#define BERRYOSGISMARTPOINTER_H_
#include <iostream>
#include <stdexcept>
#include <org_blueberry_osgi_Export.h>
#include "berryException.h"
#include <berryConfig.h>
#if defined(BLUEBERRY_DEBUG_SMARTPOINTER)
#include "berryDebugUtil.h"
#include <Poco/Mutex.h>
#endif
namespace berry
{
template<class T> class WeakPointer;
/** \class SmartPointer
* \brief Implements transparent reference counting.
*
* SmartPointer is a copy of itk::SmartPointer.
* It implements reference counting by overloading
* operator -> (and *) among others. This allows natural interface
* to the class referred to by the pointer without having to invoke
* special Register()/UnRegister() methods directly.
*
*/
template<class TObjectType>
class SmartPointer
{
public:
typedef TObjectType ObjectType;
typedef SmartPointer Self;
/** Constructor */
SmartPointer() :
m_Pointer(0)
{
#if defined(BLUEBERRY_DEBUG_SMARTPOINTER)
DebugInitSmartPointer();
#endif
}
/** Constructor to pointer p */
explicit SmartPointer(ObjectType *p) :
m_Pointer(p)
{
if (m_Pointer)
this->Register();
#if defined(BLUEBERRY_DEBUG_SMARTPOINTER)
DebugInitSmartPointer();
#endif
}
/** Copy constructor */
SmartPointer(const SmartPointer<ObjectType> &p) :
m_Pointer(p.m_Pointer)
{
this->Register();
#if defined(BLUEBERRY_DEBUG_SMARTPOINTER)
DebugInitSmartPointer();
#endif
}
template<class Other>
SmartPointer(const SmartPointer<Other>& ptr) :
m_Pointer(const_cast<Other*> (ptr.GetPointer()))
{
if (m_Pointer)
this->Register();
#if defined(BLUEBERRY_DEBUG_SMARTPOINTER)
DebugInitSmartPointer();
#endif
}
template<class Other>
explicit SmartPointer(const WeakPointer<Other>& wp)
{
if (wp.m_Pointer)
{
this->m_Pointer = wp.m_Pointer;
this->Register();
#if defined(BLUEBERRY_DEBUG_SMARTPOINTER)
DebugInitSmartPointer();
#endif
}
else
{
throw BadWeakPointerException();
}
}
/** Destructor */
~SmartPointer()
{
#if defined(BLUEBERRY_DEBUG_SMARTPOINTER)
if (m_Pointer) DebugRemoveSmartPointer();
#endif
this->UnRegister();
m_Pointer = 0;
}
template<class Other>
SmartPointer<Other> Cast() const
{
Other* pOther = dynamic_cast<Other*> (m_Pointer);
return SmartPointer<Other> (pOther);
}
/** Overload operator -> */
ObjectType *operator ->() const
{
return m_Pointer;
}
// /** Return pointer to object. */
// operator ObjectType *() const
// {
// return m_Pointer;
// }
ObjectType & operator*() const
{
poco_assert( m_Pointer != 0 );
return *m_Pointer;
}
/** Test if the pointer has been initialized */
bool IsNotNull() const
{
return m_Pointer != 0;
}
bool IsNull() const
{
return m_Pointer == 0;
}
typedef ObjectType * Self::*unspecified_bool_type;
operator unspecified_bool_type () const
{
return m_Pointer == 0 ? 0: &Self::m_Pointer;
}
/** Template comparison operators. */
template<typename R>
bool operator ==(const R* o) const
{
return (m_Pointer == 0 ? o == 0 : (o && m_Pointer->operator==(o)));
}
template<typename R>
bool operator ==(const SmartPointer<R>& r) const
{
const R* o = r.GetPointer();
return (m_Pointer == 0 ? o == 0 : (o && m_Pointer->operator==(o)));
}
bool operator ==(int r) const
{
if (r == 0)
return m_Pointer == 0;
throw std::invalid_argument("Can only compare to 0");
}
template<typename R>
bool operator !=(const R* r) const
{
return !(this->operator==(r));
}
template<typename R>
bool operator !=(const SmartPointer<R>& r) const
{
return !(this->operator==(r));
}
bool operator !=(int r) const
{
if (r == 0)
return m_Pointer != 0;
throw std::invalid_argument("Can only compare to 0");
}
// /** Template comparison operators using operator==. */
// template<typename R>
// bool CompareTo(const SmartPointer<R>& r) const
// {
// return m_Pointer == 0 ? r == 0 : r.GetPointer() && m_Pointer->operator==(r.GetPointer());
// }
// template<typename R>
// bool CompareTo(R r) const
// {
// //const ObjectType* o = static_cast<const ObjectType*> (r);
// return m_Pointer == 0 ? r == 0 : (r && m_Pointer->operator==(r));
// }
/** Access function to pointer. */
ObjectType *GetPointer() const
{
return m_Pointer;
}
/** Comparison of pointers. Less than comparison. */
bool operator <(const SmartPointer &r) const
{
return (void*) m_Pointer < (void*) r.m_Pointer;
}
/** Comparison of pointers. Greater than comparison. */
bool operator>(const SmartPointer &r) const
{
return (void*) m_Pointer > (void*) r.m_Pointer;
}
/** Comparison of pointers. Less than or equal to comparison. */
bool operator <=(const SmartPointer &r) const
{
return (void*) m_Pointer <= (void*) r.m_Pointer;
}
/** Comparison of pointers. Greater than or equal to comparison. */
bool operator >=(const SmartPointer &r) const
{
return (void*) m_Pointer >= (void*) r.m_Pointer;
}
/** Overload operator assignment. */
SmartPointer &operator =(const SmartPointer &r)
{
return this->operator =(r.GetPointer());
}
/** Overload operator assignment. */
template<typename R>
SmartPointer &operator =(const SmartPointer<R>& r)
{
return this->operator =(r.GetPointer());
}
/** Overload operator assignment. */
SmartPointer &operator =(ObjectType *r)
{
if (m_Pointer != r)
{
#if defined(BLUEBERRY_DEBUG_SMARTPOINTER)
DebugAssignSmartPointer(r, m_Pointer);
#endif
ObjectType* tmp = m_Pointer; //avoid recursive unregisters by retaining temporarily
m_Pointer = r;
this->Register();
if (tmp)
{
tmp->UnRegister();
}
}
return *this;
}
/** Function to print object pointed to */
ObjectType *Print(std::ostream& os) const
{
// This prints the object pointed to by the pointer
(*m_Pointer).Print(os);
return m_Pointer;
}
private:
/** The pointer to the object referred to by this smart pointer. */
ObjectType* m_Pointer;
void Register()
{
if (m_Pointer)
{
m_Pointer->Register();
}
}
void UnRegister()
{
if (m_Pointer)
{
m_Pointer->UnRegister();
}
}
#if defined(BLUEBERRY_DEBUG_SMARTPOINTER)
unsigned int m_Id;
Poco::FastMutex m_Mutex;
void DebugInitSmartPointer()
{
{
Poco::FastMutex::ScopedLock lock(m_Mutex);
if (m_Pointer)
{
unsigned int& counter = DebugUtil::GetSmartPointerCounter();
m_Id = ++counter;
DebugUtil::RegisterSmartPointer(m_Id, m_Pointer);
}
else m_Id = 0;
}
//if (DebugUtil::GetSmartPointerCounter() == Platform::GetConfiguration().getInt(Platform::DEBUG_ARG_SMARTPOINTER_ID))
//throw 1;
}
void DebugRemoveSmartPointer()
{
Poco::FastMutex::ScopedLock lock(m_Mutex);
DebugUtil::UnregisterSmartPointer(m_Id, m_Pointer);
}
void DebugAssignSmartPointer(const ObjectType* newObject, const ObjectType* oldObject)
{
Poco::FastMutex::ScopedLock lock(m_Mutex);
if (oldObject)
DebugUtil::UnregisterSmartPointer(m_Id, oldObject);
if (newObject)
{
if (m_Id < 1)
{
unsigned int& counter = DebugUtil::GetSmartPointerCounter();
m_Id = ++counter;
}
DebugUtil::RegisterSmartPointer(m_Id, newObject);
}
}
public:
int GetId()
{
return m_Id;
}
private:
#endif
};
template<typename T>
std::ostream& operator<<(std::ostream& os, SmartPointer<T> p)
{
p.Print(os);
return os;
}
}
#endif /*BERRYOSGISMARTPOINTER_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/berryWeakPointer.h b/BlueBerry/Bundles/org.blueberry.osgi/src/berryWeakPointer.h
index 50bfb8b57b..bbd845bcf7 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/berryWeakPointer.h
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/berryWeakPointer.h
@@ -1,194 +1,194 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 __BERRY_WEAK_POINTER_H__
#define __BERRY_WEAK_POINTER_H__
#include <exception>
#include <iostream>
#include "berryMessage.h"
#include "berrySmartPointer.h"
namespace berry
{
/** \class WeakPointer
* \brief implements a WeakPointer class to deal with circular reference problems.
*
*
* The WeakPointer class implements smart pointer semantics without increasing the reference count.
* It registers itself at the Object it points to in order to get notified of its destruction and sets its internal pointer to 0.
* To be able to access an object through a weak pointer, you either use SmartPointer(const WeakPointer&)
* or the WeakPointer::Lock() method. The first approach throws a BadWeakPointerException if
* the object has been destroyed, the second returns an empty SmartPointer.
*/
template<class TObjectType>
class WeakPointer
{
public:
typedef TObjectType ObjectType;
/** Default Constructor */
WeakPointer() :
m_Pointer(0)
{
}
/** Constructor */
template<class Other>
explicit WeakPointer(berry::SmartPointer<Other> sptr) :
m_Pointer(dynamic_cast<ObjectType*>(sptr.GetPointer()))
{
if (m_Pointer)
m_Pointer->AddDestroyListener(MessageDelegate<WeakPointer> (this,
&WeakPointer::ObjectDestroyed));
}
/** constructor */
template<class Other>
WeakPointer(const WeakPointer<Other>& p) :
m_Pointer(dynamic_cast<ObjectType*>(p.m_Pointer))
{
if (m_Pointer)
m_Pointer->AddDestroyListener(MessageDelegate<WeakPointer> (this,
&WeakPointer::ObjectDestroyed));
}
/** Copy constructor */
WeakPointer(const WeakPointer& p) :
m_Pointer(p.m_Pointer)
{
if (m_Pointer)
m_Pointer->AddDestroyListener(MessageDelegate<WeakPointer> (this,
&WeakPointer::ObjectDestroyed));
}
template<class Other>
WeakPointer &operator =(const SmartPointer<Other> &r)
{
if (m_Pointer)
m_Pointer->RemoveDestroyListener(MessageDelegate<WeakPointer> (this,
&WeakPointer::ObjectDestroyed));
m_Pointer = const_cast<ObjectType*>(r.GetPointer());
if (m_Pointer)
m_Pointer->AddDestroyListener(MessageDelegate<WeakPointer> (this,
&WeakPointer::ObjectDestroyed));
return *this;
}
WeakPointer& operator=(const WeakPointer& other)
{
if (m_Pointer)
m_Pointer->RemoveDestroyListener(MessageDelegate<WeakPointer> (this,
&WeakPointer::ObjectDestroyed));
this->m_Pointer = other.m_Pointer;
if (m_Pointer)
m_Pointer->AddDestroyListener(MessageDelegate<WeakPointer> (this,
&WeakPointer::ObjectDestroyed));
return *this;
}
template<class Other>
WeakPointer& operator=(const WeakPointer<Other>& other)
{
if (m_Pointer)
m_Pointer->RemoveDestroyListener(MessageDelegate<WeakPointer> (this,
&WeakPointer::ObjectDestroyed));
this->m_Pointer = const_cast<ObjectType*>(other.m_Pointer);
if (m_Pointer)
m_Pointer->AddDestroyListener(MessageDelegate<WeakPointer> (this,
&WeakPointer::ObjectDestroyed));
return *this;
}
/** Template comparison operators. */
template<typename R>
bool operator ==(const R* o) const
{
return (m_Pointer == 0 ? o == 0 : (o && m_Pointer->operator==(o)));
}
template<typename R>
bool operator ==(const WeakPointer<R>& r) const
{
const R* o = r.m_Pointer;
return (m_Pointer == 0 ? o == 0 : (o && m_Pointer->operator==(o)));
}
/** Comparison of pointers. Less than comparison. */
bool operator <(const WeakPointer &r) const
{
return (void*) m_Pointer < (void*) r.m_Pointer;
}
/** lock method is used to access the referring object */
SmartPointer<ObjectType> Lock() const
{
SmartPointer<ObjectType> sp(m_Pointer);
return sp;
}
void Reset()
{
if (m_Pointer)
m_Pointer->RemoveDestroyListener(MessageDelegate<WeakPointer> (this,
&WeakPointer::ObjectDestroyed));
m_Pointer = 0;
}
bool Expired() const
{
return m_Pointer == 0;
}
/** Destructor */
~ WeakPointer()
{
if (m_Pointer)
m_Pointer->RemoveDestroyListener(MessageDelegate<WeakPointer> (this,
&WeakPointer::ObjectDestroyed));
}
private:
template<class Y> friend class SmartPointer;
template<class Y> friend class WeakPointer;
ObjectType *m_Pointer;
void ObjectDestroyed()
{
m_Pointer = 0;
}
};
}
#endif // __BERRY_WEAK_POINTER_H__
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/event/berryBundleEvent.cpp b/BlueBerry/Bundles/org.blueberry.osgi/src/event/berryBundleEvent.cpp
index 345f7769b7..fd1cf062b9 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/event/berryBundleEvent.cpp
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/event/berryBundleEvent.cpp
@@ -1,65 +1,65 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryBundleEvent.h"
#include "berryIBundle.h"
namespace berry {
BundleEvent::BundleEvent(IBundle::Pointer bundle, EventKind what) :
m_Bundle(bundle), m_What(what)
{
}
BundleEvent::BundleEvent(IBundle* bundle, EventKind what) :
m_Bundle(bundle), m_What(what)
{
}
BundleEvent::BundleEvent(const BundleEvent& event) :
m_Bundle(event.GetBundle()), m_What(event.What())
{
}
BundleEvent::~BundleEvent()
{
}
BundleEvent&
BundleEvent::operator= (const BundleEvent& event)
{
m_Bundle = event.GetBundle();
m_What = event.What();
return *this;
}
IBundle::ConstPointer
BundleEvent::GetBundle() const
{
return m_Bundle;
}
BundleEvent::EventKind
BundleEvent::What() const
{
return m_What;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/event/berryBundleEvent.h b/BlueBerry/Bundles/org.blueberry.osgi/src/event/berryBundleEvent.h
index d176a96875..c731a5d3c2 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/event/berryBundleEvent.h
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/event/berryBundleEvent.h
@@ -1,56 +1,56 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYBUNDLEEVENT_H_
#define BERRYBUNDLEEVENT_H_
#include <org_blueberry_osgi_Export.h>
#include "berrySmartPointer.h"
namespace berry {
struct IBundle;
class BERRY_OSGI BundleEvent
{
public:
enum EventKind { EV_BUNDLE_INSTALLED, EV_BUNDLE_LOADED, EV_BUNDLE_RESOLVING,
EV_BUNDLE_RESOLVED, EV_BUNDLE_STARTING, EV_BUNDLE_STARTED, EV_BUNDLE_STOPPING,
EV_BUNDLE_STOPPED, EV_BUNDLE_UNINSTALLING, EV_BUNDLE_UNINSTALLED, EV_BUNDLE_UNLOADED
};
BundleEvent(SmartPointer<IBundle> bundle, EventKind what);
BundleEvent(IBundle* bundle, EventKind what);
BundleEvent(const BundleEvent& event);
virtual ~BundleEvent();
BundleEvent& operator= (const BundleEvent& event);
SmartPointer<const IBundle> GetBundle() const;
EventKind What() const;
private:
SmartPointer<const IBundle> m_Bundle;
EventKind m_What;
};
} // namespace berry
#endif /*BERRYBUNDLEEVENT_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/event/berryBundleEvents.h b/BlueBerry/Bundles/org.blueberry.osgi/src/event/berryBundleEvents.h
index eef7f4d01c..8f4c0ce999 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/event/berryBundleEvents.h
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/event/berryBundleEvents.h
@@ -1,45 +1,45 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYBUNDLEEVENTS_H_
#define BERRYBUNDLEEVENTS_H_
#include <org_blueberry_osgi_Export.h>
#include "berryMessage.h"
#include "berryBundleEvent.h"
namespace berry {
struct BERRY_OSGI BundleEvents
{
Message1<const BundleEvent&> bundleInstalled;
Message1<const BundleEvent&> bundleLoaded;
Message1<const BundleEvent&> bundleResolved;
Message1<const BundleEvent&> bundleResolving;
Message1<const BundleEvent&> bundleStarted;
Message1<const BundleEvent&> bundleStarting;
Message1<const BundleEvent&> bundleStopped;
Message1<const BundleEvent&> bundleStopping;
Message1<const BundleEvent&> bundleUninstalled;
Message1<const BundleEvent&> bundleUninstalling;
Message1<const BundleEvent&> bundleUnloaded;
};
} // namespace berry
#endif /*BERRYBUNDLEEVENTS_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/event/berryPlatformEvent.cpp b/BlueBerry/Bundles/org.blueberry.osgi/src/event/berryPlatformEvent.cpp
index f42ce0e8e1..2e7a416376 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/event/berryPlatformEvent.cpp
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/event/berryPlatformEvent.cpp
@@ -1,76 +1,76 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryPlatformEvent.h"
namespace berry {
PlatformEvent::PlatformEvent(EventKind what)
: m_What(what), m_HasException(false), m_Data(0)
{
}
PlatformEvent::PlatformEvent(EventKind what, IBundle::Pointer bundle)
: m_Bundle(bundle), m_What(what), m_HasException(false), m_Data(0)
{
}
PlatformEvent::PlatformEvent(EventKind what, IBundle::Pointer bundle, std::exception exc)
: m_Bundle(bundle), m_Exception(exc), m_What(what), m_HasException(true), m_Data(0)
{
}
PlatformEvent::EventKind
PlatformEvent::What() const
{
return m_What;
}
const std::exception*
PlatformEvent::GetException() const
{
if (m_HasException) return &m_Exception;
return 0;
}
IBundle::Pointer
PlatformEvent::GetBundle()
{
return m_Bundle;
}
void
PlatformEvent::SetData(Poco::Any* data)
{
m_Data = data;
}
Poco::Any*
PlatformEvent::GetData()
{
return m_Data;
}
const Poco::Any*
PlatformEvent::GetData() const
{
return m_Data;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/event/berryPlatformEvent.h b/BlueBerry/Bundles/org.blueberry.osgi/src/event/berryPlatformEvent.h
index 22ce3c4743..c56ef25861 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/event/berryPlatformEvent.h
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/event/berryPlatformEvent.h
@@ -1,61 +1,61 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYPLATFORMEVENT_H_
#define BERRYPLATFORMEVENT_H_
#include <org_blueberry_osgi_Export.h>
#include "berryIBundle.h"
#include "Poco/Any.h"
#include <exception>
namespace berry {
class BERRY_OSGI PlatformEvent
{
public:
enum EventKind { EV_PLATFORM_STARTED, EV_PLATFORM_ERROR, EV_PLATFORM_WARNING,
EV_LOGGED};
PlatformEvent(EventKind what);
PlatformEvent(EventKind what, IBundle::Pointer bundle);
PlatformEvent(EventKind what, IBundle::Pointer bundle, std::exception exc);
EventKind What() const;
const std::exception* GetException() const;
IBundle::Pointer GetBundle();
void SetData(Poco::Any* data);
Poco::Any* GetData();
const Poco::Any* GetData() const;
private:
IBundle::Pointer m_Bundle;
std::exception m_Exception;
EventKind m_What;
bool m_HasException;
Poco::Any* m_Data;
};
}
#endif /*BERRYPLATFORMEVENT_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/event/berryPlatformEvents.h b/BlueBerry/Bundles/org.blueberry.osgi/src/event/berryPlatformEvents.h
index 4e2b0248dc..03fd2425fa 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/event/berryPlatformEvents.h
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/event/berryPlatformEvents.h
@@ -1,41 +1,41 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYPLATFORMEVENTS_H_
#define BERRYPLATFORMEVENTS_H_
#include <org_blueberry_osgi_Export.h>
#include "berryMessage.h"
#include "berryPlatformEvent.h"
namespace berry {
struct BERRY_OSGI PlatformEvents
{
typedef Message1<const PlatformEvent&> EventType;
EventType platformStarted;
EventType platformError;
EventType platformWarning;
EventType logged;
};
}
#endif /*BERRYPLATFORMEVENTS_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryBundle.cpp b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryBundle.cpp
index 5c5b4f86e1..4e118d87f3 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryBundle.cpp
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryBundle.cpp
@@ -1,318 +1,318 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryLog.h"
#include "Poco/Exception.h"
#include "berryBundle.h"
#include "berryInternalPlatform.h"
#include "berryBundleLoader.h"
#include "berryBundleManifest.h"
#include "berryIBundleActivator.h"
#include "berryIBundleContext.h"
#include "berryPlatformException.h"
#include <ctkPluginContext.h>
#include <iostream>
namespace berry {
Bundle::Bundle(BundleLoader& loader, IBundleStorage::Pointer storage, bool initialize) :
m_BundleLoader(loader)
{
{
Poco::Mutex::ScopedLock lock(m_Mutex);
m_Storage = storage;
}
if (initialize)
{
init();
}
}
void Bundle::init()
{
Poco::Mutex::ScopedLock lock(m_Mutex);
try
{
this->LoadManifest();
m_State = BUNDLE_INSTALLED;
}
catch (Poco::FileException& exc)
{
BERRY_ERROR << "Exception: " << exc.displayText() << std::endl;
m_State = BUNDLE_UNINSTALLED;
}
}
Bundle::~Bundle()
{
}
bool Bundle::operator==(const Object* o) const
{
if (const IBundle* bundle = dynamic_cast<const IBundle*>(o))
return this->GetSymbolicName() == bundle->GetSymbolicName();
return false;
}
IBundleActivator*
Bundle::GetActivator() const
{
Poco::Mutex::ScopedLock lock(m_Mutex);
if (m_State == BUNDLE_ACTIVE)
return m_Activator;
return 0;
}
const std::string&
Bundle::GetActivatorClass() const
{
return m_Manifest->GetActivatorClass();
}
const std::string&
Bundle::GetActivatorLibrary() const
{
return m_Manifest->GetActivatorLibrary();
}
const std::string&
Bundle::GetCopyright() const
{
return m_Manifest->GetCopyright();
}
const std::string&
Bundle::GetVendor() const
{
return m_Manifest->GetVendor();
}
IBundleManifest::ActivationPolicy
Bundle::GetActivationPolicy() const
{
return m_Manifest->GetActivationPolicy();
}
std::istream*
Bundle::GetLocalizedResource(const std::string& name) const
{
return m_Storage->GetResource(name);
}
std::istream*
Bundle::GetResource(const std::string& name) const
{
return m_Storage->GetResource(name);
}
bool
Bundle::IsActive() const
{
return m_State == BUNDLE_ACTIVE;
}
bool
Bundle::IsResolved() const
{
return m_State == BUNDLE_RESOLVED || m_State == BUNDLE_STARTING ||
m_State == BUNDLE_ACTIVE || m_State == BUNDLE_STOPPING;
}
bool
Bundle::IsStarted() const
{
return m_State == BUNDLE_STARTING || m_State == BUNDLE_ACTIVE ||
m_State == BUNDLE_STOPPING;
}
bool Bundle::IsSystemBundle() const
{
return m_Manifest->IsSystemBundle();
}
const IBundleManifest&
Bundle::GetManifest() const
{
return *m_Manifest;
}
const std::string&
Bundle::GetName() const
{
return m_Manifest->GetName();
}
const Poco::Path
Bundle::GetPath() const
{
return m_Storage->GetPath();
}
IBundleStorage&
Bundle::GetStorage()
{
return *m_Storage;
}
// const Version& GetVersion() const;
const IBundleManifest::Dependencies&
Bundle::GetRequiredBundles() const
{
return m_Manifest->GetRequiredBundles();
}
void
Bundle::Resolve()
{
if (m_State == BUNDLE_INSTALLED)
{
ctkPluginContext* context = InternalPlatform::GetInstance()->GetCTKPluginFrameworkContext();
//const BundleManifest::Dependencies& dependencies =;
IBundleManifest::Dependencies::const_iterator iter;
for (iter = this->GetRequiredBundles().begin(); iter != this->GetRequiredBundles().end(); ++iter)
{
//BERRY_INFO << "Checking dependency:" << iter->symbolicName << ";\n";
IBundle::Pointer bundle = m_BundleLoader.FindBundle(iter->symbolicName);
if (bundle.IsNull())
{
// Check if we have a CTK Plugin dependency
bool resolved = false;
if (context)
{
QString symbolicName = QString::fromStdString(iter->symbolicName);
foreach (QSharedPointer<ctkPlugin> plugin, context->getPlugins())
{
if (plugin->getSymbolicName() == symbolicName)
{
resolved = true;
break;
}
}
}
if (!resolved)
{
throw BundleResolveException("The bundle " + this->GetSymbolicName() + " depends on missing bundle:", iter->symbolicName);
}
}
else if (!bundle->IsResolved())
{
bundle->Resolve();
}
}
m_State = BUNDLE_RESOLVED;
}
}
void
Bundle::Start()
{
if (m_State == BUNDLE_RESOLVED)
{
Poco::Mutex::ScopedLock lock(m_Mutex);
m_State = BUNDLE_STARTING;
// BundleEvent starting(this, BundleEvent::EV_BUNDLE_STARTING);
// this->GetEvents().bundleStarting(this, starting);
BERRY_INFO(InternalPlatform::GetInstance()->ConsoleLog()) << "Bundle " << this->GetSymbolicName() << " is starting";
m_Activator->Start(m_BundleLoader.GetContextForBundle(IBundle::Pointer(this)));
m_State = BUNDLE_ACTIVE;
// BundleEvent started(this, BundleEvent::EV_BUNDLE_STARTED);
// this->GetEvents().bundleStarted(this, started);
// BERRY_INFO << "Bundle " << this->GetSymbolicName() << " is active";
}
else
{
throw BundleStateException("Bundle " + this->GetSymbolicName() +
" could not be started, because it is not in state RESOLVED.");
}
}
void
Bundle::Stop()
{
throw Poco::NotImplementedException("Bundle::Stop() not implemented yet");
}
Bundle::State
Bundle::GetState() const
{
return m_State;
}
std::string
Bundle::GetStateString() const
{
switch (this->GetState())
{
case BUNDLE_INSTALLED:
return "Installed";
case BUNDLE_UNINSTALLED:
return "Uninstalled";
case BUNDLE_RESOLVED:
return "Resolved";
case BUNDLE_STARTING:
return "Starting";
case BUNDLE_ACTIVE:
return "Active";
case BUNDLE_STOPPING:
return "Stopping";
default: throw BundleStateException("The bundle is not in a valid state");
}
}
BundleEvents&
Bundle::GetEvents()
{
return m_BundleLoader.GetEvents();
}
const std::string&
Bundle::GetSymbolicName() const
{
return m_Manifest->GetSymbolicName();
}
void
Bundle::LoadManifest()
{
std::istream* istr = m_Storage->GetResource("META-INF/MANIFEST.MF");
if (!istr)
throw Poco::FileNotFoundException("Could not load META-INF/MANIFEST.MF from " + m_Storage->GetPath().toString());
m_Manifest = new BundleManifest(istr);
delete istr;
}
void
Bundle::SetActivator(IBundleActivator* activator)
{
Poco::Mutex::ScopedLock lock(m_Mutex);
m_Activator = activator;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryBundle.h b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryBundle.h
index 31665098b4..33dc071e57 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryBundle.h
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryBundle.h
@@ -1,98 +1,98 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYBUNDLE_H_
#define BERRYBUNDLE_H_
#include "Poco/Path.h"
#include "Poco/Mutex.h"
#include "berryIBundle.h"
#include "berryIBundleStorage.h"
namespace berry {
class BundleLoader;
class Bundle : public IBundle
{
public:
berryObjectMacro(Bundle);
Bundle(BundleLoader& loader, IBundleStorage::Pointer storage, bool init = true);
~Bundle();
void init();
IBundleActivator* GetActivator() const;
const std::string& GetActivatorClass() const;
const std::string& GetActivatorLibrary() const;
const std::string& GetCopyright() const;
const std::string& GetVendor() const;
IBundleManifest::ActivationPolicy GetActivationPolicy() const;
std::istream* GetLocalizedResource(const std::string& name) const;
std::istream* GetResource(const std::string& name) const;
bool IsActive() const;
bool IsResolved() const;
bool IsStarted() const;
bool IsSystemBundle() const;
const IBundleManifest& GetManifest() const;
const std::string& GetName() const;
const Poco::Path GetPath() const;
IBundleStorage& GetStorage();
// const Version& GetVersion() const;
const IBundleManifest::Dependencies& GetRequiredBundles() const;
void Resolve();
void Start();
void Stop();
State GetState() const;
std::string GetStateString() const;
BundleEvents& GetEvents();
const std::string& GetSymbolicName() const;
virtual void LoadManifest();
void SetActivator(IBundleActivator* activator);
bool operator==(const Object* o) const;
protected:
IBundleManifest::Pointer m_Manifest;
IBundleStorage::Pointer m_Storage;
BundleLoader& m_BundleLoader;
IBundleActivator* m_Activator;
State m_State;
mutable Poco::Mutex m_Mutex;
};
} // namespace berry
#endif /*BERRYBUNDLE_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryBundleContext.cpp b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryBundleContext.cpp
index 175ecd5737..4ee5eddc87 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryBundleContext.cpp
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryBundleContext.cpp
@@ -1,110 +1,110 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryBundleContext.h"
#include "berryBundle.h"
#include "berryBundleLoader.h"
namespace berry {
BundleContext::BundleContext(BundleLoader& loader, IBundle::Pointer bundle,
const Poco::Path& persistencyDir) :
m_BundleLoader(loader),m_Bundle(bundle), m_PersistencyDir(persistencyDir)
{
}
BundleContext::~BundleContext()
{
}
bool BundleContext::operator==(const Object* o) const
{
if (const IBundleContext* context = dynamic_cast<const IBundleContext*>(o))
return this->GetThisBundle() == context->GetThisBundle();
return false;
}
void BundleContext::RegisterService(const std::string& id, Service::Pointer service) const
{
Platform::GetServiceRegistry().RegisterService(id, service);
}
IBundleContext::Pointer
BundleContext::GetContextForBundle(IBundle::ConstPointer bundle) const
{
return m_BundleLoader.GetContextForBundle(bundle);
}
BundleEvents&
BundleContext::GetEvents() const
{
return m_BundleLoader.GetEvents();
}
IBundle::ConstPointer
BundleContext::FindBundle(const std::string& name) const
{
return m_BundleLoader.FindBundle(name);
}
void
BundleContext::ListBundles(std::vector<IBundle::Pointer>& bundles) const
{
for (BundleLoader::BundleMap::const_iterator i = m_BundleLoader.m_BundleMap.begin();
i != m_BundleLoader.m_BundleMap.end(); ++i)
{
if (i->second.m_Bundle)
{
bundles.push_back(i->second.m_Bundle);
}
}
}
Poco::Logger&
BundleContext::GetLogger() const
{
return m_BundleLoader.GetLogger();
}
Poco::Path
BundleContext::GetPathForLibrary(const std::string& libraryName) const
{
return m_BundleLoader.GetPathForLibrary(libraryName);
}
Poco::Path
BundleContext::GetPersistentDirectory() const
{
return m_PersistencyDir;
}
IBundle::Pointer
BundleContext::GetThisBundle() const
{
return m_Bundle;
}
void
BundleContext::InitPersistency(const std::string& /*persistencyPath*/)
{
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryBundleContext.h b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryBundleContext.h
index da0a6b439c..7336dd9001 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryBundleContext.h
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryBundleContext.h
@@ -1,71 +1,71 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYBUNDLECONTEXT_H_
#define BERRYBUNDLECONTEXT_H_
#include "berryIBundleContext.h"
#include "berryBundleLoader.h"
namespace berry {
class BundleContext : public IBundleContext
{
public:
berryObjectMacro(BundleContext);
BundleContext(BundleLoader& loader, SmartPointer<IBundle> bundle,
const Poco::Path& persistencyDir);
~BundleContext();
IBundleContext::Pointer GetContextForBundle(SmartPointer<const IBundle> bundle) const;
BundleEvents& GetEvents() const;
SmartPointer<const IBundle> FindBundle(const std::string& name) const;
void ListBundles(std::vector<SmartPointer<IBundle> >& bundles) const;
Poco::Logger& GetLogger() const;
// Logger& GetLogger() const;
Poco::Path GetPathForLibrary(const std::string& libraryName) const;
Poco::Path GetPersistentDirectory() const;
void RegisterService(const std::string& id, Service::Pointer service) const;
SmartPointer<IBundle> GetThisBundle() const;
void InitPersistency(const std::string& persistencyPath);
//static std::string GetLoggerName(const Bundle* bundle);
bool operator==(const Object* o) const;
private:
BundleLoader& m_BundleLoader;
SmartPointer<IBundle> m_Bundle;
const Poco::Path m_PersistencyDir;
};
} // namespace berry
#endif /*BERRYBUNDLECONTEXT_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryBundleDirectory.cpp b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryBundleDirectory.cpp
index 9a30e067f7..34be115bba 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryBundleDirectory.cpp
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryBundleDirectory.cpp
@@ -1,117 +1,117 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryLog.h"
#include "berryBundleDirectory.h"
#include "berryInternalPlatform.h"
#include <iostream>
#include "Poco/Exception.h"
#include "Poco/FileStream.h"
#include "Poco/Path.h"
#include "Poco/File.h"
namespace berry {
BundleDirectory::BundleDirectory(const Path& path) :
m_RootPath(path)
{
//Path manifestPath(m_RootPath);
//manifestPath.append(Path("META-INF/manifest.mf"));
}
BundleDirectory::~BundleDirectory()
{
}
bool BundleDirectory::operator==(const Object* o) const
{
if (const IBundleStorage* dir = dynamic_cast<const IBundleStorage*>(o))
return this->GetPath().toString() == dir->GetPath().toString();
return false;
}
std::istream*
BundleDirectory::GetResource(const std::string& path) const
{
Poco::Path resPath(m_RootPath);
std::string resStr = resPath.append(Path(path)).toString();
//BERRY_INFO << "Getting resource: " << resStr << std::endl;
try {
return new Poco::FileInputStream(resStr);
}
catch (...)
{}
return 0;
}
void
BundleDirectory::List(const std::string& path, std::vector<std::string>& files,
bool quiet) const
{
try
{
Poco::Path fullPath(m_RootPath);
fullPath.append(path);
Poco::File file(fullPath);
file.list(files);
}
catch (Poco::FileNotFoundException& exc)
{
if (!quiet)
{
BERRY_WARN << "Warning: " << exc.displayText() << std::endl;
throw exc;
}
}
catch (const Poco::PathNotFoundException& exc)
{
if (!quiet)
{
BERRY_WARN << "Warning: " << exc.displayText() << std::endl;
throw exc;
}
}
}
bool BundleDirectory::IsDirectory(const std::string& path) const
{
Poco::Path fullPath(m_RootPath);
fullPath.append(path);
Poco::File file(fullPath.makeDirectory());
//BERRY_INFO(InternalPlatform::GetInstance()->ConsoleLog()) <<
// "Testing " << file.path() << " for directory: " <<
// (file.exists() && file.isDirectory() ? "true" : "false") << std::endl;
return file.exists() && file.isDirectory();
}
Path
BundleDirectory::GetPath() const
{
return m_RootPath;
}
Path BundleDirectory::BuildPath(const std::string& path) const
{
Poco::Path tmp(m_RootPath);
return tmp.append(Path(path));
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryBundleDirectory.h b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryBundleDirectory.h
index 9d8c35a3ed..bad41e41b0 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryBundleDirectory.h
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryBundleDirectory.h
@@ -1,54 +1,54 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYBUNDLEDIRECTORY_H_
#define BERRYBUNDLEDIRECTORY_H_
#include <Poco/Path.h>
#include "berryIBundleStorage.h"
namespace berry {
using namespace Poco;
class BundleDirectory : public IBundleStorage
{
private:
Path m_RootPath;
public:
berryObjectMacro(BundleDirectory);
BundleDirectory(const Path& path);
virtual ~BundleDirectory();
std::istream* GetResource(const std::string& path) const;
void List(const std::string& path, std::vector<std::string>& files, bool quiet = true) const;
bool IsDirectory(const std::string& path) const;
Path GetPath() const;
Path BuildPath(const std::string& path) const;
bool operator==(const Object* o) const;
};
} // namespace berry
#endif /*BERRYBUNDLEDIRECTORY_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryBundleManifest.cpp b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryBundleManifest.cpp
index b2a5b6c93d..db936da5dd 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryBundleManifest.cpp
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryBundleManifest.cpp
@@ -1,177 +1,177 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryBundleManifest.h"
#include "Poco/AutoPtr.h"
#include "Poco/StringTokenizer.h"
#include "Poco/Util/PropertyFileConfiguration.h"
#include <iostream>
namespace berry {
BundleManifest::BundleManifest(std::istream* istr)
: POLICY_EAGER("eager"), POLICY_LAZY("lazy")
{
this->ParseManifest(istr);
}
BundleManifest::~BundleManifest()
{
}
bool BundleManifest::operator==(const Object* o) const
{
if (const IBundleManifest* manifest = dynamic_cast<const IBundleManifest*>(o))
return this->GetSymbolicName() == manifest->GetSymbolicName();
return false;
}
const std::string&
BundleManifest::GetActivatorClass() const
{
return m_Activator;
}
const std::string&
BundleManifest::GetActivatorLibrary() const
{
return m_ActivatorLibrary;
}
const std::string&
BundleManifest::GetCopyright() const
{
return m_Copyright;
}
IBundleManifest::ActivationPolicy
BundleManifest::GetActivationPolicy() const
{
return m_ActivationPolicy;
}
bool
BundleManifest::IsSystemBundle() const
{
return m_SystemBundle;
}
const std::string&
BundleManifest::GetName() const
{
return m_Name;
}
const BundleManifest::Dependencies&
BundleManifest::GetRequiredBundles() const
{
return m_Dependencies;
}
const std::string&
BundleManifest::GetSymbolicName() const
{
return m_SymbolicName;
}
const std::string&
BundleManifest::GetVendor() const
{
return m_Vendor;
}
//const Version& GetVersion() const;
void
BundleManifest::ParseActivator(const std::string& activator)
{
Poco::StringTokenizer tokenizer(activator, ";",
Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM);
if (tokenizer.count() == 0)
{
m_Activator = "";
m_ActivatorLibrary = "";
return;
}
m_Activator = tokenizer[0];
m_Activator = activator;
m_ActivatorLibrary = "";
if (tokenizer.count() > 1)
{
Poco::StringTokenizer tokenizer2(tokenizer[1], "=",
Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM);
if (tokenizer2.count() == 2 && tokenizer2[0] == "library")
{
m_ActivatorLibrary = tokenizer[1];
}
}
}
void
BundleManifest::ParseManifest(std::istream* istr)
{
//BERRY_INFO << "Start parsing manifest\n";
Poco::AutoPtr<Poco::Util::PropertyFileConfiguration> config(new Poco::Util::PropertyFileConfiguration(*istr));
if (config->hasProperty(BUNDLE_ACTIVATOR))
this->ParseActivator(config->getString(BUNDLE_ACTIVATOR));
else
{
m_Activator = "";
m_ActivatorLibrary = "";
}
m_Copyright = config->getString(BUNDLE_COPYRIGHT, "");
m_ActivationPolicy = (config->getString(BUNDLE_ACTIVATION_POLICY, POLICY_LAZY) == POLICY_EAGER) ? EAGER : LAZY ;
m_Name = config->getString(BUNDLE_NAME, "");
m_SymbolicName = config->getString(BUNDLE_SYMBOLICNAME, "");
m_Vendor = config->getString(BUNDLE_VENDOR, "");
m_ManifestVersion = config->getString(MANIFEST_VERSION, "1.0");
m_SystemBundle = config->getBool(SYSTEM_BUNDLE, false);
if (config->hasProperty(REQUIRE_BUNDLE))
this->ParseRequiredBundles(config->getString(REQUIRE_BUNDLE));
}
void
BundleManifest::ParseRequiredBundles(const std::string& requiredBundles)
{
Poco::StringTokenizer tokenizer(requiredBundles, ",",
Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM);
Poco::StringTokenizer::Iterator iter;
for (iter = tokenizer.begin(); iter != tokenizer.end(); iter++)
{
Poco::StringTokenizer tokenizer2(*iter, ";",
Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM);
Dependency dep;
dep.symbolicName = tokenizer2[0];
m_Dependencies.push_back(dep);
}
}
} // namespace berry
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryBundleManifest.h b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryBundleManifest.h
index 6b64ef6874..1dab6b7f21 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryBundleManifest.h
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryBundleManifest.h
@@ -1,74 +1,74 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYBUNDLEMANIFEST_H_
#define BERRYBUNDLEMANIFEST_H_
#include "berryIBundleManifest.h"
namespace berry {
class BundleManifest : public IBundleManifest
{
public:
berryObjectMacro(BundleManifest);
BundleManifest(std::istream* istr);
~BundleManifest();
const std::string& GetActivatorClass() const;
const std::string& GetActivatorLibrary() const;
const std::string& GetCopyright() const;
ActivationPolicy GetActivationPolicy() const;
bool IsSystemBundle() const;
const std::string& GetName() const;
const IBundleManifest::Dependencies& GetRequiredBundles() const;
const std::string& GetSymbolicName() const;
const std::string& GetVendor() const;
//const Version& GetVersion() const;
bool operator==(const Object* o) const;
private:
const std::string POLICY_EAGER;
const std::string POLICY_LAZY;
void ParseActivator(const std::string& activator);
void ParseManifest(std::istream* istr);
void ParseRequiredBundles(const std::string& requiredBundles);
IBundleManifest::Dependencies m_Dependencies;
std::string m_ActivatorLibrary;
std::string m_Activator;
std::string m_Copyright;
ActivationPolicy m_ActivationPolicy;
std::string m_Name;
std::string m_SymbolicName;
std::string m_Vendor;
std::string m_Version;
std::string m_ManifestVersion;
bool m_SystemBundle;
std::string m_RequireBundle;
};
} // namespace berry
#endif /*BERRYBUNDLEMANIFEST_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryCTKPluginActivator.cpp b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryCTKPluginActivator.cpp
index 279553aa2e..e447e33c33 100755
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryCTKPluginActivator.cpp
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryCTKPluginActivator.cpp
@@ -1,65 +1,65 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryCTKPluginActivator.h"
#include "berrySystemBundle.h"
#include "berryInternalPlatform.h"
#include <ctkPluginFrameworkLauncher.h>
#include <QCoreApplication>
#include <QtPlugin>
#include <QDebug>
namespace berry {
ctkPluginContext* org_blueberry_osgi_Activator::context = 0;
void org_blueberry_osgi_Activator::start(ctkPluginContext* context)
{
this->context = context;
SystemBundle::Pointer systemBundle = InternalPlatform::GetInstance()->GetBundle("system.bundle").Cast<SystemBundle>();
ExtensionPointService::Pointer service(new ExtensionPointService(&systemBundle->GetBundleLoader()));
// register the service in the legacy BlueBerry service registry
Platform::GetServiceRegistry().RegisterService(IExtensionPointService::SERVICE_ID, service);
// register the service in the CTK service registry
context->registerService<IExtensionPointService>(service.GetPointer());
}
void org_blueberry_osgi_Activator::stop(ctkPluginContext* context)
{
Q_UNUSED(context)
Platform::GetServiceRegistry().UnRegisterService(IExtensionPointService::SERVICE_ID);
this->context = 0;
// TODO stop framework
}
ctkPluginContext* org_blueberry_osgi_Activator::getPluginContext()
{
return context;
}
}
Q_EXPORT_PLUGIN2(org_blueberry_osgi, berry::org_blueberry_osgi_Activator)
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryCTKPluginActivator.h b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryCTKPluginActivator.h
index a23ce9850f..cd0d05a77d 100755
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryCTKPluginActivator.h
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryCTKPluginActivator.h
@@ -1,51 +1,51 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYCTKPLUGINACTIVATOR_H
#define BERRYCTKPLUGINACTIVATOR_H
#include <ctkPluginActivator.h>
#include <QObject>
#include <org_blueberry_osgi_Export.h>
namespace berry {
// We need to export this activator, because it is referenced
// in the templated method berry::ServiceRegistry::GetServiceById<>(...)
class BERRY_OSGI org_blueberry_osgi_Activator : public QObject, public ctkPluginActivator
{
Q_OBJECT
Q_INTERFACES(ctkPluginActivator)
public:
void start(ctkPluginContext* context);
void stop(ctkPluginContext* context);
static ctkPluginContext* getPluginContext();
private:
static ctkPluginContext* context;
};
typedef org_blueberry_osgi_Activator CTKPluginActivator;
}
#endif // BERRYCTKPLUGINACTIVATOR_H
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryCodeCache.cpp b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryCodeCache.cpp
index 1f7e60e344..41935aed21 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryCodeCache.cpp
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryCodeCache.cpp
@@ -1,137 +1,137 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryLog.h"
#include "berryCodeCache.h"
#include "berryInternalPlatform.h"
#include "Poco/Path.h"
#include "Poco/SharedLibrary.h"
#include <fstream>
#include <iostream>
#include <algorithm>
namespace berry {
CodeCache::CodeCache(const std::string& path) : m_CachePath(path)
{
BERRY_INFO(InternalPlatform::GetInstance()->ConsoleLog()) << "Creating CodeCache with path: " << path << std::endl;
if (!m_CachePath.exists())
{
m_CachePath.createDirectories();
}
}
CodeCache::~CodeCache()
{
}
void
CodeCache::Clear()
{
if (m_CachePath.exists())
{
BERRY_INFO(InternalPlatform::GetInstance()->ConsoleLog()) << "Clearing code cache\n";
std::vector<Poco::File> files;
m_CachePath.list(files);
for (std::vector<Poco::File>::iterator iter = files.begin(); iter != files.end(); ++iter)
{
iter->remove(true);
}
}
}
bool
CodeCache::HasLibrary(const std::string& name)
{
//BERRY_INFO << "HasLibrary checks for: " << name;
std::vector<std::string> files;
m_CachePath.list(files);
std::string libName(name);
//libName.append(Poco::SharedLibrary::suffix());
std::vector<std::string>::iterator iter;
for (iter = files.begin(); iter != files.end(); iter++)
{
if ((*iter) == libName) {
//BERRY_INFO << " FOUND\n";
return true;
}
}
//BERRY_INFO << " NOT FOUND\n";
return false;
}
void
CodeCache::InstallLibrary(const std::string& name, std::istream& istr)
{
//BERRY_INFO << "Installing library " << name << " to " << this->GetPathForLibrary(name).toString() << std::endl;
std::ofstream ostr(this->GetPathForLibrary(name).toString().c_str(), std::ios::binary | std::ios::trunc);
ostr << istr.rdbuf();
}
void
CodeCache::InstallLibrary(const std::string& name, const Poco::File& path)
{
//BERRY_INFO << "Registering library " << name << " in " << path.path() << std::endl;
m_LibPaths.insert(std::make_pair(name, path));
}
void
CodeCache::UnInstallLibrary(const std::string& name)
{
std::map<std::string, Poco::File>::iterator iter = m_LibPaths.find(name);
if (iter == m_LibPaths.end())
{
Poco::File(this->GetPathForLibrary(name)).remove();
}
else
{
m_LibPaths.erase(name);
}
}
Poco::Path
CodeCache::GetPathForLibrary(const std::string& name)
{
// We instructed cmake to replace "." with "_" in library names
// since they are also used for defines (for Windows dll import/export
// stuff) and . is bad in identifiers.
// Hence we must replace all "." with "_" here too
std::string libName(name);
std::replace(libName.begin(), libName.end(), '.', '_');
//BERRY_INFO << "Getting path for library: " << libName << std::endl;
if (m_LibPaths.find(libName) != m_LibPaths.end())
{
return Poco::Path(m_LibPaths[libName].path(), libName + Poco::SharedLibrary::suffix());
}
else
{
return Poco::Path(m_CachePath.path(), libName + Poco::SharedLibrary::suffix());
}
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryCodeCache.h b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryCodeCache.h
index eee950ca8c..1de4b67ac9 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryCodeCache.h
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryCodeCache.h
@@ -1,83 +1,83 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYCODECACHE_H_
#define BERRYCODECACHE_H_
#include <string>
#include <iostream>
#include <map>
#include "Poco/File.h"
#include "Poco/Path.h"
namespace berry {
class CodeCache
{
public:
CodeCache(const std::string& path);
virtual ~CodeCache();
void Clear();
/**
* Checks if the library with name name is installed
*
* @param name The name of the library without the library suffix
* @return true if the library is installed, false otherwise
*/
bool HasLibrary(const std::string& name);
/**
* Installs a library in the plugin cache directory under the name name.
* This is used to copy libraries from Zip files, network locations etc.
* into the local cache directory.
*
* @param name The name of the library without the library suffix
* @param istr The binary input stream representing the library to be installed
*/
void InstallLibrary(const std::string& name, std::istream& istr);
/**
* Installs the library name. The method only registers a library under the
* name name in the path path (no files or copied).
*
* @param name The name of the library without the library suffix
* @param path The path to the library
*/
void InstallLibrary(const std::string& name, const Poco::File& path);
/**
* If the library with name name has been copied into the local
* cache directory, it will be deleted. Otherwise, the library will become
* unknown to the CodeCache.
*
* @param name The name of the library without the library suffix
*/
void UnInstallLibrary(const std::string& name);
Poco::Path GetPathForLibrary(const std::string& name);
private:
Poco::File m_CachePath;
std::map<std::string, Poco::File> m_LibPaths;
};
}
#endif /*BERRYCODECACHE_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryConfigurationElement.cpp b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryConfigurationElement.cpp
index 034a67e4dc..b90e63fd98 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryConfigurationElement.cpp
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryConfigurationElement.cpp
@@ -1,147 +1,147 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryConfigurationElement.h"
#include "berryExtension.h"
#include "berryBundleLoader.h"
#include <Poco/DOM/NamedNodeMap.h>
#include <Poco/DOM/NodeList.h>
#include <Poco/String.h>
namespace berry {
ConfigurationElement::ConfigurationElement(BundleLoader* loader, Poco::XML::Node* config,
std::string contributor, Extension::Pointer extension,
const ConfigurationElement* parent)
: m_ConfigurationNode(config), m_Parent(parent), m_Extension(extension)
{
IConfigurationElement::m_ClassLoader = loader;
IConfigurationElement::m_Contributor = contributor;
}
bool
ConfigurationElement::GetAttribute(const std::string& name, std::string& value) const
{
if (m_ConfigurationNode->hasAttributes())
{
Poco::XML::NamedNodeMap* attributes = m_ConfigurationNode->attributes();
Poco::XML::Node* attr = attributes->getNamedItem(name);
if (attr == 0) return false;
value = attr->nodeValue();
attributes->release();
return true;
}
return false;
}
bool
ConfigurationElement::GetBoolAttribute(const std::string& name, bool& value) const
{
std::string val;
if (this->GetAttribute(name, val))
{
Poco::toUpperInPlace(val);
if (val == "1" || val == "TRUE")
value = true;
else
value = false;
return true;
}
return false;
}
const std::vector<IConfigurationElement::Pointer>
ConfigurationElement
::GetChildren() const
{
std::vector<IConfigurationElement::Pointer> children;
if (m_ConfigurationNode->hasChildNodes())
{
Poco::XML::NodeList* ch = m_ConfigurationNode->childNodes();
for (unsigned long i = 0; i < ch->length(); ++i)
{
IConfigurationElement::Pointer xelem(new ConfigurationElement(IConfigurationElement::m_ClassLoader, ch->item(i), m_Contributor, m_Extension, this));
children.push_back(xelem);
}
ch->release();
}
return children;
}
const std::vector<IConfigurationElement::Pointer>
ConfigurationElement
::GetChildren(const std::string& name) const
{
std::vector<IConfigurationElement::Pointer> children;
if (m_ConfigurationNode->hasChildNodes())
{
Poco::XML::NodeList* ch = m_ConfigurationNode->childNodes();
for (unsigned long i = 0; i < ch->length(); ++i)
{
if (ch->item(i)->nodeName() == name)
{
IConfigurationElement::Pointer xelem(new ConfigurationElement(IConfigurationElement::m_ClassLoader, ch->item(i), m_Contributor, m_Extension, this));
children.push_back(xelem);
}
}
ch->release();
}
return children;
}
std::string
ConfigurationElement::GetValue() const
{
return m_ConfigurationNode->nodeValue();
}
std::string
ConfigurationElement::GetName() const
{
return m_ConfigurationNode->nodeName();
}
const IConfigurationElement*
ConfigurationElement::GetParent() const
{
return m_Parent;
}
const std::string&
ConfigurationElement::GetContributor() const
{
return m_Contributor;
}
const IExtension*
ConfigurationElement::GetDeclaringExtension() const
{
return m_Extension.GetPointer();
}
ConfigurationElement::~ConfigurationElement()
{
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryConfigurationElement.h b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryConfigurationElement.h
index b4e8dd0534..086b9ac356 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryConfigurationElement.h
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryConfigurationElement.h
@@ -1,71 +1,71 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYEXTENSIONELEMENT_H_
#define BERRYEXTENSIONELEMENT_H_
#include "berryMacros.h"
#include "berryBundleLoader.h"
#include "Poco/DOM/Node.h"
#include "service/berryIConfigurationElement.h"
namespace berry {
class Extension;
class ConfigurationElement : public IConfigurationElement
{
public:
berryObjectMacro(ConfigurationElement);
ConfigurationElement(BundleLoader* loader, Poco::XML::Node* config,
std::string contributor, SmartPointer<Extension> extension,
const ConfigurationElement* parent = 0);
bool GetAttribute(const std::string& name, std::string& value) const;
bool GetBoolAttribute(const std::string& name, bool& value) const;
const std::vector<IConfigurationElement::Pointer> GetChildren() const;
const std::vector<IConfigurationElement::Pointer> GetChildren(const std::string& name) const;
std::string GetValue() const;
std::string GetName() const;
const IConfigurationElement* GetParent() const;
const std::string& GetContributor() const;
const IExtension* GetDeclaringExtension() const;
~ConfigurationElement();
private:
Poco::XML::Node* m_ConfigurationNode;
const ConfigurationElement* m_Parent;
SmartPointer<Extension> m_Extension;
};
} // namespace berry
#endif /*BERRYEXTENSIONELEMENT_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryDefaultActivator.cpp b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryDefaultActivator.cpp
index 467bc9e5e2..d0ec6f7939 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryDefaultActivator.cpp
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryDefaultActivator.cpp
@@ -1,33 +1,33 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryDefaultActivator.h"
namespace berry {
void
DefaultActivator::Start(IBundleContext::Pointer /*context*/)
{
}
void
DefaultActivator::Stop(IBundleContext::Pointer /*context*/)
{
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryDefaultActivator.h b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryDefaultActivator.h
index df60ae14b7..54e3520209 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryDefaultActivator.h
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryDefaultActivator.h
@@ -1,33 +1,33 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYDEFAULTACTIVATOR_H_
#define BERRYDEFAULTACTIVATOR_H_
#include "berryIBundleActivator.h"
#include "berryIBundleContext.h"
namespace berry {
class DefaultActivator : public IBundleActivator
{
void Start(IBundleContext::Pointer context);
void Stop(IBundleContext::Pointer context);
};
}
#endif /*BERRYDEFAULTACTIVATOR_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryExtension.cpp b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryExtension.cpp
index bf001a0890..295a1a5296 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryExtension.cpp
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryExtension.cpp
@@ -1,91 +1,91 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryExtension.h"
namespace berry
{
Extension::Extension(const std::string& ns)
: namespaze(ns)
{
}
bool Extension::operator==(const Object* em) const
{
if (const Extension* other = dynamic_cast<const Extension*>(em))
return (id == other->id) && (extensionPoint == other->extensionPoint);
return false;
}
std::string Extension::GetNamespace() const
{
return namespaze;
}
std::string Extension::GetExtensionPointIdentifier() const
{
return extensionPoint;
}
std::string Extension::GetSimpleIdentifier() const
{
return id;
}
std::string Extension::GetUniqueIdentifier() const
{
return id == "" ? "" : this->GetNamespace() + "." + id; //$NON-NLS-1$
}
const std::vector<IConfigurationElement::Pointer> Extension::GetConfigurationElements() const
{
return elements;
}
std::string Extension::GetLabel() const
{
return label;
}
void Extension::SetExtensionPointIdentifier(const std::string& value)
{
extensionPoint = value;
}
void Extension::SetSimpleIdentifier(const std::string& value)
{
id = value;
}
void Extension::SetSubElements(const std::vector<IConfigurationElement::Pointer>& value)
{
elements = value;
}
void Extension::SetLabel(const std::string& l)
{
label = l;
}
bool Extension::operator<(const IExtension* e2) const
{
return this->GetNamespace() < e2->GetNamespace();
}
} // namespace berry
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryExtension.h b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryExtension.h
index 7144d69bba..dca036db21 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryExtension.h
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryExtension.h
@@ -1,123 +1,123 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYEXTENSION_H_
#define BERRYEXTENSION_H_
#include "service/berryIExtension.h"
#include "berryConfigurationElement.h"
namespace berry {
/**
* An object which represents the user-defined extension in a
* plug-in manifest.
* <p>
* This class may be instantiated, or further subclassed.
* </p>
*/
class Extension : public IExtension, public Object {
private:
// DTD properties (included in plug-in manifest)
std::string extensionPoint;
std::string id;
std::string label;
std::string namespaze;
std::vector<IConfigurationElement::Pointer> elements;
public:
berryObjectMacro(Extension);
Extension(const std::string& namespaze);
/**
* Two Extensions are equal if they have the same Id
* and target the same extension point.
*/
bool operator==(const Object* em) const;
/**
* Returns the extension point with which this extension is associated.
*
* @return the extension point with which this extension is associated
* or <code>null</code>
*/
std::string GetExtensionPointIdentifier() const;
std::string GetNamespace() const;
/**
* Returns the simple identifier of this extension, or <code>null</code>
* if this extension does not have an identifier.
* This identifier is specified in the plug-in manifest as a non-empty
* string containing no period characters (<code>'.'</code>) and
* must be unique within the defining plug-in.
*
* @return the simple identifier of the extension (e.g. <code>"main"</code>)
* or <code>null</code>
*/
std::string GetSimpleIdentifier() const;
std::string GetUniqueIdentifier() const;
const std::vector<IConfigurationElement::Pointer> GetConfigurationElements() const;
std::string GetLabel() const;
/**
* Set the extension point with which this extension is associated.
* This object must not be read-only.
*
* @return the extension point with which this extension is associated.
* May be <code>null</code>.
*/
void SetExtensionPointIdentifier(const std::string& value);
/**
* Sets the simple identifier of this extension, or <code>null</code>
* if this extension does not have an identifier.
* This identifier is specified in the plug-in manifest as a non-empty
* string containing no period characters (<code>'.'</code>) and
* must be unique within the defining plug-in.
* This object must not be read-only.
*
* @param value the simple identifier of the extension (e.g. <code>"main"</code>).
* May be <code>null</code>.
*/
void SetSimpleIdentifier(const std::string& value);
/**
* Sets the configuration element children of this extension.
*
* @param value the configuration elements in this extension.
* May be <code>null</code>.
*/
void SetSubElements(const std::vector<IConfigurationElement::Pointer>& value);
void SetLabel(const std::string& l);
bool operator<(const IExtension* e2) const;
};
}
#endif /*BERRYEXTENSION_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryExtensionPoint.cpp b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryExtensionPoint.cpp
index a2aab2c797..e8c9c0716e 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryExtensionPoint.cpp
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryExtensionPoint.cpp
@@ -1,138 +1,138 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryExtensionPoint.h"
#include "service/berryIConfigurationElement.h"
#include "berryPlatformException.h"
namespace berry {
ExtensionPoint::ExtensionPoint(const std::string& contributor)
: m_Contributor(contributor), m_Label(""), m_SimpleId("")
{
m_UniqueId = contributor + "." + m_SimpleId;
}
std::string
ExtensionPoint::GetContributor() const
{
return m_Contributor;
}
const std::vector<IConfigurationElement::Pointer> ExtensionPoint::GetConfigurationElements() const
{
std::vector<IConfigurationElement::Pointer> result;
const std::vector<const IExtension*> extensions = this->GetExtensions();
for (std::vector<const IExtension*>::const_iterator itr = extensions.begin();
itr != extensions.end(); ++itr)
{
const std::vector<IConfigurationElement::Pointer> configs = (*itr)->GetConfigurationElements();
result.insert(result.end(), configs.begin(), configs.end());
}
return result;
}
const IExtension*
ExtensionPoint::GetExtension(const std::string& extensionId) const
{
std::map<std::string, Extension::Pointer>::const_iterator iter = m_Extensions.find(extensionId);
if (iter == m_Extensions.end())
return 0;
return iter->second.GetPointer();
}
const std::vector<const IExtension*>
ExtensionPoint::GetExtensions() const
{
std::vector<const IExtension*> extensions;
for (std::map<std::string, Extension::Pointer>::const_iterator iter = m_Extensions.begin();
iter != m_Extensions.end(); ++iter)
{
extensions.push_back(iter->second.GetPointer());
}
for (std::vector<Extension::Pointer>::const_iterator iter = m_UnnamedExtensions.begin();
iter != m_UnnamedExtensions.end(); ++iter)
{
extensions.push_back(iter->GetPointer());
}
//extensions.insert(extensions.end(), m_UnnamedExtensions.begin(), m_UnnamedExtensions.end());
return extensions;
}
std::string
ExtensionPoint::GetLabel() const
{
return m_Label;
}
std::string
ExtensionPoint::GetSimpleIdentifier() const
{
return m_SimpleId;
}
std::string
ExtensionPoint::GetUniqueIdentifier() const
{
return m_UniqueId;
}
void
ExtensionPoint::SetLabel(const std::string& label)
{
m_Label = label;
}
void
ExtensionPoint::SetSimpleId(const std::string& id)
{
m_SimpleId = id;
}
void
ExtensionPoint::SetParentId(const std::string& id)
{
m_UniqueId = id + "." + m_SimpleId;
}
void
ExtensionPoint::AddExtension(Extension::Pointer extension)
{
if (extension->GetUniqueIdentifier() == "")
{
m_UnnamedExtensions.push_back(extension);
return;
}
if (m_Extensions.find(extension->GetUniqueIdentifier()) != m_Extensions.end())
{
throw PlatformException("Duplicate extension id \"" + extension->GetUniqueIdentifier()
+ "\" found for extension point \"" + this->GetUniqueIdentifier() + "\" from plugin \""
+ this->GetContributor() + "\"");
}
m_Extensions[extension->GetUniqueIdentifier()] = extension;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryExtensionPoint.h b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryExtensionPoint.h
index 5f639548a1..92c9e513c9 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryExtensionPoint.h
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryExtensionPoint.h
@@ -1,72 +1,72 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYEXTENSIONPOINT_H_
#define BERRYEXTENSIONPOINT_H_
#include "berryMacros.h"
#include "service/berryIExtensionPoint.h"
#include "service/berryIExtension.h"
#include "berryExtension.h"
#include <map>
namespace berry {
struct IConfigurationElement;
class ExtensionPoint : public IExtensionPoint, public Object
{
public:
berryObjectMacro(ExtensionPoint);
ExtensionPoint(const std::string& contributor);
std::string GetContributor() const;
const std::vector<IConfigurationElement::Pointer > GetConfigurationElements() const;
const IExtension* GetExtension(const std::string& extensionId) const;
const std::vector<const IExtension*> GetExtensions() const;
std::string GetLabel() const;
std::string GetSimpleIdentifier() const;
std::string GetUniqueIdentifier() const;
void AddExtension(Extension::Pointer extension);
void SetLabel(const std::string& label);
void SetSimpleId(const std::string& id);
void SetParentId(const std::string& id);
private:
std::string m_Contributor;
std::string m_Label;
std::string m_SimpleId;
std::string m_UniqueId;
std::map<std::string, Extension::Pointer> m_Extensions;
std::vector<Extension::Pointer> m_UnnamedExtensions;
};
}
#endif /*BERRYEXTENSIONPOINT_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryExtensionPointService.cpp b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryExtensionPointService.cpp
index 0b5238dcd2..c83e060f8c 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryExtensionPointService.cpp
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryExtensionPointService.cpp
@@ -1,258 +1,258 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryLog.h"
#include "berryExtensionPointService.h"
#include "berryConfigurationElement.h"
#include "berryExtensionPoint.h"
#include "berryInternalPlatform.h"
#include "Poco/Exception.h"
#include "berryBundle.h"
#include "Poco/StringTokenizer.h"
#include "Poco/DOM/Document.h"
#include "Poco/DOM/Node.h"
#include "Poco/DOM/Element.h"
#include "Poco/DOM/NodeList.h"
#include "Poco/DOM/NamedNodeMap.h"
#include <iostream>
namespace berry {
bool
ExtensionPointService::IsA(const std::type_info& type)
{
std::string name(GetType().name());
return name == type.name() || Service::IsA(type);
}
const std::type_info&
ExtensionPointService::GetType() const
{
return typeid(IExtensionPointService);
}
ExtensionPointService::ExtensionPointService(BundleLoader* loader)
: m_BundleLoader(loader), m_ConsoleLog(false)
{
m_ConsoleLog = InternalPlatform::GetInstance()->ConsoleLog();
}
void
ExtensionPointService::AddContribution(std::istream& istr,
const std::string& contributor)
{
m_XMLInputSource.setByteStream(istr);
try
{
Poco::XML::Document* document = m_DOMParser.parse(&m_XMLInputSource);
Poco::XML::NodeList* nodes = document->getElementsByTagName("extension-point");
for (unsigned long i = 0; i < nodes->length(); ++i)
{
Poco::XML::NamedNodeMap* attributes = nodes->item(i)->attributes();
Poco::XML::Node* attr = attributes->getNamedItem("id");
std::string simpleId = attr->nodeValue();
attr = attributes->getNamedItem("name");
std::string label = "";
if (attr != 0) label = attr->nodeValue();
ExtensionPoint::Pointer xp(new ExtensionPoint(contributor));
xp->SetLabel(label);
Poco::StringTokenizer tokenizer(simpleId, ".");
if (tokenizer.count() == 1)
{
xp->SetSimpleId(simpleId);
xp->SetParentId(contributor);
}
else
{
std::string parentId = "";
for (std::size_t i = 0; i < tokenizer.count()-1; ++i)
{
if (i > 0) parentId += ".";
parentId += tokenizer[i];
}
xp->SetSimpleId(tokenizer[tokenizer.count()-1]);
xp->SetParentId(parentId);
}
m_ExtensionPointMap[xp->GetUniqueIdentifier()] = xp;
BERRY_INFO(m_ConsoleLog) << "Extension-Point found: " << xp->GetUniqueIdentifier() << " (from " << xp->GetContributor() << ")\n";
attributes->release();
}
nodes->release();
nodes = document->getElementsByTagName("extension");
for (unsigned long i = 0; i < nodes->length(); ++i)
{
Poco::XML::NamedNodeMap* attributes = nodes->item(i)->attributes();
Poco::XML::Node* attr = attributes->getNamedItem("point");
if (attr == 0) continue;
std::string xp = attr->nodeValue();
BERRY_INFO(m_ConsoleLog) << "Extension found for extension-point: " << xp << " (from " << contributor << ")\n";
if (m_ExtensionPointMap[xp].IsNull())
{
BERRY_INFO(m_ConsoleLog) << "Extension-point unknown, extension skipped.\n";
continue;
}
Extension::Pointer extension(new Extension(contributor));
extension->SetExtensionPointIdentifier(xp);
attr = attributes->getNamedItem("id");
if (attr)
extension->SetSimpleIdentifier(attr->nodeValue());
std::vector<IConfigurationElement::Pointer> children;
if (nodes->item(i)->hasChildNodes())
{
Poco::XML::NodeList* ch = nodes->item(i)->childNodes();
for (unsigned long childIndex = 0; childIndex < ch->length(); ++childIndex)
{
Poco::XML::Node* child = ch->item(childIndex);
if (dynamic_cast<Poco::XML::Element*>(child) == 0) continue;
IConfigurationElement::Pointer elem(
new ConfigurationElement(m_BundleLoader,
child,
contributor, extension, 0));
children.push_back(elem);
}
ch->release();
}
extension->SetSubElements(children);
m_ExtensionPointMap[xp]->AddExtension(extension);
attributes->release();
}
//nodes->release();
m_Contributors.insert(contributor);
}
catch(Poco::Exception* exc)
{
BERRY_ERROR << exc->displayText() << std::endl;
}
catch(...)
{
BERRY_ERROR << "Exception while parsing plugin.xml from " << contributor << std::endl;
}
}
bool
ExtensionPointService::HasContributionFrom(const std::string& name) const
{
return m_Contributors.find(name) != m_Contributors.end();
}
const std::vector<IConfigurationElement::Pointer>
ExtensionPointService::GetConfigurationElementsFor(const std::string& extensionPointId) const
{
BERRY_INFO(m_ConsoleLog) << "Getting configuration elements for point: " << extensionPointId << std::endl;
std::vector<IConfigurationElement::Pointer> configs;
const IExtensionPoint* xp = this->GetExtensionPoint(extensionPointId);
if (xp != 0)
{
std::vector<const IExtension*> extensions(xp->GetExtensions());
for (std::vector<const IExtension*>::const_iterator extension = extensions.begin();
extension != extensions.end(); ++extension)
{
std::vector<IConfigurationElement::Pointer> c((*extension)->GetConfigurationElements());
configs.insert(configs.end(), c.begin(), c.end());
}
}
return configs;
}
const IExtensionPoint*
ExtensionPointService::GetExtensionPoint(const std::string& id) const
{
ExtensionPointMap::const_iterator iter;
iter = m_ExtensionPointMap.find(id);
if (iter != m_ExtensionPointMap.end()) return iter->second.GetPointer();
return 0;
}
const IExtension*
ExtensionPointService::GetExtension(const std::string& extensionPointId, const std::string& extensionId) const
{
const IExtensionPoint* xp = this->GetExtensionPoint(extensionPointId);
if (xp != 0)
{
return xp->GetExtension(extensionId);
}
return 0;
}
const std::vector<const IExtension*>
ExtensionPointService::GetExtensions(const std::string& contributor) const
{
std::vector<const IExtension*> extensions;
for (std::map<std::string,ExtensionPoint::Pointer>::const_iterator iter = m_ExtensionPointMap.begin();
iter != m_ExtensionPointMap.end(); ++iter)
{
const std::vector<const IExtension*> ext(iter->second->GetExtensions());
for (std::vector<const IExtension*>::const_iterator extension = ext.begin();
extension != ext.end(); ++extension)
{
if ((*extension)->GetNamespace() == contributor)
extensions.push_back(*extension);
}
}
return extensions;
}
const std::vector<const IExtensionPoint*>
ExtensionPointService::GetExtensionPoints() const
{
std::vector<const IExtensionPoint*> xps;
for (std::map<std::string,ExtensionPoint::Pointer>::const_iterator iter = m_ExtensionPointMap.begin();
iter != m_ExtensionPointMap.end(); ++iter)
{
xps.push_back(iter->second.GetPointer());
}
return xps;
}
const std::vector<const IExtensionPoint*>
ExtensionPointService::GetExtensionPoints(const std::string& contributor) const
{
std::vector<const IExtensionPoint*> xps;
for (std::map<std::string,ExtensionPoint::Pointer>::const_iterator iter = m_ExtensionPointMap.begin();
iter != m_ExtensionPointMap.end(); ++iter)
{
if (iter->second->GetContributor() == contributor)
xps.push_back(iter->second.GetPointer());
}
return xps;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryExtensionPointService.h b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryExtensionPointService.h
index e389860036..3478879762 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryExtensionPointService.h
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryExtensionPointService.h
@@ -1,82 +1,82 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYEXTENSIONPOINTSERVICE_H_
#define BERRYEXTENSIONPOINTSERVICE_H_
#include "berryMacros.h"
#include "Poco/SAX/InputSource.h"
#include "Poco/DOM/DOMParser.h"
#include "service/berryIConfigurationElement.h"
#include "berryExtensionPoint.h"
#include "service/berryIExtensionPointService.h"
#include <set>
#include <QObject>
namespace berry {
class Bundle;
class BundleLoader;
class ExtensionPointService : public QObject, public IExtensionPointService
{
Q_OBJECT
Q_INTERFACES(berry::IExtensionPointService)
public:
berryObjectMacro(ExtensionPointService);
bool IsA(const std::type_info& type);
const std::type_info& GetType() const;
ExtensionPointService(BundleLoader* loader);
void AddContribution(std::istream& istr, const std::string& contributor);
const std::vector<IConfigurationElement::Pointer> GetConfigurationElementsFor(const std::string& extensionPointId) const;
const IExtension* GetExtension(const std::string& extensionPointId, const std::string& extensionId) const;
const IExtensionPoint* GetExtensionPoint(const std::string& id) const;
const std::vector<const IExtension*> GetExtensions(const std::string& contributor) const;
const std::vector<const IExtensionPoint*> GetExtensionPoints() const;
const std::vector<const IExtensionPoint*> GetExtensionPoints(const std::string& contributor) const;
bool HasContributionFrom(const std::string& name) const;
private:
typedef std::map<std::string, ExtensionPoint::Pointer > ExtensionPointMap;
std::set<std::string> m_Contributors;
BundleLoader* m_BundleLoader;
ExtensionPointMap m_ExtensionPointMap;
Poco::XML::DOMParser m_DOMParser;
Poco::XML::InputSource m_XMLInputSource;
bool m_ConsoleLog;
};
} // namespace berry
#endif /*BERRYEXTENSIONPOINTSERVICE_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryInternalPlatform.cpp b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryInternalPlatform.cpp
index 9df9abb537..294a1b75ce 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryInternalPlatform.cpp
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryInternalPlatform.cpp
@@ -1,602 +1,602 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryInternalPlatform.h"
#include "berryLog.h"
#include <Poco/Exception.h>
#include <Poco/File.h>
#include <Poco/FileStream.h>
#include <Poco/AutoPtr.h>
#include <Poco/Util/PropertyFileConfiguration.h>
#include <Poco/StringTokenizer.h>
#include <Poco/Util/HelpFormatter.h>
#include <Poco/Util/OptionException.h>
#include <ctkPluginFrameworkLauncher.h>
#include <ctkPluginFrameworkFactory.h>
#include <ctkPluginFramework.h>
#include <ctkPluginContext.h>
#include <ctkPlugin.h>
#include <ctkPluginException.h>
#include <iostream>
#include "berryPlatform.h"
#include "berryPlatformException.h"
#include "berryDebugUtil.h"
#include "event/berryPlatformEvents.h"
#include "berryPlatformLogChannel.h"
#include "berryIBundle.h"
#include "berryCodeCache.h"
#include "berryBundleLoader.h"
#include "berrySystemBundle.h"
#include "berryBundleDirectory.h"
#include "berryProvisioningInfo.h"
#include <QCoreApplication>
#include <QDesktopServices>
#include <QDebug>
namespace berry {
Poco::Mutex InternalPlatform::m_Mutex;
InternalPlatform::InternalPlatform() : m_Initialized(false), m_Running(false),
m_ConsoleLog(false), m_ServiceRegistry(0),
m_CodeCache(0), m_BundleLoader(0), m_SystemBundle(0), m_PlatformLogger(0),
m_ctkPluginFrameworkFactory(0),
m_EventStarted(PlatformEvent::EV_PLATFORM_STARTED)
{
}
InternalPlatform::~InternalPlatform()
{
}
InternalPlatform* InternalPlatform::GetInstance()
{
Poco::Mutex::ScopedLock lock(m_Mutex);
static InternalPlatform instance;
return &instance;
}
bool InternalPlatform::ConsoleLog() const
{
return m_ConsoleLog;
}
ctkPluginContext* InternalPlatform::GetCTKPluginFrameworkContext() const
{
if (m_ctkPluginFrameworkFactory)
{
return m_ctkPluginFrameworkFactory->getFramework()->getPluginContext();
}
return 0;
}
ServiceRegistry& InternalPlatform::GetServiceRegistry()
{
AssertInitialized();
return *m_ServiceRegistry;
}
void InternalPlatform::Initialize(int& argc, char** argv, Poco::Util::AbstractConfiguration* config)
{
// initialization
Poco::Mutex::ScopedLock lock(m_Mutex);
m_Argc = &argc;
m_Argv = argv;
try
{
this->init(argc, argv);
}
catch (const Poco::Util::UnknownOptionException& e)
{
BERRY_WARN << e.displayText();
}
this->loadConfiguration();
if (config)
{
this->config().add(config, 50, false);
}
m_ServiceRegistry = new ServiceRegistry();
m_ConsoleLog = this->GetConfiguration().hasProperty(Platform::ARG_CONSOLELOG);
m_ConfigPath.assign(this->GetConfiguration().getString("application.configDir"));
m_InstancePath.assign(this->GetConfiguration().getString("application.dir"));
try
{
m_InstallPath.assign(this->GetConfiguration().getString(Platform::ARG_HOME));
}
catch (Poco::NotFoundException& )
{
m_InstallPath.assign(m_InstancePath);
}
if (this->GetConfiguration().hasProperty(Platform::ARG_STORAGE_DIR))
{
std::string dataLocation = this->GetConfiguration().getString(Platform::ARG_STORAGE_DIR, "");
if (dataLocation.at(dataLocation.size()-1) != '/')
{
dataLocation += '/';
}
m_UserPath.assign(dataLocation);
}
else
{
// Append a hash value of the absolute path of the executable to the data location.
// This allows to start the same application from different build or install trees.
QString dataLocation = QDesktopServices::storageLocation(QDesktopServices::DataLocation) + '_';
dataLocation += QString::number(qHash(QCoreApplication::applicationDirPath())) + "/";
m_UserPath.assign(dataLocation.toStdString());
}
BERRY_INFO(m_ConsoleLog) << "Framework storage dir: " << m_UserPath.toString();
Poco::File userFile(m_UserPath);
try
{
userFile.createDirectories();
userFile.canWrite();
}
catch(const Poco::IOException& e)
{
BERRY_WARN << e.displayText();
m_UserPath.assign(Poco::Path::temp());
m_UserPath.pushDirectory("." + this->commandName());
userFile = m_UserPath;
}
// Initialize the CTK Plugin Framework
ctkProperties fwProps;
fwProps.insert(ctkPluginConstants::FRAMEWORK_STORAGE, QString::fromStdString(userFile.path()));
if (this->GetConfiguration().hasProperty(Platform::ARG_CLEAN))
{
fwProps.insert(ctkPluginConstants::FRAMEWORK_STORAGE_CLEAN, ctkPluginConstants::FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT);
}
if (this->GetConfiguration().hasProperty(Platform::ARG_CONSOLELOG))
{
fwProps.insert("org.commontk.pluginfw.debug.framework", true);
fwProps.insert("org.commontk.pluginfw.debug.errors", true);
fwProps.insert("org.commontk.pluginfw.debug.pluginfw", true);
fwProps.insert("org.commontk.pluginfw.debug.lazy_activation", true);
fwProps.insert("org.commontk.pluginfw.debug.resolve", true);
}
if (this->GetConfiguration().hasProperty(Platform::ARG_PRELOAD_LIBRARY))
{
QString preloadLibs = QString::fromStdString(this->GetConfiguration().getString(Platform::ARG_PRELOAD_LIBRARY));
fwProps.insert(ctkPluginConstants::FRAMEWORK_PRELOAD_LIBRARIES, preloadLibs.split(',', QString::SkipEmptyParts));
}
m_ctkPluginFrameworkFactory = new ctkPluginFrameworkFactory(fwProps);
QSharedPointer<ctkPluginFramework> pfw = m_ctkPluginFrameworkFactory->getFramework();
pfw->init();
ctkPluginContext* pfwContext = pfw->getPluginContext();
std::string provisioningFile = this->GetConfiguration().getString(Platform::ARG_PROVISIONING);
if (!provisioningFile.empty())
{
BERRY_INFO(m_ConsoleLog) << "Using provisioning file: " << provisioningFile;
ProvisioningInfo provInfo(QString::fromStdString(provisioningFile));
foreach(QString pluginPath, provInfo.getPluginDirs())
{
ctkPluginFrameworkLauncher::addSearchPath(pluginPath);
}
bool forcePluginOverwrite = this->GetConfiguration().hasOption(Platform::ARG_FORCE_PLUGIN_INSTALL);
QList<QUrl> pluginsToStart = provInfo.getPluginsToStart();
foreach(QUrl pluginUrl, provInfo.getPluginsToInstall())
{
if (forcePluginOverwrite)
{
uninstallPugin(pluginUrl, pfwContext);
}
try
{
BERRY_INFO(m_ConsoleLog) << "Installing CTK plug-in from: " << pluginUrl.toString().toStdString();
QSharedPointer<ctkPlugin> plugin = pfwContext->installPlugin(pluginUrl);
if (pluginsToStart.contains(pluginUrl))
{
m_CTKPluginsToStart << plugin->getPluginId();
}
}
catch (const ctkPluginException& e)
{
BERRY_ERROR << "Failed to install: " << pluginUrl.toString().toStdString() << ",\n" << e.what();
}
}
}
else
{
BERRY_INFO << "No provisioning file set.";
}
m_BaseStatePath = m_UserPath;
m_BaseStatePath.pushDirectory("bb-metadata");
m_BaseStatePath.pushDirectory("bb-plugins");
Poco::Path logPath(m_UserPath);
logPath.setFileName(this->commandName() + ".log");
m_PlatformLogChannel = new PlatformLogChannel(logPath.toString());
m_PlatformLogger = &Poco::Logger::create("PlatformLogger", m_PlatformLogChannel, Poco::Message::PRIO_TRACE);
try
{
m_CodeCache = new CodeCache(this->GetConfiguration().getString(Platform::ARG_PLUGIN_CACHE));
}
catch (Poco::NotFoundException&)
{
Poco::Path cachePath(m_UserPath);
cachePath.pushDirectory("bb-plugin_cache");
m_CodeCache = new CodeCache(cachePath.toString());
}
m_BundleLoader = new BundleLoader(m_CodeCache, *m_PlatformLogger);
// tell the BundleLoader about the installed CTK plug-ins
QStringList installedCTKPlugins;
foreach(QSharedPointer<ctkPlugin> plugin, pfwContext->getPlugins())
{
installedCTKPlugins << plugin->getSymbolicName();
}
m_BundleLoader->SetCTKPlugins(installedCTKPlugins);
m_Initialized = true;
// Clear the CodeCache
if (this->GetConfiguration().hasProperty(Platform::ARG_CLEAN))
m_CodeCache->Clear();
try
{
// assemble a list of base plugin-directories (which contain
// the real plugins as directories)
std::vector<std::string> pluginBaseDirs;
Poco::StringTokenizer tokenizer(this->GetConfiguration().getString(Platform::ARG_PLUGIN_DIRS, ""), ";",
Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM);
for (Poco::StringTokenizer::Iterator token = tokenizer.begin();
token != tokenizer.end(); ++token)
{
pluginBaseDirs.push_back(*token);
}
std::vector<Poco::Path> pluginPaths;
for (std::vector<std::string>::iterator pluginBaseDir = pluginBaseDirs.begin();
pluginBaseDir != pluginBaseDirs.end(); ++pluginBaseDir)
{
BERRY_INFO(m_ConsoleLog) << "Plugin base directory: " << *pluginBaseDir;
Poco::File pluginDir(*pluginBaseDir);
if (!pluginDir.exists() || !pluginDir.isDirectory())
{
BERRY_WARN(m_ConsoleLog) << *pluginBaseDir << " is not a direcotry or does not exist. SKIPPED.\n";
continue;
}
std::vector<std::string> pluginList;
pluginDir.list(pluginList);
std::vector<std::string>::iterator iter;
for (iter = pluginList.begin(); iter != pluginList.end(); iter++)
{
Poco::Path pluginPath = Poco::Path::forDirectory(*pluginBaseDir);
pluginPath.pushDirectory(*iter);
Poco::File file(pluginPath);
if (file.exists() && file.isDirectory())
{
pluginPaths.push_back(pluginPath);
}
}
}
std::vector<Poco::Path>::iterator pathIter;
for (pathIter = pluginPaths.begin(); pathIter != pluginPaths.end(); pathIter++)
{
try
{
Bundle::Pointer bundle = m_BundleLoader->LoadBundle(*pathIter);
if (bundle)
{
BERRY_INFO(m_ConsoleLog) << "Bundle state (" << pathIter->toString() << "): " << bundle->GetStateString() << std::endl;
}
}
catch (const BundleStateException& exc)
{
BERRY_WARN << exc.displayText() << std::endl;
}
}
// resolve plugins
m_BundleLoader->ResolveAllBundles();
}
catch (Poco::Exception& exc)
{
this->logger().log(exc);
}
#ifdef BLUEBERRY_DEBUG_SMARTPOINTER
DebugUtil::RestoreState();
#endif
}
void InternalPlatform::uninstallPugin(const QUrl& pluginUrl, ctkPluginContext* pfwContext)
{
QFileInfo libInfo(pluginUrl.toLocalFile());
QString libName = libInfo.baseName();
if (libName.startsWith("lib"))
{
libName = libName.mid(3);
}
QString symbolicName = libName.replace('_', '.');
foreach(QSharedPointer<ctkPlugin> plugin, pfwContext->getPlugins())
{
if (plugin->getSymbolicName() == symbolicName &&
plugin->getLocation() != pluginUrl.toString())
{
BERRY_WARN << "A plug-in with the symbolic name " << symbolicName.toStdString() <<
" but different location is already installed. Trying to uninstall " << plugin->getLocation().toStdString();
plugin->uninstall();
return;
}
}
}
void InternalPlatform::Launch()
{
AssertInitialized();
if (m_Running) return;
m_Running = true;
this->run();
}
void InternalPlatform::Shutdown()
{
QSharedPointer<ctkPluginFramework> ctkPluginFW;
{
Poco::Mutex::ScopedLock lock(m_Mutex);
AssertInitialized();
DebugUtil::SaveState();
ctkPluginFW = m_ctkPluginFrameworkFactory->getFramework();
m_Initialized = false;
}
ctkPluginFW->stop();
this->uninitialize();
// wait 10 seconds for the CTK plugin framework to stop
ctkPluginFW->waitForStop(10000);
{
Poco::Mutex::ScopedLock lock(m_Mutex);
delete m_ServiceRegistry;
delete m_BundleLoader;
delete m_CodeCache;
}
}
void InternalPlatform::AssertInitialized()
{
if (!m_Initialized)
throw Poco::SystemException("The Platform has not been initialized yet!");
}
IExtensionPointService::Pointer InternalPlatform::GetExtensionPointService()
{
Poco::Mutex::ScopedLock lock(m_Mutex);
this->AssertInitialized();
return m_ServiceRegistry->GetServiceById<IExtensionPointService>(IExtensionPointService::SERVICE_ID);
}
const Poco::Path& InternalPlatform::GetConfigurationPath()
{
return m_ConfigPath;
}
const Poco::Path& InternalPlatform::GetInstallPath()
{
return m_InstallPath;
}
const Poco::Path& InternalPlatform::GetInstancePath()
{
return m_InstancePath;
}
bool InternalPlatform::GetStatePath(Poco::Path& statePath, IBundle::Pointer bundle, bool create)
{
statePath = m_BaseStatePath;
statePath.pushDirectory(bundle->GetSymbolicName());
try
{
Poco::File stateFile(statePath);
if (!stateFile.exists() && create)
stateFile.createDirectories();
}
catch (Poco::FileException&)
{
return false;
}
return true;
}
PlatformEvents& InternalPlatform::GetEvents()
{
return m_Events;
}
const Poco::Path& InternalPlatform::GetUserPath()
{
return m_UserPath;
}
bool InternalPlatform::IsRunning() const
{
Poco::Mutex::ScopedLock lock(m_Mutex);
return (m_Initialized && m_Running);
}
IBundle::Pointer InternalPlatform::GetBundle(const std::string& id)
{
Poco::Mutex::ScopedLock lock(m_Mutex);
AssertInitialized();
return m_BundleLoader->FindBundle(id);
}
std::vector<IBundle::Pointer> InternalPlatform::GetBundles() const
{
return m_BundleLoader->GetBundles();
}
Poco::Logger* InternalPlatform::GetLogger()
{
return m_PlatformLogger;
}
Poco::Util::LayeredConfiguration& InternalPlatform::GetConfiguration() const
{
return this->config();
}
std::vector<std::string> InternalPlatform::GetApplicationArgs() const
{
return m_FilteredArgs;
}
int& InternalPlatform::GetRawApplicationArgs(char**& argv)
{
argv = m_Argv;
return *m_Argc;
}
void InternalPlatform::defineOptions(Poco::Util::OptionSet& options)
{
Poco::Util::Option helpOption("help", "h", "print this help text");
helpOption.callback(Poco::Util::OptionCallback<InternalPlatform>(this, &InternalPlatform::PrintHelp));
options.addOption(helpOption);
Poco::Util::Option newInstanceOption(Platform::ARG_NEWINSTANCE, "", "forces a new instance of this application");
newInstanceOption.binding(Platform::ARG_NEWINSTANCE);
options.addOption(newInstanceOption);
Poco::Util::Option cleanOption(Platform::ARG_CLEAN, "", "cleans the plugin cache");
cleanOption.binding(Platform::ARG_CLEAN);
options.addOption(cleanOption);
Poco::Util::Option appOption(Platform::ARG_APPLICATION, "", "the id of the application extension to be executed");
appOption.argument("<id>").binding(Platform::ARG_APPLICATION);
options.addOption(appOption);
Poco::Util::Option storageDirOption(Platform::ARG_STORAGE_DIR, "", "the location for storing persistent application data");
storageDirOption.argument("<dir>").binding(Platform::ARG_STORAGE_DIR);
options.addOption(storageDirOption);
Poco::Util::Option consoleLogOption(Platform::ARG_CONSOLELOG, "", "log messages to the console");
consoleLogOption.binding(Platform::ARG_CONSOLELOG);
options.addOption(consoleLogOption);
Poco::Util::Option forcePluginOption(Platform::ARG_FORCE_PLUGIN_INSTALL, "", "force installing plug-ins with same symbolic name");
forcePluginOption.binding(Platform::ARG_FORCE_PLUGIN_INSTALL);
options.addOption(forcePluginOption);
Poco::Util::Option preloadLibsOption(Platform::ARG_PRELOAD_LIBRARY, "", "preload a library");
preloadLibsOption.argument("<library>").repeatable(true).callback(Poco::Util::OptionCallback<InternalPlatform>(this, &InternalPlatform::handlePreloadLibraryOption));
options.addOption(preloadLibsOption);
Poco::Util::Option testPluginOption(Platform::ARG_TESTPLUGIN, "", "the plug-in to be tested");
testPluginOption.argument("<id>").binding(Platform::ARG_TESTPLUGIN);
options.addOption(testPluginOption);
Poco::Util::Option testAppOption(Platform::ARG_TESTAPPLICATION, "", "the application to be tested");
testAppOption.argument("<id>").binding(Platform::ARG_TESTAPPLICATION);
options.addOption(testAppOption);
Poco::Util::Option xargsOption(Platform::ARG_XARGS, "", "Extended argument list");
xargsOption.argument("<args>").binding(Platform::ARG_XARGS);
options.addOption(xargsOption);
Poco::Util::Application::defineOptions(options);
}
void InternalPlatform::handlePreloadLibraryOption(const std::string& name, const std::string& value)
{
std::string oldVal;
if (this->config().hasProperty(Platform::ARG_PRELOAD_LIBRARY))
{
oldVal = this->config().getString(Platform::ARG_PRELOAD_LIBRARY);
}
this->config().setString(Platform::ARG_PRELOAD_LIBRARY, oldVal + "," + value);
}
int InternalPlatform::main(const std::vector<std::string>& args)
{
m_FilteredArgs = args;
//m_FilteredArgs.insert(m_FilteredArgs.begin(), this->config().getString("application.argv[0]"));
ctkPluginContext* context = GetCTKPluginFrameworkContext();
QFileInfo storageDir = context->getDataFile("");
BundleDirectory::Pointer bundleStorage(new BundleDirectory(Poco::Path(storageDir.absolutePath().toStdString())));
SystemBundle::Pointer systemBundle(new SystemBundle(*m_BundleLoader, bundleStorage));
if (systemBundle == 0)
throw PlatformException("Could not find the system bundle");
m_BundleLoader->m_SystemBundle = systemBundle;
m_BundleLoader->LoadBundle(systemBundle);
m_ctkPluginFrameworkFactory->getFramework()->start();
foreach(long pluginId, m_CTKPluginsToStart)
{
BERRY_INFO(m_ConsoleLog) << "Starting CTK plug-in: " << context->getPlugin(pluginId)->getSymbolicName().toStdString()
<< " [" << pluginId << "]";
// do not change the autostart setting of this plugin
context->getPlugin(pluginId)->start(ctkPlugin::START_TRANSIENT | ctkPlugin::START_ACTIVATION_POLICY);
}
m_BundleLoader->StartSystemBundle(systemBundle);
systemBundle->Resume();
return EXIT_OK;
}
void InternalPlatform::PrintHelp(const std::string&, const std::string&)
{
Poco::Util::HelpFormatter help(this->options());
help.setAutoIndent();
help.setCommand(this->commandName());
help.format(std::cout);
exit(EXIT_OK);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryInternalPlatform.h b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryInternalPlatform.h
index 9a069486e3..c6e0e0b048 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryInternalPlatform.h
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryInternalPlatform.h
@@ -1,150 +1,150 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYINTERNALPLATFORM_H_
#define BERRYINTERNALPLATFORM_H_
#include <Poco/Path.h>
#include <Poco/Mutex.h>
#include <Poco/AutoPtr.h>
#include <Poco/Logger.h>
#include <Poco/Util/Application.h>
#include "event/berryPlatformEvents.h"
#include "service/berryServiceRegistry.h"
#include "berryExtensionPointService.h"
#include <map>
class ctkPluginFrameworkFactory;
class ctkPluginContext;
namespace berry {
struct IBundle;
class CodeCache;
class BundleLoader;
class PlatformLogChannel;
class SystemBundle;
class BERRY_OSGI InternalPlatform : private Poco::Util::Application
{
private:
static Poco::Mutex m_Mutex;
bool m_Initialized;
bool m_Running;
bool m_ConsoleLog;
ServiceRegistry* m_ServiceRegistry;
Poco::Path m_BaseStatePath;
Poco::Path m_InstallPath;
Poco::Path m_InstancePath;
Poco::Path m_UserPath;
Poco::Path m_ConfigPath;
std::vector<std::string> m_FilteredArgs;
CodeCache* m_CodeCache;
BundleLoader* m_BundleLoader;
SystemBundle* m_SystemBundle;
Poco::AutoPtr<PlatformLogChannel> m_PlatformLogChannel;
Poco::Logger* m_PlatformLogger;
ctkPluginFrameworkFactory* m_ctkPluginFrameworkFactory;
QList<long> m_CTKPluginsToStart;
PlatformEvents m_Events;
PlatformEvent m_EventStarted;
int* m_Argc;
char** m_Argv;
//std::map<std::string, std::string> m_ArgMap;
InternalPlatform();
//InternalPlatform(const InternalPlatform&) : m_EventStarted(PlatformEvent::EV_PLATFORM_STARTED) {};
void AssertInitialized();
void handlePreloadLibraryOption(const std::string &name, const std::string &value);
int main(const std::vector<std::string>& args);
void uninstallPugin(const QUrl& pluginUrl, ctkPluginContext* pfwContext);
public:
virtual ~InternalPlatform();
// Poco::Application method overrides
void defineOptions(Poco::Util::OptionSet& options);
void PrintHelp(const std::string& name, const std::string& value);
static InternalPlatform* GetInstance();
void Initialize(int& argc, char** argv, Poco::Util::AbstractConfiguration* config = 0);
void Launch();
void Shutdown();
ctkPluginContext* GetCTKPluginFrameworkContext() const;
/// Returns a ServiceRegistry object for registering
/// and accessing services from different plugins
ServiceRegistry& GetServiceRegistry();
/// Convenience method to quickly get the extension
/// point service, which is automatically started
/// by the platform
IExtensionPointService::Pointer GetExtensionPointService();
bool ConsoleLog() const;
const Poco::Path& GetConfigurationPath();
const Poco::Path& GetInstallPath();
const Poco::Path& GetInstancePath();
bool GetStatePath(Poco::Path& statePath, SmartPointer<IBundle> bundle, bool create = true);
const Poco::Path& GetUserPath();
PlatformEvents& GetEvents();
bool IsRunning() const;
Poco::Util::LayeredConfiguration& GetConfiguration() const;
std::vector<std::string> GetApplicationArgs() const;
int& GetRawApplicationArgs(char**& argv);
IBundle::Pointer GetBundle(const std::string& id);
std::vector<IBundle::Pointer> GetBundles() const;
Poco::Logger* GetLogger();
};
} // namespace berry
#endif /*BERRYINTERNALPLATFORM_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryPlatformLogChannel.cpp b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryPlatformLogChannel.cpp
index 4c0b09861c..be7840e05c 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryPlatformLogChannel.cpp
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryPlatformLogChannel.cpp
@@ -1,44 +1,44 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryPlatformLogChannel.h"
#include "berryPlatform.h"
#include "event/berryPlatformEvent.h"
#include "Poco/Any.h"
namespace berry {
PlatformLogChannel::PlatformLogChannel(const std::string& path)
: Poco::SimpleFileChannel(path)
{
}
void
PlatformLogChannel::log(const Poco::Message& msg)
{
Poco::SimpleFileChannel::log(msg);
PlatformEvent event(PlatformEvent::EV_LOGGED);
Poco::Any data(msg);
event.SetData(&data);
Platform::GetEvents().logged(event);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryPlatformLogChannel.h b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryPlatformLogChannel.h
index 3a53f06fb4..b7c73c1eab 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryPlatformLogChannel.h
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryPlatformLogChannel.h
@@ -1,36 +1,36 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYPLATFORMLOGCHANNEL_H_
#define BERRYPLATFORMLOGCHANNEL_H_
#include "Poco/Message.h"
#include "Poco/SimpleFileChannel.h"
namespace berry {
class PlatformLogChannel : public Poco::SimpleFileChannel
{
public:
PlatformLogChannel(const std::string& path);
void log(const Poco::Message& msg);
};
}
#endif /*BERRYPLATFORMLOGCHANNEL_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryProvisioningInfo.cpp b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryProvisioningInfo.cpp
index 1f732f1c0a..40f5322d54 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryProvisioningInfo.cpp
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryProvisioningInfo.cpp
@@ -1,228 +1,228 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryProvisioningInfo.h"
#include <berryLog.h>
#include <QFile>
#include <QFileInfo>
#include <QTextStream>
#include <QCoreApplication>
namespace berry {
#ifdef CMAKE_INTDIR
const QString ProvisioningInfo::intermediateOutDir = QString(CMAKE_INTDIR);
#else
const QString ProvisioningInfo::intermediateOutDir = QString();
#endif
ProvisioningInfo::ProvisioningInfo(const QString& file)
{
this->readProvisioningFile(file);
}
QStringList ProvisioningInfo::getPluginDirs() const
{
return pluginDirs.toList();
}
QList<QUrl> ProvisioningInfo::getPluginsToInstall() const
{
return pluginsToInstall;
}
QList<QUrl> ProvisioningInfo::getPluginsToStart() const
{
return pluginsToStart;
}
void ProvisioningInfo::readProvisioningFile(const QString& filePath)
{
QFile file(filePath);
file.open(QFile::ReadOnly);
QTextStream fileStream(&file);
QRegExp sep("\\s+");
QString line;
int count = 1;
do {
line = fileStream.readLine().trimmed();
if (!line.isEmpty() && !line.startsWith('#'))
{
QString keyword = line.section(sep, 0, 0);
QString value = line.mid(keyword.size()).trimmed();
value = substituteKeywords(value);
if (keyword.isEmpty())
{
BERRY_WARN << "Keyword missing in line " << count
<< " of provisioning file " << filePath.toStdString();
continue;
}
Keyword key = UNKNOWN;
if (keyword.compare("READ", Qt::CaseInsensitive) == 0)
{
key = READ;
}
else if (keyword.compare("INSTALL", Qt::CaseInsensitive) == 0)
{
key = INSTALL;
}
else if (keyword.compare("START", Qt::CaseInsensitive) == 0)
{
key = START;
}
else if (keyword.compare("STOP", Qt::CaseInsensitive) == 0)
{
key = STOP;
}
if (key == UNKNOWN)
{
BERRY_WARN << "Keyword " << keyword.toStdString() << " in line "
<< count << " of provisioning file "
<< filePath.toStdString() << " unknown";
continue;
}
if (value.isEmpty())
{
BERRY_WARN << "Value after keyword " << keyword.toStdString()
<< " missing in line " << count
<< " of provisioning file " << filePath.toStdString();
continue;
}
switch (key)
{
case READ:
{
QUrl readFileUrl(value);
if (!readFileUrl.isValid())
{
BERRY_WARN << "The READ URL " << value.toStdString()
<< "is invalid: " << readFileUrl.errorString().toStdString();
break;
}
this->readProvisioningFile(readFileUrl.toLocalFile());
break;
}
case INSTALL:
{
this->addPluginToInstall(value);
break;
}
case START:
{
this->addPluginToStart(value);
break;
}
case STOP:
{
break;
}
}
}
++count;
} while (!line.isNull());
}
QUrl ProvisioningInfo::addPluginToInstall(const QString& file)
{
QUrl pluginUrl(file);
if (!pluginUrl.isValid())
{
BERRY_WARN << "The plugin URL " << file.toStdString() << " is invalid:"
<< pluginUrl.errorString().toStdString();
return QUrl();
}
QFileInfo fileInfo(pluginUrl.toLocalFile());
if (!fileInfo.exists())
{
QString fileName = fileInfo.fileName();
QString filePath = fileInfo.absolutePath();
if (!intermediateOutDir.isEmpty())
{
// search in the intermediate output dir
QString filePath2 = filePath + "/" + intermediateOutDir;
fileInfo = QFileInfo(filePath2 + "/" + fileName);
if (!fileInfo.exists())
{
BERRY_WARN << "The plugin " << fileName.toStdString() << " was not found in "
<< filePath.toStdString() << " or " << filePath2.toStdString();
return QUrl();
}
pluginUrl = QUrl::fromLocalFile(fileInfo.canonicalFilePath());
pluginDirs.insert(fileInfo.canonicalPath());
}
else
{
BERRY_WARN << "The plugin " << fileName.toStdString() << " was not found in "
<< filePath.toStdString();
return QUrl();
}
}
else
{
pluginDirs.insert(fileInfo.canonicalPath());
}
pluginsToInstall.append(pluginUrl);
return pluginUrl;
}
void ProvisioningInfo::addPluginToStart(const QString& file)
{
QUrl pluginUrl = this->addPluginToInstall(file);
if (!pluginUrl.isEmpty())
{
pluginsToStart.append(pluginUrl);
}
}
QString ProvisioningInfo::substituteKeywords(const QString& value) const
{
QString appPath = QCoreApplication::applicationDirPath();
if (appPath.endsWith('/'))
{
appPath.chop(1);
}
#ifdef CMAKE_INTDIR
// Strip the intermediate dir from the application path
QString intDir(CMAKE_INTDIR);
if (appPath.endsWith(intDir))
{
appPath.chop(intDir.size()+1);
}
#endif
#ifdef _WIN32
if (value.contains("@EXECUTABLE_DIR") && value.contains("blueberry_osgi"))
{
// special case for org_blueberry_osgi in install trees for Windows
return QString(value).replace("@EXECUTABLE_DIR", appPath, Qt::CaseInsensitive).replace("plugins/", "");
}
#endif
return QString(value).replace("@EXECUTABLE_DIR", appPath, Qt::CaseInsensitive);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryProvisioningInfo.h b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryProvisioningInfo.h
index d8159564ad..ec89951e3c 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryProvisioningInfo.h
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berryProvisioningInfo.h
@@ -1,62 +1,62 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYPROVISIONINGINFO_H
#define BERRYPROVISIONINGINFO_H
#include <QString>
#include <QStringList>
#include <QSet>
#include <QUrl>
namespace berry {
class ProvisioningInfo
{
public:
ProvisioningInfo(const QString& file);
QStringList getPluginDirs() const;
QList<QUrl> getPluginsToInstall() const;
QList<QUrl> getPluginsToStart() const;
private:
enum Keyword {
UNKNOWN,
READ,
INSTALL,
START,
STOP
};
QSet<QString> pluginDirs;
QList<QUrl> pluginsToInstall;
QList<QUrl> pluginsToStart;
static const QString intermediateOutDir;
void readProvisioningFile(const QString& file);
QUrl addPluginToInstall(const QString& file);
void addPluginToStart(const QString& file);
QString substituteKeywords(const QString& value) const;
};
}
#endif // BERRYPROVISIONINGINFO_H
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berrySystemBundle.cpp b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berrySystemBundle.cpp
index 03e2d1bf58..49a9406f9d 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berrySystemBundle.cpp
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berrySystemBundle.cpp
@@ -1,76 +1,76 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryLog.h"
#include "berrySystemBundle.h"
#include "berrySystemBundleManifest.h"
#include "Poco/Exception.h"
#include "berryBundleLoader.h"
namespace berry {
SystemBundle::SystemBundle(BundleLoader& loader, IBundleStorage::Pointer storage)
: Bundle(loader, storage, false)
{
this->init();
m_State = BUNDLE_RESOLVED;
}
void SystemBundle::Start()
{
}
void SystemBundle::Resume()
{
m_State = BUNDLE_ACTIVE;
// read the plugin.xml file from the resolved plugins
try
{
m_BundleLoader.ReadAllContributions();
}
catch (Poco::Exception exc)
{
BERRY_ERROR << exc.displayText() << std::endl;
}
// start all plugins with lazy-start: false
try
{
m_BundleLoader.StartAllBundles();
}
catch (Poco::Exception exc)
{
BERRY_ERROR << exc.displayText() << std::endl;
}
}
BundleLoader& SystemBundle::GetBundleLoader()
{
return m_BundleLoader;
}
void SystemBundle::LoadManifest()
{
m_Manifest = new SystemBundleManifest();
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berrySystemBundle.h b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berrySystemBundle.h
index 246c071511..e4d62eaa7c 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berrySystemBundle.h
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berrySystemBundle.h
@@ -1,48 +1,48 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYSYSTEMBUNDLE_H_
#define BERRYSYSTEMBUNDLE_H_
#include "berryBundle.h"
namespace berry {
class BundleLoader;
class SystemBundle : public Bundle
{
public:
berryObjectMacro(SystemBundle)
SystemBundle(BundleLoader& loader, IBundleStorage::Pointer storage);
void Start();
void Resume();
BundleLoader& GetBundleLoader();
protected:
void LoadManifest();
};
}
#endif /*BERRYSYSTEMBUNDLE_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berrySystemBundleActivator.cpp b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berrySystemBundleActivator.cpp
index afe333ec67..a504e87208 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berrySystemBundleActivator.cpp
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berrySystemBundleActivator.cpp
@@ -1,40 +1,40 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryLog.h"
#include "berrySystemBundleActivator.h"
#include "berryIBundleContext.h"
#include "berryPlatform.h"
#include "service/berryServiceRegistry.h"
#include "berrySystemBundle.h"
#include "berryExtensionPointService.h"
namespace berry {
void SystemBundleActivator::Start(IBundleContext::Pointer context)
{
}
void SystemBundleActivator::Stop(IBundleContext::Pointer /*context*/)
{
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berrySystemBundleActivator.h b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berrySystemBundleActivator.h
index c6e04d132c..f2dd957bdd 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berrySystemBundleActivator.h
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berrySystemBundleActivator.h
@@ -1,34 +1,34 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYSYSTEMBUNDLEACTIVATOR_H_
#define BERRYSYSTEMBUNDLEACTIVATOR_H_
#include "berryIBundleActivator.h"
namespace berry {
class SystemBundleActivator : public IBundleActivator
{
public:
void Start(SmartPointer<IBundleContext> context);
void Stop(SmartPointer<IBundleContext> context);
};
}
#endif /*BERRYSYSTEMBUNDLEACTIVATOR_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berrySystemBundleManifest.cpp b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berrySystemBundleManifest.cpp
index 30b581543c..a75bea7f07 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berrySystemBundleManifest.cpp
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berrySystemBundleManifest.cpp
@@ -1,91 +1,91 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berrySystemBundleManifest.h"
#include "berryInternalPlatform.h"
#include <ctkPluginConstants.h>
#include <ctkPluginContext.h>
namespace berry {
SystemBundleManifest::SystemBundleManifest()
{
ctkPluginContext* context = InternalPlatform::GetInstance()->GetCTKPluginFrameworkContext();
manifestHeaders = context->getPlugin()->getHeaders();
activatorClass = "berry::SystemBundleActivator";
activatorLib = "";
copyright = manifestHeaders.value(ctkPluginConstants::PLUGIN_COPYRIGHT).toStdString();
name = manifestHeaders.value(ctkPluginConstants::PLUGIN_NAME).toStdString();
symbolicName = manifestHeaders.value(ctkPluginConstants::PLUGIN_SYMBOLICNAME).toStdString();
vendor = manifestHeaders.value(ctkPluginConstants::PLUGIN_VENDOR).toStdString();
}
const std::string& SystemBundleManifest::GetActivatorClass() const
{
return activatorClass;
}
const std::string& SystemBundleManifest::GetActivatorLibrary() const
{
return activatorLib;
}
const std::string& SystemBundleManifest::GetCopyright() const
{
return copyright;
}
IBundleManifest::ActivationPolicy SystemBundleManifest::GetActivationPolicy() const
{
QString policy = manifestHeaders.value(ctkPluginConstants::PLUGIN_ACTIVATIONPOLICY);
if (policy == ctkPluginConstants::ACTIVATION_EAGER)
{
return EAGER;
}
return LAZY;
}
bool SystemBundleManifest::IsSystemBundle() const
{
return true;
}
const std::string& SystemBundleManifest::GetName() const
{
return name;
}
const IBundleManifest::Dependencies& SystemBundleManifest::GetRequiredBundles() const
{
// The system bundle does not depend on other bundles
return dependencies;
}
const std::string& SystemBundleManifest::GetSymbolicName() const
{
return symbolicName;
}
const std::string& SystemBundleManifest::GetVendor() const
{
return vendor;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berrySystemBundleManifest.h b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berrySystemBundleManifest.h
index d999a1cb2a..741992b9e9 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berrySystemBundleManifest.h
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/internal/berrySystemBundleManifest.h
@@ -1,57 +1,57 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYSYSTEMBUNDLEMANIFEST_H
#define BERRYSYSTEMBUNDLEMANIFEST_H
#include "berryIBundleManifest.h"
#include <QHash>
namespace berry {
class SystemBundleManifest : public IBundleManifest
{
public:
SystemBundleManifest();
virtual const std::string& GetActivatorClass() const;
virtual const std::string& GetActivatorLibrary() const;
virtual const std::string& GetCopyright() const;
virtual ActivationPolicy GetActivationPolicy() const;
virtual bool IsSystemBundle() const;
virtual const std::string& GetName() const;
virtual const Dependencies& GetRequiredBundles() const;
virtual const std::string& GetSymbolicName() const;
virtual const std::string& GetVendor() const;
private:
Dependencies dependencies;
QHash<QString, QString> manifestHeaders;
std::string activatorClass;
std::string activatorLib;
std::string copyright;
std::string name;
std::string symbolicName;
std::string vendor;
};
}
#endif // BERRYSYSTEMBUNDLEMANIFEST_H
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryIConfigurationElement.h b/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryIConfigurationElement.h
index 830d154c11..b61d634a1a 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryIConfigurationElement.h
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryIConfigurationElement.h
@@ -1,156 +1,156 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIEXTENSIONELEMENT_H_
#define BERRYIEXTENSIONELEMENT_H_
#include "berryLog.h"
#include <org_blueberry_osgi_Export.h>
#include "berryBundleLoader.h"
#include "berryPlatformException.h"
#include "berryExtensionType.h"
#include "berryIExecutableExtension.h"
#include "berryIExtension.h"
#include <vector>
#include <string>
namespace berry {
struct IExtension;
struct BERRY_OSGI IConfigurationElement : public Object
{
berryObjectMacro(IConfigurationElement);
public:
typedef std::vector<IConfigurationElement::Pointer> vector;
template<class C>
C* CreateExecutableExtension(const std::string& propertyName, const std::string& manifestName)
{
std::string className;
if (this->GetAttribute(propertyName, className))
{
try
{
C* cl = m_ClassLoader->LoadClass<C>(m_Contributor, className, manifestName);
// check if we have extension adapter and initialize
if (dynamic_cast<IExecutableExtension*>(cl) != 0) {
// make the call even if the initialization string is null
dynamic_cast<IExecutableExtension*>(cl)->SetInitializationData(Pointer(this), propertyName, Object::Pointer(0));
}
if (cl == 0)
{
BERRY_WARN << "Could not load executable extension " << className << " from " << GetContributor();
}
return cl;
}
catch (Poco::Exception& e)
{
BERRY_ERROR << "Error loading class: " << e.displayText() << std::endl;
throw e;
}
}
throw CoreException("Missing attribute", propertyName);
}
template<class C>
C* CreateExecutableExtension(const std::string& propertyName)
{
std::string className;
if (this->GetAttribute(propertyName, className))
{
std::string contributor = this->GetContributor();
QSharedPointer<ctkPlugin> plugin = Platform::GetCTKPlugin(QString::fromStdString(contributor));
if (!plugin.isNull())
{
// immediately start the plugin but do not change the plugins autostart setting
plugin->start(ctkPlugin::START_TRANSIENT);
QString typeName = plugin->getSymbolicName() + "_" + QString::fromStdString(className);
int extensionTypeId = ExtensionType::type(typeName.toAscii().data());
if (extensionTypeId == 0)
{
BERRY_WARN << "The class " << className << " was not registered as an Extension Type using BERRY_REGISTER_EXTENSION_CLASS(type, pluginContext) or you forgot to run Qt's moc on the header file. "
"Legacy BlueBerry bundles should use CreateExecutableExtension<C>(propertyName, C::GetManifestName()) instead.";
}
else
{
QObject* obj = ExtensionType::construct(extensionTypeId);
// check if we have extension adapter and initialize
if (IExecutableExtension* execExt = qobject_cast<IExecutableExtension*>(obj))
{
// make the call even if the initialization string is null
execExt->SetInitializationData(Pointer(this), propertyName, Object::Pointer(0));
}
C* interface = qobject_cast<C*>(obj);
if (interface == 0)
{
BERRY_WARN << "The QObject subclass " << className << " does not seem to implement the required interface class, or you forgot the Q_INTERFACES macro.";
}
return interface;
}
}
else
{
BERRY_WARN << "Trying to create an executable extension (from "
<< this->GetDeclaringExtension()->GetExtensionPointIdentifier()
<< " in " << contributor << ") from a non-CTK plug-in. "
"Use the CreateExecutableExtension<C>(propertyName, manifestName) method instead.";
}
}
return 0;
}
virtual bool GetAttribute(const std::string& name, std::string& value) const = 0;
virtual bool GetBoolAttribute(const std::string& name, bool& value) const = 0;
virtual const std::vector<IConfigurationElement::Pointer> GetChildren() const = 0;
virtual const std::vector<IConfigurationElement::Pointer> GetChildren(const std::string& name) const = 0;
virtual std::string GetValue() const = 0;
virtual std::string GetName() const = 0;
virtual const IConfigurationElement* GetParent() const = 0;
virtual const std::string& GetContributor() const = 0;
virtual const IExtension* GetDeclaringExtension() const = 0;
virtual ~IConfigurationElement() {};
protected:
BundleLoader* m_ClassLoader;
std::string m_Contributor;
};
} // namespace berry
#endif /*BERRYIEXTENSIONELEMENT_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryIExtension.h b/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryIExtension.h
index 85af9738af..94f3853dcf 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryIExtension.h
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryIExtension.h
@@ -1,107 +1,107 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIEXTENSION_H_
#define BERRYIEXTENSION_H_
#include <org_blueberry_osgi_Export.h>
#include <berrySmartPointer.h>
#include <vector>
namespace berry {
struct IConfigurationElement;
/**
* An extension declared in a host.
* All information is obtained from the declaring host
* extensions manifest file.
* <p>
* This interface is not intended to be implemented by clients.
*
*/
struct BERRY_OSGI IExtension {
/**
* Returns all configuration elements declared by this extension.
* These elements are a direct reflection of the configuration
* markup supplied in the manifest file for the host that declares
* this extension.
* Returns an empty array if this extension does not declare any
* configuration elements.
*
* @return the configuration elements declared by this extension
*/
virtual const std::vector<SmartPointer<IConfigurationElement> > GetConfigurationElements() const = 0;
virtual std::string GetNamespace() const = 0;
/**
* Returns the unique identifier of the extension point
* that this extension gets plugged into.
*
* @return the unique identifier of the relevant extension point
*/
virtual std::string GetExtensionPointIdentifier() const = 0;
/**
* Returns the simple identifier of this extension, or <code>null</code>
* if this extension does not have an identifier.
* This identifier is specified in the extensions manifest
* file as a non-empty string containing no period characters
* (<code>'.'</code>) and must be unique within the defining host.
*
* @return the simple identifier of the extension (e.g. <code>"main"</code>)
* or <code>null</code>
*/
virtual std::string GetSimpleIdentifier() const = 0;
/**
* Returns the unique identifier of this extension, or <code>null</code>
* if this extension does not have an identifier.
* If available, this identifier is unique within the extension registry, and
* is composed of the identifier of the host that declared
* this extension and this extension's simple identifier.
*
* @return the unique identifier of the extension
* (e.g. <code>"com.example.acme.main"</code>), or <code>null</code>
*/
virtual std::string GetUniqueIdentifier() const = 0;
/**
* Returns a displayable label for this extension.
* Returns the empty string if no label for this extension
* is specified in the extension manifest file.
* <p> Note that any translation specified in the extension manifest
* file is automatically applied.
* <p>
*
* @return a displayable string label for this extension,
* possibly the empty string
*/
virtual std::string GetLabel() const = 0;
virtual bool operator<(const IExtension* e2) const = 0;
virtual ~IExtension() {}
};
}
#endif /*BERRYIEXTENSION_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryIExtensionPoint.h b/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryIExtensionPoint.h
index f4d9d39df5..174e653ad9 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryIExtensionPoint.h
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryIExtensionPoint.h
@@ -1,147 +1,147 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIEXTENSIONPOINT_H_
#define BERRYIEXTENSIONPOINT_H_
#include <org_blueberry_osgi_Export.h>
#include "berryIExtension.h"
#include "berryIConfigurationElement.h"
#include <vector>
namespace berry {
struct IBundle;
/**
* An extension point declared in a plug-in.
* Except for the list of extensions plugged in to it, the information
* available for an extension point is obtained from the declaring plug-in's
* manifest (<code>plugin.xml</code>) file.
* <p>
* These registry objects are intended for relatively short-term use. Clients that
* deal with these objects must be aware that they may become invalid if the
* declaring plug-in is updated or uninstalled. If this happens, all methods except
* {@link #isValid()} will throw {@link InvalidRegistryObjectException}.
* For extension point objects, the most common case is code in a plug-in dealing
* with one of the extension points it declares. These extension point objects are
* guaranteed to be valid while the plug-in is active. Code in a plug-in that has
* declared that it is not dynamic aware (or not declared anything) can also safely
* ignore this issue, since the registry would not be modified while it is
* active. However, code in a plug-in that declares that it is dynamic aware
* must be careful if it access the extension point object of a different plug-in,
* because it's at risk if that other plug-in is removed. Similarly,
* tools that analyze or display the extension registry are vulnerable.
* Client code can pre-test for invalid objects by calling {@link #isValid()},
* which never throws this exception. However, pre-tests are usually not sufficient
* because of the possibility of the extension point object becoming invalid as a
* result of a concurrent activity. At-risk clients must treat
* <code>InvalidRegistryObjectException</code> as if it were a checked exception.
* Also, such clients should probably register a listener with the extension registry
* so that they receive notification of any changes to the registry.
* </p>
* <p>
* This interface is not intended to be implemented by clients.
* </p>
*/
struct BERRY_OSGI IExtensionPoint
{
public:
virtual ~IExtensionPoint() {};
virtual std::string GetContributor() const = 0;
/**
* Returns all configuration elements from all extensions configured
* into this extension point. Returns an empty array if this extension
* point has no extensions configured, or none of the extensions
* contain configuration elements.
*
* @return the configuration elements for all extension configured
* into this extension point
* @throws InvalidRegistryObjectException if this extension point is no longer valid
*/
virtual const std::vector<IConfigurationElement::Pointer > GetConfigurationElements() const = 0;
/**
* Returns the extension with the given unique identifier configured into
* this extension point, or <code>null</code> if there is no such extension.
* Since an extension might not have an identifier, some extensions
* can only be found via the <code>getExtensions</code> method.
*
* @param extensionId the unique identifier of an extension
* (e.g. <code>"com.example.acme.main"</code>).
* @return an extension, or <code>null</code>
* @throws InvalidRegistryObjectException if this extension point is no longer valid
*/
virtual const IExtension* GetExtension(const std::string& extensionId) const = 0;
/**
* Returns all extensions configured into this extension point.
* Returns an empty array if this extension point has no extensions.
*
* @return the extensions configured into this extension point
* @throws InvalidRegistryObjectException if this extension point is no longer valid
*/
virtual const std::vector<const IExtension*> GetExtensions() const = 0;
/**
* Returns a displayable label for this extension point.
* Returns the empty string if no label for this extension point
* is specified in the plug-in manifest file.
* <p> Note that any translation specified in the plug-in manifest
* file is automatically applied.
* </p>
*
* @return a displayable string label for this extension point,
* possibly the empty string
* @throws InvalidRegistryObjectException if this extension point is no longer valid
*/
virtual std::string GetLabel() const = 0;
/**
* Returns the simple identifier of this extension point.
* This identifier is a non-empty string containing no
* period characters (<code>'.'</code>) and is guaranteed
* to be unique within the defining plug-in.
*
* @return the simple identifier of the extension point (e.g. <code>"builders"</code>)
* @throws InvalidRegistryObjectException if this extension point is no longer valid
*/
virtual std::string GetSimpleIdentifier() const = 0;
/**
* Returns the unique identifier of this extension point.
* This identifier is unique within the plug-in registry, and
* is composed of the namespace for this extension point
* and this extension point's simple identifier.
*
*
* @return the unique identifier of the extension point
* (e.g. <code>"org.blueberry.core.resources.builders"</code>)
* @throws InvalidRegistryObjectException if this extension point is no longer valid
*/
virtual std::string GetUniqueIdentifier() const = 0;
};
}
#endif /*BERRYIEXTENSIONPOINT_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryIExtensionPointService.cpp b/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryIExtensionPointService.cpp
index da86762c14..a7dea4d91b 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryIExtensionPointService.cpp
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryIExtensionPointService.cpp
@@ -1,23 +1,23 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryIExtensionPointService.h"
namespace berry {
std::string IExtensionPointService::SERVICE_ID = "org.blueberry.service.xp";
} // namespace berry
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryIExtensionPointService.h b/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryIExtensionPointService.h
index 4a17f36b31..a32b615da2 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryIExtensionPointService.h
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryIExtensionPointService.h
@@ -1,61 +1,61 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIEXTENSIONPOINTSERVICE_H_
#define BERRYIEXTENSIONPOINTSERVICE_H_
#include <org_blueberry_osgi_Export.h>
#include "berryService.h"
#include "berryIExtensionPoint.h"
#include "berryIConfigurationElement.h"
#include <QtPlugin>
namespace berry {
struct IBundle;
struct BERRY_OSGI IExtensionPointService : public Service
{
berryInterfaceMacro(IExtensionPointService, berry);
public:
static std::string SERVICE_ID;
virtual ~IExtensionPointService() {}
virtual void AddContribution(std::istream& istr, const std::string& contributor) = 0;
virtual const std::vector<IConfigurationElement::Pointer> GetConfigurationElementsFor(const std::string& extensionPointId) const = 0;
virtual const IExtension* GetExtension(const std::string& extensionPointId, const std::string& extensionId) const = 0;
virtual const IExtensionPoint* GetExtensionPoint(const std::string& extensionPointId) const = 0;
virtual const std::vector<const IExtension*> GetExtensions(const std::string& contributor) const = 0;
virtual const std::vector<const IExtensionPoint*> GetExtensionPoints() const = 0;
virtual const std::vector<const IExtensionPoint*> GetExtensionPoints(const std::string& contributor) const = 0;
virtual bool HasContributionFrom(const std::string& name) const = 0;
};
} // namespace berry
Q_DECLARE_INTERFACE(berry::IExtensionPointService, "org.blueberry.service.IExtensionPoint")
#endif /*BERRYIEXTENSIONPOINTSERVICE_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryService.cpp b/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryService.cpp
index a2a9a7d581..bf42521125 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryService.cpp
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryService.cpp
@@ -1,39 +1,39 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryService.h"
#include <string>
namespace berry {
Service::~Service()
{
}
bool Service::IsA(const std::type_info& type) const
{
std::string name(this->GetType().name());
return name == type.name();
}
const std::type_info& Service::GetType() const
{
return typeid(Service);
}
} // berry
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryService.h b/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryService.h
index 8b74c2cb71..30217c3823 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryService.h
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryService.h
@@ -1,43 +1,43 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYSERVICE_H_
#define BERRYSERVICE_H_
#include <org_blueberry_osgi_Export.h>
#include "berryMacros.h"
#include "berryObject.h"
#include <typeinfo>
namespace berry {
class BERRY_OSGI Service : public Object
{
public:
berryObjectMacro(Service);
virtual ~Service();
virtual bool IsA(const std::type_info& type) const;
virtual const std::type_info& GetType() const;
};
} // namespace berry
#endif /*BERRYSERVICE_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryServiceRegistry.cpp b/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryServiceRegistry.cpp
index 765f9f5f2b..ed24b1f403 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryServiceRegistry.cpp
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryServiceRegistry.cpp
@@ -1,52 +1,52 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryLog.h"
#include "berryServiceRegistry.h"
#include "Poco/Exception.h"
#include <iostream>
namespace berry {
ServiceRegistry::~ServiceRegistry()
{
}
void ServiceRegistry::RegisterService(const std::string& id, Service::Pointer service)
{
Poco::Mutex::ScopedLock lock(m_Mutex);
if (m_ServiceMap.find(id) != m_ServiceMap.end())
throw Poco::ExistsException("The following service is already registered:", id);
m_ServiceMap[id] = service;
//BERRY_INFO << "Service " << id << " registered\n";
}
void ServiceRegistry::UnRegisterService(const std::string& /*id*/)
{
throw Poco::NotImplementedException();
}
void ServiceRegistry::UnRegisterService(Service::ConstPointer /*service*/)
{
throw Poco::NotImplementedException();
}
} // namespace berry
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryServiceRegistry.h b/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryServiceRegistry.h
index 6ccc14f24e..7f122316dc 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryServiceRegistry.h
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryServiceRegistry.h
@@ -1,54 +1,54 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYSERVICEREGISTRY_H_
#define BERRYSERVICEREGISTRY_H_
#include <org_blueberry_osgi_Export.h>
#include "berryService.h"
#include "Poco/Mutex.h"
#include <string>
#include <map>
namespace berry {
class BERRY_OSGI ServiceRegistry
{
private:
std::map<const std::string, Service::Pointer> m_ServiceMap;
mutable Poco::Mutex m_Mutex;
public:
virtual ~ServiceRegistry();
template<class S>
typename S::Pointer GetServiceById(const std::string& id);
void RegisterService(const std::string& id, Service::Pointer service);
void UnRegisterService(const std::string& id);
void UnRegisterService(Service::ConstPointer service);
};
} // namespace berry
#include "berryServiceRegistry.txx"
#endif /*BERRYSERVICEREGISTRY_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryServiceRegistry.txx b/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryServiceRegistry.txx
index 09ad22dbb4..de81c1c141 100644
--- a/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryServiceRegistry.txx
+++ b/BlueBerry/Bundles/org.blueberry.osgi/src/service/berryServiceRegistry.txx
@@ -1,87 +1,87 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 __BERRY_SERVICE_REGISTRY_TXX__
#define __BERRY_SERVICE_REGISTRY_TXX__
#include "../internal/berryCTKPluginActivator.h"
#include "../berryLog.h"
#include <ctkPluginContext.h>
namespace berry {
template<class S>
typename S::Pointer ServiceRegistry::GetServiceById(const std::string& id)
{
Poco::Mutex::ScopedLock lock(m_Mutex);
Service::Pointer servicePtr;
std::map<const std::string, Service::Pointer>::const_iterator serviceIt =
m_ServiceMap.find(id);
if (serviceIt != m_ServiceMap.end())
{
servicePtr = serviceIt->second;
}
if (servicePtr.IsNull())
{
// Try to get the service from the CTK Service Registry
ctkPluginContext* context = CTKPluginActivator::getPluginContext();
if (context == 0)
{
// The org.blueberry.osgi plug-in was not started by the CTK Plugin Framework.
// This is considered a fatal error.
BERRY_FATAL << "The org.blueberry.osgi plug-in is not started. "
"Check that your application loads the correct provisioning "
"file and that it contains an entry for the org.blueberry.osgi plug-in.";
return SmartPointer<S>();
}
try
{
ctkServiceReference serviceRef = context->getServiceReference<S>();
if (!serviceRef) return SmartPointer<S>();
S* service = context->getService<S>(serviceRef);
if (!service)
{
return SmartPointer<S>();
}
//BERRY_WARN << "Getting a CTK Service object through the BlueBerry service registry.\n"
// "You should use a ctkPluginContext or ctkServiceTracker instance instead!";
return typename S::Pointer(service);
}
catch (const ctkServiceException& exc)
{
BERRY_INFO << exc.what();
}
return SmartPointer<S>();
}
if (servicePtr->IsA(typeid(S)))
{
SmartPointer<S> castService = servicePtr.Cast<S>();
return castService;
}
else throw Poco::BadCastException("The service could not be cast to: ", typeid(S).name());
}
} // namespace berry
#endif // __BERRY_SERVICE_REGISTRY_TXX__
diff --git a/BlueBerry/Bundles/org.blueberry.solstice.common/src/berryISafeRunnable.h b/BlueBerry/Bundles/org.blueberry.solstice.common/src/berryISafeRunnable.h
index b6fa487abb..ce8cefd4af 100644
--- a/BlueBerry/Bundles/org.blueberry.solstice.common/src/berryISafeRunnable.h
+++ b/BlueBerry/Bundles/org.blueberry.solstice.common/src/berryISafeRunnable.h
@@ -1,102 +1,102 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYISAFERUNNABLE_H_
#define BERRYISAFERUNNABLE_H_
#include <berryObject.h>
#include <berryMacros.h>
#include <org_blueberry_solstice_common_Export.h>
namespace berry
{
/**
* Safe runnables represent blocks of code and associated exception
* handlers. They are typically used when a plug-in needs to call some
* untrusted code (e.g., code contributed by another plug-in via an
* extension).
* <p>
* This interface can be used without OSGi running.
* </p><p>
* Clients may implement this interface.
* </p>
* @see SafeRunner#run(ISafeRunnable)
*/
struct BERRY_COMMON_RUNTIME ISafeRunnable: public Object
{
berryInterfaceMacro(ISafeRunnable, berry)
/**
* Handles an exception thrown by this runnable's <code>run</code>
* method. The processing done here should be specific to the
* particular usecase for this runnable. Generalized exception
* processing (e.g., logging in the platform's log) is done by the
* Platform's run mechanism.
*
* @param exception an exception which occurred during processing
* the body of this runnable (i.e., in <code>run()</code>)
* @see SafeRunner#run(ISafeRunnable)
*/
virtual void HandleException(const std::exception& exception) = 0;
/**
* Runs this runnable. Any exceptions thrown from this method will
* be passed to this runnable's <code>handleException</code>
* method.
*
* @exception Exception if a problem occurred while running this method.
* The exception will be processed by <code>handleException</code>
* @see SafeRunner#run(ISafeRunnable)
*/
virtual void Run() = 0;
};
template<typename R>
struct SafeRunnableDelegate: public ISafeRunnable
{
typedef void(R::*RunCallback)();
typedef void(R::*HandleExcCallback)(const std::exception&);
SafeRunnableDelegate(R* runnable, RunCallback func, HandleExcCallback handleFunc = 0) :
m_Runnable(runnable), m_RunFunc(func), m_HandleExcFunc(handleFunc)
{
}
void Run()
{
m_Runnable->*m_RunFunc();
}
void HandleException(const std::exception& exception)
{
if (m_HandleExcFunc)
m_Runnable->*m_HandleExcFunc(exception);
}
private:
R* m_Runnable;
RunCallback m_RunFunc;
HandleExcCallback m_HandleExcFunc;
};
}
#endif /* BERRYISAFERUNNABLE_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.solstice.common/src/berryIStatus.h b/BlueBerry/Bundles/org.blueberry.solstice.common/src/berryIStatus.h
index c75c191f4e..b0c79a46d3 100644
--- a/BlueBerry/Bundles/org.blueberry.solstice.common/src/berryIStatus.h
+++ b/BlueBerry/Bundles/org.blueberry.solstice.common/src/berryIStatus.h
@@ -1,201 +1,201 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYISTATUS_H_
#define BERRYISTATUS_H_
#include <berryObject.h>
#include <berryMacros.h>
#include <berryFlags.h>
#include <org_blueberry_solstice_common_Export.h>
namespace berry
{
/**
* A status object represents the outcome of an operation.
* All <code>CoreException</code>s carry a status object to indicate
* what went wrong. Status objects are also returned by methods needing
* to provide details of failures (e.g., validation methods).
* <p>
* A status carries the following information:
* <ul>
* <li> plug-in identifier (required)</li>
* <li> severity (required)</li>
* <li> status code (required)</li>
* <li> message (required) - localized to current locale</li>
* <li> exception (optional) - for problems stemming from a failure at
* a lower level</li>
* </ul>
* Some status objects, known as multi-statuses, have other status objects
* as children.
* </p>
* <p>
* The class <code>Status</code> is the standard public implementation
* of status objects; the subclass <code>MultiStatus</code> is the
* implements multi-status objects.
* </p><p>
* This interface can be used without OSGi running.
* </p>
* @see MultiStatus
* @see Status
*/
struct BERRY_COMMON_RUNTIME IStatus: public Object
{
berryInterfaceMacro(IStatus, berry)
enum Severity
{
/** Status severity constant (value 0) indicating this status represents the nominal case.
* This constant is also used as the status code representing the nominal case.
*/
OK_TYPE = 0x00,
/** Status type severity (bit mask, value 1) indicating this status is informational only. */
INFO_TYPE = 0x01,
/** Status type severity (bit mask, value 2) indicating this status represents a warning. */
WARNING_TYPE = 0x02,
/** Status type severity (bit mask, value 4) indicating this status represents an error. */
ERROR_TYPE = 0x04,
/** Status type severity (bit mask, value 8) indicating this status represents a cancelation. */
CANCEL_TYPE = 0x08
};
BERRY_DECLARE_FLAGS(Severities, Severity)
/**
* Returns a list of status object immediately contained in this
* multi-status, or an empty list if this is not a multi-status.
*
* @return an array of status objects
* @see #isMultiStatus()
*/
virtual std::vector<IStatus::Pointer> GetChildren() const = 0;
/**
* Returns the plug-in-specific status code describing the outcome.
*
* @return plug-in-specific status code
*/
virtual int GetCode() const = 0;
/**
* Returns the relevant low-level exception, or <code>null</code> if none.
* For example, when an operation fails because of a network communications
* failure, this might return the <code>java.io.IOException</code>
* describing the exact nature of that failure.
*
* @return the relevant low-level exception, or <code>null</code> if none
*/
virtual std::exception GetException() const = 0;
/**
* Returns the message describing the outcome.
* The message is localized to the current locale.
*
* @return a localized message
*/
virtual std::string GetMessage() const = 0;
/**
* Returns the unique identifier of the plug-in associated with this status
* (this is the plug-in that defines the meaning of the status code).
*
* @return the unique identifier of the relevant plug-in
*/
virtual std::string GetPlugin() const = 0;
/**
* Returns the severity. The severities are as follows (in
* descending order):
* <ul>
* <li><code>CANCEL_TYPE</code> - cancelation occurred</li>
* <li><code>ERROR_TYPE</code> - a serious error (most severe)</li>
* <li><code>WARNING_TYPE</code> - a warning (less severe)</li>
* <li><code>INFO_TYPE</code> - an informational ("fyi") message (least severe)</li>
* <li><code>OK_TYPE</code> - everything is just fine</li>
* </ul>
* <p>
* The severity of a multi-status is defined to be the maximum
* severity of any of its children, or <code>OK</code> if it has
* no children.
* </p>
*
* @return the severity: one of <code>OK_TYPE</code>, <code>ERROR_TYPE</code>,
* <code>INFO_TYPE</code>, <code>WARNING_TYPE</code>, or <code>CANCEL_TYPE</code>
* @see #matches(int)
*/
virtual Severity GetSeverity() const = 0;
/**
* Returns whether this status is a multi-status.
* A multi-status describes the outcome of an operation
* involving multiple operands.
* <p>
* The severity of a multi-status is derived from the severities
* of its children; a multi-status with no children is
* <code>OK_TYPE</code> by definition.
* A multi-status carries a plug-in identifier, a status code,
* a message, and an optional exception. Clients may treat
* multi-status objects in a multi-status unaware way.
* </p>
*
* @return <code>true</code> for a multi-status,
* <code>false</code> otherwise
* @see #getChildren()
*/
virtual bool IsMultiStatus() const = 0;
/**
* Returns whether this status indicates everything is okay
* (neither info, warning, nor error).
*
* @return <code>true</code> if this status has severity
* <code>OK</code>, and <code>false</code> otherwise
*/
virtual bool IsOK() const = 0;
/**
* Returns whether the severity of this status matches the given
* severity mask. Note that a status with severity <code>OK_TYPE</code>
* will never match; use <code>isOK</code> instead to detect
* a status with a severity of <code>OK</code>.
*
* @param severityMask a mask formed by bitwise or'ing severity mask
* constants (<code>ERROR_TYPE</code>, <code>WARNING_TYPE</code>,
* <code>INFO_TYPE</code>, <code>CANCEL_TYPE</code>)
* @return <code>true</code> if there is at least one match,
* <code>false</code> if there are no matches
* @see #getSeverity()
* @see #CANCEL_TYPE
* @see #ERROR_TYPE
* @see #WARNING_TYPE
* @see #INFO_TYPE
*/
virtual bool Matches(const Severities& severityMask) const = 0;
};
}
BERRY_DECLARE_OPERATORS_FOR_FLAGS(berry::IStatus::Severities)
#endif /* BERRYISTATUS_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.solstice.common/src/berryMultiStatus.cpp b/BlueBerry/Bundles/org.blueberry.solstice.common/src/berryMultiStatus.cpp
index 5b330f3b07..d22ef2781a 100644
--- a/BlueBerry/Bundles/org.blueberry.solstice.common/src/berryMultiStatus.cpp
+++ b/BlueBerry/Bundles/org.blueberry.solstice.common/src/berryMultiStatus.cpp
@@ -1,106 +1,106 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryMultiStatus.h"
#include <sstream>
namespace berry
{
MultiStatus::MultiStatus(const std::string& pluginId, int code,
const std::vector<IStatus::Pointer>& newChildren,
const std::string& message, const std::exception& exception) :
Status(OK_TYPE, pluginId, code, message, exception), children(newChildren)
{
Severity maxSeverity = this->GetSeverity();
for (unsigned int i = 0; i < newChildren.size(); i++)
{
poco_assert(newChildren[i])
; Severity severity = newChildren[i]->GetSeverity();
if (severity > maxSeverity)
maxSeverity = severity;
}
this->SetSeverity(maxSeverity);
}
MultiStatus::MultiStatus(const std::string& pluginId, int code, const std::string& message, const std::exception& exception)
: Status(OK_TYPE, pluginId, code, message, exception)
{
}
void MultiStatus::Add(IStatus::Pointer status)
{
poco_assert(status);
children.push_back(status);
Severity newSev = status->GetSeverity();
if (newSev > this->GetSeverity())
{
this->SetSeverity(newSev);
}
}
void MultiStatus::AddAll(IStatus::Pointer status)
{
poco_assert(status);
std::vector<IStatus::Pointer> statuses(status->GetChildren());
for (unsigned int i = 0; i < statuses.size(); i++)
{
this->Add(statuses[i]);
}
}
std::vector<IStatus::Pointer> MultiStatus::GetChildren() const
{
return children;
}
bool MultiStatus::IsMultiStatus() const
{
return true;
}
void MultiStatus::Merge(IStatus::Pointer status)
{
poco_assert(status);
if (!status->IsMultiStatus())
{
this->Add(status);
}
else
{
this->AddAll(status);
}
}
std::string MultiStatus::ToString() const
{
std::stringstream buf;
buf << Status::ToString() << " children=[";
for (unsigned int i = 0; i < children.size(); i++)
{
if (i != 0)
{
buf << " ";
}
buf << children[i]->ToString();
}
buf << "]";
return buf.str();
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.solstice.common/src/berryMultiStatus.h b/BlueBerry/Bundles/org.blueberry.solstice.common/src/berryMultiStatus.h
index a79774dd15..29ef8541d0 100644
--- a/BlueBerry/Bundles/org.blueberry.solstice.common/src/berryMultiStatus.h
+++ b/BlueBerry/Bundles/org.blueberry.solstice.common/src/berryMultiStatus.h
@@ -1,119 +1,119 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYMULTISTATUS_H_
#define BERRYMULTISTATUS_H_
#include "berryStatus.h"
#include <org_blueberry_solstice_common_Export.h>
namespace berry {
/**
* A concrete multi-status implementation,
* suitable either for instantiating or subclassing.
* <p>
* This class can be used without OSGi running.
* </p>
*/
class BERRY_COMMON_RUNTIME MultiStatus : public Status {
private:
/** List of child statuses.
*/
std::vector<IStatus::Pointer> children;
public:
/**
* Creates and returns a new multi-status object with the given children.
*
* @param pluginId the unique identifier of the relevant plug-in
* @param code the plug-in-specific status code
* @param newChildren the list of children status objects
* @param message a human-readable message, localized to the
* current locale
* @param exception a low-level exception, or <code>null</code> if not
* applicable
*/
MultiStatus(const std::string& pluginId, int code, const std::vector<IStatus::Pointer>& newChildren, const std::string& message, const std::exception& exception = std::exception());
/**
* Creates and returns a new multi-status object with no children.
*
* @param pluginId the unique identifier of the relevant plug-in
* @param code the plug-in-specific status code
* @param message a human-readable message, localized to the
* current locale
* @param exception a low-level exception, or <code>null</code> if not
* applicable
*/
MultiStatus(const std::string& pluginId, int code, const std::string& message, const std::exception& exception = std::exception());
/**
* Adds the given status to this multi-status.
*
* @param status the new child status
*/
void Add(IStatus::Pointer status);
/**
* Adds all of the children of the given status to this multi-status.
* Does nothing if the given status has no children (which includes
* the case where it is not a multi-status).
*
* @param status the status whose children are to be added to this one
*/
void AddAll(IStatus::Pointer status);
/* (Intentionally not javadoc'd)
* Implements the corresponding method on <code>IStatus</code>.
*/
std::vector<IStatus::Pointer> GetChildren() const;
/* (Intentionally not javadoc'd)
* Implements the corresponding method on <code>IStatus</code>.
*/
bool IsMultiStatus() const;
/**
* Merges the given status into this multi-status.
* Equivalent to <code>add(status)</code> if the
* given status is not a multi-status.
* Equivalent to <code>addAll(status)</code> if the
* given status is a multi-status.
*
* @param status the status to merge into this one
* @see #add(IStatus)
* @see #addAll(IStatus)
*/
void Merge(IStatus::Pointer status);
/**
* Returns a string representation of the status, suitable
* for debugging purposes only.
*/
std::string ToString() const;
};
}
#endif /* BERRYMULTISTATUS_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.solstice.common/src/berrySafeRunner.cpp b/BlueBerry/Bundles/org.blueberry.solstice.common/src/berrySafeRunner.cpp
index db6b6ca5b0..5827348263 100644
--- a/BlueBerry/Bundles/org.blueberry.solstice.common/src/berrySafeRunner.cpp
+++ b/BlueBerry/Bundles/org.blueberry.solstice.common/src/berrySafeRunner.cpp
@@ -1,79 +1,79 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berrySafeRunner.h"
#include "berrySolsticeExceptions.h"
#include <typeinfo>
namespace berry
{
void SafeRunner::Run(ISafeRunnable::Pointer code)
{
poco_assert(code);
try
{
code->Run();
} catch (const std::exception& e)
{
HandleException(code, e);
} catch (...)
{
HandleException(code);
}
}
void SafeRunner::HandleException(ISafeRunnable::Pointer code,
const std::exception& e)
{
try {
dynamic_cast<const OperationCanceledException&>(e);
}
catch (const std::bad_cast& )
{
// TODO proper exception logging
// // try to obtain the correct plug-in id for the bundle providing the safe runnable
// Activator activator = Activator.getDefault();
// String pluginId = null;
// if (activator != null)
// pluginId = activator.getBundleId(code);
// if (pluginId == null)
// pluginId = IRuntimeConstants.PI_COMMON;
// String message = NLS.bind(CommonMessages.meta_pluginProblems, pluginId);
// IStatus status;
// if (e instanceof CoreException) {
// status = new MultiStatus(pluginId, IRuntimeConstants.PLUGIN_ERROR, message, e);
// ((MultiStatus) status).merge(((CoreException) e).getStatus());
// } else {
// status = new Status(IStatus.ERROR, pluginId, IRuntimeConstants.PLUGIN_ERROR, message, e);
// }
// // Make sure user sees the exception: if the log is empty, log the exceptions on stderr
// if (!RuntimeLog.isEmpty())
// {
// RuntimeLog.log(status);
// }
// else
// {
//e.printStackTrace();
std::cerr << e.what() << std::endl;
// }
}
code->HandleException(e);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.solstice.common/src/berrySafeRunner.h b/BlueBerry/Bundles/org.blueberry.solstice.common/src/berrySafeRunner.h
index 8a89154fd8..a7ec4fdec3 100644
--- a/BlueBerry/Bundles/org.blueberry.solstice.common/src/berrySafeRunner.h
+++ b/BlueBerry/Bundles/org.blueberry.solstice.common/src/berrySafeRunner.h
@@ -1,56 +1,56 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYSAFERUNNER_H_
#define BERRYSAFERUNNER_H_
#include <org_blueberry_solstice_common_Export.h>
#include "berryISafeRunnable.h"
namespace berry {
/**
* Runs the given ISafeRunnable in a protected mode: exceptions
* thrown in the runnable are logged and passed to the runnable's
* exception handler. Such exceptions are not rethrown by this method.
* <p>
* This class can be used without OSGi running.
* </p>
*/
class BERRY_COMMON_RUNTIME SafeRunner {
public:
/**
* Runs the given runnable in a protected mode. Exceptions
* thrown in the runnable are logged and passed to the runnable's
* exception handler. Such exceptions are not rethrown by this method.
*
* @param code the runnable to run
*/
static void Run(ISafeRunnable::Pointer code);
private:
static void HandleException(ISafeRunnable::Pointer code, const std::exception& e = std::exception());
};
}
#endif /* BERRYSAFERUNNER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.solstice.common/src/berrySolsticeExceptions.cpp b/BlueBerry/Bundles/org.blueberry.solstice.common/src/berrySolsticeExceptions.cpp
index 8fc532e3f5..49ad4ee77e 100644
--- a/BlueBerry/Bundles/org.blueberry.solstice.common/src/berrySolsticeExceptions.cpp
+++ b/BlueBerry/Bundles/org.blueberry.solstice.common/src/berrySolsticeExceptions.cpp
@@ -1,25 +1,25 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berrySolsticeExceptions.h"
#include <typeinfo>
namespace berry {
POCO_IMPLEMENT_EXCEPTION(OperationCanceledException, Poco::RuntimeException, "Operation canceled exception");
}
diff --git a/BlueBerry/Bundles/org.blueberry.solstice.common/src/berrySolsticeExceptions.h b/BlueBerry/Bundles/org.blueberry.solstice.common/src/berrySolsticeExceptions.h
index 2cc8dc66ca..650bcfc019 100644
--- a/BlueBerry/Bundles/org.blueberry.solstice.common/src/berrySolsticeExceptions.h
+++ b/BlueBerry/Bundles/org.blueberry.solstice.common/src/berrySolsticeExceptions.h
@@ -1,40 +1,40 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYSOLSTICEEXCEPTIONS_H_
#define BERRYSOLSTICEEXCEPTIONS_H_
#include <org_blueberry_solstice_common_Export.h>
#include <Poco/Exception.h>
namespace berry {
/**
* This exception is thrown to blow out of a long-running method
* when the user cancels it.
* <p>
* This class can be used without OSGi running.
* </p><p>
* This class is not intended to be subclassed by clients but
* may be instantiated.
* </p>
*/
POCO_DECLARE_EXCEPTION(BERRY_COMMON_RUNTIME, OperationCanceledException, Poco::RuntimeException);
}
#endif /* BERRYSOLSTICEEXCEPTIONS_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.solstice.common/src/berryStatus.cpp b/BlueBerry/Bundles/org.blueberry.solstice.common/src/berryStatus.cpp
index 27a8739c61..cd5d67dbad 100644
--- a/BlueBerry/Bundles/org.blueberry.solstice.common/src/berryStatus.cpp
+++ b/BlueBerry/Bundles/org.blueberry.solstice.common/src/berryStatus.cpp
@@ -1,157 +1,157 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryStatus.h"
#include "internal/berryIRuntimeConstants.h"
#include <sstream>
namespace berry
{
const std::vector<IStatus::Pointer> Status::theEmptyStatusArray = std::vector<IStatus::Pointer>();
const IStatus::Pointer Status::OK_STATUS(new Status(IStatus::OK_TYPE,
IRuntimeConstants::PI_RUNTIME(), 0, "OK"));
const IStatus::Pointer Status::CANCEL_STATUS(new Status(IStatus::CANCEL_TYPE,
IRuntimeConstants::PI_RUNTIME(), 1, ""));
Status::Status(const Severity& severity, const std::string& pluginId, int code,
const std::string& message, const std::exception& exception)
{
SetSeverity(severity);
SetPlugin(pluginId);
SetCode(code);
SetMessage(message);
SetException(exception);
}
Status::Status(const Severity& severity, const std::string& pluginId,
const std::string& message, const std::exception& exception)
{
SetSeverity(severity);
SetPlugin(pluginId);
SetMessage(message);
SetException(exception);
SetCode(0);
}
std::vector<IStatus::Pointer> Status::GetChildren() const
{
return theEmptyStatusArray;
}
int Status::GetCode() const
{
return code;
}
std::exception Status::GetException() const
{
return exception;
}
/* (Intentionally not javadoc'd)
* Implements the corresponding method on <code>IStatus</code>.
*/
std::string Status::GetMessage() const
{
return message;
}
std::string Status::GetPlugin() const
{
return pluginId;
}
IStatus::Severity Status::GetSeverity() const
{
return severity;
}
bool Status::IsMultiStatus() const
{
return false;
}
bool Status::IsOK() const
{
return severity == OK_TYPE;
}
bool Status::Matches(const Severities& severityMask) const
{
return (severity & severityMask) != 0;
}
void Status::SetCode(int code)
{
this->code = code;
}
void Status::SetException(const std::exception& exception)
{
this->exception = exception;
}
void Status::SetMessage(const std::string& message)
{
this->message = message;
}
void Status::SetPlugin(const std::string& pluginId)
{
poco_assert(!pluginId.empty())
; this->pluginId = pluginId;
}
void Status::SetSeverity(const Severity& severity)
{
this->severity = severity;
}
std::string Status::ToString() const
{
std::stringstream ss;
ss << "Status ";
switch (severity)
{
case OK_TYPE:
ss << "OK";
break;
case ERROR_TYPE:
ss << "ERROR";
break;
case WARNING_TYPE:
ss << "WARNING";
break;
case INFO_TYPE:
ss << "INFO";
break;
case CANCEL_TYPE:
ss << "CANCEL";
break;
default:
ss << "severity=" << severity;
}
ss << ": " << pluginId << " code=" << code << " " << message << " " << exception.what();
return ss.str();
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.solstice.common/src/berryStatus.h b/BlueBerry/Bundles/org.blueberry.solstice.common/src/berryStatus.h
index 864306a943..b406a26d47 100644
--- a/BlueBerry/Bundles/org.blueberry.solstice.common/src/berryStatus.h
+++ b/BlueBerry/Bundles/org.blueberry.solstice.common/src/berryStatus.h
@@ -1,216 +1,216 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYSTATUS_H_
#define BERRYSTATUS_H_
#include "berryIStatus.h"
#include <org_blueberry_solstice_common_Export.h>
namespace berry {
/**
* A concrete status implementation, suitable either for
* instantiating or subclassing.
* <p>
* This class can be used without OSGi running.
* </p>
*/
class BERRY_COMMON_RUNTIME Status : public IStatus {
private:
/**
* The severity. One of
* <ul>
* <li><code>CANCEL</code></li>
* <li><code>ERROR</code></li>
* <li><code>WARNING</code></li>
* <li><code>INFO</code></li>
* <li>or <code>OK</code> (0)</li>
* </ul>
*/
Severity severity;
/** Unique identifier of plug-in.
*/
std::string pluginId;
/** Plug-in-specific status code.
*/
int code;
/** Message, localized to the current locale.
*/
std::string message;
/** Wrapped exception, or <code>null</code> if none.
*/
std::exception exception;
/** Constant to avoid generating garbage.
*/
static const std::vector<IStatus::Pointer> theEmptyStatusArray;
public:
/**
* A standard OK status with an "ok" message.
*
* @since 3.0
*/
static const IStatus::Pointer OK_STATUS;
/**
* A standard CANCEL status with no message.
*
* @since 3.0
*/
static const IStatus::Pointer CANCEL_STATUS;
/**
* Creates a new status object. The created status has no children.
*
* @param severity the severity; one of <code>OK</code>, <code>ERROR</code>,
* <code>INFO</code>, <code>WARNING</code>, or <code>CANCEL</code>
* @param pluginId the unique identifier of the relevant plug-in
* @param code the plug-in-specific status code, or <code>OK</code>
* @param message a human-readable message, localized to the
* current locale
* @param exception a low-level exception, or <code>null</code> if not
* applicable
*/
Status(const Severity& severity, const std::string& pluginId, int code, const std::string& message, const std::exception& exception = std::exception());
/**
* Simplified constructor of a new status object; assumes that code is <code>OK</code>.
* The created status has no children.
*
* @param severity the severity; one of <code>OK</code>, <code>ERROR</code>,
* <code>INFO</code>, <code>WARNING</code>, or <code>CANCEL</code>
* @param pluginId the unique identifier of the relevant plug-in
* @param message a human-readable message, localized to the
* current locale
* @param exception a low-level exception, or <code>null</code> if not
* applicable
*
* @since org.eclipse.equinox.common 3.3
*/
Status(const Severity& severity, const std::string& pluginId, const std::string& message, const std::exception& exception = std::exception());
/* (Intentionally not javadoc'd)
* Implements the corresponding method on <code>IStatus</code>.
*/
std::vector<IStatus::Pointer> GetChildren() const;
/* (Intentionally not javadoc'd)
* Implements the corresponding method on <code>IStatus</code>.
*/
int GetCode() const;
/* (Intentionally not javadoc'd)
* Implements the corresponding method on <code>IStatus</code>.
*/
std::exception GetException() const;
/* (Intentionally not javadoc'd)
* Implements the corresponding method on <code>IStatus</code>.
*/
std::string GetMessage() const;
/* (Intentionally not javadoc'd)
* Implements the corresponding method on <code>IStatus</code>.
*/
std::string GetPlugin() const;
/* (Intentionally not javadoc'd)
* Implements the corresponding method on <code>IStatus</code>.
*/
Severity GetSeverity() const;
/* (Intentionally not javadoc'd)
* Implements the corresponding method on <code>IStatus</code>.
*/
bool IsMultiStatus() const;
/* (Intentionally not javadoc'd)
* Implements the corresponding method on <code>IStatus</code>.
*/
bool IsOK() const;
/* (Intentionally not javadoc'd)
* Implements the corresponding method on <code>IStatus</code>.
*/
bool Matches(const Severities& severityMask) const;
protected:
/**
* Sets the status code.
*
* @param code the plug-in-specific status code, or <code>OK</code>
*/
virtual void SetCode(int code);
/**
* Sets the exception.
*
* @param exception a low-level exception, or <code>null</code> if not
* applicable
*/
virtual void SetException(const std::exception& exception);
/**
* Sets the message. If null is passed, message is set to an empty
* string.
*
* @param message a human-readable message, localized to the
* current locale
*/
virtual void SetMessage(const std::string& message);
/**
* Sets the plug-in id.
*
* @param pluginId the unique identifier of the relevant plug-in
*/
virtual void SetPlugin(const std::string& pluginId);
/**
* Sets the severity.
*
* @param severity the severity; one of <code>OK</code>, <code>ERROR</code>,
* <code>INFO</code>, <code>WARNING</code>, or <code>CANCEL</code>
*/
virtual void SetSeverity(const Severity& severity);
public:
/**
* Returns a string representation of the status, suitable
* for debugging purposes only.
*/
std::string ToString() const;
};
}
#endif /* BERRYSTATUS_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.solstice.common/src/internal/berryIRuntimeConstants.cpp b/BlueBerry/Bundles/org.blueberry.solstice.common/src/internal/berryIRuntimeConstants.cpp
index 88177429af..7dc8b0507e 100644
--- a/BlueBerry/Bundles/org.blueberry.solstice.common/src/internal/berryIRuntimeConstants.cpp
+++ b/BlueBerry/Bundles/org.blueberry.solstice.common/src/internal/berryIRuntimeConstants.cpp
@@ -1,36 +1,36 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryIRuntimeConstants.h"
namespace berry {
const std::string& IRuntimeConstants::PI_RUNTIME()
{
static std::string pi_runtime = "org.blueberry.core.runtime";
return pi_runtime;
}
const std::string& IRuntimeConstants::PI_COMMON()
{
static std::string pi_common = "org.blueberry.solstice.common";
return pi_common;
}
const int IRuntimeConstants::PLUGIN_ERROR = 2;
const int IRuntimeConstants::FAILED_WRITE_METADATA = 5;
}
diff --git a/BlueBerry/Bundles/org.blueberry.solstice.common/src/internal/berryIRuntimeConstants.h b/BlueBerry/Bundles/org.blueberry.solstice.common/src/internal/berryIRuntimeConstants.h
index d9dc1afec5..27ebeff4ee 100644
--- a/BlueBerry/Bundles/org.blueberry.solstice.common/src/internal/berryIRuntimeConstants.h
+++ b/BlueBerry/Bundles/org.blueberry.solstice.common/src/internal/berryIRuntimeConstants.h
@@ -1,53 +1,53 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIRUNTIMECONSTANTS_H_
#define BERRYIRUNTIMECONSTANTS_H_
#include <string>
namespace berry {
struct IRuntimeConstants {
/**
* The unique identifier constant (value "<code>org.blueberry.core.runtime</code>")
* of the Core Runtime (pseudo-) plug-in.
*/
static const std::string& PI_RUNTIME(); // = "org.blueberry.core.runtime";
/**
* Name of this bundle.
*/
static const std::string& PI_COMMON(); // = "org.blueberry.solstice.common";
/**
* Status code constant (value 2) indicating an error occurred while running a plug-in.
*/
static const int PLUGIN_ERROR; // = 2;
/**
* Status code constant (value 5) indicating the platform could not write
* some of its metadata.
*/
static const int FAILED_WRITE_METADATA; // = 5;
};
}
#endif /* BERRYIRUNTIMECONSTANTS_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.solstice.common/src/internal/berryPluginActivator.cpp b/BlueBerry/Bundles/org.blueberry.solstice.common/src/internal/berryPluginActivator.cpp
index d83dd91519..b7ea2c325e 100644
--- a/BlueBerry/Bundles/org.blueberry.solstice.common/src/internal/berryPluginActivator.cpp
+++ b/BlueBerry/Bundles/org.blueberry.solstice.common/src/internal/berryPluginActivator.cpp
@@ -1,40 +1,40 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryPluginActivator.h"
#include <QtPlugin>
namespace berry {
org_blueberry_solstice_common_Activator::org_blueberry_solstice_common_Activator()
{
}
void org_blueberry_solstice_common_Activator::start(ctkPluginContext* context)
{
Q_UNUSED(context)
}
void org_blueberry_solstice_common_Activator::stop(ctkPluginContext* context)
{
Q_UNUSED(context)
}
}
Q_EXPORT_PLUGIN2(org_blueberry_solstice_common, berry::org_blueberry_solstice_common_Activator)
diff --git a/BlueBerry/Bundles/org.blueberry.solstice.common/src/internal/berryPluginActivator.h b/BlueBerry/Bundles/org.blueberry.solstice.common/src/internal/berryPluginActivator.h
index 9df7b6aad4..ab1e764aab 100644
--- a/BlueBerry/Bundles/org.blueberry.solstice.common/src/internal/berryPluginActivator.h
+++ b/BlueBerry/Bundles/org.blueberry.solstice.common/src/internal/berryPluginActivator.h
@@ -1,42 +1,42 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYPLUGINACTIVATOR_H
#define BERRYPLUGINACTIVATOR_H
#include <ctkPluginActivator.h>
namespace berry {
class org_blueberry_solstice_common_Activator :
public QObject, public ctkPluginActivator
{
Q_OBJECT
Q_INTERFACES(ctkPluginActivator)
public:
org_blueberry_solstice_common_Activator();
void start(ctkPluginContext* context);
void stop(ctkPluginContext* context);
};
typedef org_blueberry_solstice_common_Activator PluginActivator;
}
#endif // BERRYPLUGINACTIVATOR_H
diff --git a/BlueBerry/Bundles/org.blueberry.test/src/berryBlueBerryTestDriver.cpp b/BlueBerry/Bundles/org.blueberry.test/src/berryBlueBerryTestDriver.cpp
index e72d918edc..ff7395ff2a 100644
--- a/BlueBerry/Bundles/org.blueberry.test/src/berryBlueBerryTestDriver.cpp
+++ b/BlueBerry/Bundles/org.blueberry.test/src/berryBlueBerryTestDriver.cpp
@@ -1,82 +1,82 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryBlueBerryTestDriver.h"
#include "internal/berryTestRegistry.h"
#include <CppUnit/TestRunner.h>
namespace berry
{
BlueBerryTestDriver::BlueBerryTestDriver(const std::vector<
ITestDescriptor::Pointer>& descriptors,
bool uitests,
const std::string& testName,
bool wait) :
descriptors(descriptors), uitests(uitests), testName(testName), wait(wait)
{
}
int BlueBerryTestDriver::Run()
{
CppUnit::TestRunner runner;
unsigned int testCounter = 0;
for (std::vector<ITestDescriptor::Pointer>::iterator i = descriptors.begin(); i
!= descriptors.end(); ++i)
{
ITestDescriptor::Pointer descr(*i);
if (descr->IsUITest() == uitests)
{
CppUnit::Test* test = descr->CreateTest();
runner.addTest(descr->GetId(), test);
++testCounter;
}
}
if (testCounter == 0)
{
std::cout << "No " << (uitests ? "UI " : "") << "tests registered."
<< std::endl;
return 0;
}
std::vector<std::string> args;
args.push_back("BlueBerryTestDriver");
if (testName.empty())
args.push_back("-all");
else
args.push_back(testName);
if (wait)
args.push_back("-wait");
return runner.run(args) ? 0 : 1;
}
int BlueBerryTestDriver::Run(const std::string& pluginId, bool uitests)
{
TestRegistry testRegistry;
const std::vector<ITestDescriptor::Pointer>& tests = testRegistry.GetTestsForId(
pluginId);
BlueBerryTestDriver driver(tests, uitests);
return driver.Run();
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.test/src/berryBlueBerryTestDriver.h b/BlueBerry/Bundles/org.blueberry.test/src/berryBlueBerryTestDriver.h
index b82652cb7c..4ac1539e8e 100644
--- a/BlueBerry/Bundles/org.blueberry.test/src/berryBlueBerryTestDriver.h
+++ b/BlueBerry/Bundles/org.blueberry.test/src/berryBlueBerryTestDriver.h
@@ -1,55 +1,55 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYBLUEBERRYTESTDRIVER_H_
#define BERRYBLUEBERRYTESTDRIVER_H_
#include <org_blueberry_test_Export.h>
#include "berryITestDescriptor.h"
#include <vector>
namespace berry
{
/**
* A TestDriver for CppUnit that supports running tests inside BlueBerry as well as
* running standalone.
* Example call: TODO
*/
class BERRY_TEST_EXPORT BlueBerryTestDriver
{
public:
BlueBerryTestDriver(const std::vector<ITestDescriptor::Pointer>& descriptors, bool uitests = false, const std::string& testName="", bool wait=false);
int Run();
static int Run(const std::string& pluginId, bool uitests = false);
protected:
std::vector<ITestDescriptor::Pointer> descriptors;
bool uitests;
std::string testName;
bool wait;
};
}
#endif /* BERRYBLUEBERRYTESTDRIVER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.test/src/berryCoreTestApplication.cpp b/BlueBerry/Bundles/org.blueberry.test/src/berryCoreTestApplication.cpp
index 57a5040857..2ee99d1d3b 100644
--- a/BlueBerry/Bundles/org.blueberry.test/src/berryCoreTestApplication.cpp
+++ b/BlueBerry/Bundles/org.blueberry.test/src/berryCoreTestApplication.cpp
@@ -1,54 +1,54 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryCoreTestApplication.h"
#include <berryPlatform.h>
#include <berryLog.h>
#include "berryBlueBerryTestDriver.h"
namespace berry {
CoreTestApplication::CoreTestApplication()
{
}
CoreTestApplication::CoreTestApplication(const CoreTestApplication& other)
{
Q_UNUSED(other)
}
int CoreTestApplication::Start() {
std::string testPlugin;
try {
testPlugin = Platform::GetConfiguration().getString(Platform::ARG_TESTPLUGIN);
}
catch (const Poco::NotFoundException& /*e*/)
{
BERRY_ERROR << "You must specify a test plug-in id via " << Platform::ARG_TESTPLUGIN << "=<id>";
return 1;
}
return BlueBerryTestDriver::Run(testPlugin);
}
void CoreTestApplication::Stop() {
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.test/src/berryCoreTestApplication.h b/BlueBerry/Bundles/org.blueberry.test/src/berryCoreTestApplication.h
index 1149e91b5b..a732ad2547 100644
--- a/BlueBerry/Bundles/org.blueberry.test/src/berryCoreTestApplication.h
+++ b/BlueBerry/Bundles/org.blueberry.test/src/berryCoreTestApplication.h
@@ -1,43 +1,43 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYCORETESTAPPLICATION_H_
#define BERRYCORETESTAPPLICATION_H_
#include <berryIApplication.h>
#include <QObject>
namespace berry {
class CoreTestApplication : public QObject, public IApplication
{
Q_OBJECT
Q_INTERFACES(berry::IApplication)
public:
CoreTestApplication();
CoreTestApplication(const CoreTestApplication& other);
int Start();
void Stop();
};
}
#endif /* BERRYCORETESTAPPLICATION_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.test/src/berryITestDescriptor.h b/BlueBerry/Bundles/org.blueberry.test/src/berryITestDescriptor.h
index 33252c448e..88628d32a0 100644
--- a/BlueBerry/Bundles/org.blueberry.test/src/berryITestDescriptor.h
+++ b/BlueBerry/Bundles/org.blueberry.test/src/berryITestDescriptor.h
@@ -1,42 +1,42 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYITESTDESCRIPTOR_H_
#define BERRYITESTDESCRIPTOR_H_
#include <berryObject.h>
#include <berryMacros.h>
#include <CppUnit/Test.h>
namespace berry {
struct ITestDescriptor : public Object
{
berryInterfaceMacro(ITestDescriptor, berry)
virtual CppUnit::Test* CreateTest() = 0;
virtual std::string GetId() const = 0;
virtual std::string GetContributor() const = 0;
virtual std::string GetDescription() const = 0;
virtual bool IsUITest() const = 0;
};
}
#endif /* BERRYITESTDESCRIPTOR_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.test/src/harness/berryTestCase.cpp b/BlueBerry/Bundles/org.blueberry.test/src/harness/berryTestCase.cpp
index 207dd59458..58e26fdb86 100644
--- a/BlueBerry/Bundles/org.blueberry.test/src/harness/berryTestCase.cpp
+++ b/BlueBerry/Bundles/org.blueberry.test/src/harness/berryTestCase.cpp
@@ -1,73 +1,73 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryTestCase.h"
#include <berryConfig.h>
#include <berryLog.h>
#ifdef BLUEBERRY_DEBUG_SMARTPOINTER
#include <berryDebugUtil.h>
#endif
berry::TestCase::TestCase(const std::string& testName) :
CppUnit::TestCase(testName), m_LeakDetails(false),
m_IgnoreLeakage(false)
{
}
void berry::TestCase::LeakDetailsOn()
{
m_LeakDetails = true;
}
void berry::TestCase::IgnoreLeakingObjects()
{
BERRY_WARN << "Ignoring Leaking Objects!!";
m_IgnoreLeakage = true;
}
void berry::TestCase::DoSetUp()
{
}
void berry::TestCase::DoTearDown()
{
}
void berry::TestCase::setUp()
{
CppUnit::TestCase::setUp();
#ifdef BLUEBERRY_DEBUG_SMARTPOINTER
DebugUtil::ResetObjectSummary();
#endif
DoSetUp();
}
void berry::TestCase::tearDown()
{
CppUnit::TestCase::tearDown();
DoTearDown();
#ifdef BLUEBERRY_DEBUG_SMARTPOINTER
assert(m_IgnoreLeakage || !DebugUtil::PrintObjectSummary(m_LeakDetails));
#endif
m_LeakDetails = false;
}
diff --git a/BlueBerry/Bundles/org.blueberry.test/src/harness/berryTestCase.h b/BlueBerry/Bundles/org.blueberry.test/src/harness/berryTestCase.h
index 56f3f4fb60..ae30983225 100644
--- a/BlueBerry/Bundles/org.blueberry.test/src/harness/berryTestCase.h
+++ b/BlueBerry/Bundles/org.blueberry.test/src/harness/berryTestCase.h
@@ -1,84 +1,84 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYTESTCASE_H_
#define BERRYTESTCASE_H_
#include <CppUnit/TestCase.h>
#include <org_blueberry_test_Export.h>
namespace berry {
class BERRY_TEST_EXPORT TestCase : public CppUnit::TestCase
{
public:
TestCase(const std::string& testName);
/**
* Sets up the fixture, for example, open a network connection.
* This method is called before a test is executed.
* The default implementation does nothing.
* Subclasses may extend.
*/
virtual void DoSetUp();
/**
* Tears down the fixture, for example, close a network connection.
* This method is called after a test is executed.
* The default implementation closes all test windows, processing events both before
* and after doing so.
* Subclasses may extend.
*/
virtual void DoTearDown();
/**
* Clients should overwrite DoSetUp() instead of this method.
*/
void setUp();
/**
* Clients should overwrite DoSetUp() instead of this method.
*/
void tearDown();
protected:
/**
* Call this method in your unit test to enable detailed
* output about leaking berry::Object instances.
*/
void LeakDetailsOn();
/**
* Call this method to ignore leaking objects and to continue
* with the unit tests.
*/
void IgnoreLeakingObjects();
private:
bool m_LeakDetails;
bool m_IgnoreLeakage;
};
}
#endif /* BERRYTESTCASE_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.test/src/internal/berryPluginActivator.cpp b/BlueBerry/Bundles/org.blueberry.test/src/internal/berryPluginActivator.cpp
index 1ecac8bc98..784913bc0c 100644
--- a/BlueBerry/Bundles/org.blueberry.test/src/internal/berryPluginActivator.cpp
+++ b/BlueBerry/Bundles/org.blueberry.test/src/internal/berryPluginActivator.cpp
@@ -1,43 +1,43 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryPluginActivator.h"
#include "berryCoreTestApplication.h"
#include <QtPlugin>
namespace berry {
org_blueberry_test_Activator::org_blueberry_test_Activator()
{
}
void org_blueberry_test_Activator::start(ctkPluginContext* context)
{
BERRY_REGISTER_EXTENSION_CLASS(CoreTestApplication, context)
}
void org_blueberry_test_Activator::stop(ctkPluginContext* context)
{
Q_UNUSED(context)
}
}
Q_EXPORT_PLUGIN2(org_blueberry_test, berry::org_blueberry_test_Activator)
diff --git a/BlueBerry/Bundles/org.blueberry.test/src/internal/berryPluginActivator.h b/BlueBerry/Bundles/org.blueberry.test/src/internal/berryPluginActivator.h
index 86930800d0..2e5e2b14e8 100644
--- a/BlueBerry/Bundles/org.blueberry.test/src/internal/berryPluginActivator.h
+++ b/BlueBerry/Bundles/org.blueberry.test/src/internal/berryPluginActivator.h
@@ -1,42 +1,42 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYPLUGINACTIVATOR_H
#define BERRYPLUGINACTIVATOR_H
#include <ctkPluginActivator.h>
namespace berry {
class org_blueberry_test_Activator :
public QObject, public ctkPluginActivator
{
Q_OBJECT
Q_INTERFACES(ctkPluginActivator)
public:
org_blueberry_test_Activator();
void start(ctkPluginContext* context);
void stop(ctkPluginContext* context);
};
typedef org_blueberry_test_Activator PluginActivator;
}
#endif // BERRYPLUGINACTIVATOR_H
diff --git a/BlueBerry/Bundles/org.blueberry.test/src/internal/berryTestDescriptor.cpp b/BlueBerry/Bundles/org.blueberry.test/src/internal/berryTestDescriptor.cpp
index 07d2ded3b2..2903301e18 100644
--- a/BlueBerry/Bundles/org.blueberry.test/src/internal/berryTestDescriptor.cpp
+++ b/BlueBerry/Bundles/org.blueberry.test/src/internal/berryTestDescriptor.cpp
@@ -1,76 +1,76 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryTestDescriptor.h"
#include "berryTestRegistry.h"
#include <Poco/String.h>
Q_DECLARE_INTERFACE(CppUnit::Test, "CppUnit.Test")
namespace berry
{
TestDescriptor::TestDescriptor(IConfigurationElement::Pointer elem) :
configElem(elem)
{
}
CppUnit::Test* TestDescriptor::CreateTest()
{
CppUnit::Test* test = configElem->CreateExecutableExtension<CppUnit::Test> (
TestRegistry::ATT_CLASS);
if (test == 0)
{
// Try legacy BlueBerry manifests instead
test = configElem->CreateExecutableExtension<CppUnit::Test> (
TestRegistry::ATT_CLASS, TestRegistry::TEST_MANIFEST);
}
return test;
}
std::string TestDescriptor::GetId() const
{
std::string id;
configElem->GetAttribute(TestRegistry::ATT_ID, id);
return id;
}
std::string TestDescriptor::GetContributor() const
{
return configElem->GetContributor();
}
std::string TestDescriptor::GetDescription() const
{
std::string descr;
configElem->GetAttribute(TestRegistry::ATT_DESCRIPTION, descr);
return descr;
}
bool TestDescriptor::IsUITest() const
{
std::string isUi;
if (configElem->GetAttribute(TestRegistry::ATT_UITEST, isUi))
{
return !Poco::icompare(isUi, "true");
}
return false;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.test/src/internal/berryTestDescriptor.h b/BlueBerry/Bundles/org.blueberry.test/src/internal/berryTestDescriptor.h
index df21bbe00b..0151dd59d3 100644
--- a/BlueBerry/Bundles/org.blueberry.test/src/internal/berryTestDescriptor.h
+++ b/BlueBerry/Bundles/org.blueberry.test/src/internal/berryTestDescriptor.h
@@ -1,49 +1,49 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYTESTDESCRIPTOR_H_
#define BERRYTESTDESCRIPTOR_H_
#include "berryITestDescriptor.h"
#include <service/berryIConfigurationElement.h>
namespace berry {
class TestDescriptor : public ITestDescriptor
{
public:
berryObjectMacro(TestDescriptor)
TestDescriptor(IConfigurationElement::Pointer elem);
CppUnit::Test* CreateTest();
std::string GetId() const;
std::string GetContributor() const;
std::string GetDescription() const;
bool IsUITest() const;
private:
IConfigurationElement::Pointer configElem;
};
}
#endif /* BERRYTESTDESCRIPTOR_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.test/src/internal/berryTestRegistry.cpp b/BlueBerry/Bundles/org.blueberry.test/src/internal/berryTestRegistry.cpp
index 5d5b44a648..48d87fa351 100644
--- a/BlueBerry/Bundles/org.blueberry.test/src/internal/berryTestRegistry.cpp
+++ b/BlueBerry/Bundles/org.blueberry.test/src/internal/berryTestRegistry.cpp
@@ -1,63 +1,63 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryTestRegistry.h"
#include "berryTestDescriptor.h"
#include <berryPlatform.h>
#include <service/berryIExtensionPointService.h>
namespace berry
{
const std::string TestRegistry::TAG_TEST = "test";
const std::string TestRegistry::ATT_ID = "id";
const std::string TestRegistry::ATT_CLASS = "class";
const std::string TestRegistry::ATT_DESCRIPTION = "description";
const std::string TestRegistry::ATT_UITEST = "uitest";
const std::string TestRegistry::TEST_MANIFEST = "CppUnitTest";
TestRegistry::TestRegistry()
{
std::vector<IConfigurationElement::Pointer> elements(
Platform::GetExtensionPointService()->GetConfigurationElementsFor(
"org.blueberry.tests"));
for (std::vector<IConfigurationElement::Pointer>::iterator i =
elements.begin(); i != elements.end(); ++i)
{
if ((*i)->GetName() == TAG_TEST)
{
this->ReadTest(*i);
}
}
}
const std::vector<ITestDescriptor::Pointer>&
TestRegistry::GetTestsForId(const std::string& pluginid)
{
return mapIdToTests[pluginid];
}
void TestRegistry::ReadTest(IConfigurationElement::Pointer testElem)
{
ITestDescriptor::Pointer descriptor(new TestDescriptor(testElem));
poco_assert(descriptor->GetId() != "");
mapIdToTests[descriptor->GetContributor()].push_back(descriptor);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.test/src/internal/berryTestRegistry.h b/BlueBerry/Bundles/org.blueberry.test/src/internal/berryTestRegistry.h
index afe62cdfc1..900dc8e511 100644
--- a/BlueBerry/Bundles/org.blueberry.test/src/internal/berryTestRegistry.h
+++ b/BlueBerry/Bundles/org.blueberry.test/src/internal/berryTestRegistry.h
@@ -1,57 +1,57 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYTESTREGISTRY_H_
#define BERRYTESTREGISTRY_H_
#include <service/berryIConfigurationElement.h>
#include "berryITestDescriptor.h"
#include <Poco/HashMap.h>
#include <vector>
namespace berry {
class TestRegistry
{
public:
static const std::string TAG_TEST; // = "test"
static const std::string ATT_ID; // = "id"
static const std::string ATT_CLASS; // = "class"
static const std::string ATT_DESCRIPTION; // = "description"
static const std::string ATT_UITEST; // = "uitest"
static const std::string TEST_MANIFEST; // = "CppUnitTest"
TestRegistry();
const std::vector<ITestDescriptor::Pointer>& GetTestsForId(const std::string& pluginid);
protected:
void ReadTest(IConfigurationElement::Pointer testElem);
private:
Poco::HashMap<std::string, std::vector<ITestDescriptor::Pointer> > mapIdToTests;
};
}
#endif /* BERRYTESTREGISTRY_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.test/src/util/berryCallHistory.cpp b/BlueBerry/Bundles/org.blueberry.test/src/util/berryCallHistory.cpp
index 5326b53ef0..d368aaa22f 100644
--- a/BlueBerry/Bundles/org.blueberry.test/src/util/berryCallHistory.cpp
+++ b/BlueBerry/Bundles/org.blueberry.test/src/util/berryCallHistory.cpp
@@ -1,99 +1,99 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryCallHistory.h"
#include <algorithm>
namespace berry
{
CallHistory::CallHistory(/*Object target*/)
{
// classType = target.getClass();
}
void CallHistory::Add(const std::string& methodName)
{
TestMethodName(methodName);
methodList.push_back(methodName);
}
void CallHistory::Clear()
{
methodList.clear();
}
bool CallHistory::VerifyOrder(const std::vector<std::string>& testNames) const
throw(Poco::InvalidArgumentException)
{
std::size_t testIndex = 0;
std::size_t testLength = testNames.size();
if (testLength == 0)
return true;
for (std::size_t nX = 0; nX < methodList.size(); nX++)
{
const std::string& methodName = methodList[nX];
const std::string& testName = testNames[testIndex];
TestMethodName(testName);
if (testName == methodName)
++testIndex;
if (testIndex >= testLength)
return true;
}
return false;
}
bool CallHistory::Contains(const std::string& methodName) const
{
TestMethodName(methodName);
return std::find(methodList.begin(), methodList.end(), methodName) != methodList.end();
}
bool CallHistory::Contains(const std::vector<std::string>& methodNames) const
{
for (std::size_t i = 0; i < methodNames.size(); i++)
{
TestMethodName(methodNames[i]);
if (std::find(methodList.begin(), methodList.end(), methodNames[i]) == methodList.end())
return false;
}
return true;
}
bool CallHistory::IsEmpty() const
{
return methodList.empty();
}
void CallHistory::PrintTo(std::ostream& out) const
{
for (std::size_t i = 0; i < methodList.size(); i++)
out << methodList[i] << std::endl;
}
void CallHistory::TestMethodName(const std::string&) const
throw(Poco::InvalidArgumentException)
{
// Method[] methods = classType.getMethods();
// for (int i = 0; i < methods.length; i++)
// if (methods[i].getName().equals(methodName))
// return;
// throw new IllegalArgumentException("Target class (" + classType.getName()
// + ") does not contain method: " + methodName);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.test/src/util/berryCallHistory.h b/BlueBerry/Bundles/org.blueberry.test/src/util/berryCallHistory.h
index b5ed59567b..bdef94aa1d 100644
--- a/BlueBerry/Bundles/org.blueberry.test/src/util/berryCallHistory.h
+++ b/BlueBerry/Bundles/org.blueberry.test/src/util/berryCallHistory.h
@@ -1,135 +1,135 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYCALLHISTORY_H_
#define BERRYCALLHISTORY_H_
#include <org_blueberry_test_Export.h>
#include <berryObject.h>
#include <berryMacros.h>
#include <Poco/Exception.h>
#include <vector>
#include <ostream>
namespace berry {
/**
* <code>CallHistory</code> is used to record the invocation
* of methods within a target object. This is useful during
* lifecycle testing for an object.
* <p>
* To use <code>CallHistory</code> ..
* <ol>
* <li>Create a CallHistory in the target or pass one in.</li>
* <li>Invoke some test scenario. </li>
* <li>If a method is called on the target record the invocation
* in the call history</li>
* <li>Verify the call history after the test scenario is
* complete.</li>
* </ol>
* </p><p>
* Each <code>CallHistory</code> has a target which is used to
* verify the method names passed to the history. If an invalid
* name is passed an <code>IllegalArgumentException</code> will
* be thrown.
* </p>
*/
class BERRY_TEST_EXPORT CallHistory : public Object {
private:
std::vector<std::string> methodList;
// Class classType;
public:
berryObjectMacro(CallHistory)
/**
* Creates a new call history for an object.
*
* @param target the call history target.
*/
CallHistory(/*Object target*/);
/**
* Adds a method name to the call history.
*
* @param methodName the name of a method
*/
void Add(const std::string& methodName);
/**
* Clears the call history.
*/
void Clear();
/**
* Returns whether a list of methods have been called in
* order.
*
* @param testNames an array of the method names in the order they are expected
* @return <code>true</code> if the methods were called in order
*/
bool VerifyOrder(const std::vector<std::string>& testNames) const
throw(Poco::InvalidArgumentException);
/**
* Returns whether a method has been called.
*
* @param methodName a method name
* @return <code>true</code> if the method was called
*/
bool Contains(const std::string& methodName) const ;
/**
* Returns whether a list of methods were called.
*
* @param methodNames a list of methods
* @return <code>true</code> if the methods were called
*/
bool Contains(const std::vector<std::string>& methodNames) const;
/**
* Returns whether the list of methods called is empty.
*
* @return <code>true</code> iff the list of methods is empty
*/
bool IsEmpty() const;
/**
* Prints the call history to the console.
*/
void PrintTo(std::ostream& out) const;
private:
/**
* Throws an exception if the method name is invalid
* for the given target class.
*/
void TestMethodName(const std::string&) const throw(Poco::InvalidArgumentException);
};
}
#endif /* BERRYCALLHISTORY_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpContentView.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpContentView.cpp
index d5396d7e38..1cc53f232b 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpContentView.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpContentView.cpp
@@ -1,210 +1,210 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 <windows.h>
#endif
#include "berryHelpContentView.h"
#include "berryHelpPluginActivator.h"
#include "berryHelpEditor.h"
#include "berryHelpEditorInput.h"
#include "berryHelpWebView.h"
#include "berryQHelpEngineWrapper.h"
#include <berryIWorkbenchPage.h>
#include <QSortFilterProxyModel>
#include <QHelpContentWidget>
#include <QLayout>
#include <QMenu>
#include <QHeaderView>
#include <QDir>
namespace berry {
HelpContentWidget::HelpContentWidget()
: QTreeView(0)
, m_SortModel(new QSortFilterProxyModel(this))
, m_SourceModel(0)
{
header()->hide();
setUniformRowHeights(true);
connect(this, SIGNAL(activated(QModelIndex)),
this, SLOT(showLink(QModelIndex)));
m_SortModel->setDynamicSortFilter(true);
QTreeView::setModel(m_SortModel);
}
QModelIndex HelpContentWidget::indexOf(const QUrl &link)
{
QHelpContentModel *contentModel =
qobject_cast<QHelpContentModel*>(m_SourceModel);
if (!contentModel || link.scheme() != QLatin1String("qthelp"))
return QModelIndex();
m_syncIndex = QModelIndex();
for (int i=0; i<contentModel->rowCount(); ++i)
{
QHelpContentItem *itm =
contentModel->contentItemAt(contentModel->index(i, 0));
if (itm && itm->url().host() == link.host())
{
QString path = link.path();
if (path.startsWith(QLatin1Char('/')))
path = path.mid(1);
if (searchContentItem(contentModel, contentModel->index(i, 0), path))
{
return m_syncIndex;
}
}
}
return QModelIndex();
}
void HelpContentWidget::setModel(QAbstractItemModel *model)
{
m_SourceModel = model;
m_SortModel->setSourceModel(model);
}
bool HelpContentWidget::searchContentItem(QHelpContentModel *model,
const QModelIndex &parent, const QString &path)
{
QHelpContentItem *parentItem = model->contentItemAt(parent);
if (!parentItem)
return false;
if (QDir::cleanPath(parentItem->url().path()) == path)
{
m_syncIndex = m_SortModel->mapFromSource(parent);
return true;
}
for (int i=0; i<parentItem->childCount(); ++i)
{
if (searchContentItem(model, model->index(i, 0, parent), path))
return true;
}
return false;
}
void HelpContentWidget::showLink(const QModelIndex &index)
{
QHelpContentModel *contentModel = qobject_cast<QHelpContentModel*>(m_SourceModel);
if (!contentModel)
return;
QHelpContentItem *item = contentModel->contentItemAt(m_SortModel->mapToSource(index));
if (!item)
return;
QUrl url = item->url();
if (url.isValid())
emit linkActivated(url);
}
HelpContentView::HelpContentView()
: m_ContentWidget(0)
{
}
HelpContentView::~HelpContentView()
{
}
void HelpContentView::CreateQtPartControl(QWidget* parent)
{
if (m_ContentWidget == 0)
{
QVBoxLayout* verticalLayout = new QVBoxLayout(parent);
verticalLayout->setSpacing(0);
verticalLayout->setContentsMargins(0, 0, 0, 0);
QHelpEngineWrapper& helpEngine = HelpPluginActivator::getInstance()->getQHelpEngine();
m_ContentWidget = new HelpContentWidget();
m_ContentWidget->setModel(helpEngine.contentModel());
m_ContentWidget->sortByColumn(0, Qt::AscendingOrder);
connect(helpEngine.contentModel(), SIGNAL(contentsCreationStarted()),
this, SLOT(setContentsWidgetBusy()));
connect(helpEngine.contentModel(), SIGNAL(contentsCreated()),
this, SLOT(unsetContentsWidgetBusy()));
verticalLayout->addWidget(m_ContentWidget);
m_ContentWidget->setContextMenuPolicy(Qt::CustomContextMenu);
connect(m_ContentWidget, SIGNAL(customContextMenuRequested(QPoint)),
this, SLOT(showContextMenu(QPoint)));
connect(m_ContentWidget, SIGNAL(linkActivated(QUrl)), this, SLOT(linkActivated(QUrl)));
}
}
void HelpContentView::linkActivated(const QUrl &link)
{
IWorkbenchPage::Pointer page = this->GetSite()->GetPage();
HelpPluginActivator::linkActivated(page, link);
}
void HelpContentView::showContextMenu(const QPoint &pos)
{
if (!m_ContentWidget->indexAt(pos).isValid())
return;
QHelpContentModel* contentModel =
qobject_cast<QHelpContentModel*>(m_ContentWidget->model());
QHelpContentItem *itm =
contentModel->contentItemAt(m_ContentWidget->currentIndex());
QMenu menu;
QAction *curTab = menu.addAction(tr("Open Link"));
QAction *newTab = menu.addAction(tr("Open Link in New Tab"));
if (!HelpWebView::canOpenPage(itm->url().path()))
newTab->setEnabled(false);
menu.move(m_ContentWidget->mapToGlobal(pos));
QAction *action = menu.exec();
if (curTab == action)
{
linkActivated(itm->url());
}
else if (newTab == action)
{
IEditorInput::Pointer input(new HelpEditorInput(itm->url()));
this->GetSite()->GetPage()->OpenEditor(input, HelpEditor::EDITOR_ID);
}
}
void HelpContentView::SetFocus()
{
m_ContentWidget->setFocus();
}
void HelpContentView::setContentsWidgetBusy()
{
m_ContentWidget->setCursor(Qt::WaitCursor);
}
void HelpContentView::unsetContentsWidgetBusy()
{
m_ContentWidget->unsetCursor();
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpContentView.h b/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpContentView.h
index 79972c1ea1..9dfef768d6 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpContentView.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpContentView.h
@@ -1,99 +1,99 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYHELPCONTENTVIEW_H_
#define BERRYHELPCONTENTVIEW_H_
#include <berryQtViewPart.h>
#include <QTreeView>
class QSortFilterProxyModel;
class QHelpContentModel;
namespace berry {
class HelpContentWidget : public QTreeView
{
Q_OBJECT
public:
HelpContentWidget();
QModelIndex indexOf(const QUrl &link);
void setModel(QAbstractItemModel *model);
Q_SIGNALS:
/**
* This signal is emitted when a content item is activated and
* its associated \a link should be shown.
*/
void linkActivated(const QUrl &link);
private Q_SLOTS:
/**
* Returns the index of the content item with the \a link.
* An invalid index is returned if no such an item exists.
*/
void showLink(const QModelIndex &index);
private:
bool searchContentItem(QHelpContentModel* model,
const QModelIndex &parent, const QString &path);
QModelIndex m_syncIndex;
QSortFilterProxyModel* m_SortModel;
QAbstractItemModel* m_SourceModel;
};
class HelpContentView : public QtViewPart
{
Q_OBJECT
public:
HelpContentView();
~HelpContentView();
void SetFocus();
protected:
void CreateQtPartControl(QWidget* parent);
protected Q_SLOTS:
void linkActivated(const QUrl& link);
private Q_SLOTS:
void showContextMenu(const QPoint &pos);
void setContentsWidgetBusy();
void unsetContentsWidgetBusy();
private:
Q_DISABLE_COPY(HelpContentView)
HelpContentWidget* m_ContentWidget;
};
} // namespace berry
#endif /*BERRYHELPCONTENTVIEW_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpEditor.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpEditor.cpp
index 63de55b70a..0ba5a18a4d 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpEditor.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpEditor.cpp
@@ -1,328 +1,328 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryHelpEditor.h"
#include "berryHelpEditorInput.h"
#include "berryHelpPluginActivator.h"
#include "berryHelpPerspective.h"
#include "berryHelpWebView.h"
#include "berryQHelpEngineWrapper.h"
#include "berryHelpEditorFindWidget.h"
#include "berryHelpPluginActivator.h"
#include "berryQHelpEngineWrapper.h"
#include <berryUIException.h>
#include <berryPlatformUI.h>
#include <berryIWorkbenchPage.h>
#include <berryIWorkbenchPartConstants.h>
#include <QToolBar>
#include <QHelpEngine>
#include <QVBoxLayout>
namespace berry {
const std::string HelpEditor::EDITOR_ID = "org.blueberry.editors.help";
HelpEditor::HelpEditor()
: m_ToolBar(0)
, m_WebView(0)
{
}
HelpEditor::~HelpEditor()
{
// we need to wrap the RemovePartListener call inside a
// register/unregister block to prevent infinite recursion
// due to the destruction of temporary smartpointer to this
this->Register();
this->GetSite()->GetPage()->RemovePartListener(IPartListener::Pointer(this));
this->GetSite()->GetPage()->GetWorkbenchWindow()->RemovePerspectiveListener(IPerspectiveListener::Pointer(this));
this->UnRegister(false);
}
void HelpEditor::Init(berry::IEditorSite::Pointer site, berry::IEditorInput::Pointer input)
{
if (input.Cast<HelpEditorInput>().IsNull())
throw PartInitException("Invalid Input: Must be berry::HelpEditorInput");
this->SetSite(site);
site->GetPage()->AddPartListener(IPartListener::Pointer(this));
site->GetPage()->GetWorkbenchWindow()->AddPerspectiveListener(IPerspectiveListener::Pointer(this));
m_WebView = new HelpWebView(site, 0);
connect(m_WebView, SIGNAL(loadFinished(bool)), this, SLOT(InitializeTitle()));
this->DoSetInput(input);
}
void HelpEditor::CreateQtPartControl(QWidget* parent)
{
QVBoxLayout* verticalLayout = new QVBoxLayout(parent);
verticalLayout->setSpacing(0);
verticalLayout->setContentsMargins(0, 0, 0, 0);
m_ToolBar = new QToolBar(parent);
m_ToolBar->setMaximumHeight(32);
verticalLayout->addWidget(m_ToolBar);
m_WebView->setParent(parent);
m_WebView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
verticalLayout->addWidget(m_WebView);
m_FindWidget = new HelpEditorFindWidget(parent);
m_FindWidget->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Maximum);
verticalLayout->addWidget(m_FindWidget);
m_FindWidget->hide();
connect(m_FindWidget, SIGNAL(findNext()), this, SLOT(findNext()));
connect(m_FindWidget, SIGNAL(findPrevious()), this, SLOT(findPrevious()));
connect(m_FindWidget, SIGNAL(find(QString, bool)), this,
SLOT(find(QString, bool)));
connect(m_FindWidget, SIGNAL(escapePressed()), m_WebView, SLOT(setFocus()));
// Fill the editor toolbar
m_BackAction = m_ToolBar->addAction(QIcon(":/org.blueberry.ui.qt.help/go-previous.png"), "Go back",
m_WebView, SLOT(backward()));
m_ForwardAction = m_ToolBar->addAction(QIcon(":/org.blueberry.ui.qt.help/go-next.png"), "Go forward",
m_WebView, SLOT(forward()));
m_HomeAction = m_ToolBar->addAction(QIcon(":/org.blueberry.ui.qt.help/go-home.png"), "Go home",
m_WebView, SLOT(home()));
m_ToolBar->addSeparator();
m_FindAction = m_ToolBar->addAction(QIcon(":/org.blueberry.ui.qt.help/find.png"), "Find in text",
this, SLOT(ShowTextSearch()));
m_ToolBar->addSeparator();
m_ZoomIn = m_ToolBar->addAction(QIcon(":/org.blueberry.ui.qt.help/zoom-in.png"), "Zoom in", m_WebView, SLOT(scaleUp()));
m_ZoomOut = m_ToolBar->addAction(QIcon(":/org.blueberry.ui.qt.help/zoom-out.png"), "Zoom out", m_WebView, SLOT(scaleDown()));
m_ToolBar->addSeparator();
m_OpenHelpMode = m_ToolBar->addAction("Switch to Help mode", this, SLOT(OpenHelpPerspective()));
IPerspectiveDescriptor::Pointer currPersp = this->GetSite()->GetPage()->GetPerspective();
m_OpenHelpMode->setEnabled(!(currPersp.IsNotNull() && currPersp->GetId() == HelpPerspective::ID));
connect(m_WebView, SIGNAL(backwardAvailable(bool)), m_BackAction, SLOT(setEnabled(bool)));
connect(m_WebView, SIGNAL(forwardAvailable(bool)), m_ForwardAction, SLOT(setEnabled(bool)));
m_BackAction->setEnabled(false);
m_ForwardAction->setEnabled(false);
m_HomeAction->setEnabled(!HelpPluginActivator::getInstance()->getQHelpEngine().homePage().isEmpty());
connect(&HelpPluginActivator::getInstance()->getQHelpEngine(), SIGNAL(homePageChanged(QString)),
this, SLOT(HomePageChanged(QString)));
}
void HelpEditor::DoSetInput(IEditorInput::Pointer input)
{
if (input.IsNull())
{
// close editor
class CloseEditorRunnable : public Poco::Runnable
{
private:
IEditorPart::Pointer editor;
public:
CloseEditorRunnable(IEditorPart::Pointer editor)
: editor(editor)
{}
void run()
{
editor->GetSite()->GetPage()->CloseEditor(editor, false);
delete this;
}
};
Display::GetDefault()->AsyncExec(new CloseEditorRunnable(IEditorPart::Pointer(this)));
}
else
{
// an empty url represents the home page
HelpEditorInput::Pointer helpInput = input.Cast<HelpEditorInput>();
QString currHomePage = HelpPluginActivator::getInstance()->getQHelpEngine().homePage();
if (helpInput->GetUrl().isEmpty() && !currHomePage.isEmpty())
{
helpInput = HelpEditorInput::Pointer(new HelpEditorInput(currHomePage));
}
QtEditorPart::SetInput(helpInput);
m_WebView->setSource(helpInput->GetUrl());
}
}
void HelpEditor::SetInputWithNotify(IEditorInput::Pointer input)
{
DoSetInput(input);
FirePropertyChange(IWorkbenchPartConstants::PROP_INPUT);
}
void HelpEditor::SetInput(IEditorInput::Pointer input)
{
SetInputWithNotify(input);
}
void HelpEditor::HomePageChanged(const QString &page)
{
if (page.isEmpty())
{
m_HomeAction->setEnabled(false);
}
m_HomeAction->setEnabled(true);
if (this->GetEditorInput().Cast<HelpEditorInput>()->GetUrl().isEmpty())
{
IEditorInput::Pointer newInput(new HelpEditorInput(page));
DoSetInput(newInput);
}
}
void HelpEditor::OpenHelpPerspective()
{
PlatformUI::GetWorkbench()->ShowPerspective(HelpPerspective::ID, this->GetSite()->GetPage()->GetWorkbenchWindow());
}
void HelpEditor::InitializeTitle()
{
std::string title = m_WebView->title().toStdString();
this->SetPartName(title);
}
void HelpEditor::ShowTextSearch()
{
m_FindWidget->show();
}
void HelpEditor::SetFocus()
{
m_WebView->setFocus();
enableShortcuts();
}
QWebPage *HelpEditor::GetQWebPage() const
{
return m_WebView->page();
}
IPartListener::Events::Types HelpEditor::GetPartEventTypes() const
{
return IPartListener::Events::DEACTIVATED;
}
void HelpEditor::PartDeactivated(IWorkbenchPartReference::Pointer partRef)
{
if (partRef == GetSite()->GetPage()->GetReference(IWorkbenchPart::Pointer(this)))
disableShortcuts();
}
IPerspectiveListener::Events::Types HelpEditor::GetPerspectiveEventTypes() const
{
return IPerspectiveListener::Events::ACTIVATED | IPerspectiveListener::Events::DEACTIVATED;
}
void HelpEditor::PerspectiveActivated(SmartPointer<IWorkbenchPage> page, IPerspectiveDescriptor::Pointer perspective)
{
if (perspective->GetId() == HelpPerspective::ID)
{
m_OpenHelpMode->setEnabled(false);
}
}
void HelpEditor::PerspectiveDeactivated(SmartPointer<IWorkbenchPage> page, IPerspectiveDescriptor::Pointer perspective)
{
if (perspective->GetId() == HelpPerspective::ID)
{
m_OpenHelpMode->setEnabled(true);
}
}
void HelpEditor::findNext()
{
find(m_FindWidget->text(), true);
}
void HelpEditor::findPrevious()
{
find(m_FindWidget->text(), false);
}
void HelpEditor::find(const QString &ttf, bool forward)
{
bool found = findInWebPage(ttf, forward);
if (!found && ttf.isEmpty())
found = true; // the line edit is empty, no need to mark it red...
if (!m_FindWidget->isVisible())
m_FindWidget->show();
m_FindWidget->setPalette(found);
}
bool HelpEditor::findInWebPage(const QString &ttf, bool forward)
{
bool found = false;
QWebPage::FindFlags options;
if (!ttf.isEmpty())
{
if (!forward)
options |= QWebPage::FindBackward;
if (m_FindWidget->caseSensitive())
options |= QWebPage::FindCaseSensitively;
found = m_WebView->findText(ttf, options);
if (!found)
{
options |= QWebPage::FindWrapsAroundDocument;
found = m_WebView->findText(ttf, options);
}
}
// force highlighting of all other matches, also when empty (clear)
options = QWebPage::HighlightAllOccurrences;
if (m_FindWidget->caseSensitive())
options |= QWebPage::FindCaseSensitively;
m_WebView->findText(QLatin1String(""), options);
m_WebView->findText(ttf, options);
return found;
}
void HelpEditor::enableShortcuts()
{
m_BackAction->setShortcut(QKeySequence::Back);
m_ForwardAction->setShortcut(QKeySequence::Forward);
m_FindAction->setShortcut(QKeySequence::Find);
m_ZoomIn->setShortcut(QKeySequence::ZoomIn);
m_ZoomOut->setShortcut(QKeySequence::ZoomOut);
}
void HelpEditor::disableShortcuts()
{
m_BackAction->setShortcut(QKeySequence());
m_ForwardAction->setShortcut(QKeySequence());
m_FindAction->setShortcut(QKeySequence());
m_ZoomIn->setShortcut(QKeySequence());
m_ZoomOut->setShortcut(QKeySequence());
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpEditor.h b/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpEditor.h
index f0103adc15..35ce350be5 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpEditor.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpEditor.h
@@ -1,109 +1,109 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYHELPEDITOR_H_
#define BERRYHELPEDITOR_H_
#include <berryIReusableEditor.h>
#include <berryIPartListener.h>
#include <berryIPerspectiveListener.h>
#include <berryQtEditorPart.h>
class QToolBar;
class QWebPage;
namespace berry {
class HelpWebView;
class HelpEditorFindWidget;
class HelpEditor : public QtEditorPart, public IReusableEditor, public IPartListener, public IPerspectiveListener
{
Q_OBJECT
public:
berryObjectMacro(HelpEditor)
static const std::string EDITOR_ID;
HelpEditor();
~HelpEditor();
void Init(berry::IEditorSite::Pointer site, berry::IEditorInput::Pointer input);
void SetFocus();
void DoSave() {}
void DoSaveAs() {}
bool IsDirty() const { return false; }
bool IsSaveAsAllowed() const { return false; }
QWebPage* GetQWebPage() const;
IPartListener::Events::Types GetPartEventTypes() const;
void PartDeactivated(IWorkbenchPartReference::Pointer /*partRef*/);
IPerspectiveListener::Events::Types GetPerspectiveEventTypes() const;
void PerspectiveActivated(SmartPointer<IWorkbenchPage> page, IPerspectiveDescriptor::Pointer perspective);
void PerspectiveDeactivated(SmartPointer<IWorkbenchPage> page, IPerspectiveDescriptor::Pointer perspective);
protected:
void CreateQtPartControl(QWidget* parent);
void DoSetInput(IEditorInput::Pointer input);
void SetInputWithNotify(IEditorInput::Pointer input);
void SetInput(IEditorInput::Pointer input);
private Q_SLOTS:
void HomePageChanged(const QString& page);
void OpenHelpPerspective();
void InitializeTitle();
void ShowTextSearch();
void findNext();
void findPrevious();
void find(const QString& ttf, bool forward);
private:
bool findInWebPage(const QString& ttf, bool forward);
void enableShortcuts();
void disableShortcuts();
private:
Q_DISABLE_COPY(HelpEditor)
QToolBar* m_ToolBar;
HelpWebView* m_WebView;
HelpEditorFindWidget* m_FindWidget;
QAction* m_BackAction;
QAction* m_ForwardAction;
QAction* m_FindAction;
QAction* m_ZoomIn;
QAction* m_ZoomOut;
QAction* m_OpenHelpMode;
QAction* m_HomeAction;
};
} // end namespace berry
#endif /*BERRYHELPEDITOR_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpEditorFindWidget.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpEditorFindWidget.cpp
index 75e4a9e024..13e3c9f6e9 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpEditorFindWidget.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpEditorFindWidget.cpp
@@ -1,168 +1,168 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryHelpEditorFindWidget.h"
#include <QApplication>
#include <QCheckBox>
#include <QHideEvent>
#include <QKeyEvent>
#include <QLabel>
#include <QLayout>
#include <QLineEdit>
#include <QToolButton>
namespace berry {
HelpEditorFindWidget::HelpEditorFindWidget(QWidget *parent)
: QWidget(parent)
, appPalette(qApp->palette())
{
installEventFilter(this);
QHBoxLayout *hboxLayout = new QHBoxLayout(this);
QString resourcePath = QLatin1String(":/org.blueberry.ui.qt.help");
#ifndef Q_OS_MAC
hboxLayout->setMargin(0);
hboxLayout->setSpacing(6);
#endif
toolClose = setupToolButton(QLatin1String(""),
resourcePath + QLatin1String("/close.png"));
hboxLayout->addWidget(toolClose);
connect(toolClose, SIGNAL(clicked()), SLOT(hide()));
editFind = new QLineEdit(this);
hboxLayout->addWidget(editFind);
editFind->setMinimumSize(QSize(150, 0));
connect(editFind, SIGNAL(textChanged(QString)), this,
SLOT(textChanged(QString)));
connect(editFind, SIGNAL(returnPressed()), this, SIGNAL(findNext()));
connect(editFind, SIGNAL(textChanged(QString)), this, SLOT(updateButtons()));
toolPrevious = setupToolButton(tr("Previous"),
resourcePath + QLatin1String("/go-previous.png"));
connect(toolPrevious, SIGNAL(clicked()), this, SIGNAL(findPrevious()));
hboxLayout->addWidget(toolPrevious);
toolNext = setupToolButton(tr("Next"),
resourcePath + QLatin1String("/go-next.png"));
hboxLayout->addWidget(toolNext);
connect(toolNext, SIGNAL(clicked()), this, SIGNAL(findNext()));
checkCase = new QCheckBox(tr("Case Sensitive"), this);
hboxLayout->addWidget(checkCase);
setMinimumWidth(minimumSizeHint().width());
updateButtons();
}
HelpEditorFindWidget::~HelpEditorFindWidget()
{
}
void HelpEditorFindWidget::show()
{
QWidget::show();
editFind->selectAll();
editFind->setFocus(Qt::ShortcutFocusReason);
}
void HelpEditorFindWidget::showAndClear()
{
show();
editFind->clear();
}
QString HelpEditorFindWidget::text() const
{
return editFind->text();
}
bool HelpEditorFindWidget::caseSensitive() const
{
return checkCase->isChecked();
}
void HelpEditorFindWidget::setPalette(bool found)
{
QPalette palette = editFind->palette();
palette.setColor(QPalette::Active, QPalette::Base, found ? Qt::white
: QColor(255, 102, 102));
editFind->setPalette(palette);
}
void HelpEditorFindWidget::hideEvent(QHideEvent* event)
{
// TODO: remove this once webkit supports setting the palette
if (!event->spontaneous())
qApp->setPalette(appPalette);
}
void HelpEditorFindWidget::showEvent(QShowEvent* event)
{
// TODO: remove this once webkit supports setting the palette
if (!event->spontaneous())
{
QPalette p = appPalette;
p.setColor(QPalette::Inactive, QPalette::Highlight,
p.color(QPalette::Active, QPalette::Highlight));
p.setColor(QPalette::Inactive, QPalette::HighlightedText,
p.color(QPalette::Active, QPalette::HighlightedText));
qApp->setPalette(p);
}
}
void HelpEditorFindWidget::updateButtons()
{
const bool enable = !editFind->text().isEmpty();
toolNext->setEnabled(enable);
toolPrevious->setEnabled(enable);
}
void HelpEditorFindWidget::textChanged(const QString &text)
{
emit find(text, true);
}
bool HelpEditorFindWidget::eventFilter(QObject *object, QEvent *e)
{
if (e->type() == QEvent::KeyPress)
{
if ((static_cast<QKeyEvent*>(e))->key() == Qt::Key_Escape)
{
hide();
emit escapePressed();
}
}
return QWidget::eventFilter(object, e);
}
QToolButton* HelpEditorFindWidget::setupToolButton(const QString &text, const QString &icon)
{
QToolButton *toolButton = new QToolButton(this);
toolButton->setText(text);
toolButton->setAutoRaise(true);
toolButton->setIcon(QIcon(icon));
toolButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
return toolButton;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpEditorFindWidget.h b/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpEditorFindWidget.h
index 86f6f11d8c..8289396c32 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpEditorFindWidget.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpEditorFindWidget.h
@@ -1,84 +1,84 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYHELPEDITORFINDWIDGET_H
#define BERRYHELPEDITORFINDWIDGET_H
#include <QWidget>
class QCheckBox;
class QLabel;
class QLineEdit;
class QToolButton;
namespace berry {
class HelpEditorFindWidget : public QWidget
{
Q_OBJECT
public:
HelpEditorFindWidget(QWidget *parent = 0);
~HelpEditorFindWidget();
void show();
void showAndClear();
QString text() const;
bool caseSensitive() const;
void setPalette(bool found);
Q_SIGNALS:
void escapePressed();
void findNext();
void findPrevious();
void find(const QString &text, bool forward);
protected:
void hideEvent(QHideEvent* event);
void showEvent(QShowEvent * event);
private Q_SLOTS:
void updateButtons();
void textChanged(const QString &text);
private:
bool eventFilter(QObject *object, QEvent *e);
QToolButton* setupToolButton(const QString &text, const QString &icon);
private:
QPalette appPalette;
QLineEdit *editFind;
QCheckBox *checkCase;
QToolButton *toolNext;
QToolButton *toolClose;
QToolButton *toolPrevious;
};
} // end namespace berry
#endif // BERRYHELPEDITORFINDWIDGET_H
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpEditorInput.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpEditorInput.cpp
index c8bc4279c5..7868f4490f 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpEditorInput.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpEditorInput.cpp
@@ -1,59 +1,59 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryHelpEditorInput.h"
#include <berryPlatform.h>
namespace berry
{
HelpEditorInput::HelpEditorInput(const QUrl &url)
: url(url)
{
}
bool HelpEditorInput::Exists() const
{
return !url.isEmpty();
}
std::string HelpEditorInput::GetName() const
{
if (url.isEmpty()) return "Untitled";
return url.toString().toStdString();
}
std::string HelpEditorInput::GetToolTipText() const
{
return url.toString().toStdString();
}
bool HelpEditorInput::operator==(const berry::Object* o) const
{
if (const HelpEditorInput* input = dynamic_cast<const HelpEditorInput*>(o))
return this->url == input->url;
return false;
}
QUrl HelpEditorInput::GetUrl() const
{
return url;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpEditorInput.h b/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpEditorInput.h
index 0c20ed37d0..1a5aa022a7 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpEditorInput.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpEditorInput.h
@@ -1,49 +1,49 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYHELPEDITORINPUT_H_
#define BERRYHELPEDITORINPUT_H_
#include <berryIEditorInput.h>
#include <QUrl>
namespace berry
{
class HelpEditorInput : public berry::IEditorInput
{
public:
berryObjectMacro(HelpEditorInput)
HelpEditorInput(const QUrl& url = QUrl());
bool Exists() const;
std::string GetName() const;
std::string GetToolTipText() const;
bool operator==(const berry::Object*) const;
QUrl GetUrl() const;
private:
QUrl url;
};
}
#endif /*BERRYHELPEDITORINPUT_H_*/
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 784836e6cf..32a9be5003 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,325 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 <windows.h>
#endif
#include "berryHelpIndexView.h"
#include "berryHelpPluginActivator.h"
#include "berryHelpEditor.h"
#include "berryHelpEditorInput.h"
#include "berryHelpWebView.h"
#include "berryQHelpEngineWrapper.h"
#include "berryHelpTopicChooser.h"
#include <berryIWorkbenchPage.h>
#include <ctkSearchBox.h>
#include <QHelpIndexWidget>
#include <QLayout>
#include <QLabel>
#include <QMenu>
#include <QKeyEvent>
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<QHelpIndexModel*>(model());
if (!indexModel)
return;
QVariant v = indexModel->data(index, Qt::DisplayRole);
QString name;
if (v.isValid())
name = v.toString();
QMap<QString, QUrl> 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<QHelpIndexModel*>(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,QUrl>,QString)),
this, SLOT(linksActivated(QMap<QString,QUrl>,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<QKeyEvent*>(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<QContextMenuEvent*>(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<QMouseEvent*>(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<QKeyEvent*>(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<QHelpIndexModel*>(indexWidget->model());
if (model)
{
QString keyword = model->data(index, Qt::DisplayRole).toString();
QMap<QString, QUrl> 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<QString,QUrl>& 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());
}
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpIndexView.h b/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpIndexView.h
index 9cae0b66af..a8e22826fc 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpIndexView.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpIndexView.h
@@ -1,122 +1,122 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYHELPINDEXVIEW_H_
#define BERRYHELPINDEXVIEW_H_
#include <berryQtViewPart.h>
#include <QModelIndex>
#include <QListView>
class ctkSearchBox;
class QHelpIndexWidget;
namespace berry {
class HelpIndexWidget : public QListView
{
Q_OBJECT
Q_SIGNALS:
/**
* This signal is emitted when an item is activated and its
* associated \a link should be shown. To know where the link
* belongs to, the \a keyword is given as a second paremeter.
*/
void linkActivated(const QUrl &link, const QString &keyword);
/**
* This signal is emitted when the item representing the \a keyword
* is activated and the item has more than one link associated.
* The \a links consist of the document title and their URL.
*/
void linksActivated(const QMap<QString, QUrl> &links,
const QString &keyword);
public:
HelpIndexWidget();
public Q_SLOTS:
/**
* Filters the indices according to \a filter or \a wildcard.
* The item with the best match is set as current item.
*/
void filterIndices(const QString &filter,
const QString &wildcard = QString());
/**
* Activates the current item which will result eventually in
* the emitting of a linkActivated() or linksActivated()
* signal.
*/
void activateCurrentItem();
private Q_SLOTS:
void showLink(const QModelIndex &index);
};
class HelpIndexView : public QtViewPart
{
Q_OBJECT
public:
HelpIndexView();
~HelpIndexView();
void SetFocus();
protected:
void CreateQtPartControl(QWidget* parent);
void setSearchLineEditText(const QString &text);
QString searchLineEditText() const;
protected Q_SLOTS:
void linkActivated(const QUrl& link);
void linksActivated(const QMap<QString, QUrl> &links, const QString &keyword);
private Q_SLOTS:
void filterIndices(const QString &filter);
void enableSearchLineEdit();
void disableSearchLineEdit();
void setIndexWidgetBusy();
void unsetIndexWidgetBusy();
private:
bool eventFilter(QObject *obj, QEvent *e);
void focusInEvent(QFocusEvent *e);
void open(HelpIndexWidget *indexWidget, const QModelIndex &index);
Q_DISABLE_COPY(HelpIndexView)
ctkSearchBox* m_SearchLineEdit;
HelpIndexWidget* m_IndexWidget;
};
} // namespace berry
#endif /*BERRYHELPINDEXVIEW_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpPerspective.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpPerspective.cpp
index d993eaca49..2cd88ba83c 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpPerspective.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpPerspective.cpp
@@ -1,49 +1,49 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryHelpPerspective.h"
namespace berry {
const std::string HelpPerspective::ID = "org.blueberry.perspectives.help";
HelpPerspective::HelpPerspective()
{
}
void HelpPerspective::CreateInitialLayout(berry::IPageLayout::Pointer layout)
{
std::string editorArea = layout->GetEditorArea();
layout->AddView("org.blueberry.views.helpsearch",
berry::IPageLayout::LEFT, 0.3, editorArea);
berry::IFolderLayout::Pointer leftFolder =
layout->CreateFolder("lefttop", berry::IPageLayout::TOP, 0.65f, "org.blueberry.views.helpsearch");
leftFolder->AddView("org.blueberry.views.helpcontents");
leftFolder->AddView("org.blueberry.views.helpindex");
// Make every help related view unclosable
IViewLayout::Pointer lo = layout->GetViewLayout("org.blueberry.views.helpsearch");
lo->SetCloseable(false);
lo = layout->GetViewLayout("org.blueberry.views.helpcontents");
lo->SetCloseable(false);
lo = layout->GetViewLayout("org.blueberry.views.helpindex");
lo->SetCloseable(false);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpPerspective.h b/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpPerspective.h
index e722fa1202..c308c0906e 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpPerspective.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpPerspective.h
@@ -1,44 +1,44 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYHELPPERSPECTIVE_H_
#define BERRYHELPPERSPECTIVE_H_
#include <berryIPerspectiveFactory.h>
#include <QObject>
namespace berry {
class HelpPerspective : public QObject, public berry::IPerspectiveFactory
{
Q_OBJECT
Q_INTERFACES(berry::IPerspectiveFactory)
public:
static const std::string ID;
HelpPerspective();
void CreateInitialLayout(berry::IPageLayout::Pointer layout);
};
}
#endif /* BERRYHELPPERSPECTIVE_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpPluginActivator.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpPluginActivator.cpp
index c9dcf1a16b..518d869e50 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpPluginActivator.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpPluginActivator.cpp
@@ -1,465 +1,465 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryHelpPluginActivator.h"
#include "berryHelpContentView.h"
#include "berryHelpIndexView.h"
#include "berryHelpSearchView.h"
#include "berryHelpEditor.h"
#include "berryHelpEditorInput.h"
#include "berryHelpPerspective.h"
#include "berryQHelpEngineConfiguration.h"
#include "berryQHelpEngineWrapper.h"
#include <berryPlatformUI.h>
#include <service/event/ctkEventConstants.h>
#include <QtPlugin>
#include <QDir>
#include <QDateTime>
namespace berry {
class HelpPerspectiveListener : public IPerspectiveListener
{
public:
Events::Types GetPerspectiveEventTypes() const;
void PerspectiveOpened(SmartPointer<IWorkbenchPage> page, IPerspectiveDescriptor::Pointer perspective);
void PerspectiveChanged(SmartPointer<IWorkbenchPage> page, IPerspectiveDescriptor::Pointer perspective, const std::string &changeId);
};
class HelpWindowListener : public IWindowListener
{
public:
HelpWindowListener();
~HelpWindowListener();
void WindowClosed(IWorkbenchWindow::Pointer window);
void WindowOpened(IWorkbenchWindow::Pointer window);
private:
// We use the same perspective listener for every window
IPerspectiveListener::Pointer perspListener;
};
HelpPluginActivator* HelpPluginActivator::instance = 0;
HelpPluginActivator::HelpPluginActivator()
: pluginListener(0)
{
this->instance = this;
}
HelpPluginActivator::~HelpPluginActivator()
{
instance = 0;
}
void
HelpPluginActivator::start(ctkPluginContext* context)
{
BERRY_REGISTER_EXTENSION_CLASS(berry::HelpContentView, context)
BERRY_REGISTER_EXTENSION_CLASS(berry::HelpIndexView, context)
BERRY_REGISTER_EXTENSION_CLASS(berry::HelpSearchView, context)
BERRY_REGISTER_EXTENSION_CLASS(berry::HelpEditor, context)
BERRY_REGISTER_EXTENSION_CLASS(berry::HelpPerspective, context)
QFileInfo qhcInfo = context->getDataFile("qthelpcollection.qhc");
helpEngine.reset(new QHelpEngineWrapper(qhcInfo.absoluteFilePath()));
if (!helpEngine->setupData())
{
BERRY_ERROR << "QHelpEngine set-up failed: " << helpEngine->error().toStdString();
return;
}
helpEngineConfiguration.reset(new QHelpEngineConfiguration(context, *helpEngine.data()));
delete pluginListener;
pluginListener = new QCHPluginListener(context, helpEngine.data());
context->connectPluginListener(pluginListener, SLOT(pluginChanged(ctkPluginEvent)));
// register all QCH files from all the currently installed plugins
pluginListener->processPlugins();
helpEngine->initialDocSetupDone();
// Register a wnd listener which registers a perspective listener for each
// new window. The perspective listener opens the help home page in the window
// if no other help page is opened yet.
wndListener = IWindowListener::Pointer(new HelpWindowListener());
PlatformUI::GetWorkbench()->AddWindowListener(wndListener);
// Register an event handler for CONTEXTHELP_REQUESTED events
helpContextHandler.reset(new HelpContextHandler);
ctkDictionary helpHandlerProps;
helpHandlerProps.insert(ctkEventConstants::EVENT_TOPIC, "org/blueberry/ui/help/CONTEXTHELP_REQUESTED");
context->registerService<ctkEventHandler>(helpContextHandler.data(), helpHandlerProps);
}
void
HelpPluginActivator::stop(ctkPluginContext* /*context*/)
{
delete pluginListener;
pluginListener = 0;
if (PlatformUI::IsWorkbenchRunning())
{
PlatformUI::GetWorkbench()->RemoveWindowListener(wndListener);
}
wndListener = 0;
}
HelpPluginActivator *HelpPluginActivator::getInstance()
{
return instance;
}
QHelpEngineWrapper& HelpPluginActivator::getQHelpEngine()
{
return *helpEngine;
}
void HelpPluginActivator::linkActivated(IWorkbenchPage::Pointer page, const QUrl &link)
{
IEditorInput::Pointer input(new HelpEditorInput(link));
// see if an editor with the same input is already open
IEditorPart::Pointer reuseEditor = page->FindEditor(input);
if (reuseEditor)
{
// just activate it
page->Activate(reuseEditor);
}
else
{
// reuse the currently active editor, if it is a HelpEditor
reuseEditor = page->GetActiveEditor();
if (reuseEditor.IsNotNull() && page->GetReference(reuseEditor)->GetId() == HelpEditor::EDITOR_ID)
{
page->ReuseEditor(reuseEditor.Cast<IReusableEditor>(), input);
page->Activate(reuseEditor);
}
else
{
// get the last used HelpEditor instance
std::vector<IEditorReference::Pointer> editors =
page->FindEditors(IEditorInput::Pointer(0), HelpEditor::EDITOR_ID, IWorkbenchPage::MATCH_ID);
if (editors.empty())
{
// no HelpEditor is currently open, create a new one
page->OpenEditor(input, HelpEditor::EDITOR_ID);
}
else
{
// reuse an existing editor
reuseEditor = editors.front()->GetEditor(false);
page->ReuseEditor(reuseEditor.Cast<IReusableEditor>(), input);
page->Activate(reuseEditor);
}
}
}
}
QCHPluginListener::QCHPluginListener(ctkPluginContext* context, QHelpEngine* helpEngine)
: delayRegistration(true), context(context), helpEngine(helpEngine)
{}
void QCHPluginListener::processPlugins()
{
QMutexLocker lock(&mutex);
processPlugins_unlocked();
}
void QCHPluginListener::pluginChanged(const ctkPluginEvent& event)
{
QMutexLocker lock(&mutex);
if (delayRegistration)
{
this->processPlugins_unlocked();
return;
}
/* Only should listen for RESOLVED and UNRESOLVED events.
*
* When a plugin is updated the Framework will publish an UNRESOLVED and
* then a RESOLVED event which should cause the plugin to be removed
* and then added back into the registry.
*
* When a plugin is uninstalled the Framework should publish an UNRESOLVED
* event and then an UNINSTALLED event so the plugin will have been removed
* by the UNRESOLVED event before the UNINSTALLED event is published.
*/
QSharedPointer<ctkPlugin> plugin = event.getPlugin();
switch (event.getType())
{
case ctkPluginEvent::RESOLVED :
addPlugin(plugin);
break;
case ctkPluginEvent::UNRESOLVED :
removePlugin(plugin);
break;
}
}
void QCHPluginListener::processPlugins_unlocked()
{
if (!delayRegistration) return;
foreach (QSharedPointer<ctkPlugin> plugin, context->getPlugins())
{
if (isPluginResolved(plugin))
addPlugin(plugin);
else
removePlugin(plugin);
}
delayRegistration = false;
}
bool QCHPluginListener::isPluginResolved(QSharedPointer<ctkPlugin> plugin)
{
return (plugin->getState() & (ctkPlugin::RESOLVED | ctkPlugin::ACTIVE | ctkPlugin::STARTING | ctkPlugin::STOPPING)) != 0;
}
void QCHPluginListener::removePlugin(QSharedPointer<ctkPlugin> plugin)
{
// bail out if system plugin
if (plugin->getPluginId() == 0) return;
QFileInfo qchDirInfo = context->getDataFile("qch_files/" + QString::number(plugin->getPluginId()));
if (qchDirInfo.exists())
{
QDir qchDir(qchDirInfo.absoluteFilePath());
QStringList qchEntries = qchDir.entryList(QStringList("*.qch"));
QStringList qchFiles;
foreach(QString qchEntry, qchEntries)
{
qchFiles << qchDir.absoluteFilePath(qchEntry);
}
// unregister the cached qch files
foreach(QString qchFile, qchFiles)
{
QString namespaceName = QHelpEngineCore::namespaceName(qchFile);
if (namespaceName.isEmpty())
{
BERRY_ERROR << "Could not get the namespace for qch file " << qchFile.toStdString();
continue;
}
else
{
if (!helpEngine->unregisterDocumentation(namespaceName))
{
BERRY_ERROR << "Unregistering qch namespace " << namespaceName.toStdString() << " failed: " << helpEngine->error().toStdString();
}
}
}
// clean the directory
foreach(QString qchEntry, qchEntries)
{
qchDir.remove(qchEntry);
}
}
}
void QCHPluginListener::addPlugin(QSharedPointer<ctkPlugin> plugin)
{
// bail out if system plugin
if (plugin->getPluginId() == 0) return;
QFileInfo qchDirInfo = context->getDataFile("qch_files/" + QString::number(plugin->getPluginId()));
QUrl location(plugin->getLocation());
QFileInfo pluginFileInfo(location.toLocalFile());
if (!qchDirInfo.exists() || qchDirInfo.lastModified() < pluginFileInfo.lastModified())
{
removePlugin(plugin);
if (!qchDirInfo.exists())
{
QDir().mkpath(qchDirInfo.absoluteFilePath());
}
QStringList localQCHFiles;
QStringList resourceList = plugin->findResources("/", "*.qch", true);
foreach(QString resource, resourceList)
{
QByteArray content = plugin->getResource(resource);
QFile localFile(qchDirInfo.absoluteFilePath() + "/" + resource.section('/', -1));
localFile.open(QIODevice::WriteOnly);
localFile.write(content);
localFile.close();
if (localFile.error() != QFile::NoError)
{
BERRY_WARN << "Error writing " << localFile.fileName().toStdString()
<< ": " << localFile.errorString().toStdString();
}
else
{
localQCHFiles << localFile.fileName();
}
}
foreach(QString qchFile, localQCHFiles)
{
if (!helpEngine->registerDocumentation(qchFile))
{
BERRY_ERROR << "Registering qch file " << qchFile.toStdString() << " failed: " << helpEngine->error().toStdString();
}
}
}
}
IPerspectiveListener::Events::Types HelpPerspectiveListener::GetPerspectiveEventTypes() const
{
return Events::OPENED | Events::CHANGED;
}
void HelpPerspectiveListener::PerspectiveOpened(SmartPointer<IWorkbenchPage> page, IPerspectiveDescriptor::Pointer perspective)
{
// if no help editor is opened, open one showing the home page
if (perspective->GetId() == HelpPerspective::ID &&
page->FindEditors(IEditorInput::Pointer(0), HelpEditor::EDITOR_ID, IWorkbenchPage::MATCH_ID).empty())
{
IEditorInput::Pointer input(new HelpEditorInput());
page->OpenEditor(input, HelpEditor::EDITOR_ID);
}
}
void HelpPerspectiveListener::PerspectiveChanged(SmartPointer<IWorkbenchPage> page, IPerspectiveDescriptor::Pointer perspective, const std::string &changeId)
{
if (perspective->GetId() == HelpPerspective::ID && changeId == IWorkbenchPage::CHANGE_RESET)
{
PerspectiveOpened(page, perspective);
}
}
HelpWindowListener::HelpWindowListener()
: perspListener(new HelpPerspectiveListener())
{
// Register perspective listener for already opened windows
typedef std::vector<IWorkbenchWindow::Pointer> WndVec;
WndVec windows = PlatformUI::GetWorkbench()->GetWorkbenchWindows();
for (WndVec::iterator i = windows.begin(); i != windows.end(); ++i)
{
(*i)->AddPerspectiveListener(perspListener);
}
}
HelpWindowListener::~HelpWindowListener()
{
typedef std::vector<IWorkbenchWindow::Pointer> WndVec;
WndVec windows = PlatformUI::GetWorkbench()->GetWorkbenchWindows();
for (WndVec::iterator i = windows.begin(); i != windows.end(); ++i)
{
(*i)->RemovePerspectiveListener(perspListener);
}
}
void HelpWindowListener::WindowClosed(IWorkbenchWindow::Pointer window)
{
window->RemovePerspectiveListener(perspListener);
}
void HelpWindowListener::WindowOpened(IWorkbenchWindow::Pointer window)
{
window->AddPerspectiveListener(perspListener);
}
void HelpContextHandler::handleEvent(const ctkEvent &event)
{
struct _runner : public Poco::Runnable
{
_runner(const ctkEvent& ev) : ev(ev) {}
void run()
{
QUrl helpUrl;
if (ev.containsProperty("url"))
{
helpUrl = QUrl(ev.getProperty("url").toString());
}
else
{
helpUrl = contextUrl();
}
HelpPluginActivator::linkActivated(PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage(),
helpUrl);
delete this;
}
QUrl contextUrl() const
{
berry::IWorkbench* currentWorkbench = berry::PlatformUI::GetWorkbench();
if (currentWorkbench)
{
berry::IWorkbenchWindow::Pointer currentWorkbenchWindow = currentWorkbench->GetActiveWorkbenchWindow();
if (currentWorkbenchWindow)
{
berry::IWorkbenchPage::Pointer currentPage = currentWorkbenchWindow->GetActivePage();
if (currentPage)
{
berry::IWorkbenchPart::Pointer currentPart = currentPage->GetActivePart();
if (currentPart)
{
QString pluginID = QString::fromStdString(currentPart->GetSite()->GetPluginId());
QString viewID = QString::fromStdString(currentPart->GetSite()->GetId());
QString loc = "qthelp://" + pluginID + "/bundle/%1.html";
QHelpEngineWrapper& helpEngine = HelpPluginActivator::getInstance()->getQHelpEngine();
QUrl contextUrl(loc.arg(viewID.replace(".", "_")));
QUrl url = helpEngine.findFile(contextUrl);
if (url.isValid()) return url;
else
{
BERRY_INFO << "Context help url invalid: " << contextUrl.toString().toStdString();
}
// Try to get the index.html file of the plug-in contributing the
// currently active part.
QUrl pluginIndexUrl(loc.arg("index"));
url = helpEngine.findFile(pluginIndexUrl);
if (url != pluginIndexUrl)
{
// Use the default page instead of another index.html
// (merged via the virtual folder property).
url = QUrl();
}
return url;
}
}
}
}
return QUrl();
}
ctkEvent ev;
};
// sync with GUI thread
Display::GetDefault()->AsyncExec(new _runner(event));
}
}
Q_EXPORT_PLUGIN2(org_blueberry_ui_qt_help, berry::HelpPluginActivator)
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpPluginActivator.h b/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpPluginActivator.h
index 29bef3012a..7fdd7b8dce 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpPluginActivator.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpPluginActivator.h
@@ -1,117 +1,117 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYLOGPLUGIN_H_
#define BERRYLOGPLUGIN_H_
#include <ctkPluginActivator.h>
#include <service/event/ctkEvent.h>
#include <service/event/ctkEventHandler.h>
#include <QScopedPointer>
#include <QMutex>
#include <berryIWorkbenchPage.h>
#include <berryIWindowListener.h>
class QHelpEngine;
namespace berry {
class QHelpEngineConfiguration;
class QHelpEngineWrapper;
class QCHPluginListener;
class HelpContextHandler : public QObject, public ctkEventHandler
{
Q_OBJECT
Q_INTERFACES(ctkEventHandler)
public:
void handleEvent(const ctkEvent& event);
};
class HelpPluginActivator : public QObject, public ctkPluginActivator
{
Q_OBJECT
Q_INTERFACES(ctkPluginActivator)
public:
HelpPluginActivator();
~HelpPluginActivator();
void start(ctkPluginContext* context);
void stop(ctkPluginContext* context);
static HelpPluginActivator* getInstance();
static void linkActivated(IWorkbenchPage::Pointer page, const QUrl &link);
QHelpEngineWrapper& getQHelpEngine();
private:
Q_DISABLE_COPY(HelpPluginActivator)
static HelpPluginActivator* instance;
QScopedPointer<QHelpEngineWrapper> helpEngine;
QScopedPointer<QHelpEngineConfiguration> helpEngineConfiguration;
QScopedPointer<HelpContextHandler> helpContextHandler;
QCHPluginListener* pluginListener;
IWindowListener::Pointer wndListener;
};
/**
* A listener for CTK plugin events. When plugins come and go we look to see
* if there are any qch files and update the QHelpEngine accordingly.
*/
class QCHPluginListener : public QObject {
Q_OBJECT
public:
QCHPluginListener(ctkPluginContext* context, QHelpEngine* helpEngine);
void processPlugins();
public Q_SLOTS:
void pluginChanged(const ctkPluginEvent& event);
private:
void processPlugins_unlocked();
bool isPluginResolved(QSharedPointer<ctkPlugin> plugin);
void removePlugin(QSharedPointer<ctkPlugin> plugin);
void addPlugin(QSharedPointer<ctkPlugin> plugin);
QMutex mutex;
bool delayRegistration;
ctkPluginContext* context;
QHelpEngine* helpEngine;
};
}
#endif /*BERRYLOGPLUGIN_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpSearchView.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpSearchView.cpp
index 087baada94..9a49913c4f 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpSearchView.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpSearchView.cpp
@@ -1,242 +1,242 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 <windows.h>
#endif
#include "berryHelpSearchView.h"
#include "berryHelpPluginActivator.h"
#include "berryQHelpEngineWrapper.h"
#include "berryHelpEditorInput.h"
#include "berryHelpEditor.h"
#include <QLayout>
#include <QMenu>
#include <QEvent>
#include <QMouseEvent>
#include <QTextBrowser>
#include <QClipboard>
#include <QHelpSearchQueryWidget>
#include <QHelpSearchResultWidget>
#include <QApplication>
namespace berry {
HelpSearchView::HelpSearchView()
: m_ZoomCount(0)
, m_Parent(0)
, m_SearchEngine(HelpPluginActivator::getInstance()->getQHelpEngine().searchEngine())
, m_ResultWidget(0)
, m_QueryWidget(0)
{
}
HelpSearchView::~HelpSearchView()
{
// prevent deletion of the widget
m_ResultWidget->setParent(0);
}
void HelpSearchView::CreateQtPartControl(QWidget* parent)
{
if (m_ResultWidget == 0)
{
m_Parent = parent;
QVBoxLayout* vLayout = new QVBoxLayout(parent);
// This will be lead to strange behavior when using multiple instances of this view
// because the QHelpSearchResultWidget instance is shared. The new view will
// reparent the widget.
m_ResultWidget = m_SearchEngine->resultWidget();
m_QueryWidget = new QHelpSearchQueryWidget();
vLayout->addWidget(m_QueryWidget);
vLayout->addWidget(m_ResultWidget);
connect(m_QueryWidget, SIGNAL(search()), this, SLOT(search()));
connect(m_ResultWidget, SIGNAL(requestShowLink(QUrl)), this,
SLOT(requestShowLink(QUrl)));
connect(m_SearchEngine, SIGNAL(searchingStarted()), this,
SLOT(searchingStarted()));
connect(m_SearchEngine, SIGNAL(searchingFinished(int)), this,
SLOT(searchingFinished(int)));
QTextBrowser* browser = qFindChild<QTextBrowser*>(m_ResultWidget);
if (browser) // Will be null if QtHelp was configured not to use CLucene.
{
browser->viewport()->installEventFilter(this);
browser->setContextMenuPolicy(Qt::CustomContextMenu);
connect(browser, SIGNAL(customContextMenuRequested(QPoint)),
this, SLOT(showContextMenu(QPoint)));
}
}
}
void HelpSearchView::SetFocus()
{
if (!(m_ResultWidget->hasFocus()))
{
m_QueryWidget->setFocus();
}
}
void HelpSearchView::zoomIn()
{
QTextBrowser* browser = qFindChild<QTextBrowser*>(m_ResultWidget);
if (browser && m_ZoomCount != 10)
{
m_ZoomCount++;
browser->zoomIn();
}
}
void HelpSearchView::zoomOut()
{
QTextBrowser* browser = qFindChild<QTextBrowser*>(m_ResultWidget);
if (browser && m_ZoomCount != -5)
{
m_ZoomCount--;
browser->zoomOut();
}
}
void HelpSearchView::resetZoom()
{
if (m_ZoomCount == 0)
return;
QTextBrowser* browser = qFindChild<QTextBrowser*>(m_ResultWidget);
if (browser)
{
browser->zoomOut(m_ZoomCount);
m_ZoomCount = 0;
}
}
void HelpSearchView::search() const
{
QList<QHelpSearchQuery> query = m_QueryWidget->query();
m_SearchEngine->search(query);
}
void HelpSearchView::searchingStarted()
{
m_Parent->setCursor(QCursor(Qt::WaitCursor));
}
void HelpSearchView::searchingFinished(int hits)
{
Q_UNUSED(hits)
m_Parent->unsetCursor();
//qApp->restoreOverrideCursor();
}
void HelpSearchView::requestShowLink(const QUrl &link)
{
HelpPluginActivator::linkActivated(this->GetSite()->GetPage(), link);
}
bool HelpSearchView::eventFilter(QObject* o, QEvent *e)
{
QTextBrowser* browser = qFindChild<QTextBrowser*>(m_ResultWidget);
if (browser && o == browser->viewport()
&& e->type() == QEvent::MouseButtonRelease)
{
QMouseEvent* me = static_cast<QMouseEvent*>(e);
QUrl link = m_ResultWidget->linkAt(me->pos());
if (!link.isEmpty() || link.isValid())
{
bool controlPressed = me->modifiers() & Qt::ControlModifier;
if((me->button() == Qt::LeftButton && controlPressed)
|| (me->button() == Qt::MidButton))
{
IEditorInput::Pointer input(new HelpEditorInput(link));
this->GetSite()->GetPage()->OpenEditor(input, HelpEditor::EDITOR_ID);
}
}
}
return QObject::eventFilter(o,e);
}
void HelpSearchView::showContextMenu(const QPoint& point)
{
QMenu menu;
QTextBrowser* browser = qFindChild<QTextBrowser*>(m_ResultWidget);
if (!browser)
return;
// QPoint point = browser->mapFromGlobal(pos);
// if (!browser->rect().contains(point, true))
// return;
QUrl link = browser->anchorAt(point);
QKeySequence keySeq(QKeySequence::Copy);
QAction *copyAction = menu.addAction(tr("&Copy") + QLatin1String("\t") +
keySeq.toString(QKeySequence::NativeText));
copyAction->setEnabled(QTextCursor(browser->textCursor()).hasSelection());
QAction *copyAnchorAction = menu.addAction(tr("Copy &Link Location"));
copyAnchorAction->setEnabled(!link.isEmpty() && link.isValid());
keySeq = QKeySequence(Qt::CTRL);
QAction *newTabAction = menu.addAction(tr("Open Link in New Tab") +
QLatin1String("\t") + keySeq.toString(QKeySequence::NativeText) +
QLatin1String("LMB"));
newTabAction->setEnabled(!link.isEmpty() && link.isValid());
menu.addSeparator();
keySeq = QKeySequence::SelectAll;
QAction *selectAllAction = menu.addAction(tr("Select All") +
QLatin1String("\t") + keySeq.toString(QKeySequence::NativeText));
QAction *usedAction = menu.exec(browser->mapToGlobal(point));
if (usedAction == copyAction)
{
QTextCursor cursor = browser->textCursor();
if (!cursor.isNull() && cursor.hasSelection())
{
QString selectedText = cursor.selectedText();
QMimeData *data = new QMimeData();
data->setText(selectedText);
QApplication::clipboard()->setMimeData(data);
}
}
else if (usedAction == copyAnchorAction)
{
QApplication::clipboard()->setText(link.toString());
}
else if (usedAction == newTabAction)
{
IEditorInput::Pointer input(new HelpEditorInput(link));
this->GetSite()->GetPage()->OpenEditor(input, HelpEditor::EDITOR_ID);
}
else if (usedAction == selectAllAction)
{
browser->selectAll();
}
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpSearchView.h b/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpSearchView.h
index a5e74bf8b5..58fb9ebafe 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpSearchView.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpSearchView.h
@@ -1,75 +1,75 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYHELPSEARCHVIEW_H_
#define BERRYHELPSEARCHVIEW_H_
#include <berryQtViewPart.h>
class QHelpSearchEngine;
class QHelpSearchResultWidget;
class QHelpSearchQueryWidget;
namespace berry {
class HelpSearchView : public QtViewPart
{
Q_OBJECT
public:
HelpSearchView();
~HelpSearchView();
void SetFocus();
protected:
void CreateQtPartControl(QWidget* parent);
private Q_SLOTS:
void zoomIn();
void zoomOut();
void resetZoom();
void search() const;
void searchingStarted();
void searchingFinished(int hits);
void showContextMenu(const QPoint& pos);
void requestShowLink(const QUrl& link);
private:
bool eventFilter(QObject* o, QEvent *e);
void keyPressEvent(QKeyEvent *keyEvent);
private:
Q_DISABLE_COPY(HelpSearchView)
int m_ZoomCount;
QWidget* m_Parent;
QHelpSearchEngine* m_SearchEngine;
QHelpSearchResultWidget* m_ResultWidget;
QHelpSearchQueryWidget* m_QueryWidget;
};
} // namespace berry
#endif /*BERRYHELPSEARCHVIEW_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpTopicChooser.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpTopicChooser.cpp
index d6127a659a..2547b376e5 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpTopicChooser.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpTopicChooser.cpp
@@ -1,60 +1,60 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryHelpTopicChooser.h"
namespace berry {
HelpTopicChooser::HelpTopicChooser(QWidget *parent, const QString &keyword,
const QMap<QString, QUrl> &links)
: QDialog(parent)
{
ui.setupUi(this);
ui.label->setText(tr("Choose a topic for <b>%1</b>:").arg(keyword));
QMap<QString, QUrl>::const_iterator it = links.constBegin();
for (; it != links.constEnd(); ++it)
{
ui.listWidget->addItem(it.key());
m_links.append(it.value());
}
if (ui.listWidget->count() != 0)
ui.listWidget->setCurrentRow(0);
ui.listWidget->setFocus();
connect(ui.buttonDisplay, SIGNAL(clicked()), this, SLOT(accept()));
connect(ui.buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
connect(ui.listWidget, SIGNAL(itemActivated(QListWidgetItem*)), this,
SLOT(accept()));
}
QUrl HelpTopicChooser::link() const
{
QListWidgetItem *item = ui.listWidget->currentItem();
if (!item)
return QUrl();
QString title = item->text();
if (title.isEmpty())
return QUrl();
const int row = ui.listWidget->row(item);
Q_ASSERT(row < m_links.count());
return m_links.at(row);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpTopicChooser.h b/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpTopicChooser.h
index b29d88de22..e7466d78bc 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpTopicChooser.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpTopicChooser.h
@@ -1,48 +1,48 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYHELPTOPICCHOOSER_H
#define BERRYHELPTOPICCHOOSER_H
#include <ui_berryHelpTopicChooser.h>
#include <QList>
#include <QMap>
#include <QString>
#include <QUrl>
#include <QDialog>
namespace berry {
class HelpTopicChooser : public QDialog
{
Q_OBJECT
public:
HelpTopicChooser(QWidget *parent, const QString &keyword,
const QMap<QString, QUrl> &links);
QUrl link() const;
private:
Ui::HelpTopicChooser ui;
QList<QUrl> m_links;
};
}
#endif // BERRYHELPTOPICCHOOSER_H
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpWebView.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpWebView.cpp
index ee1f1a5b05..21e3493c9d 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpWebView.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpWebView.cpp
@@ -1,527 +1,527 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryHelpWebView.h"
#include "berryHelpPluginActivator.h"
#include "berryHelpEditor.h"
#include "berryHelpEditorInput.h"
#include "berryQHelpEngineWrapper.h"
#include <berryIWorkbenchPage.h>
#include <QCoreApplication>
#include <QTimer>
#include <QStringBuilder>
#include <QTemporaryFile>
#include <QDesktopServices>
#include <QWheelEvent>
#include <QWebPage>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QNetworkRequest>
namespace berry {
struct ExtensionMap {
const char *extension;
const char *mimeType;
} extensionMap[] = {
{ ".bmp", "image/bmp" },
{ ".css", "text/css" },
{ ".gif", "image/gif" },
{ ".html", "text/html" },
{ ".htm", "text/html" },
{ ".ico", "image/x-icon" },
{ ".jpeg", "image/jpeg" },
{ ".jpg", "image/jpeg" },
{ ".js", "application/x-javascript" },
{ ".mng", "video/x-mng" },
{ ".pbm", "image/x-portable-bitmap" },
{ ".pgm", "image/x-portable-graymap" },
{ ".pdf", "application/pdf" },
{ ".png", "image/png" },
{ ".ppm", "image/x-portable-pixmap" },
{ ".rss", "application/rss+xml" },
{ ".svg", "image/svg+xml" },
{ ".svgz", "image/svg+xml" },
{ ".text", "text/plain" },
{ ".tif", "image/tiff" },
{ ".tiff", "image/tiff" },
{ ".txt", "text/plain" },
{ ".xbm", "image/x-xbitmap" },
{ ".xml", "text/xml" },
{ ".xpm", "image/x-xpm" },
{ ".xsl", "text/xsl" },
{ ".xhtml", "application/xhtml+xml" },
{ ".wml", "text/vnd.wap.wml" },
{ ".wmlc", "application/vnd.wap.wmlc" },
{ "about:blank", 0 },
{ 0, 0 }
};
const QString HelpWebView::m_PageNotFoundMessage =
QCoreApplication::translate("org.blueberry.ui.qt.help", "<title>Error 404...</title><div "
"align=\"center\"><br><br><h1>The page could not be found</h1><br><h3>'%1'"
"</h3></div>");
class HelpNetworkReply : public QNetworkReply
{
public:
HelpNetworkReply(const QNetworkRequest &request, const QByteArray &fileData,
const QString &mimeType);
virtual void abort();
virtual qint64 bytesAvailable() const
{ return data.length() + QNetworkReply::bytesAvailable(); }
protected:
virtual qint64 readData(char *data, qint64 maxlen);
private:
QByteArray data;
qint64 origLen;
};
HelpNetworkReply::HelpNetworkReply(const QNetworkRequest &request,
const QByteArray &fileData, const QString& mimeType)
: data(fileData), origLen(fileData.length())
{
setRequest(request);
setOpenMode(QIODevice::ReadOnly);
setHeader(QNetworkRequest::ContentTypeHeader, mimeType);
setHeader(QNetworkRequest::ContentLengthHeader, QByteArray::number(origLen));
QTimer::singleShot(0, this, SIGNAL(metaDataChanged()));
QTimer::singleShot(0, this, SIGNAL(readyRead()));
}
void HelpNetworkReply::abort()
{
}
qint64 HelpNetworkReply::readData(char *buffer, qint64 maxlen)
{
qint64 len = qMin(qint64(data.length()), maxlen);
if (len) {
memcpy(buffer, data.constData(), len);
data.remove(0, len);
}
if (!data.length())
QTimer::singleShot(0, this, SIGNAL(finished()));
return len;
}
class HelpNetworkAccessManager : public QNetworkAccessManager
{
public:
HelpNetworkAccessManager(QObject *parent);
protected:
virtual QNetworkReply *createRequest(Operation op,
const QNetworkRequest &request,
QIODevice *outgoingData = 0);
};
HelpNetworkAccessManager::HelpNetworkAccessManager(QObject *parent)
: QNetworkAccessManager(parent)
{
}
QNetworkReply *HelpNetworkAccessManager::createRequest(Operation /*op*/,
const QNetworkRequest &request,
QIODevice* /*outgoingData*/)
{
QString url = request.url().toString();
QHelpEngine& helpEngine = HelpPluginActivator::getInstance()->getQHelpEngine();
// TODO: For some reason the url to load is already wrong (passed from webkit)
// though the css file and the references inside should work that way. One
// possible problem might be that the css is loaded at the same level as the
// html, thus a path inside the css like (../images/foo.png) might cd out of
// the virtual folder
// if (!helpEngine.findFile(url).isValid()) {
// if (url.startsWith(AbstractHelpWebView::DocPath)) {
// QUrl newUrl = request.url();
// if (!newUrl.path().startsWith(QLatin1String("/qdoc/"))) {
// newUrl.setPath(QLatin1String("qdoc") + newUrl.path());
// url = newUrl.toString();
// }
// }
// }
const QString &mimeType = HelpWebView::mimeFromUrl(url);
const QByteArray &data = helpEngine.findFile(url).isValid()
? helpEngine.fileData(url)
: HelpWebView::m_PageNotFoundMessage.arg(url).toUtf8();
return new HelpNetworkReply(request, data, mimeType.isEmpty()
? QLatin1String("application/octet-stream") : mimeType);
}
class HelpPage : public QWebPage
{
public:
HelpPage(IEditorSite::Pointer editorSite, QObject *parent);
protected:
virtual QWebPage *createWindow(QWebPage::WebWindowType);
virtual void triggerAction(WebAction action, bool checked = false);
virtual bool acceptNavigationRequest(QWebFrame *frame,
const QNetworkRequest &request,
NavigationType type);
private:
IEditorSite::Pointer m_EditorSite;
bool m_CloseNewTabIfNeeded;
friend class HelpWebView;
QUrl m_loadingUrl;
Qt::MouseButtons m_pressedButtons;
Qt::KeyboardModifiers m_keyboardModifiers;
};
HelpPage::HelpPage(IEditorSite::Pointer editorSite, QObject *parent)
: QWebPage(parent)
, m_EditorSite(editorSite)
, m_CloseNewTabIfNeeded(false)
, m_pressedButtons(Qt::NoButton)
, m_keyboardModifiers(Qt::NoModifier)
{
}
QWebPage *HelpPage::createWindow(QWebPage::WebWindowType type)
{
IEditorInput::Pointer input(new HelpEditorInput(QUrl()));
IEditorPart::Pointer editorPart = m_EditorSite->GetPage()->OpenEditor(input, HelpEditor::EDITOR_ID);
HelpEditor::Pointer helpEditor = editorPart.Cast<HelpEditor>();
HelpPage* newPage = static_cast<HelpPage*>(helpEditor->GetQWebPage());
if (newPage)
newPage->m_CloseNewTabIfNeeded = m_CloseNewTabIfNeeded;
m_CloseNewTabIfNeeded = false;
return newPage;
}
void HelpPage::triggerAction(WebAction action, bool checked)
{
switch (action)
{
case OpenLinkInNewWindow:
m_CloseNewTabIfNeeded = true;
default: // fall through
QWebPage::triggerAction(action, checked);
break;
}
}
bool HelpPage::acceptNavigationRequest(QWebFrame *,
const QNetworkRequest &request,
QWebPage::NavigationType type)
{
const bool closeNewTab = m_CloseNewTabIfNeeded;
m_CloseNewTabIfNeeded = false;
// open in an external browser if a http link
const QUrl &url = request.url();
if (url.scheme() == QLatin1String("http"))
{
QDesktopServices::openUrl(url);
return false;
}
// const QUrl &url = request.url();
// if (AbstractHelpWebView::launchWithExternalApp(url))
// {
// if (closeNewTab)
// QMetaObject::invokeMethod(centralWidget, "closeTab");
// return false;
// }
// if (type == QWebPage::NavigationTypeLinkClicked
// && (m_keyboardModifiers & Qt::ControlModifier
// || m_pressedButtons == Qt::MidButton))
// {
// if (centralWidget->newEmptyTab())
// centralWidget->setSource(url);
// m_pressedButtons = Qt::NoButton;
// m_keyboardModifiers = Qt::NoModifier;
// return false;
// }
// m_loadingUrl = url; // because of async page loading, we will hit some kind
// of race condition while using a remote command, like a combination of
// SetSource; SyncContent. SetSource would be called and SyncContents shortly
// afterwards, but the page might not have finished loading and the old url
// would be returned.
return true;
}
// -- HelpWebView
HelpWebView::HelpWebView(IEditorSite::Pointer editorSite, QWidget *parent, qreal zoom)
: QWebView(parent)
//, parentWidget(parent)
, m_LoadFinished(false)
, m_HelpEngine(HelpPluginActivator::getInstance()->getQHelpEngine())
{
setAcceptDrops(false);
setPage(new HelpPage(editorSite, parent));
page()->setNetworkAccessManager(new HelpNetworkAccessManager(this));
QAction* action = pageAction(QWebPage::OpenLinkInNewWindow);
action->setText(tr("Open Link in New Tab"));
if (!parent)
action->setVisible(false);
pageAction(QWebPage::DownloadLinkToDisk)->setVisible(false);
pageAction(QWebPage::DownloadImageToDisk)->setVisible(false);
pageAction(QWebPage::OpenImageInNewWindow)->setVisible(false);
connect(pageAction(QWebPage::Copy), SIGNAL(changed()), this,
SLOT(actionChanged()));
connect(pageAction(QWebPage::Back), SIGNAL(changed()), this,
SLOT(actionChanged()));
connect(pageAction(QWebPage::Forward), SIGNAL(changed()), this,
SLOT(actionChanged()));
connect(page(), SIGNAL(linkHovered(QString,QString,QString)), this,
SIGNAL(highlighted(QString)));
connect(this, SIGNAL(urlChanged(QUrl)), this, SIGNAL(sourceChanged(QUrl)));
connect(this, SIGNAL(loadStarted()), this, SLOT(setLoadStarted()));
connect(this, SIGNAL(loadFinished(bool)), this, SLOT(setLoadFinished(bool)));
connect(page(), SIGNAL(printRequested(QWebFrame*)), this, SIGNAL(printRequested()));
setFont(viewerFont());
setTextSizeMultiplier(zoom == 0.0 ? 1.0 : zoom);
}
HelpWebView::~HelpWebView()
{
}
QFont HelpWebView::viewerFont() const
{
//if (m_HelpEngine.usesBrowserFont())
// return m_HelpEngine.browserFont();
QWebSettings *webSettings = QWebSettings::globalSettings();
return QFont(webSettings->fontFamily(QWebSettings::StandardFont),
webSettings->fontSize(QWebSettings::DefaultFontSize));
}
void HelpWebView::setViewerFont(const QFont &font)
{
QWebSettings *webSettings = settings();
webSettings->setFontFamily(QWebSettings::StandardFont, font.family());
webSettings->setFontSize(QWebSettings::DefaultFontSize, font.pointSize());
}
void HelpWebView::scaleUp()
{
setTextSizeMultiplier(textSizeMultiplier() + 0.1);
}
void HelpWebView::scaleDown()
{
setTextSizeMultiplier(qMax(0.0, textSizeMultiplier() - 0.1));
}
void HelpWebView::resetScale()
{
setTextSizeMultiplier(1.0);
}
bool HelpWebView::handleForwardBackwardMouseButtons(QMouseEvent *e)
{
if (e->button() == Qt::XButton1)
{
triggerPageAction(QWebPage::Back);
return true;
}
if (e->button() == Qt::XButton2)
{
triggerPageAction(QWebPage::Forward);
return true;
}
return false;
}
QUrl HelpWebView::source() const
{
HelpPage *currentPage = static_cast<HelpPage*> (page());
if (currentPage && !hasLoadFinished())
{
// see HelpPage::acceptNavigationRequest(...)
return currentPage->m_loadingUrl;
}
return url();
}
void HelpWebView::setSource(const QUrl &url)
{
if (m_HelpEngine.findFile(url).isValid())
load(url);
else
setHtml(m_PageNotFoundMessage.arg(url.toString()));
}
void HelpWebView::wheelEvent(QWheelEvent *e)
{
if (e->modifiers()& Qt::ControlModifier)
{
e->accept();
e->delta() > 0 ? scaleUp() : scaleDown();
}
else
{
QWebView::wheelEvent(e);
}
}
void HelpWebView::mouseReleaseEvent(QMouseEvent *e)
{
#ifndef Q_OS_LINUX
if (handleForwardBackwardMouseButtons(e))
return;
#endif
QWebView::mouseReleaseEvent(e);
}
void HelpWebView::actionChanged()
{
QAction *a = qobject_cast<QAction *>(sender());
if (a == pageAction(QWebPage::Copy))
emit copyAvailable(a->isEnabled());
else if (a == pageAction(QWebPage::Back))
emit backwardAvailable(a->isEnabled());
else if (a == pageAction(QWebPage::Forward))
emit forwardAvailable(a->isEnabled());
}
void HelpWebView::mousePressEvent(QMouseEvent *event)
{
#ifdef Q_OS_LINUX
if (handleForwardBackwardMouseButtons(event))
return;
#endif
HelpPage *currentPage = static_cast<HelpPage*>(page());
if (currentPage)
{
currentPage->m_pressedButtons = event->buttons();
currentPage->m_keyboardModifiers = event->modifiers();
}
QWebView::mousePressEvent(event);
}
void HelpWebView::setLoadStarted()
{
m_LoadFinished = false;
}
void HelpWebView::setLoadFinished(bool ok)
{
m_LoadFinished = ok;
emit sourceChanged(url());
}
QString HelpWebView::mimeFromUrl(const QUrl &url)
{
const QString &path = url.path();
const int index = path.lastIndexOf(QLatin1Char('.'));
const QByteArray &ext = path.mid(index).toUtf8().toLower();
const ExtensionMap *e = extensionMap;
while (e->extension)
{
if (ext == e->extension)
return QLatin1String(e->mimeType);
++e;
}
return QLatin1String("");
}
bool HelpWebView::canOpenPage(const QString &url)
{
return !mimeFromUrl(url).isEmpty();
}
bool HelpWebView::isLocalUrl(const QUrl &url)
{
const QString &scheme = url.scheme();
return scheme.isEmpty()
|| scheme == QLatin1String("file")
|| scheme == QLatin1String("qrc")
|| scheme == QLatin1String("data")
|| scheme == QLatin1String("qthelp")
|| scheme == QLatin1String("about");
}
bool HelpWebView::launchWithExternalApp(const QUrl &url)
{
if (isLocalUrl(url))
{
const QHelpEngine& helpEngine = HelpPluginActivator::getInstance()->getQHelpEngine();
const QUrl &resolvedUrl = helpEngine.findFile(url);
if (!resolvedUrl.isValid())
return false;
const QString& path = resolvedUrl.path();
if (!canOpenPage(path))
{
QTemporaryFile tmpTmpFile;
if (!tmpTmpFile.open())
return false;
const QString &extension = QFileInfo(path).completeSuffix();
QFile actualTmpFile(tmpTmpFile.fileName() % QLatin1String(".")
% extension);
if (!actualTmpFile.open(QIODevice::ReadWrite | QIODevice::Truncate))
return false;
actualTmpFile.write(helpEngine.fileData(resolvedUrl));
actualTmpFile.close();
return QDesktopServices::openUrl(QUrl(actualTmpFile.fileName()));
}
}
else if (url.scheme() == QLatin1String("http"))
{
return QDesktopServices::openUrl(url);
}
return false;
}
void HelpWebView::home()
{
setSource(m_HelpEngine.homePage());
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpWebView.h b/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpWebView.h
index 16ed677b09..3b3ee379e7 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpWebView.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpWebView.h
@@ -1,108 +1,108 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYHELPWEBVIEW_H
#define BERRYHELPWEBVIEW_H
#include <QFont>
#include <QAction>
#include <QWebView>
#include <berryIEditorSite.h>
namespace berry {
class QHelpEngineWrapper;
class HelpWebView : public QWebView
{
Q_OBJECT
public:
explicit HelpWebView(IEditorSite::Pointer editorSite, QWidget *parent, qreal zoom = 0.0);
~HelpWebView();
QFont viewerFont() const;
void setViewerFont(const QFont &font);
qreal scale() const { return textSizeMultiplier(); }
bool handleForwardBackwardMouseButtons(QMouseEvent *e);
QUrl source() const;
void setSource(const QUrl &url);
inline QString documentTitle() const
{ return title(); }
inline bool hasSelection() const
{ return !selectedText().isEmpty(); } // ### this is suboptimal
inline void copy()
{ return triggerPageAction(QWebPage::Copy); }
inline bool isForwardAvailable() const
{ return pageAction(QWebPage::Forward)->isEnabled(); }
inline bool isBackwardAvailable() const
{ return pageAction(QWebPage::Back)->isEnabled(); }
inline bool hasLoadFinished() const
{ return m_LoadFinished; }
static QString mimeFromUrl(const QUrl &url);
static bool canOpenPage(const QString &url);
static bool isLocalUrl(const QUrl &url);
static bool launchWithExternalApp(const QUrl &url);
static const QString m_PageNotFoundMessage;
public Q_SLOTS:
void backward() { back(); }
void home();
void scaleUp();
void scaleDown();
void resetScale();
Q_SIGNALS:
void copyAvailable(bool enabled);
void forwardAvailable(bool enabled);
void backwardAvailable(bool enabled);
void highlighted(const QString &);
void sourceChanged(const QUrl &);
void printRequested();
protected:
virtual void wheelEvent(QWheelEvent *);
void mouseReleaseEvent(QMouseEvent *e);
void mousePressEvent(QMouseEvent *event);
private Q_SLOTS:
void actionChanged();
void setLoadStarted();
void setLoadFinished(bool ok);
private:
bool m_LoadFinished;
QHelpEngineWrapper& m_HelpEngine;
};
}
#endif // BERRYHELPWEBVIEW_H
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryQHelpEngineConfiguration.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryQHelpEngineConfiguration.cpp
index 31fccb50be..4803f05d47 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryQHelpEngineConfiguration.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryQHelpEngineConfiguration.cpp
@@ -1,65 +1,65 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryQHelpEngineConfiguration.h"
#include "berryQHelpEngineWrapper.h"
#include <ctkPluginContext.h>
namespace berry {
QString QHelpEngineConfiguration::PID = "org.blueberry.services.help";
QHelpEngineConfiguration::QHelpEngineConfiguration(ctkPluginContext* context,
QHelpEngineWrapper& helpEngine)
: helpEngine(helpEngine)
{
QMutexLocker lock(&mutex);
registration = context->registerService<ctkManagedService>(this, getDefaults());
}
void QHelpEngineConfiguration::updated(const ctkDictionary &properties)
{
if (properties.isEmpty())
{
QMutexLocker lock(&mutex);
registration.setProperties(getDefaults());
}
else
{
QMetaObject::invokeMethod(this, "configurationChanged", Q_ARG(ctkDictionary, properties));
QMutexLocker lock(&mutex);
registration.setProperties(properties);
}
}
void QHelpEngineConfiguration::configurationChanged(const ctkDictionary& properties)
{
helpEngine.setHomePage(properties["homePage"].toString());
}
ctkDictionary QHelpEngineConfiguration::getDefaults() const
{
ctkDictionary defaults;
defaults.insert("homePage", "");
defaults.insert(ctkPluginConstants::SERVICE_PID, PID);
return defaults;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryQHelpEngineConfiguration.h b/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryQHelpEngineConfiguration.h
index 9f438346e2..8285e5cea0 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryQHelpEngineConfiguration.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryQHelpEngineConfiguration.h
@@ -1,62 +1,62 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYQHELPENGINECONFIGURATION_H
#define BERRYQHELPENGINECONFIGURATION_H
#include <QMutex>
#include <ctkServiceRegistration.h>
#include <service/cm/ctkManagedService.h>
namespace berry {
class QHelpEngineWrapper;
class QHelpEngineConfiguration : public QObject, public ctkManagedService
{
Q_OBJECT
Q_INTERFACES(ctkManagedService)
public:
QHelpEngineConfiguration(ctkPluginContext* context, QHelpEngineWrapper& helpEngine);
void updated(const ctkDictionary &properties);
public Q_SLOTS:
void configurationChanged(const ctkDictionary &properties);
private:
Q_DISABLE_COPY(QHelpEngineConfiguration)
ctkDictionary getDefaults() const;
static QString PID;
QMutex mutex;
ctkServiceRegistration registration;
QHelpEngineWrapper& helpEngine;
};
}
#endif // BERRYQHELPENGINECONFIGURATION_H
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryQHelpEngineWrapper.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryQHelpEngineWrapper.cpp
index 48ccebb55b..474d5a8f9b 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryQHelpEngineWrapper.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryQHelpEngineWrapper.cpp
@@ -1,64 +1,64 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryQHelpEngineWrapper.h"
#include <QHelpSearchEngine>
namespace berry {
QHelpEngineWrapper::QHelpEngineWrapper(const QString &collectionFile)
: QHelpEngine(collectionFile)
{
/*
* Otherwise we will waste time if several new docs are found,
* because we will start to index them, only to be interrupted
* by the next request. Also, there is a nasty SQLITE bug that will
* cause the application to hang for minutes in that case.
* This call is reverted by initalDocSetupDone(), which must be
* called after the new docs have been installed.
*/
disconnect(this, SIGNAL(setupFinished()),
searchEngine(), SLOT(indexDocumentation()));
}
QHelpEngineWrapper::~QHelpEngineWrapper()
{
}
void QHelpEngineWrapper::initialDocSetupDone()
{
connect(this, SIGNAL(setupFinished()),
searchEngine(), SLOT(indexDocumentation()));
setupData();
}
const QString QHelpEngineWrapper::homePage() const
{
return m_HomePage;
}
void QHelpEngineWrapper::setHomePage(const QString &page)
{
if (m_HomePage != page)
{
m_HomePage = page;
emit homePageChanged(page);
}
}
} // end namespace berry
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryQHelpEngineWrapper.h b/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryQHelpEngineWrapper.h
index ddc91315b5..a1055f2dae 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryQHelpEngineWrapper.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryQHelpEngineWrapper.h
@@ -1,56 +1,56 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYQHELPENGINEWRAPPER_H
#define BERRYQHELPENGINEWRAPPER_H
#include <QHelpEngine>
namespace berry {
class QHelpEngineWrapper : public QHelpEngine
{
Q_OBJECT
Q_DISABLE_COPY(QHelpEngineWrapper)
public:
QHelpEngineWrapper(const QString &collectionFile);
~QHelpEngineWrapper();
/*
* To be called after the initial search for qch files finished.
* This will mainly cause the search index to be updated, if necessary.
*/
void initialDocSetupDone();
const QString homePage() const;
void setHomePage(const QString &page);
Q_SIGNALS:
void homePageChanged(const QString& page);
private:
QString m_HomePage;
};
} // end namespace berry
#endif // BERRYQHELPENGINEWRAPPER_H
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.log/src/internal/berryLogView.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt.log/src/internal/berryLogView.cpp
index 27f72b6242..5feee67a76 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt.log/src/internal/berryLogView.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt.log/src/internal/berryLogView.cpp
@@ -1,56 +1,56 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 <windows.h>
#endif
#include "berryLogView.h"
#include "berryQtLogView.h"
#include <QHBoxLayout>
namespace berry {
LogView::LogView()
{
}
LogView::LogView(const LogView& other)
{
Q_UNUSED(other)
throw std::runtime_error("Copy constructor not implemented");
}
void LogView::CreateQtPartControl(QWidget* parent)
{
QHBoxLayout* layout = new QHBoxLayout(parent);
layout->setContentsMargins(0,0,0,0);
QtLogView* logView = new QtLogView(parent);
layout->addWidget(logView);
}
void LogView::SetFocus()
{
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.log/src/internal/berryLogView.h b/BlueBerry/Bundles/org.blueberry.ui.qt.log/src/internal/berryLogView.h
index 91e996627c..fd78823824 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt.log/src/internal/berryLogView.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt.log/src/internal/berryLogView.h
@@ -1,45 +1,45 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYLOGVIEW_H_
#define BERRYLOGVIEW_H_
#include <QtGui/QWidget>
#include "berryQtViewPart.h"
namespace berry {
class LogView : public QtViewPart
{
Q_OBJECT
public:
LogView();
LogView(const LogView& other);
void SetFocus();
protected:
void CreateQtPartControl(QWidget* parent);
};
} // namespace berry
#endif /*BERRYLOGVIEW_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.log/src/internal/berryQtLogPlugin.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt.log/src/internal/berryQtLogPlugin.cpp
index 6beb59d6bc..d5284ad844 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt.log/src/internal/berryQtLogPlugin.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt.log/src/internal/berryQtLogPlugin.cpp
@@ -1,60 +1,60 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryQtLogPlugin.h"
#include "berryLogView.h"
#include <QtPlugin>
namespace berry {
QtLogPlugin* QtLogPlugin::instance = 0;
QtLogPlugin::QtLogPlugin()
{
instance = this;
}
void
QtLogPlugin::start(ctkPluginContext* context)
{
BERRY_REGISTER_EXTENSION_CLASS(berry::LogView, context)
m_LogModel = new QtPlatformLogModel();
}
void
QtLogPlugin::stop(ctkPluginContext* /*context*/)
{
delete m_LogModel;
}
QtLogPlugin*
QtLogPlugin::GetInstance()
{
return instance;
}
QtPlatformLogModel*
QtLogPlugin::GetLogModel()
{
return m_LogModel;
}
}
Q_EXPORT_PLUGIN2(org_blueberry_ui_qt_log, berry::QtLogPlugin)
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.log/src/internal/berryQtLogPlugin.h b/BlueBerry/Bundles/org.blueberry.ui.qt.log/src/internal/berryQtLogPlugin.h
index 06b17c9f66..8dd655ebc7 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt.log/src/internal/berryQtLogPlugin.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt.log/src/internal/berryQtLogPlugin.h
@@ -1,51 +1,51 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYLOGPLUGIN_H_
#define BERRYLOGPLUGIN_H_
#include <ctkPluginActivator.h>
#include "berryQtPlatformLogModel.h"
namespace berry {
class QtLogPlugin : public QObject, public ctkPluginActivator
{
Q_OBJECT
Q_INTERFACES(ctkPluginActivator)
public:
QtLogPlugin();
void start(ctkPluginContext* context);
void stop(ctkPluginContext* context);
static QtLogPlugin* GetInstance();
QtPlatformLogModel* GetLogModel();
private:
static QtLogPlugin* instance;
QtPlatformLogModel* m_LogModel;
};
}
#endif /*BERRYLOGPLUGIN_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.log/src/internal/berryQtLogView.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt.log/src/internal/berryQtLogView.cpp
index 08dbe8ef1a..aba6b896ef 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt.log/src/internal/berryQtLogView.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt.log/src/internal/berryQtLogView.cpp
@@ -1,121 +1,121 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 <windows.h>
#endif
#include "berryQtLogView.h"
#include "berryQtLogPlugin.h"
#include <berryIPreferencesService.h>
#include <berryIBerryPreferences.h>
#include <berryPlatform.h>
#include <berryPlatformUI.h>
#include <QHeaderView>
#include <QTimer>
namespace berry {
QtLogView::QtLogView(QWidget *parent)
: QWidget(parent)
{
berry::IPreferencesService::Pointer prefService
= berry::Platform::GetServiceRegistry()
.GetServiceById<berry::IPreferencesService>(berry::IPreferencesService::ID);
berry::IBerryPreferences::Pointer prefs
= (prefService->GetSystemPreferences()->Node("org_blueberry_ui_qt_log"))
.Cast<berry::IBerryPreferences>();
bool showAdvancedFields =
prefs->GetBool("ShowAdvancedFields", true) ;
ui.setupUi(this);
model = QtLogPlugin::GetInstance()->GetLogModel();
model->SetShowAdvancedFiels( showAdvancedFields );
filterModel = new QSortFilterProxyModel(this);
filterModel->setSourceModel(model);
filterModel->setFilterKeyColumn(-1);
ui.tableView->setModel(filterModel);
ui.tableView->verticalHeader()->setVisible(false);
ui.tableView->horizontalHeader()->setStretchLastSection(true);
connect( ui.filterContent, SIGNAL( textChanged( const QString& ) ), this, SLOT( slotFilterChange( const QString& ) ) );
connect( filterModel, SIGNAL( rowsInserted ( const QModelIndex &, int, int ) ), this, SLOT( slotRowAdded( const QModelIndex &, int , int ) ) );
ui.ShowAdvancedFields->setChecked( showAdvancedFields );
}
QtLogView::~QtLogView()
{
}
void QtLogView::slotScrollDown( )
{
ui.tableView->scrollToBottom();
}
void QtLogView::slotFilterChange( const QString& q )
{
filterModel->setFilterRegExp(QRegExp(q, Qt::CaseInsensitive, QRegExp::FixedString));
}
void QtLogView::slotRowAdded ( const QModelIndex & /*parent*/, int start, int end )
{
static int first=false;
if(!first)
{
first=true;
ui.tableView->resizeColumnsToContents();
ui.tableView->resizeRowsToContents();
}
else
for(int r=start;r<=end;r++)
{
ui.tableView->resizeRowToContents(r);
}
QTimer::singleShot(0,this,SLOT( slotScrollDown() ) );
}
void QtLogView::on_ShowAdvancedFields_clicked( bool checked )
{
QtLogPlugin::GetInstance()->GetLogModel()->SetShowAdvancedFiels( checked );
ui.tableView->resizeColumnsToContents();
berry::IPreferencesService::Pointer prefService
= berry::Platform::GetServiceRegistry()
.GetServiceById<berry::IPreferencesService>(berry::IPreferencesService::ID);
berry::IBerryPreferences::Pointer prefs
= (prefService->GetSystemPreferences()->Node("org_blueberry_ui_qt_log"))
.Cast<berry::IBerryPreferences>();
prefs->PutBool("ShowAdvancedFields", checked);
prefs->Flush();
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.log/src/internal/berryQtLogView.h b/BlueBerry/Bundles/org.blueberry.ui.qt.log/src/internal/berryQtLogView.h
index 62b3c0b989..2cc9eded9b 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt.log/src/internal/berryQtLogView.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt.log/src/internal/berryQtLogView.h
@@ -1,52 +1,52 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYQTLOGVIEW_H
#define BERRYQTLOGVIEW_H
#include <QtGui/QWidget>
#include <QSortFilterProxyModel>
#include "ui_berryQtLogView.h"
#include "berryQtPlatformLogModel.h"
namespace berry {
class QtLogView : public QWidget
{
Q_OBJECT
public:
QtLogView(QWidget *parent = 0);
~QtLogView();
QtPlatformLogModel *model;
QSortFilterProxyModel *filterModel;
private:
Ui::QtLogViewClass ui;
protected slots:
void slotFilterChange( const QString& );
void slotRowAdded( const QModelIndex & , int , int );
void slotScrollDown( );
void on_ShowAdvancedFields_clicked( bool checked = false );
};
}
#endif // BERRYQTLOGVIEW_H
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.log/src/internal/berryQtPlatformLogModel.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt.log/src/internal/berryQtPlatformLogModel.cpp
index 1ec4021055..7c9c29c629 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt.log/src/internal/berryQtPlatformLogModel.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt.log/src/internal/berryQtPlatformLogModel.cpp
@@ -1,330 +1,330 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 <windows.h>
#endif
#include "berryQtPlatformLogModel.h"
#include "berryPlatform.h"
#include "event/berryPlatformEvents.h"
#include <sstream>
#include <string>
#include <iostream>
#include <iomanip>
#include <Poco/Message.h>
#include "berryLog.h"
#include <QTimer>
#include <QIcon>
namespace berry {
const QString QtPlatformLogModel::Error = QString("Error");
const QString QtPlatformLogModel::Warn = QString("Warning");
const QString QtPlatformLogModel::Fatal = QString("Fatal");
const QString QtPlatformLogModel::Info = QString("Info");
const QString QtPlatformLogModel::Debug = QString("Debug");
void QtPlatformLogModel::slotFlushLogEntries()
{
m_Mutex.lock();
std::list<ExtendedLogMessage> *tmp=m_Active;
m_Active=m_Pending; m_Pending=tmp;
m_Mutex.unlock();
int num = static_cast<int>(m_Pending->size());
if (num > 0)
{
int row = static_cast<int>(m_Entries.size());
this->beginInsertRows(QModelIndex(), row, row+num-1);
do {
m_Entries.push_back(m_Pending->front());
m_Pending->pop_front();
} while(--num);
this->endInsertRows();
}
}
void QtPlatformLogModel::addLogEntry(const mbilog::LogMessage &msg)
{
m_Mutex.lock();
//mbilog::BackendCout::FormatSmart(msg); FormatSmart is not static any more. So commented out this statement. Todo: fix
m_Active->push_back(ExtendedLogMessage(msg));
m_Mutex.unlock();
emit signalFlushLogEntries();
}
void
QtPlatformLogModel::SetShowAdvancedFiels( bool showAdvancedFiels )
{
if( m_ShowAdvancedFiels != showAdvancedFiels )
{
m_ShowAdvancedFiels = showAdvancedFiels;
this->reset();
}
}
void
QtPlatformLogModel::addLogEntry(const PlatformEvent& event)
{
const Poco::Message& entry = Poco::RefAnyCast<const Poco::Message>(*event.GetData());
mbilog::LogMessage msg(mbilog::Info,"n/a",-1,"n/a");
msg.message += entry.getText();
msg.category = "BlueBerry."+entry.getSource();
msg.moduleName = "n/a";
addLogEntry(msg);
}
QtPlatformLogModel::QtPlatformLogModel(QObject* parent) : QAbstractTableModel(parent), m_ShowAdvancedFiels(true)
{
m_Active=new std::list<ExtendedLogMessage>;
m_Pending=new std::list<ExtendedLogMessage>;
connect(this, SIGNAL(signalFlushLogEntries()), this, SLOT( slotFlushLogEntries() ), Qt::QueuedConnection );
Platform::GetEvents().logged += PlatformEventDelegate(this, &QtPlatformLogModel::addLogEntry);
myBackend = new QtLogBackend(this);
}
QtPlatformLogModel::~QtPlatformLogModel()
{
disconnect(this, SIGNAL(signalFlushLogEntries()), this, SLOT( slotFlushLogEntries() ));
// dont delete and unregister backend, only deactivate it to avoid thread syncronization issues cause mbilog::UnregisterBackend is not threadsafe
// will be fixed.
// delete myBackend;
// delete m_Active;
// delete m_Pending;
m_Mutex.lock();
myBackend->Deactivate();
m_Mutex.unlock();
}
// QT Binding
int
QtPlatformLogModel::rowCount(const QModelIndex&) const
{
return static_cast<int>(m_Entries.size());
}
int
QtPlatformLogModel::columnCount(const QModelIndex&) const
{
if( m_ShowAdvancedFiels )
return 8;
else
return 2;
}
/*
struct LogEntry {
LogEntry(const std::string& msg, const std::string& src, std::time_t t)
: message(msg.c_str()), moduleName(src.c_str()),time(std::clock())
{
}
QString message;
clock_t time;
QString level;
QString filePath;
QString lineNumber;
QString moduleName;
QString category;
QString function;
LogEntry(const mbilog::LogMessage &msg)
{
message = msg.message.c_str();
filePath = msg.filePath;
std::stringstream out;
out << msg.lineNumber;
lineNumber = out.str().c_str();
moduleName = msg.moduleName;
category = msg.category.c_str();
function = msg.functionName;
time=std::clock();
}
}; */
QVariant
QtPlatformLogModel::data(const QModelIndex& index, int role) const
{
const ExtendedLogMessage *msg = &m_Entries[index.row()];
if (role == Qt::DisplayRole)
{
if( m_ShowAdvancedFiels )
{
switch (index.column()) {
case 0: {
std::stringstream ss;
std::locale C("C");
ss.imbue(C);
ss << std::setw(7) << std::setprecision(3) << std::fixed << ((double)msg->time)/CLOCKS_PER_SEC;
return QVariant(QString(ss.str().c_str()));
}
case 1:
{
// change muellerm, an icon is returned do not return text
switch(msg->message.level)
{
default:
case mbilog::Info:
return QVariant(Info);
case mbilog::Warn:
return QVariant(Warn);
case mbilog::Error:
return QVariant(Error);
case mbilog::Fatal:
return QVariant(Fatal);
case mbilog::Debug:
return QVariant(Debug);
}
}
case 2:
return QVariant(QString(msg->message.message.c_str()));
case 3:
return QVariant(QString(msg->message.category.c_str()));
case 4:
return QVariant(QString(msg->message.moduleName));
case 5:
return QVariant(QString(msg->message.functionName));
case 6:
return QVariant(QString(msg->message.filePath));
case 7:
{
std::stringstream out;
std::locale C("C");
out.imbue(C);
out << msg->message.lineNumber;
return QVariant(QString(out.str().c_str()));
}
}
}
else // m_ShowAdvancedFields
{
// only return text
if( index.column() == 0 )
{
switch(msg->message.level)
{
default:
case mbilog::Info:
return QVariant(Info);
case mbilog::Warn:
return QVariant(Warn);
case mbilog::Error:
return QVariant(Error);
case mbilog::Fatal:
return QVariant(Fatal);
case mbilog::Debug:
return QVariant(Debug);
}
}
if( index.column()==1 )
{
return QVariant(QString(msg->message.message.c_str()));
}
}
}
else if( role == Qt::DecorationRole )
{
if ( (m_ShowAdvancedFiels && index.column()==1)
|| (!m_ShowAdvancedFiels && index.column()==0) )
{
QString file ( ":/org_blueberry_ui_qt_log/information.png" );
if( msg->message.level == mbilog::Error )
file = ":/org_blueberry_ui_qt_log/error.png";
else if( msg->message.level == mbilog::Warn )
file = ":/org_blueberry_ui_qt_log/warning.png";
else if( msg->message.level == mbilog::Debug )
file = ":/org_blueberry_ui_qt_log/debug.png";
else if( msg->message.level == mbilog::Fatal )
file = ":/org_blueberry_ui_qt_log/fatal.png";
QIcon icon(file);
return QVariant(icon);
}
}
return QVariant();
}
QVariant
QtPlatformLogModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (role == Qt::DisplayRole && orientation == Qt::Horizontal)
{
if( m_ShowAdvancedFiels )
{
switch (section)
{
case 0: return QVariant("Time");
case 1: return QVariant("Level");
case 2: return QVariant("Message");
case 3: return QVariant("Category");
case 4: return QVariant("Module");
case 5: return QVariant("Function");
case 6: return QVariant("File");
case 7: return QVariant("Line");
}
}
else
{
switch (section)
{
case 0: return QVariant("Severtiy");
case 1: return QVariant("Message");
}
}
}
return QVariant();
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.log/src/internal/berryQtPlatformLogModel.h b/BlueBerry/Bundles/org.blueberry.ui.qt.log/src/internal/berryQtPlatformLogModel.h
index 862a9c2622..c10e881d30 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt.log/src/internal/berryQtPlatformLogModel.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt.log/src/internal/berryQtPlatformLogModel.h
@@ -1,140 +1,140 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYQTPLATFORMLOGMODEL_H_
#define BERRYQTPLATFORMLOGMODEL_H_
#include "berryLog.h"
#include <QtCore/QAbstractTableModel>
#include <QtCore/QDateTime>
#include "event/berryPlatformEvent.h"
#include "berryMessage.h"
#include <vector>
#include <ctime>
#include <sstream>
#include "berryLog.h"
#include <QMutex>
namespace berry {
class QtPlatformLogModel : public QAbstractTableModel
{
Q_OBJECT
public:
QtPlatformLogModel(QObject* parent = 0);
~QtPlatformLogModel();
void SetShowAdvancedFiels( bool showAdvancedFiels );
int rowCount(const QModelIndex&) const;
int columnCount(const QModelIndex&) const;
QVariant data(const QModelIndex& index, int) const;
QVariant headerData(int section, Qt::Orientation orientation, int) const;
void addLogEntry(const mbilog::LogMessage &msg);
void addLogEntry(const PlatformEvent& event);
private:
bool m_ShowAdvancedFiels;
typedef MessageDelegate1<QtPlatformLogModel, const PlatformEvent&> PlatformEventDelegate;
struct ExtendedLogMessage {
mbilog::LogMessage message;
clock_t time;
int threadid;
ExtendedLogMessage(const ExtendedLogMessage &src):message(src.message),time(src.time),threadid(src.threadid)
{
}
ExtendedLogMessage(const mbilog::LogMessage &msg):message(msg),time(std::clock()),threadid(0)
{
}
ExtendedLogMessage operator = (const ExtendedLogMessage& src)
{
return ExtendedLogMessage(src);
}
};
class QtLogBackend : public mbilog::BackendBase
{
public:
QtLogBackend(QtPlatformLogModel *_myModel)
{
myModel=_myModel;
deactivated = false;
mbilog::RegisterBackend(this);
BERRY_INFO << "BlueBerry mbilog backend registered";
}
~QtLogBackend()
{
mbilog::UnregisterBackend(this);
}
void ProcessMessage(const mbilog::LogMessage &l )
{
if(!deactivated)
myModel->addLogEntry(l);
}
void Deactivate()
{
deactivated=true;
}
private:
QtPlatformLogModel *myModel;
bool deactivated;
} *myBackend;
std::vector<ExtendedLogMessage> m_Entries;
std::list<ExtendedLogMessage> *m_Active,*m_Pending;
static const QString Error;
static const QString Warn;
static const QString Fatal;
static const QString Info;
static const QString Debug;
QMutex m_Mutex;
signals:
void signalFlushLogEntries();
protected slots:
void slotFlushLogEntries();
};
}
#endif /*BERRYQTPLATFORMLOGMODEL_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/src/internal/berryObjectBrowserView.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/src/internal/berryObjectBrowserView.cpp
index 5795faafde..7459614fe5 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/src/internal/berryObjectBrowserView.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/src/internal/berryObjectBrowserView.cpp
@@ -1,280 +1,280 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 <windows.h>
#endif
#include <QToolBar>
#include <QSortFilterProxyModel>
#include <QVBoxLayout>
#include <QLabel>
#include "berryObjectBrowserView.h"
#include "berryDebugUtil.h"
#include "berryDebugBreakpointManager.h"
#include <sstream>
namespace berry
{
const std::string ObjectBrowserView::VIEW_ID = "objectbrowser";
ObjectBrowserView::ObjectBrowserView() :
m_ActionToggleBreakpoint(this), m_ActionEnableBreakpoint(this),
m_ActionDisableBreakpoint(this)
{
#ifdef BLUEBERRY_DEBUG_SMARTPOINTER
m_Useful = true;
#else
m_Useful = false;
#endif
}
ObjectBrowserView::ObjectBrowserView(const ObjectBrowserView& other)
: m_ActionToggleBreakpoint(this), m_ActionEnableBreakpoint(this),
m_ActionDisableBreakpoint(this)
{
Q_UNUSED(other)
throw std::runtime_error("Copy constructor not implemented");
}
void ObjectBrowserView::Init(IViewSite::Pointer site, IMemento::Pointer memento)
{
QtViewPart::Init(site, memento);
m_StateMemento = memento;
}
void ObjectBrowserView::CreateQtPartControl(QWidget* parent)
{
if (m_Useful)
{
m_Controls.setupUi(parent);
m_ProxyModel = new QSortFilterProxyModel(m_Controls.m_TreeView);
m_ObjectModel = new QtObjectTableModel(m_ProxyModel);
m_ProxyModel->setSourceModel(m_ObjectModel);
m_Controls.m_TreeView->setModel(m_ProxyModel);
m_Controls.m_TreeView->setSortingEnabled(true);
m_Controls.m_TreeView->setContextMenuPolicy(Qt::CustomContextMenu);
m_ActionToggleBreakpoint.setText(QString("Toggle Breakpoint"));
m_ActionToggleBreakpoint.setCheckable(true);
m_ContextMenu.addAction(&m_ActionToggleBreakpoint);
QToolBar* toolbar = new QToolBar(parent);
QAction* resetAction = toolbar->addAction("Reset");
toolbar->addAction("Show Breakpoints Only");
connect(resetAction, SIGNAL(triggered(bool)), this, SLOT(ResetAction(bool)));
connect(m_Controls.m_TreeView->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
this, SLOT(SelectionChanged(const QItemSelection&, const QItemSelection&)));
connect(m_Controls.m_TreeView, SIGNAL(customContextMenuRequested(const QPoint&)),
this, SLOT(ContextMenuRequested(const QPoint&)));
// context menu actions
connect(&m_ActionToggleBreakpoint, SIGNAL(triggered(bool)), this, SLOT(ToggleBreakpoint(bool)));
parent->layout()->setMenuBar(toolbar);
RestoreGuiState(m_StateMemento);
m_StateMemento = 0;
}
else
{
QVBoxLayout* layout = new QVBoxLayout(parent);
QLabel* label = new QLabel(parent);
label->setText(
"Set the CMake variable BLUEBERRY_DEBUG_SMARTPOINTER to ON for a useful object browser.");
label->setWordWrap(true);
label->setAlignment(Qt::AlignTop);
layout->addWidget(label);
}
}
void ObjectBrowserView::RestoreGuiState(IMemento::Pointer memento)
{
if (memento)
{
IMemento::Pointer columnWidths = memento->GetChild("columnWidths");
if (columnWidths)
{
int colWidth = 0;
if (columnWidths->GetInteger("column0", colWidth))
{
m_Controls.m_TreeView->setColumnWidth(0, colWidth);
}
if (columnWidths->GetInteger("column1", colWidth))
{
m_Controls.m_TreeView->setColumnWidth(1, colWidth);
}
}
IMemento::Pointer splitter = memento->GetChild("splitter");
if (splitter)
{
QList<int> sizes;
int size = 200;
splitter->GetInteger("first", size);
sizes.push_back(size);
splitter->GetInteger("second", size);
sizes.push_back(size);
m_Controls.m_Splitter->setSizes(sizes);
}
}
}
void ObjectBrowserView::ResetAction(bool /*checked*/)
{
m_ObjectModel->ResetData();
}
void ObjectBrowserView::SelectionChanged(const QItemSelection& selected,
const QItemSelection& /*deselected*/)
{
QList<QModelIndex> indexes = selected.indexes();
if (indexes.empty())
{
m_Controls.m_DetailsView->clear();
return;
}
QModelIndex index = indexes.front();
if (!index.parent().isValid())
{
m_Controls.m_DetailsView->clear();
}
QVariant data = m_ProxyModel->data(index, Qt::UserRole);
if (data.isValid())
{
const ObjectItem* item =
static_cast<const ObjectItem*> (data.value<void*> ());
if (item)
{
const Object* obj = 0;
if (item->type == ObjectItem::INSTANCE)
obj = item->obj;
else if (item->type == ObjectItem::SMARTPOINTER)
{
const ObjectItem* item =
static_cast<const ObjectItem*> (m_ProxyModel->data(index.parent(),
Qt::UserRole).value<void*> ());
if (item)
obj = item->obj;
}
if (obj)
{
std::stringstream ss;
ss << *(obj) << std::endl << obj->ToString();
m_Controls.m_DetailsView->setPlainText(QString::fromStdString(ss.str()));
}
else
{
m_Controls.m_DetailsView->setPlainText(QString("0"));
}
}
else
{
m_Controls.m_DetailsView->setPlainText(QString("0"));
}
}
}
void ObjectBrowserView::ContextMenuRequested(const QPoint& p)
{
QModelIndex index = m_Controls.m_TreeView->selectionModel()->currentIndex();
if (index.isValid())
{
QVariant data = m_ProxyModel->data(index, Qt::UserRole);
if (!data.isValid())
return;
const ObjectItem* item = static_cast<ObjectItem*> (data.value<void*> ());
if (item->type == ObjectItem::CLASS)
return;
m_ContextMenu.exec(m_Controls.m_TreeView->mapToGlobal(p));
}
}
void ObjectBrowserView::ToggleBreakpoint(bool checked)
{
QModelIndex index = m_Controls.m_TreeView->selectionModel()->currentIndex();
if (index.isValid())
{
QVariant data = m_ProxyModel->data(index, Qt::UserRole);
if (!data.isValid())
return;
const ObjectItem* item = static_cast<ObjectItem*> (data.value<void*> ());
if (item->type == ObjectItem::INSTANCE)
{
#ifdef BLUEBERRY_DEBUG_SMARTPOINTER
if (checked)
DebugUtil::GetBreakpointManager()->AddObjectBreakpoint(item->obj->GetTraceId());
else
DebugUtil::GetBreakpointManager()->RemoveObjectBreakpoint(item->obj->GetTraceId());
#endif
}
else if (item->type == ObjectItem::SMARTPOINTER)
{
if (checked)
DebugUtil::GetBreakpointManager()->AddSmartpointerBreakpoint(item->spId);
else
DebugUtil::GetBreakpointManager()->RemoveSmartpointerBreakpoint(
item->spId);
}
}
}
void ObjectBrowserView::SetFocus()
{
if (m_Useful)
{
m_Controls.m_TreeView->setFocus();
}
}
void ObjectBrowserView::SaveState(IMemento::Pointer memento)
{
if (!m_Useful)
return;
IMemento::Pointer cols = memento->CreateChild("columnWidths");
cols->PutInteger("column0", m_Controls.m_TreeView->columnWidth(0));
cols->PutInteger("column1", m_Controls.m_TreeView->columnWidth(1));
QList<int> sizes(m_Controls.m_Splitter->sizes());
IMemento::Pointer splitter = memento->CreateChild("splitter");
splitter->PutInteger("first", sizes[0]);
splitter->PutInteger("second", sizes[1]);
// delete the tree view here in order to delete the underlying model
// which in turn unregisters the object listener. Otherwise, we get
// notifications of deleted objects during workbench shutdown which
// leads to segmentation faults
m_Controls.m_TreeView->deleteLater();
}
} //namespace berry
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/src/internal/berryObjectBrowserView.h b/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/src/internal/berryObjectBrowserView.h
index 50432b271b..36cca384cb 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/src/internal/berryObjectBrowserView.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/src/internal/berryObjectBrowserView.h
@@ -1,101 +1,101 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRY_OBJECTINSPECTORVIEW_H_INCLUDED
#define BERRY_OBJECTINSPECTORVIEW_H_INCLUDED
#include <berryQtViewPart.h>
#include <string>
#include <ui_berryQtObjectBrowserView.h>
#include "berryQtObjectTableModel.h"
#include <QAction>
#include <QMenu>
class QAbstractProxyModel;
namespace berry {
/*!
* \ingroup org_blueberry_ui_qt_objectinspector_internal
*
* \brief Object Inspector
*
* You need to reimplement the methods SetFocus() and CreateQtPartControl(QWidget*)
* from berry::QtViewPart
*
* \sa berry::QtViewPart
*/
class ObjectBrowserView : public berry::QtViewPart
{
Q_OBJECT
public:
static const std::string VIEW_ID;
ObjectBrowserView();
ObjectBrowserView(const ObjectBrowserView& other);
void Init(IViewSite::Pointer site, IMemento::Pointer memento);
/*!
* \brief Gives focus to a specific control in the view
* This method is called from the framework when the view is activated.
*/
void SetFocus();
void SaveState(IMemento::Pointer memento);
protected slots:
void ResetAction(bool checked);
void SelectionChanged(const QItemSelection& selected, const QItemSelection& deselected);
void ContextMenuRequested(const QPoint&);
void ToggleBreakpoint(bool checked);
protected:
/*!
* \brief Builds the user interface of the view
* This method is called from the framework. The parent widget has no layout, so
* you should set one adapted to your needs.
*/
void CreateQtPartControl(QWidget* parent);
void RestoreGuiState(IMemento::Pointer memento);
private:
Ui::QtObjectBrowserView m_Controls;
QtObjectTableModel* m_ObjectModel;
QAbstractProxyModel* m_ProxyModel;
QAction m_ActionToggleBreakpoint;
QAction m_ActionEnableBreakpoint;
QAction m_ActionDisableBreakpoint;
QMenu m_ContextMenu;
IMemento::Pointer m_StateMemento;
bool m_Useful;
};
} //namespace berry
#endif /*BERRY_OBJECTINSPECTORVIEW_H_INCLUDED*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/src/internal/berryObjectItem.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/src/internal/berryObjectItem.cpp
index 91f28be315..5006b6f819 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/src/internal/berryObjectItem.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/src/internal/berryObjectItem.cpp
@@ -1,111 +1,111 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryObjectItem.h"
namespace berry
{
ObjectItem::ObjectItem()
{
type = CLASS;
className = 0;
parent = 0;
}
ObjectItem::ObjectItem(const char* className) :
className(className), type(CLASS), parent(0)
{
}
ObjectItem::ObjectItem(const Object* obj, ObjectItem* parent) :
obj(obj), type(INSTANCE), parent(parent)
{
}
ObjectItem::ObjectItem(unsigned int spId, ObjectItem* parent) :
spId(spId), type(SMARTPOINTER), parent(parent)
{
}
ObjectItem::ObjectItem(const ObjectItem& item) :
type(item.type), children(item.children), parent(item.parent)
{
switch (type)
{
case CLASS:
className = item.className;
break;
case INSTANCE:
obj = item.obj;
break;
case SMARTPOINTER:
spId = item.spId;
break;
}
}
ObjectItem::~ObjectItem()
{
QListIterator<ObjectItem*> iter(children);
while (iter.hasNext())
{
delete iter.next();
}
}
ObjectItem& ObjectItem::operator=(const ObjectItem& item)
{
type = item.type;
children = item.children;
parent = item.parent;
switch (type)
{
case CLASS:
className = item.className;
break;
case INSTANCE:
obj = item.obj;
break;
case SMARTPOINTER:
spId = item.spId;
break;
}
return *this;
}
bool ObjectItem::operator==(const ObjectItem& item) const
{
if (type != item.type)
return false;
switch (type)
{
case CLASS:
{
std::string str(className);
return str == item.className;
}
case INSTANCE:
return obj == item.obj;
case SMARTPOINTER:
return spId == item.spId;
};
return false;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/src/internal/berryObjectItem.h b/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/src/internal/berryObjectItem.h
index 7338dc51ab..8fc5acface 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/src/internal/berryObjectItem.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/src/internal/berryObjectItem.h
@@ -1,67 +1,67 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYOBJECTITEM_H_
#define BERRYOBJECTITEM_H_
#include <QList>
#include <berryObject.h>
namespace berry
{
struct ObjectItem
{
enum Type
{
CLASS = 0, INSTANCE = 1, SMARTPOINTER = 2
};
union
{
const Object* obj;
const char* className;
unsigned int spId;
};
Type type;
QList<ObjectItem*> children;
ObjectItem* parent;
ObjectItem();
ObjectItem(const char* className);
ObjectItem(const Object* obj, ObjectItem* parent);
ObjectItem(unsigned int spId, ObjectItem* parent);
ObjectItem(const ObjectItem& item);
~ObjectItem();
ObjectItem& operator=(const ObjectItem& item);
bool operator==(const ObjectItem& item) const;
};
}
#endif /* BERRYOBJECTITEM_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/src/internal/berryPluginActivator.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/src/internal/berryPluginActivator.cpp
index 71fc3b1013..8434f06367 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/src/internal/berryPluginActivator.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/src/internal/berryPluginActivator.cpp
@@ -1,40 +1,40 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryPluginActivator.h"
#include "berryObjectBrowserView.h"
#include <QtPlugin>
namespace berry {
void org_blueberry_ui_qt_objectinspector_Activator::start(ctkPluginContext* context)
{
BERRY_REGISTER_EXTENSION_CLASS(berry::ObjectBrowserView, context)
}
void org_blueberry_ui_qt_objectinspector_Activator::stop(ctkPluginContext* context)
{
Q_UNUSED(context)
}
}
Q_EXPORT_PLUGIN2(org_blueberry_ui_qt_objectinspector, berry::org_blueberry_ui_qt_objectinspector_Activator)
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/src/internal/berryPluginActivator.h b/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/src/internal/berryPluginActivator.h
index 487564cdab..60c45bd115 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/src/internal/berryPluginActivator.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/src/internal/berryPluginActivator.h
@@ -1,42 +1,42 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYOBJECTINSPECTORACTIVATOR_H
#define BERRYOBJECTINSPECTORACTIVATOR_H
#include <ctkPluginActivator.h>
namespace berry {
class org_blueberry_ui_qt_objectinspector_Activator :
public QObject, public ctkPluginActivator
{
Q_OBJECT
Q_INTERFACES(ctkPluginActivator)
public:
void start(ctkPluginContext* context);
void stop(ctkPluginContext* context);
};
typedef org_blueberry_ui_qt_objectinspector_Activator PluginActivator;
}
#endif // BERRYOBJECTINSPECTORACTIVATOR_H
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/src/internal/berryQtObjectTableModel.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/src/internal/berryQtObjectTableModel.cpp
index cec73d43ec..d63c707d3f 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/src/internal/berryQtObjectTableModel.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/src/internal/berryQtObjectTableModel.cpp
@@ -1,588 +1,588 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryQtObjectTableModel.h"
#include <berryLog.h>
#include <berryDebugUtil.h>
#include <berryDebugBreakpointManager.h>
#include <QTimer>
#include <QIcon>
#include <cstring>
namespace berry
{
class DebugObjectListener: public IDebugObjectListener
{
public:
DebugObjectListener(QtObjectTableModel* model) :
model(model)
{
}
Events::Types GetEventTypes() const
{
return Events::ALL;
}
void ObjectCreated(const Object* obj)
{
model->ObjectCreated(obj);
}
void ObjectDestroyed(const Object* obj)
{
model->ObjectDestroyed(obj);
}
void ObjectTracingChanged(unsigned int /*traceId*/, bool /*enabled = true*/,
const Object* /*obj*/ = 0)
{
}
void SmartPointerCreated(unsigned int id, const Object* obj)
{
model->SmartPointerCreated(id, obj);
}
void SmartPointerDestroyed(unsigned int id, const Object* obj)
{
model->SmartPointerDestroyed(id, obj);
}
private:
QtObjectTableModel* model;
};
QtObjectTableModel::QtObjectTableModel(QObject* parent) :
QAbstractItemModel(parent), objectListener(new DebugObjectListener(this))
{
std::vector<const Object*> objects;
DebugUtil::GetRegisteredObjects(objects);
for (std::vector<const Object*>::const_iterator i = objects.begin(); i
!= objects.end(); ++i)
{
const char* name = (*i)->GetClassName();
ObjectItem* classItem = 0;
QListIterator<ObjectItem*> iter(indexData);
bool classFound = false;
while (iter.hasNext())
{
classItem = iter.next();
if (std::strcmp(classItem->className, name) == 0)
{
classFound = true;
break;
}
}
ObjectItem* instanceItem = new ObjectItem(*i, 0);
// get smartpointer ids
std::list<unsigned int> spIds(DebugUtil::GetSmartPointerIDs(*i));
for (std::list<unsigned int>::const_iterator spIdIter = spIds.begin(); spIdIter
!= spIds.end(); ++spIdIter)
{
ObjectItem* spItem = new ObjectItem((unsigned int) (*spIdIter),
instanceItem);
instanceItem->children.push_back(spItem);
}
if (classFound)
{
instanceItem->parent = classItem;
classItem->children.push_back(instanceItem);
}
else
{
classItem = new ObjectItem(name);
indexData.push_back(classItem);
instanceItem->parent = classItem;
classItem->children.push_back(instanceItem);
}
}
QTimer* timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(UpdatePendingData()));
timer->start(500);
DebugUtil::AddObjectListener(objectListener);
}
QtObjectTableModel::~QtObjectTableModel()
{
DebugUtil::RemoveObjectListener(objectListener);
}
QModelIndex QtObjectTableModel::index(int row, int column,
const QModelIndex& parent) const
{
if (parent.isValid())
{
if (parent.parent().isValid())
{
ObjectItem* data = static_cast<ObjectItem*> (parent.internalPointer());
poco_assert(data->type == ObjectItem::INSTANCE)
; return createIndex(row, column, data->children[row]);
}
else
{
ObjectItem* data = static_cast<ObjectItem*>(parent.internalPointer());
poco_assert(data->type == ObjectItem::CLASS);
return createIndex(row, column, data->children[row]);
}
}
else
return createIndex(row, column, indexData[row]);
}
QModelIndex QtObjectTableModel::parent(const QModelIndex& index) const
{
ObjectItem* data = static_cast<ObjectItem*>(index.internalPointer());
if (data->parent)
{
return createIndex(data->parent->children.indexOf(data), 0, data->parent);
}
else
{
return QModelIndex();
}
}
int QtObjectTableModel::rowCount(const QModelIndex& parent) const
{
if (parent.isValid())
{
if (parent.parent().isValid())
{
if (parent.parent().parent().isValid()) // smart pointer parent
return 0;
// instance parent
ObjectItem* data = static_cast<ObjectItem*>(parent.internalPointer());
poco_assert(data->type == ObjectItem::INSTANCE);
return data->children.size();
}
else
{
// class parent
ObjectItem* data = static_cast<ObjectItem*>(parent.internalPointer());
poco_assert(data->type == ObjectItem::CLASS);
return data->children.size();
}
}
else
{
// root
return indexData.size();
}
}
int QtObjectTableModel::columnCount(const QModelIndex&) const
{
return 2;
}
QVariant QtObjectTableModel::data(const QModelIndex& index, int role) const
{
if (role == Qt::DisplayRole)
{
if (index.column() == 0)
{
if (index.parent().isValid())
{
QModelIndex parentIndex = index.parent();
if (parentIndex.parent().isValid())
{
ObjectItem* data = static_cast<ObjectItem*>(index.internalPointer());
poco_assert(data->type == ObjectItem::SMARTPOINTER);
return QVariant(QString("SmartPointer (id: ") + QString::number(data->spId) + QString(")"));
}
else
{
ObjectItem* data = static_cast<ObjectItem*>(index.internalPointer());
poco_assert(data->type == ObjectItem::INSTANCE);
#ifdef BLUEBERRY_DEBUG_SMARTPOINTER
QString text = QString::number(data->obj->GetTraceId());
#else
QString text;
#endif
text += QString(" (References: ") + QString::number(data->obj->GetReferenceCount()) + QString(")");
return QVariant(text);
}
}
else
{
ObjectItem* data = static_cast<ObjectItem*>(index.internalPointer());
poco_assert(data->type == ObjectItem::CLASS);
return QVariant(QString(data->className) + " (" + QString::number(data->children.size()) + ")");
}
}
}
else if (role == Qt::CheckStateRole && index.column() == 1)
{
ObjectItem* data = static_cast<ObjectItem*>(index.internalPointer());
if (data->type == ObjectItem::INSTANCE)
{
QVariant var = (DebugUtil::IsTraced(data->obj) ? Qt::Checked : Qt::Unchecked);
return var;
}
else if (data->type == ObjectItem::CLASS)
{
QVariant var = (DebugUtil::IsTraced(data->className) ? Qt::Checked : Qt::Unchecked);
return var;
}
}
else if (role == Qt::DecorationRole && index.column() == 0)
{
ObjectItem* data = static_cast<ObjectItem*>(index.internalPointer());
if (data->type == ObjectItem::INSTANCE)
{
QVariant var;
#ifdef BLUEBERRY_DEBUG_SMARTPOINTER
if (DebugUtil::GetBreakpointManager()->BreakAtObject(data->obj->GetTraceId()))
#else
if(false)
#endif
{
var = QIcon(":/objectinspector/break-enabled.png");
}
return var;
}
else if (data->type == ObjectItem::SMARTPOINTER)
{
QVariant var;
if (DebugUtil::GetBreakpointManager()->BreakAtSmartpointer(data->spId))
{
var = QIcon(":/objectinspector/break-enabled.png");
}
return var;
}
}
else if (role == Qt::UserRole)
{
return QVariant::fromValue(index.internalPointer());
}
return QVariant();
}
QVariant QtObjectTableModel::headerData(int section,
Qt::Orientation orientation, int role) const
{
if (role == Qt::DisplayRole && orientation == Qt::Horizontal)
{
switch (section)
{
case 0:
{
int count = 0;
QListIterator<ObjectItem*> iter(indexData);
while (iter.hasNext())
{
count += iter.next()->children.size();
}
return QVariant(QString("Instances (") + QString::number(count) + ")");
}
case 1:
{
return QVariant(QString("Trace"));
}
}
}
return QVariant();
}
Qt::ItemFlags QtObjectTableModel::flags(const QModelIndex& index) const
{
Qt::ItemFlags flags = QAbstractItemModel::flags(index);
ObjectItem* item = static_cast<ObjectItem*> (index.internalPointer());
if ((item->type == ObjectItem::INSTANCE || item->type == ObjectItem::CLASS)
&& index.column() == 1)
flags |= Qt::ItemIsUserCheckable;
return flags;
}
bool QtObjectTableModel::setData(const QModelIndex &index,
const QVariant &value, int role)
{
if (index.isValid() && index.column() == 1 && role == Qt::CheckStateRole)
{
ObjectItem* item = static_cast<ObjectItem*> (index.internalPointer());
if (value.toInt() == Qt::Checked)
{
if (item->type == ObjectItem::INSTANCE)
DebugUtil::TraceObject(item->obj);
else if (item->type == ObjectItem::CLASS)
DebugUtil::TraceClass(item->className);
}
else
{
if (item->type == ObjectItem::INSTANCE)
DebugUtil::StopTracing(item->obj);
else if (item->type == ObjectItem::CLASS)
DebugUtil::StopTracing(item->className);
}
emit dataChanged(index, index);
return true;
}
return false;
}
void QtObjectTableModel::ResetData()
{
indexData.clear();
DebugUtil::ResetObjectSummary();
QAbstractItemModel::reset();
}
void QtObjectTableModel::ObjectCreated(const Object* obj)
{
// This method is called inside the berry::Object
// constructor, hence we cannot reliably call the virtual
// method berry::Object::GetClassName() to put the new
// object under the right "class" parent. So add it to
// a list of pending objects.
ObjectItem* item = new ObjectItem(obj, 0);
pendingData.push_back(item);
}
void QtObjectTableModel::UpdatePendingData()
{
if (pendingData.empty())
return;
QListIterator<ObjectItem*> instanceIter(pendingData);
while (instanceIter.hasNext())
{
ObjectItem* instanceItem = instanceIter.next();
ObjectItem* classItem = 0;
ObjectItem classSearchItem(instanceItem->obj->GetClassName());
int classIndex = 0;
classItem = FindObjectItem(classSearchItem, classIndex);
if (!classItem)
{
classItem = new ObjectItem(instanceItem->obj->GetClassName());
classItem->children.push_back(instanceItem);
instanceItem->parent = classItem;
classIndex = rowCount(QModelIndex());
beginInsertRows(QModelIndex(), classIndex, classIndex);
indexData.push_back(classItem);
endInsertRows();
}
else
{
instanceItem->parent = classItem;
QModelIndex classModelIndex = createIndex(classIndex, 0, classItem);
int rowIndex = rowCount(classModelIndex);
beginInsertRows(classModelIndex, rowIndex, rowIndex);
classItem->children.push_back(instanceItem);
endInsertRows();
}
}
pendingData.clear();
}
void QtObjectTableModel::ObjectDestroyed(const Object* obj)
{
ObjectItem searchItem(obj, 0);
int index = 0;
ObjectItem* item = FindObjectItem(searchItem, index);
if (!item)
{
QMutableListIterator<ObjectItem*> pendingIter(pendingData);
while (pendingIter.hasNext())
{
ObjectItem* pendingItem = pendingIter.next();
if (pendingItem->obj == obj)
{
pendingIter.remove();
delete pendingItem;
break;
}
}
return;
}
int parentIndex = indexData.indexOf(item->parent);
beginRemoveRows(createIndex(parentIndex, 0, item->parent), index, index);
item->parent->children.removeAt(index);
endRemoveRows();
if (item->parent->children.empty())
{
beginRemoveRows(QModelIndex(), parentIndex, parentIndex);
indexData.removeAt(parentIndex);
endRemoveRows();
delete item->parent;
}
else
{
delete item;
}
}
void QtObjectTableModel::SmartPointerCreated(unsigned int id, const Object* obj)
{
ObjectItem searchInstance(obj, 0);
int instanceIndex = 0;
ObjectItem* instanceItem = FindObjectItem(searchInstance, instanceIndex);
if (!instanceItem)
{
QListIterator<ObjectItem*> pendingIter(pendingData);
while (pendingIter.hasNext())
{
ObjectItem* pendingItem = pendingIter.next();
if (pendingItem->obj == obj)
{
pendingItem->children.push_back(new ObjectItem(id, pendingItem));
break;
}
}
return;
}
int itemIndex = instanceItem->children.size();
beginInsertRows(createIndex(instanceIndex, 0, instanceItem), itemIndex,
itemIndex);
instanceItem->children.push_back(new ObjectItem(id, instanceItem));
endInsertRows();
}
void QtObjectTableModel::SmartPointerDestroyed(unsigned int id, const Object* obj)
{
ObjectItem searchSP(id, 0);
int spIndex = 0;
ObjectItem* spItem = FindObjectItem(searchSP, spIndex);
if (!spItem)
{
QListIterator<ObjectItem*> pendingIter(pendingData);
while (pendingIter.hasNext())
{
ObjectItem* pendingItem = pendingIter.next();
if (pendingItem->obj == obj)
{
QMutableListIterator<ObjectItem*> spIter(pendingItem->children);
while (spIter.hasNext())
{
spItem = spIter.next();
if (spItem->spId == id)
{
spIter.remove();
delete spItem;
return;
}
}
break;
}
}
return;
}
int parentIndex = 0;
ObjectItem searchInstance(obj, 0);
ObjectItem* instanceItem = FindObjectItem(searchInstance, parentIndex);
beginRemoveRows(createIndex(parentIndex, 0, instanceItem), spIndex, spIndex);
instanceItem->children.removeAt(spIndex);
delete spItem;
endRemoveRows();
}
ObjectItem* QtObjectTableModel::FindObjectItem(
const ObjectItem& item, int& index)
{
switch (item.type)
{
case ObjectItem::CLASS:
{
QListIterator<ObjectItem*> i(indexData);
index = 0;
while (i.hasNext())
{
ObjectItem* next = i.next();
if (std::strcmp(next->className, item.className) == 0)
return next;
++index;
}
return 0;
}
case ObjectItem::INSTANCE:
{
QListIterator<ObjectItem*> i(indexData);
while (i.hasNext())
{
ObjectItem* next = i.next();
index = 0;
QListIterator<ObjectItem*> childIter(next->children);
while (childIter.hasNext())
{
ObjectItem* child = childIter.next();
if (child->obj == item.obj)
return child;
++index;
}
}
return 0;
}
case ObjectItem::SMARTPOINTER:
{
QListIterator<ObjectItem*> classIter(indexData);
while (classIter.hasNext())
{
ObjectItem* nextClass = classIter.next();
QListIterator<ObjectItem*> instanceIter(nextClass->children);
while (instanceIter.hasNext())
{
ObjectItem* nextInstance = instanceIter.next();
index = 0;
QListIterator<ObjectItem*> spIter(nextInstance->children);
while (spIter.hasNext())
{
ObjectItem* nextSp = spIter.next();
if (nextSp->spId == item.spId)
return nextSp;
++index;
}
}
}
return 0;
}
}
return 0;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/src/internal/berryQtObjectTableModel.h b/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/src/internal/berryQtObjectTableModel.h
index e6e78a2b74..187898a633 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/src/internal/berryQtObjectTableModel.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/src/internal/berryQtObjectTableModel.h
@@ -1,81 +1,81 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYQTOBJECTTABLEMODEL_H_
#define BERRYQTOBJECTTABLEMODEL_H_
#include <QAbstractItemModel>
#include <QSortFilterProxyModel>
#include <QList>
#include <berryIDebugObjectListener.h>
#include "berryObjectItem.h"
namespace berry
{
class QtObjectTableModel: public QAbstractItemModel
{
Q_OBJECT
public:
QtObjectTableModel(QObject* parent = 0);
~QtObjectTableModel();
QModelIndex index(int row, int column, const QModelIndex& parent =
QModelIndex()) const;
QModelIndex parent(const QModelIndex& index) const;
int rowCount(const QModelIndex&) const;
int columnCount(const QModelIndex&) const;
QVariant data(const QModelIndex& index, int) const;
QVariant headerData(int section, Qt::Orientation orientation, int) const;
Qt::ItemFlags flags(const QModelIndex& index) const;
bool setData(const QModelIndex &index, const QVariant &value, int role);
void ResetData();
protected:
void ObjectCreated(const Object* obj);
void ObjectDestroyed(const Object* obj);
void SmartPointerCreated(unsigned int id, const Object* obj);
void SmartPointerDestroyed(unsigned int id, const Object* obj);
private slots:
void UpdatePendingData();
private:
ObjectItem* FindObjectItem(const ObjectItem& item, int& index);
QList<ObjectItem*> indexData;
QList<ObjectItem*> pendingData;
IDebugObjectListener::Pointer objectListener;
friend class DebugObjectListener;
};
}
#endif /* BERRYQTOBJECTTABLEMODEL_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/manifest.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/manifest.cpp
index 1d2e55d535..05407dab8c 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/manifest.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/manifest.cpp
@@ -1,44 +1,44 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "Poco/ClassLibrary.h"
#include <berryIBundleActivator.h>
#include "src/internal/berryQtPluginActivator.h"
#include "src/internal/berryQtWorkbenchTweaklet.h"
#include "src/internal/berryQtWorkbenchPageTweaklet.h"
#include "src/internal/berryQtDnDTweaklet.h"
#include "src/internal/berryQtWidgetsTweaklet.h"
#include "src/internal/berryQtImageTweaklet.h"
#include "src/internal/berryQtMessageDialogTweaklet.h"
#include "src/internal/defaultpresentation/berryQtWorkbenchPresentationFactory.h"
#include "src/internal/berryQtStylePreferencePage.h"
//**** Activator ****************
POCO_BEGIN_MANIFEST(berry::IBundleActivator)
POCO_EXPORT_CLASS(berry::QtPluginActivator)
POCO_END_MANIFEST
//**** Tweaklets ****************
//**** Preference Pages *****
POCO_BEGIN_NAMED_MANIFEST(berryIPreferencePage, berry::IPreferencePage)
POCO_EXPORT_CLASS(berry::QtStylePreferencePage)
POCO_END_MANIFEST
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/application/berryQtWorkbenchAdvisor.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/application/berryQtWorkbenchAdvisor.cpp
index dd989a23f9..4ea774a36a 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/application/berryQtWorkbenchAdvisor.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/application/berryQtWorkbenchAdvisor.cpp
@@ -1,59 +1,59 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryQtWorkbenchAdvisor.h"
#include "internal/berryQtGlobalEventFilter.h"
#include "berryQtPreferences.h"
#include <berryPlatform.h>
#include <berryIPreferencesService.h>
#include <berryIQtStyleManager.h>
#include <QApplication>
#include <QString>
#include <QTextCodec>
#include <Poco/File.h>
#include <Poco/FileStream.h>
#include <vector>
namespace berry
{
void QtWorkbenchAdvisor::Initialize(IWorkbenchConfigurer::Pointer configurer)
{
WorkbenchAdvisor::Initialize(configurer);
IPreferencesService::Pointer prefService = Platform::GetServiceRegistry().GetServiceById<IPreferencesService>(
IPreferencesService::ID);
IPreferences::Pointer prefs = prefService->GetSystemPreferences()->Node(QtPreferences::QT_STYLES_NODE);
QString styleName = QString::fromStdString(prefs->Get(QtPreferences::QT_STYLE_NAME, ""));
IQtStyleManager::Pointer styleManager = Platform::GetServiceRegistry().GetServiceById<IQtStyleManager>(IQtStyleManager::ID);
styleManager->SetStyle(styleName);
QObject* eventFilter = new QtGlobalEventFilter(qApp);
qApp->installEventFilter(eventFilter);
// character strings should be interpreted as UTF-8 encoded strings
// e.g. plugin.xml files are UTF-8 encoded
QTextCodec* utf8Codec = QTextCodec::codecForName("UTF-8");
QTextCodec::setCodecForCStrings(utf8Codec);
QTextCodec::setCodecForTr(utf8Codec);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/application/berryQtWorkbenchAdvisor.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/application/berryQtWorkbenchAdvisor.h
index 923ad12554..271bde77cd 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/application/berryQtWorkbenchAdvisor.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/application/berryQtWorkbenchAdvisor.h
@@ -1,41 +1,41 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYQTWORKBENCHADVISOR_H_
#define BERRYQTWORKBENCHADVISOR_H_
#include <org_blueberry_ui_qt_Export.h>
#include <berryWorkbenchAdvisor.h>
namespace berry
{
class BERRY_UI_QT QtWorkbenchAdvisor : public WorkbenchAdvisor
{
public:
/**
* Creates the global QApplication object
*/
void Initialize(IWorkbenchConfigurer::Pointer configurer);
};
}
#endif /* BERRYQTWORKBENCHADVISOR_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIQtPreferencePage.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIQtPreferencePage.cpp
index e2a8482f13..5649e9ad78 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIQtPreferencePage.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIQtPreferencePage.cpp
@@ -1,31 +1,31 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryIQtPreferencePage.h"
namespace berry {
void IQtPreferencePage::CreateControl(void* parent)
{
this->CreateQtControl(static_cast<QWidget*>(parent));
}
void* IQtPreferencePage::GetControl() const
{
return (void*)this->GetQtControl();
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIQtPreferencePage.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIQtPreferencePage.h
index 585b086870..bcba4398ec 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIQtPreferencePage.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIQtPreferencePage.h
@@ -1,57 +1,57 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIQTPREFERENCEPAGE_H_
#define BERRYIQTPREFERENCEPAGE_H_
#ifdef __MINGW32__
// We need to include winbase.h here in order to declare
// atomic intrinsics like InterlockedIncrement correctly.
// Otherwhise, they would be declared wrong within qatomic_windows.h .
#include <windows.h>
#endif
#include <QWidget>
#include "berryIPreferencePage.h"
#include <org_blueberry_ui_qt_Export.h>
namespace berry
{
/**
* \ingroup org_blueberry_ui
*
*/
struct BERRY_UI_QT IQtPreferencePage : public IPreferencePage
{
berryInterfaceMacro(IQtPreferencePage, berry);
virtual void CreateQtControl(QWidget* parent) = 0;
virtual QWidget* GetQtControl() const = 0;
protected:
void CreateControl(void* parent);
void* GetControl() const;
};
}
#endif /*BERRYIQTPREFERENCEPAGE_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIQtStyleManager.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIQtStyleManager.cpp
index 96b6b38ecd..e18e5f0a56 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIQtStyleManager.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIQtStyleManager.cpp
@@ -1,23 +1,23 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryIQtStyleManager.h"
namespace berry {
const std::string IQtStyleManager::ID = "org.blueberry.service.qtstylemanager";
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIQtStyleManager.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIQtStyleManager.h
index f9f28df099..c0b7f33811 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIQtStyleManager.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIQtStyleManager.h
@@ -1,89 +1,89 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIQTSTYLEMANAGER_H_
#define BERRYIQTSTYLEMANAGER_H_
#include <berryService.h>
#include <QString>
#include <QList>
#include <QtPlugin>
#include <Poco/Exception.h>
#include <org_blueberry_ui_qt_Export.h>
namespace berry {
struct BERRY_UI_QT IQtStyleManager : public Service
{
berryInterfaceMacro(IQtStyleManager, berry)
struct Style {
QString name;
QString fileName;
Style() {}
Style(const QString& name, const QString& fn)
: name(name), fileName(fn) {}
Style& operator=(const Style& s)
{
this->name = s.name;
this->fileName = s.fileName;
return *this;
}
bool operator<(const Style& s) const
{ return name < s.name; }
bool operator==(const Style& s) const
{ return name == s.name; }
};
static const std::string ID; // = "org.blueberry.service.qtstylemanager";
typedef QList<Style> StyleList;
virtual Style GetStyle() const = 0;
virtual QString GetStylesheet() const = 0;
virtual QString GetActiveTabStylesheet() const = 0;
virtual QString GetTabStylesheet() const = 0;
virtual void AddStyle(const QString& styleFileName, const QString& styleName = QString()) = 0;
virtual void AddStyles(const QString& path) = 0;
virtual void RemoveStyle(const QString& styleFileName) = 0;
virtual void RemoveStyles(const QString& repository = QString()) = 0;
virtual void GetStyles(StyleList& styles) const = 0;
virtual void SetStyle(const QString& fileName) = 0;
virtual Style GetDefaultStyle() const = 0;
virtual void SetDefaultStyle() = 0;
virtual bool Contains(const QString& fileName) const = 0;
};
}
Q_DECLARE_INTERFACE(berry::IQtStyleManager, "org.blueberry.service.IQtStyleManager")
#endif /* BERRYIQTSTYLEMANAGER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQCHPluginListener.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQCHPluginListener.cpp
index 2066c9ead5..185d9d205c 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQCHPluginListener.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQCHPluginListener.cpp
@@ -1,156 +1,156 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryQCHPluginListener.h"
#include <ctkPlugin.h>
#include <QDir>
#include <QDateTime>
#include "berryQtAssistantUtil.h"
namespace berry {
QCHPluginListener::QCHPluginListener(ctkPluginContext* context)
: delayRegistration(true), context(context)
{
}
void QCHPluginListener::processPlugins()
{
if (QtAssistantUtil::GetHelpCollectionFile().isEmpty())
{
return;
}
foreach (QSharedPointer<ctkPlugin> plugin, context->getPlugins())
{
if (isPluginResolved(plugin))
addPlugin(plugin);
else
removePlugin(plugin);
}
delayRegistration = false;
}
void QCHPluginListener::pluginChanged(const ctkPluginEvent& event)
{
if (delayRegistration)
{
this->processPlugins();
return;
}
/* Only should listen for RESOLVED and UNRESOLVED events.
*
* When a plugin is updated the Framework will publish an UNRESOLVED and
* then a RESOLVED event which should cause the plugin to be removed
* and then added back into the registry.
*
* When a plugin is uninstalled the Framework should publish an UNRESOLVED
* event and then an UNINSTALLED event so the plugin will have been removed
* by the UNRESOLVED event before the UNINSTALLED event is published.
*/
QSharedPointer<ctkPlugin> plugin = event.getPlugin();
switch (event.getType())
{
case ctkPluginEvent::RESOLVED :
addPlugin(plugin);
break;
case ctkPluginEvent::UNRESOLVED :
removePlugin(plugin);
break;
}
}
bool QCHPluginListener::isPluginResolved(QSharedPointer<ctkPlugin> plugin)
{
return (plugin->getState() & (ctkPlugin::RESOLVED | ctkPlugin::ACTIVE | ctkPlugin::STARTING | ctkPlugin::STOPPING)) != 0;
}
void QCHPluginListener::removePlugin(QSharedPointer<ctkPlugin> plugin)
{
// bail out if system plugin
if (plugin->getPluginId() == 0) return;
QFileInfo qchDirInfo = context->getDataFile("qch_files/" + QString::number(plugin->getPluginId()));
if (qchDirInfo.exists())
{
QDir qchDir(qchDirInfo.absoluteFilePath());
QStringList qchEntries = qchDir.entryList(QStringList("*.qch"));
QStringList qchFiles;
foreach(QString qchEntry, qchEntries)
{
qchFiles << qchDir.absoluteFilePath(qchEntry);
}
// unregister the qch files
QtAssistantUtil::UnregisterQCHFiles(qchFiles);
// clean the directory
foreach(QString qchEntry, qchEntries)
{
qchDir.remove(qchEntry);
}
}
}
void QCHPluginListener::addPlugin(QSharedPointer<ctkPlugin> plugin)
{
// bail out if system plugin
if (plugin->getPluginId() == 0) return;
QFileInfo qchDirInfo = context->getDataFile("qch_files/" + QString::number(plugin->getPluginId()));
QUrl location(plugin->getLocation());
QFileInfo pluginFileInfo(location.toLocalFile());
if (!qchDirInfo.exists() || qchDirInfo.lastModified() < pluginFileInfo.lastModified())
{
removePlugin(plugin);
if (!qchDirInfo.exists())
{
QDir().mkpath(qchDirInfo.absoluteFilePath());
}
QStringList localQCHFiles;
QStringList resourceList = plugin->findResources("/", "*.qch", true);
foreach(QString resource, resourceList)
{
QByteArray content = plugin->getResource(resource);
QFile localFile(qchDirInfo.absoluteFilePath() + "/" + resource.section('/', -1));
localFile.open(QIODevice::WriteOnly);
localFile.write(content);
localFile.close();
if (localFile.error() != QFile::NoError)
{
BERRY_WARN << "Error writing " << localFile.fileName().toStdString()
<< ": " << localFile.errorString().toStdString();
}
else
{
localQCHFiles << localFile.fileName();
}
}
QtAssistantUtil::RegisterQCHFiles(localQCHFiles);
}
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQCHPluginListener.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQCHPluginListener.h
index f1bbcf11d4..f7b5e1355a 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQCHPluginListener.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQCHPluginListener.h
@@ -1,75 +1,75 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYQCHPLUGINLISTENER_P_H
#define BERRYQCHPLUGINLISTENER_P_H
#include <QObject>
#include <QSharedPointer>
#include <ctkPluginEvent.h>
#include <berryIExtensionPointService.h>
#include <org_blueberry_ui_qt_Export.h>
class ctkPlugin;
namespace berry {
/**
* A listener for CTK plugin events. When plugins come and go we look to see
* if there are any extensions or extension points and update the legacy BlueBerry registry accordingly.
* Using a Synchronous listener here is important. If the
* plugin activator code tries to access the registry to get its extension
* points, we need to ensure that they are in the registry before the
* plugin start is called. By listening sync we are able to ensure that
* happens.
*
* \deprecated Use the org.blueberry.ui.qt.help plug-in instead.
* \see org_blueberry_ui_qt_help
*/
class BERRY_UI_QT QCHPluginListener : public QObject {
Q_OBJECT
public:
QCHPluginListener(ctkPluginContext* context);
void processPlugins();
public slots:
void pluginChanged(const ctkPluginEvent& event);
private:
bool isPluginResolved(QSharedPointer<ctkPlugin> plugin);
void removePlugin(QSharedPointer<ctkPlugin> plugin);
void addPlugin(QSharedPointer<ctkPlugin> plugin);
bool delayRegistration;
ctkPluginContext* context;
};
}
#endif // BERRYQCHPLUGINLISTENER_P_H
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQModelIndexObject.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQModelIndexObject.cpp
index 6fff9d217e..70ce783d08 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQModelIndexObject.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQModelIndexObject.cpp
@@ -1,43 +1,43 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryQModelIndexObject.h"
namespace berry
{
QModelIndexObject::QModelIndexObject(const QModelIndex& index) :
m_QModelIndex(index)
{
}
const QModelIndex& QModelIndexObject::GetQModelIndex() const
{
return m_QModelIndex;
}
bool QModelIndexObject::operator==(const Object* obj) const
{
if (const QModelIndexObject* other = dynamic_cast<const QModelIndexObject*>(obj))
{
return m_QModelIndex == other->m_QModelIndex;
}
return false;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQModelIndexObject.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQModelIndexObject.h
index c1394e9496..71dfbbca11 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQModelIndexObject.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQModelIndexObject.h
@@ -1,50 +1,50 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYQMODELINDEXOBJECT_H_
#define BERRYQMODELINDEXOBJECT_H_
#include <berryObject.h>
#include <berryMacros.h>
#include <QModelIndex>
namespace berry
{
class QModelIndexObject : public Object
{
public:
berryObjectMacro(berry::QModelIndexObject)
QModelIndexObject(const QModelIndex& index);
const QModelIndex& GetQModelIndex() const;
bool operator==(const Object* obj) const;
private:
QModelIndex m_QModelIndex;
};
}
#endif /* BERRYQMODELINDEXOBJECT_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtAssistantUtil.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtAssistantUtil.cpp
index c0efb14e61..d1877585ea 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtAssistantUtil.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtAssistantUtil.cpp
@@ -1,334 +1,334 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryQtAssistantUtil.h"
#include <berryPlatformUI.h>
#include <berryConfig.h>
#include <berryLog.h>
#include <berryIBundleStorage.h>
#include <berryIWorkbench.h>
#include <berryIWorkbenchPage.h>
#include <berryIWorkbenchPart.h>
#include <QFileInfo>
#include <QProgressDialog>
#include <QMessageBox>
#include <QDir>
#include <QCoreApplication>
#include <QDebug>
namespace berry
{
QProcess* QtAssistantUtil::assistantProcess = 0;
QString QtAssistantUtil::helpCollectionFile;
QString QtAssistantUtil::defaultHelpUrl;
QSet<QString> QtAssistantUtil::registeredBundles;
void QtAssistantUtil::SetHelpCollectionFile(const QString& file)
{
helpCollectionFile = file;
}
QString QtAssistantUtil::GetHelpCollectionFile()
{
return helpCollectionFile;
}
void QtAssistantUtil::OpenActivePartHelp()
{
//Get Plugin-ID
QString pluginID;
berry::IWorkbench* currentWorkbench = berry::PlatformUI::GetWorkbench();
if (currentWorkbench)
{
berry::IWorkbenchWindow::Pointer currentWorkbenchWindow = currentWorkbench->GetActiveWorkbenchWindow();
if (currentWorkbenchWindow)
{
berry::IWorkbenchPage::Pointer currentPage = currentWorkbenchWindow->GetActivePage();
if (currentPage)
{
berry::IWorkbenchPart::Pointer currentPart = currentPage->GetActivePart();
if (currentPart) pluginID = QString::fromStdString(currentPart->GetSite()->GetPluginId());
}
}
}
//End get Plugin-ID
QString helpUrl = defaultHelpUrl;
if (!pluginID.isEmpty() && registeredBundles.contains(pluginID))
helpUrl = "qthelp://"+pluginID+"/bundle/index.html";
OpenAssistant(helpUrl);
}
void QtAssistantUtil::OpenAssistant(const QString& startPage)
{
QString startUrl = startPage;
if (startUrl.isEmpty()) startUrl = defaultHelpUrl;
if (assistantProcess == 0)
{
assistantProcess = new QProcess;
}
if (assistantProcess->state() == QProcess::NotRunning)
{
QStringList assistantArgs;
if (!helpCollectionFile.isEmpty())
{
assistantArgs << QLatin1String("-collectionFile")
<< QLatin1String(helpCollectionFile.toLatin1());
}
assistantArgs << QLatin1String("-enableRemoteControl")
<< QLatin1String("-showUrl")
<< QLatin1String(startUrl.toLatin1());
assistantProcess->start(GetAssistantExecutable(), assistantArgs);
}
else
{
QByteArray ba;
ba.append("setSource ").append(startUrl.toLatin1()).append('\0');
assistantProcess->write(ba);
}
}
void QtAssistantUtil::CloseAssistant()
{
if (assistantProcess && (assistantProcess->state() != QProcess::NotRunning))
{
assistantProcess->close();
}
delete assistantProcess;
}
bool QtAssistantUtil::RegisterQCHFiles(const std::vector<IBundle::Pointer>& bundles)
{
QStringList qchFiles = ExtractQCHFiles(bundles);
// unregister old files
CallQtAssistant(qchFiles, false);
return CallQtAssistant(qchFiles, true);
}
bool QtAssistantUtil::RegisterQCHFiles(const QStringList& qchFiles)
{
return CallQtAssistant(qchFiles, true);
}
bool QtAssistantUtil::UnregisterQCHFiles(const QStringList& qchFiles)
{
return CallQtAssistant(qchFiles, false);
}
QStringList QtAssistantUtil::ExtractQCHFiles(const std::vector<IBundle::Pointer>& bundles)
{
QStringList result;
for (std::size_t i = 0; i < bundles.size(); ++i)
{
std::vector<std::string> resourceFiles;
bundles[i]->GetStorage().List("resources", resourceFiles);
bool qchFileFound = false;
for (std::size_t j = 0; j < resourceFiles.size(); ++j)
{
QString resource = QString::fromStdString(resourceFiles[j]);
if (resource.endsWith(".qch"))
{
qchFileFound = true;
Poco::Path qchPath = bundles[i]->GetPath();
qchPath.pushDirectory("resources");
qchPath.setFileName(resourceFiles[j]);
result << QString::fromStdString(qchPath.toString());
}
}
if (qchFileFound)
{
registeredBundles.insert(QString::fromStdString(bundles[i]->GetSymbolicName()));
}
}
return result;
}
bool QtAssistantUtil::CallQtAssistant(const QStringList& qchFiles, bool registerFile)
{
if (qchFiles.empty()) return true;
bool success = true;
QList<QStringList> argsVector;
foreach (QString qchFile, qchFiles)
{
QStringList args;
if (!helpCollectionFile.isEmpty())
{
args << QLatin1String("-collectionFile") << helpCollectionFile;
}
if (registerFile)
{
args << QLatin1String("-register");
}
else
{
args << QLatin1String("-unregister");
}
args << qchFile;
// This is necessary on Windows to suppress the pop-up dialogs on registering
// or unregistering .qch files. Unfortunately, it also suppresses specific
// error messages.
args << QLatin1String("-quiet");
//BERRY_INFO << "Registering " << qchFile.toStdString() << " with " << helpCollectionFile.toStdString();
argsVector.push_back(args);
}
QString progressLabel(registerFile ? "Registering help files..." : "Unregistering help files...");
QString progressCancel(registerFile ? "Abort Registration" : "Abort Unregistration");
QProgressDialog progress(progressLabel, progressCancel, 0, argsVector.size());
progress.setWindowModality(Qt::WindowModal);
QString assistantExec = GetAssistantExecutable();
QString errorString;
int exitCode = 0;
for (int i = 0; i < argsVector.size(); ++i)
{
const QStringList& args = argsVector[i];
progress.setValue(i);
QString labelText = (registerFile ? QString("Registering ") : QString("Unregistering ")) + args[3];
progress.setLabelText(labelText);
if (progress.wasCanceled())
{
success = false;
break;
}
QProcess* process = new QProcess;
//qDebug() << "***** " << assistantExec << args;
process->start(assistantExec, args);
BERRY_INFO << (registerFile ? "Registering " : "Unregistering ")
<< "Qt compressed help file: " << qchFiles[i].toStdString();
if (!process->waitForFinished())
{
success = false;
if (registerFile)
{
BERRY_ERROR << "Registering compressed help file" << args[3].toStdString() << " failed";
}
else
{
BERRY_ERROR << "Unregistering compressed help file" << args[3].toStdString() << " failed";
}
errorString = process->errorString();
}
//qDebug() << process->readAll();
if (process->error() != QProcess::UnknownError)
{
errorString = process->errorString();
success = false;
}
// Report errors only if we are registering files. If for example the plugin containing the
// original .qhc file has been updated, unregistering .qch files may fail but it should
// not be treated as an error.
if (process->exitCode() != 0 && registerFile)
{
exitCode = process->exitCode();
errorString = process->readAllStandardError();
}
if (success && exitCode == 0)
{
// Use a hack to get the plug-in id from the qch path
QString strId = QFileInfo(qchFiles[i]).dir().dirName();
if (strId.isEmpty())
{
BERRY_ERROR << "Could not get last directory name from: " << qchFiles[i].toStdString();
}
else
{
bool okay = true;
long pluginId = strId.toLong(&okay);
if (okay)
{
QSharedPointer<ctkPlugin> plugin = berry::Platform::GetCTKPlugin(pluginId);
if (plugin)
{
if (registerFile)
{
registeredBundles.insert(plugin->getSymbolicName());
}
else
{
registeredBundles.remove(plugin->getSymbolicName());
}
}
}
else
{
BERRY_WARN << "Could convert last directory name into an integer (legacy BlueBerry plug-in?): " << qchFiles[i].toStdString();
}
}
}
}
progress.setValue(argsVector.size());
if (!errorString.isEmpty() || exitCode)
{
QString errText;
if (errorString.isEmpty())
{
if (registerFile) errText += "Registering ";
else errText += "Unregistering ";
errText += "one or more help files failed.";
errText += "\nYou may not have write permissions in " + QDir::toNativeSeparators(QDir::homePath());
}
else
{
errText += errorString;
}
QMessageBox::warning(0, "Help System Error", errText);
}
return success;
}
QString QtAssistantUtil::GetAssistantExecutable()
{
QFileInfo assistantFile(QT_ASSISTANT_EXECUTABLE);
QFileInfo localAssistant(QCoreApplication::applicationDirPath() + "/" + assistantFile.fileName() );
if (localAssistant.isExecutable())
{
return localAssistant.absoluteFilePath();
}
else
{
return assistantFile.absoluteFilePath();
}
}
void QtAssistantUtil::SetDefaultHelpUrl(const QString& defaultUrl)
{
defaultHelpUrl = defaultUrl;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtAssistantUtil.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtAssistantUtil.h
index d494c2a598..ec1eb5b83b 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtAssistantUtil.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtAssistantUtil.h
@@ -1,80 +1,80 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYQTASSISTANTUTIL_H_
#define BERRYQTASSISTANTUTIL_H_
#include <QStringList>
#include <QProcess>
#include <vector>
#include <berryIBundle.h>
#include <ctkPlugin.h>
#include <QSharedPointer>
#include <org_blueberry_ui_qt_Export.h>
namespace berry {
/**
* \deprecated Use the org.blueberry.ui.qt.help plug-in instead.
* \see org_blueberry_ui_qt_help
*
* This class is deprecated. Please use the org.blueberry.ui.qt.help
* plug-in if you want to access help contents in your application.
*/
class BERRY_UI_QT QtAssistantUtil
{
public:
static void OpenAssistant(const QString& startPage = "");
static void CloseAssistant();
/**
* @brief With this method you can open the help-page of the active bundle.
*/
static void OpenActivePartHelp();
// for legacy BlueBerry bundle support
static bool RegisterQCHFiles(const std::vector<IBundle::Pointer>& bundles);
static bool RegisterQCHFiles(const QStringList& qchFiles);
static bool UnregisterQCHFiles(const QStringList& qchFiles);
static void SetHelpCollectionFile(const QString& file);
static QString GetHelpCollectionFile();
static void SetDefaultHelpUrl(const QString& defaultUrl);
private:
static QProcess* assistantProcess;
static QString helpCollectionFile;
static QString defaultHelpUrl;
static QSet<QString> registeredBundles;
static QString GetAssistantExecutable();
static QStringList ExtractQCHFiles(const std::vector<IBundle::Pointer>& bundles);
static bool CallQtAssistant(const QStringList& qchFiles, bool registerFile = true);
};
}
#endif /* BERRYQTASSISTANTUTIL_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtEditorPart.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtEditorPart.cpp
index dea9475287..25137bd8f0 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtEditorPart.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtEditorPart.cpp
@@ -1,27 +1,27 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryQtEditorPart.h"
namespace berry
{
void QtEditorPart::CreatePartControl(void* parent)
{
this->CreateQtPartControl(static_cast<QWidget*>(parent));
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtEditorPart.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtEditorPart.h
index be4e966919..44b9150eae 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtEditorPart.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtEditorPart.h
@@ -1,42 +1,42 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYQTEDITORPART_H_
#define BERRYQTEDITORPART_H_
#include <berryEditorPart.h>
#include <QWidget>
#include <org_blueberry_ui_qt_Export.h>
namespace berry
{
class BERRY_UI_QT QtEditorPart : public EditorPart
{
public:
berryObjectMacro(QtEditorPart);
void CreatePartControl(void* parent);
protected:
virtual void CreateQtPartControl(QWidget* parent) = 0;
};
}
#endif /*BERRYQTEDITORPART_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtIntroPart.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtIntroPart.cpp
index f2ec72bf6e..530a86d6ba 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtIntroPart.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtIntroPart.cpp
@@ -1,27 +1,27 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryQtIntroPart.h"
namespace berry
{
void QtIntroPart::CreatePartControl(void* parent)
{
this->CreateQtPartControl(static_cast<QWidget*>(parent));
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtIntroPart.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtIntroPart.h
index 2ca65fb641..a638928db5 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtIntroPart.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtIntroPart.h
@@ -1,47 +1,47 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYQTINTROPART_H_
#define BERRYQTINTROPART_H_
#include <berryIntroPart.h>
#include <org_blueberry_ui_qt_Export.h>
#include <QWidget>
namespace berry
{
class BERRY_UI_QT QtIntroPart : public IntroPart
{
public:
berryObjectMacro(QtIntroPart);
void CreatePartControl(void* parent);
protected:
virtual void CreateQtPartControl(QWidget* parent) = 0;
};
}
#endif /* BERRYQTINTROPART_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtItemSelection.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtItemSelection.cpp
index 3b0734350c..d5daf7aec3 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtItemSelection.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtItemSelection.cpp
@@ -1,86 +1,86 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryQtItemSelection.h"
#include "berryQModelIndexObject.h"
namespace berry {
QtItemSelection::QtItemSelection()
{
}
QtItemSelection::QtItemSelection(const QItemSelection& sel)
: m_Selection(new ContainerType())
{
QModelIndexList indexes = sel.indexes();
for (QModelIndexList::const_iterator index = indexes.constBegin(); index != indexes.constEnd(); ++index)
{
Object::Pointer indexObj(new QModelIndexObject(*index));
m_Selection->push_back(indexObj);
}
}
QItemSelection QtItemSelection::GetQItemSelection() const
{
return m_QItemSelection;
}
bool QtItemSelection::IsEmpty() const
{
return m_Selection->empty();
}
Object::Pointer QtItemSelection::GetFirstElement() const
{
if (m_Selection->empty()) return Object::Pointer();
return *(m_Selection->begin());
}
QtItemSelection::iterator QtItemSelection::Begin() const
{
return m_Selection->begin();
}
QtItemSelection::iterator QtItemSelection::End() const
{
return m_Selection->end();
}
int QtItemSelection::Size() const
{
return (int) m_Selection->size();
}
QtItemSelection::ContainerType::Pointer QtItemSelection::ToVector() const
{
return m_Selection;
}
bool QtItemSelection::operator==(const Object* obj) const
{
if (const IStructuredSelection* other = dynamic_cast<const IStructuredSelection*>(obj))
{
return m_Selection == other->ToVector();
}
return false;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtItemSelection.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtItemSelection.h
index d35363960b..fed7fedc5f 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtItemSelection.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtItemSelection.h
@@ -1,60 +1,60 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYQTITEMSELECTION_H_
#define BERRYQTITEMSELECTION_H_
#include <org_blueberry_ui_qt_Export.h>
#include <berryIStructuredSelection.h>
#include <QItemSelection>
namespace berry {
class BERRY_UI_QT QtItemSelection : public virtual IStructuredSelection
{
public:
berryObjectMacro(QtItemSelection)
QtItemSelection();
QtItemSelection(const QItemSelection& sel);
QItemSelection GetQItemSelection() const;
bool IsEmpty() const;
Object::Pointer GetFirstElement() const;
iterator Begin() const;
iterator End() const;
int Size() const;
ContainerType::Pointer ToVector() const;
bool operator==(const Object* obj) const;
private:
ContainerType::Pointer m_Selection;
QItemSelection m_QItemSelection;
};
}
#endif /* BERRYQTITEMSELECTION_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtPreferences.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtPreferences.cpp
index 633714b3c7..5508f28166 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtPreferences.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtPreferences.cpp
@@ -1,25 +1,25 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryQtPreferences.h"
namespace berry {
const std::string QtPreferences::QT_STYLES_NODE = "qtstyles";
const std::string QtPreferences::QT_STYLE_NAME = "stylename";
const std::string QtPreferences::QT_STYLE_SEARCHPATHS = "searchpaths";
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtPreferences.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtPreferences.h
index 6ddbbad12b..1b5982694f 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtPreferences.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtPreferences.h
@@ -1,35 +1,35 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYQTPREFERENCES_H_
#define BERRYQTPREFERENCES_H_
#include <org_blueberry_ui_qt_Export.h>
#include <string>
namespace berry {
struct BERRY_UI_QT QtPreferences
{
static const std::string QT_STYLES_NODE; // = "qtstyles";
static const std::string QT_STYLE_NAME; // = "stylename";
static const std::string QT_STYLE_SEARCHPATHS; // = "searchpaths";
};
}
#endif /* BERRYQTPREFERENCES_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtSelectionProvider.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtSelectionProvider.cpp
index 7fd3922edf..79d2bacc46 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtSelectionProvider.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtSelectionProvider.cpp
@@ -1,119 +1,119 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryLog.h"
#include "berryQtSelectionProvider.h"
#include "berryQtItemSelection.h"
#include "berryQModelIndexObject.h"
namespace berry {
QtSelectionProvider
::QtSelectionProvider() : qSelectionModel(0)
{
}
void
QtSelectionProvider
::AddSelectionChangedListener(ISelectionChangedListener::Pointer l)
{
selectionEvents.AddListener(l);
}
void
QtSelectionProvider
::RemoveSelectionChangedListener(ISelectionChangedListener::Pointer l)
{
selectionEvents.RemoveListener(l);
}
ISelection::ConstPointer
QtSelectionProvider
::GetSelection() const
{
if (qSelectionModel)
{
QtItemSelection::Pointer qsel(new QtItemSelection(qSelectionModel->selection()));
return qsel;
}
return QtItemSelection::Pointer(new QtItemSelection());
}
void
QtSelectionProvider
::SetSelection(ISelection::Pointer selection)
{
if (!qSelectionModel) return;
if (QtItemSelection::Pointer qsel = selection.Cast<QtItemSelection>())
{
qSelectionModel->select(qsel->GetQItemSelection(), QItemSelectionModel::Select);
}
}
QItemSelection
QtSelectionProvider
::GetQItemSelection() const
{
if (qSelectionModel)
return qSelectionModel->selection();
return QItemSelection();
}
void
QtSelectionProvider
::SetQItemSelection(const QItemSelection& selection)
{
if (qSelectionModel)
qSelectionModel->select(selection, QItemSelectionModel::Select);
}
QItemSelectionModel*
QtSelectionProvider
::GetItemSelectionModel() const
{
return qSelectionModel;
}
void QtSelectionProvider::SetItemSelectionModel(QItemSelectionModel* selModel)
{
if (qSelectionModel)
{
qSelectionModel->disconnect(this);
}
qSelectionModel = selModel;
if (qSelectionModel)
{
this->connect(qSelectionModel, SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)), this, SLOT(FireSelectionChanged(const QItemSelection&, const QItemSelection&)));
}
}
void QtSelectionProvider::FireSelectionChanged(const QItemSelection& /*selected*/, const QItemSelection& /*deselected*/)
{
QtItemSelection::Pointer sel(new QtItemSelection(this->GetQItemSelection()));
SelectionChangedEvent::Pointer event(new SelectionChangedEvent(ISelectionProvider::Pointer(this), sel));
selectionEvents.selectionChanged(event);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtSelectionProvider.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtSelectionProvider.h
index f28101ea22..715f63443d 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtSelectionProvider.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtSelectionProvider.h
@@ -1,68 +1,68 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYQTSELECTIONPROVIDER_H_
#define BERRYQTSELECTIONPROVIDER_H_
#include <org_blueberry_ui_qt_Export.h>
#include <berryISelectionProvider.h>
#include <QItemSelectionModel>
#include <QItemSelection>
#include <QObject>
namespace berry
{
class BERRY_UI_QT QtSelectionProvider: public QObject,
public ISelectionProvider
{
Q_OBJECT
public:
berryObjectMacro(QtSelectionProvider)
QtSelectionProvider();
void AddSelectionChangedListener(ISelectionChangedListener::Pointer listener);
void RemoveSelectionChangedListener(
ISelectionChangedListener::Pointer listener);
ISelection::ConstPointer GetSelection() const;
void SetSelection(ISelection::Pointer selection);
QItemSelection GetQItemSelection() const;
void SetQItemSelection(const QItemSelection& selection);
QItemSelectionModel* GetItemSelectionModel() const;
void SetItemSelectionModel(QItemSelectionModel* combo);
protected:
ISelectionChangedListener::Events selectionEvents;
QItemSelectionModel* qSelectionModel;
protected slots:
virtual void FireSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected);
};
}
#endif /* BERRYQTSELECTIONPROVIDER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtViewPart.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtViewPart.cpp
index 619a2e81eb..05a0ce95f1 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtViewPart.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtViewPart.cpp
@@ -1,27 +1,27 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryQtViewPart.h"
namespace berry
{
void QtViewPart::CreatePartControl(void* parent)
{
this->CreateQtPartControl(static_cast<QWidget*>(parent));
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtViewPart.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtViewPart.h
index 502d9ae6fc..edc7ac4b15 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtViewPart.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtViewPart.h
@@ -1,53 +1,53 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYQTVIEWPART_H_
#define BERRYQTVIEWPART_H_
#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 <windows.h>
#endif
#include <berryViewPart.h>
#include <org_blueberry_ui_qt_Export.h>
#include <QWidget>
namespace berry
{
class BERRY_UI_QT QtViewPart : public ViewPart
{
public:
berryObjectMacro(QtViewPart);
void CreatePartControl(void* parent);
protected:
virtual void CreateQtPartControl(QWidget* parent) = 0;
};
}
#endif /*BERRYQTVIEWPART_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtDisplay.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtDisplay.cpp
index 5d83d9423d..72a5b1e718 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtDisplay.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtDisplay.cpp
@@ -1,69 +1,69 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryQtDisplay.h"
#include "berryQtSafeApplication.h"
namespace berry {
QtDisplay::QtDisplay()
{
this->CreateDisplay();
}
bool QtDisplay::InDisplayThread()
{
return displayThread == QThread::currentThread();
}
void QtDisplay::AsyncExec(Poco::Runnable* runnable)
{
emit NewAsyncRunnable(runnable);
}
void QtDisplay::SyncExec(Poco::Runnable* runnable)
{
emit NewSyncRunnable(runnable);
}
int QtDisplay::RunEventLoop()
{
return QApplication::exec();
}
void QtDisplay::ExitEventLoop(int code)
{
QApplication::exit(code);
}
void QtDisplay::CreateDisplay()
{
Display::instance = this;
displayThread = QThread::currentThread();
QtSafeApplication::CreateInstance();
this->connect(this, SIGNAL(NewAsyncRunnable(Poco::Runnable*)), this, SLOT(ExecuteRunnable(Poco::Runnable*)));
this->connect(this, SIGNAL(NewSyncRunnable(Poco::Runnable*)), this, SLOT(ExecuteRunnable(Poco::Runnable*)), Qt::BlockingQueuedConnection);
}
void QtDisplay::ExecuteRunnable(Poco::Runnable* runnable)
{
runnable->run();
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtDisplay.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtDisplay.h
index f11565fab6..2352fa1dab 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtDisplay.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtDisplay.h
@@ -1,78 +1,78 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYQTDISPLAY_H_
#define BERRYQTDISPLAY_H_
#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 <windows.h>
#endif
#include <berryDisplay.h>
#include <QObject>
#include <QThread>
namespace berry
{
class QtDisplay: public QObject, public Display
{
Q_OBJECT
public:
QtDisplay();
bool InDisplayThread();
void AsyncExec(Poco::Runnable*);
void SyncExec(Poco::Runnable*);
int RunEventLoop();
void ExitEventLoop(int code);
signals:
void NewAsyncRunnable(Poco::Runnable*);
void NewSyncRunnable(Poco::Runnable*);
protected:
/**
* This method must be called from within the UI thread
* and should create the Display instance and initialize
* variables holding implementation specific thread data.
*/
void CreateDisplay();
protected slots:
void ExecuteRunnable(Poco::Runnable*);
private:
QThread * displayThread;
};
}
#endif /* BERRYQTDISPLAY_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtDnDTweaklet.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtDnDTweaklet.cpp
index d7c7c09fac..917857bb02 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtDnDTweaklet.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtDnDTweaklet.cpp
@@ -1,38 +1,38 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryQtDnDTweaklet.h"
#include "berryQtTracker.h"
namespace berry {
QtDnDTweaklet::QtDnDTweaklet()
{
}
QtDnDTweaklet::QtDnDTweaklet(const QtDnDTweaklet& other)
{
Q_UNUSED(other)
}
ITracker* QtDnDTweaklet::CreateTracker()
{
return new QtTracker();
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtDnDTweaklet.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtDnDTweaklet.h
index fe58ed1ae8..38ac898040 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtDnDTweaklet.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtDnDTweaklet.h
@@ -1,40 +1,40 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYQTDNDTWEAKLET_H_
#define BERRYQTDNDTWEAKLET_H_
#include <berryDnDTweaklet.h>
namespace berry {
class QtDnDTweaklet : public QObject, public DnDTweaklet
{
Q_OBJECT
Q_INTERFACES(berry::DnDTweaklet)
public:
QtDnDTweaklet();
QtDnDTweaklet(const QtDnDTweaklet& other);
ITracker* CreateTracker();
};
}
#endif /* BERRYQTDNDTWEAKLET_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtFileImageDescriptor.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtFileImageDescriptor.cpp
index d9beeba513..ba76a7f506 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtFileImageDescriptor.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtFileImageDescriptor.cpp
@@ -1,110 +1,110 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryQtFileImageDescriptor.h"
#include "tweaklets/berryImageTweaklet.h"
#include <QIcon>
#include <QPixmap>
#include <QByteArray>
#include <Poco/FileStream.h>
#include <Poco/Exception.h>
namespace berry
{
QtFileImageDescriptor::QtFileImageDescriptor(const std::string& filename,
const std::string& pluginid) :
filename(filename), pluginid(pluginid)
{
}
void* QtFileImageDescriptor::CreateImage(bool returnMissingImageOnError)
{
if (pluginid.empty())
{
try
{
Poco::FileInputStream fs(filename);
return this->CreateFromStream(&fs);
} catch (const Poco::FileNotFoundException* e)
{
BERRY_ERROR << e->displayText() << std::endl;
if (returnMissingImageOnError)
return GetMissingImageDescriptor()->CreateImage();
}
}
else
{
IBundle::Pointer bundle(Platform::GetBundle(pluginid));
if (!bundle)
{
if (returnMissingImageOnError)
return GetMissingImageDescriptor()->CreateImage();
return 0;
}
std::istream* s = bundle->GetResource(filename);
if (!s && returnMissingImageOnError)
return GetMissingImageDescriptor()->CreateImage();
if (s) {
void* image = this->CreateFromStream(s);
delete s;
return image;
}
}
return 0;
}
void QtFileImageDescriptor::DestroyImage(void* img)
{
const QIcon* icon = static_cast<const QIcon*>(img);
delete icon;
}
QIcon* QtFileImageDescriptor::CreateFromStream(std::istream* s)
{
s->seekg(0, std::ios::end);
std::ios::pos_type length = s->tellg();
s->seekg(0, std::ios::beg);
char* data = new char[length];
s->read(data, length);
QPixmap pixmap;
pixmap.loadFromData(QByteArray::fromRawData(data, length));
QIcon* icon = new QIcon(pixmap);
delete[] data;
return icon;
}
bool QtFileImageDescriptor::operator ==(const Object* o) const
{
if (const QtFileImageDescriptor* obj = dynamic_cast<const QtFileImageDescriptor*>(o))
{
return this->pluginid == obj->pluginid && this->filename == obj->filename;
}
return false;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtFileImageDescriptor.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtFileImageDescriptor.h
index c09beb0e9e..37abf0f371 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtFileImageDescriptor.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtFileImageDescriptor.h
@@ -1,52 +1,52 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYFILEIMAGEDESCRIPTOR_H_
#define BERRYFILEIMAGEDESCRIPTOR_H_
#include "berryImageDescriptor.h"
#include <iostream>
class QIcon;
namespace berry {
class QtFileImageDescriptor : public ImageDescriptor
{
private:
const std::string filename;
const std::string pluginid;
QIcon* CreateFromStream(std::istream* s);
public:
QtFileImageDescriptor(const std::string& filename, const std::string& pluginid);
virtual void* CreateImage(bool returnMissingImageOnError = true);
virtual void DestroyImage(void* img);
bool operator ==(const Object* o) const;
};
}
#endif /* BERRYFILEIMAGEDESCRIPTOR_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtGlobalEventFilter.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtGlobalEventFilter.cpp
index 90cf2c4add..3003550345 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtGlobalEventFilter.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtGlobalEventFilter.cpp
@@ -1,60 +1,60 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryQtGlobalEventFilter.h"
#include "internal/berryQtControlWidget.h"
#include <QEvent>
#include <QMouseEvent>
#include <QApplication>
#include <QWidget>
#include <iostream>
namespace berry {
QtGlobalEventFilter::QtGlobalEventFilter(QObject* parent)
: QObject(parent)
{
}
bool QtGlobalEventFilter::eventFilter(QObject* /*obj*/, QEvent* event)
{
if (event->type() == QEvent::MouseButtonPress)
{
QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event);
QWidget* widget = QApplication::widgetAt(mouseEvent->globalPos());
if (widget)
{
QObject* parent = widget;
while (parent)
{
if (parent->objectName() == "PartPaneControl")
{
(dynamic_cast<QtControlWidget*>(parent))->FireActivateEvent();
break;
}
parent = parent->parent();
}
}
}
return false;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtGlobalEventFilter.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtGlobalEventFilter.h
index 477b19a5c3..0378fa49d1 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtGlobalEventFilter.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtGlobalEventFilter.h
@@ -1,40 +1,40 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYQTGLOBALEVENTFILTER_H_
#define BERRYQTGLOBALEVENTFILTER_H_
#include <QObject>
class QEvent;
namespace berry {
class QtGlobalEventFilter : public QObject
{
Q_OBJECT
public:
QtGlobalEventFilter(QObject* parent = 0);
bool eventFilter(QObject* obj, QEvent* event);
};
}
#endif /* BERRYQTGLOBALEVENTFILTER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtIconImageDescriptor.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtIconImageDescriptor.cpp
index d9282ce084..cd7b48b3b1 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtIconImageDescriptor.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtIconImageDescriptor.cpp
@@ -1,60 +1,60 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryQtIconImageDescriptor.h"
#include <QIcon>
namespace berry {
QtIconImageDescriptor::QtIconImageDescriptor(void* img)
: icon(static_cast<QIcon*>(img))
{
}
QtIconImageDescriptor::~QtIconImageDescriptor()
{
delete icon;
}
void* QtIconImageDescriptor::CreateImage(bool returnMissingImageOnError)
{
if (icon) return new QIcon(*icon);
if (returnMissingImageOnError)
return GetMissingImageDescriptor()->CreateImage();
return 0;
}
void QtIconImageDescriptor::DestroyImage(void* img)
{
QIcon* i = static_cast<QIcon*>(img);
delete i;
}
bool QtIconImageDescriptor::operator ==(const Object* o) const
{
if (const QtIconImageDescriptor* obj = dynamic_cast<const QtIconImageDescriptor*>(o))
{
return this->icon == obj->icon;
}
return false;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtIconImageDescriptor.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtIconImageDescriptor.h
index ddb9c4d18b..28e01d1304 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtIconImageDescriptor.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtIconImageDescriptor.h
@@ -1,49 +1,49 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYQTICONIMAGEDESCRIPTOR_H_
#define BERRYQTICONIMAGEDESCRIPTOR_H_
#include <berryImageDescriptor.h>
class QIcon;
namespace berry {
class QtIconImageDescriptor : public ImageDescriptor
{
private:
QIcon* icon;
public:
QtIconImageDescriptor(void* img);
~QtIconImageDescriptor();
virtual void* CreateImage(bool returnMissingImageOnError = true);
virtual void DestroyImage(void* img);
virtual bool operator==(const Object* o) const;
};
}
#endif /* BERRYQTICONIMAGEDESCRIPTOR_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtImageTweaklet.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtImageTweaklet.cpp
index b4824e6592..896220dc60 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtImageTweaklet.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtImageTweaklet.cpp
@@ -1,59 +1,59 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryQtImageTweaklet.h"
#include <berryImageDescriptor.h>
#include "berryQtFileImageDescriptor.h"
#include "berryQtIconImageDescriptor.h"
#include "berryQtMissingImageDescriptor.h"
namespace berry {
QtImageTweaklet::QtImageTweaklet()
{
}
QtImageTweaklet::QtImageTweaklet(const QtImageTweaklet& other)
{
Q_UNUSED(other)
}
SmartPointer<ImageDescriptor> QtImageTweaklet::CreateFromFile(const std::string& filename, const std::string& pluginid)
{
ImageDescriptor::Pointer descriptor(new QtFileImageDescriptor(filename, pluginid));
return descriptor;
}
SmartPointer<ImageDescriptor> QtImageTweaklet::CreateFromImage(void* img)
{
ImageDescriptor::Pointer descriptor(new QtIconImageDescriptor(img));
return descriptor;
}
SmartPointer<ImageDescriptor> QtImageTweaklet::GetMissingImageDescriptor()
{
SmartPointer<QtMissingImageDescriptor> descriptor(new QtMissingImageDescriptor());
return descriptor;
}
void QtImageTweaklet::DestroyImage(const void* /*img*/)
{
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtImageTweaklet.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtImageTweaklet.h
index 997b2d3d2f..3fd127747d 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtImageTweaklet.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtImageTweaklet.h
@@ -1,45 +1,45 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYQTIMAGETWEAKLET_H_
#define BERRYQTIMAGETWEAKLET_H_
#include <berryImageTweaklet.h>
namespace berry {
class QtImageTweaklet : public QObject, public ImageTweaklet
{
Q_OBJECT
Q_INTERFACES(berry::ImageTweaklet)
public:
QtImageTweaklet();
QtImageTweaklet(const QtImageTweaklet& other);
virtual SmartPointer<ImageDescriptor> CreateFromFile(const std::string& filename, const std::string& pluginid);
virtual SmartPointer<ImageDescriptor> CreateFromImage(void* img);
virtual SmartPointer<ImageDescriptor> GetMissingImageDescriptor();
virtual void DestroyImage(const void* img);
};
}
#endif /* BERRYQTIMAGETWEAKLET_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtMainWindowControl.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtMainWindowControl.cpp
index 4adda839da..faba407a58 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtMainWindowControl.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtMainWindowControl.cpp
@@ -1,155 +1,155 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryQtMainWindowControl.h"
#include <berryShell.h>
#include <QEvent>
#include <QMoveEvent>
#include <QResizeEvent>
#include <QWindowStateChangeEvent>
namespace berry {
QtMainWindowControl::QtMainWindowControl(Shell* shell, QWidget* parent, Qt::WindowFlags flags)
: QMainWindow(parent, flags)
{
controller = new QtWidgetController(shell);
// TODO WeakPointer: QVariant should hold a weak pointer
QVariant variant(QVariant::UserType);
variant.setValue(controller);
this->setProperty(QtWidgetController::PROPERTY_ID, variant);
}
void QtMainWindowControl::changeEvent(QEvent* event)
{
if (!controller->shell)
return QMainWindow::changeEvent(event);
typedef IShellListener::Events::ShellEventType::ListenerList ListenerList;
ShellEvent::Pointer shellEvent(new ShellEvent(Shell::Pointer(controller->shell)));
switch (event->type())
{
case QEvent::ActivationChange:
{
if (isActiveWindow())
{
ListenerList activatedListeners(controller->shellEvents.shellActivated.GetListeners());
for (ListenerList::iterator listener = activatedListeners.begin();
listener != activatedListeners.end(); ++listener)
{
(*listener)->Execute(shellEvent);
if (!shellEvent->doit) {
event->accept();
return;
}
}
}
else
{
ListenerList deactivatedListeners(controller->shellEvents.shellDeactivated.GetListeners());
for (ListenerList::iterator listener = deactivatedListeners.begin();
listener != deactivatedListeners.end(); ++listener)
{
(*listener)->Execute(shellEvent);
if (!shellEvent->doit) {
event->accept();
return;
}
}
}
}
break;
case QEvent::WindowStateChange:
{
QWindowStateChangeEvent* stateEvent = dynamic_cast<QWindowStateChangeEvent*>(event);
Qt::WindowStates oldState = stateEvent->oldState();
if (this->isMinimized() && !(oldState & Qt::WindowMinimized))
{
ListenerList iconifiedListeners(controller->shellEvents.shellIconified.GetListeners());
for (ListenerList::iterator listener = iconifiedListeners.begin();
listener != iconifiedListeners.end(); ++listener)
{
(*listener)->Execute(shellEvent);
if (!shellEvent->doit) {
event->accept();
return;
}
}
}
else if (oldState & Qt::WindowMinimized && !this->isMinimized())
{
ListenerList deiconifiedListeners(controller->shellEvents.shellDeiconified.GetListeners());
for (ListenerList::iterator listener = deiconifiedListeners.begin();
listener != deiconifiedListeners.end(); ++listener)
{
(*listener)->Execute(shellEvent);
if (!shellEvent->doit) return;
}
}
}
break;
default:
break;
}
QMainWindow::changeEvent(event);
}
void QtMainWindowControl::closeEvent(QCloseEvent* event)
{
if (!controller->shell)
return QMainWindow::changeEvent(event);
typedef IShellListener::Events::ShellEventType::ListenerList ListenerList;
ShellEvent::Pointer shellEvent(new ShellEvent(Shell::Pointer(controller->shell)));
ListenerList closedListeners(controller->shellEvents.shellClosed.GetListeners());
for (ListenerList::iterator listener = closedListeners.begin();
listener != closedListeners.end(); ++listener)
{
(*listener)->Execute(shellEvent);
if (!shellEvent->doit) {
event->accept();
return;
}
}
QMainWindow::closeEvent(event);
}
void QtMainWindowControl::moveEvent(QMoveEvent* event)
{
GuiTk::ControlEvent::Pointer controlEvent(new GuiTk::ControlEvent(this, event->pos().x(), event->pos().y()));
controller->controlEvents.movedEvent(controlEvent);
}
void QtMainWindowControl::resizeEvent(QResizeEvent* event)
{
GuiTk::ControlEvent::Pointer controlEvent(new GuiTk::ControlEvent(this, 0, 0, event->size().width(), event->size().height()));
controller->controlEvents.resizedEvent(controlEvent);
}
void QtMainWindowControl::inFocusEvent(QFocusEvent* /*event*/)
{
GuiTk::ControlEvent::Pointer controlEvent(new GuiTk::ControlEvent(this));
controller->controlEvents.activatedEvent(controlEvent);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtMainWindowControl.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtMainWindowControl.h
index 87aa12a9da..0c4a4ded41 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtMainWindowControl.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtMainWindowControl.h
@@ -1,55 +1,55 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYQTMAINWINDOWCONTROL_H_
#define BERRYQTMAINWINDOWCONTROL_H_
#include <QMainWindow>
#include <internal/berryQtWidgetController.h>
namespace berry {
class QtMainWindowControl : public QMainWindow
{
Q_OBJECT
public:
QtMainWindowControl(Shell* shell, QWidget* parent = 0, Qt::WindowFlags flags = 0);
protected:
// used for shell listeners
void changeEvent(QEvent* event);
void closeEvent(QCloseEvent* closeEvent);
// used for control listeners
void moveEvent(QMoveEvent* event);
void resizeEvent(QResizeEvent* event);
void inFocusEvent(QFocusEvent* event);
private:
QtWidgetController::Pointer controller;
};
}
#endif /* BERRYQTMAINWINDOWCONTROL_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtMessageDialogTweaklet.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtMessageDialogTweaklet.cpp
index 2d029be898..ec4ec9d40e 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtMessageDialogTweaklet.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtMessageDialogTweaklet.cpp
@@ -1,157 +1,157 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryQtMessageDialogTweaklet.h"
#include <QMessageBox>
#include <map>
namespace berry
{
class QtDialog: public IDialog
{
private:
QMessageBox msgBox;
std::map<QAbstractButton*, std::size_t> mapButtonToIndex;
public:
QtDialog(Shell::Pointer, const std::string& dialogTitle,
void* /*dialogTitleImage*/, const std::string& dialogMessage,
int dialogImageType, const std::vector<std::string>& dialogButtonLabels,
int defaultIndex)
{
msgBox.setWindowTitle(QString::fromStdString(dialogTitle));
msgBox.setText(QString::fromStdString(dialogMessage));
if (dialogImageType == IDialog::ERR)
msgBox.setIcon(QMessageBox::Critical);
else if (dialogImageType == IDialog::INFORMATION)
msgBox.setIcon(QMessageBox::Information);
else if (dialogImageType == IDialog::QUESTION)
msgBox.setIcon(QMessageBox::Question);
else if (dialogImageType == IDialog::WARNING)
msgBox.setIcon(QMessageBox::Warning);
QPushButton* defaultButton(NULL);
for (std::size_t i = 0; i < dialogButtonLabels.size(); ++i)
{
QPushButton* button = msgBox.addButton(QString::fromStdString(dialogButtonLabels[i]),
QMessageBox::ActionRole);
mapButtonToIndex[(QAbstractButton*)button] = i;
if (i == (std::size_t)defaultIndex)
defaultButton = button;
}
msgBox.setDefaultButton(defaultButton);
}
int Open()
{
msgBox.exec();
return static_cast<int>(mapButtonToIndex[msgBox.clickedButton()]);
}
};
QtMessageDialogTweaklet::QtMessageDialogTweaklet()
{
}
QtMessageDialogTweaklet::QtMessageDialogTweaklet(const QtMessageDialogTweaklet& other)
{
}
bool QtMessageDialogTweaklet::OpenConfirm(Shell::Pointer,
const std::string& title, const std::string& message)
{
QMessageBox msgBox;
msgBox.setWindowTitle(QString::fromStdString(title));
msgBox.setText(QString::fromStdString(message));
msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
msgBox.setDefaultButton(QMessageBox::Cancel);
msgBox.setEscapeButton(QMessageBox::Cancel);
return msgBox.exec() == QMessageBox::Ok;
}
void QtMessageDialogTweaklet::OpenError(Shell::Pointer,
const std::string& title, const std::string& message)
{
QMessageBox msgBox;
msgBox.setWindowTitle(QString::fromStdString(title));
msgBox.setText(QString::fromStdString(message));
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.setEscapeButton(QMessageBox::Ok);
msgBox.setIcon(QMessageBox::Critical);
msgBox.exec();
}
void QtMessageDialogTweaklet::OpenInformation(Shell::Pointer,
const std::string& title, const std::string& message)
{
QMessageBox msgBox;
msgBox.setWindowTitle(QString::fromStdString(title));
msgBox.setText(QString::fromStdString(message));
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.setEscapeButton(QMessageBox::Ok);
msgBox.setIcon(QMessageBox::Information);
msgBox.exec();
}
bool QtMessageDialogTweaklet::OpenQuestion(Shell::Pointer,
const std::string& title, const std::string& message)
{
QMessageBox msgBox;
msgBox.setWindowTitle(QString::fromStdString(title));
msgBox.setText(QString::fromStdString(message));
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::No);
msgBox.setEscapeButton(QMessageBox::No);
msgBox.setIcon(QMessageBox::Question);
return msgBox.exec() == QMessageBox::Yes;
}
void QtMessageDialogTweaklet::OpenWarning(Shell::Pointer,
const std::string& title, const std::string& message)
{
QMessageBox msgBox;
msgBox.setWindowTitle(QString::fromStdString(title));
msgBox.setText(QString::fromStdString(message));
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.setEscapeButton(QMessageBox::Ok);
msgBox.setIcon(QMessageBox::Warning);
msgBox.exec();
}
IDialog::Pointer QtMessageDialogTweaklet::MessageDialog(
Shell::Pointer parentShell, const std::string& dialogTitle,
void* dialogTitleImage, const std::string& dialogMessage,
int dialogImageType, const std::vector<std::string>& dialogButtonLabels,
int defaultIndex)
{
IDialog::Pointer dialog(new QtDialog(parentShell, dialogTitle,
dialogTitleImage, dialogMessage, dialogImageType, dialogButtonLabels,
defaultIndex));
return dialog;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtMessageDialogTweaklet.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtMessageDialogTweaklet.h
index efc9116986..ab32874f45 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtMessageDialogTweaklet.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtMessageDialogTweaklet.h
@@ -1,55 +1,55 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYQTMESSAGEDIALOGTWEAKLET_H_
#define BERRYQTMESSAGEDIALOGTWEAKLET_H_
#include <berryMessageDialogTweaklet.h>
namespace berry
{
class QtMessageDialogTweaklet: public QObject, public MessageDialogTweaklet
{
Q_OBJECT
Q_INTERFACES(berry::MessageDialogTweaklet)
public:
QtMessageDialogTweaklet();
QtMessageDialogTweaklet(const QtMessageDialogTweaklet& other);
bool OpenConfirm(Shell::Pointer, const std::string& title,
const std::string& message);
void OpenError(Shell::Pointer, const std::string& title,
const std::string& message);
void OpenInformation(Shell::Pointer, const std::string& title,
const std::string& message);
bool OpenQuestion(Shell::Pointer, const std::string& title,
const std::string& message);
void OpenWarning(Shell::Pointer, const std::string& title,
const std::string& message);
IDialog::Pointer MessageDialog(Shell::Pointer parentShell,
const std::string& dialogTitle, void* dialogTitleImage,
const std::string& dialogMessage, int dialogImageType, const std::vector<
std::string>& dialogButtonLabels, int defaultIndex);
};
}
#endif /* BERRYQTMESSAGEDIALOGTWEAKLET_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtMissingImageDescriptor.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtMissingImageDescriptor.cpp
index 38ca25e071..cfc126fa19 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtMissingImageDescriptor.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtMissingImageDescriptor.cpp
@@ -1,42 +1,42 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryQtMissingImageDescriptor.h"
#include <QIcon>
namespace berry {
void* QtMissingImageDescriptor::CreateImage(bool /*returnMissingImageOnError*/)
{
return new QIcon(":/org.blueberry.ui.qt/icon_missing.png");
}
void QtMissingImageDescriptor::DestroyImage(void* img)
{
QIcon* i = static_cast<QIcon*>(img);
delete i;
}
bool QtMissingImageDescriptor::operator ==(const Object* o) const
{
return dynamic_cast<const QtMissingImageDescriptor*>(o) != 0;
}
} // namespace
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtMissingImageDescriptor.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtMissingImageDescriptor.h
index d6e7c04cd0..c39720a95e 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtMissingImageDescriptor.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtMissingImageDescriptor.h
@@ -1,44 +1,44 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYQTMISSINGIMAGEDESCRIPTOR_H_
#define BERRYQTMISSINGIMAGEDESCRIPTOR_H_
#include <berryImageDescriptor.h>
class QIcon;
namespace berry {
class QtMissingImageDescriptor : public ImageDescriptor
{
private:
public:
virtual void* CreateImage(bool returnMissingImageOnError = true);
virtual void DestroyImage(void* img);
virtual bool operator==(const Object* o) const;
};
}
#endif /* BERRYQTICONIMAGEDESCRIPTOR_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtOpenPerspectiveAction.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtOpenPerspectiveAction.cpp
index 8e80dad6b6..bdd6c48da3 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtOpenPerspectiveAction.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtOpenPerspectiveAction.cpp
@@ -1,62 +1,62 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryQtOpenPerspectiveAction.h"
#include <berryIWorkbenchPage.h>
#include <berryIWorkbench.h>
#include <QWidget>
#include <QMessageBox>
namespace berry
{
QtOpenPerspectiveAction::QtOpenPerspectiveAction(
IWorkbenchWindow::Pointer window, IPerspectiveDescriptor::Pointer descr, QActionGroup* group) :
QAction(0),
window(window.GetPointer())
{
this->setParent(group);
this->setText(QString(descr->GetLabel().c_str()));
this->setToolTip(QString(descr->GetLabel().c_str()));
this->setCheckable(true);
this->setIconVisibleInMenu(true);
group->addAction(this);
QIcon* icon = static_cast<QIcon*>(descr->GetImageDescriptor()->CreateImage());
this->setIcon(*icon);
descr->GetImageDescriptor()->DestroyImage(icon);
perspectiveId = descr->GetId();
this->connect(this, SIGNAL(triggered(bool)), this, SLOT(Run()));
}
void QtOpenPerspectiveAction::Run()
{
try
{
window->GetWorkbench()->ShowPerspective(perspectiveId, IWorkbenchWindow::Pointer(window));
}
catch (...)
{
QMessageBox::critical(0, "Opening Perspective Failed", QString("The perspective \"") + this->text() + "\" could not be opened.\nSee the log for details.");
}
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtOpenPerspectiveAction.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtOpenPerspectiveAction.h
index ae051435d6..9038260391 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtOpenPerspectiveAction.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtOpenPerspectiveAction.h
@@ -1,54 +1,54 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYQTOPENPERSPECTIVEACTION_H_
#define BERRYQTOPENPERSPECTIVEACTION_H_
#include <QAction>
#include <QActionGroup>
#include <berryIWorkbenchWindow.h>
#include <berryIPerspectiveDescriptor.h>
//TODO should be removed later
#include <org_blueberry_ui_qt_Export.h>
namespace berry
{
class BERRY_UI_QT QtOpenPerspectiveAction: public QAction
{
Q_OBJECT
public:
QtOpenPerspectiveAction(IWorkbenchWindow::Pointer window,
IPerspectiveDescriptor::Pointer descr, QActionGroup* group);
protected slots:
void Run();
private:
IWorkbenchWindow* window;
std::string perspectiveId;
};
}
#endif /* BERRYQTOPENPERSPECTIVEACTION_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtPerspectiveSwitcher.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtPerspectiveSwitcher.cpp
index 9853275051..24700c5e6e 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtPerspectiveSwitcher.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtPerspectiveSwitcher.cpp
@@ -1,82 +1,82 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryQtPerspectiveSwitcher.h"
#include "berryQtOpenPerspectiveAction.h"
#include <berryIWorkbench.h>
#include <berryIWorkbenchPage.h>
#include <berryIPerspectiveRegistry.h>
#include <QActionGroup>
namespace berry {
struct QtPerspectiveSwitcherListener : public IPerspectiveListener
{
QtPerspectiveSwitcherListener(QtPerspectiveSwitcher* switcher)
: switcher(switcher)
{}
Events::Types GetPerspectiveEventTypes() const
{
return Events::ACTIVATED;
}
void PerspectiveActivated(IWorkbenchPage::Pointer /*page*/,
IPerspectiveDescriptor::Pointer perspective)
{
QAction* action = switcher->perspIdToActionMap[QString::fromStdString(perspective->GetId())];
if (action) action->setChecked(true);
}
private:
QtPerspectiveSwitcher* switcher;
};
QtPerspectiveSwitcher::QtPerspectiveSwitcher(IWorkbenchWindow::Pointer window)
: window(window)
{
QWidget* parent = static_cast<QWidget*>(window->GetShell()->GetControl());
this->setParent(parent);
this->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
QActionGroup* perspGroup = new QActionGroup(this);
IPerspectiveRegistry* perspRegistry = window->GetWorkbench()->GetPerspectiveRegistry();
std::vector<IPerspectiveDescriptor::Pointer> perspectives(perspRegistry->GetPerspectives());
for (std::vector<IPerspectiveDescriptor::Pointer>::iterator perspIt =
perspectives.begin(); perspIt != perspectives.end(); ++perspIt)
{
QAction* perspAction = new QtOpenPerspectiveAction(window, *perspIt, perspGroup);
perspIdToActionMap[QString::fromStdString((*perspIt)->GetId())] = perspAction;
}
this->addActions(perspGroup->actions());
perspListener = new QtPerspectiveSwitcherListener(this);
window->AddPerspectiveListener(perspListener);
}
QtPerspectiveSwitcher::~QtPerspectiveSwitcher()
{
window->RemovePerspectiveListener(perspListener);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtPerspectiveSwitcher.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtPerspectiveSwitcher.h
index 0c7043032f..8b5ba3840b 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtPerspectiveSwitcher.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtPerspectiveSwitcher.h
@@ -1,50 +1,50 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYQTPERSPECTIVESWITCHER_H_
#define BERRYQTPERSPECTIVESWITCHER_H_
#include <QToolBar>
#include <QHash>
#include <berryIPerspectiveListener.h>
#include <berryIWorkbenchWindow.h>
namespace berry {
class QtPerspectiveSwitcher : public QToolBar
{
Q_OBJECT
public:
QtPerspectiveSwitcher(IWorkbenchWindow::Pointer window);
~QtPerspectiveSwitcher();
private:
IWorkbenchWindow::Pointer window;
IPerspectiveListener::Pointer perspListener;
QHash<QString, QAction*> perspIdToActionMap;
friend struct QtPerspectiveSwitcherListener;
};
}
#endif /* BERRYQTPERSPECTIVESWITCHER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtPluginActivator.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtPluginActivator.cpp
index 8705ed94c8..7d92bfc84b 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtPluginActivator.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtPluginActivator.cpp
@@ -1,72 +1,72 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryQtPluginActivator.h"
#include "berryQtStyleManager.h"
#include "berryQtDnDTweaklet.h"
#include "berryQtImageTweaklet.h"
#include "berryQtMessageDialogTweaklet.h"
#include "berryQtWorkbenchTweaklet.h"
#include "berryQtWorkbenchPageTweaklet.h"
#include "berryQtWidgetsTweaklet.h"
#include "berryQtStylePreferencePage.h"
#include "defaultpresentation/berryQtWorkbenchPresentationFactory.h"
namespace berry {
QtPluginActivator::QtPluginActivator()
{
}
QtPluginActivator::~QtPluginActivator()
{
}
void
QtPluginActivator::start(ctkPluginContext* context)
{
AbstractUICTKPlugin::start(context);
BERRY_REGISTER_EXTENSION_CLASS(QtDnDTweaklet, context)
BERRY_REGISTER_EXTENSION_CLASS(QtImageTweaklet, context);
BERRY_REGISTER_EXTENSION_CLASS(QtMessageDialogTweaklet, context);
BERRY_REGISTER_EXTENSION_CLASS(QtWidgetsTweaklet, context)
BERRY_REGISTER_EXTENSION_CLASS(QtWorkbenchTweaklet, context)
BERRY_REGISTER_EXTENSION_CLASS(QtWorkbenchPageTweaklet, context)
BERRY_REGISTER_EXTENSION_CLASS(QtWorkbenchPresentationFactory, context)
BERRY_REGISTER_EXTENSION_CLASS(QtStylePreferencePage, context)
QtStyleManager* manager = new QtStyleManager();
styleManager = IQtStyleManager::Pointer(manager);
context->registerService<berry::IQtStyleManager>(manager);
}
void QtPluginActivator::stop(ctkPluginContext* context)
{
styleManager = 0;
AbstractUICTKPlugin::stop(context);
}
}
Q_EXPORT_PLUGIN2(org_blueberry_ui_qt, berry::QtPluginActivator)
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtPluginActivator.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtPluginActivator.h
index a0d9fa9e9b..3b351d0770 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtPluginActivator.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtPluginActivator.h
@@ -1,48 +1,48 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYQTPLUGINACTIVATOR_H_
#define BERRYQTPLUGINACTIVATOR_H_
#include <berryAbstractUICTKPlugin.h>
#include <berryIQtStyleManager.h>
namespace berry {
class QtPluginActivator : public QObject, public AbstractUICTKPlugin
{
Q_OBJECT
Q_INTERFACES(ctkPluginActivator)
public:
QtPluginActivator();
~QtPluginActivator();
void start(ctkPluginContext* context);
void stop(ctkPluginContext* context);
private:
IQtStyleManager::Pointer styleManager;
};
}
#endif /* BERRYQTPLUGINACTIVATOR_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtSafeApplication.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtSafeApplication.cpp
index 2ece918b2a..e54824a7a9 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtSafeApplication.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtSafeApplication.cpp
@@ -1,86 +1,86 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryQtSafeApplication.h"
#include <berryPlatform.h>
#include <QMessageBox>
#include <cstring>
namespace berry
{
int G_QT_ARGC = 0;
char** G_QT_ARGV = 0;
QtSafeApplication::QtSafeApplication(int& argc, char** argv) :
QApplication(argc, argv)
{
}
QApplication* QtSafeApplication::CreateInstance()
{
if (qApp)
return qApp;
// TODO extract the proper Qt command line arguments
std::string name = Platform::GetConfiguration().getString(
"application.name");
G_QT_ARGC = 1;
G_QT_ARGV = new char*[1];
G_QT_ARGV[0] = new char[name.length() + 1];
std::strcpy(G_QT_ARGV[0], name.c_str());
return new QtSafeApplication(G_QT_ARGC, G_QT_ARGV);
}
QtSafeApplication::~QtSafeApplication()
{
if (G_QT_ARGC == 0) return;
for (int i = 0; i < G_QT_ARGC; ++i)
delete[] G_QT_ARGV[i];
delete[] G_QT_ARGV;
}
bool QtSafeApplication::notify(QObject* receiver, QEvent* event)
{
QString msg;
try
{
return QApplication::notify(receiver, event);
} catch (Poco::Exception& e)
{
msg = QString::fromStdString(e.displayText());
} catch (std::exception& e)
{
msg = e.what();
} catch (...)
{
msg = "Unknown exception";
}
QString
text(
"An error occurred. You should save all data and quit the program to prevent possible data loss.\nSee the error log for details.\n\n");
text += msg;
QMessageBox::critical(0, "Error", text);
return false;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtSafeApplication.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtSafeApplication.h
index 0ada6a865d..7044fa434b 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtSafeApplication.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtSafeApplication.h
@@ -1,51 +1,51 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYQTSAFEAPPLICATION_H_
#define BERRYQTSAFEAPPLICATION_H_
#include <QApplication>
namespace berry {
class QtSafeApplication : public QApplication
{
private:
QtSafeApplication(int& argc, char** argv);
public:
static QApplication* CreateInstance();
~QtSafeApplication();
/**
* Reimplement notify to catch unhandled exceptions and open an error message.
*
* @param receiver
* @param event
* @return
*/
bool notify(QObject* receiver, QEvent* event);
};
}
#endif /* BERRYQTSAFEAPPLICATION_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtSash.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtSash.cpp
index 455c7a4e1b..348aca91ba 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtSash.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtSash.cpp
@@ -1,300 +1,300 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryLog.h"
#include "berryQtSash.h"
#include <berryConstants.h>
#include <QMouseEvent>
#include <QStyleOption>
#include <QPainter>
namespace berry
{
/*!
Creates a QtSash with the given orientation, parent, and smoothness.
*/
QtSash::QtSash(Qt::Orientation orientation, QWidget *parent, bool smooth) :
QWidget(parent), smooth(smooth), orientation(orientation), rubberBand(0),
lastX(0), lastY(0)
{
if (orientation == Qt::Horizontal)
this->setCursor(Qt::SplitVCursor);
else
this->setCursor(Qt::SplitHCursor);
}
QtSash::~QtSash()
{
}
void QtSash::AddSelectionListener(GuiTk::ISelectionListener::Pointer listener)
{
selectionEvents.AddListener(listener);
}
void QtSash::RemoveSelectionListener(
GuiTk::ISelectionListener::Pointer listener)
{
selectionEvents.AddListener(listener);
}
/*!
Returns the sash's orientation.
*/
Qt::Orientation QtSash::GetOrientation() const
{
return orientation;
}
/*!
Returns true if widgets are resized dynamically (smoothly), otherwise
returns false.
*/
bool QtSash::SmoothResize() const
{
return smooth;
}
/*!
Tells the splitter to move this handle to position \a pos, which is
the distance from the left or top edge of the widget.
Note that \a pos is also measured from the left (or top) for
right-to-left languages. This function will map \a pos to the
appropriate position before calling QSplitter::moveSplitter().
\sa QSplitter::moveSplitter() closestLegalPosition()
*/
//void QtSash::moveSplitter(int pos)
//{
// Q_D(QSplitterHandle);
// if (d->s->isRightToLeft() && d->orient == Qt::Horizontal)
// pos = d->s->contentsRect().width() - pos;
// d->s->moveSplitter(pos, d->s->indexOf(this));
//}
/*!
\reimp
*/
//QSize QtSash::sizeHint() const
//{
// Q_D(const QSplitterHandle);
// int hw = d->s->handleWidth();
// QStyleOption opt(0);
// opt.init(d->s);
// opt.state = QStyle::State_None;
// return parentWidget()->style()->sizeFromContents(QStyle::CT_Splitter, &opt, QSize(hw, hw), d->s)
// .expandedTo(QApplication::globalStrut());
//}
/*!
\reimp
*/
bool QtSash::event(QEvent *event)
{
// switch(event->type()) {
// case QEvent::HoverEnter:
// d->hover = true;
// update();
// break;
// case QEvent::HoverLeave:
// d->hover = false;
// update();
// break;
// default:
// break;
// }
return QWidget::event(event);
}
/*!
\reimp
*/
void QtSash::mouseMoveEvent(QMouseEvent *e)
{
if (!dragging && !(e->buttons() & Qt::LeftButton))
return;
QPoint eventPoint(e->globalX(), e->globalY());
eventPoint = this->parentWidget()->mapFromGlobal(eventPoint);
int eventX = eventPoint.x();
int eventY = eventPoint.y();
// int eventX = e->globalX();
// int eventY = e->globalY();
//int x = OS.GTK_WIDGET_X (handle);
//int y = OS.GTK_WIDGET_Y (handle);
int width = this->geometry().width();
int height = this->geometry().height();
//int parentBorder = 0;
//int parentWidth = OS.GTK_WIDGET_WIDTH (parent.handle);
//int parentHeight = OS.GTK_WIDGET_HEIGHT (parent.handle);
int newX = lastX;
int newY = lastY;
if ((orientation & Qt::Vertical) != 0)
{
//newX = std::min(std::max (0, eventX + x - startX - parentBorder), parentWidth - width);
newX = eventX;
}
else
{
// newY = Math.min (Math.max (0, eventY + y - startY - parentBorder), parentHeight - height);
newY = eventY;
}
if (newX == lastX && newY == lastY)
return;
drawRubberBand(lastX, lastY, width, height);
GuiTk::SelectionEvent::Pointer event(new GuiTk::SelectionEvent(this));
event->x = newX;
event->y = newY;
event->width = width;
event->height = height;
if (!smooth)
{
event->detail = Constants::DRAG;
}
selectionEvents.selected(event);
if (event->doit)
{
lastX = event->x;
lastY = event->y;
}
//parent.update (true, (style & SWT.SMOOTH) == 0);
drawRubberBand(lastX, lastY, width, height);
if (smooth)
{
setGeometry(lastX, lastY, width, height);
// widget could be disposed at this point
}
}
/*!
\reimp
*/
void QtSash::mousePressEvent(QMouseEvent *e)
{
if (e->button() == Qt::LeftButton)
{
// const QRect& rect = this->geometry();
// QPoint p1(this->mapToGlobal(rect.topLeft()));
// QPoint p2(this->mapToGlobal(rect.bottomRight()));
// startRect = QRect(p1, p2);
startRect = this->geometry();
lastX = startRect.x();
lastY = startRect.y();
GuiTk::SelectionEvent::Pointer event(new GuiTk::SelectionEvent(this));
event->x = lastX;
event->y = lastY;
event->width = startRect.width();
event->height = startRect.height();
if (!smooth)
{
event->detail = Constants::DRAG;
}
selectionEvents.selected(event);
if (event->doit)
{
dragging = true;
lastX = event->x;
lastY = event->y;
//parent.update (true, (style & SWT.SMOOTH) == 0);
drawRubberBand(lastX, lastY, startRect.width(), startRect.height());
if (smooth)
{
this->setGeometry(lastX, lastY, startRect.width(), startRect.height());
// widget could be disposed at this point
}
}
}
}
/*!
\reimp
*/
void QtSash::mouseReleaseEvent(QMouseEvent *e)
{
if (dragging && e->button() == Qt::LeftButton)
{
this->drawRubberBand(-1, -1, -1, -1);
dragging = false;
const QRect& rect = this->geometry();
int width = rect.width();
int height = rect.height();
GuiTk::SelectionEvent::Pointer event(new GuiTk::SelectionEvent(this));
event->x = lastX;
event->y = lastY;
event->width = width;
event->height = height;
//drawBand (lastX, lastY, width, height);
selectionEvents.selected(event);
if (event->doit)
{
if (smooth)
{
this->setGeometry(event->x, event->y, width, height);
// widget could be disposed at this point
}
}
}
}
void QtSash::drawRubberBand(int x, int y, int width, int height)
{
if (smooth)
return;
if (x < 0 || y < 0)
{
if (this->rubberBand)
this->rubberBand->hide();
return;
}
if (!this->rubberBand)
{
this->rubberBand = new QRubberBand(QRubberBand::Line, this->parentWidget());
// For accessibility to identify this special widget.
this->rubberBand->setObjectName(QLatin1String("qt_rubberband"));
}
this->rubberBand->setGeometry(x, y, width, height);
if (!this->rubberBand->isVisible())
this->rubberBand->show();
}
void QtSash::paintEvent(QPaintEvent*)
{
QStyleOption opt;
opt.init(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtSash.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtSash.h
index cfab3dee2f..14932085fc 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtSash.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtSash.h
@@ -1,75 +1,75 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYQTSASH_H_
#define BERRYQTSASH_H_
#include <QWidget>
#include <QRubberBand>
#include <berryGuiTkISelectionListener.h>
namespace berry {
class QtSash : public QWidget
{
Q_OBJECT
public:
QtSash(Qt::Orientation o, QWidget* parent = 0, bool smooth = true);
~QtSash();
//void setOrientation(Qt::Orientation o);
Qt::Orientation GetOrientation() const;
bool SmoothResize() const;
void AddSelectionListener(GuiTk::ISelectionListener::Pointer listener);
void RemoveSelectionListener(GuiTk::ISelectionListener::Pointer listener);
protected:
//void paintEvent(QPaintEvent *);
void mouseMoveEvent(QMouseEvent *);
void mousePressEvent(QMouseEvent *);
void mouseReleaseEvent(QMouseEvent *);
bool event(QEvent *);
void drawRubberBand(int x, int y, int width, int height);
// needed for stylesheet support
void paintEvent(QPaintEvent*);
//void moveSplitter(int p);
//int closestLegalPosition(int p);
private:
bool smooth;
Qt::Orientation orientation;
QRubberBand* rubberBand;
QRect startRect;
int lastX, lastY;
bool dragging;
GuiTk::ISelectionListener::Events selectionEvents;
};
}
#endif /* BERRYQTSASH_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtShell.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtShell.cpp
index 3b0fb12944..8cdc3aa7a8 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtShell.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtShell.cpp
@@ -1,223 +1,223 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryQtShell.h"
#include "berryQtWidgetsTweakletImpl.h"
#include "berryQtMainWindowControl.h"
#include <internal/berryQtControlWidget.h>
#include <berryConstants.h>
#include <internal/berryTweaklets.h>
#include <tweaklets/berryGuiWidgetsTweaklet.h>
#include <QApplication>
#include <QVariant>
namespace berry
{
QtShell::QtShell(QWidget* parent, Qt::WindowFlags flags)
: updatesDisabled(false)
{
if (parent == 0 || flags.testFlag(Qt::Window))
{
widget = new QtMainWindowControl(this, parent, flags);
widget->setUpdatesEnabled(false);
updatesDisabled = true;
widget->setAttribute(Qt::WA_DeleteOnClose);
}
else
{
widget = new QtControlWidget(parent, this, flags | Qt::Dialog);
widget->setObjectName("shell widget");
}
}
QtShell::~QtShell()
{
widget->deleteLater();
}
void QtShell::SetBounds(const Rectangle& bounds)
{
widget->move(bounds.x, bounds.y);
widget->resize(bounds.width, bounds.height);
}
Rectangle QtShell::GetBounds() const
{
const QRect& qRect = widget->frameGeometry();
const QSize& size = widget->size();
Rectangle rect(qRect.x(), qRect.y(), size.width(), size.height());
return rect;
}
void QtShell::SetLocation(int x, int y)
{
widget->move(x, y);
}
Point QtShell::ComputeSize(int /*wHint*/, int /*hHint*/, bool changed)
{
if (changed) widget->updateGeometry();
QSize size(widget->size());
Point point(size.width(), size.height());
return point;
}
std::string QtShell::GetText() const
{
return widget->windowTitle().toStdString();
}
void QtShell::SetText(const std::string& text)
{
QString title(QString::fromStdString(text));
widget->setWindowTitle(title);
widget->setObjectName(title);
}
bool QtShell::IsVisible()
{
return widget->isVisible();
}
void QtShell::SetVisible(bool visible)
{
widget->setVisible(visible);
}
void QtShell::SetActive()
{
widget->activateWindow();
widget->raise();
}
void* QtShell::GetControl()
{
return widget;
}
void QtShell::SetImages(const std::vector<void*>& /*images*/)
{
}
bool QtShell::GetMaximized()
{
return widget->isMaximized();
}
bool QtShell::GetMinimized()
{
return widget->isMinimized();
}
void QtShell::SetMaximized(bool maximized)
{
maximized ? widget->showMaximized() : widget->showNormal();
}
void QtShell::SetMinimized(bool minimized)
{
minimized ? widget->showMinimized() : widget->showNormal();
}
void QtShell::AddShellListener(IShellListener::Pointer listener)
{
QVariant variant = widget->property(QtWidgetController::PROPERTY_ID);
poco_assert(variant.isValid());
QtWidgetController::Pointer controller = variant.value<QtWidgetController::Pointer>();
poco_assert(controller != 0);
controller->AddShellListener(listener);
}
void QtShell::RemoveShellListener(IShellListener::Pointer listener)
{
QVariant variant = widget->property(QtWidgetController::PROPERTY_ID);
if (variant.isValid())
{
QtWidgetController::Pointer controller = variant.value<QtWidgetController::Pointer>();
if (controller != 0)
controller->RemoveShellListener(listener);
}
}
void QtShell::Open(bool block)
{
if (updatesDisabled)
{
widget->setUpdatesEnabled(true);
updatesDisabled = false;
}
widget->setWindowModality(block ? Qt::WindowModal : Qt::NonModal);
widget->show();
}
void QtShell::Close()
{
widget->close();
}
std::vector<Shell::Pointer> QtShell::GetShells()
{
GuiWidgetsTweaklet* widgetTweaklet = Tweaklets::Get(GuiWidgetsTweaklet::KEY);
std::vector<Shell::Pointer> allShells(widgetTweaklet->GetShells());
std::vector<Shell::Pointer> descendants;
for (std::size_t i = 0; i < allShells.size(); ++i)
{
Shell::Pointer shell = allShells[i];
if (widgetTweaklet->GetShell(shell->GetControl()) == this)
{
descendants.push_back(shell);
}
}
return descendants;
}
int QtShell::GetStyle()
{
Qt::WindowFlags qtFlags = widget->windowFlags();
int berryFlags = 0;
if (!(qtFlags & Qt::FramelessWindowHint))
berryFlags |= Constants::BORDER;
if (qtFlags & Qt::WindowTitleHint)
berryFlags |= Constants::TITLE;
if (qtFlags & Qt::WindowSystemMenuHint)
berryFlags |= Constants::CLOSE;
if (qtFlags & Qt::WindowMinimizeButtonHint)
berryFlags |= Constants::MIN;
if (qtFlags & Qt::WindowMaximizeButtonHint)
berryFlags |= Constants::MAX;
if (widget->windowModality() == Qt::WindowModal)
berryFlags |= Constants::PRIMARY_MODAL;
else if(widget->windowModality() == Qt::ApplicationModal)
berryFlags |= Constants::APPLICATION_MODAL;
return berryFlags;
}
QWidget* QtShell::GetWidget()
{
return widget;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtShell.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtShell.h
index 1f8c08ebf8..3a156841da 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtShell.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtShell.h
@@ -1,86 +1,86 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYQTMAINWINDOWSHELL_H_
#define BERRYQTMAINWINDOWSHELL_H_
#include <berryShell.h>
#include <berryPoint.h>
#include <QWidget>
namespace berry {
class QtAbstractControlWidget;
class QtShell : public Shell
{
public:
QtShell(QWidget* parent = 0, Qt::WindowFlags flags = 0);
~QtShell();
// berry::Shell
void SetBounds(const Rectangle& bounds);
Rectangle GetBounds() const;
void SetLocation(int x, int y);
Point ComputeSize(int wHint, int hHint, bool changed);
std::string GetText() const;
void SetText(const std::string& text);
bool IsVisible();
void SetVisible(bool visible);
void SetActive();
void* GetControl();
void SetImages(const std::vector<void*>& images);
bool GetMaximized();
bool GetMinimized();
void SetMaximized(bool maximized);
void SetMinimized(bool minimized);
void AddShellListener(IShellListener::Pointer listener);
void RemoveShellListener(IShellListener::Pointer listener);
void Open(bool block = false);
void Close();
std::vector<Shell::Pointer> GetShells();
int GetStyle ();
QWidget* GetWidget();
private:
QWidget* widget;
bool updatesDisabled;
};
}
#endif /* BERRYQTMAINWINDOWSHELL_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtShowViewAction.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtShowViewAction.cpp
index 473e6f7677..bce7dad261 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtShowViewAction.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtShowViewAction.cpp
@@ -1,60 +1,60 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryQtShowViewAction.h"
#include <berryIWorkbenchPage.h>
#include <berryUIException.h>
namespace berry
{
QtShowViewAction::QtShowViewAction(IWorkbenchWindow::Pointer window,
IViewDescriptor::Pointer desc) :
QAction(0)
{
this->setParent(static_cast<QWidget*>(window->GetShell()->GetControl()));
this->setText(QString(desc->GetLabel().c_str()));
this->setToolTip(QString(desc->GetLabel().c_str()));
this->setIconVisibleInMenu(true);
QIcon* icon = static_cast<QIcon*>(desc->GetImageDescriptor()->CreateImage());
this->setIcon(*icon);
desc->GetImageDescriptor()->DestroyImage(icon);
m_Window = window.GetPointer();
m_Desc = desc;
this->connect(this, SIGNAL(triggered(bool)), this, SLOT(Run()));
}
void QtShowViewAction::Run()
{
IWorkbenchPage::Pointer page = m_Window->GetActivePage();
if (page.IsNotNull())
{
try
{
page->ShowView(m_Desc->GetId());
}
catch (PartInitException e)
{
BERRY_ERROR << "Error: " << e.displayText() << std::endl;
}
}
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtShowViewAction.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtShowViewAction.h
index ae19e5ab0c..94d19460cb 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtShowViewAction.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtShowViewAction.h
@@ -1,62 +1,62 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYQTSHOWVIEWACTION_H_
#define BERRYQTSHOWVIEWACTION_H_
#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 <windows.h>
#endif
#include <QAction>
#include <berryIWorkbenchWindow.h>
#include <berryIViewDescriptor.h>
//TODO should be removed later
#include <org_blueberry_ui_qt_Export.h>
namespace berry
{
class BERRY_UI_QT QtShowViewAction : public QAction {
Q_OBJECT
private:
IWorkbenchWindow* m_Window;
IViewDescriptor::Pointer m_Desc;
public:
QtShowViewAction(IWorkbenchWindow::Pointer window, IViewDescriptor::Pointer desc) ;
protected slots:
/**
* Implementation of method defined on <code>IAction</code>.
*/
void Run();
};
}
#endif /*BERRYQTSHOWVIEWACTION_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtShowViewDialog.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtShowViewDialog.cpp
index aadf3bd0ab..968b1d0344 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtShowViewDialog.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtShowViewDialog.cpp
@@ -1,43 +1,43 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryQtShowViewDialog.h"
namespace berry {
QtShowViewDialog::QtShowViewDialog(IViewRegistry* /*registry*/, QWidget* parent, Qt::WindowFlags f)
: QDialog(parent, f)
{
m_UserInterface.setupUi(this);
}
int QtShowViewDialog::Open()
{
int returnCode = this->exec();
if (returnCode == QDialog::Accepted)
return IShowViewDialog::OK;
else return IShowViewDialog::CANCEL;
}
std::vector<IViewDescriptor::Pointer>
QtShowViewDialog::GetSelection()
{
std::vector<IViewDescriptor::Pointer> selected;
return selected;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtShowViewDialog.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtShowViewDialog.h
index aa70371d98..633658544f 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtShowViewDialog.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtShowViewDialog.h
@@ -1,53 +1,53 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYQTSHOWVIEWDIALOG_H_
#define BERRYQTSHOWVIEWDIALOG_H_
#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 <windows.h>
#endif
#include <QDialog>
#include <berryIViewRegistry.h>
#include <berryIShowViewDialog.h>
#include "ui_berryQtShowViewDialog.h"
namespace berry {
class QtShowViewDialog : public QDialog, public IShowViewDialog
{
public:
berryObjectMacro(QtShowViewDialog);
QtShowViewDialog(IViewRegistry* registry, QWidget* parent = 0, Qt::WindowFlags f = 0);
std::vector<IViewDescriptor::Pointer> GetSelection();
int Open();
protected:
Ui::QtShowViewDialog_ m_UserInterface;
};
}
#endif /*BERRYQTSHOWVIEWDIALOG_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtStyleManager.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtStyleManager.cpp
index 56757c0bc3..312487eb06 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtStyleManager.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtStyleManager.cpp
@@ -1,314 +1,314 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryQtStyleManager.h"
#include <QApplication>
#include <QFile>
#include <QTextStream>
#include <QFileInfo>
#include <QStringList>
#include <QDirIterator>
#include <berryLog.h>
#include <berryPlatform.h>
#include <berryPlatformUI.h>
#include <berryIPreferencesService.h>
#include <berryIPreferences.h>
#include "berryQtPreferences.h"
namespace berry
{
bool QtStyleManager::IsA(const std::type_info& type) const
{
std::string name(GetType().name());
return name == type.name() || Service::IsA(type);
}
const std::type_info& QtStyleManager::GetType() const
{
return typeid(berry::IQtStyleManager);
}
QtStyleManager::QtStyleManager()
{
AddDefaultStyle();
ReadPreferences();
}
void QtStyleManager::ReadPreferences()
{
IPreferencesService::Pointer prefService
= Platform::GetServiceRegistry()
.GetServiceById<IPreferencesService>(IPreferencesService::ID);
IPreferences::Pointer stylePref = prefService->GetSystemPreferences()->Node(QtPreferences::QT_STYLES_NODE);
QString paths = QString::fromStdString(stylePref->Get(QtPreferences::QT_STYLE_SEARCHPATHS, ""));
QStringList pathList = paths.split(";", QString::SkipEmptyParts);
QStringListIterator it(pathList);
while (it.hasNext())
{
AddStyles(it.next());
}
QString styleName = QString::fromStdString(stylePref->Get(QtPreferences::QT_STYLE_NAME, ""));
// if a style is contributed via the Qt resource mechanism, it may not be
// registered yet.
if (Contains(styleName))
// do not update the style in the QApplication instance,
// since it might not be created yet
SetStyle(styleName, false);
else
SetDefaultStyle(false);
}
QtStyleManager::~QtStyleManager()
{
for (FileNameToStyleMap::const_iterator i = styles.begin(); i != styles.end(); ++i)
{
delete i.value();
}
}
void QtStyleManager::AddDefaultStyle()
{
#ifndef _APPLE_
AddStyle(":/org.blueberry.ui.qt/defaultstyle.qss", "Default");
defaultStyle = styles[":/org.blueberry.ui.qt/defaultstyle.qss"];
#endif
}
void QtStyleManager::ClearStyles()
{
for (FileNameToStyleMap::iterator i = styles.begin(); i != styles.end(); )
{
if (!i.value()->fileName.startsWith(':'))
{
delete i.value();
i = styles.erase(i);
}
else ++i;
}
SetDefaultStyle();
}
QtStyleManager::Style QtStyleManager::GetStyle() const
{
return Style(currentStyle->name, currentStyle->fileName);
}
QString QtStyleManager::GetStylesheet() const
{
return currentStyle->stylesheet;
}
QString QtStyleManager::GetActiveTabStylesheet() const
{
return currentStyle->activeTabStylesheet;
}
QString QtStyleManager::GetTabStylesheet() const
{
return currentStyle->tabStylesheet;
}
void QtStyleManager::AddStyle(const QString& styleFileName,
const QString& styleName)
{
ExtStyle* newStyle = new ExtStyle();
if (styleName.isEmpty())
{
QFileInfo info(styleFileName);
newStyle->name = info.completeBaseName();
}
else
{
newStyle->name = styleName;
}
newStyle->fileName = styleFileName;
styles.insert(newStyle->fileName, newStyle);
}
void QtStyleManager::AddStyles(const QString& path)
{
QDirIterator dirIt(path);
while (dirIt.hasNext())
{
QString current = dirIt.next();
QFileInfo info = dirIt.fileInfo();
if (info.isFile() && info.isReadable())
{
QString fileName = info.fileName();
if (fileName.endsWith("-tab.qss") || fileName.endsWith("-activetab.qss"))
continue;
if (fileName.endsWith(".qss"))
AddStyle(current);
}
}
}
void QtStyleManager::ReadStyleData(ExtStyle* style)
{
QString tabStyleFileName(style->fileName);
QString activeTabStyleFileName(style->fileName);
int index = style->fileName.lastIndexOf(".qss");
tabStyleFileName.replace(index, 4, "-tab.qss");
activeTabStyleFileName.replace(index, 4, "-activetab.qss");
QFile styleFile(style->fileName);
if (styleFile.open(QIODevice::ReadOnly))
{
QTextStream in(&styleFile);
style->stylesheet = in.readAll();
}
else
{
BERRY_WARN << "Could not read " << style->fileName.toStdString();
}
QFile tabStyleFile(tabStyleFileName);
if (tabStyleFile.open(QIODevice::ReadOnly))
{
QTextStream in(&tabStyleFile);
style->tabStylesheet = in.readAll();
}
else
{
BERRY_WARN << "Could not read " << tabStyleFileName.toStdString();
}
QFile activeTabStyleFile(activeTabStyleFileName);
if (activeTabStyleFile.open(QIODevice::ReadOnly))
{
QTextStream in(&activeTabStyleFile);
style->activeTabStylesheet = in.readAll();
}
else
{
BERRY_WARN << "Could not read " << activeTabStyleFileName.toStdString();
}
}
void QtStyleManager::RemoveStyle(const QString& styleFileName)
{
if (currentStyle->fileName == styleFileName)
{
SetDefaultStyle();
}
delete styles.take(styleFileName);
}
void QtStyleManager::RemoveStyles(const QString& repo)
{
if (repo.isEmpty())
{
ClearStyles();
return;
}
for (FileNameToStyleMap::iterator i = styles.begin(); i != styles.end();)
{
ExtStyle* style = i.value();
QFileInfo info(style->fileName);
if (info.absolutePath() == repo)
{
if (style->name == currentStyle->name)
{
SetDefaultStyle();
}
i = styles.erase(i);
delete style;
}
else
{
++i;
}
}
}
void QtStyleManager::GetStyles(StyleList& styleNames) const
{
for (FileNameToStyleMap::const_iterator i = styles.begin(); i != styles.end(); ++i)
styleNames.push_back(Style(i.value()->name, i.value()->fileName));
}
void QtStyleManager::SetStyle(const QString& fileName)
{
SetStyle(fileName, true);
}
void QtStyleManager::SetStyle(const QString& fileName, bool update)
{
if (fileName.isEmpty())
{
SetDefaultStyle();
return;
}
FileNameToStyleMap::const_iterator i = styles.find(fileName);
ExtStyle* style = 0;
if (i == styles.end())
{
BERRY_WARN << "Style " + fileName.toStdString() << " does not exist";
style = defaultStyle;
}
else
{
style = i.value();
}
currentStyle = style;
ReadStyleData(style);
if (update)
{
qApp->setStyleSheet(currentStyle->stylesheet);
PlatformUI::GetWorkbench()->UpdateTheme();
}
}
QtStyleManager::Style QtStyleManager::GetDefaultStyle() const
{
return Style(defaultStyle->name, defaultStyle->fileName);
}
void QtStyleManager::SetDefaultStyle()
{
SetDefaultStyle(true);
}
void QtStyleManager::SetDefaultStyle(bool update)
{
SetStyle(defaultStyle->fileName, update);
}
bool QtStyleManager::Contains(const QString& fileName) const
{
return styles.contains(fileName);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtStyleManager.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtStyleManager.h
index 583f3f29fe..cf1dc8b3b2 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtStyleManager.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtStyleManager.h
@@ -1,85 +1,85 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYQTSTYLEMANAGER_H_
#define BERRYQTSTYLEMANAGER_H_
#include "berryIQtStyleManager.h"
#include <QHash>
namespace berry {
class QtStyleManager : public QObject, public IQtStyleManager
{
Q_OBJECT
Q_INTERFACES(berry::IQtStyleManager)
public:
QtStyleManager();
~QtStyleManager();
Style GetStyle() const;
QString GetStylesheet() const;
QString GetActiveTabStylesheet() const;
QString GetTabStylesheet() const;
void AddStyle(const QString& styleFileName, const QString& styleName = QString());
void AddStyles(const QString& path);
void RemoveStyle(const QString& styleFileName);
void RemoveStyles(const QString& path = QString());
void GetStyles(StyleList& styles) const;
void SetStyle(const QString& fileName);
Style GetDefaultStyle() const;
void SetDefaultStyle();
bool Contains(const QString& fileName) const;
bool IsA( const std::type_info& type ) const;
const std::type_info& GetType() const;
private:
void AddDefaultStyle();
void ClearStyles();
void ReadPreferences();
void SetStyle(const QString& fileName, bool update);
void SetDefaultStyle(bool update);
struct ExtStyle : public Style
{
QString stylesheet;
QString tabStylesheet;
QString activeTabStylesheet;
};
void ReadStyleData(ExtStyle* style);
typedef QHash<QString, ExtStyle*> FileNameToStyleMap;
FileNameToStyleMap styles;
ExtStyle const* currentStyle;
ExtStyle* defaultStyle;
};
}
#endif /* BERRYQTSTYLEMANAGER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtStylePreferencePage.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtStylePreferencePage.cpp
index 0a815ebe5e..5bc09d5e72 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtStylePreferencePage.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtStylePreferencePage.cpp
@@ -1,209 +1,209 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryQtStylePreferencePage.h"
#include <berryIPreferencesService.h>
#include <berryQtPreferences.h>
#include <QFileDialog>
#include <QDirIterator>
namespace berry
{
QtStylePreferencePage::QtStylePreferencePage()
{
}
QtStylePreferencePage::QtStylePreferencePage(const QtStylePreferencePage& other)
{
Q_UNUSED(other)
}
void QtStylePreferencePage::Init(IWorkbench::Pointer )
{
}
void QtStylePreferencePage::CreateQtControl(QWidget* parent)
{
mainWidget = new QWidget(parent);
controls.setupUi(mainWidget);
berry::IPreferencesService::Pointer prefService
= berry::Platform::GetServiceRegistry()
.GetServiceById<berry::IPreferencesService>(berry::IPreferencesService::ID);
styleManager = berry::Platform::GetServiceRegistry()
.GetServiceById<berry::IQtStyleManager>(berry::IQtStyleManager::ID);
m_StylePref = prefService->GetSystemPreferences()->Node(berry::QtPreferences::QT_STYLES_NODE);
Update();
connect(controls.m_StylesCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(StyleChanged(int)));
connect(controls.m_PathList, SIGNAL(itemSelectionChanged()), this, SLOT(UpdatePathListButtons()));
connect(controls.m_AddButton, SIGNAL(clicked(bool)), this, SLOT(AddPathClicked(bool)));
connect(controls.m_EditButton, SIGNAL(clicked(bool)), this, SLOT(EditPathClicked(bool)));
connect(controls.m_RemoveButton, SIGNAL(clicked(bool)), this, SLOT(RemovePathClicked(bool)));
}
void QtStylePreferencePage::FillStyleCombo(const berry::IQtStyleManager::Style& currentStyle)
{
controls.m_StylesCombo->clear();
styles.clear();
styleManager->GetStyles(styles);
qSort(styles);
for (int i = 0; i < styles.size(); ++i)
{
controls.m_StylesCombo->addItem(styles.at(i).name, QVariant(styles.at(i).fileName));
}
controls.m_StylesCombo->setCurrentIndex(styles.indexOf(currentStyle));
}
void QtStylePreferencePage::AddPath(const QString& path, bool updateCombo)
{
if (!controls.m_PathList->findItems(path, Qt::MatchCaseSensitive).isEmpty()) return;
new QListWidgetItem(path, controls.m_PathList);
styleManager->AddStyles(path);
if (updateCombo)
FillStyleCombo(oldStyle);
}
void QtStylePreferencePage::StyleChanged(int /*index*/)
{
QString fileName = controls.m_StylesCombo->itemData(controls.m_StylesCombo->currentIndex()).toString();
styleManager->SetStyle(fileName);
}
void QtStylePreferencePage::AddPathClicked(bool /*checked*/)
{
QListWidgetItem* item = controls.m_PathList->currentItem();
QString initialDir;
if (item) initialDir = item->text();
QString dir = QFileDialog::getExistingDirectory(mainWidget, "", initialDir);
if (!dir.isEmpty()) this->AddPath(dir, true);
}
void QtStylePreferencePage::RemovePathClicked(bool /*checked*/)
{
QList<QListWidgetItem*> selection = controls.m_PathList->selectedItems();
QListIterator<QListWidgetItem*> it(selection);
while (it.hasNext())
{
QListWidgetItem* item = it.next();
QString dir = item->text();
controls.m_PathList->takeItem(controls.m_PathList->row(item));
delete item;
styleManager->RemoveStyles(dir);
}
if (!styleManager->Contains(oldStyle.fileName))
{
oldStyle = styleManager->GetDefaultStyle();
}
FillStyleCombo(oldStyle);
}
void QtStylePreferencePage::EditPathClicked(bool checked)
{
QListWidgetItem* item = controls.m_PathList->currentItem();
QString initialDir = item->text();
QString dir = QFileDialog::getExistingDirectory(mainWidget, "", initialDir);
if (!dir.isEmpty())
{
this->RemovePathClicked(checked);
this->AddPath(dir, true);
}
}
void QtStylePreferencePage::UpdatePathListButtons()
{
int s = controls.m_PathList->selectedItems().size();
if (s == 0)
{
controls.m_EditButton->setEnabled(false);
controls.m_RemoveButton->setEnabled(false);
}
else if (s == 1)
{
controls.m_EditButton->setEnabled(true);
controls.m_RemoveButton->setEnabled(true);
}
else
{
controls.m_EditButton->setEnabled(false);
controls.m_RemoveButton->setEnabled(true);
}
}
QWidget* QtStylePreferencePage::GetQtControl() const
{
return mainWidget;
}
bool QtStylePreferencePage::PerformOk()
{
m_StylePref->Put(berry::QtPreferences::QT_STYLE_NAME,
controls.m_StylesCombo->itemData(controls.m_StylesCombo->currentIndex()).toString().toStdString());
std::string paths;
for (int i = 0; i < controls.m_PathList->count(); ++i)
{
QString path = controls.m_PathList->item(i)->text() + ";";
paths += path.toStdString();
}
m_StylePref->Put(berry::QtPreferences::QT_STYLE_SEARCHPATHS, paths);
return true;
}
void QtStylePreferencePage::PerformCancel()
{
Update();
}
void QtStylePreferencePage::Update()
{
styleManager->RemoveStyles();
QString paths = QString::fromStdString(m_StylePref->Get(berry::QtPreferences::QT_STYLE_SEARCHPATHS, ""));
QStringList pathList = paths.split(";", QString::SkipEmptyParts);
QStringListIterator it(pathList);
while (it.hasNext())
{
AddPath(it.next(), false);
}
std::string name = m_StylePref->Get(berry::QtPreferences::QT_STYLE_NAME, "");
styleManager->SetStyle(QString::fromStdString(name));
oldStyle = styleManager->GetStyle();
FillStyleCombo(oldStyle);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtStylePreferencePage.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtStylePreferencePage.h
index 005ed80570..24010646f1 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtStylePreferencePage.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtStylePreferencePage.h
@@ -1,81 +1,81 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYQTSTYLEPREFERENCEPAGE_H_
#define BERRYQTSTYLEPREFERENCEPAGE_H_
#include <berryIQtPreferencePage.h>
#include <berryIPreferences.h>
#include <berryIQtStyleManager.h>
#include <ui_berryQtStylePreferencePage.h>
#include <QStringList>
namespace berry {
class QtStylePreferencePage : public QObject, public IQtPreferencePage
{
Q_OBJECT
Q_INTERFACES(berry::IPreferencePage)
public:
QtStylePreferencePage();
QtStylePreferencePage(const QtStylePreferencePage& other);
void Init(IWorkbench::Pointer workbench);
void CreateQtControl(QWidget* parent);
QWidget* GetQtControl() const;
bool PerformOk();
void PerformCancel();
void Update();
protected:
void AddPath(const QString& path, bool updateCombo);
void FillStyleCombo(const berry::IQtStyleManager::Style& currentStyle);
protected slots:
void StyleChanged(int /*index*/);
void AddPathClicked(bool /*checked*/);
void RemovePathClicked(bool /*checked*/);
void EditPathClicked(bool checked);
void UpdatePathListButtons();
private:
berry::IQtStyleManager::Pointer styleManager;
Ui::QtStylePreferencePageUI controls;
berry::IPreferences::Pointer m_StylePref;
berry::IQtStyleManager::Style oldStyle;
berry::IQtStyleManager::StyleList styles;
QWidget* mainWidget;
};
}
#endif /* BERRYQTSTYLEPREFERENCEPAGE_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtTracker.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtTracker.cpp
index fabb1890d2..4429f9b3f6 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtTracker.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtTracker.cpp
@@ -1,249 +1,249 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryQtTracker.h"
#include <QEvent>
#include <QKeyEvent>
#include <QApplication>
namespace berry
{
bool QtDragManager::eventFilter(QObject* o, QEvent* e)
{
if (beingCancelled)
{
if (e->type() == QEvent::KeyRelease && ((QKeyEvent*) e)->key()
== Qt::Key_Escape)
{
QApplication::instance()->removeEventFilter(this);
beingCancelled = false;
eventLoop->exit();
return true; // block the key release
}
return false;
}
if (!o->isWidgetType())
return false;
if (e->type() == QEvent::MouseMove)
{
QMouseEvent* me = (QMouseEvent *) e;
this->Move(me->globalPos());
return true;
}
else if (e->type() == QEvent::MouseButtonRelease)
{
//DEBUG("pre drop");
QApplication::instance()->removeEventFilter(this);
beingCancelled = false;
eventLoop->exit();
return true;
}
if (e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease)
{
QKeyEvent *ke = ((QKeyEvent*) e);
if (ke->key() == Qt::Key_Escape && e->type() == QEvent::KeyPress)
{
this->Cancel();
QApplication::instance()->removeEventFilter(this);
//beingCancelled = false;
eventLoop->exit();
}
else
{
// move(QCursor::pos());
}
return true; // Eat all key events
}
// ### We bind modality to widgets, so we have to do this
// ### "manually".
// DnD is modal - eat all other interactive events
switch (e->type())
{
case QEvent::MouseButtonPress:
case QEvent::MouseButtonRelease:
case QEvent::MouseButtonDblClick:
case QEvent::MouseMove:
case QEvent::KeyPress:
case QEvent::KeyRelease:
case QEvent::Wheel:
case QEvent::ShortcutOverride:
#ifdef QT3_SUPPORT
case QEvent::Accel:
case QEvent::AccelAvailable:
#endif
return true;
default:
return false;
}
}
void QtDragManager::Cancel()
{
beingCancelled = true;
}
void QtDragManager::Move(const QPoint& globalPos)
{
tracker->HandleMove(globalPos);
}
bool QtDragManager::Drag(QtTracker* tracker)
{
if (tracker == 0)
return false;
this->tracker = tracker;
beingCancelled = false;
QApplication::instance()->installEventFilter(this);
// if (!QWidget::mouseGrabber())
// rubberBand->grabMouse();
eventLoop = new QEventLoop;
eventLoop->exec();
delete eventLoop;
eventLoop = 0;
return !beingCancelled;
}
QtTracker::QtTracker() :
rubberBand(0), dragManager(0), cursorOverride(0)
{
rubberBand = new QRubberBand(QRubberBand::Rectangle);
QPalette rubberPalette(rubberBand->palette());
//rubberPalette.setColor(QPalette::Button, QColor(Qt::darkRed));
rubberPalette.setBrush(QPalette::Foreground, QBrush(Qt::darkRed));
rubberPalette.setBrush(QPalette::Window, QBrush(Qt::darkRed));
rubberPalette.setBrush(QPalette::Background, QBrush(Qt::darkRed));
rubberPalette.setBrush(QPalette::Base, QBrush(Qt::darkRed));
rubberPalette.setBrush(QPalette::Text, QBrush(Qt::darkRed));
rubberBand->setPalette(rubberPalette);
rubberBand->ensurePolished();
QPixmap pixCursorTop(":/org.blueberry.ui.qt/cursor_top.xpm");
QCursor* cursorTop = new QCursor(pixCursorTop, 15, 8);
cursorMap.insert(std::make_pair(DnDTweaklet::CURSOR_TOP, cursorTop));
QPixmap pixCursorRight(":/org.blueberry.ui.qt/cursor_right.xpm");
QCursor* cursorRight = new QCursor(pixCursorRight, 23, 15);
cursorMap.insert(std::make_pair(DnDTweaklet::CURSOR_RIGHT, cursorRight));
QPixmap pixCursorBottom(":/org.blueberry.ui.qt/cursor_bottom.xpm");
QCursor* cursorBottom = new QCursor(pixCursorBottom, 16, 23);
cursorMap.insert(std::make_pair(DnDTweaklet::CURSOR_BOTTOM, cursorBottom));
QPixmap pixCursorLeft(":/org.blueberry.ui.qt/cursor_left.xpm");
QCursor* cursorLeft = new QCursor(pixCursorLeft, 8, 15);
cursorMap.insert(std::make_pair(DnDTweaklet::CURSOR_LEFT, cursorLeft));
QPixmap pixCursorCenter(":/org.blueberry.ui.qt/cursor_center.xpm");
QCursor* cursorCenter = new QCursor(pixCursorCenter, 15, 15);
cursorMap.insert(std::make_pair(DnDTweaklet::CURSOR_CENTER, cursorCenter));
QPixmap pixCursorOffscreen(":/org.blueberry.ui.qt/cursor_offscreen.xpm");
QCursor* cursorOffscreen = new QCursor(pixCursorOffscreen, 15, 15);
cursorMap.insert(std::make_pair(DnDTweaklet::CURSOR_OFFSCREEN, cursorOffscreen));
QCursor* cursorInvalid = new QCursor(Qt::ForbiddenCursor);
cursorMap.insert(std::make_pair(DnDTweaklet::CURSOR_INVALID, cursorInvalid));
}
QtTracker::~QtTracker()
{
delete rubberBand;
for (std::map<DnDTweaklet::CursorType, QCursor*>::iterator iter = cursorMap.begin();
iter != cursorMap.end(); ++iter)
{
delete iter->second;
}
}
Rectangle QtTracker::GetRectangle()
{
const QRect& rect = rubberBand->geometry();
return Rectangle(rect.x(), rect.y(), rect.width(), rect.height());
}
void QtTracker::SetRectangle(const Rectangle& rectangle)
{
rubberBand->setGeometry(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
}
void QtTracker::SetCursor(DnDTweaklet::CursorType cursorType)
{
QCursor* cursor = cursorMap[cursorType];
if (!cursor) return;
if (cursorOverride > 0)
{
QApplication::changeOverrideCursor(*cursor);
}
else
{
++cursorOverride;
QApplication::setOverrideCursor(*cursor);
}
}
bool QtTracker::Open()
{
rubberBand->show();
dragManager = new QtDragManager();
bool result = dragManager->Drag(this);
delete dragManager;
rubberBand->hide();
while (cursorOverride > 0)
{
QApplication::restoreOverrideCursor();
--cursorOverride;
}
return result;
}
void QtTracker::AddControlListener(GuiTk::IControlListener::Pointer listener)
{
controlEvents.AddListener(listener);
}
void QtTracker::RemoveControlListener(GuiTk::IControlListener::Pointer listener)
{
controlEvents.RemoveListener(listener);
}
void QtTracker::HandleMove(const QPoint& globalPoint)
{
GuiTk::ControlEvent::Pointer event(
new GuiTk::ControlEvent(this, globalPoint.x(), globalPoint.y(), 0, 0));
controlEvents.movedEvent(event);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtTracker.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtTracker.h
index 9bcc93b8a5..1d269f98d9 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtTracker.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtTracker.h
@@ -1,97 +1,97 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYQTTRACKER_H_
#define BERRYQTTRACKER_H_
#include <berryITracker.h>
#include <berryDnDTweaklet.h>
#include <berryGuiTkIControlListener.h>
#include <QDrag>
#include <QRubberBand>
#include <QEventLoop>
#include <QCursor>
#include <map>
namespace berry {
class QtTracker;
class QtDragManager : public QObject {
Q_OBJECT
private:
QtTracker* tracker;
QEventLoop* eventLoop;
bool beingCancelled;
protected:
bool eventFilter(QObject* o, QEvent* e);
void Cancel();
void Move(const QPoint& globalPos);
public:
bool Drag(QtTracker* tracker);
};
class QtTracker : public ITracker {
private:
QRubberBand* rubberBand;
QtDragManager* dragManager;
int cursorOverride;
GuiTk::IControlListener::Events controlEvents;
std::map<DnDTweaklet::CursorType, QCursor*> cursorMap;
public:
QtTracker();
~QtTracker();
Rectangle GetRectangle();
void SetRectangle(const Rectangle& rectangle);
void SetCursor(DnDTweaklet::CursorType cursor);
bool Open();
void AddControlListener(GuiTk::IControlListener::Pointer listener);
void RemoveControlListener(GuiTk::IControlListener::Pointer listener);
void HandleMove(const QPoint& globalPoint);
};
}
#endif /* BERRYQTTRACKER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWidgetsTweaklet.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWidgetsTweaklet.cpp
index 5b9e3ea860..0e69eea542 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWidgetsTweaklet.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWidgetsTweaklet.cpp
@@ -1,280 +1,280 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryQtWidgetsTweaklet.h"
#include <QWidget>
#include <QVariant>
namespace berry
{
QtWidgetsTweaklet::QtWidgetsTweaklet()
{
}
QtWidgetsTweaklet::QtWidgetsTweaklet(const QtWidgetsTweaklet& other)
{
Q_UNUSED(other)
}
void QtWidgetsTweaklet::AddSelectionListener(void* widget,
GuiTk::ISelectionListener::Pointer listener)
{
impl.AddSelectionListener(static_cast<QWidget*>(widget), listener);
}
void QtWidgetsTweaklet::RemoveSelectionListener(void* widget,
GuiTk::ISelectionListener::Pointer listener)
{
impl.RemoveSelectionListener(static_cast<QWidget*>(widget), listener);
}
Rectangle QtWidgetsTweaklet::GetScreenSize(int i)
{
return impl.GetScreenSize(i);
}
unsigned int QtWidgetsTweaklet::GetScreenNumber()
{
return impl.GetScreenNumber();
}
int QtWidgetsTweaklet::GetPrimaryScreenNumber()
{
return impl.GetPrimaryScreenNumber();
}
Rectangle QtWidgetsTweaklet::GetAvailableScreenSize(int i)
{
return impl.GetAvailableScreenSize(i);
}
int QtWidgetsTweaklet::GetClosestScreenNumber(const Rectangle& rect)
{
return impl.GetClosestScreenNumber(rect);
}
//IMenu::Pointer QtWidgetsTweaklet::CreateMenu(void*, IMenu::Style style)
//{
// //TODO Qt CreateMenu
// return IMenu::Pointer(0);
//}
//IMenu::Pointer QtWidgetsTweaklet::CreateMenu(IMenu::Pointer parent)
//{
// //TODO Qt CreateMenu
// return IMenu::Pointer(0);
//}
//IMenuItem::Pointer QtWidgetsTweaklet::CreateMenuItem(IMenu::Pointer, IMenuItem::Style, int index)
//{
// //TODO Qt CreateMenuItem
// return IMenuItem::Pointer(0);
//}
void QtWidgetsTweaklet::AddControlListener(void* widget,
GuiTk::IControlListener::Pointer listener)
{
QWidget* qwidget = static_cast<QWidget*>(widget);
QVariant variant = qwidget->property(QtWidgetController::PROPERTY_ID);
if (variant.isValid())
{
QtWidgetController::Pointer controller = variant.value<QtWidgetController::Pointer>();
if (controller != 0)
impl.AddControlListener(controller.GetPointer(), listener);
}
}
void QtWidgetsTweaklet::RemoveControlListener(void* widget,
GuiTk::IControlListener::Pointer listener)
{
QWidget* qwidget = static_cast<QWidget*>(widget);
QVariant variant = qwidget->property(QtWidgetController::PROPERTY_ID);
if (variant.isValid())
{
QtWidgetController::Pointer controller = variant.value<QtWidgetController::Pointer>();
if (controller != 0)
impl.RemoveControlListener(controller.GetPointer(), listener);
}
}
bool QtWidgetsTweaklet::GetEnabled(void* widget)
{
return impl.GetEnabled(static_cast<QWidget*>(widget));
}
void QtWidgetsTweaklet::SetEnabled(void* widget, bool enabled)
{
impl.SetEnabled(static_cast<QWidget*>(widget), enabled);
}
void QtWidgetsTweaklet::SetBounds(void* widget, const Rectangle& bounds)
{
impl.SetBounds(static_cast<QWidget*>(widget), bounds);
}
Rectangle QtWidgetsTweaklet::GetBounds(void* widget)
{
return impl.GetBounds(static_cast<QWidget*>(widget));
}
void QtWidgetsTweaklet::SetVisible(void* widget, bool visible)
{
impl.SetVisible(static_cast<QWidget*>(widget), visible);
}
bool QtWidgetsTweaklet::GetVisible(void* widget)
{
return impl.GetVisible(static_cast<QWidget*>(widget));
}
bool QtWidgetsTweaklet::IsVisible(void* widget)
{
return impl.IsVisible(static_cast<QWidget*>(widget));
}
Rectangle QtWidgetsTweaklet::GetClientArea(void* widget)
{
return impl.GetClientArea(static_cast<QWidget*>(widget));
}
void* QtWidgetsTweaklet::GetParent(void* widget)
{
return impl.GetParent(static_cast<QWidget*>(widget));
}
bool QtWidgetsTweaklet::SetParent(void* widget, void* parent)
{
return impl.SetParent(static_cast<QWidget*>(widget),
static_cast<QWidget*>(parent));
}
void QtWidgetsTweaklet::SetData(void* widget, const std::string& id, Object::Pointer data)
{
impl.SetData(static_cast<QWidget*>(widget), id, data);
}
Object::Pointer QtWidgetsTweaklet::GetData(void* widget, const std::string& id)
{
return impl.GetData(static_cast<QWidget*>(widget), id);
}
Point QtWidgetsTweaklet::GetCursorLocation()
{
return impl.GetCursorLocation();
}
void* QtWidgetsTweaklet::GetCursorControl()
{
return impl.GetCursorControl();
}
void* QtWidgetsTweaklet::FindControl(const std::vector<Shell::Pointer>& shells, const Point& location)
{
return impl.FindControl(shells, location);
}
bool QtWidgetsTweaklet::IsChild(void* parentToTest, void* childToTest)
{
return impl.IsChild(static_cast<QObject*>(parentToTest),
static_cast<QObject*>(childToTest));
}
void* QtWidgetsTweaklet::GetFocusControl()
{
return impl.GetFocusControl();
}
bool QtWidgetsTweaklet::IsReparentable(void* widget)
{
return impl.IsReparentable(static_cast<QWidget*>(widget));
}
void QtWidgetsTweaklet::MoveAbove(void* widgetToMove, void* widget)
{
impl.MoveAbove(static_cast<QWidget*>(widgetToMove),
static_cast<QWidget*>(widget));
}
void QtWidgetsTweaklet::MoveBelow(void* widgetToMove, void* widget)
{
impl.MoveBelow(static_cast<QWidget*>(widgetToMove),
static_cast<QWidget*>(widget));
}
void QtWidgetsTweaklet::Dispose(void* widget)
{
impl.Dispose(static_cast<QWidget*>(widget));
}
Shell::Pointer QtWidgetsTweaklet::CreateShell(Shell::Pointer parent, int style)
{
return impl.CreateShell(parent, style);
}
void* QtWidgetsTweaklet::CreateComposite(void* parent)
{
return impl.CreateComposite(static_cast<QWidget*>(parent));
}
void QtWidgetsTweaklet::DisposeShell(Shell::Pointer shell)
{
impl.DisposeShell(shell);
}
std::vector<Shell::Pointer> QtWidgetsTweaklet::GetShells()
{
return impl.GetShells();
}
Shell::Pointer QtWidgetsTweaklet::GetShell(void* widget)
{
return impl.GetShell(static_cast<QWidget*>(widget));
}
Shell::Pointer QtWidgetsTweaklet::GetActiveShell()
{
return impl.GetActiveShell();
}
Rectangle QtWidgetsTweaklet::ToControl(void* coordinateSystem,
const Rectangle& toConvert)
{
return impl.ToControl(static_cast<QWidget*>(coordinateSystem), toConvert);
}
Point QtWidgetsTweaklet::ToControl(void* coordinateSystem,
const Point& toConvert)
{
return impl.ToControl(static_cast<QWidget*>(coordinateSystem), toConvert);
}
Rectangle QtWidgetsTweaklet::ToDisplay(void* coordinateSystem,
const Rectangle& toConvert)
{
return impl.ToDisplay(static_cast<QWidget*>(coordinateSystem), toConvert);
}
Point QtWidgetsTweaklet::ToDisplay(void* coordinateSystem,
const Point& toConvert)
{
return impl.ToDisplay(static_cast<QWidget*>(coordinateSystem), toConvert);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWidgetsTweaklet.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWidgetsTweaklet.h
index c14d1e69dd..aa99633bda 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWidgetsTweaklet.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWidgetsTweaklet.h
@@ -1,132 +1,132 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYQTWIDGETSTWEAKLET_H_
#define BERRYQTWIDGETSTWEAKLET_H_
#include <berryGuiWidgetsTweaklet.h>
#include "berryQtWidgetsTweakletImpl.h"
namespace berry {
class QtWidgetsTweaklet : public QObject, public GuiWidgetsTweaklet
{
Q_OBJECT
Q_INTERFACES(berry::GuiWidgetsTweaklet)
public:
QtWidgetsTweaklet();
QtWidgetsTweaklet(const QtWidgetsTweaklet& other);
void AddSelectionListener(void* widget, GuiTk::ISelectionListener::Pointer listener);
void RemoveSelectionListener(void* widget, GuiTk::ISelectionListener::Pointer listener);
void AddControlListener(void* widget, GuiTk::IControlListener::Pointer listener);
void RemoveControlListener(void* widget, GuiTk::IControlListener::Pointer listener);
bool GetEnabled(void* widget);
void SetEnabled(void* widget, bool enabled);
void SetBounds(void* widget, const Rectangle& bounds);
Rectangle GetBounds(void* widget);
void SetVisible(void* widget, bool visible);
bool GetVisible(void* widget);
bool IsVisible(void* widget);
Rectangle GetClientArea(void* widget);
void* GetParent(void* widget);
bool SetParent(void* widget, void* parent);
void SetData(void* widget, const std::string& id, Object::Pointer data);
Object::Pointer GetData(void* widget, const std::string& id);
//IMenu::Pointer CreateMenu(void*, IMenu::Style = IMenu::POP_UP);
//IMenu::Pointer CreateMenu(IMenu::Pointer parent);
//IMenuItem::Pointer CreateMenuItem(IMenu::Pointer, IMenuItem::Style, int index = -1);
Rectangle GetScreenSize(int i = -1);
unsigned int GetScreenNumber();
int GetPrimaryScreenNumber();
Rectangle GetAvailableScreenSize(int i = -1);
int GetClosestScreenNumber(const Rectangle&);
Point GetCursorLocation();
void* GetCursorControl();
void* FindControl(const std::vector<Shell::Pointer>& shells, const Point& location);
/**
* Determines if one control is a child of another. Returns true iff the second
* argument is a child of the first (or the same object).
*
* @param potentialParent
* @param childToTest
* @return
*/
bool IsChild(void* potentialParent, void* childToTest);
/**
* Returns the control which currently has keyboard focus,
* or null if keyboard events are not currently going to
* any of the controls built by the currently running
* application.
*
* @return the control under the cursor
*/
void* GetFocusControl();
bool IsReparentable(void* widget);
void MoveAbove(void* widgetToMove, void* widget);
void MoveBelow(void* widgetToMove, void* widget);
void Dispose(void* widget);
Shell::Pointer CreateShell(Shell::Pointer parent, int style);
void DisposeShell(Shell::Pointer shell);
void* CreateComposite(void* parent);
std::vector<Shell::Pointer> GetShells();
Shell::Pointer GetShell(void* widget);
Shell::Pointer GetActiveShell();
Rectangle ToControl(void* coordinateSystem,
const Rectangle& toConvert);
Point ToControl(void* coordinateSystem,
const Point& toConvert);
Rectangle ToDisplay(void* coordinateSystem,
const Rectangle& toConvert);
Point ToDisplay(void* coordinateSystem,
const Point& toConvert);
private:
QtWidgetsTweakletImpl impl;
};
}
#endif /* BERRYQTWIDGETSTWEAKLET_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWidgetsTweakletImpl.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWidgetsTweakletImpl.cpp
index f1fc56e3ef..3a13edec67 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWidgetsTweakletImpl.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWidgetsTweakletImpl.cpp
@@ -1,446 +1,446 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryLog.h"
#include "berryQtWidgetsTweakletImpl.h"
#include "berryQtSash.h"
#include "berryQtShell.h"
#include <internal/berryQtControlWidget.h>
#include <berryConstants.h>
#include <QAbstractButton>
#include <QDesktopWidget>
#include <QApplication>
#include <QVariant>
namespace berry {
QtSelectionListenerWrapper::QtSelectionListenerWrapper(QWidget* w)
: widget(w)
{
}
void QtSelectionListenerWrapper::AddListener(GuiTk::ISelectionListener::Pointer listener)
{
QAbstractButton* button = qobject_cast<QAbstractButton*>(widget);
if (button != 0)
{
this->connect(button, "clicked(bool)", this, "QAbstractButtonClicked(bool)");
selectionEvents.AddListener(listener);
}
BERRY_WARN << "WARNING: QtWidgetsTweaklet: no suitable type for listening for selections found!\n";
}
int QtSelectionListenerWrapper::RemoveListener(GuiTk::ISelectionListener::Pointer listener)
{
selectionEvents.RemoveListener(listener);
return static_cast<int>(std::max<std::size_t>(selectionEvents.selected.GetListeners().size(),
selectionEvents.defaultSelected.GetListeners().size()));
}
void QtSelectionListenerWrapper::QAbstractButtonClicked(bool /*checked*/)
{
GuiTk::SelectionEvent::Pointer event(new GuiTk::SelectionEvent(widget));
selectionEvents.selected(event);
}
void QtWidgetsTweakletImpl::AddSelectionListener(QWidget* widget,
GuiTk::ISelectionListener::Pointer listener)
{
if (widget == 0) return;
// special handling for berry::QtSash
QtSash* sash = qobject_cast<QtSash*>(widget);
if (sash != 0)
{
sash->AddSelectionListener(listener);
return;
}
// "normal" Qt widgets get wrapped
QtSelectionListenerWrapper* wrapper = selectionListenerMap[widget];
if (wrapper == 0)
{
wrapper = new QtSelectionListenerWrapper(widget);
selectionListenerMap[widget] = wrapper;
}
wrapper->AddListener(listener);
}
void QtWidgetsTweakletImpl::RemoveSelectionListener(QWidget* widget,
GuiTk::ISelectionListener::Pointer listener)
{
if (widget == 0) return;
// special handling for berry::QtSash
QtSash* sash = qobject_cast<QtSash*>(widget);
if (sash != 0)
{
sash->RemoveSelectionListener(listener);
return;
}
QtSelectionListenerWrapper* wrapper = selectionListenerMap[widget];
if (wrapper == 0) return;
if (wrapper->RemoveListener(listener) == 0)
{
selectionListenerMap.erase(wrapper);
delete wrapper;
}
}
Rectangle QtWidgetsTweakletImpl::GetScreenSize(int i)
{
QDesktopWidget *desktop = QApplication::desktop();
QRect screenGeometry;
if (i < 0) screenGeometry = desktop->screen()->geometry();
else screenGeometry = desktop->screenGeometry(i);
return (Rectangle(screenGeometry.x(), screenGeometry.y()
, screenGeometry.width(), screenGeometry.height()));
}
unsigned int QtWidgetsTweakletImpl::GetScreenNumber()
{
QDesktopWidget *desktop = QApplication::desktop();
// get the primary screen
unsigned int numScreens = desktop->numScreens();
return numScreens;
}
int QtWidgetsTweakletImpl::GetPrimaryScreenNumber()
{
QDesktopWidget *desktop = QApplication::desktop();
// get the primary screen
int primaryScreenNr = desktop->primaryScreen();
return primaryScreenNr;
}
Rectangle QtWidgetsTweakletImpl::GetAvailableScreenSize(int i)
{
QDesktopWidget *desktop = QApplication::desktop();
QRect screenGeometry;
if (i < 0) screenGeometry = desktop->screen()->geometry();
else screenGeometry = desktop->availableGeometry(i);
return (Rectangle(screenGeometry.x(), screenGeometry.y()
, screenGeometry.width(), screenGeometry.height()));
}
int QtWidgetsTweakletImpl::GetClosestScreenNumber(const Rectangle& r)
{
QDesktopWidget *desktop = QApplication::desktop();
return desktop->screenNumber(QPoint(r.x + r.width/2, r.y + r.height/2));
}
void QtWidgetsTweakletImpl::AddControlListener(QtWidgetController* controller,
GuiTk::IControlListener::Pointer listener)
{
controller->AddControlListener(listener);
}
void QtWidgetsTweakletImpl::RemoveControlListener(QtWidgetController* controller,
GuiTk::IControlListener::Pointer listener)
{
controller->RemoveControlListener(listener);
}
bool QtWidgetsTweakletImpl::GetEnabled(QWidget* widget)
{
return widget->isEnabled();
}
void QtWidgetsTweakletImpl::SetEnabled(QWidget* widget, bool enabled)
{
widget->setEnabled(enabled);
}
void QtWidgetsTweakletImpl::SetBounds(QWidget* widget, const Rectangle& bounds)
{
widget->setGeometry(bounds.x, bounds.y, bounds.width, bounds.height);
}
Rectangle QtWidgetsTweakletImpl::GetBounds(QWidget* widget)
{
const QRect& geometry = widget->geometry();
Rectangle rect(geometry.x(), geometry.y(), geometry.width(), geometry.height());
return rect;
}
void QtWidgetsTweakletImpl::SetVisible(QWidget* widget, bool visible)
{
widget->setVisible(visible);
}
bool QtWidgetsTweakletImpl::GetVisible(QWidget* widget)
{
return !widget->isHidden();
}
bool QtWidgetsTweakletImpl::IsVisible(QWidget* widget)
{
return widget->isVisible();
}
Rectangle QtWidgetsTweakletImpl::GetClientArea(QWidget* widget)
{
const QRect& contentsRect = widget->contentsRect();
Rectangle rect(contentsRect.x(), contentsRect.y(), contentsRect.width(), contentsRect.height());
return rect;
}
void* QtWidgetsTweakletImpl::GetParent(QWidget* widget)
{
return widget->parentWidget();
}
bool QtWidgetsTweakletImpl::SetParent(QWidget* widget, QWidget* parent)
{
if (parent != widget->parentWidget())
{
widget->setParent(parent);
return true;
}
return false;
}
void QtWidgetsTweakletImpl::SetData(QWidget* object, const std::string& id, Object::Pointer data)
{
if (object == 0) return;
QVariant variant;
if (data != 0)
variant.setValue(data);
object->setProperty(id.c_str(), variant);
}
Object::Pointer QtWidgetsTweakletImpl::GetData(QWidget* object, const std::string& id)
{
if (object == 0) return Object::Pointer(0);
QVariant variant = object->property(id.c_str());
if (variant.isValid())
{
return variant.value<Object::Pointer>();
}
return Object::Pointer(0);
}
Point QtWidgetsTweakletImpl::GetCursorLocation()
{
QPoint qpoint = QCursor::pos();
return Point(qpoint.x(), qpoint.y());
}
QWidget* QtWidgetsTweakletImpl::GetCursorControl()
{
return QApplication::widgetAt(QCursor::pos());
}
QWidget* QtWidgetsTweakletImpl::FindControl(const std::vector<Shell::Pointer>& shells, const Point& location)
{
for (std::vector<Shell::Pointer>::const_iterator iter = shells.begin();
iter != shells.end(); ++iter)
{
QWidget* shellWidget = static_cast<QWidget*>((*iter)->GetControl());
QWidget* control = shellWidget->childAt(location.x, location.y);
if (control) return control;
}
return 0;
}
bool QtWidgetsTweakletImpl::IsChild(QObject* parentToTest, QObject* childToTest)
{
bool found = false;
QObject* parent = childToTest->parent();
while (!found && parent != 0)
{
if (parent == parentToTest) found = true;
parent = parent->parent();
}
return found;
}
QWidget* QtWidgetsTweakletImpl::GetFocusControl()
{
return QApplication::focusWidget();
}
bool QtWidgetsTweakletImpl::IsReparentable(QWidget* /*widget*/)
{
return true;
}
void QtWidgetsTweakletImpl::MoveAbove(QWidget* widgetToMove, QWidget* /*widget*/)
{
widgetToMove->raise();
}
void QtWidgetsTweakletImpl::MoveBelow(QWidget* widgetToMove, QWidget* /*widget*/)
{
widgetToMove->lower();
}
void QtWidgetsTweakletImpl::Dispose(QWidget* widget)
{
delete widget;
widget = 0;
}
Shell::Pointer QtWidgetsTweakletImpl::CreateShell(Shell::Pointer parent, int style)
{
Qt::WindowFlags qtFlags(Qt::CustomizeWindowHint);
if (style & Constants::MAX)
qtFlags |= Qt::WindowMaximizeButtonHint;
if (style & Constants::MIN)
qtFlags |= Qt::WindowMinimizeButtonHint;
if (style & Constants::CLOSE)
{
qtFlags |= Qt::WindowSystemMenuHint;
#if QT_VERSION >= 0x040500
qtFlags |= Qt::WindowCloseButtonHint;
#endif
}
if (!(style & Constants::BORDER))
qtFlags |= Qt::FramelessWindowHint;
if (style & Constants::TITLE)
qtFlags |= Qt::WindowTitleHint;
if (style & Constants::TOOL)
qtFlags |= Qt::Tool;
QWidget* parentWidget = 0;
if (parent != 0)
parentWidget = static_cast<QWidget*>(parent->GetControl());
QtShell* qtshell = new QtShell(parentWidget, qtFlags);
Shell::Pointer shell(qtshell);
shellList.push_back(shell);
if ((style & Constants::APPLICATION_MODAL)
|| (style & Constants::SYSTEM_MODAL)) qtshell->GetWidget()->setWindowModality(Qt::ApplicationModal);
if (style & Constants::PRIMARY_MODAL) qtshell->GetWidget()->setWindowModality(Qt::WindowModal);
return shell;
}
QWidget* QtWidgetsTweakletImpl::CreateComposite(QWidget* parent)
{
QWidget* composite = new QtControlWidget(parent, 0);
composite->setObjectName("created composite");
return composite;
}
void QtWidgetsTweakletImpl::DisposeShell(Shell::Pointer shell)
{
shellList.remove(shell);
}
std::vector<Shell::Pointer> QtWidgetsTweakletImpl::GetShells()
{
std::vector<Shell::Pointer> shells(shellList.begin(), shellList.end());
return shells;
}
Shell::Pointer QtWidgetsTweakletImpl::GetShell(QWidget* widget)
{
QWidget* qwindow = widget->window();
QVariant variant = qwindow->property(QtWidgetController::PROPERTY_ID);
if (variant.isValid())
{
QtWidgetController::Pointer controller = variant.value<QtWidgetController::Pointer>();
poco_assert(controller != 0);
return controller->GetShell();
}
return Shell::Pointer(0);
}
Shell::Pointer QtWidgetsTweakletImpl::GetActiveShell()
{
QWidget* qwidget = QApplication::activeWindow();
if (qwidget == 0) return Shell::Pointer(0);
QVariant variant = qwidget->property(QtWidgetController::PROPERTY_ID);
if (variant.isValid())
{
return variant.value<QtWidgetController::Pointer>()->GetShell();
}
return Shell::Pointer(0);
}
Rectangle QtWidgetsTweakletImpl::ToControl(QWidget* coordinateSystem,
const Rectangle& toConvert)
{
QPoint globalUpperLeft(toConvert.x, toConvert.y);
QPoint globalLowerRight(toConvert.x + toConvert.width, toConvert.y + toConvert.height);
QPoint upperLeft = coordinateSystem->mapFromGlobal(globalUpperLeft);
QPoint lowerRight = coordinateSystem->mapFromGlobal(globalLowerRight);
return Rectangle(upperLeft.x(), upperLeft.y(), lowerRight.x() - upperLeft.x(),
lowerRight.y() - upperLeft.y());
}
Point QtWidgetsTweakletImpl::ToControl(QWidget* coordinateSystem,
const Point& toConvert)
{
QPoint displayPoint(toConvert.x, toConvert.y);
QPoint localPoint = coordinateSystem->mapFromGlobal(displayPoint);
return Point(localPoint.x(), localPoint.y());
}
Rectangle QtWidgetsTweakletImpl::ToDisplay(QWidget* coordinateSystem,
const Rectangle& toConvert)
{
QPoint upperLeft(toConvert.x, toConvert.y);
QPoint lowerRight(toConvert.x + toConvert.width, toConvert.y + toConvert.height);
QPoint globalUpperLeft = coordinateSystem->mapToGlobal(upperLeft);
QPoint globalLowerRight = coordinateSystem->mapToGlobal(lowerRight);
return Rectangle(globalUpperLeft.x(), globalUpperLeft.y(), globalLowerRight.x() - globalUpperLeft.x(),
globalLowerRight.y() - globalUpperLeft.y());
}
Point QtWidgetsTweakletImpl::ToDisplay(QWidget* coordinateSystem,
const Point& toConvert)
{
QPoint localPoint(toConvert.x, toConvert.y);
QPoint displayPoint = coordinateSystem->mapToGlobal(localPoint);
return Point(displayPoint.x(), displayPoint.y());
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWidgetsTweakletImpl.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWidgetsTweakletImpl.h
index e94b644a4e..d14594b925 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWidgetsTweakletImpl.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWidgetsTweakletImpl.h
@@ -1,159 +1,159 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYQTWIDGETSTWEAKLETIMPL_H_
#define BERRYQTWIDGETSTWEAKLETIMPL_H_
#include <internal/berryQtWidgetController.h>
#include <berryRectangle.h>
#include <berryShell.h>
#include <berryGuiTkISelectionListener.h>
#include <QMetaType>
#include <list>
#include <vector>
Q_DECLARE_METATYPE(berry::Object::Pointer)
namespace berry {
class QtSelectionListenerWrapper : public QObject
{
Q_OBJECT
public:
QtSelectionListenerWrapper(QWidget* widget);
QWidget* widget;
void AddListener(GuiTk::ISelectionListener::Pointer listener);
int RemoveListener(GuiTk::ISelectionListener::Pointer listener);
protected slots:
void QAbstractButtonClicked(bool checked);
private:
GuiTk::ISelectionListener::Events selectionEvents;
};
class QtWidgetsTweakletImpl
{
public:
void AddSelectionListener(QWidget* widget, GuiTk::ISelectionListener::Pointer listener);
void RemoveSelectionListener(QWidget* widget, GuiTk::ISelectionListener::Pointer listener);
void AddControlListener(QtWidgetController* widget, GuiTk::IControlListener::Pointer listener);
void RemoveControlListener(QtWidgetController* widget, GuiTk::IControlListener::Pointer listener);
bool GetEnabled(QWidget* widget);
void SetEnabled(QWidget* widget, bool enabled);
void SetBounds(QWidget* widget, const Rectangle& bounds);
Rectangle GetBounds(QWidget* widget);
void SetVisible(QWidget* widget, bool visible);
bool GetVisible(QWidget* widget);
bool IsVisible(QWidget* widget);
Rectangle GetClientArea(QWidget* widget);
void* GetParent(QWidget* widget);
bool SetParent(QWidget* widget, QWidget* parent);
void SetData(QWidget* widget, const std::string& id, Object::Pointer data);
Object::Pointer GetData(QWidget* widget, const std::string& id);
Rectangle GetScreenSize(int i = -1);
unsigned int GetScreenNumber();
int GetPrimaryScreenNumber();
Rectangle GetAvailableScreenSize(int i = -1);
int GetClosestScreenNumber(const Rectangle&);
Point GetCursorLocation();
QWidget* GetCursorControl();
QWidget* FindControl(const std::vector<Shell::Pointer>& shells, const Point& location);
/**
* Determines if one control is a child of another. Returns true iff the second
* argument is a child of the first (or the same object).
*
* @param potentialParent
* @param childToTest
* @return
*/
bool IsChild(QObject* potentialParent, QObject* childToTest);
/**
* Returns the control which currently has keyboard focus,
* or null if keyboard events are not currently going to
* any of the controls built by the currently running
* application.
*
* @return the control under the cursor
*/
QWidget* GetFocusControl();
bool IsReparentable(QWidget* widget);
void MoveAbove(QWidget* widgetToMove, QWidget* widget);
void MoveBelow(QWidget* widgetToMove, QWidget* widget);
void Dispose(QWidget* widget);
Shell::Pointer CreateShell(Shell::Pointer parent, int style);
void DisposeShell(Shell::Pointer shell);
QWidget* CreateComposite(QWidget* parent);
std::vector<Shell::Pointer> GetShells();
Shell::Pointer GetShell(QWidget* widget);
Shell::Pointer GetActiveShell();
Rectangle ToControl(QWidget* coordinateSystem,
const Rectangle& toConvert);
Point ToControl(QWidget* coordinateSystem,
const Point& toConvert);
Rectangle ToDisplay(QWidget* coordinateSystem,
const Rectangle& toConvert);
Point ToDisplay(QWidget* coordinateSystem,
const Point& toConvert);
private:
typedef std::map<void*, QtSelectionListenerWrapper* > SelectionListenerMap;
SelectionListenerMap selectionListenerMap;
std::list<Shell::Pointer> shellList;
friend class QtShell;
};
}
#endif /* BERRYQTWIDGETSTWEAKLETIMPL_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWorkbenchPageTweaklet.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWorkbenchPageTweaklet.cpp
index cba863a501..5807966877 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWorkbenchPageTweaklet.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWorkbenchPageTweaklet.cpp
@@ -1,80 +1,80 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryQtWorkbenchPageTweaklet.h"
#include <internal/berryQtControlWidget.h>
#include <ui_berryQtStatusPart.h>
#include <QWidget>
#include <QHBoxLayout>
namespace berry
{
QtWorkbenchPageTweaklet::QtWorkbenchPageTweaklet()
{
}
QtWorkbenchPageTweaklet::QtWorkbenchPageTweaklet(const QtWorkbenchPageTweaklet& other)
{
Q_UNUSED(other)
}
void* QtWorkbenchPageTweaklet::CreateClientComposite(void* pageControl)
{
QWidget* parent = static_cast<QWidget*>(pageControl);
QtControlWidget* client = new QtControlWidget(parent, 0);
client->setObjectName("Client Composite");
parent->layout()->setContentsMargins(3, 3, 3, 3);
parent->layout()->addWidget(client);
// we have to enable visibility to get a proper layout (see bug #1654)
client->setVisible(true);
return client;
}
void* QtWorkbenchPageTweaklet::CreatePaneControl(void* parent)
{
QWidget* qParent = static_cast<QWidget*>(parent);
QtControlWidget* control = new QtControlWidget(qParent, 0);
// the object name is used in the global event filter to find
// the pane control over which a mouse pressed event occured
// --> do not change the object name
control->setObjectName("PartPaneControl");
return control;
}
Object::Pointer QtWorkbenchPageTweaklet::CreateStatusPart(void* parent, const std::string& title, const std::string& msg)
{
Ui::QtStatusPart statusPart;
statusPart.setupUi(static_cast<QWidget*>(parent));
statusPart.m_TitleLabel->setText(QString::fromStdString(title));
statusPart.m_DetailsLabel->setText(QString::fromStdString(msg));
return Object::Pointer(0);
}
IEditorPart::Pointer QtWorkbenchPageTweaklet::CreateErrorEditorPart(const std::string& /*partName*/, const std::string& /*msg*/)
{
return IEditorPart::Pointer(0);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWorkbenchPageTweaklet.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWorkbenchPageTweaklet.h
index 3ab363216e..6d14b90b4c 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWorkbenchPageTweaklet.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWorkbenchPageTweaklet.h
@@ -1,50 +1,50 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYQTWORKBENCHPAGETWEAKLET_H_
#define BERRYQTWORKBENCHPAGETWEAKLET_H_
#include <berryWorkbenchPageTweaklet.h>
#include <org_blueberry_ui_qt_Export.h>
namespace berry
{
class BERRY_UI_QT QtWorkbenchPageTweaklet : public QObject, public WorkbenchPageTweaklet
{
Q_OBJECT
Q_INTERFACES(berry::WorkbenchPageTweaklet)
public:
berryObjectMacro(QtWorkbenchPageTweaklet);
QtWorkbenchPageTweaklet();
QtWorkbenchPageTweaklet(const QtWorkbenchPageTweaklet& other);
void* CreateClientComposite(void* pageControl);
void* CreatePaneControl(void* parent);
Object::Pointer CreateStatusPart(void* parent, const std::string& title, const std::string& msg);
IEditorPart::Pointer CreateErrorEditorPart(const std::string& partName, const std::string& msg);
};
}
#endif /* BERRYQTWORKBENCHPAGETWEAKLET_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWorkbenchTweaklet.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWorkbenchTweaklet.cpp
index fe964702a5..5536a5b6e7 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWorkbenchTweaklet.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWorkbenchTweaklet.cpp
@@ -1,71 +1,71 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryQtWorkbenchTweaklet.h"
#include <internal/berryQtControlWidget.h>
#include <QApplication>
#include <QMainWindow>
#include "berryQtShowViewDialog.h"
#include "berryQtDisplay.h"
#include "berryQtWorkbenchWindow.h"
#include <berryPlatform.h>
#include <berryPlatformUI.h>
#include <internal/berryWorkbenchWindow.h>
namespace berry {
QtWorkbenchTweaklet::QtWorkbenchTweaklet()
{
}
QtWorkbenchTweaklet::QtWorkbenchTweaklet(const QtWorkbenchTweaklet& other)
{
}
Display* QtWorkbenchTweaklet::CreateDisplay()
{
return new QtDisplay();
}
bool QtWorkbenchTweaklet::IsRunning()
{
return QApplication::instance() != 0;
}
WorkbenchWindow::Pointer QtWorkbenchTweaklet::CreateWorkbenchWindow(int number)
{
WorkbenchWindow::Pointer wnd(new QtWorkbenchWindow(number));
return wnd;
}
IDialog::Pointer
QtWorkbenchTweaklet::CreateStandardDialog(const std::string& dialogid)
{
if (dialogid == DIALOG_ID_SHOW_VIEW)
return IDialog::Pointer(new QtShowViewDialog(PlatformUI::GetWorkbench()->GetViewRegistry()));
else
return IDialog::Pointer(0);
}
} // namespace berry
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWorkbenchTweaklet.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWorkbenchTweaklet.h
index 204e286c78..4667db837f 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWorkbenchTweaklet.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWorkbenchTweaklet.h
@@ -1,52 +1,52 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYQTWORKBENCHTWEAKLET_H_
#define BERRYQTWORKBENCHTWEAKLET_H_
#include <berryWorkbenchTweaklet.h>
#include <org_blueberry_ui_qt_Export.h>
namespace berry {
class BERRY_UI_QT QtWorkbenchTweaklet : public QObject, public WorkbenchTweaklet
{
Q_OBJECT
Q_INTERFACES(berry::WorkbenchTweaklet)
public:
berryObjectMacro(QtWorkbenchTweaklet);
QtWorkbenchTweaklet();
QtWorkbenchTweaklet(const QtWorkbenchTweaklet& other);
Display* CreateDisplay();
bool IsRunning();
SmartPointer<WorkbenchWindow> CreateWorkbenchWindow(int number);
void* CreatePageComposite(void* parent);
IDialog::Pointer CreateStandardDialog(const std::string& id);
};
} // namespace berry
#endif /*BERRYQTWORKBENCHTWEAKLET_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWorkbenchWindow.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWorkbenchWindow.cpp
index ee932f8353..ea97ed5fce 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWorkbenchWindow.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWorkbenchWindow.cpp
@@ -1,66 +1,66 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryQtWorkbenchWindow.h"
#include <internal/berryQtControlWidget.h>
#include "berryQtPerspectiveSwitcher.h"
#include <QWidget>
#include <QMainWindow>
#include <QHBoxLayout>
namespace berry
{
QtWorkbenchWindow::QtWorkbenchWindow(int number) :
WorkbenchWindow(number)
{
}
void* QtWorkbenchWindow::CreatePageComposite(void* p)
{
QWidget* parent = static_cast<QWidget*> (p);
QtControlWidget* pageArea = new QtControlWidget(parent, 0);
pageArea->setObjectName("Page Composite");
new QHBoxLayout(pageArea);
if (qobject_cast<QMainWindow*> (parent) != 0)
qobject_cast<QMainWindow*> (parent)->setCentralWidget(pageArea);
else
parent->layout()->addWidget(pageArea);
// we have to enable visibility to get a proper layout (see bug #1654)
pageArea->setVisible(true);
parent->setVisible(true);
pageComposite = pageArea;
return pageArea;
}
void QtWorkbenchWindow::CreateDefaultContents(Shell::Pointer shell)
{
QMainWindow* mainWindow = static_cast<QMainWindow*>(shell->GetControl());
if (GetWindowConfigurer()->GetShowPerspectiveBar() && mainWindow)
{
mainWindow->addToolBar(new QtPerspectiveSwitcher(IWorkbenchWindow::Pointer(this)));
}
// Create the client composite area (where page content goes).
CreatePageComposite(shell->GetControl());
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWorkbenchWindow.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWorkbenchWindow.h
index 1b0fca473b..130699bcf1 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWorkbenchWindow.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWorkbenchWindow.h
@@ -1,41 +1,41 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYQTWORKBENCHWINDOW_H_
#define BERRYQTWORKBENCHWINDOW_H_
#include <internal/berryWorkbenchWindow.h>
namespace berry {
class QtWorkbenchWindow : public WorkbenchWindow
{
public:
QtWorkbenchWindow(int number);
protected:
void* CreatePageComposite(void* p);
void CreateDefaultContents(Shell::Pointer shell);
};
}
#endif /* BERRYQTWORKBENCHWINDOW_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/defaultpresentation/berryEmptyTabFolder.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/defaultpresentation/berryEmptyTabFolder.cpp
index 336de77367..e400dbc00b 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/defaultpresentation/berryEmptyTabFolder.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/defaultpresentation/berryEmptyTabFolder.cpp
@@ -1,127 +1,127 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryEmptyTabFolder.h"
#include "berryEmptyTabItem.h"
#include <QHBoxLayout>
#include <QRect>
#include <QWidget>
#include <QFrame>
namespace berry
{
EmptyTabFolder::EmptyTabFolder(QWidget* parent, bool /*showborder*/) :
control(0), childControl(0)
{
control = new QFrame(parent);
control->setObjectName("StandaloneViewForm");
QHBoxLayout* layout = new QHBoxLayout(control);
layout->setContentsMargins(0,0,0,0);
control->setLayout(layout);
//borderColor = parent.getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW);
// if (showborder) {
// layout.xmargin = 1;
// layout.ymargin = 1;
// control.addPaintListener(new PaintListener() {
// public void paintControl(PaintEvent e) {
// e.gc.setForeground(borderColor);
// Rectangle rect = control.getClientArea();
// rect.width--;
// rect.height--;
// e.gc.drawRectangle(rect);
// }
// });
// }
}
QSize EmptyTabFolder::ComputeSize(int /*widthHint*/, int /*heightHint*/)
{
QRect rect = control->layout()->contentsRect();
return QSize(rect.x(), rect.y());
}
AbstractTabItem* EmptyTabFolder::Add(int /*index*/, int /*flags*/)
{
return new EmptyTabItem();
}
void EmptyTabFolder::Move(int /*from*/, int /*to*/)
{
}
QWidget* EmptyTabFolder::GetContentParent()
{
return control;
}
void EmptyTabFolder::SetContent(QWidget* newContent)
{
if (childControl)
{
childControl->setParent(0);
}
childControl = newContent;
control->layout()->addWidget(childControl);
}
std::vector<AbstractTabItem*> EmptyTabFolder::GetItems()
{
return std::vector<AbstractTabItem*>();
}
AbstractTabItem* EmptyTabFolder::GetSelection()
{
return 0;
}
void EmptyTabFolder::SetSelection(AbstractTabItem* /*toSelect*/)
{
}
void EmptyTabFolder::Layout(bool flushCache)
{
AbstractTabFolder::Layout(flushCache);
//control->layout->update();
}
void EmptyTabFolder::SetSelectedInfo(const PartInfo& /*info*/)
{
}
void EmptyTabFolder::EnablePaneMenu(bool /*enabled*/)
{
}
QWidget* EmptyTabFolder::GetControl()
{
return control;
}
QRect EmptyTabFolder::GetTabArea()
{
return QRect(0, 0, 0, 0);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/defaultpresentation/berryEmptyTabFolder.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/defaultpresentation/berryEmptyTabFolder.h
index 34d73e88dc..53702c9b91 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/defaultpresentation/berryEmptyTabFolder.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/defaultpresentation/berryEmptyTabFolder.h
@@ -1,122 +1,122 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYEMPTYTABFOLDER_H_
#define BERRYEMPTYTABFOLDER_H_
#include "internal/util/berryAbstractTabFolder.h"
namespace berry
{
/**
* Implements the AbstractTabFolder interface, however this object only displays
* the content of the currently selected part. There are no tabs, no title, no toolbar,
* etc. There is no means to select a different part, unless it is done programmatically.
*
* @since 3.1
*/
class EmptyTabFolder: public AbstractTabFolder
{
private:
QWidget* control;
QWidget* childControl;
//QColor borderColor;
public:
EmptyTabFolder(QWidget* parent, bool showborder);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.presentations.util.AbstractTabFolder#computeSize(int, int)
*/
QSize ComputeSize(int widthHint, int heightHint);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.presentations.util.AbstractTabFolder#add(int, int)
*/
AbstractTabItem* Add(int index, int flags);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.presentations.util.AbstractTabFolder#move(int, int)
*/
void Move(int from, int to);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.presentations.util.AbstractTabFolder#getContentParent()
*/
QWidget* GetContentParent();
/* (non-Javadoc)
* @see org.blueberry.ui.internal.presentations.util.AbstractTabFolder#setContent(org.blueberry.swt.widgets.Control)
*/
void SetContent(QWidget* newContent);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.presentations.util.AbstractTabFolder#getItems()
*/
std::vector<AbstractTabItem*> GetItems();
/* (non-Javadoc)
* @see org.blueberry.ui.internal.presentations.util.AbstractTabFolder#getSelection()
*/
AbstractTabItem* GetSelection();
/* (non-Javadoc)
* @see org.blueberry.ui.internal.presentations.util.AbstractTabFolder#setSelection(org.blueberry.ui.internal.presentations.util.AbstractTabItem)
*/
void SetSelection(AbstractTabItem* toSelect);
// void SetToolbar(Control toolbar) {
// if (toolbar != null) {
// toolbar.setVisible(false);
// }
// }
void Layout(bool flushCache);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.presentations.util.AbstractTabFolder#setSelectedInfo(org.blueberry.ui.internal.presentations.util.PartInfo)
*/
void SetSelectedInfo(const PartInfo& info);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.presentations.util.AbstractTabFolder#enablePaneMenu(boolean)
*/
void EnablePaneMenu(bool enabled);
// /* (non-Javadoc)
// * @see org.blueberry.ui.internal.presentations.util.AbstractTabFolder#getToolbarParent()
// */
// Composite getToolbarParent() {
// return control;
// }
/* (non-Javadoc)
* @see org.blueberry.ui.internal.presentations.util.AbstractTabFolder#getControl()
*/
QWidget* GetControl();
/* (non-Javadoc)
* @see org.blueberry.ui.internal.presentations.util.AbstractTabFolder#getTabArea()
*/
QRect GetTabArea();
};
}
#endif /* BERRYEMPTYTABFOLDER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/defaultpresentation/berryEmptyTabItem.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/defaultpresentation/berryEmptyTabItem.cpp
index 29b11c7cec..af808fbee3 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/defaultpresentation/berryEmptyTabItem.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/defaultpresentation/berryEmptyTabItem.cpp
@@ -1,47 +1,47 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryEmptyTabItem.h"
namespace berry
{
QRect EmptyTabItem::GetBounds()
{
return QRect();
}
void EmptyTabItem::SetInfo(const PartInfo& /*info*/)
{
}
void EmptyTabItem::Dispose()
{
}
Object::Pointer EmptyTabItem::GetData()
{
return Object::Pointer(0);
}
void EmptyTabItem::SetData(Object::Pointer /*data*/)
{
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/defaultpresentation/berryEmptyTabItem.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/defaultpresentation/berryEmptyTabItem.h
index 015ddbfebf..8e94c1393a 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/defaultpresentation/berryEmptyTabItem.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/defaultpresentation/berryEmptyTabItem.h
@@ -1,55 +1,55 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYEMPTYTABITEM_H_
#define BERRYEMPTYTABITEM_H_
#include "internal/util/berryAbstractTabItem.h"
namespace berry {
struct EmptyTabItem : public AbstractTabItem {
/* (non-Javadoc)
* @see AbstractTabItem#getBounds()
*/
QRect GetBounds();
/* (non-Javadoc)
* @see AbstractTabItem#setInfo(org.blueberry.ui.internal.presentations.util.PartInfo)
*/
void SetInfo(const PartInfo& info);
/* (non-Javadoc)
* @see AbstractTabItem#Dispose()
*/
void Dispose();
/* (non-Javadoc)
* @see org.blueberry.ui.internal.presentations.util.AbstractTabItem#getData()
*/
Object::Pointer GetData();
/* (non-Javadoc)
* @see org.blueberry.ui.internal.presentations.util.AbstractTabItem#setData(java.lang.Object)
*/
void SetData(Object::Pointer data);
};
}
#endif /* BERRYEMPTYTABITEM_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/defaultpresentation/berryNativeTabFolder.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/defaultpresentation/berryNativeTabFolder.cpp
index 4aad19ad44..8602c456ab 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/defaultpresentation/berryNativeTabFolder.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/defaultpresentation/berryNativeTabFolder.cpp
@@ -1,358 +1,358 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryNativeTabFolder.h"
#include "berryNativeTabItem.h"
#include "berryQCTabBar.h"
#include <internal/berryQtControlWidget.h>
#include <berryShell.h>
#include <berryConstants.h>
#include <berryPlatform.h>
#include <berryPlatformUI.h>
#include <berryLog.h>
#include <QFrame>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QKeyEvent>
namespace berry
{
AbstractTabItem* NativeTabFolder::GetTab(int index)
{
return tabControl->getTab(index);
}
void NativeTabFolder::TabSelectionChanged(int index)
{
this->FireEvent(TabFolderEvent::EVENT_TAB_SELECTED, tabControl->getTab(index));
}
void NativeTabFolder::DragStarted(const QPoint& location)
{
Point point(location.x(), location.y());
this->HandleDragStarted(location);
}
void NativeTabFolder::ViewFormDestroyed(QObject*)
{
viewForm = 0;
content = 0;
}
NativeTabFolder::NativeTabFolder(QWidget* parent)
: QObject(parent)
{
content = 0;
viewForm = new QtControlWidget(parent, 0);
viewForm->setObjectName("ViewForm");
viewForm->installEventFilter(this);
QVBoxLayout* layout = new QVBoxLayout(viewForm);
layout->setContentsMargins(0,0,0,0);
layout->setSpacing(0);
viewForm->setLayout(layout);
connect(viewForm, SIGNAL(destroyed(QObject*)), this, SLOT(ViewFormDestroyed(QObject*)));
QWidget* topControls = new QWidget(viewForm);
topControls->setMinimumSize(0, 24);
topControls->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
layout->addWidget(topControls);
QHBoxLayout* topLayout = new QHBoxLayout(topControls);
topLayout->setContentsMargins(0, 0, 0, 0);
topLayout->setSpacing(0);
tabControl = new QCTabBar(topControls);
tabControl->installEventFilter(this);
tabControl->setMinimumSize(0, 25);
tabControl->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
topLayout->addWidget(tabControl);
QFrame* topRightControls = new QFrame(topControls);
topRightControls->setObjectName("TabTopRightControls");
topRightControls->setMinimumSize(6, 25);
topRightControls->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
topLayout->addWidget(topRightControls);
contentFrame = new QFrame(viewForm);
contentFrame->setObjectName("ViewFormContentFrame");
contentFrame->installEventFilter(this);
contentFrame->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
QVBoxLayout* contentFrameLayout = new QVBoxLayout(contentFrame);
contentFrameLayout->setContentsMargins(0,0,0,0);
contentFrameLayout->setSpacing(0);
//contentFrame->setLayout(layout);
layout->addWidget(contentFrame);
this->connect(tabControl, SIGNAL(currentChanged(int)), this,
SLOT(TabSelectionChanged(int)));
this->connect(tabControl, SIGNAL(dragStarted(const QPoint&)), this,
SLOT(DragStarted(const QPoint&)));
//std::cout << "Created: viewForm <-- " << qPrintable(parent->objectName());
//for (parent = parent->parentWidget(); parent != 0; parent = parent->parentWidget())
// std::cout << " <-- " << qPrintable(parent->objectName());
//std::cout << std::endl;
//parent = viewForm;
//std::cout << "Created control: QCTabBar <-- " << qPrintable(parent->objectName());
//for (parent = parent->parentWidget(); parent != 0; parent = parent->parentWidget())
// std::cout << " <-- " << qPrintable(parent->objectName());
//std::cout << std::endl;
//attachListeners(control, false);
// viewForm = new ViewForm(control, SWT.FLAT);
// attachListeners(viewForm, false);
// systemToolbar = new StandardSystemToolbar(viewForm, true, false, true, true, true);
// systemToolbar.addListener(systemToolbarListener);
// viewForm.setTopRight(systemToolbar.getControl());
//
// topCenter = new ProxyControl(viewForm);
// topCenterCache = new SizeCache();
//
// title = new CLabel(viewForm, SWT.LEFT);
// attachListeners(title, false);
// viewForm.setTopLeft(title);
skinManager = Platform::GetServiceRegistry().GetServiceById<IQtStyleManager>(IQtStyleManager::ID);
}
NativeTabFolder::~NativeTabFolder()
{
if (!PlatformUI::GetWorkbench()->IsClosing())
{
BERRY_DEBUG << "Deleting viewForm";
if (content != 0)
{
content->setParent(0);
}
viewForm->deleteLater();
}
}
bool NativeTabFolder::eventFilter(QObject* watched, QEvent* event)
{
if (event->type() == QEvent::MouseButtonPress)
{
QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event);
this->HandleMousePress(mouseEvent->pos());
}
return QObject::eventFilter(watched, event);
}
void NativeTabFolder::UpdateColors()
{
QString tabStyle = this->GetActive() == 1 ? skinManager->GetActiveTabStylesheet() : skinManager->GetTabStylesheet();
//tabControl->setStyleSheet(tabSkin);
//contentFrame->setStyleSheet(tabSkin);
viewForm->setStyleSheet(tabStyle);
}
void NativeTabFolder::SetActive(int activeState)
{
AbstractTabFolder::SetActive(activeState);
this->UpdateColors();
}
void NativeTabFolder::CloseButtonClicked(AbstractTabItem* item)
{
this->FireEvent(TabFolderEvent::EVENT_CLOSE, item);
}
QSize NativeTabFolder::ComputeSize(int /*widthHint*/, int /*heightHint*/)
{
return QSize(50,50);
}
AbstractTabItem* NativeTabFolder::Add(int index, int flags)
{
NativeTabItem* item = new NativeTabItem(this, index, flags);
return item;
}
void NativeTabFolder::Move(int from, int to)
{
int tabCount = tabControl->count();
if (to > tabCount) to = tabCount;
tabControl->moveAbstractTab(from, to);
}
void NativeTabFolder::Layout(bool flushCache)
{
AbstractTabFolder::Layout(flushCache);
// QRect rect1 = tabControl->geometry();
// QRect rect2 = viewForm->geometry();
// std::cout << "QCTabBar geometry is: x=" << rect1.x() << ", y=" << rect1.y() << ", width=" << rect1.width() << ", height=" << rect1.height() << std::endl;
// std::cout << "ViewForm geometry is: " << rect2.x() << ", y=" << rect2.y() << ", width=" << rect2.width() << ", height=" << rect2.height() << std::endl;
// Rectangle oldBounds = viewForm.getBounds();
// Rectangle newBounds = control.getClientArea();
//
// viewForm.setBounds(newBounds);
//
// if (Util.equals(oldBounds, newBounds))
// {
// viewForm.layout(flushCache);
// }
}
QPoint NativeTabFolder::GetPaneMenuLocation()
{
return AbstractTabFolder::GetPaneMenuLocation();
//return systemToolbar.getPaneMenuLocation();
}
void NativeTabFolder::SetState(int state)
{
AbstractTabFolder::SetState(state);
//systemToolbar.setState(state);
}
QRect NativeTabFolder::GetClientArea()
{
if (content == 0)
{
return QRect();
}
return content->geometry();
}
std::vector<AbstractTabItem*> NativeTabFolder::GetItems()
{
return tabControl->getTabs();
}
void NativeTabFolder::SetSelection(AbstractTabItem* toSelect)
{
if (toSelect == 0)
{
return;
}
tabControl->setCurrentTab(toSelect);
}
void NativeTabFolder::SetSelectedInfo(const PartInfo& /*info*/)
{
// if (!Util.equals(title.getText(), info.title))
// {
// title.setText(info.title);
// }
// if (title.getImage() != info.image)
// {
// title.setImage(info.image);
// }
}
QRect NativeTabFolder::GetTabArea()
{
return tabControl->geometry();
// Rectangle bounds = control.getBounds();
//
// Rectangle clientArea = control.getClientArea();
//
// bounds.x = 0;
// bounds.y = 0;
// Geometry.expand(bounds, 0, 0, -(clientArea.height + clientArea.y), 0);
//
// return Geometry.toDisplay(control.getParent(), bounds);
}
QWidget* NativeTabFolder::GetControl()
{
return viewForm;
}
bool NativeTabFolder::IsOnBorder(const QPoint& /*globalPos*/)
{
// Point localPos = getControl().toControl(globalPos);
//
// Rectangle clientArea = getClientArea();
// return localPos.y > clientArea.y && localPos.y < clientArea.y
// + clientArea.height;
return false;
}
AbstractTabItem* NativeTabFolder::GetSelection()
{
return tabControl->getCurrentTab();
}
QWidget* NativeTabFolder::GetContentParent()
{
return contentFrame;
}
void NativeTabFolder::SetContent(QWidget* newContent)
{
//viewForm.setContent(newContent);
if (content != 0)
{
contentFrame->layout()->removeWidget(content);
disconnect(content);
}
content = newContent;
content->installEventFilter(this);
//((QBoxLayout*)contentFrame->layout())->addWidget(content, 1);
contentFrame->layout()->addWidget(content);
}
QCTabBar* NativeTabFolder::GetTabFolder()
{
return tabControl;
}
void NativeTabFolder::SetSelectedTitle(const QString& /*newTitle*/)
{
//title.setText(newTitle);
}
void NativeTabFolder::SetSelectedImage(const QPixmap* /*image*/)
{
//title.setImage(image);
}
AbstractTabItem* NativeTabFolder::GetItem(const QPoint& toFind)
{
QPoint localPoint = tabControl->mapFromGlobal(toFind);
int index = tabControl->tabAt(localPoint);
if (index < 0)
return 0;
return tabControl->getTab(index);
}
void NativeTabFolder::EnablePaneMenu(bool /*enabled*/)
{
//systemToolbar.enablePaneMenu(enabled);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/defaultpresentation/berryNativeTabFolder.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/defaultpresentation/berryNativeTabFolder.h
index 6ca1243a42..e71d7f4bfa 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/defaultpresentation/berryNativeTabFolder.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/defaultpresentation/berryNativeTabFolder.h
@@ -1,228 +1,228 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYNATIVETABFOLDER_H_
#define BERRYNATIVETABFOLDER_H_
#include <internal/util/berryAbstractTabFolder.h>
#include <berryIQtStyleManager.h>
#include <QObject>
class QFrame;
class QWidget;
namespace berry
{
class QCTabBar;
class NativeTabFolder: public QObject, public AbstractTabFolder
{
Q_OBJECT
private:
QCTabBar* tabControl;
QFrame* contentFrame;
QWidget* viewForm;
QWidget* content;
// ViewForm viewForm;
// StandardSystemToolbar systemToolbar;
// CLabel title;
// ProxyControl topCenter;
// SizeCache topCenterCache;
// IPropertyListener systemToolbarListener = new IPropertyListener() {
//
// public void propertyChanged(Object source, int propId) {
// Point location;
//
// if (propId == TabFolderEvent.EVENT_PANE_MENU) {
// location = getPaneMenuLocation();
// } else {
// location = new Point(0,0);
// }
//
// fireEvent(propId, getSelection(), location);
// }
//
// };
IQtStyleManager::Pointer skinManager;
/**
* @param item
* @return
*/
AbstractTabItem* GetTab(int index);
private slots:
void TabSelectionChanged(int index);
void DragStarted(const QPoint& location);
void ViewFormDestroyed(QObject*);
public:
NativeTabFolder(QWidget* parent);
~NativeTabFolder();
void UpdateColors();
void SetActive(int activeState);
bool eventFilter(QObject* watched, QEvent* event);
void CloseButtonClicked(AbstractTabItem* item);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.presentations.util.AbstractTabFolder#computeSize(int, int)
*/
QSize ComputeSize(int widthHint, int heightHint);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.presentations.util.AbstractTabFolder#add(int)
*/
AbstractTabItem* Add(int index, int flags);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.presentations.util.AbstractTabFolder#move(int, int)
*/
void Move(int from, int to);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.presentations.util.AbstractTabFolder#layout(boolean)
*/
void Layout(bool flushCache);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.presentations.util.AbstractTabFolder#getPaneMenuLocation()
*/
QPoint GetPaneMenuLocation();
/* (non-Javadoc)
* @see org.blueberry.ui.internal.presentations.util.AbstractTabFolder#setState(int)
*/
void SetState(int state);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.presentations.util.AbstractTabFolder#getClientArea()
*/
QRect GetClientArea();
/* (non-Javadoc)
* @see org.blueberry.ui.internal.presentations.util.AbstractTabFolder#getItems()
*/
std::vector<AbstractTabItem*> GetItems();
/* (non-Javadoc)
* @see org.blueberry.ui.internal.presentations.util.AbstractTabFolder#setSelection(org.blueberry.ui.internal.presentations.util.Widget)
*/
void SetSelection(AbstractTabItem* toSelect);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.presentations.util.AbstractTabFolder#setSelectedInfo(org.blueberry.ui.internal.presentations.util.PartInfo)
*/
void SetSelectedInfo(const PartInfo& info);
// /* (non-Javadoc)
// * @see org.blueberry.ui.internal.presentations.util.AbstractTabFolder#getToolbarParent()
// */
// Composite getToolbarParent() {
// return viewForm;
// }
/* (non-Javadoc)
* @see org.blueberry.ui.internal.presentations.util.AbstractTabFolder#getTabArea()
*/
QRect GetTabArea();
// /* (non-Javadoc)
// * @see org.blueberry.ui.internal.presentations.util.AbstractTabFolder#setToolbar(org.blueberry.swt.widgets.Control)
// */
// void setToolbar(Control toolbarControl) {
//
// if (toolbarControl != null) {
// topCenterCache.setControl(toolbarControl);
// topCenter.setTarget(topCenterCache);
// viewForm.setTopCenter(topCenter.getControl());
// } else {
// topCenterCache.setControl(null);
// topCenter.setTarget(null);
// viewForm.setTopCenter(null);
// }
//
// super.setToolbar(toolbarControl);
// }
QWidget* GetControl();
/* (non-Javadoc)
* @see org.blueberry.ui.internal.presentations.util.AbstractTabFolder#isOnBorder(org.blueberry.swt.graphics.Point)
*/
bool IsOnBorder(const QPoint& globalPos);
AbstractTabItem* GetSelection();
/* (non-Javadoc)
* @see org.blueberry.ui.internal.presentations.util.AbstractTabFolder#getContentParent()
*/
QWidget* GetContentParent();
/* (non-Javadoc)
* @see org.blueberry.ui.internal.presentations.util.AbstractTabFolder#setContent(org.blueberry.swt.widgets.Control)
*/
void SetContent(QWidget* newContent);
/**
* @return
* @since 3.1
*/
QCTabBar* GetTabFolder();
/**
* @param item
* @param newTitle
* @since 3.1
*/
/* protected */void SetSelectedTitle(const QString& newTitle);
/**
* @param image
* @since 3.1
*/
/* protected */void SetSelectedImage(const QPixmap* image);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.presentations.util.AbstractTabFolder#getItem(org.blueberry.swt.graphics.Point)
*/
AbstractTabItem* GetItem(const QPoint& toFind);
/**
* @param enabled
* @since 3.1
*/
void EnablePaneMenu(bool enabled);
};
}
#endif /* BERRYNATIVETABFOLDER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/defaultpresentation/berryNativeTabItem.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/defaultpresentation/berryNativeTabItem.cpp
index 8f07d221df..831dd87d55 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/defaultpresentation/berryNativeTabItem.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/defaultpresentation/berryNativeTabItem.cpp
@@ -1,137 +1,137 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryNativeTabItem.h"
#include "berryNativeTabFolder.h"
#include "berryQCTabBar.h"
#include <berryConstants.h>
#include <QToolButton>
namespace berry
{
NativeTabItem::NativeTabItem(NativeTabFolder* _parent, int index, int flags) :
parent(_parent), style(flags), showClose(true), closeButton(0)
{
parent->GetTabFolder()->insertTab(index, this);
#if QT_VERSION >= 0x040500
if (this->GetShowClose())
{
parent->GetTabFolder()->setTabButton(index, QTabBar::RightSide, this->GetCloseButton());
this->connect(this->GetCloseButton(), SIGNAL(clicked()), this, SLOT(CloseButtonClicked()));
}
#endif
}
void NativeTabItem::CloseButtonClicked()
{
parent->CloseButtonClicked(this);
}
QRect NativeTabItem::GetBounds()
{
int index = parent->IndexOf(this);
QTabBar* folder = parent->GetTabFolder();
QRect localRect = folder->tabRect(index);
QPoint topLeft = localRect.topLeft();
QPoint bottomRight = localRect.bottomRight();
QPoint globalTopLeft = folder->mapToGlobal(topLeft);
QPoint globalBottomRight = folder->mapToGlobal(bottomRight);
return QRect(globalTopLeft, globalBottomRight);
}
void NativeTabItem::SetInfo(const PartInfo& info)
{
QTabBar* widget = parent->GetTabFolder();
int index = parent->IndexOf(this);
if (widget->tabText(index) != info.name)
{
widget->setTabText(index, info.name);
}
if (widget->tabToolTip(index) != info.toolTip)
{
widget->setTabToolTip(index, info.toolTip);
}
if (info.image == 0)
{
widget->setTabIcon(index, QIcon());
}
else
{
QIcon icon(*(info.image));
if (widget->tabIcon(index).cacheKey() != icon.cacheKey())
{
widget->setTabIcon(index, icon);
}
}
}
bool NativeTabItem::GetShowClose() const
{
return ((style & Constants::CLOSE) && showClose);
}
void NativeTabItem::SetShowClose(bool close)
{
showClose = close;
}
QWidget* NativeTabItem::GetCloseButton()
{
if (!closeButton)
{
QIcon iconCloseTab( ":/org.blueberry.ui.qt/tab_close_icon.png" );
iconCloseTab.addFile(":/org.blueberry.ui.qt/tab_close_icon-active.png", QSize(), QIcon::Active);
closeButton = new QToolButton(parent->GetControl());
closeButton->setObjectName("TabCloseButton");
closeButton->setContentsMargins(0, 0, 0, 0);
closeButton->setFixedSize(12,12);
//closeButton->setFlat(true);
closeButton->setIcon(iconCloseTab);
closeButton->setAutoRaise(true);
}
return closeButton;
}
void NativeTabItem::Dispose()
{
QTabBar* widget = parent->GetTabFolder();
int index = parent->IndexOf(this);
widget->removeTab(index); // this calls QCTabBar::tabRemoved
}
Object::Pointer NativeTabItem::GetData()
{
return data;
}
void NativeTabItem::SetData(Object::Pointer d)
{
this->data = d;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/defaultpresentation/berryNativeTabItem.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/defaultpresentation/berryNativeTabItem.h
index 1430ef88c5..c8f344f9b0 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/defaultpresentation/berryNativeTabItem.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/defaultpresentation/berryNativeTabItem.h
@@ -1,82 +1,82 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYNATIVETABITEM_H_
#define BERRYNATIVETABITEM_H_
#include "internal/util/berryAbstractTabItem.h"
#include <QObject>
class QToolButton;
namespace berry
{
class NativeTabFolder;
class NativeTabItem: public QObject, public AbstractTabItem
{
Q_OBJECT
private:
Object::Pointer data;
NativeTabFolder* parent;
const int style;
bool showClose;
QToolButton* closeButton;
private slots:
void CloseButtonClicked();
public:
NativeTabItem(NativeTabFolder* parent, int index, int style);
/* (non-Javadoc)
* @see AbstractTabItem#getBounds()
*/
QRect GetBounds();
void SetInfo(const PartInfo& info);
bool GetShowClose() const;
void SetShowClose(bool close);
QWidget* GetCloseButton();
void Dispose();
/* (non-Javadoc)
* @see AbstractTabItem#getData()
*/
Object::Pointer GetData();
/* (non-Javadoc)
* @see AbstractTabItem#setData(java.lang.Object)
*/
void SetData(Object::Pointer d);
};
}
#endif /* BERRYNATIVETABITEM_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/defaultpresentation/berryQCTabBar.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/defaultpresentation/berryQCTabBar.cpp
index 4eb80bafde..0550b5d27d 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/defaultpresentation/berryQCTabBar.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/defaultpresentation/berryQCTabBar.cpp
@@ -1,129 +1,129 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryQCTabBar.h"
#include <QApplication>
#include <QMouseEvent>
#include <algorithm>
namespace berry
{
QCTabBar::QCTabBar(QWidget* parent) :
QTabBar(parent)
{
}
QCTabBar::~QCTabBar()
{
for (std::deque<AbstractTabItem*>::iterator iter = tabItemList.begin();
iter != tabItemList.end(); ++iter)
{
delete *iter;
}
}
void QCTabBar::tabRemoved(int index)
{
std::deque<AbstractTabItem*>::iterator iter = tabItemList.begin();
std::advance(iter, index);
if (iter != tabItemList.end())
{
AbstractTabItem* item = *iter;
tabItemList.erase(iter);
delete item;
}
}
void QCTabBar::mousePressEvent(QMouseEvent* event)
{
if (event->button() == Qt::LeftButton)
dragStartPosition = event->globalPos();
QTabBar::mousePressEvent(event);
}
void QCTabBar::mouseMoveEvent(QMouseEvent* event)
{
if (!(event->buttons() & Qt::LeftButton))
{
QTabBar::mouseMoveEvent(event);
return;
}
if ((event->globalPos() - dragStartPosition).manhattanLength()
< QApplication::startDragDistance())
{
QTabBar::mouseMoveEvent(event);
return;
}
emit dragStarted(dragStartPosition);
}
AbstractTabItem* QCTabBar::getTab(int index) const
{
if (index < 0 || ((unsigned int) index) >= tabItemList.size()) return 0;
return tabItemList[index];
}
std::vector<AbstractTabItem*> QCTabBar::getTabs() const
{
return std::vector<AbstractTabItem*>(tabItemList.begin(), tabItemList.end());
}
void QCTabBar::insertTab(int index, AbstractTabItem* item)
{
std::deque<AbstractTabItem*>::iterator iter = tabItemList.begin();
std::advance(iter, index);
tabItemList.insert(iter, item);
QTabBar::insertTab(index, QString());
}
void QCTabBar::moveAbstractTab(int from, int to)
{
AbstractTabItem* item = tabItemList[from];
if ((unsigned int)to >= tabItemList.size()) --to;
std::deque<AbstractTabItem*>::iterator fromIter = tabItemList.begin();
std::advance(fromIter, from);
tabItemList.erase(fromIter);
std::deque<AbstractTabItem*>::iterator toIter = tabItemList.begin();
std::advance(toIter, to);
tabItemList.insert(toIter, item);
this->moveTab(from, to);
}
void QCTabBar::setCurrentTab(AbstractTabItem* item)
{
std::deque<AbstractTabItem*>::iterator iter = std::find(tabItemList.begin(), tabItemList.end(), item);
int index = iter - tabItemList.begin();
this->setCurrentIndex(index);
}
AbstractTabItem* QCTabBar::getCurrentTab()
{
int index = this->currentIndex();
return tabItemList[index];
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/defaultpresentation/berryQCTabBar.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/defaultpresentation/berryQCTabBar.h
index 733c35d715..90461836fe 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/defaultpresentation/berryQCTabBar.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/defaultpresentation/berryQCTabBar.h
@@ -1,72 +1,72 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYQCTABBAR_H_
#define BERRYQCTABBAR_H_
#include <QTabBar>
#include <deque>
#include "internal/util/berryAbstractTabItem.h"
namespace berry {
class QCTabBar : public QTabBar
{
Q_OBJECT
private:
// maps the index in the tabbar to the AbstractTabItem
std::deque<AbstractTabItem*> tabItemList;
QPoint dragStartPosition;
protected:
void tabRemoved(int index);
void mousePressEvent(QMouseEvent* event);
void mouseMoveEvent(QMouseEvent* event);
public:
QCTabBar(QWidget* parent = 0);
~QCTabBar();
AbstractTabItem* getTab(int index) const;
std::vector<AbstractTabItem*> getTabs() const;
/**
* Inserts a new tab at the specified index. The TabBar takes
* ownership of the AbstractTabItem.
*/
void insertTab(int index, AbstractTabItem* item);
void moveAbstractTab(int from, int to);
void setCurrentTab(AbstractTabItem* item);
AbstractTabItem* getCurrentTab();
signals:
void dragStarted(const QPoint& location);
};
}
#endif /* BERRYQCTABBAR_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/defaultpresentation/berryQtWorkbenchPresentationFactory.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/defaultpresentation/berryQtWorkbenchPresentationFactory.cpp
index bf158b3c48..152446aeb6 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/defaultpresentation/berryQtWorkbenchPresentationFactory.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/defaultpresentation/berryQtWorkbenchPresentationFactory.cpp
@@ -1,167 +1,167 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryQtWorkbenchPresentationFactory.h"
#include "berryNativeTabFolder.h"
#include "berryEmptyTabFolder.h"
#include "internal/util/berryPresentablePartFolder.h"
#include "internal/util/berryTabbedStackPresentation.h"
#include "internal/berryQtSash.h"
#include <internal/berryQtControlWidget.h>
#include <QApplication>
namespace berry
{
QtWorkbenchPresentationFactory::QtWorkbenchPresentationFactory()
{}
QtWorkbenchPresentationFactory::QtWorkbenchPresentationFactory(
const QtWorkbenchPresentationFactory& other)
{
}
StackPresentation::Pointer QtWorkbenchPresentationFactory::CreateEditorPresentation(
void* parent, IStackPresentationSite::Pointer site)
{
NativeTabFolder* folder = new NativeTabFolder(static_cast<QWidget*> (parent));
// /*
// * Set the minimum characters to display, if the preference is something
// * other than the default. This is mainly intended for RCP applications
// * or for expert users (i.e., via the plug-in customization file).
// *
// * Bug 32789.
// */
// final IPreferenceStore store = PlatformUI.getPreferenceStore();
// if (store
// .contains(IWorkbenchPreferenceConstants.EDITOR_MINIMUM_CHARACTERS)) {
// final int minimumCharacters = store
// .getInt(IWorkbenchPreferenceConstants.EDITOR_MINIMUM_CHARACTERS);
// if (minimumCharacters >= 0) {
// folder.setMinimumCharacters(minimumCharacters);
// }
// }
PresentablePartFolder* partFolder = new PresentablePartFolder(folder);
StackPresentation::Pointer result(new TabbedStackPresentation(site,
partFolder)); //, new StandardEditorSystemMenu(site));
// DefaultThemeListener themeListener =
// new DefaultThemeListener(folder, result.getTheme());
// result.getTheme().addListener(themeListener);
//
// new DefaultMultiTabListener(result.getApiPreferences(), IWorkbenchPreferenceConstants.SHOW_MULTIPLE_EDITOR_TABS, folder);
//
// new DefaultSimpleTabListener(result.getApiPreferences(), IWorkbenchPreferenceConstants.SHOW_TRADITIONAL_STYLE_TABS, folder);
return result;
}
StackPresentation::Pointer QtWorkbenchPresentationFactory::CreateViewPresentation(
void* parent, IStackPresentationSite::Pointer site)
{
NativeTabFolder* folder = new NativeTabFolder(static_cast<QWidget*> (parent));
// final IPreferenceStore store = PlatformUI.getPreferenceStore();
// final int minimumCharacters = store
// .getInt(IWorkbenchPreferenceConstants.VIEW_MINIMUM_CHARACTERS);
// if (minimumCharacters >= 0) {
// folder.setMinimumCharacters(minimumCharacters);
// }
PresentablePartFolder* partFolder = new PresentablePartFolder(folder);
//folder->SetUnselectedCloseVisible(false);
//folder->SetUnselectedImageVisible(true);
StackPresentation::Pointer result(new TabbedStackPresentation(site,
partFolder)); //, new StandardViewSystemMenu(site));
// DefaultThemeListener themeListener =
// new DefaultThemeListener(folder, result.getTheme());
// result.getTheme().addListener(themeListener);
//
// new DefaultSimpleTabListener(result.getApiPreferences(), IWorkbenchPreferenceConstants.SHOW_TRADITIONAL_STYLE_TABS, folder);
return result;
}
StackPresentation::Pointer QtWorkbenchPresentationFactory::CreateStandaloneViewPresentation(
void* parent, IStackPresentationSite::Pointer site, bool showTitle)
{
if (showTitle)
{
return this->CreateViewPresentation(parent, site);
}
EmptyTabFolder* folder = new EmptyTabFolder(static_cast<QWidget*> (parent),
true);
StackPresentation::Pointer presentation(new TabbedStackPresentation(site,
folder)); //, new StandardViewSystemMenu(site));
return presentation;
}
std::string QtWorkbenchPresentationFactory::GetId()
{
return "berryQtWorkbenchPresentationFactory";
}
void* QtWorkbenchPresentationFactory::CreateSash(void* parent, int style)
{
Qt::Orientation orientation =
style & SASHORIENTATION_HORIZONTAL ? Qt::Horizontal : Qt::Vertical;
QWidget* sash = new QtSash(orientation, static_cast<QWidget*> (parent));
sash->setObjectName("Sash widget");
if (orientation == Qt::Horizontal)
sash->setFixedHeight(this->GetSashSize(style));
else
sash->setFixedWidth(this->GetSashSize(style));
return sash;
}
int QtWorkbenchPresentationFactory::GetSashSize(int /*style*/)
{
return 3;
}
void QtWorkbenchPresentationFactory::UpdateTheme()
{
QWidgetList topLevels = QApplication::topLevelWidgets();
QListIterator<QWidget*> topIt(topLevels);
while (topIt.hasNext())
{
QWidget* topWidget = topIt.next();
QList<NativeTabFolder*> folders =
topWidget->findChildren<NativeTabFolder*> ();
QListIterator<NativeTabFolder*> i(folders);
while (i.hasNext())
{
i.next()->UpdateColors();
}
}
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/defaultpresentation/berryQtWorkbenchPresentationFactory.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/defaultpresentation/berryQtWorkbenchPresentationFactory.h
index 9965d18673..ffd2d697e4 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/defaultpresentation/berryQtWorkbenchPresentationFactory.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/defaultpresentation/berryQtWorkbenchPresentationFactory.h
@@ -1,87 +1,87 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYQTWORKBENCHPRESENTATIONFACTORY_H_
#define BERRYQTWORKBENCHPRESENTATIONFACTORY_H_
#include <berryIPresentationFactory.h>
namespace berry
{
/**
* The default presentation factory for the Workbench.
*
*/
class QtWorkbenchPresentationFactory: public QObject, public IPresentationFactory
{
Q_OBJECT
Q_INTERFACES(berry::IPresentationFactory)
// // don't reset these dynamically, so just keep the information static.
// // see bug:
// // 75422 [Presentations] Switching presentation to R21 switches immediately,
// // but only partially
// private static int editorTabPosition = PlatformUI.getPreferenceStore()
// .getInt(IWorkbenchPreferenceConstants.EDITOR_TAB_POSITION);
// private static int viewTabPosition = PlatformUI.getPreferenceStore()
// .getInt(IWorkbenchPreferenceConstants.VIEW_TAB_POSITION);
public:
QtWorkbenchPresentationFactory();
QtWorkbenchPresentationFactory(const QtWorkbenchPresentationFactory& other);
/*
* (non-Javadoc)
*
* @see org.blueberry.ui.presentations.AbstractPresentationFactory#createEditorPresentation(org.blueberry.swt.widgets.Composite,
* org.blueberry.ui.presentations.IStackPresentationSite)
*/
StackPresentation::Pointer CreateEditorPresentation(void* parent,
IStackPresentationSite::Pointer site);
/*
* (non-Javadoc)
*
* @see org.blueberry.ui.presentations.AbstractPresentationFactory#createViewPresentation(org.blueberry.swt.widgets.Composite,
* org.blueberry.ui.presentations.IStackPresentationSite)
*/
StackPresentation::Pointer CreateViewPresentation(void* parent,
IStackPresentationSite::Pointer site);
/*
* (non-Javadoc)
*
* @see org.blueberry.ui.presentations.AbstractPresentationFactory#createStandaloneViewPresentation(org.blueberry.swt.widgets.Composite,
* org.blueberry.ui.presentations.IStackPresentationSite, boolean)
*/
StackPresentation::Pointer CreateStandaloneViewPresentation(void* parent,
IStackPresentationSite::Pointer site, bool showTitle);
std::string GetId();
void* CreateSash(void* parent, int style);
int GetSashSize(int style);
void UpdateTheme();
};
}
#endif /* BERRYQTWORKBENCHPRESENTATIONFACTORY_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryAbstractTabFolder.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryAbstractTabFolder.cpp
index e669a998a3..09d5d75be6 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryAbstractTabFolder.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryAbstractTabFolder.cpp
@@ -1,234 +1,234 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryAbstractTabFolder.h"
#include "berryAbstractTabItem.h"
#include <berryConstants.h>
#include <berryIStackPresentationSite.h>
#include <QWidget>
namespace berry
{
AbstractTabFolder::AbstractTabFolder() :
activeState(IStackPresentationSite::STATE_RESTORED)
{
}
AbstractTabFolder::~AbstractTabFolder()
{
}
void AbstractTabFolder::SetActive(int activeState)
{
this->activeState = activeState;
}
int AbstractTabFolder::GetActive()
{
return activeState;
}
QPoint AbstractTabFolder::GetPaneMenuLocation()
{
return this->GetControl()->mapToGlobal(QPoint(0, 0));
}
QPoint AbstractTabFolder::GetPartListLocation()
{
return this->GetSystemMenuLocation();
}
QPoint AbstractTabFolder::GetSystemMenuLocation()
{
return this->GetControl()->mapToGlobal(QPoint(0, 0));
}
AbstractTabItem* AbstractTabFolder::GetItem(int idx)
{
return this->GetItems()[idx];
}
AbstractTabItem* AbstractTabFolder::GetItem(const QPoint& toFind)
{
std::vector<AbstractTabItem*> items = this->GetItems();
for (unsigned int i = 0; i < items.size(); i++)
{
AbstractTabItem* item = items[i];
if (item->GetBounds().contains(toFind))
{
return item;
}
}
return 0;
}
AbstractTabItem* AbstractTabFolder::FindItem(Object::Pointer dataToFind)
{
std::vector<AbstractTabItem*> items = this->GetItems();
for (unsigned int i = 0; i < items.size(); i++)
{
AbstractTabItem* item = items[i];
if (item->GetData() == dataToFind)
{
return item;
}
}
return 0;
}
int AbstractTabFolder::IndexOf(AbstractTabItem* item)
{
std::vector<AbstractTabItem*> items = this->GetItems();
for (unsigned int idx = 0; idx < items.size(); ++idx)
{
AbstractTabItem* next = items[idx];
if (next == item)
{
return idx;
}
}
return -1;
}
std::size_t AbstractTabFolder::GetItemCount()
{
return this->GetItems().size();
}
void AbstractTabFolder::SetState(int state)
{
this->state = state;
}
void AbstractTabFolder::ShellActive(bool /*isActive*/)
{
}
void AbstractTabFolder::Layout(bool /*flushCache*/)
{
}
void AbstractTabFolder::SetTabPosition(int /*tabPosition*/)
{
}
int AbstractTabFolder::GetTabPosition()
{
return Constants::TOP;
}
int AbstractTabFolder::GetState()
{
return state;
}
bool AbstractTabFolder::IsOnBorder(const QPoint& /*toTest*/)
{
return false;
}
void AbstractTabFolder::SetVisible(bool visible)
{
this->GetControl()->setVisible(visible);
}
void AbstractTabFolder::ShowMinMax(bool /*show*/)
{
}
void AbstractTabFolder::FireEvent(TabFolderEvent::Pointer e)
{
tabFolderEvent(e);
}
void AbstractTabFolder::FireEvent(int id)
{
TabFolderEvent::Pointer event(new TabFolderEvent(id));
this->FireEvent(event);
}
void AbstractTabFolder::FireEvent(int id, AbstractTabItem* w)
{
TabFolderEvent::Pointer event(new TabFolderEvent(id, w, 0, 0));
this->FireEvent(event);
}
void AbstractTabFolder::FireEvent(int id, AbstractTabItem* w, const QPoint& pos)
{
TabFolderEvent::Pointer event(new TabFolderEvent(id, w, pos));
this->FireEvent(event);
}
void AbstractTabFolder::HandleContextMenu(const QPoint& displayPos)
{
if (this->IsOnBorder(displayPos))
{
return;
}
AbstractTabItem* tab = this->GetItem(displayPos);
this->FireEvent(TabFolderEvent::EVENT_SYSTEM_MENU, tab, displayPos);
}
void AbstractTabFolder::HandleMousePress(const QPoint& /*displayPos*/)
{
this->FireEvent(TabFolderEvent::EVENT_GIVE_FOCUS_TO_PART);
}
void AbstractTabFolder::HandleDoubleClick(const QPoint& displayPos)
{
if (this->IsOnBorder(displayPos))
{
return;
}
if (this->GetState() == IStackPresentationSite::STATE_MAXIMIZED)
{
this->FireEvent(TabFolderEvent::EVENT_RESTORE);
}
else
{
this->FireEvent(TabFolderEvent::EVENT_MAXIMIZE);
}
}
void AbstractTabFolder::HandleDragStarted(const QPoint& displayPos)
{
if (this->IsOnBorder(displayPos))
{
return;
}
AbstractTabItem* tab = this->GetItem(displayPos);
this->FireEvent(TabFolderEvent::EVENT_DRAG_START, tab, displayPos);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryAbstractTabFolder.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryAbstractTabFolder.h
index 94576f991b..0a4c14ec9f 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryAbstractTabFolder.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryAbstractTabFolder.h
@@ -1,265 +1,265 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYABSTRACTTABFOLDER_H_
#define BERRYABSTRACTTABFOLDER_H_
#include <berryMessage.h>
#include <QRect>
#include "berryPartInfo.h"
#include "berryTabFolderEvent.h"
class QWidget;
namespace berry
{
class AbstractTabFolder
{
public:
Message1<TabFolderEvent::Pointer> tabFolderEvent;
private:
// Control toolbar;
int state;
int activeState;
// Listener menuListener = new Listener() {
// /* (non-Javadoc)
// * @see org.blueberry.swt.widgets.Listener#handleEvent(org.blueberry.swt.widgets.Event)
// */
// public void handleEvent(Event event) {
// Point globalPos = new Point(event.x, event.y);
// handleContextMenu(globalPos, event);
// }
// };
// Listener dragListener = new Listener() {
// public void handleEvent(Event e) {
// Point globalPos = ((Control)e.widget).toDisplay(e.x, e.y);
// handleDragStarted(globalPos, e);
// }
// };
// MouseListener mouseListener = new MouseAdapter() {
//
// // If we single-click on an empty space on the toolbar, move focus to the
// // active control
// public void mouseDown(MouseEvent e) {
// Point p = ((Control)e.widget).toDisplay(e.x, e.y);
//
// handleMouseDown(p, e);
// }
//
//
// // If we double-click on the toolbar, maximize the presentation
// public void mouseDoubleClick(MouseEvent e) {
// Point p = ((Control)e.widget).toDisplay(e.x, e.y);
//
// handleDoubleClick(p, e);
// }
// };
public:
AbstractTabFolder();
virtual ~AbstractTabFolder();
virtual QSize ComputeSize(int widthHint, int heightHint) = 0;
virtual AbstractTabItem* Add(int index, int flags) = 0;
virtual void Move(int from, int to) = 0;
virtual QWidget* GetContentParent() = 0;
virtual void SetContent(QWidget* newContent) = 0;
virtual std::vector<AbstractTabItem*> GetItems() = 0;
virtual AbstractTabItem* GetSelection() = 0;
virtual void SetSelection(AbstractTabItem* toSelect) = 0;
virtual void SetSelectedInfo(const PartInfo& info) = 0;
virtual void EnablePaneMenu(bool enabled) = 0;
virtual void SetActive(int activeState);
virtual int GetActive();
/**
* Returns the location where the pane menu should be opened when activated
* by a keyboard shortcut (display coordinates)
*
* @return the location for the pane menu (display coordinates)
* @since 3.1
*/
virtual QPoint GetPaneMenuLocation();
/**
* Returns the location where the part list should be opened when activated
* by a keyboard shortcut (display coordinates)
*
* @return the location for the part list (display coordinates)
* @since 3.1
*/
virtual QPoint GetPartListLocation();
/**
* Returns the location where the pane menu should be opened when activated
* by a keyboard shortcut (display coordinates)
*
* @return the location for the pane menu (display coordinates)
* @since 3.1
*/
virtual QPoint GetSystemMenuLocation();
// /**
// * Returns the parent composite that should be used for creating the toolbar.
// * Any control passed into setToolbar must have this composite as its parent.
// *
// * @return the parent composite that should be used for creating the toolbar
// *
// * @since 3.1
// */
// virtual QWidget* GetToolbarParent() = 0;
/**
* Returns the main control for this folder.
*
* @return the main control for the folder
* @since 3.1
*/
virtual QWidget* GetControl() = 0;
virtual AbstractTabItem* GetItem(int idx);
virtual AbstractTabItem* GetItem(const QPoint& toFind);
virtual AbstractTabItem* FindItem(Object::Pointer dataToFind);
/**
* Returns the index of the given item, or -1 if the given item is
* not found in this tab folder. Subclasses should override this if
* the underlying SWT widget has an equivalent method
*
* @param item item to find
* @return the index of the given item or -1
*/
virtual int IndexOf(AbstractTabItem* item);
virtual std::size_t GetItemCount();
/**
* Sets the current state for the folder
*
* @param state one of the IStackPresentationSite.STATE_* constants
*/
virtual void SetState(int state);
/**
* Returns the title area for this control (in the control's coordinate system)
*
* @return
*/
virtual QRect GetTabArea() = 0;
/**
* Called when the tab folder's shell becomes active or inactive. Subclasses
* can override this to change the appearance of the tabs based on activation.
*
* @param isActive
*/
virtual void ShellActive(bool isActive);
virtual void Layout(bool flushCache);
virtual void SetTabPosition(int tabPosition);
virtual int GetTabPosition();
virtual int GetState();
/**
* Returns true iff the given point is on the border of the folder.
* By default, double-clicking, context menus, and drag/drop are disabled
* on the folder's border.
*
* @param toTest a point (display coordinates)
* @return true iff the point is on the presentation border
* @since 3.1
*/
virtual bool IsOnBorder(const QPoint& toTest);
/**
* Set the folder to visible. This can be extended to propogate the
* visibility request to other components in the subclass.
*
* @param visible
* <code>true</code> - the folder is visible.
* @since 3.2
*/
virtual void SetVisible(bool visible);
/**
* Cause the folder to hide or show its
* Minimize and Maximize affordances.
*
* @param show
* <code>true</code> - the min/max buttons are visible.
* @since 3.3
*/
virtual void ShowMinMax(bool show);
protected:
friend class PresentablePartFolder;
void FireEvent(TabFolderEvent::Pointer e);
void FireEvent(int id);
void FireEvent(int id, AbstractTabItem* w);
void FireEvent(int id, AbstractTabItem* w, const QPoint& pos);
// void attachSlots(QWidget* theControl) {
// theControl.addListener(SWT.MenuDetect, menuListener);
// theControl.addMouseListener(mouseListener);
//
// //TODO DnD
// //PresentationUtil.addDragListener(theControl, dragListener);
//
// }
void HandleContextMenu(const QPoint& displayPos);
void HandleMousePress(const QPoint& displayPos);
void HandleDoubleClick(const QPoint& displayPos);
void HandleDragStarted(const QPoint& displayPos);
};
}
#endif /* BERRYABSTRACTTABFOLDER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryAbstractTabItem.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryAbstractTabItem.h
index 5b8334d69e..9d442a3390 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryAbstractTabItem.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryAbstractTabItem.h
@@ -1,51 +1,51 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYABSTRACTTABITEM_H_
#define BERRYABSTRACTTABITEM_H_
#include <QRect>
#include <berryObject.h>
#include "berryPartInfo.h"
#include <org_blueberry_ui_qt_Export.h>
namespace berry {
struct BERRY_UI_QT AbstractTabItem {
virtual ~AbstractTabItem();
virtual QRect GetBounds() = 0;
virtual void SetInfo(const PartInfo& info) = 0;
virtual void Dispose() = 0;
virtual void SetBusy(bool /*busy*/) {}
virtual void SetBold(bool /*bold*/) {}
virtual Object::Pointer GetData() = 0;
virtual void SetData(Object::Pointer data) = 0;
virtual bool IsShowing() { return true; }
};
}
#endif /* BERRYABSTRACTTABITEM_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryIPresentablePartList.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryIPresentablePartList.h
index febafe3c90..b8a7744d36 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryIPresentablePartList.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryIPresentablePartList.h
@@ -1,48 +1,48 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIPRESENTABLEPARTLIST_H_
#define BERRYIPRESENTABLEPARTLIST_H_
#include <berryIPresentablePart.h>
#include <vector>
#include <org_blueberry_ui_qt_Export.h>
namespace berry
{
struct BERRY_UI_QT IPresentablePartList
{
virtual ~IPresentablePartList();
virtual void Insert(IPresentablePart::Pointer part, int idx) = 0;
virtual void Remove(IPresentablePart::Pointer part) = 0;
virtual void Move(IPresentablePart::Pointer part, int newIndex) = 0;
virtual std::size_t Size() = 0;
virtual void Select(IPresentablePart::Pointer part) = 0;
virtual std::vector<IPresentablePart::Pointer> GetPartList() = 0;
};
}
#endif /* BERRYIPRESENTABLEPARTLIST_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryLeftToRightTabOrder.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryLeftToRightTabOrder.cpp
index 6f6410889d..1a8f79f8f6 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryLeftToRightTabOrder.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryLeftToRightTabOrder.cpp
@@ -1,101 +1,101 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryLeftToRightTabOrder.h"
#include <internal/berryWorkbenchConstants.h>
namespace berry
{
LeftToRightTabOrder::LeftToRightTabOrder(IPresentablePartList* _list) :
list(_list)
{
}
void LeftToRightTabOrder::Add(IPresentablePart::Pointer newPart)
{
list->Insert(newPart, static_cast<int>(list->Size()));
}
void LeftToRightTabOrder::AddInitial(IPresentablePart::Pointer newPart)
{
this->Add(newPart);
}
void LeftToRightTabOrder::Insert(IPresentablePart::Pointer newPart, int index)
{
list->Insert(newPart, index);
}
void LeftToRightTabOrder::Remove(IPresentablePart::Pointer removed)
{
list->Remove(removed);
}
void LeftToRightTabOrder::Select(IPresentablePart::Pointer selected)
{
list->Select(selected);
}
void LeftToRightTabOrder::Move(IPresentablePart::Pointer toMove, int newIndex)
{
list->Move(toMove, newIndex);
}
std::vector<IPresentablePart::Pointer> LeftToRightTabOrder::GetPartList()
{
return list->GetPartList();
}
void LeftToRightTabOrder::RestoreState(IPresentationSerializer* serializer,
IMemento::Pointer savedState)
{
std::vector<IMemento::Pointer> parts = savedState->GetChildren(
WorkbenchConstants::TAG_PART);
for (std::size_t idx = 0; idx < parts.size(); idx++)
{
std::string id;
parts[idx]->GetString(WorkbenchConstants::TAG_ID, id);
if (!id.empty())
{
IPresentablePart::Pointer part = serializer->GetPart(id);
if (part)
{
this->AddInitial(part);
}
}
}
}
void LeftToRightTabOrder::SaveState(IPresentationSerializer* context,
IMemento::Pointer memento)
{
std::vector<IPresentablePart::Pointer> parts(list->GetPartList());
for (std::vector<IPresentablePart::Pointer>::iterator iter = parts.begin();
iter != parts.end(); ++iter)
{
IMemento::Pointer childMem = memento->CreateChild(WorkbenchConstants::TAG_PART);
childMem->PutString(WorkbenchConstants::TAG_ID, context->GetId(*iter));
}
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryLeftToRightTabOrder.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryLeftToRightTabOrder.h
index 0fb14ef624..8aee182fe2 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryLeftToRightTabOrder.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryLeftToRightTabOrder.h
@@ -1,90 +1,90 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYLEFTTORIGHTTABORDER_H_
#define BERRYLEFTTORIGHTTABORDER_H_
#include "berryTabOrder.h"
#include "berryIPresentablePartList.h"
namespace berry {
class LeftToRightTabOrder : public TabOrder {
private:
IPresentablePartList* list;
public:
LeftToRightTabOrder(IPresentablePartList* list);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.presentations.util.TabOrder#add(org.blueberry.ui.presentations.IPresentablePart)
*/
void Add(IPresentablePart::Pointer newPart);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.presentations.util.TabOrder#addInitial(org.blueberry.ui.presentations.IPresentablePart)
*/
void AddInitial(IPresentablePart::Pointer newPart);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.presentations.util.TabOrder#insert(org.blueberry.ui.presentations.IPresentablePart, int)
*/
void Insert(IPresentablePart::Pointer newPart, int index);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.presentations.util.TabOrder#remove(org.blueberry.ui.presentations.IPresentablePart)
*/
void Remove(IPresentablePart::Pointer removed);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.presentations.util.TabOrder#select(org.blueberry.ui.presentations.IPresentablePart)
*/
void Select(IPresentablePart::Pointer selected);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.presentations.util.TabOrder#move(org.blueberry.ui.presentations.IPresentablePart, int)
*/
void Move(IPresentablePart::Pointer toMove, int newIndex);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.presentations.util.TabOrder#getPartList()
*/
std::vector<IPresentablePart::Pointer> GetPartList();
/**
* Restores a presentation from a previously stored state
*
* @param serializer (not null)
* @param savedState (not null)
*/
void RestoreState(IPresentationSerializer* serializer,
IMemento::Pointer savedState);
/* (non-Javadoc)
* @see org.blueberry.ui.presentations.StackPresentation#saveState(org.blueberry.ui.presentations.IPresentationSerializer, org.blueberry.ui.IMemento)
*/
void SaveState(IPresentationSerializer* context, IMemento::Pointer memento);
};
}
#endif /* BERRYLEFTTORIGHTTABORDER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryPartInfo.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryPartInfo.cpp
index 79215de27d..000260b3f0 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryPartInfo.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryPartInfo.cpp
@@ -1,43 +1,43 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryPartInfo.h"
namespace berry
{
PartInfo::PartInfo() :
image(0)
{
}
PartInfo::PartInfo(IPresentablePart::Pointer part)
{
this->Set(part);
}
void PartInfo::Set(IPresentablePart::Pointer part)
{
name = part->GetName().c_str();
title = part->GetTitle().c_str();
contentDescription = part->GetTitleStatus().c_str();
image = static_cast<QIcon*> (part->GetTitleImage());
toolTip = part->GetTitleToolTip().c_str();
dirty = part->IsDirty();
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryPartInfo.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryPartInfo.h
index b4a949bd38..e233727f5e 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryPartInfo.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryPartInfo.h
@@ -1,44 +1,44 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYPARTINFO_H_
#define BERRYPARTINFO_H_
#include <QIcon>
#include <berryIPresentablePart.h>
namespace berry {
struct PartInfo {
QString name;
QString title;
QString contentDescription;
QString toolTip;
QIcon* image;
bool dirty;
PartInfo();
PartInfo(IPresentablePart::Pointer part);
void Set(IPresentablePart::Pointer part);
};
}
#endif /* BERRYPARTINFO_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryPresentablePartFolder.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryPresentablePartFolder.cpp
index 46ba2bc7cf..5d77c09188 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryPresentablePartFolder.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryPresentablePartFolder.cpp
@@ -1,435 +1,435 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryPresentablePartFolder.h"
#include "berryAbstractTabItem.h"
#include "internal/berryQtWidgetsTweaklet.h"
#include <internal/berryQtControlWidget.h>
#include <berryConstants.h>
#include <internal/berryDragUtil.h>
namespace berry
{
PresentablePartFolder::ContentProxyListener::ContentProxyListener(
PresentablePartFolder* folder) :
folder(folder)
{
}
GuiTk::IControlListener::Events::Types PresentablePartFolder::ContentProxyListener::GetEventTypes() const
{
return Events::MOVED & Events::RESIZED;
}
void PresentablePartFolder::ContentProxyListener::ControlMoved(
GuiTk::ControlEvent::Pointer /*e*/)
{
folder->LayoutContent();
}
void PresentablePartFolder::ContentProxyListener::ControlResized(
GuiTk::ControlEvent::Pointer /*e*/)
{
}
PresentablePartFolder::ShellListener::ShellListener(AbstractTabFolder* _folder) :
folder(_folder)
{
}
void PresentablePartFolder::ShellListener::ShellActivated(ShellEvent::Pointer /*e*/)
{
folder->ShellActive(true);
}
void PresentablePartFolder::ShellListener::ShellDeactivated(
ShellEvent::Pointer /*e*/)
{
folder->ShellActive(false);
}
PresentablePartFolder::ChildPropertyChangeListener::ChildPropertyChangeListener(
PresentablePartFolder* folder) :
presentablePartFolder(folder)
{
}
void PresentablePartFolder::ChildPropertyChangeListener::PropertyChange(
Object::Pointer source, int property)
{
if (source.Cast<IPresentablePart> () != 0)
{
IPresentablePart::Pointer part = source.Cast<IPresentablePart> ();
presentablePartFolder->ChildPropertyChanged(part, property);
}
}
PartInfo PresentablePartFolder::tempPartInfo = PartInfo();
void PresentablePartFolder::LayoutContent()
{
if (current != 0)
{
Rectangle clientArea = DragUtil::GetDisplayBounds(contentProxy);
Rectangle bounds = Tweaklets::Get(GuiWidgetsTweaklet::KEY)->ToControl(
folder->GetControl()->parentWidget(), clientArea);
current->SetBounds(bounds);
}
}
void PresentablePartFolder::InternalRemove(IPresentablePart::Pointer toRemove)
{
AbstractTabItem* item = this->GetTab(toRemove);
if (item != 0) {
item->Dispose();
}
// do not use item anymore!
if (std::find(partList.begin(), partList.end(), toRemove) != partList.end())
{
toRemove->RemovePropertyListener(childPropertyChangeListener);
partList.remove(toRemove);
}
}
void PresentablePartFolder::ChildPropertyChanged(
IPresentablePart::Pointer part, int property)
{
AbstractTabItem* tab = this->GetTab(part);
if (property == IPresentablePart::PROP_HIGHLIGHT_IF_BACK)
{
if (tab != 0 && this->GetCurrent() != part)
{//Set bold if it doesn't currently have focus
tab->SetBold(true);
this->InitTab(tab, part);
}
}
// else if (property == IPresentablePart::PROP_TOOLBAR)
// {
// if (tab != 0 && this->GetCurrent() == part)
// {
// folder->FlushToolbarSize();
// }
// if (tab != 0)
// {
// this->InitTab(tab, part);
// if (this->GetCurrent() == part)
// {
// this->Layout(true);
// }
// }
else if (property == IPresentablePart::PROP_CONTENT_DESCRIPTION || property
== IPresentablePart::PROP_PANE_MENU || property
== IPresentablePart::PROP_TITLE)
{
if (tab != 0)
{
this->InitTab(tab, part);
if (this->GetCurrent() == part)
{
this->Layout(true);
}
}
}
else if (property == IPresentablePart::PROP_PREFERRED_SIZE)
{
TabFolderEvent::Pointer event(
new TabFolderEvent(TabFolderEvent::EVENT_PREFERRED_SIZE, tab, 0, 0));
folder->FireEvent(event);
}
else
{
if (tab != 0)
this->InitTab(tab, part);
}
}
PresentablePartFolder::~PresentablePartFolder()
{
Tweaklets::Get(QtWidgetsTweaklet::KEY)->GetShell(folder->GetControl())->RemoveShellListener(
shellListener);
for (std::list<IPresentablePart::Pointer>::iterator iter = partList.begin(); iter
!= partList.end(); ++iter)
{
(*iter)->RemovePropertyListener(childPropertyChangeListener);
}
for (QWidget* currentWidget = contentProxy; currentWidget != 0 && currentWidget
!= folder->GetControl()->parentWidget(); currentWidget = currentWidget->parentWidget())
{
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->RemoveControlListener(currentWidget, contentListener);
}
BERRY_DEBUG << "DELETING PresentablePartFolder and contentProxy\n";
delete folder;
}
void PresentablePartFolder::InitTab(AbstractTabItem* item,
IPresentablePart::Pointer part)
{
tempPartInfo.Set(part);
item->SetInfo(tempPartInfo);
item->SetBusy(part->IsBusy());
if (part == this->GetCurrent())
{
folder->SetSelectedInfo(tempPartInfo);
//TODO Pane menu
//folder->EnablePaneMenu(part->GetMenu() != 0);
//setToolbar(part.getToolBar());
}
}
PresentablePartFolder::PresentablePartFolder(AbstractTabFolder* _folder) :
folder(_folder), isVisible(true), shellListener(new ShellListener(folder)),
childPropertyChangeListener(new ChildPropertyChangeListener(this))
{
Shell::Pointer controlShell =
Tweaklets::Get(QtWidgetsTweaklet::KEY)->GetShell(folder->GetControl());
controlShell->AddShellListener(shellListener);
folder->ShellActive(Tweaklets::Get(QtWidgetsTweaklet::KEY)->GetActiveShell()
== controlShell);
//folder.getControl().addDisposeListener(tabDisposeListener);
//toolbarProxy = new ProxyControl(folder.getToolbarParent());
// NOTE: if the shape of contentProxy changes, the fix for bug 85899 in EmptyTabFolder.computeSize may need adjustment.
contentListener = new ContentProxyListener(this);
contentProxy = new QtControlWidget(folder->GetContentParent(), 0);
contentProxy->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
//contentProxy->setVisible(false);
for (QWidget* currentWidget = contentProxy; currentWidget != 0 && currentWidget
!= folder->GetControl()->parentWidget(); currentWidget = currentWidget->parentWidget())
{
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->AddControlListener(currentWidget, contentListener);
}
folder->SetContent(contentProxy);
}
std::vector<IPresentablePart::Pointer> PresentablePartFolder::GetPartList()
{
std::vector<AbstractTabItem*> items = folder->GetItems();
std::vector<IPresentablePart::Pointer> result;
for (unsigned int i = 0; i < items.size(); i++)
{
result.push_back(this->GetPartForTab(items[i]));
}
return result;
}
void PresentablePartFolder::Insert(IPresentablePart::Pointer part, int idx)
{
poco_assert(folder->GetControl() != 0);
if (this->GetTab(part) != 0)
{
if (this->IndexOf(part) != idx)
this->Move(part, idx);
return;
}
idx = std::min<int>(idx, static_cast<int>(folder->GetItemCount()));
AbstractTabItem* item = 0;
int style = 0;
if (part->IsCloseable())
{
style |= Constants::CLOSE;
}
item = folder->Add(idx, style);
item->SetData(part);
this->InitTab(item, part);
part->AddPropertyListener(childPropertyChangeListener);
partList.push_back(part);
}
void PresentablePartFolder::Remove(IPresentablePart::Pointer toRemove)
{
if (toRemove == current)
{
this->Select(IPresentablePart::Pointer(0));
}
this->InternalRemove(toRemove);
}
void PresentablePartFolder::Move(IPresentablePart::Pointer part, int newIndex)
{
int currentIndex = this->IndexOf(part);
if (currentIndex == newIndex)
{
return;
}
folder->Move(currentIndex, newIndex);
//this->InternalRemove(part);
//this->Insert(part, newIndex);
//if (current == part)
//{
// folder->SetSelection(this->GetTab(part));
//}
}
std::size_t PresentablePartFolder::Size()
{
return folder->GetItemCount();
}
void PresentablePartFolder::SetBounds(const QRect& bounds)
{
QSize minSize = folder->ComputeSize(bounds.width(), Constants::DEFAULT);
QRect newBounds(bounds);
if (folder->GetState() == IStackPresentationSite::STATE_MINIMIZED
&& minSize.height() < bounds.height())
{
newBounds.setHeight(minSize.height());
}
// Set the tab folder's bounds
folder->GetControl()->setGeometry(newBounds);
this->Layout(false);
}
void PresentablePartFolder::Select(IPresentablePart::Pointer toSelect)
{
if (toSelect == current)
{
return;
}
if (toSelect != 0)
{
toSelect->SetVisible(true);
}
if (current != 0)
{
current->SetVisible(false);
//setToolbar(null);
}
current = toSelect;
AbstractTabItem* selectedItem = this->GetTab(toSelect);
folder->SetSelection(selectedItem);
if (selectedItem != 0)
{
// Determine if we need to un-bold this tab
selectedItem->SetBold(false);
this->InitTab(selectedItem, toSelect);
}
// else
// {
// setToolbar(null);
// }
this->Layout(true);
}
IPresentablePart::Pointer PresentablePartFolder::GetPartForTab(
AbstractTabItem* tab)
{
if (tab == 0)
{
return IPresentablePart::Pointer(0);
}
IPresentablePart::Pointer part = tab->GetData().Cast<IPresentablePart> ();
return part;
}
AbstractTabItem* PresentablePartFolder::GetTab(IPresentablePart::Pointer part)
{
return folder->FindItem(part);
}
int PresentablePartFolder::IndexOf(IPresentablePart::Pointer part)
{
AbstractTabItem* item = this->GetTab(part);
if (item == 0)
{
return -1;
}
return folder->IndexOf(item);
}
AbstractTabFolder* PresentablePartFolder::GetTabFolder()
{
return folder;
}
void PresentablePartFolder::SetVisible(bool isVisible)
{
this->isVisible = isVisible;
this->GetTabFolder()->SetVisible(isVisible);
if (isVisible)
{
this->Layout(true);
}
}
void PresentablePartFolder::Layout(bool changed)
{
if (!isVisible)
{
// Don't bother with layout if we're not visible
return;
}
// Lay out the tab folder and compute the client area
folder->Layout(changed);
//toolbarProxy.layout();
this->LayoutContent();
}
IPresentablePart::Pointer PresentablePartFolder::GetCurrent()
{
return current;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryPresentablePartFolder.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryPresentablePartFolder.h
index 56b7bfcebf..2e5c8acd91 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryPresentablePartFolder.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryPresentablePartFolder.h
@@ -1,196 +1,196 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYPRESENTABLEPARTFOLDER_H_
#define BERRYPRESENTABLEPARTFOLDER_H_
#include "berryIPresentablePartList.h"
#include "berryAbstractTabFolder.h"
#include "berryPartInfo.h"
#include <berryIShellListener.h>
#include <berryIPropertyChangeListener.h>
#include <berryGuiTkIControlListener.h>
#include <list>
namespace berry
{
class PresentablePartFolder: public IPresentablePartList
{
private:
AbstractTabFolder* folder;
IPresentablePart::Pointer current;
//private ProxyControl toolbarProxy;
QWidget* contentProxy;
static PartInfo tempPartInfo;
std::list<IPresentablePart::Pointer> partList;
bool isVisible;
/**
* Movement listener. Updates the bounds of the target to match the
* bounds of the dummy control.
*/
struct ContentProxyListener : public GuiTk::IControlListener
{
ContentProxyListener(PresentablePartFolder*);
Events::Types GetEventTypes() const;
void ControlMoved(GuiTk::ControlEvent::Pointer e);
void ControlResized(GuiTk::ControlEvent::Pointer e);
private:
PresentablePartFolder* folder;
};
GuiTk::IControlListener::Pointer contentListener;
struct ShellListener: public IShellListener
{
ShellListener(AbstractTabFolder* folder);
void ShellActivated(ShellEvent::Pointer e);
void ShellDeactivated(ShellEvent::Pointer e);
private:
AbstractTabFolder* folder;
};
IShellListener::Pointer shellListener;
/**
* Listener attached to all child parts. It responds to changes in part properties
*/
struct ChildPropertyChangeListener: public IPropertyChangeListener
{
ChildPropertyChangeListener(PresentablePartFolder* folder);
void PropertyChange(Object::Pointer source, int property);
private:
PresentablePartFolder* presentablePartFolder;
};
IPropertyChangeListener::Pointer childPropertyChangeListener;
// /**
// * Dispose listener that is attached to the main control. It triggers cleanup of
// * any listeners. This is required to prevent memory leaks.
// */
// private DisposeListener tabDisposeListener = new DisposeListener() {
// public void widgetDisposed(DisposeEvent e) {
// if (e.widget == folder.getControl()) {
// // If we're disposing the main control...
// disposed();
// }
// }
// };
void LayoutContent();
void InternalRemove(IPresentablePart::Pointer toRemove);
// void SetToolbar(Control newToolbar) {
// if (folder.getToolbar() != newToolbar) {
// folder.setToolbar(newToolbar);
// }
// }
void ChildPropertyChanged(IPresentablePart::Pointer part, int property);
protected:
void InitTab(AbstractTabItem* item, IPresentablePart::Pointer part);
public:
/**
* The PresentablePartFolder takes ownership of the AbstractTabFolder pointer.
*/
PresentablePartFolder(AbstractTabFolder* folder);
~PresentablePartFolder();
/* (non-Javadoc)
* @see org.blueberry.ui.internal.presentations.util.IPresentablePartList#getPartList()
*/
std::vector<IPresentablePart::Pointer> GetPartList();
/**
* Adds the given presentable part directly into this presentation at the
* given index. Does nothing if a tab already exists for the given part.
* This is intended to be called by TabOrder and its subclasses.
*
* @param part part to add
* @param idx index to insert at
*/
void Insert(IPresentablePart::Pointer part, int idx);
void Remove(IPresentablePart::Pointer toRemove);
/**
* Moves the given part to the given index. When this method returns,
* indexOf(part) will return newIndex.
*
* @param part
* @param newIndex
*/
void Move(IPresentablePart::Pointer part, int newIndex);
/**
* Returns the number of parts in this folder
*/
std::size_t Size();
void SetBounds(const QRect& bounds);
void Select(IPresentablePart::Pointer toSelect);
IPresentablePart::Pointer GetPartForTab(AbstractTabItem* tab);
/**
* Returns the tab for the given part, or null if there is no such tab
*
* @param part the part being searched for
* @return the tab for the given part, or null if there is no such tab
*/
AbstractTabItem* GetTab(IPresentablePart::Pointer part);
int IndexOf(IPresentablePart::Pointer part);
AbstractTabFolder* GetTabFolder();
void SetVisible(bool isVisible);
void Layout(bool changed);
IPresentablePart::Pointer GetCurrent();
};
}
#endif /* BERRYPRESENTABLEPARTFOLDER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryReplaceDragHandler.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryReplaceDragHandler.cpp
index 4a33aa732a..c8ff8c937b 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryReplaceDragHandler.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryReplaceDragHandler.cpp
@@ -1,139 +1,139 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryReplaceDragHandler.h"
#include "berryAbstractTabItem.h"
#include <berryGeometry.h>
#include <internal/berryDragUtil.h>
namespace berry
{
ReplaceDragHandler::DragCookie::DragCookie(int pos) :
insertPosition(pos)
{
}
ReplaceDragHandler::ReplaceDragHandler(AbstractTabFolder* folder) :
tabFolder(folder)
{
}
StackDropResult::Pointer ReplaceDragHandler::DragOver(QWidget*,
const Point& location, int dragStart)
{
// Determine which tab we're currently dragging over
//Point localPos = tabFolder.getControl().toControl(location);
QPoint point(location.x, location.y);
AbstractTabItem* tabUnderPointer = tabFolder->GetItem(point);
// This drop target only deals with tabs... if we're not dragging over
// a tab, exit.
if (tabUnderPointer == 0)
{
QRect titleArea = tabFolder->GetTabArea();
// If we're dragging over the title area, treat this as a drop in the last
// tab position.
if (titleArea.contains(point) && tabFolder->GetItemCount() > 0)
{
int dragOverIndex = static_cast<int>(tabFolder->GetItemCount());
AbstractTabItem* lastTab = tabFolder->GetItem(dragOverIndex - 1);
// Can't drag to end unless you can see the end
if (!lastTab->IsShowing())
{
return StackDropResult::Pointer(0);
}
// If we are unable to compute the bounds for this tab, then ignore the drop
QRect qlastTabBounds = lastTab->GetBounds();
Rectangle lastTabBounds(qlastTabBounds.x(), qlastTabBounds.y(), qlastTabBounds.width(), qlastTabBounds.height());
if (qlastTabBounds.isEmpty())
{
return StackDropResult::Pointer(0);
}
if (dragStart >= 0)
{
dragOverIndex--;
Object::Pointer cookie(new DragCookie(dragOverIndex));
StackDropResult::Pointer result(new StackDropResult(lastTabBounds, cookie));
return result;
}
// Make the drag-over rectangle look like a tab at the end of the tab region.
// We don't actually know how wide the tab will be when it's dropped, so just
// make it 3 times wider than it is tall.
Rectangle dropRectangle(titleArea.x(), titleArea.y(), titleArea.width(), titleArea.height());
dropRectangle.x = lastTabBounds.x + lastTabBounds.width;
dropRectangle.width = 3 * dropRectangle.height;
Object::Pointer cookie(new DragCookie(dragOverIndex));
StackDropResult::Pointer result(new StackDropResult(dropRectangle, cookie));
return result;
}
else
{
// If the closest side is the side with the tabs, consider this a stack operation.
// Otherwise, let the drop fall through to whatever the default behavior is
Rectangle displayBounds = DragUtil::GetDisplayBounds(
tabFolder->GetControl());
int closestSide = Geometry::GetClosestSide(displayBounds, location);
if (closestSide == tabFolder->GetTabPosition())
{
StackDropResult::Pointer result(new StackDropResult(displayBounds, Object::Pointer(0)));
return result;
}
return StackDropResult::Pointer(0);
}
}
if (!tabUnderPointer->IsShowing())
{
return StackDropResult::Pointer(0);
}
QRect qtabBounds = tabUnderPointer->GetBounds();
Rectangle tabBounds(qtabBounds.x(), qtabBounds.y(), qtabBounds.width(), qtabBounds.height());
if (qtabBounds.isEmpty())
{
return StackDropResult::Pointer(0);
}
Object::Pointer cookie(new DragCookie(tabFolder->IndexOf(tabUnderPointer)));
StackDropResult::Pointer result(new StackDropResult(tabBounds, cookie));
return result;
}
int ReplaceDragHandler::GetInsertionPosition(Object::Pointer cookie)
{
if (cookie.Cast<DragCookie>() != 0)
{
return std::min<int>(static_cast<int>(tabFolder->GetItemCount()),
cookie.Cast<DragCookie>()->insertPosition);
}
return static_cast<int>(tabFolder->GetItemCount());
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryReplaceDragHandler.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryReplaceDragHandler.h
index 1042561440..2083feb3af 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryReplaceDragHandler.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryReplaceDragHandler.h
@@ -1,58 +1,58 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYREPLACEDRAGHANDLER_H_
#define BERRYREPLACEDRAGHANDLER_H_
#include "berryTabDragHandler.h"
#include "berryAbstractTabFolder.h"
namespace berry {
class ReplaceDragHandler : public TabDragHandler {
private:
struct DragCookie : public Object {
int insertPosition;
DragCookie(int pos);
};
AbstractTabFolder* tabFolder;
public:
ReplaceDragHandler(AbstractTabFolder* folder);
/* (non-Javadoc)
* @see org.eclipse.ui.internal.presentations.util.TabDragHandler#dragOver(org.eclipse.swt.widgets.Control, org.eclipse.swt.graphics.Point)
*/
StackDropResult::Pointer DragOver(QWidget*, const Point& location,
int dragStart);
/* (non-Javadoc)
* @see org.eclipse.ui.internal.presentations.util.TabDragHandler#getInsertionPosition(java.lang.Object)
*/
int GetInsertionPosition(Object::Pointer cookie);
};
}
#endif /* BERRYREPLACEDRAGHANDLER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryTabDragHandler.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryTabDragHandler.h
index 8706aa1eba..b9cb7cc2cb 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryTabDragHandler.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryTabDragHandler.h
@@ -1,51 +1,51 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYTABDRAGHANDLER_H_
#define BERRYTABDRAGHANDLER_H_
#include <berryStackDropResult.h>
#include <QWidget>
#include <QPoint>
#include <org_blueberry_ui_qt_Export.h>
namespace berry {
struct BERRY_UI_QT TabDragHandler {
virtual ~TabDragHandler();
/**
* Returns the StackDropResult for the location being dragged over.
*
* @param currentControl control being dragged over
* @param location mouse position (display coordinates)
* @param initialTab the index of the tab in this stack being dragged,
* or -1 if dragging a tab from another stack.
* @return the StackDropResult for this drag location
*/
virtual StackDropResult::Pointer DragOver(QWidget* currentControl,
const Point& location, int initialTab) = 0;
virtual int GetInsertionPosition(Object::Pointer cookie) = 0;
};
}
#endif /* BERRYTABDRAGHANDLER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryTabFolderEvent.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryTabFolderEvent.cpp
index 2df92ba5bc..efac9719bf 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryTabFolderEvent.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryTabFolderEvent.cpp
@@ -1,83 +1,83 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryTabFolderEvent.h"
#include "berryAbstractTabItem.h"
namespace berry
{
const int TabFolderEvent::EVENT_PANE_MENU = 1;
const int TabFolderEvent::EVENT_HIDE_TOOLBAR = 2;
const int TabFolderEvent::EVENT_SHOW_TOOLBAR = 3;
const int TabFolderEvent::EVENT_RESTORE = 4;
const int TabFolderEvent::EVENT_MINIMIZE = 5;
const int TabFolderEvent::EVENT_CLOSE = 6;
const int TabFolderEvent::EVENT_MAXIMIZE = 7;
const int TabFolderEvent::EVENT_TAB_SELECTED = 8;
const int TabFolderEvent::EVENT_GIVE_FOCUS_TO_PART = 9;
const int TabFolderEvent::EVENT_DRAG_START = 10;
const int TabFolderEvent::EVENT_SHOW_LIST = 11;
const int TabFolderEvent::EVENT_SYSTEM_MENU = 12;
const int TabFolderEvent::EVENT_PREFERRED_SIZE = 13;
int TabFolderEvent::EventIdToStackState(int eventId)
{
switch (eventId)
{
case EVENT_RESTORE:
return IStackPresentationSite::STATE_RESTORED;
case EVENT_MINIMIZE:
return IStackPresentationSite::STATE_MINIMIZED;
case EVENT_MAXIMIZE:
return IStackPresentationSite::STATE_MAXIMIZED;
}
return 0;
}
int TabFolderEvent::StackStateToEventId(int stackState)
{
if (stackState == IStackPresentationSite::STATE_RESTORED)
return EVENT_RESTORE;
else if (stackState == IStackPresentationSite::STATE_MINIMIZED)
return EVENT_MINIMIZE;
else if (stackState == IStackPresentationSite::STATE_MAXIMIZED)
return EVENT_MAXIMIZE;
return 0;
}
TabFolderEvent::TabFolderEvent(int _type) :
type(_type)
{
}
TabFolderEvent::TabFolderEvent(int _type, AbstractTabItem* w, int _x, int _y)
: tab(w), type(_type), x(_x), y(_y)
{
}
TabFolderEvent::TabFolderEvent(int _type, AbstractTabItem* w, const QPoint& pos)
: tab(w), type(_type), x(pos.x()), y(pos.y())
{
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryTabFolderEvent.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryTabFolderEvent.h
index 41b19f1855..3af6f6ef8c 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryTabFolderEvent.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryTabFolderEvent.h
@@ -1,65 +1,65 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYTABFOLDEREVENT_H_
#define BERRYTABFOLDEREVENT_H_
#include <berryIStackPresentationSite.h>
#include <QPoint>
namespace berry
{
struct AbstractTabItem;
struct TabFolderEvent : public Object
{
berryObjectMacro(TabFolderEvent);
static const int EVENT_PANE_MENU; // = 1;
static const int EVENT_HIDE_TOOLBAR; // = 2;
static const int EVENT_SHOW_TOOLBAR; // = 3;
static const int EVENT_RESTORE; // = 4;
static const int EVENT_MINIMIZE; // = 5;
static const int EVENT_CLOSE; // = 6;
static const int EVENT_MAXIMIZE; // = 7;
static const int EVENT_TAB_SELECTED; // = 8;
static const int EVENT_GIVE_FOCUS_TO_PART; // = 9;
static const int EVENT_DRAG_START; // = 10;
static const int EVENT_SHOW_LIST; // = 11;
static const int EVENT_SYSTEM_MENU; // = 12;
static const int EVENT_PREFERRED_SIZE; // = 13;
static int EventIdToStackState(int eventId);
static int StackStateToEventId(int stackState);
AbstractTabItem* tab;
int type;
int x;
int y;
TabFolderEvent(int _type);
TabFolderEvent(int type, AbstractTabItem* w, int x, int y);
TabFolderEvent(int type, AbstractTabItem* w, const QPoint& pos);
};
}
#endif /* BERRYTABFOLDEREVENT_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryTabOrder.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryTabOrder.h
index 27bd668439..61eb2891bb 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryTabOrder.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryTabOrder.h
@@ -1,83 +1,83 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYTABORDER_H_
#define BERRYTABORDER_H_
#include <berryIPresentablePart.h>
#include <berryIPresentationSerializer.h>
#include <berryIMemento.h>
#include <org_blueberry_ui_qt_Export.h>
namespace berry {
struct BERRY_UI_QT TabOrder {
virtual ~TabOrder();
/**
* Adds a part due to a user action that opened a part
*
* @param newPart part being added
*/
virtual void Add(IPresentablePart::Pointer newPart) = 0;
/**
* Adds a part at initialization-time (the part was added as
* part of a perspective, rather than by a user action)
*
* @param newPart the part being added
*/
virtual void AddInitial(IPresentablePart::Pointer newPart) = 0;
virtual void RestoreState(IPresentationSerializer* serializer,
IMemento::Pointer savedState) = 0;
virtual void SaveState(IPresentationSerializer* serializer, IMemento::Pointer memento) = 0;
/**
* Adds a part at a particular index due to a drag/drop operation.
*
* @param added part being added
* @param index index where the part is added at
*/
virtual void Insert(IPresentablePart::Pointer added, int index) = 0;
virtual void Move(IPresentablePart::Pointer toMove, int newIndex) = 0;
/**
* Removes a part
*
* @param removed part being removed
*/
virtual void Remove(IPresentablePart::Pointer removed) = 0;
/**
* Selects a part
*
* @param selected part being selected
*/
virtual void Select(IPresentablePart::Pointer selected) = 0;
virtual std::vector<IPresentablePart::Pointer> GetPartList() = 0;
};
}
#endif /* BERRYTABORDER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryTabbedStackPresentation.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryTabbedStackPresentation.cpp
index 0888a7ac8b..d4d76250dc 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryTabbedStackPresentation.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryTabbedStackPresentation.cpp
@@ -1,495 +1,495 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryLog.h"
#include "berryTabbedStackPresentation.h"
#include "berryAbstractTabItem.h"
#include "berryLeftToRightTabOrder.h"
#include "berryReplaceDragHandler.h"
#include <berryConstants.h>
namespace berry
{
int TabbedStackPresentation::ComputePreferredMinimumSize(bool width,
int availablePerpendicular)
{
int minSize;
int hint =
availablePerpendicular == INF ? Constants::DEFAULT
: availablePerpendicular;
if (width)
{
minSize = folder->GetTabFolder()->ComputeSize(Constants::DEFAULT, hint).width();
}
else
{
minSize = folder->GetTabFolder()->ComputeSize(hint, Constants::DEFAULT).height();
}
return minSize;
}
void TabbedStackPresentation::HandleTabFolderEvent(TabFolderEvent::Pointer e)
{
int type = e->type;
if (type == TabFolderEvent::EVENT_MINIMIZE)
{
this->GetSite()->SetState(IStackPresentationSite::STATE_MINIMIZED);
}
else if (type == TabFolderEvent::EVENT_MAXIMIZE)
{
this->GetSite()->SetState(IStackPresentationSite::STATE_MAXIMIZED);
}
else if (type == TabFolderEvent::EVENT_RESTORE)
{
this->GetSite()->SetState(IStackPresentationSite::STATE_RESTORED);
}
else if (type == TabFolderEvent::EVENT_CLOSE)
{
IPresentablePart::Pointer part = folder->GetPartForTab(e->tab);
if (part != 0)
{
std::vector<IPresentablePart::Pointer> parts;
parts.push_back(part);
this->GetSite()->Close(parts);
}
}
else if (type == TabFolderEvent::EVENT_SHOW_LIST)
{
this->ShowPartList();
}
else if (type == TabFolderEvent::EVENT_GIVE_FOCUS_TO_PART)
{
IPresentablePart::Pointer part = this->GetSite()->GetSelectedPart();
if (part != 0)
{
part->SetFocus();
}
}
else if (type == TabFolderEvent::EVENT_PANE_MENU)
{
IPresentablePart::Pointer part = this->GetSite()->GetSelectedPart();
if (part != 0)
{
part->SetFocus();
}
//this->ShowPaneMenu(folder->GetPartForTab(e->tab), QPoint(e->x, e->y));
}
else if (type == TabFolderEvent::EVENT_DRAG_START)
{
AbstractTabItem* beingDragged = e->tab;
Point initialLocation(e->x, e->y);
if (beingDragged == 0)
{
this->GetSite()->DragStart(initialLocation, false);
}
else
{
IPresentablePart::Pointer part = folder->GetPartForTab(beingDragged);
try {
dragStart = folder->IndexOf(part);
// hold on to this TabbedStackPresentation instance, because
// in this->GetSite()->DragStart() all reference may be deleted
// and this instance is destroyed, leading to a seg fault when
// trying to write to dragStart
StackPresentation::Pointer tabbedStackPresentation(this);
this->GetSite()->DragStart(part, initialLocation, false);
dragStart = -1;
} catch(std::exception& exc) {
dragStart = -1;
throw exc;
}
}
}
else if (type == TabFolderEvent::EVENT_TAB_SELECTED)
{
if (ignoreSelectionChanges > 0)
{
return;
}
IPresentablePart::Pointer part = folder->GetPartForTab(e->tab);
if (part != 0)
{
this->GetSite()->SelectPart(part);
}
}
else if (type == TabFolderEvent::EVENT_SYSTEM_MENU)
{
IPresentablePart::Pointer part = folder->GetPartForTab(e->tab);
if (part == 0)
{
part = this->GetSite()->GetSelectedPart();
}
if (part != 0)
{
//this->ShowSystemMenu(QPoint(e->x, e->y), part);
}
}
else if (type == TabFolderEvent::EVENT_PREFERRED_SIZE)
{
IPresentablePart::Pointer part = folder->GetPartForTab(e->tab);
if (part == 0)
{
// Standalone views with no title have no tab, so just get the part.
std::list<IPresentablePart::Pointer> parts = this->GetSite()->GetPartList();
if (parts.size() > 0)
part = parts.front();
}
if (part == this->GetSite()->GetSelectedPart())
{
this->GetSite()->FlushLayout();
}
}
}
TabbedStackPresentation::TabbedStackPresentation(
IStackPresentationSite::Pointer site, AbstractTabFolder* widget/*, ISystemMenu systemMenu*/)
: StackPresentation(site)
{
PresentablePartFolder* folder = new PresentablePartFolder(widget);
this->Init(site, folder, new LeftToRightTabOrder(folder),
new ReplaceDragHandler(widget)); // systemMenu);
}
TabbedStackPresentation::TabbedStackPresentation(
IStackPresentationSite::Pointer site, PresentablePartFolder* folder/*, ISystemMenu systemMenu*/)
: StackPresentation(site)
{
this->Init(site, folder, new LeftToRightTabOrder(folder),
new ReplaceDragHandler(folder->GetTabFolder())); //, systemMenu);
}
TabbedStackPresentation::TabbedStackPresentation(
IStackPresentationSite::Pointer site, PresentablePartFolder* newFolder,
TabOrder* tabs, TabDragHandler* dragBehavior /*, ISystemMenu systemMenu*/)
: StackPresentation(site)
{
this->Init(site, newFolder, tabs, dragBehavior);
}
void TabbedStackPresentation::Init(IStackPresentationSite::Pointer,
PresentablePartFolder* newFolder, TabOrder* tabs, TabDragHandler* dragBehavior /*, ISystemMenu systemMenu*/)
{
//this->systemMenu = systemMenu;
initializing = true;
ignoreSelectionChanges = 0;
dragStart = -1;
this->folder = newFolder;
this->tabs = tabs;
this->dragBehavior = dragBehavior;
// // Add a dispose listener. This will call the presentationDisposed()
// // method when the widget is destroyed.
// folder.getTabFolder().getControl().addDisposeListener(new DisposeListener() {
// public void widgetDisposed(DisposeEvent e) {
// presentationDisposed();
// }
// });
folder->GetTabFolder()->tabFolderEvent += TabFolderEventDelegate(this, &TabbedStackPresentation::HandleTabFolderEvent);
//this->partList = new DefaultPartList(site, newFolder);
}
void TabbedStackPresentation::RestoreState(IPresentationSerializer* serializer,
IMemento::Pointer savedState)
{
tabs->RestoreState(serializer, savedState);
}
void TabbedStackPresentation::SaveState(IPresentationSerializer* context,
IMemento::Pointer memento)
{
StackPresentation::SaveState(context, memento);
tabs->SaveState(context, memento);
}
void TabbedStackPresentation::SetBounds(const Rectangle& bounds)
{
QRect rectangle(bounds.x, bounds.y, bounds.width, bounds.height);
folder->SetBounds(rectangle);
}
Point TabbedStackPresentation::ComputeMinimumSize()
{
QSize point = folder->GetTabFolder()->ComputeSize(Constants::DEFAULT, Constants::DEFAULT);
return Point(point.width(), point.height());
}
int TabbedStackPresentation::ComputePreferredSize(bool width,
int availableParallel, int availablePerpendicular, int preferredResult)
{
// If there is exactly one part in the stack, this just returns the
// preferred size of the part as the preferred size of the stack.
std::list<IPresentablePart::Pointer> parts = this->GetSite()->GetPartList();
if (parts.size() == 1 && parts.front() != 0 && !(this->GetSite()->GetState()
== IStackPresentationSite::STATE_MINIMIZED))
{
int partSize = parts.front()->ComputePreferredSize(width, availableParallel,
availablePerpendicular, preferredResult);
if (partSize == INF)
return partSize;
// Adjust preferred size to take into account tab and border trim.
int minSize = this->ComputePreferredMinimumSize(width, availablePerpendicular);
if (width)
{
// PaneFolder adds some bogus tab spacing, so just find the maximum width.
partSize = std::max<int>(minSize, partSize);
}
else
{
// Add them (but only if there's enough room)
if (INF - minSize > partSize)
partSize += minSize;
}
return partSize;
}
if (preferredResult != INF || this->GetSite()->GetState()
== IStackPresentationSite::STATE_MINIMIZED)
{
int minSize = this->ComputePreferredMinimumSize(width, availablePerpendicular);
if (this->GetSite()->GetState() == IStackPresentationSite::STATE_MINIMIZED)
{
return minSize;
}
return std::max<int>(minSize, preferredResult);
}
return INF;
}
int TabbedStackPresentation::GetSizeFlags(bool width)
{
int flags = 0;
// If there is exactly one part in the stack,
// then take into account the size flags of the part.
std::list<IPresentablePart::Pointer> parts = this->GetSite()->GetPartList();
if (parts.size() == 1 && parts.front() != 0)
{
flags |= parts.front()->GetSizeFlags(width);
}
return flags | StackPresentation::GetSizeFlags(width);
}
void TabbedStackPresentation::ShowPartList()
{
// if (partList != 0)
// {
// int numberOfParts = folder->GetTabFolder()->GetItemCount();
// if (numberOfParts > 0)
// {
// partList.show(getControl(), folder.getTabFolder() .getPartListLocation(),
// getSite().getSelectedPart());
// }
// }
}
TabbedStackPresentation::~TabbedStackPresentation()
{
// // Dispose the tab folder's widgetry
// folder.getTabFolder().getControl().dispose();
BERRY_DEBUG << "DELETING TabbedStackPresentation\n";
delete tabs;
delete dragBehavior;
delete folder;
}
void TabbedStackPresentation::SetActive(int newState)
{
folder->GetTabFolder()->SetActive(newState);
}
void TabbedStackPresentation::SetVisible(bool isVisible)
{
IPresentablePart::Pointer current = this->GetSite()->GetSelectedPart();
if (current != 0)
{
current->SetVisible(isVisible);
}
folder->SetVisible(isVisible);
}
void TabbedStackPresentation::SetState(int state)
{
folder->GetTabFolder()->SetState(state);
}
void* TabbedStackPresentation::GetControl()
{
return folder->GetTabFolder()->GetControl();
}
AbstractTabFolder* TabbedStackPresentation::GetTabFolder()
{
return folder->GetTabFolder();
}
void TabbedStackPresentation::AddPart(IPresentablePart::Pointer newPart,
Object::Pointer cookie)
{
++ignoreSelectionChanges;
try
{
if (initializing)
{
tabs->AddInitial(newPart);
}
else
{
if (cookie == 0)
{
tabs->Add(newPart);
}
else
{
int insertionPoint = dragBehavior->GetInsertionPosition(cookie);
tabs->Insert(newPart, insertionPoint);
}
}
--ignoreSelectionChanges;
} catch (std::exception& e)
{
--ignoreSelectionChanges;
throw e;
}
if (tabs->GetPartList().size() == 1)
{
if (newPart->GetSizeFlags(true) != 0 || newPart->GetSizeFlags(false) != 0)
{
this->GetSite()->FlushLayout();
}
}
}
void TabbedStackPresentation::MovePart(IPresentablePart::Pointer toMove,
Object::Pointer cookie)
{
++ignoreSelectionChanges;
try
{
int insertionPoint = dragBehavior->GetInsertionPosition(cookie);
if (insertionPoint == folder->IndexOf(toMove))
{
--ignoreSelectionChanges;
return;
}
tabs->Move(toMove, insertionPoint);
--ignoreSelectionChanges;
} catch (std::exception& e)
{
--ignoreSelectionChanges;
throw e;
}
}
void TabbedStackPresentation::RemovePart(IPresentablePart::Pointer oldPart)
{
++ignoreSelectionChanges;
try
{
tabs->Remove(oldPart);
--ignoreSelectionChanges;
} catch (std::exception& e)
{
--ignoreSelectionChanges;
throw e;
}
}
void TabbedStackPresentation::SelectPart(IPresentablePart::Pointer toSelect)
{
initializing = false;
tabs->Select(toSelect);
}
StackDropResult::Pointer TabbedStackPresentation::DragOver(void* currentControl, const Point& location)
{
QWidget* currentWidget = static_cast<QWidget*>(currentControl);
return dragBehavior->DragOver(currentWidget, location, dragStart);
}
std::vector<void*> TabbedStackPresentation::GetTabList(
IPresentablePart::Pointer part)
{
std::vector<void*> list;
if (folder->GetTabFolder()->GetTabPosition() == Constants::BOTTOM)
{
if (part->GetControl() != 0)
{
list.push_back(part->GetControl());
}
}
list.push_back(folder->GetTabFolder()->GetControl());
// if (part->GetToolBar() != 0)
// {
// list.push_back(part->GetToolBar());
// }
if (folder->GetTabFolder()->GetTabPosition() == Constants::TOP)
{
if (part->GetControl() != 0)
{
list.push_back(part->GetControl());
}
}
return list;
}
void TabbedStackPresentation::MoveTab(IPresentablePart::Pointer part, int index)
{
tabs->Move(part, index);
folder->Layout(true);
}
std::vector<IPresentablePart::Pointer> TabbedStackPresentation::GetPartList()
{
return tabs->GetPartList();
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryTabbedStackPresentation.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryTabbedStackPresentation.h
index d6b5fb9429..3098d452a1 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryTabbedStackPresentation.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryTabbedStackPresentation.h
@@ -1,276 +1,276 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYTABBEDSTACKPRESENTATION_H_
#define BERRYTABBEDSTACKPRESENTATION_H_
#include <berryStackPresentation.h>
#include "berryPresentablePartFolder.h"
#include "berryTabOrder.h"
#include "berryTabDragHandler.h"
namespace berry {
class TabbedStackPresentation : public StackPresentation {
private:
typedef MessageDelegate1<TabbedStackPresentation, TabFolderEvent::Pointer> TabFolderEventDelegate;
PresentablePartFolder* folder;
//ISystemMenu systemMenu;
//ISystemMenu partList;
// PreferenceStoreAdapter apiPreferences = new PreferenceStoreAdapter(PrefUtil
// .getAPIPreferenceStore());
// ThemeManagerAdapter themePreferences = new ThemeManagerAdapter(
// PlatformUI.getWorkbench().getThemeManager());
TabOrder* tabs;
TabDragHandler* dragBehavior;
bool initializing;
int ignoreSelectionChanges;
int dragStart;
//Map prefs = new HashMap();
/**
* Returns the minimum size for this stack, taking into account
* the available perpendicular space.
* @param width indicates whether a width (=true) or a height (=false) is being computed
* @param availablePerpendicular available space perpendicular to the direction being measured
* or INFINITE if unbounded (pixels).
* @return returns the preferred minimum size (pixels).
* This is a width if width == true or a height if width == false.
*/
int ComputePreferredMinimumSize(bool width, int availablePerpendicular);
public:
void HandleTabFolderEvent(TabFolderEvent::Pointer e);
/**
* Creates a TabbedStackPresentation. The created object will take ownership of the AbstractTabFolder pointer.
*/
TabbedStackPresentation(IStackPresentationSite::Pointer site, AbstractTabFolder* widget/*, ISystemMenu systemMenu*/);
/**
* Creates a TabbedStackPresentation. The created object will take ownership of the PresentablePartFolder pointer.
*/
TabbedStackPresentation(IStackPresentationSite::Pointer site, PresentablePartFolder* folder/*, ISystemMenu systemMenu*/);
/**
* Creates a TabbedStackPresentation. The created object will take ownership of the PresentablePartFolder and the TabOrder pointer.
*/
TabbedStackPresentation(IStackPresentationSite::Pointer site,
PresentablePartFolder* newFolder, TabOrder* tabs, TabDragHandler* dragBehavior /*, ISystemMenu systemMenu*/);
void Init(IStackPresentationSite::Pointer,
PresentablePartFolder* newFolder, TabOrder* tabs, TabDragHandler* dragBehavior /*, ISystemMenu systemMenu*/);
/**
* Restores a presentation from a previously stored state
*
* @param serializer (not null)
* @param savedState (not null)
*/
void RestoreState(IPresentationSerializer* serializer,
IMemento::Pointer savedState);
/* (non-Javadoc)
* @see org.blueberry.ui.presentations.StackPresentation#saveState(org.blueberry.ui.presentations.IPresentationSerializer, org.blueberry.ui.IMemento)
*/
void SaveState(IPresentationSerializer* context, IMemento::Pointer memento);
/* (non-Javadoc)
* @see org.blueberry.ui.presentations.StackPresentation#setBounds(org.blueberry.swt.graphics.Rectangle)
*/
void SetBounds(const Rectangle& bounds);
/* (non-Javadoc)
* @see org.blueberry.ui.presentations.StackPresentation#computeMinimumSize()
*/
Point ComputeMinimumSize();
/* (non-Javadoc)
* @see org.blueberry.ui.ISizeProvider#computePreferredSize(boolean, int, int, int)
*/
int ComputePreferredSize(bool width, int availableParallel,
int availablePerpendicular, int preferredResult);
/* (non-Javadoc)
* @see org.blueberry.ui.presentations.StackPresentation#getSizeFlags(boolean)
*/
int GetSizeFlags(bool width);
/* (non-Javadoc)
* @see org.blueberry.ui.presentations.StackPresentation#showPartList()
*/
void ShowPartList();
/* (non-Javadoc)
* @see org.blueberry.ui.presentations.StackPresentation#dispose()
*/
~TabbedStackPresentation();
/* (non-Javadoc)
* @see org.blueberry.ui.presentations.StackPresentation#setActive(int)
*/
void SetActive(int newState);
/* (non-Javadoc)
* @see org.blueberry.ui.presentations.StackPresentation#setVisible(boolean)
*/
void SetVisible(bool isVisible);
/* (non-Javadoc)
* @see org.blueberry.ui.presentations.StackPresentation#setState(int)
*/
void SetState(int state);
/* (non-Javadoc)
* @see org.blueberry.ui.presentations.StackPresentation#getControl()
*/
void* GetControl();
/**
* @return AbstractTabFolder the presentation's tab folder
*/
AbstractTabFolder* GetTabFolder();
/* (non-Javadoc)
* @see org.blueberry.ui.presentations.StackPresentation#addPart(org.blueberry.ui.presentations.IPresentablePart, java.lang.Object)
*/
void AddPart(IPresentablePart::Pointer newPart, Object::Pointer cookie);
/* (non-Javadoc)
* @see org.blueberry.ui.presentations.StackPresentation#movePart(org.blueberry.ui.presentations.IPresentablePart, java.lang.Object)
*/
void MovePart(IPresentablePart::Pointer toMove, Object::Pointer cookie);
/* (non-Javadoc)
* @see org.blueberry.ui.presentations.StackPresentation#removePart(org.blueberry.ui.presentations.IPresentablePart)
*/
void RemovePart(IPresentablePart::Pointer oldPart);
/* (non-Javadoc)
* @see org.blueberry.ui.presentations.StackPresentation#selectPart(org.blueberry.ui.presentations.IPresentablePart)
*/
void SelectPart(IPresentablePart::Pointer toSelect);
/* (non-Javadoc)
* @see org.blueberry.ui.presentations.StackPresentation#DragOver(void*, const Point&)
*/
StackDropResult::Pointer DragOver(void* currentControl, const Point& location);
// void showSystemMenu() {
// showSystemMenu(folder.getTabFolder().getSystemMenuLocation(), getSite().getSelectedPart());
// }
// void showSystemMenu(Point displayCoordinates, IPresentablePart context) {
// if (context != getSite().getSelectedPart()) {
// getSite().selectPart(context);
// }
// systemMenu.show(getControl(), displayCoordinates, context);
// }
// /* (non-Javadoc)
// * @see org.blueberry.ui.presentations.StackPresentation#showPaneMenu()
// */
// void showPaneMenu() {
// IPresentablePart part = getSite().getSelectedPart();
//
// if (part != null) {
// showPaneMenu(part, folder.getTabFolder().getPaneMenuLocation());
// }
// }
// void showPaneMenu(IPresentablePart part, Point location) {
// Assert.isTrue(!isDisposed());
//
// IPartMenu menu = part.getMenu();
//
// if (menu != null) {
// menu.showMenu(location);
// }
// }
/* (non-Javadoc)
* @see org.blueberry.ui.presentations.StackPresentation#getTabList(org.blueberry.ui.presentations.IPresentablePart)
*/
std::vector<void*> GetTabList(IPresentablePart::Pointer part);
// void SetPartList(ISystemMenu menu) {
// this.partList = menu;
// }
// IDynamicPropertyMap getTheme() {
// return themePreferences;
// }
// IDynamicPropertyMap getApiPreferences() {
// return apiPreferences;
// }
// IDynamicPropertyMap getPluginPreferences(Plugin toQuery) {
// String id = toQuery.getBundle().getSymbolicName();
// IDynamicPropertyMap result = (IDynamicPropertyMap)prefs.get(id);
//
// if (result != null) {
// return result;
// }
//
// result = new PreferencesAdapter(toQuery.getPluginPreferences());
// prefs.put(id, result);
// return result;
// }
/**
* Move the tabs around. This is for testing <b>ONLY</b>.
* @param part the part to move
* @param index the new index
* @since 3.2
*/
void MoveTab(IPresentablePart::Pointer part, int index);
/**
* Get the tab list. This is for testing <b>ONLY</b>.
* @return the presentable parts in order.
* @since 3.2
*/
std::vector<IPresentablePart::Pointer> GetPartList();
// /**
// * Cause the folder to hide or show its
// * Minimize and Maximize affordances.
// *
// * @param show
// * <code>true</code> - the min/max buttons are visible.
// * @since 3.3
// */
// void ShowMinMax(bool show) {
// folder.getTabFolder().showMinMax(show);
// }
};
}
#endif /* BERRYTABBEDSTACKPRESENTATION_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/manifest.cpp b/BlueBerry/Bundles/org.blueberry.ui/manifest.cpp
index eb49bb2b64..b9125f8c49 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/manifest.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/manifest.cpp
@@ -1,36 +1,36 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "Poco/ClassLibrary.h"
#include <berryIBundleActivator.h>
#include "src/internal/berryWorkbenchPlugin.h"
POCO_BEGIN_MANIFEST(berry::IBundleActivator)
POCO_EXPORT_CLASS(berry::WorkbenchPlugin)
POCO_END_MANIFEST
#include "src/internal/intro/berryViewIntroAdapterPart.h"
POCO_BEGIN_NAMED_MANIFEST(berryIViewPart, berry::IViewPart)
POCO_EXPORT_CLASS(berry::ViewIntroAdapterPart)
POCO_END_MANIFEST
#include "src/internal/intro/berryEditorIntroAdapterPart.h"
POCO_BEGIN_NAMED_MANIFEST(berryIEditorPart, berry::IEditorPart)
POCO_EXPORT_CLASS(berry::EditorIntroAdapterPart)
POCO_END_MANIFEST
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/application/berryActionBarAdvisor.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/application/berryActionBarAdvisor.cpp
index 604feb5355..b5f4a96898 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/application/berryActionBarAdvisor.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/application/berryActionBarAdvisor.cpp
@@ -1,79 +1,79 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryActionBarAdvisor.h"
namespace berry
{
const int ActionBarAdvisor::FILL_PROXY = 0x01;
const int ActionBarAdvisor::FILL_MENU_BAR = 0x02;
const int ActionBarAdvisor::FILL_COOL_BAR = 0x04;
const int ActionBarAdvisor::FILL_STATUS_LINE = 0x08;
ActionBarAdvisor::ActionBarAdvisor(IActionBarConfigurer::Pointer configurer)
{
poco_assert(configurer.IsNotNull());
actionBarConfigurer = configurer;
}
IActionBarConfigurer::Pointer ActionBarAdvisor::GetActionBarConfigurer()
{
return actionBarConfigurer;
}
void ActionBarAdvisor::FillActionBars(int flags)
{
if ((flags & FILL_PROXY) == 0)
{
this->MakeActions(actionBarConfigurer->GetWindowConfigurer()->GetWindow());
}
if ((flags & FILL_MENU_BAR) != 0)
{
this->FillMenuBar(actionBarConfigurer->GetMenuManager());
}
// if ((flags & FILL_COOL_BAR) != 0) {
// fillCoolBar(actionBarConfigurer.getCoolBarManager());
// }
// if ((flags & FILL_STATUS_LINE) != 0) {
// fillStatusLine(actionBarConfigurer.getStatusLineManager());
// }
}
void ActionBarAdvisor::MakeActions(IWorkbenchWindow::Pointer /*window*/)
{
// do nothing
}
void ActionBarAdvisor::FillMenuBar(void* /*menuBar*/)
{
// do nothing
}
bool ActionBarAdvisor::SaveState(IMemento::Pointer /*memento*/)
{
return true;
}
bool ActionBarAdvisor::RestoreState(IMemento::Pointer /*memento*/)
{
return true;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/application/berryActionBarAdvisor.h b/BlueBerry/Bundles/org.blueberry.ui/src/application/berryActionBarAdvisor.h
index 6ff9d584a2..6e79b68508 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/application/berryActionBarAdvisor.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/application/berryActionBarAdvisor.h
@@ -1,260 +1,260 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYACTIONBARADVISOR_H_
#define BERRYACTIONBARADVISOR_H_
#include "berryIMemento.h"
#include "berryIWorkbenchWindow.h"
#include "berryIActionBarConfigurer.h"
namespace berry
{
/**
* Public base class for configuring the action bars of a workbench window.
* <p>
* An application should declare a subclass of <code>ActionBarAdvisor</code>
* and override methods to configure a window's action bars to suit the needs of the
* particular application.
* </p>
* <p>
* The following advisor methods are called at strategic points in the
* workbench's lifecycle (all occur within the dynamic scope of the call
* to {@link PlatformUI#createAndRunWorkbench PlatformUI.createAndRunWorkbench}):
* <ul>
* <li><code>fillActionBars</code> - called after <code>WorkbenchWindowAdvisor.preWindowOpen</code>
* to configure a window's action bars</li>
* </ul>
* </p>
*
* @see WorkbenchWindowAdvisor#createActionBarAdvisor(IActionBarConfigurer)
*
* @since 3.1
*/
class BERRY_UI ActionBarAdvisor : public Object {
public:
berryObjectMacro(ActionBarAdvisor);
/**
* Bit flag for {@link #fillActionBars fillActionBars} indicating that the
* operation is not filling the action bars of an actual workbench window,
* but rather a proxy (used for perspective customization).
*/
public: static const int FILL_PROXY;
/**
* Bit flag for {@link #fillActionBars fillActionBars} indicating that the
* operation is supposed to fill (or describe) the workbench window's menu
* bar.
*/
public: static const int FILL_MENU_BAR;
/**
* Bit flag for {@link #fillActionBars fillActionBars} indicating that the
* operation is supposed to fill (or describe) the workbench window's cool
* bar.
*/
public: static const int FILL_COOL_BAR;
/**
* Bit flag for {@link #fillActionBars fillActionBars} indicating that the
* operation is supposed to fill (or describe) the workbench window's status
* line.
*/
public: static const int FILL_STATUS_LINE;
private: IActionBarConfigurer::Pointer actionBarConfigurer;
//private: Map actions = new HashMap();
/**
* Creates a new action bar advisor to configure a workbench
* window's action bars via the given action bar configurer.
*
* @param configurer the action bar configurer
*/
public: ActionBarAdvisor(IActionBarConfigurer::Pointer configurer);
/**
* Returns the action bar configurer.
*
* @return the action bar configurer
*/
protected: virtual IActionBarConfigurer::Pointer GetActionBarConfigurer();
/**
* Configures the action bars using the given action bar configurer.
* Under normal circumstances, <code>flags</code> does not include
* <code>FILL_PROXY</code>, meaning this is a request to fill the action
* bars of the corresponding workbench window; the
* remaining flags indicate which combination of
* the menu bar (<code>FILL_MENU_BAR</code>),
* the tool bar (<code>FILL_COOL_BAR</code>),
* and the status line (<code>FILL_STATUS_LINE</code>) are to be filled.
* <p>
* If <code>flags</code> does include <code>FILL_PROXY</code>, then this
* is a request to describe the actions bars of the given workbench window
* (which will already have been filled);
* again, the remaining flags indicate which combination of the menu bar,
* the tool bar, and the status line are to be described.
* The actions included in the proxy action bars can be the same instances
* as in the actual window's action bars. Calling <code>ActionFactory</code>
* to create new action instances is not recommended, because these
* actions internally register listeners with the window and there is no
* opportunity to dispose of these actions.
* </p>
* <p>
* This method is called just after {@link WorkbenchWindowAdvisor#preWindowOpen()}.
* Clients must not call this method directly (although super calls are okay).
* The default implementation calls <code>makeActions</code> if
* <code>FILL_PROXY</code> is specified, then calls <code>fillMenuBar</code>,
* <code>fillCoolBar</code>, and <code>fillStatusLine</code>
* if the corresponding flags are specified.
* </p>
* <p>
* Subclasses may override, but it is recommended that they override the
* methods mentioned above instead.
* </p>
*
* @param flags bit mask composed from the constants
* {@link #FILL_MENU_BAR FILL_MENU_BAR},
* {@link #FILL_COOL_BAR FILL_COOL_BAR},
* {@link #FILL_STATUS_LINE FILL_STATUS_LINE},
* and {@link #FILL_PROXY FILL_PROXY}
*/
public: virtual void FillActionBars(int flags);
/**
* Instantiates the actions used in the fill methods.
* Use {@link #register(IAction)} to register the action with the key binding service
* and add it to the list of actions to be disposed when the window is closed.
*
* @param window the window containing the action bars
*/
protected: virtual void MakeActions(IWorkbenchWindow::Pointer window);
/**
* Registers the given action with the key binding service
* (by calling {@link IActionBarConfigurer#registerGlobalAction(IAction)}),
* and adds it to the list of actions to be disposed when the window is closed.
* <p>
* In order to participate in key bindings, the action must have an action
* definition id (aka command id), and a corresponding command extension.
* See the <code>org.blueberry.ui.commands</code> extension point documentation
* for more details.
* </p>
*
* @param action the action to register, this cannot be <code>null</code>
*
* @see IAction#setActionDefinitionId(String)
* @see #disposeAction(IAction)
*/
// protected: virtual void Register(IAction action) {
// Assert.isNotNull(action, "Action must not be null"); //$NON-NLS-1$
// String id = action.getId();
// Assert.isNotNull(id, "Action must not have null id"); //$NON-NLS-1$
// getActionBarConfigurer().registerGlobalAction(action);
// actions.put(id, action);
// }
/**
* Returns the action with the given id, or <code>null</code> if not found.
*
* @param id the action id
* @return the action with the given id, or <code>null</code> if not found
* @see IAction#getId()
*/
// protected: virtual IAction GetAction(const std::string& id) {
// return (IAction) actions.get(id);
// }
/**
* Fills the menu bar with the main menus for the window.
* <p>
* The default implementation does nothing.
* Subclasses may override.
* </p>
*
* @param menuBar the menu manager for the menu bar
*/
protected: virtual void FillMenuBar(void* menuBar);
/**
* Fills the cool bar with the main toolbars for the window.
* <p>
* The default implementation does nothing.
* Subclasses may override.
* </p>
*
* @param coolBar the cool bar manager
*/
// protected: virtual void FillCoolBar(ICoolBarManager coolBar) {
// // do nothing
// }
/**
* Fills the status line with the main status line contributions
* for the window.
* <p>
* The default implementation does nothing.
* Subclasses may override.
* </p>
*
* @param statusLine the status line manager
*/
// protected: virtual void FillStatusLine(IStatusLineManager statusLine) {
// // do nothing
// }
/**
* Saves arbitrary application-specific state information
* for this action bar advisor.
* <p>
* The default implementation simply returns an OK status.
* Subclasses may extend or override.
* </p>
*
* @param memento the memento in which to save the advisor's state
* @return a status object indicating whether the save was successful
* @since 3.1
*/
public: virtual bool SaveState(IMemento::Pointer memento);
/**
* Restores arbitrary application-specific state information
* for this action bar advisor.
* <p>
* The default implementation simply returns an OK status.
* Subclasses may extend or override.
* </p>
*
* @param memento the memento from which to restore the advisor's state
* @return a status object indicating whether the restore was successful
* @since 3.1
*/
public: virtual bool RestoreState(IMemento::Pointer memento);
};
}
#endif /*BERRYACTIONBARADVISOR_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/application/berryIActionBarConfigurer.h b/BlueBerry/Bundles/org.blueberry.ui/src/application/berryIActionBarConfigurer.h
index b2e52e6757..78c7015cae 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/application/berryIActionBarConfigurer.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/application/berryIActionBarConfigurer.h
@@ -1,101 +1,101 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIACTIONBARCONFIGURER_H_
#define BERRYIACTIONBARCONFIGURER_H_
#include <berryMacros.h>
#include <org_blueberry_ui_Export.h>
#include "berryIWorkbenchWindowConfigurer.h"
namespace berry
{
/**
* Interface providing special access for configuring the action bars
* of a workbench window.
* <p>
* Note that these objects are only available to the main application
* (the plug-in that creates and owns the workbench).
* </p>
* <p>
* This interface is not intended to be implemented by clients.
* </p>
*
* @see org.blueberry.ui.application.WorkbenchAdvisor#fillActionBars
* @since 3.0
* @noimplement This interface is not intended to be implemented by clients.
*/
struct BERRY_UI IActionBarConfigurer : public Object {
berryInterfaceMacro(IActionBarConfigurer, berry);
~IActionBarConfigurer();
/**
* Returns the workbench window configurer for the window
* containing this configurer's action bars.
*
* @return the workbench window configurer
* @since 3.1
*/
virtual IWorkbenchWindowConfigurer::Pointer GetWindowConfigurer() = 0;
/**
* Returns the menu manager for the main menu bar of a workbench window.
*
* @return the menu manager
*/
virtual void* GetMenuManager() = 0;
/**
* Returns the status line manager of a workbench window.
*
* @return the status line manager
*/
//virtual IStatusLineManager GetStatusLineManager() = 0;
/**
* Returns the cool bar manager of the workbench window.
*
* @return the cool bar manager
*/
//virtual ICoolBarManager GetCoolBarManager() = 0;
/**
* Register the action as a global action with a workbench
* window.
* <p>
* For a workbench retarget action
* ({@link org.blueberry.ui.actions.RetargetAction RetargetAction})
* to work, it must be registered.
* You should also register actions that will participate
* in custom key bindings.
* </p>
*
* @param action the global action
* @see org.blueberry.ui.actions.RetargetAction
*/
//virtual void RegisterGlobalAction(IAction action) = 0;
};
}
#endif /*BERRYIACTIONBARCONFIGURER_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/application/berryIWorkbenchConfigurer.h b/BlueBerry/Bundles/org.blueberry.ui/src/application/berryIWorkbenchConfigurer.h
index 847c9fcfb6..4c322d002f 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/application/berryIWorkbenchConfigurer.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/application/berryIWorkbenchConfigurer.h
@@ -1,260 +1,260 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIWORKBENCHCONFIGURER_H_
#define BERRYIWORKBENCHCONFIGURER_H_
#include <berryMacros.h>
#include <org_blueberry_ui_Export.h>
#include "berryIWorkbench.h"
#include "berryIWorkbenchWindowConfigurer.h"
namespace berry {
/**
* Interface providing special access for configuring the workbench.
* <p>
* Note that these objects are only available to the main application
* (the plug-in that creates and owns the workbench).
* </p>
* <p>
* This interface is not intended to be implemented by clients.
* </p>
*
* @see WorkbenchAdvisor#Initialize()
* @note This interface is not intended to be implemented by clients.
*/
struct BERRY_UI IWorkbenchConfigurer : public Object {
berryInterfaceMacro(IWorkbenchConfigurer, berry);
~IWorkbenchConfigurer();
/**
* Restore status code indicating that the saved state
* could not be restored, but that startup should continue
* with a reset state.
*
* @see #RestoreState()
*/
static const int RESTORE_CODE_RESET = 1;
/**
* Restore status code indicating that the saved state
* could not be restored, and that the application
* must exit immediately without modifying any previously
* saved workbench state.
*/
static const int RESTORE_CODE_EXIT = 2;
/**
* Returns the underlying workbench.
*
* @return the workbench
*/
virtual IWorkbench* GetWorkbench() = 0;
/**
* Returns whether the workbench state should be saved on close and
* restored on subsequent open.
* <p>
* The initial value is <code>false</code>.
* </p>
*
* @return <code>true</code> to save and restore workbench state, or
* <code>false</code> to forget current workbench state on close.
*/
virtual bool GetSaveAndRestore() = 0;
/**
* Sets whether the workbench state should be saved on close and
* restored on subsequent open.
*
* @param enabled <code>true</code> to save and restore workbench state, or
* <code>false</code> to forget current workbench state on close.
*/
virtual void SetSaveAndRestore(bool enabled) = 0;
/**
* Restores a workbench window from the given memento.
*
* @param memento the memento from which to restore the window's state
* @return the configurer for the restored window
* @throws WorkbenchException if an error occurred during the restore
* @see IWorkbenchWindowConfigurer#SaveState(IMemento::Pointer)
*/
virtual IWorkbenchWindowConfigurer::Pointer RestoreWorkbenchWindow(IMemento::Pointer memento) = 0;
/*
* Declares a workbench image.
* <p>
* The workbench remembers the given image descriptor under the given name,
* and makes the image available to plug-ins via
* {@link IWorkbench#GetSharedImages() IWorkbench.getSharedImages()}.
* For "shared" images, the workbench remembers the image descriptor and
* will manages the image object create from it; clients retrieve "shared"
* images via
* {@link org.blueberry.ui.ISharedImages#getImage ISharedImages.getImage()}.
* For the other, "non-shared" images, the workbench remembers only the
* image descriptor; clients retrieve the image descriptor via
* {@link org.blueberry.ui.ISharedImages#getImageDescriptor
* ISharedImages.getImageDescriptor()} and are entirely
* responsible for managing the image objects they create from it.
* (This is made confusing by the historical fact that the API interface
* is called "ISharedImages".)
* </p>
*
* @param symbolicName the symbolic name of the image
* @param descriptor the image descriptor
* @param shared <code>true</code> if this is a shared image, and
* <code>false</code> if this is not a shared image
* @see org.blueberry.ui.ISharedImages#getImage
* @see org.blueberry.ui.ISharedImages#getImageDescriptor
*/
// virtual void declareImage(String symbolicName, ImageDescriptor descriptor,
// boolean shared);
/**
* Forces the workbench to close due to an emergency. This method should
* only be called when the workbench is in dire straights and cannot
* continue, and cannot even risk a normal workbench close (think "out of
* memory" or "unable to create shell"). When this method is called, an
* abbreviated workbench shutdown sequence is performed (less critical
* steps may be skipped). The workbench advisor is still called; however,
* it must not attempt to communicate with the user. While an emergency
* close is in progress, <code>EmergencyClosing()</code> returns
* <code>true</code>. %Workbench advisor methods should always check this
* flag before communicating with the user.
*
* @see #EmergencyClosing()
*/
virtual void EmergencyClose() = 0;
/**
* Returns whether the workbench is being closed due to an emergency.
* When this method returns <code>true</code>, the workbench is in dire
* straights and cannot continue. Indeed, things are so bad that we cannot
* even risk a normal workbench close. %Workbench advisor methods should
* always check this flag before attempting to communicate with the user.
*
* @return <code>true</code> if the workbench is in the process of being
* closed under emergency conditions, and <code>false</code> otherwise
*/
virtual bool EmergencyClosing() = 0;
/**
* Returns an object that can be used to configure the given window.
*
* @param window a workbench window
* @return a workbench window configurer
*/
virtual IWorkbenchWindowConfigurer::Pointer GetWindowConfigurer(
IWorkbenchWindow::Pointer window) = 0;
/**
* Returns the data associated with the workbench at the given key.
*
* @param key the key
* @return the data, or <code>null</code> if there is no data at the given
* key
*/
virtual Object::Pointer GetData(const std::string& key) const = 0;
/**
* Sets the data associated with the workbench at the given key.
*
* @param key the key
* @param data the data, or <code>null</code> to delete existing data
*/
virtual void SetData(const std::string& key, Object::Pointer data) = 0;
/**
* Restores the workbench state saved from the previous session, if any.
* This includes any open windows and their open perspectives, open views
* and editors, layout information, and any customizations to the open
* perspectives.
* <p>
* This is typically called from the advisor's <code>WorkbenchAdvisor#OpenWindows()</code>
* method.
* </p>
*
* @return a status object indicating whether the restore was successful
* @see #RESTORE_CODE_RESET
* @see #RESTORE_CODE_EXIT
* @see WorkbenchAdvisor#OpenWindows()
*/
virtual bool RestoreState() = 0;
/**
* Opens the first time window, using the default perspective and
* default page input.
* <p>
* This is typically called from the advisor's <code>WorkbenchAdvisor#OpenWindows()</code>
* method.
* </p>
*
* @see WorkbenchAdvisor#OpenWindows()
*/
virtual void OpenFirstTimeWindow() = 0;
/**
* Returns <code>true</code> if the workbench should exit when the last
* window is closed, <code>false</code> if the window should just be
* closed, leaving the workbench (and its event loop) running.
* <p>
* If <code>true</code>, the last window's state is saved before closing,
* so that it will be restored in the next session. This applies only if
* <code>#GetSaveAndRestore()</code> returns <code>true</code>).
* </p>
* <p>
* If <code>false</code>, the window is simply closed, losing its state.
* </p>
* <p>
* If the workbench is left running, it can be closed using
* <code>IWorkbench#Close()</code>, or a new window can be opened using
* <code>IWorkbench#OpenWorkbenchWindow(const std::string&, IAdaptable*)</code>.
* </p>
* <p>
* The initial value is <code>true</code>.
* </p>
*
* @return <code>true</code> if the workbench will exit when the last
* window is closed, <code>false</code> if the window should just
* be closed
*/
virtual bool GetExitOnLastWindowClose() = 0;
/**
* Sets whether the workbench should exit when the last window is closed, or
* whether the window should just be closed, leaving the workbench (and its
* event loop) running.
* <p>
* For more details, see <code>#GetExitOnLastWindowClose()</code>.
* </p>
*
* @param enabled
* <code>true</code> if the workbench should exit when the last
* window is closed, <code>false</code> if the window should
* just be closed
*/
virtual void SetExitOnLastWindowClose(bool enabled) = 0;
};
}
#endif /*BERRYIWORKBENCHCONFIGURER_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/application/berryIWorkbenchWindowConfigurer.h b/BlueBerry/Bundles/org.blueberry.ui/src/application/berryIWorkbenchWindowConfigurer.h
index 48abdb9bfd..546d5440b3 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/application/berryIWorkbenchWindowConfigurer.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/application/berryIWorkbenchWindowConfigurer.h
@@ -1,376 +1,376 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIWORKBENCHWINDOWCONFIGURER_H_
#define BERRYIWORKBENCHWINDOWCONFIGURER_H_
#include <berryMacros.h>
#include <org_blueberry_ui_Export.h>
#include "berryShell.h"
#include "berryIMemento.h"
#include "berryPoint.h"
#include "berryIDropTargetListener.h"
namespace berry
{
struct IWorkbenchConfigurer;
struct IWorkbenchWindow;
/**
* Interface providing special access for configuring workbench windows.
* <p>
* %Window configurer objects are in 1-1 correspondence with the workbench
* windows they configure. Clients may use <code>Get/SetData</code> to
* associate arbitrary state with the window configurer object.
* </p>
* <p>
* Note that these objects are only available to the main application
* (the plug-in that creates and owns the workbench).
* </p>
* <p>
* This interface is not intended to be implemented by clients.
* </p>
*
* @see IWorkbenchConfigurer#GetWindowConfigurer()
* @see WorkbenchAdvisor#PreWindowOpen()
* @note This interface is not intended to be implemented by clients.
*/
struct BERRY_UI IWorkbenchWindowConfigurer : public Object {
berryInterfaceMacro(IWorkbenchWindowConfigurer, berry);
~IWorkbenchWindowConfigurer();
/**
* Returns the underlying workbench window.
*
* @return the workbench window
*/
virtual SmartPointer<IWorkbenchWindow> GetWindow() = 0;
/**
* Returns the workbench configurer.
*
* @return the workbench configurer
*/
virtual SmartPointer<IWorkbenchConfigurer> GetWorkbenchConfigurer() = 0;
/*
* Returns the action bar configurer for this workbench
* window.
*
* @return the action bar configurer
*/
//virtual IActionBarConfigurer GetActionBarConfigurer() = 0;
/**
* Returns the title of the underlying workbench window.
*
* @return the window title
*/
virtual std::string GetTitle() = 0;
/**
* Sets the title of the underlying workbench window.
*
* @param title the window title
*/
virtual void SetTitle(const std::string& title) = 0;
/**
* Returns whether the underlying workbench window has a menu bar.
* <p>
* The initial value is <code>true</code>.
* </p>
*
* @return <code>true</code> for a menu bar, and <code>false</code>
* for no menu bar
*/
virtual bool GetShowMenuBar() = 0;
/**
* Sets whether the underlying workbench window has a menu bar.
*
* @param show <code>true</code> for a menu bar, and <code>false</code>
* for no menu bar
*/
virtual void SetShowMenuBar(bool show) = 0;
/**
* Returns whether the underlying workbench window has a cool bar.
* <p>
* The initial value is <code>true</code>.
* </p>
*
* @return <code>true</code> for a cool bar, and <code>false</code>
* for no cool bar
*/
virtual bool GetShowCoolBar() = 0;
/**
* Sets whether the underlying workbench window has a cool bar.
*
* @param show <code>true</code> for a cool bar, and <code>false</code>
* for no cool bar
*/
virtual void SetShowCoolBar(bool show) = 0;
/**
* Returns whether the underlying workbench window has a status line.
* <p>
* The initial value is <code>true</code>.
* </p>
*
* @return <code>true</code> for a status line, and <code>false</code>
* for no status line
*/
virtual bool GetShowStatusLine() = 0;
/**
* Sets whether the underlying workbench window has a status line.
*
* @param show <code>true</code> for a status line, and <code>false</code>
* for no status line
*/
virtual void SetShowStatusLine(bool show) = 0;
/**
* Returns whether the underlying workbench window has a perspective bar (the
* perspective bar provides buttons to quickly switch between perspectives).
* <p>
* The initial value is <code>false</code>.
* </p>
*
* @return <code>true</code> for a perspective bar, and <code>false</code>
* for no perspective bar
*/
virtual bool GetShowPerspectiveBar() = 0;
/**
* Sets whether the underlying workbench window has a perspective bar (the
* perspective bar provides buttons to quickly switch between perspectives).
*
* @param show <code>true</code> for a perspective bar, and
* <code>false</code> for no perspective bar
*/
virtual void SetShowPerspectiveBar(bool show) = 0;
/**
* Returns whether the underlying workbench window has a progress indicator.
* <p>
* The initial value is <code>false</code>.
* </p>
*
* @return <code>true</code> for a progress indicator, and <code>false</code>
* for no progress indicator
*/
virtual bool GetShowProgressIndicator() = 0;
/**
* Sets whether the underlying workbench window has a progress indicator.
*
* @param show <code>true</code> for a progress indicator, and <code>false</code>
* for no progress indicator
*/
virtual void SetShowProgressIndicator(bool show) = 0;
/**
* Returns the style bits to use for the window's shell when it is created.
* The default is <code>SWT.SHELL_TRIM</code>.
*
* @return the shell style bits
*/
virtual int GetShellStyle() = 0;
/**
* Sets the style bits to use for the window's shell when it is created.
* This method has no effect after the shell is created.
* That is, it must be called within the <code>WorkbenchAdvisor#PreWindowOpen()</code>
* callback.
* <p>
* For more details on the applicable shell style bits, see the
* documentation for Shell.
* </p>
*
* @param shellStyle the shell style bits
*/
virtual void SetShellStyle(int shellStyle) = 0;
/**
* Returns the size to use for the window's shell when it is created.
*
* @return the initial size to use for the shell
*/
virtual Point GetInitialSize() = 0;
/**
* Sets the size to use for the window's shell when it is created.
* This method has no effect after the shell is created.
* That is, it must be called within the <code>WorkbenchAdvisor#PreWindowOpen()</code>
* callback.
*
* @param initialSize the initial size to use for the shell
*/
virtual void SetInitialSize(Point initialSize) = 0;
/*
* Returns the data associated with this workbench window at the given key.
*
* @param key the key
* @return the data, or <code>null</code> if there is no data at the given
* key
*/
//virtual Object getData(String key);
/*
* Sets the data associated with this workbench window at the given key.
*
* @param key the key
* @param data the data, or <code>null</code> to delete existing data
*/
//virtual void setData(String key, Object data);
/**
* Adds the given drag and drop Mime types to the ones
* supported for drag and drop on the editor area of this workbench window.
* <p>
* The workbench advisor would ordinarily call this method from the
* <code>PreWindowOpen</code> callback.
* A newly-created workbench window supports no drag and drop transfer
* types.
* </p>
* <p>
* Note that drag and drop to the editor area requires adding one or more
* transfer types (using <code>AddEditorAreaTransfer</code>) and
* configuring a drop target listener
* (with <code>ConfigureEditorAreaDropListener</code>)
* capable of handling any of those transfer types.
* </p>
*
* @param transfer a drag and drop transfer object
* @see #configureEditorAreaDropListener
* @see org.blueberry.ui.part.EditorInputTransfer
*/
virtual void AddEditorAreaTransfer(const QStringList& transferTypes) = 0;
/**
* Configures the drop target listener for the editor area of this workbench window.
* <p>
* The workbench advisor ordinarily calls this method from the
* <code>PreWindowOpen</code> callback.
* A newly-created workbench window has no configured drop target listener for its
* editor area.
* </p>
* <p>
* Note that drag and drop to the editor area requires adding one or more
* transfer types (using <code>AddEditorAreaTransfer</code>) and
* configuring a drop target listener
* (with <code>ConfigureEditorAreaDropListener</code>)
* capable of handling any of those transfer types.
* </p>
*
* @param dropTargetListener the drop target listener that will handle
* requests to drop an object on to the editor area of this window
*
* @see #AddEditorAreaTransfer
*/
virtual void ConfigureEditorAreaDropListener(const IDropTargetListener::Pointer& dropTargetListener) = 0;
/*
* Creates the menu bar for the window's shell.
* <p>
* This should only be called if the advisor is defining custom window contents
* in <code>createWindowContents</code>, and may only be called once.
* The caller must set it in the shell using <code>Shell.setMenuBar(Menu)</code>
* but must not make add, remove or change items in the result.
* The menu bar is populated by the window's menu manager.
* The application can add to the menu manager in the advisor's
* <code>fillActionBars</code> method instead.
* </p>
*
* @return the menu bar, suitable for setting in the shell
*/
//virtual Menu createMenuBar();
/*
* Creates the cool bar control.
* <p>
* This should only be called if the advisor is defining custom window contents
* in <code>createWindowContents</code>, and may only be called once.
* The caller must lay out the cool bar appropriately within the parent,
* but must not add, remove or change items in the result (hence the
* return type of <code>Control</code>).
* The cool bar is populated by the window's cool bar manager.
* The application can add to the cool bar manager in the advisor's
* <code>fillActionBars</code> method instead.
* </p>
*
* @param parent the parent composite
* @return the cool bar control, suitable for laying out in the parent
*/
//virtual Control createCoolBarControl(Composite parent);
/*
* Creates the status line control.
* <p>
* This should only be called if the advisor is defining custom window contents
* in <code>createWindowContents</code>, and may only be called once.
* The caller must lay out the status line appropriately within the parent,
* but must not add, remove or change items in the result (hence the
* return type of <code>Control</code>).
* The status line is populated by the window's status line manager.
* The application can add to the status line manager in the advisor's
* <code>fillActionBars</code> method instead.
* </p>
*
* @param parent the parent composite
* @return the status line control, suitable for laying out in the parent
*/
//virtual Control createStatusLineControl(Composite parent);
/**
* Creates the page composite, in which the window's pages, and their
* views and editors, appear.
* <p>
* This should only be called if the advisor is defining custom window contents
* in <code>WorkbenchWindowAdvisor#CreateWindowContents()</code>, and may only be called once.
* The caller must lay out the page composite appropriately within the parent,
* but must not add, remove or change items in the result.
* The page composite is populated by the workbench.
* </p>
*
* @param parent the parent composite
* @return the page composite, suitable for laying out in the parent
*/
virtual void* CreatePageComposite(void* parent) = 0;
/**
* Saves the current state of the window using the specified memento.
*
* @param memento the memento in which to save the window's state
* @return a status object indicating whether the save was successful
* @see IWorkbenchConfigurer#RestoreWorkbenchWindow(IMemento::Pointer)
*/
virtual bool SaveState(IMemento::Pointer memento) = 0;
};
}
#endif /*BERRYIWORKBENCHWINDOWCONFIGURER_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/application/berryWorkbenchAdvisor.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/application/berryWorkbenchAdvisor.cpp
index 3f17a6ddac..34b97135fc 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/application/berryWorkbenchAdvisor.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/application/berryWorkbenchAdvisor.cpp
@@ -1,170 +1,170 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryWorkbenchAdvisor.h"
#include <Poco/Exception.h>
namespace berry
{
WorkbenchAdvisor::WorkbenchAdvisor()
{
// do nothing
}
WorkbenchAdvisor::~WorkbenchAdvisor()
{
}
void WorkbenchAdvisor::InternalBasicInitialize(IWorkbenchConfigurer::Pointer configurer)
{
if (workbenchConfigurer.IsNotNull())
{
throw Poco::IllegalStateException();
}
this->workbenchConfigurer = configurer;
this->Initialize(configurer);
}
void WorkbenchAdvisor::Initialize(IWorkbenchConfigurer::Pointer /*configurer*/)
{
// do nothing
}
IWorkbenchConfigurer::Pointer WorkbenchAdvisor::GetWorkbenchConfigurer()
{
return workbenchConfigurer;
}
void WorkbenchAdvisor::PreStartup()
{
// do nothing
}
void WorkbenchAdvisor::PostStartup()
{
// do nothing
}
bool WorkbenchAdvisor::PreShutdown()
{
return true;
}
void WorkbenchAdvisor::PostShutdown()
{
// do nothing
}
IAdaptable* WorkbenchAdvisor::GetDefaultPageInput()
{
// default: no input
return 0;
}
std::string WorkbenchAdvisor::GetMainPreferencePageId()
{
// default: no opinion
return "";
}
bool WorkbenchAdvisor::OpenWindows()
{
// final Display display = PlatformUI.getWorkbench().getDisplay();
// final boolean result [] = new boolean[1];
//
// // spawn another init thread. For API compatibility We guarantee this method is called from
// // the UI thread but it could take enough time to disrupt progress reporting.
// // spawn a new thread to do the grunt work of this initialization and spin the event loop
// // ourselves just like it's done in Workbench.
// final boolean[] initDone = new boolean[]{false};
// final Throwable [] error = new Throwable[1];
// Thread initThread = new Thread() {
// /* (non-Javadoc)
// * @see java.lang.Thread#run()
// */
// void run() {
// try {
// //declare us to be a startup thread so that our syncs will be executed
// UISynchronizer.startupThread.set(Boolean.TRUE);
// final IWorkbenchConfigurer [] myConfigurer = new IWorkbenchConfigurer[1];
// StartupThreading.runWithoutExceptions(new StartupRunnable() {
//
// void runWithException() throws Throwable {
// myConfigurer[0] = getWorkbenchConfigurer();
//
// }});
//
// IStatus status = myConfigurer[0].restoreState();
// if (!status.isOK()) {
// if (status.getCode() == IWorkbenchConfigurer.RESTORE_CODE_EXIT) {
// result[0] = false;
// return;
// }
// if (status.getCode() == IWorkbenchConfigurer.RESTORE_CODE_RESET) {
// myConfigurer[0].openFirstTimeWindow();
// }
// }
// result[0] = true;
// } catch (Throwable e) {
// error[0] = e;
// }
// finally {
// initDone[0] = true;
// display.wake();
// }
// }};
// initThread.start();
//
// while (true) {
// if (!display.readAndDispatch()) {
// if (initDone[0])
// break;
// display.sleep();
// }
//
// }
//
// // can only be a runtime or error
// if (error[0] instanceof Error)
// throw (Error)error[0];
// else if (error[0] instanceof RuntimeException)
// throw (RuntimeException)error[0];
//
// return result[0];
IWorkbenchConfigurer::Pointer myConfigurer = this->GetWorkbenchConfigurer();
bool status = myConfigurer->RestoreState();
if (!status)
{
myConfigurer->OpenFirstTimeWindow();
}
return true;
}
bool WorkbenchAdvisor::SaveState(IMemento::Pointer /*memento*/)
{
return true;
}
bool WorkbenchAdvisor::RestoreState(IMemento::Pointer /*memento*/)
{
return true;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/application/berryWorkbenchAdvisor.h b/BlueBerry/Bundles/org.blueberry.ui/src/application/berryWorkbenchAdvisor.h
index 6db8034861..10d9e9d23a 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/application/berryWorkbenchAdvisor.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/application/berryWorkbenchAdvisor.h
@@ -1,411 +1,411 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYWORKBENCHADVISOR_H_
#define BERRYWORKBENCHADVISOR_H_
#include <org_blueberry_ui_Export.h>
#include "berryIMemento.h"
#include <berryIAdaptable.h>
#include "berryWorkbenchWindowAdvisor.h"
#include "berryIWorkbenchConfigurer.h"
namespace berry {
/**
* public: base class for configuring the workbench.
* <p>
* Note that the workbench advisor object is created in advance of creating the
* workbench. However, by the time the workbench starts calling methods on this
* class, <code>PlatformUI#GetWorkbench()</code> is guaranteed to have been
* properly initialized.
* </p>
* <p>
* Example of creating and running a workbench (in an
* <code>berry#IApplication</code>):
*
* <pre>
* <code>
* class MyApplication : public %berry::IApplication {
*
* public:
*
* int Start()
* {
* WorkbenchAdvisor* workbenchAdvisor = new MyWorkbenchAdvisor();
* %berry::Display* display = %berry::PlatformUI::CreateDisplay();
* int returnCode = berry::PlatformUI::CreateAndRunWorkbench(display, workbenchAdvisor);
*
* if (returnCode == %PlatformUI::RETURN_RESTART) {
* return %berry::IApplication::EXIT_RESTART;
* } else {
* return %berry::IApplication::EXIT_OK;
* }
* };
* </code>
* </pre>
*
* </p>
* <p>
* An application should declare a subclass of <code>berry::WorkbenchAdvisor</code>
* and override methods to configure the workbench to suit the needs of the
* particular application.
* </p>
* <p>
* The following advisor methods are called at strategic points in the
* workbench's lifecycle (all occur within the dynamic scope of the call to
* <code>PlatformUI#CreateAndRunWorkbench()</code>):
* <ul>
* <li>Initialize() - called first; before any windows; use to
* register things</li>
* <li>PreStartup() - called second; after initialize but before
* first window is opened; use to temporarily disable things during startup or
* restore</li>
* <li>PostStartup() - called third; after first window is opened;
* use to reenable things temporarily disabled in previous step</li>
* <li>EventLoopException() - called to handle the case where the
* event loop has crashed; use to inform the user that things are not well (not implemented yet)</li>
* <li>EventLoopIdle() - called when there are currently no more
* events to be processed; use to perform other work or to yield until new
* events enter the queue (not implemented yet)</li>
* <li>PreShutdown() - called immediately prior to workbench
* shutdown before any windows have been closed; allows the advisor to veto the
* shutdown</li>
* <li>PostShutdown() - called last; after event loop has
* terminated and all windows have been closed; use to deregister things
* registered during initialize</li>
* </ul>
* </p>
*
*/
class BERRY_UI WorkbenchAdvisor {
/**
* The workbench configurer.
*/
private: IWorkbenchConfigurer::Pointer workbenchConfigurer;
/*
* The workbench error handler.
*/
//private: AbstractStatusHandler workbenchErrorHandler;
private: bool introOpened;
/**
* Creates and initializes a new workbench advisor instance.
*/
protected: WorkbenchAdvisor();
virtual ~WorkbenchAdvisor();
/**
* Remembers the configurer and calls <code>Initialize()</code>.
* <p>
* For internal use by the workbench only.
* </p>
*
* @param configurer
* an object for configuring the workbench
*/
public: void InternalBasicInitialize(IWorkbenchConfigurer::Pointer configurer);
/**
* Performs arbitrary initialization before the workbench starts running.
* <p>
* This method is called during workbench initialization prior to any
* windows being opened. Clients must not call this method directly
* (although super calls are okay). The default implementation does nothing.
* Subclasses may override. Typical clients will use the configurer passed
* in to tweak the workbench. If further tweaking is required in the future,
* the configurer may be obtained using <code>GetWorkbenchConfigurer()</code>.
* </p>
*
* @param configurer
* an object for configuring the workbench
*/
public: virtual void Initialize(IWorkbenchConfigurer::Pointer configurer);
/**
* Returns the workbench configurer for the advisor. Can be
* <code>null</code> if the advisor is not initialized yet.
*
* @return the workbench configurer, or <code>null</code> if the advisor
* is not initialized yet
*/
protected: IWorkbenchConfigurer::Pointer GetWorkbenchConfigurer();
/*
* Returns the workbench error handler for the advisor.
*
* @return the workbench error handler
* @since 3.3
*/
// public: AbstractStatusHandler getWorkbenchErrorHandler() {
// if (workbenchErrorHandler == null) {
// workbenchErrorHandler = new WorkbenchErrorHandler();
// }
// return workbenchErrorHandler;
// }
/**
* Performs arbitrary actions just before the first workbench window is
* opened (or restored).
* <p>
* This method is called after the workbench has been initialized and just
* before the first window is about to be opened. Clients must not call this
* method directly (although super calls are okay). The default
* implementation does nothing. Subclasses may override.
* </p>
*/
public: virtual void PreStartup();
/**
* Performs arbitrary actions after the workbench windows have been opened
* (or restored), but before the main event loop is run.
* <p>
* This method is called just after the windows have been opened. Clients
* must not call this method directly (although super calls are okay). The
* default implementation does nothing. Subclasses may override. It is okay
* to call <code>IWorkbench#Close()</code> from this method.
* </p>
*/
public: virtual void PostStartup();
/**
* Performs arbitrary finalization before the workbench is about to shut
* down.
* <p>
* This method is called immediately prior to workbench shutdown before any
* windows have been closed. Clients must not call this method directly
* (although super calls are okay). The default implementation returns
* <code>true</code>. Subclasses may override.
* </p>
* <p>
* The advisor may veto a regular shutdown by returning <code>false</code>,
* although this will be ignored if the workbench is being forced to shut
* down.
* </p>
*
* @return <code>true</code> to allow the workbench to proceed with
* shutdown, <code>false</code> to veto a non-forced shutdown
*/
public: virtual bool PreShutdown();
/**
* Performs arbitrary finalization after the workbench stops running.
* <p>
* This method is called during workbench shutdown after all windows have
* been closed. Clients must not call this method directly (although super
* calls are okay). The default implementation does nothing. Subclasses may
* override.
* </p>
*/
public: virtual void PostShutdown();
/*
* Performs arbitrary actions when the event loop crashes (the code that
* handles a UI event throws an exception that is not caught).
* <p>
* This method is called when the code handling a UI event throws an
* exception. In a perfectly functioning application, this method would
* never be called. In practice, it comes into play when there are bugs in
* the code that trigger unchecked runtime exceptions. It is also activated
* when the system runs short of memory, etc. Fatal errors (ThreadDeath) are
* not passed on to this method, as there is nothing that could be done.
* </p>
* <p>
* Clients must not call this method directly (although super calls are
* okay). The default implementation logs the problem so that it does not go
* unnoticed. Subclasses may override or extend this method. It is generally
* a bad idea to override with an empty method, and you should be especially
* careful when handling Errors.
* </p>
*
* @param exception
* the uncaught exception that was thrown inside the UI event
* loop
*/
// public: void eventLoopException(Throwable exception) {
// // Protection from client doing super(null) call
// if (exception == null) {
// return;
// }
//
// try {
// StatusManager.getManager().handle(
// new Status(IStatus.ERR, WorkbenchPlugin.PI_WORKBENCH,
// "Unhandled event loop exception", exception)); //$NON-NLS-1$
//
// if (WorkbenchPlugin.DEBUG) {
// exception.printStackTrace();
// }
// } catch (Throwable e) {
// // One of the log listeners probably failed. Core should have logged
// // the
// // exception since its the first listener.
// System.err.println("Error while logging event loop exception:"); //$NON-NLS-1$
// exception.printStackTrace();
// System.err.println("Logging exception:"); //$NON-NLS-1$
// e.printStackTrace();
// }
// }
/*
* Performs arbitrary work or yields when there are no events to be
* processed.
* <p>
* This method is called when there are currently no more events on the
* queue to be processed at the moment.
* </p>
* <p>
* Clients must not call this method directly (although super calls are
* okay). The default implementation yields until new events enter the
* queue. Subclasses may override or extend this method. It is generally a
* bad idea to override with an empty method. It is okay to call
* <code>IWorkbench.close()</code> from this method.
* </p>
*
* @param display
* the main display of the workbench UI
*/
// public: void eventLoopIdle(Display display) {
// // default: yield cpu until new events enter the queue
// display.sleep();
// }
/**
* Creates a new workbench window advisor for configuring a new workbench
* window via the given workbench window configurer. Clients should override
* to provide their own window configurer.
*
* @param configurer
* the workbench window configurer
* @return a new workbench window advisor
*/
public: virtual WorkbenchWindowAdvisor* CreateWorkbenchWindowAdvisor(
IWorkbenchWindowConfigurer::Pointer configurer) = 0;
/**
* Returns the default input for newly created workbench pages when the
* input is not explicitly specified.
* <p>
* The default implementation returns <code>null</code>. Subclasses may
* override.
* </p>
*
* @return the default input for a new workbench window page, or
* <code>null</code> if none
*
* @see #CreateWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer::Pointer)
*/
public: virtual IAdaptable* GetDefaultPageInput();
/**
* Returns the id of the perspective to use for the initial workbench
* window, or <code>null</code> if no initial perspective should be shown
* in the initial workbench window.
* <p>
* This method is called during startup when the workbench is creating the
* first new window. Subclasses must implement.
* </p>
* <p>
* If the <code>WorkbenchPreferenceConstants#DEFAULT_PERSPECTIVE_ID</code>
* preference is specified, it supercedes the perspective specified here.
* </p>
*
* @return the id of the perspective for the initial window, or
* <code>null</code> if no initial perspective should be shown
*/
public: virtual std::string GetInitialWindowPerspectiveId() = 0;
/**
* Returns the id of the preference page that should be presented most
* prominently.
* <p>
* The default implementation returns <code>null</code>. Subclasses may
* override.
* </p>
*
* @return the id of the preference page, or <code>null</code> if none
*/
public: virtual std::string GetMainPreferencePageId();
/**
* Opens the workbench windows on startup. The default implementation tries
* to restore the previously saved workbench state using
* <code>IWorkbenchConfigurer#RestoreState()</code>. If there
* was no previously saved state, or if the restore failed, then a
* first-time window is opened using
* IWorkbenchConfigurer#OpenFirstTimeWindow().
*
* @return <code>true</code> to proceed with workbench startup, or
* <code>false</code> to exit
*/
public: virtual bool OpenWindows();
/**
* Saves arbitrary application-specific state information for this workbench
* advisor.
* <p>
* The default implementation simply returns an OK status. Subclasses may
* extend or override.
* </p>
*
* @param memento
* the memento in which to save the advisor's state
* @return a status object indicating whether the save was successful
*/
public: virtual bool SaveState(IMemento::Pointer memento);
/**
* Restores arbitrary application-specific state information for this
* workbench advisor.
* <p>
* The default implementation simply returns an OK status. Subclasses may
* extend or override.
* </p>
*
* @param memento
* the memento from which to restore the advisor's state
* @return a status object indicating whether the restore was successful
*/
public: virtual bool RestoreState(IMemento::Pointer memento);
/*
* Return the contribution comparator for the particular type of
* contribution. The default implementation of this class returns a
* comparator that sorts the items by label.
*
* The contributionType may be one of the constants in
* {@link IContributionService} or it can be a value defined by the user.
*
* @param contributionType
* the contribution type
* @return the comparator, must not return <code>null</code>
* @see IContributionService#GetComparatorFor(const std::string&)
*/
// public: ContributionComparator getComparatorFor(String contributionType) {
// return new ContributionComparator();
// }
};
}
#endif /*BERRYWORKBENCHADVISOR_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/application/berryWorkbenchWindowAdvisor.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/application/berryWorkbenchWindowAdvisor.cpp
index ae69235ae7..66465dc063 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/application/berryWorkbenchWindowAdvisor.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/application/berryWorkbenchWindowAdvisor.cpp
@@ -1,141 +1,141 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryWorkbenchWindowAdvisor.h"
#include <Poco/Bugcheck.h>
#include <berryWorkbenchPreferenceConstants.h>
#include <berryObjects.h>
#include <berryIPreferences.h>
#include "internal/berryWorkbenchWindowConfigurer.h"
#include "internal/berryWorkbenchPlugin.h"
namespace berry
{
IWorkbenchWindowConfigurer::Pointer WorkbenchWindowAdvisor::GetWindowConfigurer()
{
return windowConfigurer;
}
WorkbenchWindowAdvisor::WorkbenchWindowAdvisor(
IWorkbenchWindowConfigurer::Pointer configurer)
{
poco_assert(configurer.IsNotNull());
this->windowConfigurer = configurer;
}
WorkbenchWindowAdvisor::~WorkbenchWindowAdvisor()
{
}
void WorkbenchWindowAdvisor::PreWindowOpen()
{
// do nothing
}
ActionBarAdvisor::Pointer WorkbenchWindowAdvisor::CreateActionBarAdvisor(
IActionBarConfigurer::Pointer configurer)
{
ActionBarAdvisor::Pointer actionBarAdvisor(new ActionBarAdvisor(configurer));
return actionBarAdvisor;
}
void WorkbenchWindowAdvisor::PostWindowRestore()
{
// do nothing
}
void WorkbenchWindowAdvisor::OpenIntro()
{
// TODO: Refactor this into an IIntroManager.openIntro(IWorkbenchWindow) call
// introOpened flag needs to be global
IWorkbenchConfigurer::Pointer wbConfig = GetWindowConfigurer()->GetWorkbenchConfigurer();
std::string key = "introOpened"; //$NON-NLS-1$
ObjectBool::Pointer introOpened = wbConfig->GetData(key).Cast<ObjectBool>();
if (introOpened && introOpened->GetValue())
{
return;
}
wbConfig->SetData(key, ObjectBool::Pointer(new ObjectBool(true)));
IPreferences::Pointer workbenchPrefs = WorkbenchPlugin::GetDefault()->GetPreferencesService()->GetSystemPreferences();
bool showIntro = workbenchPrefs->GetBool(WorkbenchPreferenceConstants::SHOW_INTRO, true);
IIntroManager* introManager = wbConfig->GetWorkbench()->GetIntroManager();
bool hasIntro = introManager->HasIntro();
bool isNewIntroContentAvailable = introManager->IsNewContentAvailable();
if (hasIntro && (showIntro || isNewIntroContentAvailable))
{
introManager
->ShowIntro(GetWindowConfigurer()->GetWindow(), false);
workbenchPrefs->PutBool(WorkbenchPreferenceConstants::SHOW_INTRO, false);
workbenchPrefs->Flush();
}
}
void WorkbenchWindowAdvisor::PostWindowCreate()
{
// do nothing
}
void WorkbenchWindowAdvisor::PostWindowOpen()
{
// do nothing
}
bool WorkbenchWindowAdvisor::PreWindowShellClose()
{
// do nothing, but allow the close() to proceed
return true;
}
void WorkbenchWindowAdvisor::PostWindowClose()
{
// do nothing
}
void WorkbenchWindowAdvisor::CreateWindowContents(Shell::Pointer shell)
{
this->GetWindowConfigurer().Cast<WorkbenchWindowConfigurer>()->CreateDefaultContents(shell);
}
void* WorkbenchWindowAdvisor::CreateEmptyWindowContents(void* /*parent*/)
{
return 0;
}
bool WorkbenchWindowAdvisor::SaveState(IMemento::Pointer /*memento*/)
{
// do nothing
return true;
}
bool WorkbenchWindowAdvisor::RestoreState(IMemento::Pointer /*memento*/)
{
// do nothing
return true;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/application/berryWorkbenchWindowAdvisor.h b/BlueBerry/Bundles/org.blueberry.ui/src/application/berryWorkbenchWindowAdvisor.h
index 7cb2ab6f6f..1cf7f99857 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/application/berryWorkbenchWindowAdvisor.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/application/berryWorkbenchWindowAdvisor.h
@@ -1,261 +1,261 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYWORKBENCHWINDOWADVISOR_H_
#define BERRYWORKBENCHWINDOWADVISOR_H_
#include "berryIMemento.h"
#include "berryShell.h"
#include "berryActionBarAdvisor.h"
#include "berryIActionBarConfigurer.h"
namespace berry
{
/**
* Public base class for configuring a workbench window.
* <p>
* The workbench window advisor object is created in response to a workbench
* window being created (one per window), and is used to configure the window.
* </p>
* <p>
* An application should declare a subclass of <code>WorkbenchWindowAdvisor</code>
* and override methods to configure workbench windows to suit the needs of the
* particular application.
* </p>
* <p>
* The following advisor methods are called at strategic points in the
* workbench window's lifecycle (as with the workbench advisor, all occur
* within the dynamic scope of the call to
* <code>PlatformUI#CreateAndRunWorkbench()</code>):
* <ul>
* <li>PreWindowOpen() - called as the window is being opened;
* use to configure aspects of the window other than actions bars</li>
* <li>PostWindowRestore() - called after the window has been
* recreated from a previously saved state; use to adjust the restored
* window</li>
* <li>PostWindowCreate() - called after the window has been created,
* either from an initial state or from a restored state; used to adjust the
* window</li>
* <li>OpenIntro() - called immediately before the window is opened in
* order to create the introduction component, if any.</li>
* <li>PostWindowOpen() - called after the window has been
* opened; use to hook window listeners, etc.</li>
* <li>PreWindowShellClose() - called when the window's shell
* is closed by the user; use to pre-screen window closings</li>
* </ul>
* </p>
*
*/
class BERRY_UI WorkbenchWindowAdvisor
{
private:
IWorkbenchWindowConfigurer::Pointer windowConfigurer;
protected:
/**
* Returns the workbench window configurer.
*
* @return the workbench window configurer
*/
IWorkbenchWindowConfigurer::Pointer GetWindowConfigurer();
public:
/**
* Creates a new workbench window advisor for configuring a workbench
* window via the given workbench window configurer.
*
* @param configurer an object for configuring the workbench window
*/
WorkbenchWindowAdvisor(IWorkbenchWindowConfigurer::Pointer configurer);
virtual ~WorkbenchWindowAdvisor();
/**
* Performs arbitrary actions before the window is opened.
* <p>
* This method is called before the window's controls have been created.
* Clients must not call this method directly (although super calls are okay).
* The default implementation does nothing. Subclasses may override.
* Typical clients will use the window configurer to tweak the
* workbench window in an application-specific way; however, filling the
* window's menu bar, tool bar, and status line must be done in
* <code>ActionBarAdvisor#FillActionBars()</code>, which is called immediately
* after this method is called.
* </p>
*/
virtual void PreWindowOpen();
/**
* Creates a new action bar advisor to configure the action bars of the window
* via the given action bar configurer.
* The default implementation returns a new instance of <code>ActionBarAdvisor</code>.
*
* @param configurer the action bar configurer for the window
* @return the action bar advisor for the window
*/
virtual ActionBarAdvisor::Pointer CreateActionBarAdvisor(
IActionBarConfigurer::Pointer configurer);
/**
* Performs arbitrary actions after the window has been restored,
* but before it is opened.
* <p>
* This method is called after a previously-saved window has been
* recreated. This method is not called when a new window is created from
* scratch. This method is never called when a workbench is started for the
* very first time, or when workbench state is not saved or restored.
* Clients must not call this method directly (although super calls are okay).
* The default implementation does nothing. Subclasses may override.
* It is okay to call <code>IWorkbench#Close()</code> from this method.
* </p>
*
* @exception WorkbenchException thrown if there are any errors to report
* from post-restoration of the window
*/
virtual void PostWindowRestore();
/**
* Opens the introduction componenet.
* <p>
* Clients must not call this method directly (although super calls are okay).
* The default implementation opens the intro in the first window provided
* if the preference <code>WorkbenchPreferenceConstants#SHOW_INTRO</code> is <code>true</code>. If
* an intro is shown then this preference will be set to <code>false</code>.
* Subsequently, and intro will be shown only if
* <code>WorkbenchConfigurer#GetSaveAndRestore()</code> returns
* <code>true</code> and the introduction was visible on last shutdown.
* Subclasses may override.
* </p>
*/
virtual void OpenIntro();
/**
* Performs arbitrary actions after the window has been created (possibly
* after being restored), but has not yet been opened.
* <p>
* This method is called after the window has been created from scratch,
* or when it has been restored from a previously-saved window. In the latter case,
* this method is called after <code>PostWindowRestore()</code>.
* Clients must not call this method directly (although super calls are okay).
* The default implementation does nothing. Subclasses may override.
* </p>
*/
virtual void PostWindowCreate();
/**
* Performs arbitrary actions after the window has been opened (possibly
* after being restored).
* <p>
* This method is called after the window has been opened. This method is
* called after the window has been created from scratch, or when
* it has been restored from a previously-saved window.
* Clients must not call this method directly (although super calls are okay).
* The default implementation does nothing. Subclasses may override.
* </p>
*/
virtual void PostWindowOpen();
/**
* Performs arbitrary actions as the window's shell is being closed
* directly, and possibly veto the close.
* <p>
* This method is called from a <code>IShellListener</code> associated with the window,
* for example when the user clicks the window's close button. It is not
* called when the window is being closed for other reasons, such as if the
* user exits the workbench via the <code>ActionFactory#QUIT</code> action.
* Clients must not call this method directly (although super calls are
* okay). If this method returns <code>false</code>, then the user's
* request to close the shell is ignored. This gives the workbench advisor
* an opportunity to query the user and/or veto the closing of a window
* under some circumstances.
* </p>
*
* @return <code>true</code> to allow the window to close, and
* <code>false</code> to prevent the window from closing
* @see IWorkbenchWindow#Close()
* @see WorkbenchAdvisor#PreShutdown()
*/
virtual bool PreWindowShellClose();
/**
* Performs arbitrary actions after the window is closed.
* <p>
* This method is called after the window's controls have been disposed.
* Clients must not call this method directly (although super calls are
* okay). The default implementation does nothing. Subclasses may override.
* </p>
*/
virtual void PostWindowClose();
/**
* Creates the contents of the window.
* <p>
* The default implementation adds a menu bar, a cool bar, a status line,
* a perspective bar, and a fast view bar. The visibility of these controls
* can be configured using the <code>SetShow*</code> methods on
* IWorkbenchWindowConfigurer.
* </p>
* <p>
* Subclasses may override to define custom window contents and layout,
* but must call <code>IWorkbenchWindowConfigurer#CreatePageComposite()</code>.
* </p>
*
* @param shell the window's shell
* @see IWorkbenchWindowConfigurer#CreateMenuBar()
* @see IWorkbenchWindowConfigurer#CreateCoolBarControl()
* @see IWorkbenchWindowConfigurer#CreateStatusLineControl()
* @see IWorkbenchWindowConfigurer#CreatePageComposite()
*/
virtual void CreateWindowContents(Shell::Pointer shell);
/**
* Creates and returns the control to be shown when the window has no open pages.
* If <code>null</code> is returned, the default window background is shown.
* <p>
* The default implementation returns <code>null</code>.
* Subclasses may override.
* </p>
*
* @param parent the parent composite
* @return the control or <code>null</code>
*/
virtual void* CreateEmptyWindowContents(void* parent);
/**
* Saves arbitrary application specific state information.
*
* @param memento the storage area for object's state
* @return a status object indicating whether the save was successful
*/
virtual bool SaveState(IMemento::Pointer memento);
/**
* Restores arbitrary application specific state information.
*
* @param memento the storage area for object's state
* @return a status object indicating whether the restore was successful
*/
virtual bool RestoreState(IMemento::Pointer memento);
};
}
#endif /*BERRYWORKBENCHWINDOWADVISOR_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryAbstractSourceProvider.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/berryAbstractSourceProvider.cpp
index e67adf8cb9..9de3c32e39 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryAbstractSourceProvider.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryAbstractSourceProvider.cpp
@@ -1,75 +1,75 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include <berryLog.h>
#include "berryAbstractSourceProvider.h"
#include "services/berryIServiceLocator.h"
#include <Poco/Exception.h>
namespace berry
{
bool AbstractSourceProvider::DEBUG = true; //Policy.DEBUG_SOURCES;
void AbstractSourceProvider::FireSourceChanged(int sourcePriority,
const std::string& sourceName, Object::Pointer sourceValue)
{
sourceEvents.singleSourceChanged(sourcePriority, sourceName, sourceValue);
}
void AbstractSourceProvider::FireSourceChanged(int sourcePriority,
const std::map<std::string, Object::Pointer>& sourceValuesByName)
{
sourceEvents.multipleSourcesChanged(sourcePriority, sourceValuesByName);
}
void AbstractSourceProvider::LogDebuggingInfo(const std::string& message)
{
if (DEBUG && (message != ""))
{
BERRY_INFO << "SOURCES" << " >>> " << message;
}
}
void AbstractSourceProvider::AddSourceProviderListener(
ISourceProviderListener::Pointer listener)
{
if (listener == 0)
{
throw Poco::NullPointerException("The listener cannot be null"); //$NON-NLS-1$
}
sourceEvents.AddListener(listener);
}
void AbstractSourceProvider::RemoveSourceProviderListener(
ISourceProviderListener::Pointer listener)
{
if (listener == 0)
{
throw Poco::NullPointerException("The listener cannot be null"); //$NON-NLS-1$
}
sourceEvents.RemoveListener(listener);
}
void AbstractSourceProvider::Initialize(IServiceLocator::ConstPointer /*locator*/)
{
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryAbstractSourceProvider.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryAbstractSourceProvider.h
index 92c1ec224c..e4dacd716f 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryAbstractSourceProvider.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryAbstractSourceProvider.h
@@ -1,117 +1,117 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYABSTRACTSOURCEPROVIDER_H_
#define BERRYABSTRACTSOURCEPROVIDER_H_
#include "berryISourceProvider.h"
namespace berry {
struct IServiceLocator;
/**
* <p>
* An implementation of <code>ISourceProvider</code> that provides listener
* support. Subclasses need only call <code>fireSourceChanged</code> whenever
* appropriate.
* </p>
*
* @since 3.1
*/
class AbstractSourceProvider : public ISourceProvider {
protected:
/**
* Whether source providers should print out debugging information to the
* console when events arrive.
*
* @since 3.2
*/
static bool DEBUG; // = Policy.DEBUG_SOURCES;
/**
* Notifies all listeners that a single source has changed.
*
* @param sourcePriority
* The source priority that has changed.
* @param sourceName
* The name of the source that has changed; must not be
* <code>null</code>.
* @param sourceValue
* The new value for the source; may be <code>null</code>.
*/
void FireSourceChanged(int sourcePriority,
const std::string& sourceName, Object::Pointer sourceValue);
/**
* Notifies all listeners that multiple sources have changed.
*
* @param sourcePriority
* The source priority that has changed.
* @param sourceValuesByName
* The map of source names (<code>String</code>) to source
* values (<code>Object</code>) that have changed; must not
* be <code>null</code>. The names must not be
* <code>null</code>, but the values may be <code>null</code>.
*/
void FireSourceChanged(int sourcePriority,
const std::map<std::string, Object::Pointer>& sourceValuesByName);
/**
* Logs a debugging message in an appropriate manner. If the message is
* <code>null</code> or the <code>DEBUG</code> is <code>false</code>,
* then this method does nothing.
*
* @param message
* The debugging message to log; if <code>null</code>, then
* nothing is logged.
* @since 3.2
*/
void LogDebuggingInfo(const std::string& message);
private:
ISourceProviderListener::Events sourceEvents;
public:
void AddSourceProviderListener(ISourceProviderListener::Pointer listener);
void RemoveSourceProviderListener(
ISourceProviderListener::Pointer listener);
/**
* This method is called when the source provider is instantiated by
* <code>org.blueberry.ui.services</code>. Clients may override this method
* to perform initialization.
*
* @param locator
* The global service locator. It can be used to retrieve
* services like the IContextService
* @since 3.4
*/
void Initialize(SmartPointer<const IServiceLocator> locator);
};
}
#endif /* BERRYABSTRACTSOURCEPROVIDER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryAbstractUICTKPlugin.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/berryAbstractUICTKPlugin.cpp
index eb918fa9ee..f18c5db8e1 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryAbstractUICTKPlugin.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryAbstractUICTKPlugin.cpp
@@ -1,264 +1,264 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryAbstractUICTKPlugin.h"
#include "internal/berryBundleUtility.h"
#include "internal/berryWorkbenchPlugin.h"
#include "berryImageDescriptor.h"
#include "berryPlatformUI.h"
#include <QIcon>
#include <QImage>
namespace berry
{
const std::string AbstractUICTKPlugin::FN_DIALOG_SETTINGS = "dialog_settings.xml";
AbstractUICTKPlugin::AbstractUICTKPlugin()
{
}
// IDialogSettings getDialogSettings() {
// if (dialogSettings == null) {
// loadDialogSettings();
// }
// return dialogSettings;
// }
// ImageRegistry getImageRegistry() {
// if (imageRegistry == null) {
// imageRegistry = createImageRegistry();
// initializeImageRegistry(imageRegistry);
// }
// return imageRegistry;
// }
IPreferencesService::Pointer AbstractUICTKPlugin::GetPreferencesService()
{
// Create the preference store lazily.
if (preferencesService == 0)
{
preferencesService = Platform::GetServiceRegistry().GetServiceById<
IPreferencesService> (IPreferencesService::ID);
}
return preferencesService;
}
IWorkbench* AbstractUICTKPlugin::GetWorkbench()
{
return PlatformUI::GetWorkbench();
}
// ImageRegistry createImageRegistry()
// {
//
// //If we are in the UI Thread use that
// if (Display.getCurrent() != null)
// {
// return new ImageRegistry(Display.getCurrent());
// }
//
// if (PlatformUI.isWorkbenchRunning())
// {
// return new ImageRegistry(PlatformUI.getWorkbench().getDisplay());
// }
//
// //Invalid thread access if it is not the UI Thread
// //and the workbench is not created.
// throw new SWTError(SWT.ERROR_THREAD_INVALID_ACCESS);
// }
// void initializeImageRegistry(ImageRegistry reg) {
// // spec'ed to do nothing
// }
// void loadDialogSettings() {
// dialogSettings = new DialogSettings("Workbench"); //$NON-NLS-1$
//
// // bug 69387: The instance area should not be created (in the call to
// // #getStateLocation) if -data @none or -data @noDefault was used
// IPath dataLocation = getStateLocationOrNull();
// if (dataLocation != null) {
// // try r/w state area in the local file system
// String readWritePath = dataLocation.append(FN_DIALOG_SETTINGS)
// .toOSString();
// File settingsFile = new File(readWritePath);
// if (settingsFile.exists()) {
// try {
// dialogSettings.load(readWritePath);
// } catch (IOException e) {
// // load failed so ensure we have an empty settings
// dialogSettings = new DialogSettings("Workbench"); //$NON-NLS-1$
// }
//
// return;
// }
// }
//
// // otherwise look for bundle specific dialog settings
// URL dsURL = BundleUtility.find(getBundle(), FN_DIALOG_SETTINGS);
// if (dsURL == null) {
// return;
// }
//
// InputStream is = null;
// try {
// is = dsURL.openStream();
// BufferedReader reader = new BufferedReader(
// new InputStreamReader(is, "utf-8")); //$NON-NLS-1$
// dialogSettings.load(reader);
// } catch (IOException e) {
// // load failed so ensure we have an empty settings
// dialogSettings = new DialogSettings("Workbench"); //$NON-NLS-1$
// } finally {
// try {
// if (is != null) {
// is.close();
// }
// } catch (IOException e) {
// // do nothing
// }
// }
// }
// void refreshPluginActions() {
// // If the workbench is not started yet, or is no longer running, do nothing.
// if (!PlatformUI.isWorkbenchRunning()) {
// return;
// }
//
// // startup() is not guaranteed to be called in the UI thread,
// // but refreshPluginActions must run in the UI thread,
// // so use asyncExec. See bug 6623 for more details.
// Display.getDefault().asyncExec(new Runnable() {
// public void run() {
// WWinPluginAction.refreshActionList();
// }
// });
// }
// void saveDialogSettings() {
// if (dialogSettings == null) {
// return;
// }
//
// try {
// IPath path = getStateLocationOrNull();
// if(path == null) {
// return;
// }
// String readWritePath = path
// .append(FN_DIALOG_SETTINGS).toOSString();
// dialogSettings.save(readWritePath);
// } catch (IOException e) {
// // spec'ed to ignore problems
// } catch (IllegalStateException e) {
// // spec'ed to ignore problems
// }
// }
void AbstractUICTKPlugin::start(ctkPluginContext* context)
{
Q_UNUSED(context)
// Should only attempt refreshPluginActions() once the bundle
// has been fully started. Otherwise, action delegates
// can be created while in the process of creating
// a triggering action delegate (if UI events are processed during startup).
// Also, if the start throws an exception, the bundle will be shut down.
// We don't want to have created any delegates if this happens.
// See bug 63324 for more details.
// bundleListener = new BundleListener()
// {
// public void bundleChanged(BundleEvent event)
// {
// if (event.getBundle() == getBundle())
// {
// if (event.getType() == BundleEvent.STARTED)
// {
// // We're getting notified that the bundle has been started.
// // Make sure it's still active. It may have been shut down between
// // the time this event was queued and now.
// if (getBundle().getState() == Bundle.ACTIVE)
// {
// refreshPluginActions();
// }
// fc.removeBundleListener(this);
// }
// }
// }
// };
// context.addBundleListener(bundleListener);
// bundleListener is removed in stop(BundleContext)
}
void AbstractUICTKPlugin::stop(ctkPluginContext* context)
{
Q_UNUSED(context)
// try
// {
// if (bundleListener != null)
// {
// context.removeBundleListener(bundleListener);
// }
// saveDialogSettings();
// savePreferenceStore();
// preferenceStore = null;
// if (imageRegistry != null)
// imageRegistry.dispose();
// imageRegistry = null;
//}
}
SmartPointer<ImageDescriptor> AbstractUICTKPlugin::ImageDescriptorFromPlugin(
const std::string& pluginId, const std::string& imageFilePath)
{
if (pluginId.empty() || imageFilePath.empty())
{
throw Poco::InvalidArgumentException();
}
// if the plug-in is not ready then there is no image
QSharedPointer<ctkPlugin> plugin = BundleUtility::FindPlugin(QString::fromStdString(pluginId));
if (!BundleUtility::IsReady(plugin))
{
return ImageDescriptor::Pointer(0);
}
QByteArray imgContent = plugin->getResource(QString::fromStdString(imageFilePath));
QImage image = QImage::fromData(imgContent);
QPixmap pixmap = QPixmap::fromImage(image);
QIcon* icon = new QIcon(pixmap);
if (icon->isNull())
return ImageDescriptor::Pointer(0);
return ImageDescriptor::CreateFromImage(icon);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryAbstractUICTKPlugin.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryAbstractUICTKPlugin.h
index 424157eb93..ae8ee9c2a6 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryAbstractUICTKPlugin.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryAbstractUICTKPlugin.h
@@ -1,326 +1,326 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYABSTRACTUICTKPLUGIN_H_
#define BERRYABSTRACTUICTKPLUGIN_H_
#include <ctkPluginActivator.h>
#include <berryIPreferencesService.h>
#include "berryIWorkbench.h"
namespace berry {
/**
* \ingroup org_blueberry_ui
*
* Abstract base class for plug-ins that integrate with the BlueBerry platform UI.
* <p>
* Subclasses obtain the following capabilities:
* </p>
* <p>
* Preferences
* <ul>
* <li> The platform core runtime contains general support for plug-in
* preferences (<code>org.blueberry.core.runtime.Preferences</code>).
* This class provides appropriate conversion to the older JFace preference
* API (<code>org.blueberry.jface.preference.IPreferenceStore</code>).</li>
* <li> The method <code>getPreferenceStore</code> returns the JFace preference
* store (cf. <code>Plugin.getPluginPreferences</code> which returns
* a core runtime preferences object.</li>
* <li> Subclasses may reimplement <code>initializeDefaultPreferences</code>
* to set up any default values for preferences using JFace API. In this
* case, <code>initializeDefaultPluginPreferences</code> should not be
* overridden.</li>
* <li> Subclasses may reimplement
* <code>initializeDefaultPluginPreferences</code> to set up any default
* values for preferences using core runtime API. In this
* case, <code>initializeDefaultPreferences</code> should not be
* overridden.</li>
* <li> Preferences are also saved automatically on plug-in shutdown.
* However, saving preferences immediately after changing them is
* strongly recommended, since that ensures that preference settings
* are not lost even in the event of a platform crash.</li>
* </ul>
* Dialogs
* <ul>
* <li> The dialog store is read the first time <code>getDialogSettings</code>
* is called.</li>
* <li> The dialog store allows the plug-in to "record" important choices made
* by the user in a wizard or dialog, so that the next time the
* wizard/dialog is used the widgets can be defaulted to better values. A
* wizard could also use it to record the last 5 values a user entered into
* an editable combo - to show "recent values". </li>
* <li> The dialog store is found in the file whose name is given by the
* constant <code>FN_DIALOG_STORE</code>. A dialog store file is first
* looked for in the plug-in's read/write state area; if not found there,
* the plug-in's install directory is checked.
* This allows a plug-in to ship with a read-only copy of a dialog store
* file containing initial values for certain settings.</li>
* <li> Plug-in code can call <code>saveDialogSettings</code> to cause settings to
* be saved in the plug-in's read/write state area. A plug-in may opt to do
* this each time a wizard or dialog is closed to ensure the latest
* information is always safe on disk. </li>
* <li> Dialog settings are also saved automatically on plug-in shutdown.</li>
* </ul>
* Images
* <ul>
* <li> A typical UI plug-in will have some images that are used very frequently
* and so need to be cached and shared. The plug-in's image registry
* provides a central place for a plug-in to store its common images.
* Images managed by the registry are created lazily as needed, and will be
* automatically disposed of when the plug-in shuts down. Note that the
* number of registry images should be kept to a minimum since many OSs
* have severe limits on the number of images that can be in memory at once.
* </ul>
* <p>
* For easy access to your plug-in object, use the singleton pattern. Declare a
* static variable in your plug-in class for the singleton. Store the first
* (and only) instance of the plug-in class in the singleton when it is created.
* Then access the singleton when needed through a static <code>getDefault</code>
* method.
* </p>
* <p>
* See the description on {@link Plugin}.
* </p>
*/
class BERRY_UI AbstractUICTKPlugin : public ctkPluginActivator {
private:
/**
* The name of the dialog settings file (value
* <code>"dialog_settings.xml"</code>).
*/
static const std::string FN_DIALOG_SETTINGS;
/**
* Storage for dialog and wizard data; <code>null</code> if not yet
* initialized.
*/
//DialogSettings dialogSettings = null;
/**
* Storage for preferences.
*/
IPreferencesService::Pointer preferencesService;
/**
* The registry for all graphic images; <code>null</code> if not yet
* initialized.
*/
//ImageRegistry imageRegistry = null;
/**
* The bundle listener used for kicking off refreshPluginActions().
*/
//BundleListener bundleListener;
public:
/**
* Creates an abstract UI plug-in runtime object.
* <p>
* Plug-in runtime classes are <code>ctkPluginActivator</code>s and so must
* have an default constructor. This method is called by the runtime when
* the associated bundle is being activated.
*/
AbstractUICTKPlugin();
/**
* Returns the dialog settings for this UI plug-in.
* The dialog settings is used to hold persistent state data for the various
* wizards and dialogs of this plug-in in the context of a workbench.
* <p>
* If an error occurs reading the dialog store, an empty one is quietly created
* and returned.
* </p>
* <p>
* Subclasses may override this method but are not expected to.
* </p>
*
* @return the dialog settings
*/
// IDialogSettings getDialogSettings();
/**
* Returns the image registry for this UI plug-in.
* <p>
* The image registry contains the images used by this plug-in that are very
* frequently used and so need to be globally shared within the plug-in. Since
* many OSs have a severe limit on the number of images that can be in memory at
* any given time, a plug-in should only keep a small number of images in their
* registry.
* <p>
* Subclasses should reimplement <code>initializeImageRegistry</code> if they have
* custom graphic images to load.
* </p>
* <p>
* Subclasses may override this method but are not expected to.
* </p>
*
* @return the image registry
*/
// ImageRegistry getImageRegistry();
/**
* Returns the preferences service for this UI plug-in.
* This preferences service is used to hold persistent settings for this plug-in in
* the context of a workbench. Some of these settings will be user controlled,
* whereas others may be internal setting that are never exposed to the user.
* <p>
* If an error occurs reading the preferences service, an empty preference service is
* quietly created, initialized with defaults, and returned.
* </p>
*
* @return the preferences service
*/
IPreferencesService::Pointer GetPreferencesService();
/**
* Returns the Platform UI workbench.
* <p>
* This method exists as a convenience for plugin implementors. The
* workbench can also be accessed by invoking <code>PlatformUI.getWorkbench()</code>.
* </p>
* @return IWorkbench the workbench for this plug-in
*/
IWorkbench* GetWorkbench();
protected:
/**
* Returns a new image registry for this plugin-in. The registry will be
* used to manage images which are frequently used by the plugin-in.
* <p>
* The default implementation of this method creates an empty registry.
* Subclasses may override this method if needed.
* </p>
*
* @return ImageRegistry the resulting registry.
* @see #getImageRegistry
*/
// ImageRegistry createImageRegistry();
/**
* Initializes an image registry with images which are frequently used by the
* plugin.
* <p>
* The image registry contains the images used by this plug-in that are very
* frequently used and so need to be globally shared within the plug-in. Since
* many OSs have a severe limit on the number of images that can be in memory
* at any given time, each plug-in should only keep a small number of images in
* its registry.
* </p><p>
* Implementors should create a JFace image descriptor for each frequently used
* image. The descriptors describe how to create/find the image should it be needed.
* The image described by the descriptor is not actually allocated until someone
* retrieves it.
* </p><p>
* Subclasses may override this method to fill the image registry.
* </p>
* @param reg the registry to initalize
*
* @see #getImageRegistry
*/
// void initializeImageRegistry(ImageRegistry reg);
/**
* Loads the dialog settings for this plug-in.
* The default implementation first looks for a standard named file in the
* plug-in's read/write state area; if no such file exists, the plug-in's
* install directory is checked to see if one was installed with some default
* settings; if no file is found in either place, a new empty dialog settings
* is created. If a problem occurs, an empty settings is silently used.
* <p>
* This framework method may be overridden, although this is typically
* unnecessary.
* </p>
*/
// void loadDialogSettings();
/**
* Refreshes the actions for the plugin.
* This method is called from <code>startup</code>.
* <p>
* This framework method may be overridden, although this is typically
* unnecessary.
* </p>
*/
// void refreshPluginActions();
/**
* Saves this plug-in's dialog settings.
* Any problems which arise are silently ignored.
*/
// void saveDialogSettings();
public:
/**
* The <code>AbstractUIPlugin</code> implementation of this <code>Plugin</code>
* method refreshes the plug-in actions. Subclasses may extend this method,
* but must send super <b>first</b>.
*/
void start(ctkPluginContext* context);
/**
* The <code>AbstractUIPlugin</code> implementation of this <code>Plugin</code>
* method saves this plug-in's preference and dialog stores and shuts down
* its image registry (if they are in use). Subclasses may extend this
* method, but must send super <b>last</b>. A try-finally statement should
* be used where necessary to ensure that <code>super.shutdown()</code> is
* always done.
*/
void stop(ctkPluginContext* context);
/**
* Creates and returns a new image descriptor for an image file located
* within the specified plug-in.
* <p>
* This is a convenience method that simply locates the image file in
* within the plug-in (no image registries are involved). The path is
* relative to the root of the plug-in, and takes into account files
* coming from plug-in fragments. The path may include $arg$ elements.
* However, the path must not have a leading "." or path separator.
* Clients should use a path like "icons/mysample.gif" rather than
* "./icons/mysample.gif" or "/icons/mysample.gif".
* </p>
*
* @param pluginId the id of the plug-in containing the image file;
* <code>null</code> is returned if the plug-in does not exist
* @param imageFilePath the relative path of the image file, relative to the
* root of the plug-in; the path must be legal
* @return an image descriptor, or <code>null</code> if no image
* could be found
* @since 3.0
*/
static SmartPointer<ImageDescriptor> ImageDescriptorFromPlugin(
const std::string& pluginId, const std::string& imageFilePath);
};
} // namespace berry
#endif /*BERRYABSTRACTUICTKPLUGIN_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryAbstractUIPlugin.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/berryAbstractUIPlugin.cpp
index 2aa45e9701..567cfe36cc 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryAbstractUIPlugin.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryAbstractUIPlugin.cpp
@@ -1,254 +1,254 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryAbstractUIPlugin.h"
#include "internal/berryBundleUtility.h"
#include "berryImageDescriptor.h"
#include "berryPlatformUI.h"
namespace berry
{
const std::string AbstractUIPlugin::FN_DIALOG_SETTINGS = "dialog_settings.xml";
AbstractUIPlugin::AbstractUIPlugin()
{
}
// IDialogSettings getDialogSettings() {
// if (dialogSettings == null) {
// loadDialogSettings();
// }
// return dialogSettings;
// }
// ImageRegistry getImageRegistry() {
// if (imageRegistry == null) {
// imageRegistry = createImageRegistry();
// initializeImageRegistry(imageRegistry);
// }
// return imageRegistry;
// }
IPreferencesService::Pointer AbstractUIPlugin::GetPreferencesService()
{
// Create the preference store lazily.
if (preferencesService == 0)
{
preferencesService = Platform::GetServiceRegistry().GetServiceById<
IPreferencesService> (IPreferencesService::ID);
}
return preferencesService;
}
IWorkbench* AbstractUIPlugin::GetWorkbench()
{
return PlatformUI::GetWorkbench();
}
// ImageRegistry createImageRegistry()
// {
//
// //If we are in the UI Thread use that
// if (Display.getCurrent() != null)
// {
// return new ImageRegistry(Display.getCurrent());
// }
//
// if (PlatformUI.isWorkbenchRunning())
// {
// return new ImageRegistry(PlatformUI.getWorkbench().getDisplay());
// }
//
// //Invalid thread access if it is not the UI Thread
// //and the workbench is not created.
// throw new SWTError(SWT.ERROR_THREAD_INVALID_ACCESS);
// }
// void initializeImageRegistry(ImageRegistry reg) {
// // spec'ed to do nothing
// }
// void loadDialogSettings() {
// dialogSettings = new DialogSettings("Workbench"); //$NON-NLS-1$
//
// // bug 69387: The instance area should not be created (in the call to
// // #getStateLocation) if -data @none or -data @noDefault was used
// IPath dataLocation = getStateLocationOrNull();
// if (dataLocation != null) {
// // try r/w state area in the local file system
// String readWritePath = dataLocation.append(FN_DIALOG_SETTINGS)
// .toOSString();
// File settingsFile = new File(readWritePath);
// if (settingsFile.exists()) {
// try {
// dialogSettings.load(readWritePath);
// } catch (IOException e) {
// // load failed so ensure we have an empty settings
// dialogSettings = new DialogSettings("Workbench"); //$NON-NLS-1$
// }
//
// return;
// }
// }
//
// // otherwise look for bundle specific dialog settings
// URL dsURL = BundleUtility.find(getBundle(), FN_DIALOG_SETTINGS);
// if (dsURL == null) {
// return;
// }
//
// InputStream is = null;
// try {
// is = dsURL.openStream();
// BufferedReader reader = new BufferedReader(
// new InputStreamReader(is, "utf-8")); //$NON-NLS-1$
// dialogSettings.load(reader);
// } catch (IOException e) {
// // load failed so ensure we have an empty settings
// dialogSettings = new DialogSettings("Workbench"); //$NON-NLS-1$
// } finally {
// try {
// if (is != null) {
// is.close();
// }
// } catch (IOException e) {
// // do nothing
// }
// }
// }
// void refreshPluginActions() {
// // If the workbench is not started yet, or is no longer running, do nothing.
// if (!PlatformUI.isWorkbenchRunning()) {
// return;
// }
//
// // startup() is not guaranteed to be called in the UI thread,
// // but refreshPluginActions must run in the UI thread,
// // so use asyncExec. See bug 6623 for more details.
// Display.getDefault().asyncExec(new Runnable() {
// public void run() {
// WWinPluginAction.refreshActionList();
// }
// });
// }
// void saveDialogSettings() {
// if (dialogSettings == null) {
// return;
// }
//
// try {
// IPath path = getStateLocationOrNull();
// if(path == null) {
// return;
// }
// String readWritePath = path
// .append(FN_DIALOG_SETTINGS).toOSString();
// dialogSettings.save(readWritePath);
// } catch (IOException e) {
// // spec'ed to ignore problems
// } catch (IllegalStateException e) {
// // spec'ed to ignore problems
// }
// }
void AbstractUIPlugin::Start(IBundleContext::Pointer context)
{
Plugin::Start(context);
// Should only attempt refreshPluginActions() once the bundle
// has been fully started. Otherwise, action delegates
// can be created while in the process of creating
// a triggering action delegate (if UI events are processed during startup).
// Also, if the start throws an exception, the bundle will be shut down.
// We don't want to have created any delegates if this happens.
// See bug 63324 for more details.
// bundleListener = new BundleListener()
// {
// public void bundleChanged(BundleEvent event)
// {
// if (event.getBundle() == getBundle())
// {
// if (event.getType() == BundleEvent.STARTED)
// {
// // We're getting notified that the bundle has been started.
// // Make sure it's still active. It may have been shut down between
// // the time this event was queued and now.
// if (getBundle().getState() == Bundle.ACTIVE)
// {
// refreshPluginActions();
// }
// fc.removeBundleListener(this);
// }
// }
// }
// };
// context.addBundleListener(bundleListener);
// bundleListener is removed in stop(BundleContext)
}
void AbstractUIPlugin::Stop(IBundleContext::Pointer context)
{
// try
// {
// if (bundleListener != null)
// {
// context.removeBundleListener(bundleListener);
// }
// saveDialogSettings();
// savePreferenceStore();
// preferenceStore = null;
// if (imageRegistry != null)
// imageRegistry.dispose();
// imageRegistry = null;
//}
Plugin::Stop(context);
}
SmartPointer<ImageDescriptor> AbstractUIPlugin::ImageDescriptorFromPlugin(
const std::string& pluginId, const std::string& imageFilePath)
{
if (pluginId.empty() || imageFilePath.empty())
{
throw Poco::InvalidArgumentException();
}
// if the bundle is not ready then there is no image
IBundle::Pointer bundle = Platform::GetBundle(pluginId);
if (!BundleUtility::IsReady(bundle))
{
return ImageDescriptor::Pointer(0);
}
return ImageDescriptor::CreateFromFile(imageFilePath, pluginId);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryAbstractUIPlugin.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryAbstractUIPlugin.h
index 0e3fc00588..47494714e1 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryAbstractUIPlugin.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryAbstractUIPlugin.h
@@ -1,337 +1,337 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYABSTRACTUIPLUGIN_H_
#define BERRYABSTRACTUIPLUGIN_H_
#include <berryPlugin.h>
#include <berryIPreferencesService.h>
#include "berryIWorkbench.h"
namespace berry {
/**
* \ingroup org_blueberry_ui
*
* Abstract base class for plug-ins that integrate with the BlueBerry platform UI.
* <p>
* Subclasses obtain the following capabilities:
* </p>
* <p>
* Preferences
* <ul>
* <li> The platform core runtime contains general support for plug-in
* preferences (<code>org.blueberry.core.runtime.Preferences</code>).
* This class provides appropriate conversion to the older JFace preference
* API (<code>org.blueberry.jface.preference.IPreferenceStore</code>).</li>
* <li> The method <code>getPreferenceStore</code> returns the JFace preference
* store (cf. <code>Plugin.getPluginPreferences</code> which returns
* a core runtime preferences object.</li>
* <li> Subclasses may reimplement <code>initializeDefaultPreferences</code>
* to set up any default values for preferences using JFace API. In this
* case, <code>initializeDefaultPluginPreferences</code> should not be
* overridden.</li>
* <li> Subclasses may reimplement
* <code>initializeDefaultPluginPreferences</code> to set up any default
* values for preferences using core runtime API. In this
* case, <code>initializeDefaultPreferences</code> should not be
* overridden.</li>
* <li> Preferences are also saved automatically on plug-in shutdown.
* However, saving preferences immediately after changing them is
* strongly recommended, since that ensures that preference settings
* are not lost even in the event of a platform crash.</li>
* </ul>
* Dialogs
* <ul>
* <li> The dialog store is read the first time <code>getDialogSettings</code>
* is called.</li>
* <li> The dialog store allows the plug-in to "record" important choices made
* by the user in a wizard or dialog, so that the next time the
* wizard/dialog is used the widgets can be defaulted to better values. A
* wizard could also use it to record the last 5 values a user entered into
* an editable combo - to show "recent values". </li>
* <li> The dialog store is found in the file whose name is given by the
* constant <code>FN_DIALOG_STORE</code>. A dialog store file is first
* looked for in the plug-in's read/write state area; if not found there,
* the plug-in's install directory is checked.
* This allows a plug-in to ship with a read-only copy of a dialog store
* file containing initial values for certain settings.</li>
* <li> Plug-in code can call <code>saveDialogSettings</code> to cause settings to
* be saved in the plug-in's read/write state area. A plug-in may opt to do
* this each time a wizard or dialog is closed to ensure the latest
* information is always safe on disk. </li>
* <li> Dialog settings are also saved automatically on plug-in shutdown.</li>
* </ul>
* Images
* <ul>
* <li> A typical UI plug-in will have some images that are used very frequently
* and so need to be cached and shared. The plug-in's image registry
* provides a central place for a plug-in to store its common images.
* Images managed by the registry are created lazily as needed, and will be
* automatically disposed of when the plug-in shuts down. Note that the
* number of registry images should be kept to a minimum since many OSs
* have severe limits on the number of images that can be in memory at once.
* </ul>
* <p>
* For easy access to your plug-in object, use the singleton pattern. Declare a
* static variable in your plug-in class for the singleton. Store the first
* (and only) instance of the plug-in class in the singleton when it is created.
* Then access the singleton when needed through a static <code>getDefault</code>
* method.
* </p>
* <p>
* See the description on {@link Plugin}.
* </p>
*/
class BERRY_UI AbstractUIPlugin : public Plugin {
private:
/**
* The name of the dialog settings file (value
* <code>"dialog_settings.xml"</code>).
*/
static const std::string FN_DIALOG_SETTINGS;
/**
* Storage for dialog and wizard data; <code>null</code> if not yet
* initialized.
*/
//DialogSettings dialogSettings = null;
/**
* Storage for preferences.
*/
IPreferencesService::Pointer preferencesService;
/**
* The registry for all graphic images; <code>null</code> if not yet
* initialized.
*/
//ImageRegistry imageRegistry = null;
/**
* The bundle listener used for kicking off refreshPluginActions().
*
* @since 3.0.1
*/
//BundleListener bundleListener;
public:
/**
* Creates an abstract UI plug-in runtime object.
* <p>
* Plug-in runtime classes are <code>BundleActivators</code> and so must
* have an default constructor. This method is called by the runtime when
* the associated bundle is being activated.
* <p>
* For more details, see <code>Plugin</code>'s default constructor.
*
* @see Plugin#Plugin()
* @since 3.0
*/
AbstractUIPlugin();
/**
* Returns the dialog settings for this UI plug-in.
* The dialog settings is used to hold persistent state data for the various
* wizards and dialogs of this plug-in in the context of a workbench.
* <p>
* If an error occurs reading the dialog store, an empty one is quietly created
* and returned.
* </p>
* <p>
* Subclasses may override this method but are not expected to.
* </p>
*
* @return the dialog settings
*/
// IDialogSettings getDialogSettings();
/**
* Returns the image registry for this UI plug-in.
* <p>
* The image registry contains the images used by this plug-in that are very
* frequently used and so need to be globally shared within the plug-in. Since
* many OSs have a severe limit on the number of images that can be in memory at
* any given time, a plug-in should only keep a small number of images in their
* registry.
* <p>
* Subclasses should reimplement <code>initializeImageRegistry</code> if they have
* custom graphic images to load.
* </p>
* <p>
* Subclasses may override this method but are not expected to.
* </p>
*
* @return the image registry
*/
// ImageRegistry getImageRegistry();
/**
* Returns the preferences service for this UI plug-in.
* This preferences service is used to hold persistent settings for this plug-in in
* the context of a workbench. Some of these settings will be user controlled,
* whereas others may be internal setting that are never exposed to the user.
* <p>
* If an error occurs reading the preferences service, an empty preference service is
* quietly created, initialized with defaults, and returned.
* </p>
*
* @return the preferences service
*/
IPreferencesService::Pointer GetPreferencesService();
/**
* Returns the Platform UI workbench.
* <p>
* This method exists as a convenience for plugin implementors. The
* workbench can also be accessed by invoking <code>PlatformUI.getWorkbench()</code>.
* </p>
* @return IWorkbench the workbench for this plug-in
*/
IWorkbench* GetWorkbench();
protected:
/**
* Returns a new image registry for this plugin-in. The registry will be
* used to manage images which are frequently used by the plugin-in.
* <p>
* The default implementation of this method creates an empty registry.
* Subclasses may override this method if needed.
* </p>
*
* @return ImageRegistry the resulting registry.
* @see #getImageRegistry
*/
// ImageRegistry createImageRegistry();
/**
* Initializes an image registry with images which are frequently used by the
* plugin.
* <p>
* The image registry contains the images used by this plug-in that are very
* frequently used and so need to be globally shared within the plug-in. Since
* many OSs have a severe limit on the number of images that can be in memory
* at any given time, each plug-in should only keep a small number of images in
* its registry.
* </p><p>
* Implementors should create a JFace image descriptor for each frequently used
* image. The descriptors describe how to create/find the image should it be needed.
* The image described by the descriptor is not actually allocated until someone
* retrieves it.
* </p><p>
* Subclasses may override this method to fill the image registry.
* </p>
* @param reg the registry to initalize
*
* @see #getImageRegistry
*/
// void initializeImageRegistry(ImageRegistry reg);
/**
* Loads the dialog settings for this plug-in.
* The default implementation first looks for a standard named file in the
* plug-in's read/write state area; if no such file exists, the plug-in's
* install directory is checked to see if one was installed with some default
* settings; if no file is found in either place, a new empty dialog settings
* is created. If a problem occurs, an empty settings is silently used.
* <p>
* This framework method may be overridden, although this is typically
* unnecessary.
* </p>
*/
// void loadDialogSettings();
/**
* Refreshes the actions for the plugin.
* This method is called from <code>startup</code>.
* <p>
* This framework method may be overridden, although this is typically
* unnecessary.
* </p>
*/
// void refreshPluginActions();
/**
* Saves this plug-in's dialog settings.
* Any problems which arise are silently ignored.
*/
// void saveDialogSettings();
public:
/**
* The <code>AbstractUIPlugin</code> implementation of this <code>Plugin</code>
* method refreshes the plug-in actions. Subclasses may extend this method,
* but must send super <b>first</b>.
* {@inheritDoc}
*
* @since 3.0
*/
void Start(IBundleContext::Pointer context);
/**
* The <code>AbstractUIPlugin</code> implementation of this <code>Plugin</code>
* method saves this plug-in's preference and dialog stores and shuts down
* its image registry (if they are in use). Subclasses may extend this
* method, but must send super <b>last</b>. A try-finally statement should
* be used where necessary to ensure that <code>super.shutdown()</code> is
* always done.
* {@inheritDoc}
*
* @since 3.0
*/
void Stop(IBundleContext::Pointer context);
/**
* Creates and returns a new image descriptor for an image file located
* within the specified plug-in.
* <p>
* This is a convenience method that simply locates the image file in
* within the plug-in (no image registries are involved). The path is
* relative to the root of the plug-in, and takes into account files
* coming from plug-in fragments. The path may include $arg$ elements.
* However, the path must not have a leading "." or path separator.
* Clients should use a path like "icons/mysample.gif" rather than
* "./icons/mysample.gif" or "/icons/mysample.gif".
* </p>
*
* @param pluginId the id of the plug-in containing the image file;
* <code>null</code> is returned if the plug-in does not exist
* @param imageFilePath the relative path of the image file, relative to the
* root of the plug-in; the path must be legal
* @return an image descriptor, or <code>null</code> if no image
* could be found
* @since 3.0
*/
static SmartPointer<ImageDescriptor> ImageDescriptorFromPlugin(
const std::string& pluginId, const std::string& imageFilePath);
};
} // namespace berry
#endif /*BERRYABSTRACTUIPLUGIN_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryAsyncRunnable.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryAsyncRunnable.h
index bf8ec066fc..cd3c7156b1 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryAsyncRunnable.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryAsyncRunnable.h
@@ -1,58 +1,58 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYASYNCRUNNABLE_H_
#define BERRYASYNCRUNNABLE_H_
#include <Poco/ActiveRunnable.h>
namespace berry {
/**
* This class can be used to call a method asynchronously from the UI thread using
* the Display::AsyncExec(Poco::Runnable*) method.
*
*/
template <class ArgType, class OwnerType>
class AsyncRunnable : public Poco::ActiveRunnableBase
{
public:
typedef void (OwnerType::*Callback)(const ArgType&);
AsyncRunnable(OwnerType* pOwner, Callback method, const ArgType& arg):
_pOwner(pOwner),
_method(method),
_arg(arg)
{
poco_check_ptr (pOwner);
}
void run()
{
ActiveRunnableBase::Ptr guard(this, false); // ensure automatic release when done
(_pOwner->*_method)(_arg);
}
private:
OwnerType* _pOwner;
Callback _method;
ArgType _arg;
};
}
#endif /* BERRYASYNCRUNNABLE_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryConstants.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/berryConstants.cpp
index ae24c9aa0f..bc5d0cd535 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryConstants.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryConstants.cpp
@@ -1,52 +1,52 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryConstants.h"
namespace berry
{
const int Constants::NONE = 0;
const int Constants::DEFAULT = -1;
const int Constants::DRAG = 1;
const int Constants::CENTER = 1 << 24;
const int Constants::HORIZONTAL = 1 << 8;
const int Constants::VERTICAL = 1 << 9;
const int Constants::MIN = 1 << 7;
const int Constants::MAX = 1 << 10;
const int Constants::UP = 1 << 7;
const int Constants::TOP = Constants::UP;
const int Constants::DOWN = 1 << 10;
const int Constants::BOTTOM = Constants::DOWN;
const int Constants::LEAD = 1 << 14;
const int Constants::LEFT = Constants::LEAD;
const int Constants::TRAIL = 1 << 17;
const int Constants::RIGHT = Constants::TRAIL;
const int Constants::FILL = 4;
const int Constants::WRAP = 1 << 6;
const int Constants::BORDER = 1 << 11;
const int Constants::CLOSE = 1 << 6;
const int Constants::TOOL = 1 << 2;
const int Constants::RESIZE = 1 << 4;
const int Constants::TITLE = 1 << 5;
const int Constants::SHELL_TRIM = Constants::BORDER| Constants::CLOSE | Constants::TITLE | Constants::MIN | Constants::MAX | Constants::RESIZE;
const int Constants::DIALOG_TRIM = Constants::TITLE | Constants::CLOSE | Constants::BORDER;
const int Constants::MODELESS = 0;
const int Constants::PRIMARY_MODAL = 1 << 15;
const int Constants::APPLICATION_MODAL = 1 << 16;
const int Constants::SYSTEM_MODAL = 1 << 17;
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryConstants.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryConstants.h
index 5a263cc924..7fb4fc527c 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryConstants.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryConstants.h
@@ -1,309 +1,309 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYCONSTANTS_H_
#define BERRYCONSTANTS_H_
#include <org_blueberry_ui_Export.h>
namespace berry
{
struct BERRY_UI Constants
{
/**
* A constant known to be zero (0), typically used in operations
* which take bit flags to indicate that "no bits are set".
*/
static const int NONE; // = 0;
static const int DEFAULT; // = -1
/**
* Indicates that a user-interface component is being dragged,
* for example dragging the thumb of a scroll bar (value is 1).
*/
static const int DRAG; // = 1;
/**
* Style constant for align center behavior (value is 1&lt;&lt;24).
* <p><b>Used By:</b><ul>
* <li><code>Button</code></li>
* <li><code>Label</code></li>
* <li><code>TableColumn</code></li>
* <li><code>FormAttachment</code> in a <code>FormLayout</code></li>
* </ul></p>
*/
static const int CENTER; // = 1 << 24;
/**
* Style constant for horizontal alignment or orientation behavior (value is 1&lt;&lt;8).
* <p><b>Used By:</b><ul>
* <li><code>Label</code></li>
* <li><code>ProgressBar</code></li>
* <li><code>Sash</code></li>
* <li><code>Scale</code></li>
* <li><code>ScrollBar</code></li>
* <li><code>Slider</code></li>
* <li><code>ToolBar</code></li>
* <li><code>FillLayout</code> type</li>
* <li><code>RowLayout</code> type</li>
* </ul></p>
*/
static const int HORIZONTAL; // = 1 << 8;
/**
* Style constant for vertical alignment or orientation behavior (value is 1&lt;&lt;9).
* <p><b>Used By:</b><ul>
* <li><code>Label</code></li>
* <li><code>ProgressBar</code></li>
* <li><code>Sash</code></li>
* <li><code>Scale</code></li>
* <li><code>ScrollBar</code></li>
* <li><code>Slider</code></li>
* <li><code>ToolBar</code></li>
* <li><code>CoolBar</code></li>
* <li><code>FillLayout</code> type</li>
* <li><code>RowLayout</code> type</li>
* </ul></p>
*/
static const int VERTICAL; // = 1 << 9;
/**
* Style constant for minimize box trim (value is 1&lt;&lt;7).
* <p><b>Used By:</b><ul>
* <li><code>Decorations</code> and subclasses</li>
* </ul></p>
*/
static const int MIN; // = 1 << 7;
/**
* Style constant for maximize box trim (value is 1&lt;&lt;10).
* <p><b>Used By:</b><ul>
* <li><code>Decorations</code> and subclasses</li>
* </ul></p>
*/
static const int MAX; // = 1 << 10;
/**
* Style constant for align up behavior (value is 1&lt;&lt;7,
* since align UP and align TOP are considered the same).
* <p><b>Used By:</b><ul>
* <li><code>Button</code> with <code>ARROW</code> style</li>
* <li><code>Tracker</code></li>
* <li><code>Table</code></li>
* <li><code>Tree</code></li>
* </ul></p>
*/
static const int UP; // = 1 << 7;
/**
* Style constant for align top behavior (value is 1&lt;&lt;7,
* since align UP and align TOP are considered the same).
* <p><b>Used By:</b><ul>
* <li><code>FormAttachment</code> in a <code>FormLayout</code></li>
* </ul></p>
*/
static const int TOP; // = UP;
/**
* Style constant for align down behavior (value is 1&lt;&lt;10,
* since align DOWN and align BOTTOM are considered the same).
* <p><b>Used By:</b><ul>
* <li><code>Button</code> with <code>ARROW</code> style</li>
* <li><code>Tracker</code></li>
* <li><code>Table</code></li>
* <li><code>Tree</code></li>
* </ul></p>
*/
static const int DOWN; // = 1 << 10;
/**
* Style constant for align bottom behavior (value is 1&lt;&lt;10,
* since align DOWN and align BOTTOM are considered the same).
* <p><b>Used By:</b><ul>
* <li><code>FormAttachment</code> in a <code>FormLayout</code></li>
* </ul></p>
*/
static const int BOTTOM; // = DOWN;
/**
* Style constant for leading alignment (value is 1&lt;&lt;14).
* <p><b>Used By:</b><ul>
* <li><code>Button</code></li>
* <li><code>Label</code></li>
* <li><code>TableColumn</code></li>
* <li><code>Tracker</code></li>
* <li><code>FormAttachment</code> in a <code>FormLayout</code></li>
* </ul></p>
*
* @since 2.1.2
*/
static const int LEAD; // = 1 << 14;
/**
* Style constant for align left behavior (value is 1&lt;&lt;14).
* This is a synonym for LEAD (value is 1&lt;&lt;14). Newer
* applications should use LEAD instead of LEFT to make code more
* understandable on right-to-left platforms.
*/
static const int LEFT; // = LEAD;
/**
* Style constant for trailing alignment (value is 1&lt;&lt;17).
* <p><b>Used By:</b><ul>
* <li><code>Button</code></li>
* <li><code>Label</code></li>
* <li><code>TableColumn</code></li>
* <li><code>Tracker</code></li>
* <li><code>FormAttachment</code> in a <code>FormLayout</code></li>
* </ul></p>
*
* @since 2.1.2
*/
static const int TRAIL; // = 1 << 17;
/**
* Style constant for align right behavior (value is 1&lt;&lt;17).
* This is a synonym for TRAIL (value is 1&lt;&lt;17). Newer
* applications should use TRAIL instead of RIGHT to make code more
* understandable on right-to-left platforms.
*/
static const int RIGHT; // = TRAIL;
/**
* Style constant for vertical alignment or orientation behavior (value is 4).
*/
static const int FILL; // = 4;
/**
* Style constant for automatic line wrap behavior (value is 1&lt;&lt;6).
*/
static const int WRAP; // = 1 << 6;
/**
* Style constant for bordered behavior (value is 1&lt;&lt;11).
* <br>Note that this is a <em>HINT</em>.
* <p><b>Used By:</b><ul>
* <li><code>Control</code> and subclasses</li>
* </ul></p>
*/
static const int BORDER; // = 1 << 11;
/**
* Style constant for close box trim (value is 1&lt;&lt;6,
* since we do not distinguish between CLOSE style and MENU style).
* <p><b>Used By:</b><ul>
* <li><code>Decorations</code> and subclasses</li>
* </ul></p>
*/
static const int CLOSE; // = 1 << 6;
/**
* Style constant for tool window behavior (value is 1&lt;&lt;2).
* <p>
* A tool window is a window intended to be used as a floating toolbar.
* It typically has a title bar that is shorter than a normal title bar,
* and the window title is typically drawn using a smaller font.
* <br>Note that this is a <em>HINT</em>.
* </p><p><b>Used By:</b><ul>
* <li><code>Decorations</code> and subclasses</li>
* </ul></p>
*/
static const int TOOL; // = 1 << 2;
/**
* Style constant for resize box trim (value is 1&lt;&lt;4).
* <p><b>Used By:</b><ul>
* <li><code>Decorations</code> and subclasses</li>
* <li><code>Tracker</code></li>
* </ul></p>
*/
static const int RESIZE; // = 1 << 4;
/**
* Style constant for title area trim (value is 1&lt;&lt;5).
* <p><b>Used By:</b><ul>
* <li><code>Decorations</code> and subclasses</li>
* </ul></p>
*/
static const int TITLE; // = 1 << 5;
/**
* Trim style convenience constant for the most common top level shell appearance
* (value is CLOSE|TITLE|MIN|MAX|RESIZE).
* <p><b>Used By:</b><ul>
* <li><code>Shell</code></li>
* </ul></p>
*/
static const int SHELL_TRIM; // = CLOSE | TITLE | MIN | MAX | RESIZE;
/**
* Trim style convenience constant for the most common dialog shell appearance
* (value is CLOSE|TITLE|BORDER).
* <p><b>Used By:</b><ul>
* <li><code>Shell</code></li>
* </ul></p>
*/
static const int DIALOG_TRIM; // = TITLE | CLOSE | BORDER;
/**
* Style constant for modeless behavior (value is 0).
* <br>Note that this is a <em>HINT</em>.
* <p><b>Used By:</b><ul>
* <li><code>Dialog</code></li>
* <li><code>Shell</code></li>
* </ul></p>
*/
static const int MODELESS; // = 0;
/**
* Style constant for primary modal behavior (value is 1&lt;&lt;15).
* <br>Note that this is a <em>HINT</em>.
* <p><b>Used By:</b><ul>
* <li><code>Dialog</code></li>
* <li><code>Shell</code></li>
* </ul></p>
*/
static const int PRIMARY_MODAL; // = 1 << 15;
/**
* Style constant for application modal behavior (value is 1&lt;&lt;16).
* <br>Note that this is a <em>HINT</em>.
* <p><b>Used By:</b><ul>
* <li><code>Dialog</code></li>
* <li><code>Shell</code></li>
* </ul></p>
*/
static const int APPLICATION_MODAL; // = 1 << 16;
/**
* Style constant for system modal behavior (value is 1&lt;&lt;17).
* <br>Note that this is a <em>HINT</em>.
* <p><b>Used By:</b><ul>
* <li><code>Dialog</code></li>
* <li><code>Shell</code></li>
* </ul></p>
*/
static const int SYSTEM_MODAL; // = 1 << 17;
};
}
#endif /* BERRYCONSTANTS_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryDisplay.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/berryDisplay.cpp
index d47e2e62ec..0808682532 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryDisplay.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryDisplay.cpp
@@ -1,36 +1,36 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryDisplay.h"
#include <Poco/Bugcheck.h>
namespace berry {
Display* Display::instance = 0;
Display::~Display()
{
}
Display* Display::GetDefault()
{
poco_assert(instance);
return instance;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryDisplay.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryDisplay.h
index 9be41705a7..399d18f37c 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryDisplay.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryDisplay.h
@@ -1,64 +1,64 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYDISPLAY_H_
#define BERRYDISPLAY_H_
#include <Poco/Runnable.h>
#include <org_blueberry_ui_Export.h>
namespace berry {
class BERRY_UI Display
{
public:
virtual ~Display();
static Display* GetDefault();
/**
* Returns true if the calling thread is the same thread
* who created this Display instance.
* @return
*/
virtual bool InDisplayThread() = 0;
virtual void AsyncExec(Poco::Runnable*) = 0;
virtual void SyncExec(Poco::Runnable*) = 0;
virtual int RunEventLoop() = 0;
virtual void ExitEventLoop(int code) = 0;
protected:
/**
* This method must be called from within the UI thread
* and should create the Display instance and initialize
* variables holding implementation specific thread data.
*/
virtual void CreateDisplay() = 0;
static Display* instance;
};
}
#endif /* BERRYDISPLAY_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryEditorPart.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/berryEditorPart.cpp
index 64564b8393..3f035964e8 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryEditorPart.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryEditorPart.cpp
@@ -1,101 +1,101 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryEditorPart.h"
#include "berryImageDescriptor.h"
#include "berryIWorkbenchPartConstants.h"
#include <cassert>
namespace berry
{
EditorPart::EditorPart()
{
}
void EditorPart::SetInput(IEditorInput::Pointer input)
{
editorInput = input;
}
void EditorPart::SetInputWithNotify(IEditorInput::Pointer input)
{
if (input != editorInput)
{
editorInput = input;
FirePropertyChange(IWorkbenchPartConstants::PROP_INPUT);
}
}
void EditorPart::SetContentDescription(const std::string& description)
{
// if (compatibilityTitleListener != null)
// {
// removePropertyListener(compatibilityTitleListener);
// compatibilityTitleListener = null;
// }
WorkbenchPart::SetContentDescription(description);
}
void EditorPart::SetPartName(const std::string& partName)
{
// if (compatibilityTitleListener != null)
// {
// removePropertyListener(compatibilityTitleListener);
// compatibilityTitleListener = null;
// }
WorkbenchPart::SetPartName(partName);
}
void EditorPart::CheckSite(IWorkbenchPartSite::Pointer site)
{
WorkbenchPart::CheckSite(site);
assert(!site.Cast<IEditorSite>().IsNull()); // The site for an editor must be an IEditorSite
}
IEditorInput::Pointer EditorPart::GetEditorInput() const
{
return editorInput;
}
IEditorSite::Pointer EditorPart::GetEditorSite() const
{
return this->GetSite().Cast<IEditorSite>();
}
std::string EditorPart::GetTitleToolTip() const
{
if (editorInput.IsNull())
{
return WorkbenchPart::GetTitleToolTip();
}
else
{
return editorInput->GetToolTipText();
}
}
bool EditorPart::IsSaveOnCloseNeeded() const
{
return this->IsDirty();
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryEditorPart.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryEditorPart.h
index c576f32736..7a300fdd0c 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryEditorPart.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryEditorPart.h
@@ -1,250 +1,250 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYEDITORPART_H_
#define BERRYEDITORPART_H_
#include <org_blueberry_ui_Export.h>
#include "berryIEditorPart.h"
#include "berryIEditorInput.h"
#include "berryIEditorSite.h"
#include "berryWorkbenchPart.h"
namespace berry {
/**
* \ingroup org_blueberry_ui
*
* Abstract base implementation of all workbench editors.
* <p>
* This class should be subclassed by clients wishing to define new editors.
* The name of the subclass should be given as the <code>"class"</code>
* attribute in a <code>editor</code> extension contributed to the workbench's
* editor extension point (named <code>"org.mitk.ui.editors"</code>).
* For example, the plug-in's XML markup might contain:
* <pre>
* &LT;extension point="org.blueberry.ui.editors"&GT;
* &LT;editor id="com.example.myplugin.ed"
* name="My Editor"
* icon="./images/cedit.gif"
* extensions="foo"
* class="com.example.myplugin.MyFooEditor"
* contributorClass="com.example.myplugin.MyFooEditorContributor"
* /&GT;
* &LT;/extension&GT;
* </pre>
* where <code>com.example.myplugin.MyEditor</code> is the name of the
* <code>EditorPart</code> subclass.
* </p>
* <p>
* Subclasses must implement the following methods:
* <ul>
* <li><code>IEditorPart.init</code> - to initialize editor when assigned its site</li>
* <li><code>IWorkbenchPart.createPartControl</code> - to create the editor's controls </li>
* <li><code>IWorkbenchPart.setFocus</code> - to accept focus</li>
* <li><code>IEditorPart.isDirty</code> - to decide whether a significant change has
* occurred</li>
* <li><code>IEditorPart.doSave</code> - to save contents of editor</li>
* <li><code>IEditorPart.doSaveAs</code> - to save contents of editor</li>
* <li><code>IEditorPart.isSaveAsAllowed</code> - to control Save As</li>
* </ul>
* </p>
* <p>
* Subclasses may extend or reimplement the following methods as required:
* <ul>
* <li><code>IExecutableExtension.setInitializationData</code> - extend to provide additional
* initialization when editor extension is instantiated</li>
* <li><code>IWorkbenchPart.dispose</code> - extend to provide additional cleanup</li>
* <li><code>IAdaptable.getAdapter</code> - reimplement to make the editor
* adaptable</li>
* </ul>
* </p>
*/
class BERRY_UI EditorPart : public WorkbenchPart , public virtual IEditorPart {
Q_OBJECT
Q_INTERFACES(berry::IEditorPart)
public:
berryObjectMacro(EditorPart);
private:
/**
* Editor input, or <code>null</code> if none.
*/
IEditorInput::Pointer editorInput;
protected:
/**
* Creates a new workbench editor.
*/
EditorPart();
/**
* Sets the input to this editor. This method simply updates the internal
* member variable.
*
* <p>Unlike most of the other set methods on this class, this method does
* not fire a property change. Clients that call this method from a subclass
* must ensure that they fire an IWorkbenchPartConstants.PROP_INPUT property
* change after calling this method but before leaving whatever public method
* they are in. Clients that expose this method as public API must fire
* the property change within their implementation of setInput.</p>
*
* <p>Note that firing a property change may cause listeners to immediately
* reach back and call methods on this editor. Care should be taken not to
* fire the property change until the editor has fully updated its internal
* state to reflect the new input.</p>
*
* @param input the editor input
*
* @see #setInputWithNotify(IEditorInput)
*/
virtual void SetInput(IEditorInput::Pointer input) ;
/**
* Sets the input to this editor and fires a PROP_INPUT property change if
* the input has changed. This is the convenience method implementation.
*
* <p>Note that firing a property change may cause other objects to reach back
* and invoke methods on the editor. Care should be taken not to call this method
* until the editor has fully updated its internal state to reflect the
* new input.</p>
*
* @since 3.2
*
* @param input the editor input
*/
virtual void SetInputWithNotify(IEditorInput::Pointer input);
/* (non-Javadoc)
* @see org.blueberry.ui.part.WorkbenchPart#setContentDescription(java.lang.String)
*/
virtual void SetContentDescription(const std::string& description);
/* (non-Javadoc)
* @see org.blueberry.ui.part.WorkbenchPart#setPartName(java.lang.String)
*/
virtual void SetPartName(const std::string& partName);
/**
* Checks that the given site is valid for this type of part.
* The site for an editor must be an <code>IEditorSite</code>.
*
* @param site the site to check
* @since 3.1
*/
void CheckSite(IWorkbenchPartSite::Pointer site);
public:
/* (non-Javadoc)
* Saves the contents of this editor.
* <p>
* Subclasses must override this method to implement the open-save-close lifecycle
* for an editor. For greater details, see <code>IEditorPart</code>
* </p>
*
* @see IEditorPart
*/
virtual void DoSave(/*IProgressMonitor monitor*/) = 0;
/* (non-Javadoc)
* Saves the contents of this editor to another object.
* <p>
* Subclasses must override this method to implement the open-save-close lifecycle
* for an editor. For greater details, see <code>IEditorPart</code>
* </p>
*
* @see IEditorPart
*/
virtual void DoSaveAs() = 0;
/* (non-Javadoc)
* Method declared on IEditorPart.
*/
IEditorInput::Pointer GetEditorInput() const;
/* (non-Javadoc)
* Method declared on IEditorPart.
*/
IEditorSite::Pointer GetEditorSite() const;
/* (non-Javadoc)
* Gets the title tool tip text of this part.
*
* @return the tool tip text
*/
std::string GetTitleToolTip() const;
/* (non-Javadoc)
* Initializes the editor part with a site and input.
* <p>
* Subclasses of <code>EditorPart</code> must implement this method. Within
* the implementation subclasses should verify that the input type is acceptable
* and then save the site and input. Here is sample code:
* </p>
* <pre>
* if (!(input instanceof IFileEditorInput))
* throw new PartInitException("Invalid Input: Must be IFileEditorInput");
* setSite(site);
* setInput(input);
* </pre>
*/
virtual void Init(IEditorSite::Pointer site, IEditorInput::Pointer input) = 0;
/* (non-Javadoc)
* Returns whether the contents of this editor have changed since the last save
* operation.
* <p>
* Subclasses must override this method to implement the open-save-close lifecycle
* for an editor. For greater details, see <code>IEditorPart</code>
* </p>
*
* @see IEditorPart
*/
virtual bool IsDirty() const = 0;
/* (non-Javadoc)
* Returns whether the "save as" operation is supported by this editor.
* <p>
* Subclasses must override this method to implement the open-save-close lifecycle
* for an editor. For greater details, see <code>IEditorPart</code>
* </p>
*
* @see IEditorPart
*/
virtual bool IsSaveAsAllowed() const = 0;
/* (non-Javadoc)
* Returns whether the contents of this editor should be saved when the editor
* is closed.
* <p>
* This method returns <code>true</code> if and only if the editor is dirty
* (<code>isDirty</code>).
* </p>
*/
virtual bool IsSaveOnCloseNeeded() const;
};
}
#endif /*BERRYEDITORPART_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryFileEditorInput.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/berryFileEditorInput.cpp
index 9a4c976d91..e7bbf425c6 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryFileEditorInput.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryFileEditorInput.cpp
@@ -1,61 +1,61 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryFileEditorInput.h"
#include <Poco/File.h>
namespace berry {
FileEditorInput::FileEditorInput(const Poco::Path& path)
: m_Path(path)
{
}
Poco::Path FileEditorInput::GetPath() const
{
return m_Path;
}
bool FileEditorInput::Exists() const
{
Poco::File file(m_Path);
return file.exists();
}
std::string FileEditorInput::GetName() const
{
return m_Path.getFileName();
}
std::string FileEditorInput::GetToolTipText() const
{
return m_Path.toString();
}
bool FileEditorInput::operator==(const Object* o) const
{
if (const IPathEditorInput* other = dynamic_cast<const IPathEditorInput*>(o))
{
return other->GetPath().toString() == this->GetPath().toString();
}
return false;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryFileEditorInput.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryFileEditorInput.h
index b083fdfb73..ce153bca51 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryFileEditorInput.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryFileEditorInput.h
@@ -1,53 +1,53 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYFILEEDITORINPUT_H_
#define BERRYFILEEDITORINPUT_H_
#include "berryIPathEditorInput.h"
#include <org_blueberry_ui_Export.h>
namespace berry {
class BERRY_UI FileEditorInput : public IPathEditorInput
{
public:
berryObjectMacro(FileEditorInput);
FileEditorInput(const Poco::Path& path);
Poco::Path GetPath() const;
bool Exists() const;
std::string GetName() const ;
std::string GetToolTipText() const;
bool operator==(const Object* o) const;
private:
Poco::Path m_Path;
};
}
#endif /* BERRYFILEEDITORINPUT_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryGeometry.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/berryGeometry.cpp
index d5a31bebf4..d176b1d72f 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryGeometry.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryGeometry.cpp
@@ -1,171 +1,171 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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.
===================================================================*/
// needed under windows to suppress the definition of the
// min/max macros in windows.h, which would clash with
// std::numeric_limits<>::max()
#define NOMINMAX
#include "tweaklets/berryGuiWidgetsTweaklet.h"
#include "berryGeometry.h"
#include "berryConstants.h"
#include <limits>
namespace berry
{
int Geometry::GetDimension(const Rectangle& toMeasure, bool width)
{
if (width)
{
return toMeasure.width;
}
return toMeasure.height;
}
bool Geometry::IsHorizontal(int berrySideConstant)
{
return !(berrySideConstant == Constants::LEFT || berrySideConstant
== Constants::RIGHT);
}
Rectangle Geometry::GetExtrudedEdge(const Rectangle& toExtrude, int size,
int orientation)
{
Rectangle bounds(toExtrude);
if (!IsHorizontal(orientation))
{
bounds.width = size;
}
else
{
bounds.height = size;
}
if (orientation == Constants::RIGHT)
{
bounds.x = toExtrude.x + toExtrude.width - bounds.width;
}
else if (orientation == Constants::BOTTOM)
{
bounds.y = toExtrude.y + toExtrude.height - bounds.height;
}
Normalize(bounds);
return bounds;
}
void Geometry::Normalize(Rectangle& rect)
{
if (rect.width < 0)
{
rect.width = -rect.width;
rect.x -= rect.width;
}
if (rect.height < 0)
{
rect.height = -rect.height;
rect.y -= rect.height;
}
}
int Geometry::GetClosestSide(const Rectangle& boundary, const Point& toTest)
{
int sides[] =
{ Constants::LEFT, Constants::RIGHT, Constants::TOP, Constants::BOTTOM };
int closestSide = Constants::LEFT;
int closestDistance = std::numeric_limits<int>::max();
for (unsigned int idx = 0; idx < 4; idx++)
{
int side = sides[idx];
int distance = GetDistanceFromEdge(boundary, toTest, side);
if (distance < closestDistance)
{
closestDistance = distance;
closestSide = side;
}
}
return closestSide;
}
int Geometry::GetDistanceFromEdge(const Rectangle& rectangle,
const Point& testPoint, int edgeOfInterest)
{
if (edgeOfInterest == Constants::TOP)
return testPoint.y - rectangle.y;
else if (edgeOfInterest == Constants::BOTTOM)
return rectangle.y + rectangle.height - testPoint.y;
else if (edgeOfInterest == Constants::LEFT)
return testPoint.x - rectangle.x;
else if (edgeOfInterest == Constants::RIGHT)
return rectangle.x + rectangle.width - testPoint.x;
return 0;
}
int Geometry::GetOppositeSide(int directionConstant)
{
if (directionConstant == Constants::TOP)
return Constants::BOTTOM;
else if (directionConstant == Constants::BOTTOM)
return Constants::TOP;
else if (directionConstant == Constants::LEFT)
return Constants::RIGHT;
else if (directionConstant == Constants::RIGHT)
return Constants::LEFT;
return directionConstant;
}
Rectangle Geometry::ToControl(void* coordinateSystem,
const Rectangle& toConvert)
{
return Tweaklets::Get(GuiWidgetsTweaklet::KEY)->ToControl(coordinateSystem,
toConvert);
}
Point Geometry::ToControl(void* coordinateSystem, const Point& toConvert)
{
return Tweaklets::Get(GuiWidgetsTweaklet::KEY)->ToControl(coordinateSystem,
toConvert);
}
Rectangle Geometry::ToDisplay(void* coordinateSystem,
const Rectangle& toConvert)
{
return Tweaklets::Get(GuiWidgetsTweaklet::KEY)->ToDisplay(coordinateSystem,
toConvert);
}
Point Geometry::ToDisplay(void* coordinateSystem, const Point& toConvert)
{
return Tweaklets::Get(GuiWidgetsTweaklet::KEY)->ToDisplay(coordinateSystem,
toConvert);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryGeometry.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryGeometry.h
index 126a33540f..e4e990867b 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryGeometry.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryGeometry.h
@@ -1,163 +1,163 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYGEOMETRY_H_
#define BERRYGEOMETRY_H_
#include "berryRectangle.h"
#include "berryPoint.h"
namespace berry {
struct BERRY_UI Geometry
{
/**
* Returns the height or width of the given rectangle.
*
* @param toMeasure rectangle to measure
* @param width returns the width if true, and the height if false
* @return the width or height of the given rectangle
* @since 3.0
*/
static int GetDimension(const Rectangle& toMeasure, bool width);
/**
* Returns true iff the given side constant corresponds to a horizontal side
* of a rectangle. That is, returns true for the top and bottom but false for the
* left and right.
*
* @param swtSideConstant one of Constants::TOP, Constants::BOTTOM, Constants::LEFT, or Constants::RIGHT
* @return true iff the given side is horizontal.
* @since 3.0
*/
static bool IsHorizontal(int berrySideConstant);
/**
* Extrudes the given edge inward by the given distance. That is, if one side of the rectangle
* was sliced off with a given thickness, this returns the rectangle that forms the slice. Note
* that the returned rectangle will be inside the given rectangle if size > 0.
*
* @param toExtrude the rectangle to extrude. The resulting rectangle will share three sides
* with this rectangle.
* @param size distance to extrude. A negative size will extrude outwards (that is, the resulting
* rectangle will overlap the original iff this is positive).
* @param orientation the side to extrude. One of Constants::LEFT, Constants::RIGHT, Constants::TOP, or Constants::BOTTOM. The
* resulting rectangle will always share this side with the original rectangle.
* @return a rectangle formed by extruding the given side of the rectangle by the given distance.
*/
static Rectangle GetExtrudedEdge(const Rectangle& toExtrude, int size,
int orientation);
/**
* Normalizes the given rectangle. That is, any rectangle with
* negative width or height becomes a rectangle with positive
* width or height that extends to the upper-left of the original
* rectangle.
*
* @param rect rectangle to modify
*/
static void Normalize(Rectangle& rect);
/**
* Returns the edge of the given rectangle is closest to the given
* point.
*
* @param boundary rectangle to test
* @param toTest point to compare
* @return one of SWT.LEFT, SWT.RIGHT, SWT.TOP, or SWT.BOTTOM
*
* @since 3.0
*/
static int GetClosestSide(const Rectangle& boundary, const Point& toTest);
/**
* Returns the distance of the given point from a particular side of the given rectangle.
* Returns negative values for points outside the rectangle.
*
* @param rectangle a bounding rectangle
* @param testPoint a point to test
* @param edgeOfInterest side of the rectangle to test against
* @return the distance of the given point from the given edge of the rectangle
* @since 3.0
*/
static int GetDistanceFromEdge(const Rectangle& rectangle, const Point& testPoint,
int edgeOfInterest);
/**
* Returns the opposite of the given direction. That is, returns SWT.LEFT if
* given SWT.RIGHT and visa-versa.
*
* @param swtDirectionConstant one of SWT.LEFT, SWT.RIGHT, SWT.TOP, or SWT.BOTTOM
* @return one of SWT.LEFT, SWT.RIGHT, SWT.TOP, or SWT.BOTTOM
* @since 3.0
*/
static int GetOppositeSide(int directionConstant);
/**
* Converts the given rectangle from display coordinates to the local coordinate system
* of the given object
*
* @param coordinateSystem local coordinate system (widget) being converted to
* @param toConvert rectangle to convert
* @return a rectangle in control coordinates
* @since 3.0
*/
static Rectangle ToControl(void* coordinateSystem,
const Rectangle& toConvert);
/**
* Converts the given point from display coordinates to the local coordinate system
* of the given object
*
* @param coordinateSystem local coordinate system (widget) being converted to
* @param toConvert point to convert
* @return a point in control coordinates
* @since 3.0
*/
static Point ToControl(void* coordinateSystem,
const Point& toConvert);
/**
* Converts the given rectangle from the local coordinate system of the given object
* into display coordinates.
*
* @param coordinateSystem local coordinate system (widget) being converted from
* @param toConvert rectangle to convert
* @return a rectangle in display coordinates
* @since 3.0
*/
static Rectangle ToDisplay(void* coordinateSystem,
const Rectangle& toConvert);
/**
* Converts the given point from the local coordinate system of the given object
* into display coordinates.
*
* @param coordinateSystem local coordinate system (widget) being converted from
* @param toConvert point to convert
* @return a point in display coordinates
* @since 3.0
*/
static Point ToDisplay(void* coordinateSystem,
const Point& toConvert);
};
}
#endif /* BERRYGEOMETRY_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIDropTargetListener.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/berryIDropTargetListener.cpp
index 13397c0f8b..b30f1e4ddd 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIDropTargetListener.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIDropTargetListener.cpp
@@ -1,48 +1,48 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryIDropTargetListener.h"
namespace berry {
void IDropTargetListener::Events::AddListener(IDropTargetListener* l)
{
if (l == 0) return;
Types t = l->GetDropTargetEventTypes();
if (t & ENTER)
dragEnter += DragEnterDelegate(l, &IDropTargetListener::DragEnterEvent);
if (t & LEAVE)
dragLeave += DragLeaveDelegate(l, &IDropTargetListener::DragLeaveEvent);
if (t & MOVE)
dragMove += DragMoveDelegate(l, &IDropTargetListener::DragMoveEvent);
if (t & DROP)
drop += DropDelegate(l, &IDropTargetListener::DropEvent);
}
void IDropTargetListener::Events::RemoveListener(IDropTargetListener* l)
{
if (l == 0) return;
dragEnter -= DragEnterDelegate(l, &IDropTargetListener::DragEnterEvent);
dragLeave -= DragLeaveDelegate(l, &IDropTargetListener::DragLeaveEvent);
dragMove -= DragMoveDelegate(l, &IDropTargetListener::DragMoveEvent);
drop -= DropDelegate(l, &IDropTargetListener::DropEvent);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIDropTargetListener.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryIDropTargetListener.h
index d657593544..2f554b67dc 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIDropTargetListener.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIDropTargetListener.h
@@ -1,85 +1,85 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIDROPTARGETLISTENER_H
#define BERRYIDROPTARGETLISTENER_H
#include <berryMacros.h>
#include <berryObject.h>
#include <org_blueberry_ui_Export.h>
class QDragEnterEvent;
class QDragLeaveEvent;
class QDragMoveEvent;
class QDropEvent;
namespace berry {
struct BERRY_UI IDropTargetListener : public Object {
berryInterfaceMacro(IDropTargetListener, berry);
struct Events {
enum Type {
NONE = 0x00000000,
ENTER = 0x00000001,
LEAVE = 0x00000002,
MOVE = 0x00000004,
DROP = 0x00000008,
ALL = 0xffffffff
};
Q_DECLARE_FLAGS(Types, Type)
typedef Message1<QDragEnterEvent*> DragEnterEventType;
typedef Message1<QDragLeaveEvent*> DragLeaveEventType;
typedef Message1<QDragMoveEvent*> DragMoveEventType;
typedef Message1<QDropEvent*> DropEventType;
DragEnterEventType dragEnter;
DragLeaveEventType dragLeave;
DragMoveEventType dragMove;
DropEventType drop;
void AddListener(IDropTargetListener* listener);
void RemoveListener(IDropTargetListener* listener);
private:
typedef MessageDelegate1<IDropTargetListener, QDragEnterEvent*> DragEnterDelegate;
typedef MessageDelegate1<IDropTargetListener, QDragLeaveEvent*> DragLeaveDelegate;
typedef MessageDelegate1<IDropTargetListener, QDragMoveEvent*> DragMoveDelegate;
typedef MessageDelegate1<IDropTargetListener, QDropEvent*> DropDelegate;
};
virtual Events::Types GetDropTargetEventTypes() const = 0;
virtual void DragEnterEvent(QDragEnterEvent* /*event*/) {}
virtual void DragLeaveEvent(QDragLeaveEvent* /*event*/) {}
virtual void DragMoveEvent(QDragMoveEvent* /*event*/) {}
virtual void DropEvent(QDropEvent* /*event*/) {}
};
}
Q_DECLARE_OPERATORS_FOR_FLAGS(berry::IDropTargetListener::Events::Types)
#endif // BERRYIDROPTARGETLISTENER_H
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIEditorDescriptor.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryIEditorDescriptor.h
index fb55e2c6cb..12d833691f 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIEditorDescriptor.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIEditorDescriptor.h
@@ -1,123 +1,123 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIEDITORDESCRIPTOR_H_
#define BERRYIEDITORDESCRIPTOR_H_
#include <org_blueberry_ui_Export.h>
#include "berryIWorkbenchPartDescriptor.h"
#include "berryIEditorMatchingStrategy.h"
namespace berry
{
/**
* \ingroup org_blueberry_ui
*
* Description of an editor in the workbench editor registry. The
* editor descriptor contains the information needed to create editor instances.
* <p>
* An editor descriptor typically represents one of three types of editors:
* <ul>
* <li>a file editor extension for a specific file extension.</li>
* <li>a file editor added by the user (via the workbench preference page)</li>
* <li>a general editor extension which works on objects other than files.</li>
* </ul>
* </p>
* <p>
* This interface is not intended to be implemented or extended by clients.
* </p>
*
* @see IEditorRegistry
* @noimplement This interface is not intended to be implemented by clients.
*/
struct BERRY_UI IEditorDescriptor : public IWorkbenchPartDescriptor
{
berryInterfaceMacro(IEditorDescriptor, berry);
virtual ~IEditorDescriptor();
/**
* Returns the editor id.
* <p>
* For internal editors, this is the extension id as defined in the workbench
* registry; for external editors, it is path and file name of the external
* program.
* </p>
*
* @return the id of the editor
*/
virtual std::string GetId() const = 0;
/**
* Returns the descriptor of the image for this editor.
*
* @return the descriptor of the image to display next to this editor
*/
//ImageDescriptor getImageDescriptor() = 0;
/**
* Returns the label to show for this editor.
*
* @return the editor label
*/
virtual std::string GetLabel() const = 0;
/**
* Returns whether this editor descriptor will open a regular editor
* part inside the editor area.
*
* @return <code>true</code> if editor is inside editor area, and
* <code>false</code> otherwise
* @since 3.0
*/
virtual bool IsInternal() const = 0;
/**
* Returns whether this editor descriptor will open an external
* editor in-place inside the editor area.
*
* @return <code>true</code> if editor is in-place, and <code>false</code>
* otherwise
* @since 3.0
*/
virtual bool IsOpenInPlace() const = 0;
/**
* Returns whether this editor descriptor will open an external editor
* in a new window outside the workbench.
*
* @return <code>true</code> if editor is external, and <code>false</code>
* otherwise
* @since 3.0
*/
virtual bool IsOpenExternal() const = 0;
/**
* Returns the editor matching strategy object for editors
* represented by this editor descriptor, or <code>null</code>
* if there is no explicit matching strategy specified.
*
* @return the editor matching strategy, or <code>null</code> if none
* @since 3.1
*/
virtual IEditorMatchingStrategy::Pointer GetEditorMatchingStrategy() = 0;
};
}
#endif /*BERRYIEDITORDESCRIPTOR_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIEditorInput.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryIEditorInput.h
index 2453e77e81..f505cd6a2e 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIEditorInput.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIEditorInput.h
@@ -1,143 +1,143 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIEDITORINPUT_H_
#define BERRYIEDITORINPUT_H_
#include <berryMacros.h>
#include <berryObject.h>
#include <org_blueberry_ui_Export.h>
namespace berry
{
/**
* \ingroup org_blueberry_ui
*
* <code>IEditorInput</code> is a light weight descriptor of editor input,
* like a file name but more abstract. It is not a model. It is a description of
* the model source for an <code>IEditorPart</code>.
* <p>
* Clients implementing this editor input interface must override
* <code>Object#operator==(const Object*)</code> to answer true
* for two inputs that are
* the same. The <code>IWorbenchPage.openEditor</code> APIs are dependent on
* this to find an editor with the same input.
* </p>
* <p>
* Clients should extend this interface to declare new types of editor inputs.
* </p>
* <p>
* An editor input is passed to an editor via the <code>IEditorPart.init</code>
* method. Due to the wide range of valid editor inputs, it is not possible to
* define generic methods for getting and setting bytes.
* </p>
* <p>
* Editor input must implement the <code>IAdaptable</code> interface;
* extensions are managed by the platform's adapter manager.
* </p>
* <p>
* Please note that it is important that the editor input be light weight.
* Within the workbench, the navigation history tends to hold on to editor
* inputs as a means of reconstructing the editor at a later time. The
* navigation history can hold on to quite a few inputs (i.e., the default is
* fifty). The actual data model should probably not be held in the input.
* </p>
*
*
* @see org.blueberry.ui.IEditorPart
* @see org.blueberry.ui.IWorkbenchPage#openEditor(IEditorInput, String)
* @see org.blueberry.ui.IWorkbenchPage#openEditor(IEditorInput, String, boolean)
*/
struct BERRY_UI IEditorInput : public Object // public IAdaptable
{
berryInterfaceMacro(IEditorInput, berry);
~IEditorInput();
/**
* Returns whether the editor input exists.
* <p>
* This method is primarily used to determine if an editor input should
* appear in the "File Most Recently Used" menu. An editor input will appear
* in the list until the return value of <code>exists</code> becomes
* <code>false</code> or it drops off the bottom of the list.
*
* @return <code>true</code> if the editor input exists;
* <code>false</code> otherwise
*/
virtual bool Exists() const = 0;
/**
* Returns the image descriptor for this input.
*
* <p>
* Note: although a null return value has never been permitted from this
* method, there are many known buggy implementations that return null.
* Clients that need the image for an editor are advised to use
* IWorkbenchPart.getImage() instead of IEditorInput.getImageDescriptor(),
* or to recover from a null return value in a manner that records the ID of
* the problematic editor input. Implementors that have been returning null
* from this method should pick some other default return value (such as
* ImageDescriptor.getMissingImageDescriptor()).
* </p>
*
* @return the image descriptor for this input; may be <code>null</code> if
* there is no image.
*/
//virtual ImageDescriptor GetImageDescriptor() = 0;
/**
* Returns the name of this editor input for display purposes.
* <p>
* For instance, when the input is from a file, the return value would
* ordinarily be just the file name.
*
* @return the name string; never <code>null</code>;
*/
virtual std::string GetName() const = 0;
/**
* Returns an object that can be used to save the state of this editor
* input.
*
* @return the persistable element, or <code>null</code> if this editor
* input cannot be persisted
*/
//virtual IPersistableElement GetPersistable() = 0;
/**
* Returns the tool tip text for this editor input. This text is used to
* differentiate between two input with the same name. For instance,
* MyClass.java in folder X and MyClass.java in folder Y. The format of the
* text varies between input types.
* </p>
*
* @return the tool tip text; never <code>null</code>.
*/
virtual std::string GetToolTipText() const = 0;
/**
* Returns true if two editor inputs are the same
*
*/
virtual bool operator==(const Object* o) const = 0;
};
}
#endif /*BERRYIEDITORINPUT_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIEditorMatchingStrategy.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryIEditorMatchingStrategy.h
index d94ed9fc6f..8dac822b6d 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIEditorMatchingStrategy.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIEditorMatchingStrategy.h
@@ -1,66 +1,66 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIEDITORMATCHINGSTRATEGY_H_
#define BERRYIEDITORMATCHINGSTRATEGY_H_
#include <berryMacros.h>
#include "berryIEditorReference.h"
#include "berryIEditorInput.h"
namespace berry {
/**
* \ingroup org_blueberry_ui
*
* An editor matching strategy allows editor extensions to provide their own
* algorithm for matching the input of an open editor of that type to a
* given editor input. This is used to find a matching editor during
* {@link org.blueberry.ui.IWorkbenchPage#openEditor(IEditorInput, String, boolean)} and
* {@link org.blueberry.ui.IWorkbenchPage#findEditor(IEditorInput)}.
*
* @since 3.1
*/
struct BERRY_UI IEditorMatchingStrategy : public Object {
berryInterfaceMacro(IEditorMatchingStrategy, berry);
~IEditorMatchingStrategy();
/**
* Returns whether the editor represented by the given editor reference
* matches the given editor input.
* <p>
* Implementations should inspect the given editor input first,
* and try to reject it early before calling <code>IEditorReference.getEditorInput()</code>,
* since that method may be expensive.
* </p>
*
* @param editorRef the editor reference to match against
* @param input the editor input to match
* @return <code>true</code> if the editor matches the given editor input,
* <code>false</code> if it does not match
*/
virtual bool Matches(IEditorReference::Pointer editorRef, IEditorInput::Pointer input) = 0;
};
}
Q_DECLARE_INTERFACE(berry::IEditorMatchingStrategy, "org.blueberry.IEditorMatchingStrategy")
#endif /*BERRYIEDITORMATCHINGSTRATEGY_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIEditorPart.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryIEditorPart.h
index 04ced89282..9c1aa001fa 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIEditorPart.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIEditorPart.h
@@ -1,130 +1,130 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIEDITORPART_H_
#define BERRYIEDITORPART_H_
#include "berryIWorkbenchPart.h"
#include "berryISaveablePart.h"
#include <QObject>
namespace berry
{
struct IEditorInput;
struct IEditorSite;
/**
* \ingroup org_blueberry_ui
*
* An editor is a visual component within a workbench page. It is
* typically used to edit or browse a document or input object. The input
* is identified using an <code>IEditorInput</code>. Modifications made
* in an editor part follow an open-save-close lifecycle model (in contrast
* to a view part, where modifications are saved to the workbench
* immediately).
* <p>
* An editor is document or input-centric. Each editor has an input, and only
* one editor can exist for each editor input within a page. This policy has
* been designed to simplify part management.
* </p><p>
* An editor should be used in place of a view whenever more than one instance
* of a document type can exist.
* </p><p>
* This interface may be implemented directly. For convenience, a base
* implementation is defined in <code>EditorPart</code>.
* </p>
* <p>
* An editor part is added to the workbench in two stages:
* <ol>
* <li>An editor extension is contributed to the workbench registry. This
* extension defines the extension id, extension class, and the file
* extensions which are supported by the editor.</li>
* <li>An editor part based upon the extension is created and added to the
* workbench when the user opens a file with one of the supported file
* extensions (or some other suitable form of editor input).</li>
* </ol>
* </p>
* <p>
* All editor parts implement the <code>IAdaptable</code> interface; extensions
* are managed by the platform's adapter manager.
* </p>
*
* @see org.blueberry.ui.IWorkbenchPage#openEditor(IEditorInput, String)
* @see org.blueberry.ui.part.EditorPart
*/
struct BERRY_UI IEditorPart : public virtual IWorkbenchPart,
public ISaveablePart {
berryInterfaceMacro(IEditorPart, berry)
virtual ~IEditorPart();
/**
* The property id for <code>getEditorInput</code>.
*/
//static const int PROP_INPUT = IWorkbenchPartConstants.PROP_INPUT;
/**
* Returns the input for this editor. If this value changes the part must
* fire a property listener event with <code>PROP_INPUT</code>.
*
* @return the editor input
*/
virtual SmartPointer<IEditorInput> GetEditorInput() const = 0;
/**
* Returns the site for this editor.
* This method is equivalent to <code>(IEditorSite) getSite()</code>.
* <p>
* The site can be <code>null</code> while the editor is being initialized.
* After the initialization is complete, this value must be non-<code>null</code>
* for the remainder of the editor's life cycle.
* </p>
*
* @return the editor site; this value may be <code>null</code> if the editor
* has not yet been initialized
*/
virtual SmartPointer<IEditorSite> GetEditorSite() const = 0;
/**
* Initializes this editor with the given editor site and input.
* <p>
* This method is automatically called shortly after the part is instantiated.
* It marks the start of the part's lifecycle. The
* {@link IWorkbenchPart#dispose IWorkbenchPart.dispose} method will be called
* automically at the end of the lifecycle. Clients must not call this method.
* </p><p>
* Implementors of this method must examine the editor input object type to
* determine if it is understood. If not, the implementor must throw
* a <code>PartInitException</code>
* </p>
* @param site the editor site
* @param input the editor input
* @exception PartInitException if this editor was not initialized successfully
*/
virtual void Init(SmartPointer<IEditorSite> site,
SmartPointer<IEditorInput> input) = 0;
};
}
Q_DECLARE_INTERFACE(berry::IEditorPart, "org.blueberry.IEditorPart")
#endif /*BERRYIEDITORPART_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIEditorReference.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryIEditorReference.h
index 3834656499..716e451c30 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIEditorReference.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIEditorReference.h
@@ -1,82 +1,82 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIEDITORREFERENCE_H_
#define BERRYIEDITORREFERENCE_H_
#include "berryIWorkbenchPartReference.h"
#include "berryIEditorPart.h"
#include "berryIEditorInput.h"
namespace berry {
/**
* \ingroup org_blueberry_ui
*
* Implements a reference to a editor.
* The IEditorPart will not be instanciated until
* the editor becomes visible or the API getEditor
* is sent with true;
* <p>
* This interface is not intended to be implemented by clients.
* </p>
*/
struct BERRY_UI IEditorReference : public virtual IWorkbenchPartReference {
berryInterfaceMacro(IEditorReference, berry)
~IEditorReference();
/**
* Returns the factory id of the factory used to
* restore this editor. Returns null if the editor
* is not persistable.
*/
virtual std::string GetFactoryId() = 0;
/**
* Returns the editor input name. May return null is the
* name is not available or if the editor failed to be
* restored.
*/
virtual std::string GetName() = 0;
/**
* Returns the editor referenced by this object.
* Returns <code>null</code> if the editor was not instantiated or
* it failed to be restored. Tries to restore the editor
* if <code>restore</code> is true.
*/
virtual IEditorPart::Pointer GetEditor(bool restore) = 0;
/**
* Returns the editor input for the editor referenced by this object.
* <p>
* Unlike most of the other methods on this type, this method
* can trigger plug-in activation.
* </p>
*
* @return the editor input for the editor referenced by this object
* @throws PartInitException if there was an error restoring the editor input
* @since 3.1
*/
virtual IEditorInput::Pointer GetEditorInput() = 0;
};
} // namespace berry
#endif /*BERRYIEDITORREFERENCE_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIEditorRegistry.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/berryIEditorRegistry.cpp
index 2d3b208bb5..8992e737f6 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIEditorRegistry.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIEditorRegistry.cpp
@@ -1,32 +1,32 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryIEditorRegistry.h"
namespace berry
{
const int IEditorRegistry::PROP_CONTENTS = 0x01;
const std::string IEditorRegistry::SYSTEM_EXTERNAL_EDITOR_ID =
"org.blueberry.ui.systemExternalEditor"; //$NON-NLS-1$
const std::string IEditorRegistry::SYSTEM_INPLACE_EDITOR_ID =
"org.blueberry.ui.systemInPlaceEditor"; //$NON-NLS-1$
IEditorRegistry::~IEditorRegistry()
{
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIEditorRegistry.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryIEditorRegistry.h
index 3cb9029da1..f839715bff 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIEditorRegistry.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIEditorRegistry.h
@@ -1,287 +1,287 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 MITKIEDITORREGISTRY_H_
#define MITKIEDITORREGISTRY_H_
#include <string>
#include <vector>
#include "berryIEditorDescriptor.h"
#include "berryIFileEditorMapping.h"
namespace berry {
/**
* \ingroup org_blueberry_ui
*
* Registry of editors known to the workbench.
* <p>
* An editor can be created in one of two ways:
* <ul>
* <li>An editor can be defined by an extension to the workbench.</li>
* <li>The user manually associates an editor with a given resource extension
* type. This will override any default workbench or platform association.
* </li>
* </ul>
* </p>
* <p>
* The registry does not keep track of editors that are "implicitly" determined.
* For example a bitmap (<code>.bmp</code>) file will typically not have a
* registered editor. Instead, when no registered editor is found, the
* underlying OS is consulted.
* </p>
* <p>
* This interface is not intended to be implemented by clients.
* </p>
*
* @see org.blueberry.ui.IWorkbench#getEditorRegistry()
* @noimplement This interface is not intended to be implemented by clients.
*/
struct BERRY_UI IEditorRegistry {
/**
* The property identifier for the contents of this registry.
*/
static const int PROP_CONTENTS; // = 0x01;
/**
* The identifier for the system external editor descriptor. This descriptor
* is always present in the registry on all platforms.
* This editor requires an input which implements
* {@link org.blueberry.ui.IPathEditorInput IPathEditorInput}.
* Use {@link #findEditor findEditor} to access the editor descriptor for
* this identifier.
*
* @since 3.0
*/
static const std::string SYSTEM_EXTERNAL_EDITOR_ID; // = "org.blueberry.ui.systemExternalEditor"; //$NON-NLS-1$
/**
* The identifier for the system in-place editor descriptor. This descriptor
* is only present in the registry on platforms that support in-place editing
* (for example Win32). This editor requires an input which implements
* {@link org.blueberry.ui.IInPlaceEditorInput IInPlaceEditorInput}. Use
* {@link #findEditor findEditor} to access the editor descriptor for this
* identifier.
*
* @since 3.0
*/
static const std::string SYSTEM_INPLACE_EDITOR_ID; // = "org.blueberry.ui.systemInPlaceEditor"; //$NON-NLS-1$
/*
* Adds a listener for changes to properties of this registry.
* Has no effect if an identical listener is already registered.
* <p>
* The properties ids are as follows:
* <ul>
* <li><code>PROP_CONTENTS</code>: Triggered when the file editor mappings in
* the editor registry change.</li>
* </ul>
* </p>
*
* @param listener a property listener
*/
// virtual void AddPropertyListener(IPropertyListener listener) = 0;
virtual ~IEditorRegistry();
/**
* Finds and returns the descriptor of the editor with the given editor id.
*
* @param editorId the editor id
* @return the editor descriptor with the given id, or <code>null</code> if not
* found
*/
virtual IEditorDescriptor::Pointer FindEditor(const std::string& editorId) = 0;
/**
* Returns the default editor. The default editor always exist.
*
* @return the descriptor of the default editor
* @deprecated The system external editor is the default editor.
* Use <code>findEditor(IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID)</code>
* instead.
*/
virtual IEditorDescriptor::Pointer GetDefaultEditor() = 0;
/**
* Returns the default editor for a given file name. This method assumes an
* unknown content type for the given file.
* <p>
* The default editor is determined by taking the file extension for the
* file and obtaining the default editor for that extension.
* </p>
*
* @param fileName
* the file name in the system
* @return the descriptor of the default editor, or <code>null</code> if
* not found
*/
virtual IEditorDescriptor::Pointer GetDefaultEditor(const std::string& fileName) = 0;
/*
* Returns the default editor for a given file name and with the given content type.
* <p>
* The default editor is determined by taking the file extension for the
* file and obtaining the default editor for that extension.
* </p>
*
* @param fileName the file name in the system
* @param contentType the content type or <code>null</code> for the unknown content type
* @return the descriptor of the default editor, or <code>null</code> if not
* found
* @since 3.1
*/
//virtual IEditorDescriptor::Pointer GetDefaultEditor(const std::string& fileName, IContentType contentType) = 0;
/**
* Returns the list of file editors registered to work against the file with
* the given file name. This method assumes an unknown content type for the
* given file.
* <p>
* Note: Use <code>getDefaultEditor(String)</code> if you only the need
* the default editor rather than all candidate editors.
* </p>
*
* @param fileName
* the file name in the system
* @return a list of editor descriptors
*/
virtual std::list<IEditorDescriptor::Pointer> GetEditors(const std::string& fileName) = 0;
/*
* Returns the list of file editors registered to work against the file with
* the given file name and with the given content type.
* <p>
* Note: Use <code>getDefaultEditor(String)</code> if you only the need
* the default editor rather than all candidate editors.
* </p>
*
* @param fileName
* the file name in the system
* @param contentType
* the content type or <code>null</code> for the unknown
* content type
* @return a list of editor descriptors
* @since 3.1
*/
//virtual std::vector<IEditorDescriptor::Pointer> GetEditors(const std::string& fileName, IContentType contentType) = 0;
/**
* Returns a list of mappings from file type to editor. The resulting list
* is sorted in ascending order by file extension.
* <p>
* Each mapping defines an extension and the set of editors that are
* available for that type. The set of editors includes those registered
* via plug-ins and those explicitly associated with a type by the user
* in the workbench preference pages.
* </p>
*
* @return a list of mappings sorted alphabetically by extension
*/
virtual std::vector<IFileEditorMapping::Pointer> GetFileEditorMappings() = 0;
/*
* Returns the image descriptor associated with a given file. This image is
* usually displayed next to the given file. This method assumes an unknown
* content type for the given file.
* <p>
* The image is determined by taking the file extension of the file and
* obtaining the image for the default editor associated with that
* extension. A default image is returned if no default editor is available.
* </p>
*
* @param filename
* the file name in the system
* @return the descriptor of the image to display next to the file
*/
// virtual ImageDescriptor* GetImageDescriptor(const std::string& filename) = 0;
/*
* Returns the image descriptor associated with a given file. This image is
* usually displayed next to the given file.
* <p>
* The image is determined by taking the file extension of the file and
* obtaining the image for the default editor associated with that
* extension. A default image is returned if no default editor is available.
* </p>
*
* @param filename
* the file name in the system
* @param contentType
* the content type of the file or <code>null</code> for the
* unknown content type
* @return the descriptor of the image to display next to the file
* @since 3.1
*/
// virtual ImageDescriptor* GetImageDescriptor(const std::tring& filename, IContentType contentType) = 0;
/*
* Removes the given property listener from this registry.
* Has no affect if an identical listener is not registered.
*
* @param listener a property listener
*/
// virtual void RemovePropertyListener(IPropertyListener listener) = 0;
/**
* Sets the default editor id for the files that match that
* specified file name or extension. The specified editor must be
* defined as an editor for that file name or extension.
*
* @param fileNameOrExtension the file name or extension pattern (e.g. "*.xml");
* @param editorId the editor id or <code>null</code> for no default
*/
virtual void SetDefaultEditor(const std::string& fileNameOrExtension, const std::string& editorId) = 0;
/**
* Returns whether there is an in-place editor that could handle a file
* with the given name.
*
* @param filename the file name
* @return <code>true</code> if an in-place editor is available, and
* <code>false</code> otherwise
* @since 3.0
*/
virtual bool IsSystemInPlaceEditorAvailable(const std::string& filename) = 0;
/**
* Returns whether the system has an editor that could handle a file
* with the given name.
*
* @param filename the file name
* @return <code>true</code> if an external editor available, and
* <code>false</code> otherwise
* @since 3.0
*/
virtual bool IsSystemExternalEditorAvailable(const std::string& filename) = 0;
/*
* Returns the image descriptor associated with the system editor that
* would be used to edit this file externally.
*
* @param filename the file name
* @return the descriptor of the external editor image, or <code>null</code>
* if none
* @since 3.0
*/
// virtual ImageDescriptor GetSystemExternalEditorImageDescriptor(const std::string& filename) = 0;
};
}
#endif /*MITKIEDITORREGISTRY_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIEditorSite.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryIEditorSite.h
index 32bda01919..91772dabbb 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIEditorSite.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIEditorSite.h
@@ -1,133 +1,133 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIEDITORSITE_H_
#define BERRYIEDITORSITE_H_
#include "berryIWorkbenchPartSite.h"
namespace berry {
/**
* \ingroup org_blueberry_ui
*
* The primary interface between an editor part and the workbench.
* <p>
* The workbench exposes its implemention of editor part sites via this
* interface, which is not intended to be implemented or extended by clients.
* </p>
* @noimplement This interface is not intended to be implemented by clients.
*/
struct BERRY_UI IEditorSite : public virtual IWorkbenchPartSite {
berryInterfaceMacro(IEditorSite, berry);
virtual ~IEditorSite();
/**
* Returns the action bar contributor for this editor.
* <p>
* An action contributor is responsable for the creation of actions.
* By design, this contributor is used for one or more editors of the same type.
* Thus, the contributor returned by this method is not owned completely
* by the editor - it is shared.
* </p>
*
* @return the editor action bar contributor, or <code>null</code> if none exists
*/
//virtual IEditorActionBarContributor getActionBarContributor();
/**
* Returns the action bars for this part site. Editors of the same type (and
* in the same window) share the same action bars. Contributions to the
* action bars are done by the <code>IEditorActionBarContributor</code>.
*
* @return the action bars
* @since 2.1
*/
//virtual IActionBars getActionBars();
/**
* <p>
* Registers a pop-up menu with the default id for extension. The default id
* is defined as the part id.
* </p>
* <p>
* By default, context menus include object contributions based on the
* editor input for the current editor. It is possible to override this
* behaviour by calling this method with <code>includeEditorInput</code>
* as <code>false</code>. This might be desirable for editors that
* present a localized view of an editor input (e.g., a node in a model
* editor).
* </p>
* <p>
* For a detailed description of context menu registration see
* {@link IWorkbenchPartSite#registerContextMenu(MenuManager, ISelectionProvider)}
* </p>
*
* @param menuManager
* the menu manager; must not be <code>null</code>.
* @param selectionProvider
* the selection provider; must not be <code>null</code>.
* @param includeEditorInput
* Whether the editor input should be included when adding object
* contributions to this context menu.
* @see IWorkbenchPartSite#registerContextMenu(MenuManager,
* ISelectionProvider)
* @since 3.1
*/
// virtual void registerContextMenu(MenuManager menuManager,
// ISelectionProvider selectionProvider, boolean includeEditorInput);
/**
* <p>
* Registers a pop-up menu with a particular id for extension. This method
* should only be called if the target part has more than one context menu
* to register.
* </p>
* <p>
* By default, context menus include object contributions based on the
* editor input for the current editor. It is possible to override this
* behaviour by calling this method with <code>includeEditorInput</code>
* as <code>false</code>. This might be desirable for editors that
* present a localized view of an editor input (e.g., a node in a model
* editor).
* </p>
* <p>
* For a detailed description of context menu registration see
* {@link IWorkbenchPartSite#registerContextMenu(MenuManager, ISelectionProvider)}
* </p>
*
* @param menuId
* the menu id; must not be <code>null</code>.
* @param menuManager
* the menu manager; must not be <code>null</code>.
* @param selectionProvider
* the selection provider; must not be <code>null</code>.
* @param includeEditorInput
* Whether the editor input should be included when adding object
* contributions to this context menu.
* @see IWorkbenchPartSite#registerContextMenu(MenuManager,
* ISelectionProvider)
* @since 3.1
*/
// virtual void registerContextMenu(String menuId, MenuManager menuManager,
// ISelectionProvider selectionProvider, boolean includeEditorInput);
};
}
#endif /*BERRYIEDITORSITE_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIFileEditorMapping.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryIFileEditorMapping.h
index bd55734c35..5ecb47afc8 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIFileEditorMapping.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIFileEditorMapping.h
@@ -1,113 +1,113 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIFILEEDITORMAPPING_H_
#define BERRYIFILEEDITORMAPPING_H_
#include <berryMacros.h>
#include "berryIEditorDescriptor.h"
#include <string>
#include <vector>
#include <list>
namespace berry {
/**
* \ingroup org_blueberry_ui
*
* An association between a file name/extension and a list of known editors for
* files of that type.
* <p>
* The name and extension can never empty or null. The name may contain
* the single wild card character (*) to indicate the editor applies to
* all files with the same extension (e.g. *.doc). The name can never
* embed the wild card character within itself (i.e. rep*)
* </p>
* <p>
* This interface is not intended to be implemented by clients.
* </p>
*
* @see IEditorRegistry#getFileEditorMappings
* @noimplement This interface is not intended to be implemented by clients.
*/
struct BERRY_UI IFileEditorMapping : public Object {
berryInterfaceMacro(IFileEditorMapping, berry)
virtual ~IFileEditorMapping();
/**
* Returns the default editor registered for this type mapping.
*
* @return the descriptor of the default editor, or <code>null</code> if there
* is no default editor registered. Will also return <code>null</code> if
* the default editor exists but fails the Expressions check.
*/
virtual IEditorDescriptor::Pointer GetDefaultEditor() = 0;
/**
* Returns the list of editors registered for this type mapping.
*
* @return a possibly empty list of editors.
*/
virtual std::list<IEditorDescriptor::Pointer> GetEditors() const = 0;
/**
* Returns the list of editors formerly registered for this type mapping
* which have since been deleted.
*
* @return a possibly empty list of editors
*/
virtual std::list<IEditorDescriptor::Pointer> GetDeletedEditors() const = 0;
/**
* Returns the file's extension for this type mapping.
*
* @return the extension for this mapping
*/
virtual std::string GetExtension() const = 0;
/**
* Returns the descriptor of the image to use for a file of this type.
* <p>
* The image is obtained from the default editor. A default file image is
* returned if no default editor is available.
* </p>
*
* @return the descriptor of the image to use for a resource of this type
*/
//virtual ImageDescriptor GetImageDescriptor() = 0;
/**
* Returns the label to use for this mapping.
* Labels have the form "<it>name</it>.<it>extension</it>".
*
* @return the label to use for this mapping
*/
virtual std::string GetLabel() const = 0;
/**
* Returns the file's name for this type mapping.
*
* @return the name for this mapping
*/
virtual std::string GetName() const = 0;
};
}
#endif /*BERRYIFILEEDITORMAPPING_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIFolderLayout.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryIFolderLayout.h
index 66eaecd83c..92e950ed79 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIFolderLayout.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIFolderLayout.h
@@ -1,56 +1,56 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIFOLDERLAYOUT_H_
#define BERRYIFOLDERLAYOUT_H_
#include "berryIPlaceholderFolderLayout.h"
namespace berry {
/**
* \ingroup org_blueberry_ui
*
* An <code>IFolderLayout</code> is used to define the initial views within a folder.
* The folder itself is contained within an <code>IPageLayout</code>.
* <p>
* This interface is not intended to be implemented by clients.
* </p>
*
* @see IPageLayout#createFolder
* @noimplement This interface is not intended to be implemented by clients.
*/
struct BERRY_UI IFolderLayout : public IPlaceholderFolderLayout {
berryInterfaceMacro(IFolderLayout, berry)
~IFolderLayout();
/**
* Adds a view with the given compound id to this folder.
* See the {@link IPageLayout} type documentation for more details about compound ids.
* The primary id must name a view contributed to the workbench's view extension point
* (named <code>"org.blueberry.ui.views"</code>).
*
* @param viewId the view id
*/
virtual void AddView(const std::string& viewId) = 0;
};
}
#endif /*BERRYIFOLDERLAYOUT_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIMemento.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/berryIMemento.cpp
index 7908c82f7f..8ca7be2c63 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIMemento.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIMemento.cpp
@@ -1,27 +1,27 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryIMemento.h"
namespace berry {
const std::string IMemento::TAG_ID = "IMemento.internal.id";
IMemento::~IMemento()
{
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIMemento.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryIMemento.h
index 37c3fb6d68..1a9186f59a 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIMemento.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIMemento.h
@@ -1,250 +1,250 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIMEMENTO_H_
#define BERRYIMEMENTO_H_
#include <berryMacros.h>
#include <berryObject.h>
#include <org_blueberry_ui_Export.h>
#include <string>
namespace berry
{
/**
* \ingroup org_blueberry_ui
*
* Interface to a memento used for saving the important state of an object
* in a form that can be persisted in the file system.
* <p>
* Mementos were designed with the following requirements in mind:
* <ol>
* <li>Certain objects need to be saved and restored across platform sessions.
* </li>
* <li>When an object is restored, an appropriate class for an object might not
* be available. It must be possible to skip an object in this case.</li>
* <li>When an object is restored, the appropriate class for the object may be
* different from the one when the object was originally saved. If so, the
* new class should still be able to read the old form of the data.</li>
* </ol>
* </p>
* <p>
* Mementos meet these requirements by providing support for storing a
* mapping of arbitrary string keys to primitive values, and by allowing
* mementos to have other mementos as children (arranged into a tree).
* A robust external storage format based on XML is used.
* </p><p>
* The key for an attribute may be any alpha numeric value. However, the
* value of <code>TAG_ID</code> is reserved for internal use.
* </p><p>
* This interface is not intended to be implemented or extended by clients.
* </p>
*
* @see IPersistableElement
* @see IElementFactory
* @noimplement This interface is not intended to be implemented by clients.
*
**/
struct BERRY_UI IMemento: public Object
{
berryInterfaceMacro(IMemento, berry)
/**
* Special reserved key used to store the memento id
* (value <code>"IMemento.internal.id"</code>).
*
* @see #getID()
*/
static const std::string TAG_ID; // = "IMemento.internal.id";
/**
* Creates a new child of this memento with the given type.
* <p>
* The <code>GetChild</code> and <code>GetChildren</code> methods
* are used to retrieve children of a given type.
* </p>
*
* @param type the type
* @return a new child memento
* @see #GetChild
* @see #GetChildren
*/
virtual IMemento::Pointer CreateChild(const std::string& type) = 0;
/**
* Creates a new child of this memento with the given type and id.
* The id is stored in the child memento (using a special reserved
* key, <code>TAG_ID</code>) and can be retrieved using <code>GetID</code>.
* <p>
* The <code>GetChild</code> and <code>GetChildren</code> methods
* are used to retrieve children of a given type.
* </p>
*
* @param type the type
* @param id the child id
* @return a new child memento with the given type and id
* @see #GetID
*/
virtual IMemento::Pointer CreateChild(const std::string& type,
const std::string& id) = 0;
/**
* Returns the first child with the given type id.
*
* @param type the type id
* @return the first child with the given type
*/
virtual IMemento::Pointer GetChild(const std::string& type) const = 0;
/**
* Returns all children with the given type id.
*
* @param type the type id
* @return an array of children with the given type
*/
virtual std::vector<IMemento::Pointer>
GetChildren(const std::string& type) const = 0;
/**
* Gets the floating point value of the given key.
*
* @param key the key
* @param value the value of the given key
* @return false if the key was not found or was found
* but was not a floating point number, else true
*/
virtual bool GetFloat(const std::string& key, double& value) const = 0;
/**
* Gets the integer value of the given key.
*
* @param key the key
* @param value the value of the given key
* @return false if the key was not found or was found
* but was not an integer, else true
*/
virtual bool GetInteger(const std::string& key, int& value) const = 0;
/**
* Gets the string value of the given key.
*
* @param key the key
* @param value the value of the given key
* @return false if the key was not found, else true
*/
virtual bool GetString(const std::string& key, std::string& value) const = 0;
/**
* Gets the boolean value of the given key.
*
* @param key the key
* @param value the value of the given key
* @return false if the key was not found, else true
*/
virtual bool GetBoolean(const std::string& key, bool& value) const = 0;
/**
* Returns the data of the Text node of the memento. Each memento is allowed
* only one Text node.
*
* @return the data of the Text node of the memento, or <code>null</code>
* if the memento has no Text node.
*/
virtual const std::string& GetTextData() const = 0;
/**
* Returns an array of all the attribute keys of the memento. This will not
* be <code>null</code>. If there are no keys, an array of length zero will
* be returned.
* @return an array with all the attribute keys of the memento
*/
virtual std::vector<std::string> GetAttributeKeys() const = 0;
/**
* Returns the type for this memento.
*
* @return the memento type
* @see #CreateChild(const std::string&)
* @see #CreateChild(const std::string&, const std::string&)
*/
virtual std::string GetType() const = 0;
/**
* Returns the id for this memento.
*
* @return the memento id, or <code>""</code> if none
* @see #CreateChild(const std::string&, const std::string&)
*/
virtual std::string GetID() const = 0;
/**
* Sets the value of the given key to the given floating point number.
*
* @param key the key
* @param value the value
*/
virtual void PutFloat(const std::string& key, double value) = 0;
/**
* Sets the value of the given key to the given integer.
*
* @param key the key
* @param value the value
*/
virtual void PutInteger(const std::string& key, int value) = 0;
/**
* Copy the attributes and children from <code>memento</code>
* to the receiver.
*
* @param memento the IMemento to be copied.
*/
virtual void PutMemento(IMemento::Pointer memento) = 0;
/**
* Sets the value of the given key to the given const std::string&.
*
* @param key the key
* @param value the value
*/
virtual void PutString(const std::string& key, const std::string& value) = 0;
/**
* Sets the value of the given key to the given boolean value.
*
* @param key the key
* @param value the value
*/
virtual void PutBoolean(const std::string& key, bool value) = 0;
/**
* Sets the memento's Text node to contain the given data. Creates the Text node if
* none exists. If a Text node does exist, it's current contents are replaced.
* Each memento is allowed only one text node.
*
* @param data the data to be placed on the Text node
*/
virtual void PutTextData(const std::string& data) = 0;
virtual ~IMemento();
};
} // namespace berry
#endif /*BERRYIMEMENTO_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryINullSelectionListener.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryINullSelectionListener.h
index 306588a0c2..ff520b0f06 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryINullSelectionListener.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryINullSelectionListener.h
@@ -1,101 +1,101 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYINULLSELECTIONLISTENER_H_
#define BERRYINULLSELECTIONLISTENER_H_
#include "berryISelectionListener.h"
namespace berry
{
/**
* Interface for listening to <code>null</code> selection changes.
* <p>
* This interface should be implemented by selection listeners
* that want to be notified when the selection becomes <code>null</code>.
* It has no methods. It simply indicates the desire to receive
* <code>null</code> selection events through the existing
* <code>SelectionChanged()</code> method. Either the part or the
* selection may be <code>null</code>.
* </p>
*
* @see ISelectionListener#SelectionChanged()
* @see IActionDelegate#SelectionChanged()
* @see ISelectionListener
*
*/
struct BERRY_UI INullSelectionListener : public ISelectionListener {
berryInterfaceMacro(INullSelectionListener, berry)
~INullSelectionListener();
};
/**
* \ingroup org_blueberry_ui
*
* This template can be used like this:
*
* <code>
* class MyClass {
*
* private:
* void HandleSelectionChanged(berry::IWorkbenchPart::Pointer part, berry::ISelection::ConstPointer selection)
* { // do something }
*
* berry::INullSelectionListener::Pointer m_SelectionListener;
*
* public:
* MyClass()
* : m_SelectionListener(new berry::NullSelectionChangedAdapter<MyClass>(this, &MyClass::HandleSelectionChanged))
* {
* // get the selection service
* // ...
* service->AddPostSelectionListener(m_SelectionListener);
* }
* };
* </code>
*/
template<typename R>
struct NullSelectionChangedAdapter: public INullSelectionListener
{
typedef R Listener;
typedef void
(R::*Callback)(IWorkbenchPart::Pointer, ISelection::ConstPointer);
NullSelectionChangedAdapter(R* l, Callback c) :
listener(l), callback(c)
{
poco_assert(listener);
poco_assert(callback);
}
void SelectionChanged(IWorkbenchPart::Pointer part, ISelection::ConstPointer selection)
{
(listener->*callback)(part, selection);
}
private:
Listener* listener;
Callback callback;
};
}
#endif /* BERRYINULLSELECTIONLISTENER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIPageLayout.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/berryIPageLayout.cpp
index 1ca01c924f..a37c56e4eb 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIPageLayout.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIPageLayout.cpp
@@ -1,57 +1,57 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryIPageLayout.h"
namespace berry {
const std::string IPageLayout::ID_EDITOR_AREA = "org.blueberry.ui.editors"; //$NON-NLS-1$
const std::string IPageLayout::ID_RES_NAV = "org.blueberry.ui.views.ResourceNavigator"; //$NON-NLS-1$
const std::string IPageLayout::ID_PROP_SHEET = "org.blueberry.ui.views.PropertySheet"; //$NON-NLS-1$
const std::string IPageLayout::ID_OUTLINE = "org.blueberry.ui.views.ContentOutline"; //$NON-NLS-1$
const std::string IPageLayout::ID_BOOKMARKS = "org.blueberry.ui.views.BookmarkView"; //$NON-NLS-1$
const std::string IPageLayout::ID_PROBLEM_VIEW = "org.blueberry.ui.views.ProblemView"; //$NON-NLS-1$
const std::string IPageLayout::ID_PROGRESS_VIEW = "org.blueberry.ui.views.ProgressView"; //$NON-NLS-1$
const std::string IPageLayout::ID_TASK_LIST = "org.blueberry.ui.views.TaskList"; //$NON-NLS-1$
const std::string IPageLayout::ID_NAVIGATE_ACTION_SET = "org.blueberry.ui.NavigateActionSet"; //$NON-NLS-1$
const int IPageLayout::LEFT = 1;
const int IPageLayout::RIGHT = 2;
const int IPageLayout::TOP = 3;
const int IPageLayout::BOTTOM = 4;
const float IPageLayout::RATIO_MIN = 0.05f;
const float IPageLayout::RATIO_MAX = 0.95f;
const float IPageLayout::DEFAULT_VIEW_RATIO = 0.5f;
const float IPageLayout::INVALID_RATIO = -1.0;
const float IPageLayout::NULL_RATIO = -2.0;
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIPageLayout.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryIPageLayout.h
index ec77c4e271..4eaa6253fb 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIPageLayout.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIPageLayout.h
@@ -1,501 +1,501 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIPAGELAYOUT_H_
#define BERRYIPAGELAYOUT_H_
#include "berryIFolderLayout.h"
#include "berryIPlaceholderFolderLayout.h"
#include "berryIViewLayout.h"
#include "berryIPerspectiveDescriptor.h"
#include <string>
namespace berry {
/**
* \ingroup org_blueberry_ui
*
* A page layout defines the initial layout for a perspective within a page
* in a workbench window.
* <p>
* This interface is not intended to be implemented by clients.
* </p>
* <p>
* When a perspective is opened, it creates a new page layout with a single editor area.
* This layout is then passed to the perspective factory (implementation of
* {@link org.blueberry.ui.IPerspectiveFactory#createInitialLayout(IPageLayout)}) where
* additional views and other content can be added, using the existing editor area as
* the initial point of reference.
* </p>
* <p>
* In some cases, multiple instances of a particular view may need to be added
* to the same layout. These are disambiguated using a secondary id.
* In layout methods taking a view id, the id can have the compound form:
* <strong>primaryId [':' secondaryId]</strong>.
* If a secondary id is given, the view must allow multiple instances by
* having specified <code>allowMultiple="true"</code> in its extension.
* View placeholders may also have a secondary id.
* </p>
* <p>
* Wildcards are permitted in placeholder ids (but not regular view ids).
* '*' matches any substring, '?' matches any single character.
* Wildcards can be specified for the primary id, the secondary id, or both.
* For example, the placeholder "someView:*" will match any occurrence of the view
* that has primary id "someView" and that also has some non-null secondary id.
* Note that this placeholder will not match the view if it has no secondary id,
* since the compound id in this case is simply "someView".
* </p>
* <p>
* Example of populating a layout with standard workbench views:
* <pre>
* IPageLayout layout = ...
* // Get the editor area.
* String editorArea = layout.getEditorArea();
*
* // Top left: Resource Navigator view and Bookmarks view placeholder
* IFolderLayout topLeft = layout.createFolder("topLeft", IPageLayout.LEFT, 0.25f,
* editorArea);
* topLeft.addView(IPageLayout.ID_RES_NAV);
* topLeft.addPlaceholder(IPageLayout.ID_BOOKMARKS);
*
* // Bottom left: Outline view and Property Sheet view
* IFolderLayout bottomLeft = layout.createFolder("bottomLeft", IPageLayout.BOTTOM, 0.50f,
* "topLeft");
* bottomLeft.addView(IPageLayout.ID_OUTLINE);
* bottomLeft.addView(IPageLayout.ID_PROP_SHEET);
*
* // Bottom right: Task List view
* layout.addView(IPageLayout.ID_TASK_LIST, IPageLayout.BOTTOM, 0.66f, editorArea);
* </pre>
* </p>
* @noimplement This interface is not intended to be implemented by clients.
*/
struct BERRY_UI IPageLayout : public Object {
berryInterfaceMacro(IPageLayout, berry);
/**
* The part id for the workbench's editor area. This may only be used
* as a reference part for view addition.
*/
static const std::string ID_EDITOR_AREA; // = "org.blueberry.ui.editors"; //$NON-NLS-1$
/**
* The view id for the workbench's Resource Navigator standard component.
*/
static const std::string ID_RES_NAV; // = "org.blueberry.ui.views.ResourceNavigator"; //$NON-NLS-1$
/**
* The view id for the workbench's Property Sheet standard component.
*/
static const std::string ID_PROP_SHEET; // = "org.blueberry.ui.views.PropertySheet"; //$NON-NLS-1$
/**
* The view id for the workbench's Content Outline standard component.
*/
static const std::string ID_OUTLINE; // = "org.blueberry.ui.views.ContentOutline"; //$NON-NLS-1$
/**
* The view id for the workbench's Bookmark Navigator standard component.
*/
static const std::string ID_BOOKMARKS; // = "org.blueberry.ui.views.BookmarkView"; //$NON-NLS-1$
/**
* The view id for the workbench's Problems View standard component.
* @since 3.0
*/
static const std::string ID_PROBLEM_VIEW; // = "org.blueberry.ui.views.ProblemView"; //$NON-NLS-1$
/**
* The view id for the workbench's Progress View standard component.
* @since 3.2
*/
static const std::string ID_PROGRESS_VIEW; // = "org.blueberry.ui.views.ProgressView"; //$NON-NLS-1$
/**
* The view id for the workbench's Task List standard component.
*/
static const std::string ID_TASK_LIST; // = "org.blueberry.ui.views.TaskList"; //$NON-NLS-1$
/**
* Id of the navigate action set.
* (value <code>"org.blueberry.ui.NavigateActionSet"</code>)
* @since 2.1
*/
static const std::string ID_NAVIGATE_ACTION_SET; // = "org.blueberry.ui.NavigateActionSet"; //$NON-NLS-1$
/**
* Relationship constant indicating a part should be placed to the left of
* its relative.
*/
static const int LEFT; // = 1;
/**
* Relationship constant indicating a part should be placed to the right of
* its relative.
*/
static const int RIGHT; // = 2;
/**
* Relationship constant indicating a part should be placed above its
* relative.
*/
static const int TOP; // = 3;
/**
* Relationship constant indicating a part should be placed below its
* relative.
*/
static const int BOTTOM; // = 4;
/**
* Minimum acceptable ratio value when adding a view
* @since 2.0
*/
static const float RATIO_MIN; // = 0.05f;
/**
* Maximum acceptable ratio value when adding a view
* @since 2.0
*/
static const float RATIO_MAX; // = 0.95f;
/**
* The default view ratio width for regular (non-fast) views.
* @since 2.0
*/
static const float DEFAULT_VIEW_RATIO; // = 0.5f;
/**
* A variable used to represent invalid ratios.
* @since 2.0
*/
static const float INVALID_RATIO; // = -1f;
/**
* A variable used to represent a ratio which has not been specified.
* @since 2.0
*/
static const float NULL_RATIO; // = -2f;
/**
* Adds an action set with the given id to this page layout.
* The id must name an action set contributed to the workbench's extension
* point (named <code>"org.blueberry.ui.actionSet"</code>).
*
* @param actionSetId the action set id
*/
//virtual void AddActionSet(const std::string& actionSetId) = 0;
/**
* Adds a perspective shortcut to the page layout.
* These are typically shown in the UI to allow rapid navigation to appropriate new wizards.
* For example, in the Eclipse IDE, these appear as items under the Window > Open Perspective menu.
* The id must name a perspective extension contributed to the
* workbench's perspectives extension point (named <code>"org.blueberry.ui.perspectives"</code>).
*
* @param id the perspective id
*/
virtual void AddPerspectiveShortcut(const std::string& id) = 0;
/**
* Adds a view placeholder to this page layout.
* A view placeholder is used to define the position of a view before the view
* appears. Initially, it is invisible; however, if the user ever opens a view
* whose compound id matches the placeholder, the view will appear at the same
* location as the placeholder.
* See the {@link IPageLayout} type documentation for more details about compound ids.
* If the placeholder contains wildcards, it remains in the layout, otherwise
* it is replaced by the view.
* If the primary id of the placeholder has no wildcards, it must refer to a view
* contributed to the workbench's view extension point
* (named <code>"org.blueberry.ui.views"</code>).
*
* @param viewId the compound view id (wildcards allowed)
* @param relationship the position relative to the reference part;
* one of <code>TOP</code>, <code>BOTTOM</code>, <code>LEFT</code>,
* or <code>RIGHT</code>
* @param ratio a ratio specifying how to divide the space currently occupied by the reference part,
* in the range <code>0.05f</code> to <code>0.95f</code>.
* Values outside this range will be clipped to facilitate direct manipulation.
* For a vertical split, the part on top gets the specified ratio of the current space
* and the part on bottom gets the rest.
* Likewise, for a horizontal split, the part at left gets the specified ratio of the current space
* and the part at right gets the rest.
* @param refId the id of the reference part; either a view id, a folder id,
* or the special editor area id returned by <code>getEditorArea</code>
*/
virtual void AddPlaceholder(const std::string& viewId, int relationship, float ratio,
const std::string& refId) = 0;
/**
* Adds an item to the Show In prompter.
* The id must name a view contributed to the workbench's view extension point
* (named <code>"org.blueberry.ui.views"</code>).
*
* @param id the view id
*
* @since 2.1
*/
virtual void AddShowInPart(const std::string& id) = 0;
/**
* Adds a show view shortcut to the page layout.
* These are typically shown in the UI to allow rapid navigation to appropriate views.
* For example, in the Eclipse IDE, these appear as items under the Window > Show View menu.
* The id must name a view contributed to the workbench's views extension point
* (named <code>"org.blueberry.ui.views"</code>).
*
* @param id the view id
*/
virtual void AddShowViewShortcut(const std::string& id) = 0;
/**
* Adds a view with the given compound id to this page layout.
* See the {@link IPageLayout} type documentation for more details about compound ids.
* The primary id must name a view contributed to the workbench's view extension point
* (named <code>"org.blueberry.ui.views"</code>).
*
* @param viewId the compound view id
* @param relationship the position relative to the reference part;
* one of <code>TOP</code>, <code>BOTTOM</code>, <code>LEFT</code>,
* or <code>RIGHT</code>
* @param ratio a ratio specifying how to divide the space currently occupied by the reference part,
* in the range <code>0.05f</code> to <code>0.95f</code>.
* Values outside this range will be clipped to facilitate direct manipulation.
* For a vertical split, the part on top gets the specified ratio of the current space
* and the part on bottom gets the rest.
* Likewise, for a horizontal split, the part at left gets the specified ratio of the current space
* and the part at right gets the rest.
* @param refId the id of the reference part; either a view id, a folder id,
* or the special editor area id returned by <code>getEditorArea</code>
*/
virtual void AddView(const std::string& viewId, int relationship, float ratio,
const std::string& refId) = 0;
/**
* Creates and adds a new folder with the given id to this page layout.
* The position and relative size of the folder is expressed relative to
* a reference part.
*
* @param folderId the id for the new folder. This must be unique within
* the layout to avoid collision with other parts.
* @param relationship the position relative to the reference part;
* one of <code>TOP</code>, <code>BOTTOM</code>, <code>LEFT</code>,
* or <code>RIGHT</code>
* @param ratio a ratio specifying how to divide the space currently occupied by the reference part,
* in the range <code>0.05f</code> to <code>0.95f</code>.
* Values outside this range will be clipped to facilitate direct manipulation.
* For a vertical split, the part on top gets the specified ratio of the current space
* and the part on bottom gets the rest.
* Likewise, for a horizontal split, the part at left gets the specified ratio of the current space
* and the part at right gets the rest.
* @param refId the id of the reference part; either a view id, a folder id,
* or the special editor area id returned by <code>getEditorArea</code>
* @return the new folder
*/
virtual IFolderLayout::Pointer CreateFolder(const std::string& folderId, int relationship,
float ratio, const std::string& refId) = 0;
/**
* Creates and adds a placeholder for a new folder with the given id to this page layout.
* The position and relative size of the folder is expressed relative to
* a reference part.
*
* @param folderId the id for the new folder. This must be unique within
* the layout to avoid collision with other parts.
* @param relationship the position relative to the reference part;
* one of <code>TOP</code>, <code>BOTTOM</code>, <code>LEFT</code>,
* or <code>RIGHT</code>
* @param ratio a ratio specifying how to divide the space currently occupied by the reference part,
* in the range <code>0.05f</code> to <code>0.95f</code>.
* Values outside this range will be clipped to facilitate direct manipulation.
* For a vertical split, the part on top gets the specified ratio of the current space
* and the part on bottom gets the rest.
* Likewise, for a horizontal split, the part at left gets the specified ratio of the current space
* and the part at right gets the rest.
* @param refId the id of the reference part; either a view id, a folder id,
* or the special editor area id returned by <code>getEditorArea</code>
* @return a placeholder for the new folder
* @since 2.0
*/
virtual IPlaceholderFolderLayout::Pointer CreatePlaceholderFolder(const std::string& folderId,
int relationship, float ratio, const std::string& refId) = 0;
/**
* Returns the special identifier for the editor area in this page
* layout. The identifier for the editor area is also stored in
* <code>ID_EDITOR_AREA</code>.
* <p>
* The editor area is automatically added to each layout before anything else.
* It should be used as the point of reference when adding views to a layout.
* </p>
*
* @return the special id of the editor area
*/
virtual std::string GetEditorArea() = 0;
/**
* Returns whether the page's layout will show
* the editor area.
*
* @return <code>true</code> when editor area visible, <code>false</code> otherwise
*/
virtual bool IsEditorAreaVisible() = 0;
/**
* Show or hide the editor area for the page's layout.
*
* @param showEditorArea <code>true</code> to show the editor area, <code>false</code> to hide the editor area
*/
virtual void SetEditorAreaVisible(bool showEditorArea) = 0;
/**
* Sets whether this layout is fixed.
* In a fixed layout, layout parts cannot be moved or zoomed, and the initial
* set of views cannot be closed.
*
* @param isFixed <code>true</code> if this layout is fixed, <code>false</code> if not
* @since 3.0
*/
virtual void SetFixed(bool isFixed) = 0;
/**
* Returns <code>true</code> if this layout is fixed, <code>false</code> if not.
* In a fixed layout, layout parts cannot be moved or zoomed, and the initial
* set of views cannot be closed.
* The default is <code>false</code>.
*
* @return <code>true</code> if this layout is fixed, <code>false</code> if not.
* @since 3.0
*/
virtual bool IsFixed() = 0;
/**
* Returns the layout for the view or placeholder with the given compound id in
* this page layout.
* See the {@link IPageLayout} type documentation for more details about compound ids.
* Returns <code>null</code> if the specified view or placeholder is unknown to the layout.
*
* @param id the compound view id or placeholder
* @return the view layout, or <code>null</code>
* @since 3.0
*/
virtual IViewLayout::Pointer GetViewLayout(const std::string& id) = 0;
/**
* Adds a standalone view with the given compound id to this page layout.
* See the {@link IPageLayout} type documentation for more details about compound ids.
* A standalone view cannot be docked together with other views.
* A standalone view's title can optionally be hidden. If hidden,
* then any controls typically shown with the title (such as the close button)
* are also hidden. Any contributions or other content from the view itself
* are always shown (e.g. toolbar or view menu contributions, content description).
* <p>
* The id must name a view contributed to the workbench's view extension point
* (named <code>"org.blueberry.ui.views"</code>).
* </p>
*
* @param viewId the compound view id
* @param showTitle <code>true</code> to show the title and related controls,
* <code>false</code> to hide them
* @param relationship the position relative to the reference part;
* one of <code>TOP</code>, <code>BOTTOM</code>, <code>LEFT</code>,
* or <code>RIGHT</code>
* @param ratio a ratio specifying how to divide the space currently occupied by the reference part,
* in the range <code>0.05f</code> to <code>0.95f</code>.
* Values outside this range will be clipped to facilitate direct manipulation.
* For a vertical split, the part on top gets the specified ratio of the current space
* and the part on bottom gets the rest.
* Likewise, for a horizontal split, the part at left gets the specified ratio of the current space
* and the part at right gets the rest.
* @param refId the id of the reference part; either a view id, a folder id,
* or the special editor area id returned by <code>getEditorArea</code>
*
* @since 3.0
*/
virtual void AddStandaloneView(const std::string& viewId, bool showTitle,
int relationship, float ratio, const std::string& refId) = 0;
/**
* Adds a standalone view placeholder to this page layout. A view
* placeholder is used to define the position of a view before the view
* appears. Initially, it is invisible; however, if the user ever opens a
* view whose compound id matches the placeholder, the view will appear at
* the same location as the placeholder. See the {@link IPageLayout} type
* documentation for more details about compound ids. If the placeholder
* contains wildcards, it remains in the layout, otherwise it is replaced by
* the view. If the primary id of the placeholder has no wildcards, it must
* refer to a view contributed to the workbench's view extension point
* (named <code>"org.blueberry.ui.views"</code>).
*
* @param viewId
* the compound view id (wildcards allowed)
* @param relationship
* the position relative to the reference part; one of
* <code>TOP</code>, <code>BOTTOM</code>, <code>LEFT</code>,
* or <code>RIGHT</code>
* @param ratio
* a ratio specifying how to divide the space currently occupied
* by the reference part, in the range <code>0.05f</code> to
* <code>0.95f</code>. Values outside this range will be
* clipped to facilitate direct manipulation. For a vertical
* split, the part on top gets the specified ratio of the current
* space and the part on bottom gets the rest. Likewise, for a
* horizontal split, the part at left gets the specified ratio of
* the current space and the part at right gets the rest.
* @param refId
* the id of the reference part; either a view id, a folder id,
* or the special editor area id returned by
* <code>getEditorArea</code>
* @param showTitle
* true to show the view's title, false if not
*
* @since 3.2
*/
virtual void AddStandaloneViewPlaceholder(const std::string& viewId, int relationship,
float ratio, const std::string& refId, bool showTitle) = 0;
/**
* Returns the perspective descriptor for the perspective being layed out.
*
* @return the perspective descriptor for the perspective being layed out
* @since 3.2
*/
virtual IPerspectiveDescriptor::Pointer GetDescriptor() = 0;
/**
* Returns the folder layout for the view or placeholder with the given
* compound id in this page layout. See the {@link IPageLayout} type
* documentation for more details about compound ids. Returns
* <code>null</code> if the specified view or placeholder is unknown to
* the layout, or the placeholder was not in a folder.
*
* @param id
* the compound view id or placeholder. Must not be
* <code>null</code>.
* @return the folder layout, or <code>null</code>
* @since 3.3
*/
virtual IPlaceholderFolderLayout::Pointer GetFolderForView(const std::string& id) = 0;
};
}
#endif /*BERRYIPAGELAYOUT_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIPageService.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryIPageService.h
index 809e2d5c6a..22e309ebdd 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIPageService.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIPageService.h
@@ -1,108 +1,108 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIPAGESERVICE_H_
#define BERRYIPAGESERVICE_H_
#include <org_blueberry_ui_Export.h>
#include "berryIPerspectiveListener.h"
namespace berry {
struct IWorkbenchPage;
/**
* A page service tracks the page and perspective lifecycle events
* within a workbench window.
* <p>
* This service can be acquired from your service locator:
* <pre>
* IPageService service = (IPageService) getSite().getService(IPageService.class);
* </pre>
* <ul>
* <li>This service is not available globally, only from the workbench window level down.</li>
* </ul>
* </p>
*
* @see IWorkbenchWindow
* @see IPageListener
* @see IPerspectiveListener
* @see org.blueberry.ui.services.IServiceLocator#getService(Class)
* @noimplement This interface is not intended to be implemented by clients.
*/
struct BERRY_UI IPageService {
virtual ~IPageService();
/**
* Adds the given listener for page lifecycle events.
* Has no effect if an identical listener is already registered.
* <p>
* <b>Note:</b> listeners should be removed when no longer necessary. If
* not, they will be removed when the IServiceLocator used to acquire this
* service is disposed.
* </p>
*
* @param listener a page listener
* @see #removePageListener(IPageListener)
*/
//virtual void AddPageListener(IPageListener listener);
/**
* Adds the given listener for a page's perspective lifecycle events.
* Has no effect if an identical listener is already registered.
* <p>
* <b>Note:</b> listeners should be removed when no longer necessary. If
* not, they will be removed when the IServiceLocator used to acquire this
* service is disposed.
* </p>
*
* @param listener a perspective listener
* @see #removePerspectiveListener(IPerspectiveListener)
*/
virtual void AddPerspectiveListener(IPerspectiveListener::Pointer listener) = 0;
/**
* Returns the active page.
*
* @return the active page, or <code>null</code> if no page is currently active
*/
virtual SmartPointer<IWorkbenchPage> GetActivePage() = 0;
/**
* Removes the given page listener.
* Has no affect if an identical listener is not registered.
*
* @param listener a page listener
*/
//virtual void RemovePageListener(IPageListener listener);
/**
* Removes the given page's perspective listener.
* Has no affect if an identical listener is not registered.
*
* @param listener a perspective listener
*/
virtual void RemovePerspectiveListener(IPerspectiveListener::Pointer listener) = 0;
virtual IPerspectiveListener::Events& GetPerspectiveEvents() = 0;
};
}
#endif /* BERRYIPAGESERVICE_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIPartListener.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/berryIPartListener.cpp
index 2f67d08dad..706fd60d83 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIPartListener.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIPartListener.cpp
@@ -1,63 +1,63 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryIPartListener.h"
namespace berry {
void
IPartListener::Events
::AddListener(IPartListener::Pointer l)
{
if (l.IsNull()) return;
Types t = l->GetPartEventTypes();
if (t & ACTIVATED)
partActivated += Delegate(l.GetPointer(), &IPartListener::PartActivated);
if (t & BROUGHT_TO_TOP)
partBroughtToTop += Delegate(l.GetPointer(), &IPartListener::PartBroughtToTop);
if (t & CLOSED)
partClosed += Delegate(l.GetPointer(), &IPartListener::PartClosed);
if (t & DEACTIVATED)
partDeactivated += Delegate(l.GetPointer(), &IPartListener::PartDeactivated);
if (t & OPENED)
partOpened += Delegate(l.GetPointer(), &IPartListener::PartOpened);
if (t & HIDDEN)
partHidden += Delegate(l.GetPointer(), &IPartListener::PartHidden);
if (t & VISIBLE)
partVisible += Delegate(l.GetPointer(), &IPartListener::PartVisible);
if (t & INPUT_CHANGED)
partInputChanged += Delegate(l.GetPointer(), &IPartListener::PartInputChanged);
}
void
IPartListener::Events
::RemoveListener(IPartListener::Pointer l)
{
if (l.IsNull()) return;
partActivated -= Delegate(l.GetPointer(), &IPartListener::PartActivated);
partBroughtToTop -= Delegate(l.GetPointer(), &IPartListener::PartBroughtToTop);
partClosed -= Delegate(l.GetPointer(), &IPartListener::PartClosed);
partDeactivated -= Delegate(l.GetPointer(), &IPartListener::PartDeactivated);
partOpened -= Delegate(l.GetPointer(), &IPartListener::PartOpened);
partHidden -= Delegate(l.GetPointer(), &IPartListener::PartHidden);
partVisible -= Delegate(l.GetPointer(), &IPartListener::PartVisible);
partInputChanged -= Delegate(l.GetPointer(), &IPartListener::PartInputChanged);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIPartListener.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryIPartListener.h
index f60a090b60..1038c882b6 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIPartListener.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIPartListener.h
@@ -1,163 +1,163 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIPARTLISTENER_H_
#define BERRYIPARTLISTENER_H_
#include <berryMacros.h>
#include <berryMessage.h>
#include <org_blueberry_ui_Export.h>
#include "berryIWorkbenchPartReference.h"
namespace berry {
/**
* \ingroup org_blueberry_ui
*
* Interface for listening to part lifecycle events.
* <p>
* This interface may be implemented by clients.
* </p>
*
* @see IPartService#AddPartListener(IPartListener)
*/
struct BERRY_UI IPartListener : public virtual Object {
berryInterfaceMacro(IPartListener, berry);
struct Events {
enum Type {
NONE = 0x00000000,
ACTIVATED = 0x00000001,
BROUGHT_TO_TOP = 0x00000002,
CLOSED = 0x00000004,
DEACTIVATED = 0x00000008,
OPENED = 0x00000010,
HIDDEN = 0x00000020,
VISIBLE = 0x00000040,
INPUT_CHANGED = 0x00000080,
ALL = 0xffffffff
};
BERRY_DECLARE_FLAGS(Types, Type)
typedef Message1<IWorkbenchPartReference::Pointer> PartEvent;
PartEvent partActivated;
PartEvent partBroughtToTop;
PartEvent partClosed;
PartEvent partDeactivated;
PartEvent partOpened;
PartEvent partHidden;
PartEvent partVisible;
PartEvent partInputChanged;
void AddListener(IPartListener::Pointer listener);
void RemoveListener(IPartListener::Pointer listener);
private:
typedef MessageDelegate1<IPartListener, IWorkbenchPartReference::Pointer> Delegate;
};
virtual Events::Types GetPartEventTypes() const = 0;
/**
* Notifies this listener that the given part has been activated.
*
* @param partRef the part that was activated
* @see IWorkbenchPage#activate
*/
virtual void PartActivated(IWorkbenchPartReference::Pointer /*partRef*/) {};
/**
* Notifies this listener that the given part has been brought to the top.
* <p>
* These events occur when an editor is brought to the top in the editor area,
* or when a view is brought to the top in a page book with multiple views.
* They are normally only sent when a part is brought to the top
* programmatically (via <code>IPerspective.bringToTop</code>). When a part is
* activated by the user clicking on it, only <code>partActivated</code> is sent.
* </p>
*
* @param partRef the part that was surfaced
* @see IWorkbenchPage#bringToTop
*/
virtual void PartBroughtToTop(IWorkbenchPartReference::Pointer /*partRef*/) {};
/**
* Notifies this listener that the given part has been closed.
* <p>
* Note that if other perspectives in the same page share the view,
* this notification is not sent. It is only sent when the view
* is being removed from the page entirely (it is being disposed).
* </p>
*
* @param partRef the part that was closed
* @see IWorkbenchPage#hideView
*/
virtual void PartClosed(IWorkbenchPartReference::Pointer /*partRef*/) {};
/**
* Notifies this listener that the given part has been deactivated.
*
* @param partRef the part that was deactivated
* @see IWorkbenchPage#activate
*/
virtual void PartDeactivated(IWorkbenchPartReference::Pointer /*partRef*/) {};
/**
* Notifies this listener that the given part has been opened.
* <p>
* Note that if other perspectives in the same page share the view,
* this notification is not sent. It is only sent when the view
* is being newly opened in the page (it is being created).
* </p>
*
* @param partRef the part that was opened
* @see IWorkbenchPage#showView
*/
virtual void PartOpened(IWorkbenchPartReference::Pointer /*partRef*/) {};
/**
* Notifies this listener that the given part is hidden or obscured by another part.
*
* @param partRef the part that is hidden or obscured by another part
*/
virtual void PartHidden(IWorkbenchPartReference::Pointer /*partRef*/) {};
/**
* Notifies this listener that the given part is visible.
*
* @param partRef the part that is visible
*/
virtual void PartVisible(IWorkbenchPartReference::Pointer /*partRef*/) {};
/**
* Notifies this listener that the given part's input was changed.
*
* @param partRef the part whose input was changed
*/
virtual void PartInputChanged(IWorkbenchPartReference::Pointer /*partRef*/) {};
};
} // namespace berry
BERRY_DECLARE_OPERATORS_FOR_FLAGS(berry::IPartListener::Events::Types)
#endif /*BERRYIPARTLISTENER_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIPartService.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryIPartService.h
index 2a45c3c68d..5c50178204 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIPartService.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIPartService.h
@@ -1,84 +1,84 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIPARTSERVICE_H_
#define BERRYIPARTSERVICE_H_
#include <org_blueberry_ui_Export.h>
#include "berryIWorkbenchPart.h"
#include "berryIWorkbenchPartReference.h"
#include "berryIPartListener.h"
namespace berry {
/**
* \ingroup org_blueberry_ui
*
* A part service tracks the creation and activation of parts within a
* workbench page.
* <p>
* This interface is not intended to be implemented by clients.
* </p>
*
* @see IWorkbenchPage
*/
struct BERRY_UI IPartService {
virtual ~IPartService();
/**
* Adds the given observer for part lifecycle events.
* Has no effect if an identical listener is already registered.
* <p>
* <b>Note:</b> listeners should be removed when no longer necessary. If
* not, they will be removed when the IServiceLocator used to acquire this
* service is disposed.
* </p>
*
* @param listener a part listener
* @see #removePartListener(IPartListener)
*/
virtual void AddPartListener(IPartListener::Pointer listener) = 0;
/**
* Returns the active part.
*
* @return the active part, or <code>null</code> if no part is currently active
*/
virtual IWorkbenchPart::Pointer GetActivePart() = 0;
/**
* Returns the active part reference.
*
* @return the active part reference, or <code>null</code> if no part
* is currently active
*/
virtual IWorkbenchPartReference::Pointer GetActivePartReference() = 0;
/**
* Removes the given part listener.
* Has no affect if an identical listener is not registered.
*
* @param listener a part listener
*/
virtual void RemovePartListener(IPartListener::Pointer listener) = 0;
};
} // namespace berry
#endif /*BERRYIPARTSERVICE_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIPathEditorInput.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryIPathEditorInput.h
index 0ebbc60625..3dcf5a28f8 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIPathEditorInput.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIPathEditorInput.h
@@ -1,63 +1,63 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIPATHEDITORINPUT_H_
#define BERRYIPATHEDITORINPUT_H_
#include "berryIEditorInput.h"
#include <Poco/Path.h>
namespace berry {
/**
* \ingroup org_blueberry_ui
*
* This interface defines an editor input based on the local file system path
* of a file.
* <p>
* Clients implementing this editor input interface should override
* <code>Object.equals(Object)</code> to answer true for two inputs
* that are the same. The <code>IWorkbenchPage.openEditor</code> APIs
* are dependent on this to find an editor with the same input.
* </p><p>
* Path-oriented editors should support this as a valid input type, and
* can allow full read-write editing of its content.
* </p><p>
* All editor inputs must implement the <code>IAdaptable</code> interface;
* extensions are managed by the platform's adapter manager.
* </p>
*
* @see org.blueberry.core.runtime.IPath
* @since 3.0
*/
struct BERRY_UI IPathEditorInput : public IEditorInput {
berryInterfaceMacro(IPathEditorInput, berry)
virtual ~IPathEditorInput();
/**
* Returns the local file system path of the file underlying this editor input.
*
* @return a local file system path
*/
virtual Poco::Path GetPath() const = 0;
};
}
#endif /*BERRYIPATHEDITORINPUT_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIPerspectiveDescriptor.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryIPerspectiveDescriptor.h
index 9b1db23b1d..d477b796ce 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIPerspectiveDescriptor.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIPerspectiveDescriptor.h
@@ -1,106 +1,106 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 <berryMacros.h>
#include <berryObject.h>
#include <org_blueberry_ui_Export.h>
#include "berryImageDescriptor.h"
namespace berry {
/**
* \ingroup org_blueberry_ui
*
* A perspective descriptor describes a perspective in an
* <code>IPerspectiveRegistry</code>.
* <p>
* 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.
* <ul>
* <li>A predefined perspective is defined by an extension to the workbench's
* perspective extension point (<code>"org.blueberry.ui.perspectives"</code>).
* The extension defines a id, label, and <code>IPerspectiveFactory</code>.
* A perspective factory is used to define the initial layout for a page.
* </li>
* <li>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.
* </li>
* </ul>
* </p>
* <p>
* 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 <code>Open Perspective</code> menu. When selected, the views
* and actions within the active page rearrange to reflect the perspective.
* </p>
* <p>
* This interface is not intended to be implemented by clients.
* </p>
* @see IPerspectiveRegistry
* @noimplement This interface is not intended to be implemented by clients.
*/
struct BERRY_UI IPerspectiveDescriptor : public Object {
berryInterfaceMacro(IPerspectiveDescriptor, berry)
virtual ~IPerspectiveDescriptor();
/**
* Returns the description of this perspective.
* This is the value of its <code>"description"</code> 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 <code>"id"</code> 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 <code>"label"</code> attribute.
*
* @return the label
*/
virtual std::string GetLabel() const = 0;
};
}
#endif /*BERRYIPERSPECTIVEDESCRIPTOR_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIPerspectiveFactory.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryIPerspectiveFactory.h
index 901aea322a..18dd47eeda 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIPerspectiveFactory.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIPerspectiveFactory.h
@@ -1,111 +1,111 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIPERSPECTIVEFACTORY_H_
#define BERRYIPERSPECTIVEFACTORY_H_
#include <berryMacros.h>
#include <org_blueberry_ui_Export.h>
#include "berryIPageLayout.h"
#include <QObject>
namespace berry {
/**
* A perspective factory generates the initial page layout and visible
* action set for a page.
* <p>
* When a new page is created in the workbench a perspective is used to define
* the initial page layout. If this is a predefined perspective (based on an extension to
* the workbench's perspective extension point) an <code>IPerspectiveFactory</code>
* is used to define the initial page layout.
* </p><p>
* The factory for the perspective is created and passed an <code>IPageLayout</code>
* where views can be added. The default layout consists of the editor area with no
* additional views. Additional views are added to the layout using
* the editor area as the initial point of reference. The factory is used only briefly
* while a new page is created; then discarded.
* </p><p>
* To define a perspective clients should implement this interface and
* include the name of their class in an extension to the workbench's perspective
* extension point (named <code>"org.blueberry.ui.perspectives"</code>). For example,
* the plug-in's XML markup might contain:
* <pre>
* &lt;extension point="org.blueberry.ui.perspectives"&gt;
* &lt;perspective
* id="com.example.plugin.perspective"
* name="My Perspective"
* class="namespaze::MyPerspective"&gt;
* &lt;/perspective&gt;
* &lt;/extension&gt;
* </pre>
* </p><p>
* Example of populating a page with standard workbench views:
* <pre>
* public: void CreateInitialLayout(IPageLayout layout) {
* // Get the editor area.
* std::string editorArea = layout->GetEditorArea();
*
* // Top left: Resource Navigator view and Bookmarks view placeholder
* IFolderLayout::Pointer topLeft = layout->CreateFolder("topLeft", IPageLayout::LEFT, 0.25f,
* editorArea);
* topLeft->AddView(IPageLayout::ID_RES_NAV);
* topLeft->AddPlaceholder(IPageLayout::ID_BOOKMARKS);
*
* // Bottom left: Outline view and Property Sheet view
* IFolderLayout::Pointer bottomLeft = layout->CreateFolder("bottomLeft", IPageLayout::BOTTOM, 0.50f,
* "topLeft");
* bottomLeft->AddView(IPageLayout::ID_OUTLINE);
* bottomLeft->AddView(IPageLayout::ID_PROP_SHEET);
*
* // Bottom right: Task List view
* layout->AddView(IPageLayout::ID_TASK_LIST, IPageLayout::BOTTOM, 0.66f, editorArea);
* }
* </pre>
* </p><p>
* Within the workbench a user may override the visible views, layout and
* action sets of a predefined perspective to create a custom perspective. In such cases
* the layout is persisted by the workbench and the factory is not used.
* </p>
*/
struct BERRY_UI IPerspectiveFactory : public Object {
berryInterfaceMacro(IPerspectiveFactory, berry)
~IPerspectiveFactory();
/**
* Creates the initial layout for a page.
* <p>
* Implementors of this method may add additional views to a
* perspective. The perspective already contains an editor folder
* identified by the result of <code>IPageLayout.getEditorArea()</code>.
* Additional views should be added to the layout using this value as
* the initial point of reference.
* </p>
*
* @param layout the page layout
*/
virtual void CreateInitialLayout(IPageLayout::Pointer layout) = 0;
};
}
Q_DECLARE_INTERFACE(berry::IPerspectiveFactory, "org.blueberry.IPerspectiveFactory")
#endif /* BERRYIPERSPECTIVEFACTORY_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIPerspectiveListener.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/berryIPerspectiveListener.cpp
index 01217a796b..e826e3d422 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIPerspectiveListener.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIPerspectiveListener.cpp
@@ -1,99 +1,99 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryIPerspectiveListener.h"
#include "berryIWorkbenchPage.h"
namespace berry {
void
IPerspectiveListener::Events
::AddListener(IPerspectiveListener::Pointer listener)
{
if (listener.IsNull()) return;
Types types = listener->GetPerspectiveEventTypes();
if (types & ACTIVATED)
this->perspectiveActivated += Delegate2(listener.GetPointer(), &IPerspectiveListener::PerspectiveActivated);
if (types & CHANGED)
this->perspectiveChanged += PerspChangedDelegate(listener.GetPointer(), &IPerspectiveListener::PerspectiveChanged);
if (types & PART_CHANGED)
this->perspectivePartChanged += PerspPartChangedDelegate(listener.GetPointer(), &IPerspectiveListener::PerspectiveChanged);
if (types & OPENED)
this->perspectiveOpened += Delegate2(listener.GetPointer(), &IPerspectiveListener::PerspectiveOpened);
if (types & CLOSED)
this->perspectiveClosed += Delegate2(listener.GetPointer(), &IPerspectiveListener::PerspectiveClosed);
if (types & DEACTIVATED)
this->perspectiveDeactivated += Delegate2(listener.GetPointer(), &IPerspectiveListener::PerspectiveDeactivated);
if (types & SAVED_AS)
this->perspectiveSavedAs += PerspSavedAsDelegate(listener.GetPointer(), &IPerspectiveListener::PerspectiveSavedAs);
if (types & PRE_DEACTIVATE)
this->perspectivePreDeactivate += Delegate2(listener.GetPointer(), &IPerspectiveListener::PerspectivePreDeactivate);
}
void
IPerspectiveListener::Events
::RemoveListener(IPerspectiveListener::Pointer listener)
{
if (listener.IsNull()) return;
this->perspectiveActivated -= Delegate2(listener.GetPointer(), &IPerspectiveListener::PerspectiveActivated);
this->perspectiveChanged -= PerspChangedDelegate(listener.GetPointer(), &IPerspectiveListener::PerspectiveChanged);
this->perspectivePartChanged -= PerspPartChangedDelegate(listener.GetPointer(), &IPerspectiveListener::PerspectiveChanged);
this->perspectiveOpened -= Delegate2(listener.GetPointer(), &IPerspectiveListener::PerspectiveOpened);
this->perspectiveClosed -= Delegate2(listener.GetPointer(), &IPerspectiveListener::PerspectiveClosed);
this->perspectiveDeactivated -= Delegate2(listener.GetPointer(), &IPerspectiveListener::PerspectiveDeactivated);
this->perspectiveSavedAs -= PerspSavedAsDelegate(listener.GetPointer(), &IPerspectiveListener::PerspectiveSavedAs);
this->perspectivePreDeactivate -= Delegate2(listener.GetPointer(), &IPerspectiveListener::PerspectivePreDeactivate);
}
void IPerspectiveListener::PerspectiveActivated(SmartPointer<IWorkbenchPage> /*page*/,
IPerspectiveDescriptor::Pointer /*perspective*/)
{}
void IPerspectiveListener::PerspectiveChanged(SmartPointer<IWorkbenchPage> /*page*/,
IPerspectiveDescriptor::Pointer /*perspective*/, const std::string& /*changeId*/)
{}
void IPerspectiveListener::PerspectiveChanged(SmartPointer<IWorkbenchPage> /*page*/,
IPerspectiveDescriptor::Pointer /*perspective*/,
IWorkbenchPartReference::Pointer /*partRef*/, const std::string& /*changeId*/)
{}
void IPerspectiveListener::PerspectiveOpened(SmartPointer<IWorkbenchPage> /*page*/,
IPerspectiveDescriptor::Pointer /*perspective*/)
{}
void IPerspectiveListener::PerspectiveClosed(SmartPointer<IWorkbenchPage> /*page*/,
IPerspectiveDescriptor::Pointer /*perspective*/)
{}
void IPerspectiveListener::PerspectiveDeactivated(SmartPointer<IWorkbenchPage> /*page*/,
IPerspectiveDescriptor::Pointer /*perspective*/)
{}
void IPerspectiveListener::PerspectiveSavedAs(SmartPointer<IWorkbenchPage> /*page*/,
IPerspectiveDescriptor::Pointer /*oldPerspective*/,
IPerspectiveDescriptor::Pointer /*newPerspective*/)
{};
void IPerspectiveListener::PerspectivePreDeactivate(SmartPointer<IWorkbenchPage> /*page*/,
IPerspectiveDescriptor::Pointer /*perspective*/)
{}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIPerspectiveListener.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryIPerspectiveListener.h
index 9008d7c2a7..42159a78d4 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIPerspectiveListener.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIPerspectiveListener.h
@@ -1,200 +1,200 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIPERSPECTIVELISTENER_H_
#define BERRYIPERSPECTIVELISTENER_H_
#include <org_blueberry_ui_Export.h>
#include "berryIPerspectiveDescriptor.h"
#include "berryIWorkbenchPartReference.h"
#include <berryMacros.h>
namespace berry {
struct IWorkbenchPage;
/**
* Interface for listening to perspective lifecycle events.
* <p>
* This interface may be implemented by clients.
* </p>
*
* @see IPageService#addPerspectiveListener(IPerspectiveListener)
* @see PerspectiveAdapter
*/
struct BERRY_UI IPerspectiveListener : public virtual Object {
berryInterfaceMacro(IPerspectiveListener, berry);
struct Events {
enum Type {
NONE = 0x00000000,
ACTIVATED = 0x00000001,
CHANGED = 0x00000002,
PART_CHANGED = 0x00000004,
OPENED = 0x00000008,
CLOSED = 0x00000010,
DEACTIVATED = 0x00000020,
SAVED_AS = 0x00000040,
PRE_DEACTIVATE = 0x00000080,
ALL = 0xffffffff
};
BERRY_DECLARE_FLAGS(Types, Type)
Message2<SmartPointer<IWorkbenchPage>, IPerspectiveDescriptor::Pointer> perspectiveActivated;
Message3<SmartPointer<IWorkbenchPage>, IPerspectiveDescriptor::Pointer, const std::string&> perspectiveChanged;
Message4<SmartPointer<IWorkbenchPage>, IPerspectiveDescriptor::Pointer, IWorkbenchPartReference::Pointer, const std::string&> perspectivePartChanged;
Message2<SmartPointer<IWorkbenchPage>, IPerspectiveDescriptor::Pointer> perspectiveOpened;
Message2<SmartPointer<IWorkbenchPage>, IPerspectiveDescriptor::Pointer> perspectiveClosed;
Message2<SmartPointer<IWorkbenchPage>, IPerspectiveDescriptor::Pointer> perspectiveDeactivated;
Message3<SmartPointer<IWorkbenchPage>, IPerspectiveDescriptor::Pointer, IPerspectiveDescriptor::Pointer> perspectiveSavedAs;
Message2<SmartPointer<IWorkbenchPage>, IPerspectiveDescriptor::Pointer> perspectivePreDeactivate;
void AddListener(IPerspectiveListener::Pointer l);
void RemoveListener(IPerspectiveListener::Pointer l);
private:
typedef MessageDelegate2<IPerspectiveListener, SmartPointer<IWorkbenchPage>, IPerspectiveDescriptor::Pointer > Delegate2;
typedef MessageDelegate3<IPerspectiveListener, SmartPointer<IWorkbenchPage>, IPerspectiveDescriptor::Pointer, const std::string&> PerspChangedDelegate;
typedef MessageDelegate3<IPerspectiveListener, SmartPointer<IWorkbenchPage>, IPerspectiveDescriptor::Pointer, IPerspectiveDescriptor::Pointer> PerspSavedAsDelegate;
typedef MessageDelegate4<IPerspectiveListener, SmartPointer<IWorkbenchPage>, IPerspectiveDescriptor::Pointer, IWorkbenchPartReference::Pointer, const std::string&> PerspPartChangedDelegate;
};
virtual Events::Types GetPerspectiveEventTypes() const = 0;
/**
* Notifies this listener that a perspective in the given page
* has been activated.
*
* @param page the page containing the activated perspective
* @param perspective the perspective descriptor that was activated
* @see IWorkbenchPage#setPerspective
*/
virtual void PerspectiveActivated(SmartPointer<IWorkbenchPage> page,
IPerspectiveDescriptor::Pointer perspective);
/**
* Notifies this listener that a perspective has changed in some way
* (for example, editor area hidden, perspective reset,
* view show/hide, editor open/close, etc).
*
* @param page the page containing the affected perspective
* @param perspective the perspective descriptor
* @param changeId one of the <code>CHANGE_*</code> constants on IWorkbenchPage
*/
virtual void PerspectiveChanged(SmartPointer<IWorkbenchPage> page,
IPerspectiveDescriptor::Pointer perspective, const std::string& changeId);
/**
* Notifies this listener that a part in the given page's perspective
* has changed in some way (for example, view show/hide, editor open/close, etc).
*
* @param page the workbench page containing the perspective
* @param perspective the descriptor for the changed perspective
* @param partRef the reference to the affected part
* @param changeId one of the <code>CHANGE_*</code> constants on IWorkbenchPage
*/
virtual void PerspectiveChanged(SmartPointer<IWorkbenchPage> page,
IPerspectiveDescriptor::Pointer perspective,
IWorkbenchPartReference::Pointer partRef, const std::string& changeId);
/**
* Notifies this listener that a perspective in the given page has been
* opened.
*
* @param page
* the page containing the opened perspective
* @param perspective
* the perspective descriptor that was opened
* @see IWorkbenchPage#setPerspective(IPerspectiveDescriptor)
*/
virtual void PerspectiveOpened(SmartPointer<IWorkbenchPage> page,
IPerspectiveDescriptor::Pointer perspective);
/**
* Notifies this listener that a perspective in the given page has been
* closed.
*
* @param page
* the page containing the closed perspective
* @param perspective
* the perspective descriptor that was closed
* @see IWorkbenchPage#closePerspective(IPerspectiveDescriptor, boolean, boolean)
* @see IWorkbenchPage#closeAllPerspectives(boolean, boolean)
*/
virtual void PerspectiveClosed(SmartPointer<IWorkbenchPage> page,
IPerspectiveDescriptor::Pointer perspective);
/**
* Notifies this listener that a perspective in the given page has been
* deactivated.
*
* @param page
* the page containing the deactivated perspective
* @param perspective
* the perspective descriptor that was deactivated
* @see IWorkbenchPage#setPerspective(IPerspectiveDescriptor)
*/
virtual void PerspectiveDeactivated(SmartPointer<IWorkbenchPage> page,
IPerspectiveDescriptor::Pointer perspective);
/**
* Notifies this listener that a perspective in the given page has been
* saved as a new perspective with a different perspective descriptor.
*
* @param page
* the page containing the saved perspective
* @param oldPerspective
* the old perspective descriptor
* @param newPerspective
* the new perspective descriptor
* @see IWorkbenchPage#savePerspectiveAs(IPerspectiveDescriptor)
*/
virtual void PerspectiveSavedAs(SmartPointer<IWorkbenchPage> page,
IPerspectiveDescriptor::Pointer oldPerspective,
IPerspectiveDescriptor::Pointer newPerspective);
/**
* <p>
* Notifies this listener that a perspective in the given page is about to
* be deactivated.
* </p>
* <p>
* Note: This does not have the ability to veto a perspective deactivation.
* </p>
*
* @param page
* the page containing the deactivated perspective
* @param perspective
* the perspective descriptor that was deactivated
* @see IWorkbenchPage#setPerspective(IPerspectiveDescriptor)
*/
virtual void PerspectivePreDeactivate(SmartPointer<IWorkbenchPage> page,
IPerspectiveDescriptor::Pointer perspective);
};
}
BERRY_DECLARE_OPERATORS_FOR_FLAGS(berry::IPerspectiveListener::Events::Types)
#endif /* BERRYIPERSPECTIVELISTENER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIPerspectiveRegistry.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryIPerspectiveRegistry.h
index 362817c58f..50d6abe128 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIPerspectiveRegistry.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIPerspectiveRegistry.h
@@ -1,130 +1,130 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 <vector>
namespace berry {
/**
* \ingroup org_blueberry_ui
*
* The workbench's global registry of perspectives.
* <p>
* 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 (<code>"org.blueberry.ui.perspectives"</code>) and
* with custom perspectives defined by the user.
* </p><p>
* This interface is not intended to be implemented by clients.
* </p>
* @see IWorkbench#getPerspectiveRegistry
* @noimplement This interface is not intended to be implemented by clients.
*/
struct BERRY_UI IPerspectiveRegistry {
virtual ~IPerspectiveRegistry();
/**
* 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 <code>null</code> 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 <code>null</code> 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.
* <p>
* Returns <code>null</code> if there is no default perspective.
* </p>
*
* @return the default perspective id, or <code>null</code>
*/
virtual std::string GetDefaultPerspective() = 0;
/**
* Returns a list of the perspectives known to the workbench.
*
* @return a list of perspectives
*/
virtual std::vector<IPerspectiveDescriptor::Pointer> GetPerspectives() = 0;
/**
* Sets the default perspective for the workbench to the given perspective id.
* If non-<code>null</code>, the id must correspond to a perspective extension
* within the workbench's perspective registry.
* <p>
* A <code>null</code> id indicates no default perspective.
* </p>
*
* @param id a perspective id, or <code>null</code>
*/
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/berryIPlaceholderFolderLayout.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryIPlaceholderFolderLayout.h
index ecee818d7d..0088fa1974 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIPlaceholderFolderLayout.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIPlaceholderFolderLayout.h
@@ -1,101 +1,101 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIPLACEHOLDERFOLDERLAYOUT_H_
#define BERRYIPLACEHOLDERFOLDERLAYOUT_H_
#include <berryMacros.h>
#include <berryObject.h>
#include <org_blueberry_ui_Export.h>
namespace berry {
/**
* \ingroup org_blueberry_ui
*
* An <code>IPlaceholderFolderLayout</code> is used to define the initial
* view placeholders within a folder.
* The folder itself is contained within an <code>IPageLayout</code>.
* <p>
* This interface is not intended to be implemented by clients.
* </p>
*
* @see IPageLayout#createPlaceholderFolder
* @since 2.0
* @noimplement This interface is not intended to be implemented by clients.
*/
struct BERRY_UI IPlaceholderFolderLayout : public Object {
berryInterfaceMacro(IPlaceholderFolderLayout, berry)
virtual ~IPlaceholderFolderLayout();
/**
* Adds a view placeholder to this folder.
* A view placeholder is used to define the position of a view before the view
* appears. Initially, it is invisible; however, if the user ever opens a view
* whose compound id matches the placeholder, the view will appear at the same
* location as the placeholder.
* See the {@link IPageLayout} type documentation for more details about compound ids.
* If the placeholder contains wildcards, it remains in the layout, otherwise
* it is replaced by the view.
* If the primary id of the placeholder has no wildcards, it must refer to a view
* contributed to the workbench's view extension point
* (named <code>"org.blueberry.ui.views"</code>).
*
* @param viewId the compound view id (wildcards allowed)
*/
virtual void AddPlaceholder(const std::string& viewId) = 0;
/**
* Returns the property with the given id or <code>null</code>. Folder
* properties are an extensible mechanism for perspective authors to
* customize the appearance of view stacks. The list of customizable
* properties is determined by the presentation factory.
*
* @param id
* Must not be <code>null</code>.
* @return property value, or <code>null</code> if the property is not
* set.
* @since 3.3
*/
virtual std::string GetProperty(const std::string& id) = 0;
/**
* Sets the given property to the given value. Folder properties are an
* extensible mechanism for perspective authors to customize the appearance
* of view stacks. The list of customizable properties is determined by the
* presentation factory.
* <p>
* These folder properties are intended to be set during
* <code>IPerspectiveFactory#createInitialLayout</code>. Any subsequent
* changes to property values after this method completes will not fire
* change notifications and will not be reflected in the presentation.
* </p>
*
* @param id
* property id. Must not be <code>null</code>.
* @param value
* property value. <code>null</code> will clear the property.
* @since 3.3
*/
virtual void SetProperty(const std::string& id, const std::string& value) = 0;
};
}
#endif /*BERRYIPLACEHOLDERFOLDERLAYOUT_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIPostSelectionProvider.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryIPostSelectionProvider.h
index 92c9017e15..9b0fd49a10 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIPostSelectionProvider.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIPostSelectionProvider.h
@@ -1,67 +1,67 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIPOSTSELECTIONPROVIDER_H_
#define BERRYIPOSTSELECTIONPROVIDER_H_
#include "berryISelectionProvider.h"
namespace berry
{
/**
* \ingroup org_blueberry_ui
*
* Selection provider extension interface to allow providers
* to notify about post selection changed events.
* A post selection changed event is equivalent to selection changed event
* if the selection change was triggered by the mouse, but it has a delay
* if the selection change is triggered by keyboard navigation.
*
* @see ISelectionProvider
*
* @since 3.0
*/
struct BERRY_UI IPostSelectionProvider : public ISelectionProvider {
berryInterfaceMacro(IPostSelectionProvider, berry)
~IPostSelectionProvider();
/**
* Adds a listener for post selection changes in this selection provider.
* Has no effect if an identical listener is already registered.
*
* @param listener a selection changed listener
*/
virtual void AddPostSelectionChangedListener(
ISelectionChangedListener::Pointer listener) = 0;
/**
* Removes the given listener for post selection changes from this selection
* provider.
* Has no affect if an identical listener is not registered.
*
* @param listener a selection changed listener
*/
virtual void RemovePostSelectionChangedListener(
ISelectionChangedListener::Pointer listener) = 0;
};
}
#endif /*BERRYIPOSTSELECTIONPROVIDER_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIPreferencePage.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryIPreferencePage.h
index b7b547f7d2..6dcab5161e 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIPreferencePage.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIPreferencePage.h
@@ -1,109 +1,109 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIPREFERENCEPAGE_H_
#define BERRYIPREFERENCEPAGE_H_
#include "berryObject.h"
#include "berryIPreferences.h"
#include "berryIWorkbench.h"
#include <QObject>
namespace berry
{
/**
* \ingroup org_blueberry_ui
*
* Interface for workbench preference pages.
* <p>
* Clients should implement this interface and include the name of their class
* in an extension contributed to the workbench's preference extension point
* (named <code>"org.blueberry.ui.preferencePages"</code>).
* For example, the plug-in's XML markup might contain:
* <pre>
* &LT;extension point="org.blueberry.ui.preferencePages"&GT;
* &LT;page id="com.example.myplugin.prefs"
* name="Knobs"
* class="ns::MyPreferencePage" /&GT;
* &LT;/extension&GT;
* </pre>
* </p>
*/
struct BERRY_UI IPreferencePage: virtual public Object
{
berryInterfaceMacro(IPreferencePage, berry)
~IPreferencePage();
/**
* Initializes this preference page for the given workbench.
* <p>
* This method is called automatically as the preference page is being created
* and initialized. Clients must not call this method.
* </p>
*
* @param workbench the workbench
*/
virtual void Init(IWorkbench::Pointer workbench) = 0;
/**
* Creates the top level control for this preference
* page under the given parent widget.
* <p>
* Implementors are responsible for ensuring that
* the created control can be accessed via <code>GetControl</code>
* </p>
*
* @param parent the parent widget
*/
virtual void CreateControl(void* parent) = 0;
/**
* Returns the top level control for this dialog page.
* <p>
* May return <code>null</code> if the control
* has not been created yet.
* </p>
*
* @return the top level control or <code>null</code>
*/
virtual void* GetControl() const = 0;
///
/// Invoked when the OK button was clicked in the preferences dialog
///
virtual bool PerformOk() = 0;
///
/// Invoked when the Cancel button was clicked in the preferences dialog
///
virtual void PerformCancel() = 0;
///
/// Invoked when the user performed an import. As the values of the preferences may have changed
/// you should read all values again from the preferences service.
///
virtual void Update() = 0;
};
}
Q_DECLARE_INTERFACE(berry::IPreferencePage, "org.blueberry.IPreferencePage")
#endif /*BERRYIPREFERENCEPAGE_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIPropertyChangeListener.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/berryIPropertyChangeListener.cpp
index 5bcd1161ca..63863aa427 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIPropertyChangeListener.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIPropertyChangeListener.cpp
@@ -1,54 +1,54 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryIPropertyChangeListener.h"
#include "berryIWorkbenchPartConstants.h"
#include <berryObjects.h>
namespace berry {
IPropertyChangeListener::~IPropertyChangeListener()
{
}
void
IPropertyChangeListener::Events
::AddListener(IPropertyChangeListener::Pointer listener)
{
if (listener.IsNull()) return;
this->propertyChange += Delegate(listener.GetPointer(), &IPropertyChangeListener::PropertyChange);
}
void
IPropertyChangeListener::Events
::RemoveListener(IPropertyChangeListener::Pointer listener)
{
if (listener.IsNull()) return;
this->propertyChange -= Delegate(listener.GetPointer(), &IPropertyChangeListener::PropertyChange);
}
void IPropertyChangeListener::PropertyChange(PropertyChangeEvent::Pointer event)
{
if (event->GetProperty() == IWorkbenchPartConstants::INTEGER_PROPERTY)
{
this->PropertyChange(event->GetSource(), event->GetNewValue().Cast<ObjectInt>()->GetValue());
}
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIPropertyChangeListener.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryIPropertyChangeListener.h
index 0d41ef34e0..f24720fc74 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIPropertyChangeListener.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIPropertyChangeListener.h
@@ -1,140 +1,140 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIPROPERTYCHANGELISTENER_H_
#define BERRYIPROPERTYCHANGELISTENER_H_
#include <berryMacros.h>
#include <berryMessage.h>
#include <org_blueberry_ui_Export.h>
#include "berryPropertyChangeEvent.h"
namespace berry
{
/**
* Listener for property changes.
* <p>
* Usage:
* <pre>
* IPropertyChangeListener listener =
* new IPropertyChangeListener() {
* public void propertyChange(PropertyChangeEvent event) {
* ... // code to deal with occurrence of property change
* }
* };
* emitter.addPropertyChangeListener(listener);
* ...
* emitter.removePropertyChangeListener(listener);
* </pre>
* </p>
*/
struct BERRY_UI IPropertyChangeListener: public virtual Object
{
berryInterfaceMacro(IPropertyChangeListener, berry);
virtual ~IPropertyChangeListener();
struct BERRY_UI Events {
typedef Message1<PropertyChangeEvent::Pointer> EventType;
EventType propertyChange;
void AddListener(IPropertyChangeListener::Pointer listener);
void RemoveListener(IPropertyChangeListener::Pointer listener);
private:
typedef MessageDelegate1<IPropertyChangeListener, PropertyChangeEvent::Pointer> Delegate;
};
/**
* Notification that a property has changed.
* <p>
* This method gets called when the observed object fires a property
* change event.
* </p>
*
* @param event the property change event object describing which property
* changed and how
*/
virtual void PropertyChange(PropertyChangeEvent::Pointer event);
virtual void PropertyChange(Object::Pointer /*source*/, int /*propId*/) {}
};
template<typename R>
struct PropertyChangeAdapter: public IPropertyChangeListener
{
typedef R Listener;
typedef void
(R::*Callback)(PropertyChangeEvent::Pointer);
PropertyChangeAdapter(R* l, Callback c) :
listener(l), callback(c)
{
poco_assert(listener);
poco_assert(callback);
}
using IPropertyChangeListener::PropertyChange;
void PropertyChange(PropertyChangeEvent::Pointer event)
{
(listener->*callback)(event);
}
private:
Listener* listener;
Callback callback;
};
template<typename R>
struct PropertyChangeIntAdapter: public IPropertyChangeListener
{
typedef R Listener;
typedef void
(R::*Callback)(Object::Pointer, int);
PropertyChangeIntAdapter(R* l, Callback c) :
listener(l), callback(c)
{
poco_assert(listener);
poco_assert(callback);
}
using IPropertyChangeListener::PropertyChange;
void PropertyChange(Object::Pointer source, int propId)
{
(listener->*callback)(source, propId);
}
private:
Listener* listener;
Callback callback;
};
}
#endif /* BERRYIPROPERTYCHANGELISTENER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIReusableEditor.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryIReusableEditor.h
index 5189d37c8e..55422bd9e0 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIReusableEditor.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIReusableEditor.h
@@ -1,54 +1,54 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIREUSABLEEDITOR_H_
#define BERRYIREUSABLEEDITOR_H_
#include "berryIEditorPart.h"
#include "berryIEditorInput.h"
namespace berry {
/**
* \ingroup org_blueberry_ui
*
* Interface for reusable editors.
*
* An editors may support changing its input so that
* the workbench may change its contents instead of
* opening a new editor.
*/
struct BERRY_UI IReusableEditor : public virtual IEditorPart {
berryInterfaceMacro(IReusableEditor, berry)
virtual ~IReusableEditor();
/**
* Sets the input to this editor.
*
* <p><b>Note:</b> Clients must fire the {@link IEditorPart#PROP_INPUT }
* property change within their implementation of
* <code>setInput()</code>.<p>
*
* @param input the editor input
*/
virtual void SetInput(IEditorInput::Pointer input) = 0;
};
}
#endif /*BERRYIREUSABLEEDITOR_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryISaveablePart.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/berryISaveablePart.cpp
index 27e7767d50..32ab10fee6 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryISaveablePart.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryISaveablePart.cpp
@@ -1,26 +1,26 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryISaveablePart.h"
#include "berryIWorkbenchPartConstants.h"
namespace berry {
const int ISaveablePart::PROP_DIRTY = IWorkbenchPartConstants::PROP_DIRTY;
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryISaveablePart.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryISaveablePart.h
index 58da79ee8d..b2d028d1d8 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryISaveablePart.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryISaveablePart.h
@@ -1,121 +1,121 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYISAVEABLEPART_H_
#define BERRYISAVEABLEPART_H_
#include <berryMacros.h>
#include <berryObject.h>
#include <org_blueberry_ui_Export.h>
#include <QtPlugin>
namespace berry {
/**
* Workbench parts implement or adapt to this interface to participate
* in the enablement and execution of the <code>Save</code> and
* <code>Save As</code> actions.
*
* @since 2.1
* @see org.blueberry.ui.IEditorPart
*/
struct BERRY_UI ISaveablePart : public virtual Object {
berryInterfaceMacro(ISaveablePart, berry);
/**
* The property id for <code>isDirty</code>.
*/
static const int PROP_DIRTY; // = IWorkbenchPartConstants.PROP_DIRTY;
/**
* Saves the contents of this part.
* <p>
* If the save is successful, the part should fire a property changed event
* reflecting the new dirty state (<code>PROP_DIRTY</code> property).
* </p>
* <p>
* If the save is cancelled through user action, or for any other reason, the
* part should invoke <code>setCancelled</code> on the <code>IProgressMonitor</code>
* to inform the caller.
* </p>
* <p>
* This method is long-running; progress and cancellation are provided
* by the given progress monitor.
* </p>
*
* @param monitor the progress monitor
*/
virtual void DoSave(/*IProgressMonitor monitor*/) = 0;
/**
* Saves the contents of this part to another object.
* <p>
* Implementors are expected to open a "Save As" dialog where the user will
* be able to select a new name for the contents. After the selection is made,
* the contents should be saved to that new name. During this operation a
* <code>IProgressMonitor</code> should be used to indicate progress.
* </p>
* <p>
* If the save is successful, the part fires a property changed event
* reflecting the new dirty state (<code>PROP_DIRTY</code> property).
* </p>
*/
virtual void DoSaveAs() = 0;
/**
* Returns whether the contents of this part have changed since the last save
* operation. If this value changes the part must fire a property listener
* event with <code>PROP_DIRTY</code>.
* <p>
* <b>Note:</b> this method is called often on a part open or part
* activation switch, for example by actions to determine their
* enabled status.
* </p>
*
* @return <code>true</code> if the contents have been modified and need
* saving, and <code>false</code> if they have not changed since the last
* save
*/
virtual bool IsDirty() const = 0;
/**
* Returns whether the "Save As" operation is supported by this part.
*
* @return <code>true</code> if "Save As" is supported, and <code>false</code>
* if not supported
*/
virtual bool IsSaveAsAllowed() const = 0;
/**
* Returns whether the contents of this part should be saved when the part
* is closed.
*
* @return <code>true</code> if the contents of the part should be saved on
* close, and <code>false</code> if the contents are expendable
*/
virtual bool IsSaveOnCloseNeeded() const = 0;
};
}
Q_DECLARE_INTERFACE(berry::ISaveablePart, "org.blueberry.ISaveablePart")
#endif /* BERRYISAVEABLEPART_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryISaveablesLifecycleListener.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/berryISaveablesLifecycleListener.cpp
index 53cf4ee26d..fbf5edd2dc 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryISaveablesLifecycleListener.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryISaveablesLifecycleListener.cpp
@@ -1,39 +1,39 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryISaveablesLifecycleListener.h"
namespace berry {
void
ISaveablesLifecycleListener::Events
::AddListener(ISaveablesLifecycleListener::Pointer listener)
{
if (listener.IsNull()) return;
this->lifecycleChange += Delegate(listener.GetPointer(), &ISaveablesLifecycleListener::HandleLifecycleEvent);
}
void
ISaveablesLifecycleListener::Events
::RemoveListener(ISaveablesLifecycleListener::Pointer listener)
{
if (listener.IsNull()) return;
this->lifecycleChange -= Delegate(listener.GetPointer(), &ISaveablesLifecycleListener::HandleLifecycleEvent);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryISaveablesLifecycleListener.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryISaveablesLifecycleListener.h
index b3c6baf60d..40766391b1 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryISaveablesLifecycleListener.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryISaveablesLifecycleListener.h
@@ -1,80 +1,80 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYISAVEABLESLIFECYCLELISTENER_H_
#define BERRYISAVEABLESLIFECYCLELISTENER_H_
#include "berrySaveablesLifecycleEvent.h"
#include <berryMessage.h>
#include <berryMacros.h>
namespace berry {
/**
* Listener for events fired by implementers of {@link ISaveablesSource}.
*
* <p>
* This service can be acquired from a part's service locator:
*
* <pre>
* ISaveablesLifecycleListener listener = (ISaveablesLifecycleListener) getSite()
* .getService(ISaveablesLifecycleListener.class);
* </pre>
*
* or, in the case of implementers of {@link ISaveablesSource} that are not a
* part, from the workbench:
*
* <pre>
* ISaveablesLifecycleListener listener = (ISaveablesLifecycleListener) workbench
* .getService(ISaveablesLifecycleListener.class);
* </pre>
*
* <ul>
* <li>This service is available globally.</li>
* </ul>
* </p>
*
* @since 3.2
*/
struct ISaveablesLifecycleListener : public virtual Object {
berryInterfaceMacro(ISaveablesLifecycleListener, berry);
struct Events {
Message1<SaveablesLifecycleEvent::Pointer> lifecycleChange;
void AddListener(ISaveablesLifecycleListener::Pointer listener);
void RemoveListener(ISaveablesLifecycleListener::Pointer listener);
private:
typedef MessageDelegate1<ISaveablesLifecycleListener, SaveablesLifecycleEvent::Pointer> Delegate;
};
/**
* Handle the given event. This method must be called on the UI thread.
*
* @param event
*/
virtual void HandleLifecycleEvent(SaveablesLifecycleEvent::Pointer event) = 0;
};
}
#endif /* BERRYISAVEABLESLIFECYCLELISTENER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryISaveablesSource.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryISaveablesSource.h
index 1e280bac1b..58b1ff0cc8 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryISaveablesSource.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryISaveablesSource.h
@@ -1,124 +1,124 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYISAVEABLESSOURCE_H_
#define BERRYISAVEABLESSOURCE_H_
#include <berryMacros.h>
#include <org_blueberry_ui_Export.h>
#include "berrySaveable.h"
namespace berry {
/**
* Represents a source of Saveable objects (units of saveability). Workbench
* parts that show more than one unit of saveability, or whose units of
* saveability change over time, should implement this interface in order to
* provide better integration with workbench facilities like the Save command,
* prompts to save on part close or shutdown, etc.
* <p>
* IMPORTANT: As of 3.2, implementers of <code>ISaveablesSource</code> must
* satisfy the following conditions:
* <ul>
* <li>If ISaveablesSource is implemented by an IWorkbenchPart:
* <ul>
* <li>the part must implement <code>ISaveablePart</code></li>
* <li>if any of its Saveable objects are dirty, the part must return
* <code>true</code> from {@link ISaveablePart#isDirty()}</li>
* <li>the part must return <code>true</code> from
* {@link ISaveablePart#isSaveOnCloseNeeded()} if it is dirty (the default
* behaviour implemented by {@link EditorPart})</li>
* <li>the part must not implement {@link ISaveablePart2}</li>
* </ul>
* </li>
* <li>If ISaveablesSource is implemented by a non-part (possible as of 3.2.1 and 3.3):
* <ul>
* <li>the Workbench's {@link ISaveablesLifecycleListener} (obtained from the
* Workbench by calling
* <code>workbench.getService(ISaveablesLifecycleListener.class)</code>) must
* be notified of any change to the result of {@link #getSaveables()} </li>
* <li>getActiveSaveables() should be implemented to return an empty array
* </li>
* </ul>
* </ul>
* If any of these conditions are not met, it is undefined whether the Workbench
* will prompt to save dirty Saveables when closing parts or the Workbench.
* </p>
* <p>
* These conditions may be relaxed in future releases.
* </p>
*
* @since 3.2
*/
struct BERRY_UI ISaveablesSource : public virtual Object {
berryInterfaceMacro(ISaveablesSource, berry)
~ISaveablesSource();
/**
* Returns the saveables presented by the workbench part. If the return
* value of this method changes during the lifetime of
* this part (i.e. after initialization and control creation but before disposal)
* the part must notify an implicit listener using
* {@link ISaveablesLifecycleListener#handleLifecycleEvent(SaveablesLifecycleEvent)}.
* <p>
* Additions of saveables to the list of saveables of this part are
* announced using an event of type
* {@link SaveablesLifecycleEvent#POST_OPEN}. Removals are announced in a
* two-stage process, first using an event of type
* {@link SaveablesLifecycleEvent#PRE_CLOSE} followed by an event of type
* {@link SaveablesLifecycleEvent#POST_CLOSE}. Since firing the
* <code>PRE_CLOSE</code> event may trigger prompts to save dirty
* saveables, the cancellation status of the event must be checked by the
* part after the notification. When removing only non-dirty saveables,
* <code>POST_CLOSE</code> notification is sufficient.
* </p>
* <p>
* The listener is obtained from the part site by calling
* <code>partSite.getService(ISaveablesLifecycleListener.class)</code>.
* </p>
* <p>
* The part must not notify from its initialization methods (e.g. <code>init</code>
* or <code>createPartControl</code>), or from its dispose method. Parts that
* implement {@link IReusableEditor} must notify when their input is changed
* through {@link IReusableEditor#setInput(IEditorInput)}.
* </p>
*
* @return the saveables presented by the workbench part
*
* @see ISaveablesLifecycleListener
*/
virtual std::vector<Saveable::Pointer> GetSaveables() = 0;
/**
* Returns the saveables currently active in the workbench part.
* <p>
* Certain workbench actions, such as Save, target only the active saveables
* in the active part. For example, the active saveables could be determined
* based on the current selection in the part.
* </p>
*
* @return the saveables currently active in the workbench part
*/
virtual std::vector<Saveable::Pointer> GetActiveSaveables() = 0;
};
}
#endif /* BERRYISAVEABLESSOURCE_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryISelection.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryISelection.h
index f10bec8423..6eacb2f081 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryISelection.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryISelection.h
@@ -1,55 +1,55 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYISELECTION_H_
#define BERRYISELECTION_H_
#include <berryMacros.h>
#include <berryObject.h>
#include <org_blueberry_ui_Export.h>
namespace berry {
/**
* \ingroup org_blueberry_ui
*
* Interface for a selection.
*
* @see ISelectionProvider
* @see ISelectionChangedListener
* @see SelectionChangedEvent
*
**/
struct BERRY_UI ISelection : public Object
{
berryInterfaceMacro(ISelection, berry)
~ISelection();
/**
* Returns whether this selection is empty.
*
* @return <code>true</code> if this selection is empty,
* and <code>false</code> otherwise
*/
virtual bool IsEmpty() const = 0;
};
}
#endif /*BERRYISELECTION_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryISelectionChangedListener.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/berryISelectionChangedListener.cpp
index 572b281ed9..013996ce70 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryISelectionChangedListener.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryISelectionChangedListener.cpp
@@ -1,40 +1,40 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryISelectionChangedListener.h"
#include "berryISelectionProvider.h"
namespace berry {
void
ISelectionChangedListener::Events
::AddListener(ISelectionChangedListener::Pointer listener)
{
if (listener.IsNull()) return;
this->selectionChanged += Delegate(listener.GetPointer(), &ISelectionChangedListener::SelectionChanged);
}
void
ISelectionChangedListener::Events
::RemoveListener(ISelectionChangedListener::Pointer listener)
{
if (listener.IsNull()) return;
this->selectionChanged -= Delegate(listener.GetPointer(), &ISelectionChangedListener::SelectionChanged);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryISelectionChangedListener.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryISelectionChangedListener.h
index 9c6524f51a..5b0d72d386 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryISelectionChangedListener.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryISelectionChangedListener.h
@@ -1,67 +1,67 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYISELECTIONCHANGEDLISTENER_H_
#define BERRYISELECTIONCHANGEDLISTENER_H_
#include <org_blueberry_ui_Export.h>
#include <berryMacros.h>
#include <berryMessage.h>
#include "berrySelectionChangedEvent.h"
namespace berry
{
class SelectionChangedEvent;
/**
* \ingroup org_blueberry_ui
*
* A listener which is notified when a viewer's selection changes.
*
* @see ISelection
* @see ISelectionProvider
* @see SelectionChangedEvent
*/
struct BERRY_UI ISelectionChangedListener : public virtual Object {
berryInterfaceMacro(ISelectionChangedListener, berry);
struct BERRY_UI Events {
Message1<SelectionChangedEvent::Pointer > selectionChanged;
void AddListener(ISelectionChangedListener::Pointer listener);
void RemoveListener(ISelectionChangedListener::Pointer listener);
private:
typedef MessageDelegate1<ISelectionChangedListener, SelectionChangedEvent::Pointer> Delegate;
};
/**
* Notifies that the selection has changed.
*
* @param event event object describing the change
*/
virtual void SelectionChanged(SelectionChangedEvent::Pointer event) = 0;
};
}
#endif /*BERRYISELECTIONCHANGEDLISTENER_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryISelectionListener.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/berryISelectionListener.cpp
index e0920e2e21..018ffd1cac 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryISelectionListener.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryISelectionListener.cpp
@@ -1,39 +1,39 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryISelectionListener.h"
namespace berry {
void
ISelectionListener::Events
::AddListener(ISelectionListener::Pointer listener)
{
if (listener.IsNull()) return;
this->selectionChanged += Delegate(listener.GetPointer(), &ISelectionListener::SelectionChanged);
}
void
ISelectionListener::Events
::RemoveListener(ISelectionListener::Pointer listener)
{
if (listener.IsNull()) return;
this->selectionChanged -= Delegate(listener.GetPointer(), &ISelectionListener::SelectionChanged);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryISelectionListener.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryISelectionListener.h
index a4b3717878..4fb883c950 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryISelectionListener.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryISelectionListener.h
@@ -1,131 +1,131 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYISELECTIONLISTENER_H_
#define BERRYISELECTIONLISTENER_H_
#include <berryMessage.h>
#include <org_blueberry_ui_Export.h>
#include "berryIWorkbenchPart.h"
#include "berryISelection.h"
namespace berry
{
/**
* \ingroup org_blueberry_ui
*
* Interface for listening to selection changes.
* <p>
* This interface may be implemented by clients.
* </p>
*
* @see ISelectionService#AddSelectionListener(ISelectionListener::Pointer)
* @see ISelectionService#AddSelectionListener(const std::string&, ISelectionListener::Pointer)
* @see INullSelectionListener
*/
struct BERRY_UI ISelectionListener: public virtual Object
{
berryInterfaceMacro(ISelectionListener, berry)
struct Events
{
Message2<IWorkbenchPart::Pointer, ISelection::ConstPointer>
selectionChanged;
void AddListener(ISelectionListener::Pointer listener);
void RemoveListener(ISelectionListener::Pointer listener);
typedef MessageDelegate2<ISelectionListener, IWorkbenchPart::Pointer,
ISelection::ConstPointer> Delegate;
};
/**
* Notifies this listener that the selection has changed.
* <p>
* This method is called when the selection changes from one to a
* <code>non-null</code> value, but not when the selection changes to
* <code>null</code>. If there is a requirement to be notified in the latter
* scenario, implement <code>INullSelectionListener</code>. The event will
* be posted through this method.
* </p>
*
* @param part the workbench part containing the selection
* @param selection the current selection. This may be <code>null</code>
* if <code>INullSelectionListener</code> is implemented.
*/
virtual void SelectionChanged(IWorkbenchPart::Pointer part,
ISelection::ConstPointer selection) = 0;
};
/**
* \ingroup org_blueberry_ui
*
* This template can be used like this:
*
* <code>
* class MyClass {
*
* private:
* void HandleSelectionChanged(berry::IWorkbenchPart::Pointer part, berry::ISelection::ConstPointer selection)
* { // do something }
*
* berry::ISelectionListener::Pointer m_SelectionListener;
*
* public:
* MyClass()
* : m_SelectionListener(new berry::SelectionChangedAdapter<MyClass>(this, &MyClass::HandleSelectionChanged))
* {
* // get the selection service
* // ...
* service->AddPostSelectionListener(m_SelectionListener);
* }
* };
* </code>
*/
template<typename R>
struct SelectionChangedAdapter: public ISelectionListener
{
typedef R Listener;
typedef void
(R::*Callback)(IWorkbenchPart::Pointer, ISelection::ConstPointer);
SelectionChangedAdapter(R* l, Callback c) :
listener(l), callback(c)
{
poco_assert(listener);
poco_assert(callback);
}
void SelectionChanged(IWorkbenchPart::Pointer part, ISelection::ConstPointer selection)
{
(listener->*callback)(part, selection);
}
private:
Listener* listener;
Callback callback;
};
}
#endif /*BERRYISELECTIONLISTENER_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryISelectionProvider.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryISelectionProvider.h
index dce3da6c98..c5e4a5db23 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryISelectionProvider.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryISelectionProvider.h
@@ -1,77 +1,77 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYISELECTIONPROVIDER_H_
#define BERRYISELECTIONPROVIDER_H_
#include <berryMacros.h>
#include "berryISelectionChangedListener.h"
#include "berryISelection.h"
namespace berry
{
/**
* \ingroup org_blueberry_ui
*
* Interface common to all objects that provide a selection.
*
* @see ISelection
* @see ISelectionChangedListener
* @see SelectionChangedEvent
*/
struct BERRY_UI ISelectionProvider : public virtual Object {
berryInterfaceMacro(ISelectionProvider, berry)
~ISelectionProvider();
/**
* Adds a listener for selection changes in this selection provider.
* Has no effect if an identical listener is already registered.
*
* @param listener a selection changed listener
*/
virtual void AddSelectionChangedListener(ISelectionChangedListener::Pointer listener) = 0;
/**
* Returns the current selection for this provider.
*
* @return the current selection
*/
virtual ISelection::ConstPointer GetSelection() const = 0;
/**
* Removes the given selection change listener from this selection provider.
* Has no affect if an identical listener is not registered.
*
* @param listener a selection changed listener
*/
virtual void RemoveSelectionChangedListener(
ISelectionChangedListener::Pointer listener) = 0;
/**
* Sets the current selection for this selection provider.
*
* @param selection the new selection
*/
virtual void SetSelection(ISelection::Pointer selection) = 0;
};
}
#endif /*BERRYISELECTIONPROVIDER_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryISelectionService.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryISelectionService.h
index 76c5e1f380..e4746c20bb 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryISelectionService.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryISelectionService.h
@@ -1,183 +1,183 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYISELECTIONSERVICE_H_
#define BERRYISELECTIONSERVICE_H_
#include <org_blueberry_ui_Export.h>
#include "berryISelection.h"
#include "berryISelectionListener.h"
#include "berryIWorkbenchPart.h"
#include <berryMessage.h>
namespace berry {
/**
* \ingroup org_blueberry_ui
*
* A selection service tracks the selection within an object.
* <p>
* A listener that wants to be notified when the selection becomes
* <code>null</code> must implement the <code>INullSelectionListener</code>
* interface.
* </p>
* <p>
* This interface is not intended to be implemented by clients.
* </p>
* @see org.blueberry.ui.ISelectionListener
* @see org.blueberry.ui.INullSelectionListener
*/
struct BERRY_UI ISelectionService {
struct SelectionEvents {
typedef Message2<IWorkbenchPart::Pointer, ISelection::ConstPointer> SelectionEvent;
typedef MessageDelegate2<ISelectionListener, IWorkbenchPart::Pointer, ISelection::ConstPointer> Delegate;
SelectionEvent selectionChanged;
SelectionEvent postSelectionChanged;
};
virtual ~ISelectionService();
//virtual SelectionEvents& GetSelectionEvents(const std::string& partId = "") = 0;
/**
* Adds the given selection listener.
* Has no effect if an identical listener is already registered.
*
* @param listener a selection listener
*/
virtual void AddSelectionListener(ISelectionListener::Pointer listener) = 0;
/**
* Adds a part-specific selection listener which is notified when selection changes
* in the part with the given id. This is independent of part activation - the part
* need not be active for notification to be sent.
* <p>
* When the part is created, the listener is passed the part's initial selection.
* When the part is disposed, the listener is passed a <code>null</code> selection,
* but only if the listener implements <code>INullSelectionListener</code>.
* </p>
* <p>
* Note: This will not correctly track editor parts as each editor does
* not have a unique partId.
* </p>
*
* @param partId the id of the part to track
* @param listener a selection listener
* @since 2.0
*/
virtual void AddSelectionListener(const std::string& partId, ISelectionListener::Pointer listener) = 0;
/**
* Adds the given post selection listener.It is equivalent to selection
* changed if the selection was triggered by the mouse but it has a
* delay if the selection is triggered by the keyboard arrows.
* Has no effect if an identical listener is already registered.
*
* Note: Works only for StructuredViewer(s).
*
* @param listener a selection listener
*/
virtual void AddPostSelectionListener(ISelectionListener::Pointer listener) = 0;
/**
* Adds a part-specific selection listener which is notified when selection changes
* in the part with the given id. This is independent of part activation - the part
* need not be active for notification to be sent.
* <p>
* When the part is created, the listener is passed the part's initial selection.
* When the part is disposed, the listener is passed a <code>null</code> selection,
* but only if the listener implements <code>INullSelectionListener</code>.
* </p>
* <p>
* Note: This will not correctly track editor parts as each editor does
* not have a unique partId.
* </p>
*
* @param partId the id of the part to track
* @param listener a selection listener
* @since 2.0
*/
virtual void AddPostSelectionListener(const std::string& partId,
ISelectionListener::Pointer listener) = 0;
/**
* Returns the current selection in the active part. If the selection in the
* active part is <em>undefined</em> (the active part has no selection provider)
* the result will be <code>null</code>.
*
* @return the current selection, or <code>null</code> if undefined
*/
virtual ISelection::ConstPointer GetSelection() const = 0;
/**
* Returns the current selection in the part with the given id. If the part is not open,
* or if the selection in the active part is <em>undefined</em> (the active part has no selection provider)
* the result will be <code>null</code>.
*
* @param partId the id of the part
* @return the current selection, or <code>null</code> if undefined
* @since 2.0
*/
virtual ISelection::ConstPointer GetSelection(const std::string& partId) = 0;
/**
* Removes the given selection listener.
* Has no effect if an identical listener is not registered.
*
* @param listener a selection listener
*/
virtual void RemoveSelectionListener(ISelectionListener::Pointer listener) = 0;
/**
* Removes the given part-specific selection listener.
* Has no effect if an identical listener is not registered for the given part id.
*
* @param partId the id of the part to track
* @param listener a selection listener
* @since 2.0
*/
virtual void RemoveSelectionListener(const std::string& partId,
ISelectionListener::Pointer listener) = 0;
/**
* Removes the given post selection listener.
* Has no effect if an identical listener is not registered.
*
* @param listener a selection listener
*/
virtual void RemovePostSelectionListener(ISelectionListener::Pointer listener) = 0;
/**
* Removes the given part-specific post selection listener.
* Has no effect if an identical listener is not registered for the given part id.
*
* @param partId the id of the part to track
* @param listener a selection listener
* @since 2.0
*/
virtual void RemovePostSelectionListener(const std::string& partId,
ISelectionListener::Pointer listener) = 0;
};
} // namespace berry
#endif /*BERRYISELECTIONSERVICE_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIShellListener.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/berryIShellListener.cpp
index 2fa4c4971b..e23e84eec1 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIShellListener.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIShellListener.cpp
@@ -1,59 +1,59 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryIShellListener.h"
#include "berryShell.h"
namespace berry {
void
IShellListener::Events
::AddListener(IShellListener::Pointer listener)
{
if (listener.IsNull()) return;
shellActivated += Delegate(listener.GetPointer(), &IShellListener::ShellActivated);
shellClosed += Delegate(listener.GetPointer(), &IShellListener::ShellClosed);
shellDeactivated += Delegate(listener.GetPointer(), &IShellListener::ShellDeactivated);
shellDeiconified += Delegate(listener.GetPointer(), &IShellListener::ShellDeiconified);
shellIconified += Delegate(listener.GetPointer(), &IShellListener::ShellIconified);
}
void
IShellListener::Events
::RemoveListener(IShellListener::Pointer listener)
{
if (listener.IsNull()) return;
shellActivated -= Delegate(listener.GetPointer(), &IShellListener::ShellActivated);
shellClosed -= Delegate(listener.GetPointer(), &IShellListener::ShellClosed);
shellDeactivated -= Delegate(listener.GetPointer(), &IShellListener::ShellDeactivated);
shellDeiconified -= Delegate(listener.GetPointer(), &IShellListener::ShellDeiconified);
shellIconified -= Delegate(listener.GetPointer(), &IShellListener::ShellIconified);
}
void IShellListener::ShellActivated(ShellEvent::Pointer /*e*/)
{}
void IShellListener::ShellClosed(ShellEvent::Pointer /*e*/)
{}
void IShellListener::ShellDeactivated(ShellEvent::Pointer /*e*/)
{}
void IShellListener::ShellDeiconified(ShellEvent::Pointer /*e*/)
{}
void IShellListener::ShellIconified(ShellEvent::Pointer /*e*/)
{}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIShellListener.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryIShellListener.h
index f0ac3319b2..8735e56a2e 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIShellListener.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIShellListener.h
@@ -1,118 +1,118 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYISHELLLISTENER_H_
#define BERRYISHELLLISTENER_H_
#include <org_blueberry_ui_Export.h>
#include "berryShellEvent.h"
#include <berryMessage.h>
#include <berryMacros.h>
namespace berry {
/**
* Classes which implement this interface provide methods
* that deal with changes in state of <code>Shell</code>s.
* <p>
* After creating an instance of a class that implements
* this interface it can be added to a shell using the
* <code>AddShellListener</code> method and removed using
* the <code>RemoveShellListener</code> method. When the
* state of the shell changes, the appropriate method will
* be invoked.
* </p>
*
* @see ShellEvent
*/
struct BERRY_UI IShellListener : public virtual Object {
berryInterfaceMacro(IShellListener, berry);
struct BERRY_UI Events {
typedef Message1<ShellEvent::Pointer> ShellEventType;
enum Type {
NONE = 0x00000000,
ACTIVATED = 0x00000001,
CLOSED = 0x00000002,
DEACTIVATED = 0x00000004,
DEICONIFIED = 0x00000008,
ICONIFIED = 0x00000010,
ALL = 0xffffffff
};
BERRY_DECLARE_FLAGS(Types, Type)
ShellEventType shellActivated;
ShellEventType shellClosed;
ShellEventType shellDeactivated;
ShellEventType shellDeiconified;
ShellEventType shellIconified;
void AddListener(IShellListener::Pointer listener);
void RemoveListener(IShellListener::Pointer listener);
private:
typedef MessageDelegate1<IShellListener, ShellEvent::Pointer> Delegate;
};
/**
* Sent when a shell becomes the active window.
*
* @param e an event containing information about the activation
*/
virtual void ShellActivated(ShellEvent::Pointer e);
/**
* Sent when a shell is closed.
*
* @param e an event containing information about the close
*/
virtual void ShellClosed(ShellEvent::Pointer e);
/**
* Sent when a shell stops being the active window.
*
* @param e an event containing information about the deactivation
*/
virtual void ShellDeactivated(ShellEvent::Pointer e);
/**
* Sent when a shell is un-minimized.
*
* @param e an event containing information about the un-minimization
*/
virtual void ShellDeiconified(ShellEvent::Pointer e);
/**
* Sent when a shell is minimized.
*
* @param e an event containing information about the minimization
*/
virtual void ShellIconified(ShellEvent::Pointer e);
};
}
BERRY_DECLARE_OPERATORS_FOR_FLAGS(berry::IShellListener::Events::Types)
#endif /* BERRYISHELLLISTENER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIShellProvider.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryIShellProvider.h
index f5f712d762..ac40f14e64 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIShellProvider.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIShellProvider.h
@@ -1,53 +1,53 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYISHELLPROVIDER_H_
#define BERRYISHELLPROVIDER_H_
#include <org_blueberry_ui_Export.h>
#include "berryShell.h"
#include <berryMacros.h>
namespace berry {
/**
* Interface for objects that can return a shell. This is normally used for
* opening child windows. An object that wants to open child shells can take
* an IShellProvider in its constructor, and the object that implements IShellProvider
* can dynamically choose where child shells should be opened.
*
* @since 3.1
*/
struct BERRY_UI IShellProvider : public virtual Object {
berryInterfaceMacro(IShellProvider, berry);
~IShellProvider();
/**
* Returns the current shell (or null if none). This return value may
* change over time, and should not be cached.
*
* @return the current shell or null if none
*/
virtual Shell::Pointer GetShell() = 0;
};
}
#endif /* BERRYISHELLPROVIDER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryISizeProvider.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/berryISizeProvider.cpp
index 90ae55c322..4ef76779b1 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryISizeProvider.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryISizeProvider.cpp
@@ -1,30 +1,30 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryISizeProvider.h"
#include <limits>
namespace berry {
const int ISizeProvider::INF = std::numeric_limits<int>::max();
ISizeProvider::~ISizeProvider()
{
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryISizeProvider.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryISizeProvider.h
index c78892106d..8c62750967 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryISizeProvider.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryISizeProvider.h
@@ -1,159 +1,159 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYISIZEPROVIDER_H_
#define BERRYISIZEPROVIDER_H_
#include <org_blueberry_ui_Export.h>
namespace berry {
/**
* Interface implemented by objects that are capable of computing
* a preferred size
*
* @since 3.1
* @noimplement This interface is not intended to be implemented by clients.
*/
struct BERRY_UI ISizeProvider {
/**
* Constant used to indicate infinite size. This is equal to Integer.MAX_VALUE, ensuring
* that it is greater than any other integer.
*/
static const int INF;
virtual ~ISizeProvider();
/**
* Returns a bitwise combination of flags indicating how and when computePreferredSize should
* be used. When called with horizontal=true, this indicates the usage of computePreferredSize(true,...)
* for computing widths. When called with horizontal=false, this indicates the usage of computeSize(false,...)
* for computing heights. These flags are used for optimization. Each flag gives the part more control
* over its preferred size but slows down the layout algorithm. Parts should return the minimum set
* of flags necessary to specify their constraints.
* <p>
* If the return value of this function ever changes, the part must call <code>flushLayout</code> before
* the changes will take effect.
* </p>
*
* <ul>
* <li>SWT.MAX: The part has a maximum size that will be returned by computePreferredSize(horizontal,
* INF, someWidth, INF)</li>
* <li>SWT.MIN: The part has a minimum size that will be returned by computePreferredSize(horizontal,
* INF, someWidth, 0)</li>
* <li>SWT.WRAP: Indicates that computePreferredSize makes use of the availablePerpendicular argument. If this
* flag is not specified, then the third argument to computePreferredSize will always be set to
* INF. The perpendicular size is expensive to compute, and it is usually only used
* for wrapping parts.
* <li>SWT.FILL: The part may not return the preferred size verbatim when computePreferredSize is
* is given a value between the minimum and maximum sizes. This is commonly used if the part
* wants to use a set of predetermined sizes instead of using the workbench-provided size.
* For example, computePreferredSize(horizontal, availableSpace, someWidth,
* preferredSize) may return the nearest predetermined size. Note that this flag should
* be used sparingly. It can prevent layout caching and cause the workbench layout algorithm
* to degrade to exponential worst-case runtime. If this flag is omitted, then
* computePreferredSize may be used to compute the minimum and maximum sizes, but not for
* anything in between.</li>
* </ul>
*
* @param width a value of true or false determines whether the return value applies when computing
* widths or heights respectively. That is, getSizeFlags(true) will be used when calling
* computePreferredSize(true,...)
* @return any bitwise combination of SWT.MAX, SWT.MIN, SWT.WRAP, and SWT.FILL
*/
virtual int GetSizeFlags(bool width) = 0;
/**
* <p>
* Returns the best size for this part, given the available width and height and the workbench's
* preferred size for the part. Parts can overload this to enforce a minimum size, maximum size,
* or a quantized set of preferred sizes. If width == true, this method computes a width in pixels.
* If width == false, this method computes a height. availableParallel and availablePerpendicular
* contain the space available, and preferredParallel contains the preferred result.
* </p>
*
* <p>
* This method returns an answer that is less than or equal to availableParallel and as
* close to preferredParallel as possible. Return values larger than availableParallel will
* be truncated.
* </p>
*
* <p>
* Most presentations will define a minimum size at all times, and a maximum size that only applies
* when maximized.
* </p>
*
* <p>
* The getSizeFlags method controls how frequently this method will be called and what information
* will be available when it is. Any subclass that specializes this method should also specialize
* getSizeFlags. computePreferredSize(width, INF, someSize, 0) returns
* the minimum size of the control (if any). computePreferredSize(width, INF, someSize,
* INF) returns the maximum size of the control.
* </p>
*
* <p>
* Examples:
* <ul>
* <li>To maintain a constant size of 100x300 pixels: {return width ? 100 : 300}, getSizeFlags(boolean) must
* return SWT.MIN | SWT.MAX</li>
* <li>To grow without constraints: {return preferredResult;}, getSizeFlags(boolean) must return 0.</li>
* <li>To enforce a width that is always a multiple of 100 pixels, to a minimum of 100 pixels:
* <code>
* {
* if (width && preferredResult != INF) {
* int result = preferredResult - ((preferredResult + 50) % 100) + 50;
* result = Math.max(100, Math.min(result, availableParallel - (availableParallel % 100)));
*
* return result;
* }
* return preferredResult;
* }
* </code>
* In this case, getSizeFlags(boolean width) must return (width ? SWT.FILL | SWT.MIN: 0)
* </ul>
* <li>To maintain a minimum area of 100000 pixels:
* <code>
* {return availablePerpendicular < 100 ? 1000 : 100000 / availablePerpendicular;}
* </code>
* getSizeFlags(boolean width) must return SWT.WRAP | SWT.MIN;
* </li>
* </p>
*
* @param width indicates whether a width (=true) or a height (=false) is being computed
* @param availableParallel available space. This is a width (pixels) if width == true, and a height (pixels)
* if width == false. A return value larger than this will be ignored.
* @param availablePerpendicular available space perpendicular to the direction being measured
* or INF if unbounded (pixels). This
* is a height if width == true, or a height if width == false. Implementations will generally ignore this
* argument unless they contain wrapping widgets. Note this argument will only contain meaningful information
* if the part returns the SWT.WRAP flag from getSizeFlags(width)
* @param preferredResult preferred size of the control (pixels, <= availableParallel). Set to
* INF if unknown or unbounded.
* @return returns the preferred size of the control (pixels). This is a width if width == true or a height
* if width == false. Callers are responsible for rounding down the return value if it is larger than
* availableParallel. If availableParallel is INF, then a return value of INF
* is permitted, indicating that the preferred size of the control is unbounded.
*
* @see ISizeProvider#getSizeFlags(boolean)
*/
virtual int ComputePreferredSize(bool width, int availableParallel, int availablePerpendicular, int preferredResult) = 0;
};
}
#endif /* BERRYISIZEPROVIDER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryISourceProvider.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryISourceProvider.h
index 552210650d..350fc75fd1 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryISourceProvider.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryISourceProvider.h
@@ -1,107 +1,107 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYISOURCEPROVIDER_H_
#define BERRYISOURCEPROVIDER_H_
#include <org_blueberry_ui_Export.h>
#include "berryISourceProviderListener.h"
#include <map>
#include <vector>
#include <string>
#include <QObject>
namespace berry {
/**
* <p>
* A provider of notifications for when a change has occurred to a particular
* type of source. These providers can be given to the appropriate service, and
* this service will then re-evaluate the appropriate pieces of its internal
* state in response to these changes.
* </p>
* <p>
* It is recommended that clients subclass <code>AbstractSourceProvider</code>
* instead, as this provides some common support for listeners.
* </p>
*
* @since 3.1
* @see org.blueberry.ui.handlers.IHandlerService
* @see org.blueberry.ui.ISources
*/
struct BERRY_UI ISourceProvider : public virtual Object {
berryInterfaceMacro(ISourceProvider, berry);
typedef std::map<std::string, Object::Pointer> StateMapType;
~ISourceProvider();
/**
* Adds a listener to this source provider. This listener will be notified
* whenever the corresponding source changes.
*
* @param listener
* The listener to add; must not be <code>null</code>.
*/
virtual void AddSourceProviderListener(ISourceProviderListener::Pointer listener) = 0;
/**
* Returns the current state of the sources tracked by this provider. This
* is used to provide a view of the world if the event loop is busy and
* things are some state has already changed.
* <p>
* For use with core expressions, this map should contain
* IEvaluationContext#UNDEFINED_VARIABLE for properties which
* are only sometimes available.
* </p>
*
* @return A map of variable names (<code>String</code>) to variable
* values (<code>Object</code>). This may be empty, and may be
* <code>null</code>.
*/
virtual StateMapType GetCurrentState() = 0;
/**
* Returns the names of those sources provided by this class. This is used
* by clients of source providers to determine which source providers they
* actually need.
*
* @return An array of source names. This value should never be
* <code>null</code> or empty.
*/
virtual std::vector<std::string> GetProvidedSourceNames() = 0;
/**
* Removes a listener from this source provider. This listener will be
* notified whenever the corresponding source changes.
*
* @param listener
* The listener to remove; must not be <code>null</code>.
*/
virtual void RemoveSourceProviderListener(ISourceProviderListener::Pointer listener) = 0;
};
}
Q_DECLARE_INTERFACE(berry::ISourceProvider, "org.blueberry.ISourceProvider")
#endif /* BERRYISOURCEPROVIDER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryISourceProviderListener.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/berryISourceProviderListener.cpp
index 1b0c435ec1..7bb9307df2 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryISourceProviderListener.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryISourceProviderListener.cpp
@@ -1,37 +1,37 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryISourceProviderListener.h"
namespace berry {
void ISourceProviderListener::Events::AddListener(ISourceProviderListener::Pointer l)
{
if (l == 0) return;
multipleSourcesChanged += Delegate2(l.GetPointer(), &ISourceProviderListener::SourceChanged);
singleSourceChanged += Delegate3(l.GetPointer(), &ISourceProviderListener::SourceChanged);
}
void ISourceProviderListener::Events::RemoveListener(ISourceProviderListener::Pointer l)
{
if (l == 0) return;
multipleSourcesChanged -= Delegate2(l.GetPointer(), &ISourceProviderListener::SourceChanged);
singleSourceChanged -= Delegate3(l.GetPointer(), &ISourceProviderListener::SourceChanged);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryISourceProviderListener.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryISourceProviderListener.h
index cd3a26da5b..a195d937e3 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryISourceProviderListener.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryISourceProviderListener.h
@@ -1,100 +1,100 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYISOURCEPROVIDERLISTENER_H_
#define BERRYISOURCEPROVIDERLISTENER_H_
#include <org_blueberry_ui_Export.h>
#include <berryMacros.h>
#include <berryObject.h>
#include <berryMessage.h>
#include <map>
namespace berry {
/**
* <p>
* A listener to changes in a particular source of information. This listener is
* notified as the source changes. Typically, workbench services will implement
* this interface, and register themselves as listeners to the
* <code>ISourceProvider</code> instances that are registered with them.
* </p>
*
* @since 3.1
* @see org.blueberry.ui.ISources
* @see org.blueberry.ui.ISourceProvider
*/
struct BERRY_UI ISourceProviderListener : public virtual Object {
berryInterfaceMacro(ISourceProviderListener, berry);
struct Events {
Message2<int, const std::map<std::string, Object::Pointer>& > multipleSourcesChanged;
Message3<int, const std::string&, Object::Pointer> singleSourceChanged;
void AddListener(ISourceProviderListener::Pointer l);
void RemoveListener(ISourceProviderListener::Pointer l);
private:
typedef MessageDelegate2<ISourceProviderListener, int, const std::map<std::string, Object::Pointer>& > Delegate2;
typedef MessageDelegate3<ISourceProviderListener, int, const std::string&, Object::Pointer> Delegate3;
};
/**
* Handles a change to multiple sources. The source priority should be a bit
* mask indicating the sources. The map will be used to construct the
* variables on an <code>IEvaluationContext</code>
*
* @param sourcePriority
* A bit mask of all the source priorities that have changed.
* @param sourceValuesByName
* A mapping of the source names (<code>String</code>) to the
* source values (<code>Object</code>). The names should
* never be <code>null</code>, but the values may be. The map
* must not be <code>null</code>, and should contain at least
* two elements (one for each source).
* @see org.blueberry.core.expressions.IEvaluationContext
* @see ISources
*/
virtual void SourceChanged(int sourcePriority,
const std::map<std::string, Object::Pointer>& sourceValuesByName) = 0;
/**
* Handles a change to one source. The source priority should indicate the
* source, and the name-value pair will be used to create an
* <code>IEvaluationContext</code> with a single variable.
*
* @param sourcePriority
* A bit mask of all the source priorities that have changed.
* @param sourceName
* The name of the source that changed; must not be
* <code>null</code>.
* @param sourceValue
* The new value for that source; may be <code>null</code>.
* @see org.blueberry.core.expressions.IEvaluationContext
* @see ISources
*/
virtual void SourceChanged(int sourcePriority,
const std::string& sourceName, Object::Pointer sourceValue) = 0;
};
}
#endif /* BERRYISOURCEPROVIDERLISTENER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryISources.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/berryISources.cpp
index d1d66a391f..800adf50cb 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryISources.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryISources.cpp
@@ -1,253 +1,253 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryISources.h"
namespace berry
{
int ISources::WORKBENCH()
{
static int val = 0;
return val;
}
int ISources::LEGACY_LEGACY()
{
static int val = 1;
return val;
}
int ISources::LEGACY_LOW()
{
static int val = 1 << 1;
return val;
}
int ISources::LEGACY_MEDIUM()
{
static int val = 1 << 2;
return val;
}
int ISources::ACTIVE_CONTEXT()
{
static int val = 1 << 6;
return val;
}
const std::string ISources::ACTIVE_CONTEXT_NAME()
{
static const std::string val = "activeContexts";
return val;
} //$NON-NLS-1$
int ISources::ACTIVE_ACTION_SETS()
{
static int val = 1 << 8;
return val;
}
const std::string ISources::ACTIVE_ACTION_SETS_NAME()
{
static const std::string val = "activeActionSets";
return val;
} //$NON-NLS-1$
int ISources::ACTIVE_SHELL()
{
static int val = 1 << 10;
return val;
}
const std::string ISources::ACTIVE_SHELL_NAME()
{
static const std::string val = "activeShell";
return val;
} //$NON-NLS-1$
int ISources::ACTIVE_WORKBENCH_WINDOW_SHELL()
{
static int val = 1 << 12;
return val;
}
const std::string ISources::ACTIVE_WORKBENCH_WINDOW_SHELL_NAME()
{
static const std::string val = "activeWorkbenchWindowShell";
return val;
} //$NON-NLS-1$
int ISources::ACTIVE_WORKBENCH_WINDOW()
{
static int val = 1 << 14;
return val;
}
const std::string ISources::ACTIVE_WORKBENCH_WINDOW_NAME()
{
static const std::string val = "activeWorkbenchWindow";
return val;
} //$NON-NLS-1$
int ISources::ACTIVE_WORKBENCH_WINDOW_SUBORDINATE()
{
static int val = 1 << 15;
return val;
}
const std::string ISources::ACTIVE_WORKBENCH_WINDOW_IS_COOLBAR_VISIBLE_NAME()
{
static const std::string val = ISources::ACTIVE_WORKBENCH_WINDOW_NAME()
+ ".isCoolbarVisible";
return val;
} //$NON-NLS-1$
const std::string ISources::ACTIVE_WORKBENCH_WINDOW_IS_PERSPECTIVEBAR_VISIBLE_NAME()
{
static const std::string val = ISources::ACTIVE_WORKBENCH_WINDOW_NAME()
+ ".isPerspectiveBarVisible";
return val;
} //$NON-NLS-1$
const std::string ISources::ACTIVE_WORKBENCH_WINDOW_ACTIVE_PERSPECTIVE_NAME()
{
static const std::string val = ISources::ACTIVE_WORKBENCH_WINDOW_NAME()
+ ".activePerspective";
return val;
} //$NON-NLS-1$
int ISources::ACTIVE_EDITOR()
{
static int val = 1 << 16;
return val;
}
const std::string ISources::ACTIVE_EDITOR_NAME()
{
static const std::string val = "activeEditor";
return val;
} //$NON-NLS-1$
int ISources::ACTIVE_EDITOR_ID()
{
static int val = 1 << 18;
return val;
}
const std::string ISources::ACTIVE_EDITOR_ID_NAME()
{
static const std::string val = "activeEditorId";
return val;
} //$NON-NLS-1$
int ISources::ACTIVE_PART()
{
static int val = 1 << 20;
return val;
}
const std::string ISources::ACTIVE_PART_NAME()
{
static const std::string val = "activePart";
return val;
} //$NON-NLS-1$
int ISources::ACTIVE_PART_ID()
{
static int val = 1 << 22;
return val;
}
const std::string ISources::ACTIVE_PART_ID_NAME()
{
static const std::string val = "activePartId";
return val;
} //$NON-NLS-1$
int ISources::ACTIVE_SITE()
{
static int val = 1 << 26;
return val;
}
const std::string ISources::ACTIVE_SITE_NAME()
{
static const std::string val = "activeSite";
return val;
} //$NON-NLS-1$
const std::string ISources::SHOW_IN_SELECTION()
{
static const std::string val = "showInSelection";
return val;
} //$NON-NLS-1$
const std::string ISources::SHOW_IN_INPUT()
{
static const std::string val = "showInInput";
return val;
} //$NON-NLS-1$
int ISources::ACTIVE_CURRENT_SELECTION()
{
static int val = 1 << 30;
return val;
}
const std::string ISources::ACTIVE_CURRENT_SELECTION_NAME()
{
static const std::string val = "selection";
return val;
} //$NON-NLS-1$
int ISources::ACTIVE_MENU()
{
static int val = 1 << 31;
return val;
}
const std::string ISources::ACTIVE_MENU_NAME()
{
static const std::string val = "activeMenu";
return val;
} //$NON-NLS-1$
const std::string ISources::ACTIVE_MENU_SELECTION_NAME()
{
static const std::string val = "activeMenuSelection";
return val;
} //$NON-NLS-1$
const std::string ISources::ACTIVE_MENU_EDITOR_INPUT_NAME()
{
static const std::string val = "activeMenuEditorInput";
return val;
} //$NON-NLS-1$
const std::string ISources::ACTIVE_FOCUS_CONTROL_NAME()
{
static const std::string val = "activeFocusControl";
return val;
} //$NON-NLS-1$
const std::string ISources::ACTIVE_FOCUS_CONTROL_ID_NAME()
{
static const std::string val = "activeFocusControlId";
return val;
} //$NON-NLS-1$
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryISources.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryISources.h
index ed36318ef4..fbc07e86df 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryISources.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryISources.h
@@ -1,340 +1,340 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYISOURCES_H_
#define BERRYISOURCES_H_
#include <string>
#include <org_blueberry_ui_Export.h>
namespace berry {
/**
* \ingroup org_blueberry_ui
*
* <p>
* A source is type of event change that can occur within the workbench. For
* example, the active workbench window can change, so it is considered a
* source. Workbench services can track changes to these sources, and thereby
* try to resolve conflicts between a variety of possible options. This is most
* commonly used for things like handlers and contexts.
* </p>
* <p>
* This interface defines the source that are known to the workbench at
* compile-time. These sources can be combined in a bit-wise fashion. So, for
* example, a <code>ACTIVE_PART | ACTIVE_CONTEXT</code> source includes change
* to both the active context and the active part.
* </p>
* <p>
* The values assigned to each source indicates its relative priority. The
* higher the value, the more priority the source is given in resolving
* conflicts. Another way to look at this is that the higher the value, the more
* "local" the source is to what the user is currently doing. This is similar
* to, but distinct from the concept of components. The nesting support provided
* by components represent only one source (<code>ACTIVE_SITE</code>) that
* the workbench understands.
* </p>
* <p>
* Note that for backward compatibility, we must reserve the lowest three bits
* for <code>Priority</code> instances using the old
* <code>HandlerSubmission</code> mechanism. This mechanism was used in
* Eclipse 3.0.
* </p>
* <p>
* <b>Note in 3.3:</b>
* </p>
* <p>
* Currently, source variables are not extensible by user plugins, and
* the number of bits available for resolving conflicts is limited. When
* the variable sources become user extensible a new conflict resolution
* mechanism will be implemented.
* </p>
* @noimplement This interface is not intended to be implemented by clients.
* @noextend This interface is not intended to be extended by clients.
*
* @see org.blueberry.ui.ISourceProvider
* @since 3.1
*/
struct BERRY_UI ISources {
/**
* The priority given to default handlers and handlers that are active
* across the entire workbench.
*/
static int WORKBENCH(); // = 0;
/**
* The priority given when the activation is defined by a handler submission
* with a legacy priority.
*/
static int LEGACY_LEGACY(); // = 1;
/**
* The priority given when the activation is defined by a handler submission
* with a low priority.
*/
static int LEGACY_LOW(); // = 1 << 1;
/**
* The priority given when the activation is defined by a handler submission
* with a medium priority.
*/
static int LEGACY_MEDIUM(); // = 1 << 2;
/**
* The priority given when the source includes a particular context.
*/
static int ACTIVE_CONTEXT(); // = 1 << 6;
/**
* The variable name for the active contexts. This is for use with the
* <code>ISourceProvider</code> and <code>IEvaluationContext</code>.
* @since 3.2
*/
static const std::string ACTIVE_CONTEXT_NAME(); // = "activeContexts"; //$NON-NLS-1$
/**
* The priority given when the source includes a particular action set.
* @since 3.2
*/
static int ACTIVE_ACTION_SETS(); // = 1 << 8;
/**
* The variable name for the active action sets. This is for use with the
* {@link ISourceProvider} and {@link IEvaluationContext}.
* @since 3.2
*/
static const std::string ACTIVE_ACTION_SETS_NAME(); // = "activeActionSets"(); //$NON-NLS-1$
/**
* The priority given when the source includes the currently active shell.
*/
static int ACTIVE_SHELL(); // = 1 << 10();
/**
* The variable name for the active shell. This is for use with the
* <code>ISourceProvider</code> and <code>IEvaluationContext</code>.
*/
static const std::string ACTIVE_SHELL_NAME(); // = "activeShell"(); //$NON-NLS-1$
/**
* The priority given when the source includes the currently active
* workbench window shell.
* @since 3.2
*/
static int ACTIVE_WORKBENCH_WINDOW_SHELL(); // = 1 << 12();
/**
* The variable name for the active workbench window shell. This is for use
* with the <code>ISourceProvider</code> and
* <code>IEvaluationContext</code>.
* @since 3.2
*/
static const std::string ACTIVE_WORKBENCH_WINDOW_SHELL_NAME(); // = "activeWorkbenchWindowShell"(); //$NON-NLS-1$
/**
* The priority given when the source includes the currently active
* workbench window.
*/
static int ACTIVE_WORKBENCH_WINDOW(); // = 1 << 14();
/**
* The variable name for the active workbench window. This is for use with
* the <code>ISourceProvider</code> and <code>IEvaluationContext</code>.
*/
static const std::string ACTIVE_WORKBENCH_WINDOW_NAME(); // = "activeWorkbenchWindow"(); //$NON-NLS-1$
/**
* The priority given when the source includes subordinate properties of the currently active
* workbench window.
*
* @since 3.3
*/
static int ACTIVE_WORKBENCH_WINDOW_SUBORDINATE(); // = 1 << 15();
/**
* The variable name for the coolbar visibility state of the active
* workbench window. This is for use with the <code>ISourceProvider</code>
* and <code>IEvaluationContext</code>.
*
* @since 3.3
*/
static const std::string ACTIVE_WORKBENCH_WINDOW_IS_COOLBAR_VISIBLE_NAME(); // = ACTIVE_WORKBENCH_WINDOW_NAME
// + ".isCoolbarVisible"(); //$NON-NLS-1$
/**
* The variable name for the perspective bar visibility state of the active
* workbench window. This is for use with the <code>ISourceProvider</code>
* and <code>IEvaluationContext</code>.
*
* @since 3.3
*/
static const std::string ACTIVE_WORKBENCH_WINDOW_IS_PERSPECTIVEBAR_VISIBLE_NAME(); // = ACTIVE_WORKBENCH_WINDOW_NAME
// + ".isPerspectiveBarVisible"(); //$NON-NLS-1$
/**
* The variable name for the current perspective of the active workbench
* window. This is for use with the <code>ISourceProvider</code> and
* <code>IEvaluationContext</code>.
*
* @since 3.4
*/
static const std::string ACTIVE_WORKBENCH_WINDOW_ACTIVE_PERSPECTIVE_NAME(); // = ACTIVE_WORKBENCH_WINDOW_NAME
//+ ".activePerspective"(); //$NON-NLS-1$
/**
* The priority given when the source includes the active editor part.
*/
static int ACTIVE_EDITOR(); // = 1 << 16();
/**
* The variable name for the active editor part. This is for use with the
* <code>ISourceProvider</code> and <code>IEvaluationContext</code>.
* @since 3.2
*/
static const std::string ACTIVE_EDITOR_NAME(); // = "activeEditor"(); //$NON-NLS-1$
/**
* The priority given when the source includes the active editor identifier.
*
* @since 3.2
*/
static int ACTIVE_EDITOR_ID(); // = 1 << 18();
/**
* The variable name for the active editor identifier. This is for use with
* the <code>ISourceProvider</code> and <code>IEvaluationContext</code>.
*
* @since 3.2
*/
static const std::string ACTIVE_EDITOR_ID_NAME(); // = "activeEditorId"(); //$NON-NLS-1$
/**
* The priority given when the source includes the active part.
*/
static int ACTIVE_PART(); // = 1 << 20();
/**
* The variable name for the active part. This is for use with the
* <code>ISourceProvider</code> and <code>IEvaluationContext</code>.
*/
static const std::string ACTIVE_PART_NAME(); // = "activePart"(); //$NON-NLS-1$
/**
* The priority given when the source includes the active part id.
*
* @since 3.2
*/
static int ACTIVE_PART_ID(); // = 1 << 22();
/**
* The variable name for the active part id. This is for use with the
* <code>ISourceProvider</code> and <code>IEvaluationContext</code>.
*
* @since 3.2
*/
static const std::string ACTIVE_PART_ID_NAME(); // = "activePartId"(); //$NON-NLS-1$
/**
* The priority given when the source includes the active workbench site. In
* the case of nesting components, one should be careful to only activate
* the most nested component.
*/
static int ACTIVE_SITE(); // = 1 << 26();
/**
* The variable name for the active workbench site. This is for use with the
* <code>ISourceProvider</code> and <code>IEvaluationContext</code>.
*/
static const std::string ACTIVE_SITE_NAME(); // = "activeSite"(); //$NON-NLS-1$
/**
* The variable for the showIn selection. This is for use with the
* <code>ISourceProvider</code> and <code>IEvaluationContext</code>.
* @since 3.4
* @see IShowInSource
*/
static const std::string SHOW_IN_SELECTION(); // = "showInSelection"(); //$NON-NLS-1$
/**
* The variable for the showIn input. This is for use with the
* <code>ISourceProvider</code> and <code>IEvaluationContext</code>.
* @since 3.4
* @see IShowInSource
*/
static const std::string SHOW_IN_INPUT(); // = "showInInput"(); //$NON-NLS-1$
/**
* The priority given when the source includes the current selection.
*/
static int ACTIVE_CURRENT_SELECTION(); // = 1 << 30();
/**
* The variable name for the active selection. This is for use with the
* <code>ISourceProvider</code> and <code>IEvaluationContext</code>.
* @since 3.2
*/
static const std::string ACTIVE_CURRENT_SELECTION_NAME(); // = "selection"(); //$NON-NLS-1$
/**
* The priority given when the source includes the current menu.
* @since 3.2
*/
static int ACTIVE_MENU(); // = 1 << 31();
/**
* The variable name for the active menu. This is for use with the
* {@link ISourceProvider} and {@link IEvaluationContext}.
* @since 3.2
*/
static const std::string ACTIVE_MENU_NAME(); // = "activeMenu"(); //$NON-NLS-1$
/**
* The variable name for the <b>local</b> selection, available while a
* context menu is visible.
*
* @since 3.3
*/
static const std::string ACTIVE_MENU_SELECTION_NAME(); // = "activeMenuSelection"(); //$NON-NLS-1$
/**
* The variable name for the <b>local</b> editor input which is sometimes
* available while a context menu is visible.
*
* @since 3.3
*/
static const std::string ACTIVE_MENU_EDITOR_INPUT_NAME(); // = "activeMenuEditorInput"(); //$NON-NLS-1$
/**
* The variable name for the active focus Control, when provided by the
* IFocusService.
*
* @since 3.3
*/
static const std::string ACTIVE_FOCUS_CONTROL_NAME(); // = "activeFocusControl"(); //$NON-NLS-1$
/**
* The variable name for the active focus Control id, when provided by the
* IFocusService.
*
* @since 3.3
*/
static const std::string ACTIVE_FOCUS_CONTROL_ID_NAME(); // = "activeFocusControlId"(); //$NON-NLS-1$
};
}
#endif /*BERRYISOURCES_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIStickyViewDescriptor.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryIStickyViewDescriptor.h
index e22c072a65..0e7fd89727 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIStickyViewDescriptor.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIStickyViewDescriptor.h
@@ -1,79 +1,79 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYISTICKYVIEWDESCRIPTOR_H_
#define BERRYISTICKYVIEWDESCRIPTOR_H_
#include <berryObject.h>
#include <berryMacros.h>
#include <org_blueberry_ui_Export.h>
namespace berry {
/**
* Supplemental view interface that describes various sticky characteristics
* that a view may possess.
* <p>
* This interface is not intended to be implemented by clients.
* </p>
*
* @see org.eclipse.ui.views.IViewRegistry
* @see org.eclipse.ui.views.IViewDescriptor
* @since 3.1
* @noimplement This interface is not intended to be implemented by clients.
*/
struct BERRY_UI IStickyViewDescriptor : public Object {
berryObjectMacro(IStickyViewDescriptor)
~IStickyViewDescriptor();
/**
* Return the id of the view to be made sticky.
*
* @return the id of the view to be made sticky
*/
virtual std::string GetId() const = 0;
/**
* Return the location of this sticky view. Must be one of
* <code>IPageLayout.LEFT</code>, <code>IPageLayout.RIGHT</code>,
* <code>IPageLayout.TOP</code>, or <code>IPageLayout.BOTTOM</code>.
*
* @return the location constant
*/
virtual int GetLocation() const = 0;
/**
* Return whether this view should be closeable.
*
* @return whether this view should be closeeable
*/
virtual bool IsCloseable() const = 0;
/**
* Return whether this view should be moveable.
*
* @return whether this view should be moveable
*/
virtual bool IsMoveable() const = 0;
};
}
#endif /* BERRYISTICKYVIEWDESCRIPTOR_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIStructuredSelection.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/berryIStructuredSelection.cpp
index b5a3e48339..5ed0ca2932 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIStructuredSelection.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIStructuredSelection.cpp
@@ -1,25 +1,25 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryIStructuredSelection.h"
namespace berry {
IStructuredSelection::~IStructuredSelection()
{
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIStructuredSelection.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryIStructuredSelection.h
index 46b0d8e21b..9625a3f56e 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIStructuredSelection.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIStructuredSelection.h
@@ -1,87 +1,87 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYISTRUCTUREDSELECTION_H_
#define BERRYISTRUCTUREDSELECTION_H_
#include "berryISelection.h"
#include <berryObjectVector.h>
#include <org_blueberry_ui_Export.h>
namespace berry
{
/**
* A selection containing elements.
*/
struct BERRY_UI IStructuredSelection : public ISelection {
typedef ObjectVector<Object::Pointer> ContainerType;
typedef ContainerType::const_iterator iterator;
berryInterfaceMacro(IStructuredSelection, berry);
/**
* Returns the first element in this selection, or <code>null</code>
* if the selection is empty.
*
* @return an element, or <code>null</code> if none
*/
virtual Object::Pointer GetFirstElement() const = 0;
/**
* Returns an iterator to the beginning of the elements of this selection.
*
* @return an iterator over the selected elements
*/
virtual iterator Begin() const = 0;
/**
* Returns an iterator to the end of the elements of this selection.
*
* @return an iterator over the selected elements
*/
virtual iterator End() const = 0;
/**
* Returns the number of elements selected in this selection.
*
* @return the number of elements selected
*/
virtual int Size() const = 0;
/**
* Returns the elements in this selection as a vector.
*
* @return the selected elements as a vector
*/
virtual ContainerType::Pointer ToVector() const = 0;
/*
* We need to define at least the destructor in this compilation unit
* because of the export macro above. Otherwise Windows throws
* a linker error in dependent librraies. The export macro is needed
* for gcc < 4.5 to correctly mark the type_info object of this class
* as visible (we have default visibility 'hidden') so that dynamic_cast calls work.
*/
virtual ~IStructuredSelection();
};
}
#endif /* BERRYISTRUCTUREDSELECTION_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIViewCategory.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryIViewCategory.h
index 1ac673083f..121d0f9e7e 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIViewCategory.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIViewCategory.h
@@ -1,46 +1,46 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIVIEWCATEGORY_H_
#define BERRYIVIEWCATEGORY_H_
#include "berryIViewDescriptor.h"
#include <berryMacros.h>
#include <vector>
namespace berry {
/**
* \ingroup org_blueberry_ui
*
*/
struct BERRY_UI IViewCategory : public Object
{
berryInterfaceMacro(IViewCategory, berry)
virtual const std::string& GetId() const = 0;
virtual std::string GetLabel() const = 0;
virtual std::vector<std::string> GetPath() const = 0;
virtual const std::vector<IViewDescriptor::Pointer>& GetViews() const = 0;
virtual ~IViewCategory();
};
}
#endif /*BERRYIVIEWCATEGORY_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIViewDescriptor.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryIViewDescriptor.h
index b82e02a9c0..5fabbb9861 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIViewDescriptor.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIViewDescriptor.h
@@ -1,107 +1,107 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 <org_blueberry_ui_Export.h>
#include "berryIWorkbenchPartDescriptor.h"
#include "berryIViewPart.h"
#include <berryIConfigurationElement.h>
#include <berryIAdaptable.h>
#include "berryImageDescriptor.h"
#include <string>
#include <vector>
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.
* <p>
* The view registry provides facilities to map from an extension
* to a IViewDescriptor.
* </p>
* <p>
* This interface is not intended to be implemented by clients.
* </p>
*
* @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;
/**
* 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<std::string>& 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<ImageDescriptor> 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/berryIViewLayout.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryIViewLayout.h
index 076f88ff19..6a63bf42dc 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIViewLayout.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIViewLayout.h
@@ -1,92 +1,92 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIVIEWLAYOUT_H_
#define BERRYIVIEWLAYOUT_H_
#include <org_blueberry_ui_Export.h>
#include <berryMacros.h>
#include <berryObject.h>
namespace berry {
/**
* \ingroup org_blueberry_ui
*
* Represents the layout info for a view or placeholder in an {@link IPageLayout}.
* <p>
* This interface is not intended to be implemented by clients.
* </p>
*
* @since 3.0
* @noimplement This interface is not intended to be implemented by clients.
*/
struct BERRY_UI IViewLayout : public Object {
berryInterfaceMacro(IViewLayout, berry)
virtual ~IViewLayout();
/**
* Returns whether the view is closeable.
* The default is <code>true</code>.
*
* @return <code>true</code> if the view is closeable, <code>false</code> if not
*/
virtual bool IsCloseable() = 0;
/**
* Sets whether the view is closeable.
*
* @param closeable <code>true</code> if the view is closeable, <code>false</code> if not
*/
virtual void SetCloseable(bool closeable) = 0;
/**
* Returns whether the view is moveable.
* The default is <code>true</code>.
*
* @return <code>true</code> if the view is moveable, <code>false</code> if not
*/
virtual bool IsMoveable() = 0;
/**
* Sets whether the view is moveable.
*
* @param moveable <code>true</code> if the view is moveable, <code>false</code> if not
*/
virtual void SetMoveable(bool moveable) = 0;
/**
* Returns whether the view is a standalone view.
*
* @see IPageLayout#addStandaloneView
*/
virtual bool IsStandalone() = 0;
/**
* Returns whether the view shows its title.
* This is only applicable to standalone views.
*
* @see IPageLayout#addStandaloneView
*/
virtual bool GetShowTitle() = 0;
};
}
#endif /*BERRYIVIEWLAYOUT_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIViewPart.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryIViewPart.h
index c412b95a4c..c9b6d5d008 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIViewPart.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIViewPart.h
@@ -1,124 +1,124 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIVIEWPART_H_
#define BERRYIVIEWPART_H_
#include <org_blueberry_ui_Export.h>
#include "berryMacros.h"
#include "berryIMemento.h"
#include "berryIWorkbenchPart.h"
#include "berryIViewSite.h"
#include <QObject>
namespace berry {
/**
* \ingroup org_blueberry_ui
*
* 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. Modifications made in a view are
* saved immediately (in contrast to an editor part, which conforms to a more
* elaborate open-save-close lifecycle).
* <p>
* Only one instance of a particular view type may exist within a workbench
* page. This policy is designed to simplify part management for a user.
* </p>
* <p>
* This interface may be implemented directly. For convenience, a base
* implementation is defined in <code>ViewPart</code>.
* </p>
* <p>
* A view is added to the workbench in two steps:
* <ol>
* <li>A view extension is contributed to the workbench registry. This
* extension defines the extension id and extension class.</li>
* <li>The view is included in the default layout for a perspective.
* Alternatively, the user may open the view from the Perspective menu.</li>
* </ol>
* </p>
* <p>
* Views implement the <code>IAdaptable</code> interface; extensions are
* managed by the platform's adapter manager.
* </p>
* <p>
* As of 3.4, views may optionally adapt to {@link ISizeProvider} if they have
* a preferred size. The default presentation will make a best effort to
* allocate the preferred size to a view if it is the only part in a stack. If
* there is more than one part in the stack, the constraints will be disabled
* for that stack. The size constraints are adjusted for the size of the tab and
* border trim. Note that this is considered to be a hint to the presentation,
* and not all presentations may honor size constraints.
* </p>
*
* @see IWorkbenchPage#showView
* @see org.blueberry.ui.part.ViewPart
* @see ISizeProvider
*/
struct BERRY_UI IViewPart : public virtual IWorkbenchPart {
berryInterfaceMacro(IViewPart, berry)
virtual ~IViewPart();
/**
* Returns the site for this view.
* This method is equivalent to <code>(IViewSite) getSite()</code>.
* <p>
* The site can be <code>null</code> while the view is being initialized.
* After the initialization is complete, this value must be non-<code>null</code>
* for the remainder of the view's life cycle.
* </p>
*
* @return the view site; this value may be <code>null</code> if the view
* has not yet been initialized
*/
virtual IViewSite::Pointer GetViewSite() = 0;
/**
* Initializes this view with the given view site. A memento is passed to
* the view which contains a snapshot of the views state from a previous
* session. Where possible, the view should try to recreate that state
* within the part controls.
* <p>
* This method is automatically called by the workbench shortly after the part
* is instantiated. It marks the start of the views's lifecycle. Clients must
* not call this method.
* </p>
*
* @param site the view site
* @param memento the IViewPart state or null if there is no previous saved state
* @exception PartInitException if this view was not initialized successfully
*/
virtual void Init(IViewSite::Pointer site, IMemento::Pointer memento = IMemento::Pointer(0)) = 0;
/**
* Saves the object state within a memento.
*
* @param memento a memento to receive the object state
*/
virtual void SaveState(IMemento::Pointer memento) = 0;
};
}
Q_DECLARE_INTERFACE(berry::IViewPart, "org.blueberry.IViewPart")
#endif /*BERRYIVIEWPART_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIViewReference.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryIViewReference.h
index 32d418c651..9175f735ab 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIViewReference.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIViewReference.h
@@ -1,60 +1,60 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIVIEWREFERENCE_H_
#define BERRYIVIEWREFERENCE_H_
#include "berryIWorkbenchPartReference.h"
#include "berryIViewPart.h"
namespace berry {
/**
* \ingroup org_blueberry_ui
*
* Defines a reference to an IViewPart.
* <p>
* This interface is not intended to be implemented by clients.
* </p>
*/
struct BERRY_UI IViewReference : virtual public IWorkbenchPartReference {
berryInterfaceMacro(IViewReference, berry);
~IViewReference();
/**
* Returns the secondary ID for the view.
*
* @return the secondary ID, or <code>null</code> if there is no secondary id
* @see IWorkbenchPage#showView(String, String, int)
* @since 3.0
*/
virtual std::string GetSecondaryId() = 0;
/**
* Returns the <code>IViewPart</code> referenced by this object.
* Returns <code>null</code> if the view was not instantiated or
* it failed to be restored. Tries to restore the view
* if <code>restore</code> is true.
*/
virtual IViewPart::Pointer GetView(bool restore) = 0;
};
} // namespace berry
#endif /*BERRYIVIEWREFERENCE_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIViewRegistry.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryIViewRegistry.h
index 9105e1ad8e..77bdf15405 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIViewRegistry.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIViewRegistry.h
@@ -1,85 +1,85 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIVIEWREGISTRY_H_
#define BERRYIVIEWREGISTRY_H_
#include <org_blueberry_ui_Export.h>
#include "berryIViewDescriptor.h"
#include "berryIViewCategory.h"
#include "berryIStickyViewDescriptor.h"
#include <vector>
namespace berry {
/**
* \ingroup org_blueberry_ui
*
* The view registry maintains a list of views explicitly registered
* against the view extension point.
* <p>
* The description of a given view is kept in a <code>IViewDescriptor</code>.
* </p>
* <p>
* This interface is not intended to be implemented by clients.
* </p>
*
* @see IViewDescriptor
* @see IStickyViewDescriptor
* @noimplement This interface is not intended to be implemented by clients.
*/
struct BERRY_UI IViewRegistry
{
/**
* Return a view descriptor with the given extension id. If no view exists
* with the id return <code>null</code>.
* Will also return <code>null</code> if the view descriptor exists, but
* is filtered by an expression-based activity.
*
* @param id the id to search for
* @return the descriptor or <code>null</code>
*/
virtual IViewDescriptor::Pointer Find(const std::string& id) const = 0;
/**
* Returns an array of view categories.
*
* @return the categories.
*/
virtual std::vector<IViewCategory::Pointer> GetCategories() = 0;
/**
* Return a list of views defined in the registry.
*
* @return the views.
*/
virtual const std::vector<IViewDescriptor::Pointer>& GetViews() const = 0;
/**
* Return a list of sticky views defined in the registry.
*
* @return the sticky views. Never <code>null</code>.
*/
virtual std::vector<IStickyViewDescriptor::Pointer> GetStickyViews() const = 0;
virtual ~IViewRegistry();
};
}
#endif /*BERRYIVIEWREGISTRY_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIViewSite.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryIViewSite.h
index 771de796ce..f7691a9ae7 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIViewSite.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIViewSite.h
@@ -1,62 +1,62 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIVIEWSITE_H_
#define BERRYIVIEWSITE_H_
#include "berryIWorkbenchPartSite.h"
#include <string>
namespace berry {
/**
* \ingroup org_blueberry_ui
*
* The primary interface between a view part and the workbench.
* <p>
* The workbench exposes its implemention of view part sites via this interface,
* which is not intended to be implemented or extended by clients.
* </p>
* @noimplement This interface is not intended to be implemented by clients.
*/
struct BERRY_UI IViewSite : public virtual IWorkbenchPartSite {
berryInterfaceMacro(IViewSite, berry)
virtual ~IViewSite();
/**
* Returns the action bars for this part site.
* Views have exclusive use of their site's action bars.
*
* @return the action bars
*/
//IActionBars getActionBars();
/**
* Returns the secondary id for this part site's part,
* or <code>null</code> if it has none.
*
* @see IWorkbenchPage#showView(String, String, int)
* @since 3.0
*/
virtual std::string GetSecondaryId() = 0;
};
}
#endif /*BERRYIVIEWSITE_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIWindowListener.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/berryIWindowListener.cpp
index 91a2f6d691..a17589b8b3 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIWindowListener.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIWindowListener.cpp
@@ -1,45 +1,45 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryIWindowListener.h"
namespace berry {
void
IWindowListener::Events
::AddListener(IWindowListener::Pointer listener)
{
if (listener.IsNull()) return;
windowActivated += Delegate(listener.GetPointer(), &IWindowListener::WindowActivated);
windowDeactivated += Delegate(listener.GetPointer(), &IWindowListener::WindowDeactivated);
windowClosed += Delegate(listener.GetPointer(), &IWindowListener::WindowClosed);
windowOpened += Delegate(listener.GetPointer(), &IWindowListener::WindowOpened);
}
void
IWindowListener::Events
::RemoveListener(IWindowListener::Pointer listener)
{
if (listener.IsNull()) return;
windowActivated -= Delegate(listener.GetPointer(), &IWindowListener::WindowActivated);
windowDeactivated -= Delegate(listener.GetPointer(), &IWindowListener::WindowDeactivated);
windowClosed -= Delegate(listener.GetPointer(), &IWindowListener::WindowClosed);
windowOpened -= Delegate(listener.GetPointer(), &IWindowListener::WindowOpened);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIWindowListener.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryIWindowListener.h
index 04a50c7cad..a532a4d281 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIWindowListener.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIWindowListener.h
@@ -1,99 +1,99 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIWINDOWLISTENER_H_
#define BERRYIWINDOWLISTENER_H_
#include <org_blueberry_ui_Export.h>
#include <berryMacros.h>
#include <berryMessage.h>
#include "berryIWorkbenchWindow.h"
namespace berry
{
/**
* Interface for listening to window lifecycle events.
* <p>
* This interface may be implemented by clients.
* </p>
*/
struct BERRY_UI IWindowListener : public virtual Object {
berryInterfaceMacro(IWindowListener, berry);
struct Events {
typedef Message1<IWorkbenchWindow::Pointer> WindowEvent;
WindowEvent windowActivated;
WindowEvent windowDeactivated;
WindowEvent windowClosed;
WindowEvent windowOpened;
void AddListener(IWindowListener::Pointer listener);
void RemoveListener(IWindowListener::Pointer listener);
private:
typedef MessageDelegate1<IWindowListener, IWorkbenchWindow::Pointer> Delegate;
};
/**
* Notifies this listener that the given window has been activated.
* <p>
* <b>Note:</b> This event is not fired if no perspective is
* open (the window is empty).
* </p>
*
* @param window the window that was activated
*/
virtual void WindowActivated(IWorkbenchWindow::Pointer /*window*/) {};
/**
* Notifies this listener that the given window has been deactivated.
* <p>
* <b>Note:</b> This event is not fired if no perspective is
* open (the window is empty).
* </p>
*
* @param window the window that was activated
*/
virtual void WindowDeactivated(IWorkbenchWindow::Pointer /*window*/) {};
/**
* Notifies this listener that the given window has been closed.
*
* @param window the window that was closed
* @see IWorkbenchWindow#close
*/
virtual void WindowClosed(IWorkbenchWindow::Pointer /*window*/) {};
/**
* Notifies this listener that the given window has been opened.
*
* @param window the window that was opened
* @see IWorkbench#openWorkbenchWindow
*/
virtual void WindowOpened(IWorkbenchWindow::Pointer /*window*/) {};
};
}
#endif /* BERRYIWINDOWLISTENER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIWorkbench.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryIWorkbench.h
index ab665654af..76c3f4232b 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIWorkbench.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIWorkbench.h
@@ -1,400 +1,400 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIWORKBENCH_H_
#define BERRYIWORKBENCH_H_
#include <berryMacros.h>
#include "services/berryIServiceLocator.h"
#include "dialogs/berryIDialog.h"
#include "berryIViewRegistry.h"
#include "berryIEditorRegistry.h"
#include "intro/berryIIntroManager.h"
#include "berryIPerspectiveRegistry.h"
#include "berryIWorkbenchWindow.h"
#include "berryIWorkbenchListener.h"
#include "berryIWindowListener.h"
#include "berryDisplay.h"
namespace berry {
struct IWorkbenchPage;
/**
* \ingroup org_blueberry_ui
*
* A workbench is the root object for the BlueBerry Platform user interface.
* <p>
* A <b>workbench</b> has one or more main windows which present to the end
* user information based on some underlying model, typically on resources in an
* underlying workspace. A workbench usually starts with a single open window,
* and automatically closes when its last window closes.
* </p>
* <p>
* Each <b>workbench window</b> has a collection of <b>pages</b>; 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.
* </p>
* <p>
* Each workbench page has a collection of <b>workbench parts</b>, of which
* there are two kinds: views and editors. A page's parts are arranged (tiled or
* stacked) for presentation on the screen. The arrangement is not fixed; the
* user can arrange the parts as they see fit. A <b>perspective</b> is a
* template for a page, capturing a collection of parts and their arrangement.
* </p>
* <p>
* The platform creates a workbench when the workbench plug-in is activated;
* since this happens at most once during the life of the running platform,
* there is only one workbench instance. Due to its singular nature, it is
* commonly referred to as <it>the</it> workbench.
* </p>
* <p>
* The workbench 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 shuts down. The supported services
* are:
* </p>
* <ul>
* <li>{@link IBindingService}</li>
* <li>{@link ICommandService}</li>
* <li>{@link IContextService}</li>
* <li>{@link IHandlerService}</li>
* </ul>
* <p>
* This interface is not intended to be implemented by clients.
* </p>
*
* @see PlatformUI#getWorkbench
* @noimplement This interface is not intended to be implemented by clients.
*/
struct BERRY_UI IWorkbench : public IServiceLocator {
berryInterfaceMacro(IWorkbench, berry)
virtual ~IWorkbench();
/**
* Returns the display for this workbench.
* <p>
* Code should always ask the workbench for the display rather than rely on
* {@link Display#getDefault Display.getDefault()}.
* </p>
*
* @return the display to be used for all UI interactions with this
* workbench
*/
virtual Display* GetDisplay() = 0;
/**
* Adds a workbench listener.
*
* @param listener
* the workbench listener to add
* @since 3.2
*/
virtual void AddWorkbenchListener(IWorkbenchListener::Pointer listener) = 0;
/**
* Removes a workbench listener.
*
* @param listener
* the workbench listener to remove
* @since 3.2
*/
virtual void RemoveWorkbenchListener(IWorkbenchListener::Pointer listener) = 0;
/**
* Returns the workbench events object
*/
virtual IWorkbenchListener::Events& GetWorkbenchEvents() = 0;
/**
* Adds a window listener.
*
* @param listener
* the window listener to add
* @since 2.0
*/
virtual void AddWindowListener(IWindowListener::Pointer listener) = 0;
/**
* Removes a window listener.
*
* @param listener
* the window listener to remove
* @since 2.0
*/
virtual void RemoveWindowListener(IWindowListener::Pointer listener) = 0;
/**
* Returns the window events object
*
*/
virtual IWindowListener::Events& GetWindowEvents() = 0;
/**
* Closes this workbench and all its open windows.
* <p>
* If the workbench has an open editor with unsaved content, the user will
* be given the opportunity to save it.
* </p>
*
* @return <code>true</code> if the workbench was successfully closed, and
* <code>false</code> if it is still open
*/
virtual bool Close() = 0;
/**
* Returns the currently active window for this workbench (if any). Returns
* <code>null</code> if there is no active workbench window. Returns
* <code>null</code> if called from a non-UI thread.
*
* @return the active workbench window, or <code>null</code> if there is
* no active workbench window or if called from a non-UI thread
*/
virtual IWorkbenchWindow::Pointer GetActiveWorkbenchWindow() = 0;
/**
* Returns the perspective registry for the workbench.
*
* @return the workbench perspective registry
*/
virtual IPerspectiveRegistry* GetPerspectiveRegistry() = 0;
/**
* Returns the view registry for the workbench.
*
* @return the workbench view registry
* @since 3.1
*/
virtual IViewRegistry* GetViewRegistry() = 0;
/**
* Returns the editor registry for the workbench.
*
* @return the workbench editor registry
*/
virtual IEditorRegistry* GetEditorRegistry() = 0;
/**
* Returns the number of open main windows associated with this workbench.
* Note that wizards and dialogs are not included in this list since they
* are not considered main windows.
*
* @return the number of open windows
* @since 3.0
*/
virtual std::size_t GetWorkbenchWindowCount() = 0;
/**
* Returns a list of the open main windows associated with this workbench.
* Note that wizards and dialogs are not included in this list since they
* are not considered main windows.
*
* @return a list of open windows
*/
virtual std::vector<IWorkbenchWindow::Pointer> GetWorkbenchWindows() = 0;
/**
* Creates and opens a new workbench window with one page. The perspective
* of the new page is defined by the specified perspective ID. The new
* window and new page become active.
* <p>
* <b>Note:</b> The caller is responsible to ensure the action using this
* method will explicitly inform the user a new window will be opened.
* Otherwise, callers are strongly recommended to use the
* <code>openPerspective</code> APIs to programmatically show a
* perspective to avoid confusing the user.
* </p>
* <p>
* In most cases where this method is used the caller is tightly coupled to
* a particular perspective. They define it in the registry and contribute
* some user interface action to open or activate it. In situations like
* this a static variable is often used to identify the perspective ID.
* </p>
*
* @param perspectiveId
* the perspective id for the window's initial page, or
* <code>null</code> for no initial page
* @param input
* the page input, or <code>null</code> 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 new window and page could not be opened
*
* @see IWorkbench#showPerspective(String, IWorkbenchWindow, IAdaptable)
*/
virtual IWorkbenchWindow::Pointer OpenWorkbenchWindow(const std::string& perspectiveId,
IAdaptable* input) = 0;
/**
* Creates and opens a new workbench window with one page. The perspective
* of the new page is defined by the default perspective ID. The new window
* and new page become active.
* <p>
* <b>Note:</b> The caller is responsible to ensure the action using this
* method will explicitly inform the user a new window will be opened.
* Otherwise, callers are strongly recommended to use the
* <code>openPerspective</code> APIs to programmatically show a
* perspective to avoid confusing the user.
* </p>
*
* @param input
* the page input, or <code>null</code> 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 new window and page could not be opened
*
* @see IWorkbench#showPerspective(String, IWorkbenchWindow, IAdaptable)
*/
virtual IWorkbenchWindow::Pointer OpenWorkbenchWindow(IAdaptable* input) = 0;
/**
* Shows the specified perspective to the user. The caller should use this
* method when the perspective to be shown is not dependent on the page's
* input. That is, the perspective can open in any page depending on user
* preferences.
* <p>
* The perspective may be shown in the specified window, in another existing
* window, or in a new window depending on user preferences. The exact
* policy is controlled by the workbench to ensure consistency to the user.
* The policy is subject to change. The current policy is as follows:
* <ul>
* <li>If the specified window has the requested perspective open, then the
* window is given focus and the perspective is shown. The page's input is
* ignored.</li>
* <li>If another window that has the workspace root as input and the
* requested perspective open and active, then the window is given focus.
* </li>
* <li>Otherwise the requested perspective is opened and shown in the
* specified window or in a new window depending on the current user
* preference for opening perspectives, and that window is given focus.
* </li>
* </ul>
* </p>
* <p>
* The workbench also defines a number of menu items to activate or open
* each registered perspective. A complete list of these perspectives is
* available from the perspective registry found on <code>IWorkbench</code>.
* </p>
*
* @param perspectiveId
* the perspective ID to show
* @param window
* the workbench window of the action calling this method.
* @return the workbench page that the perspective was shown
* @exception WorkbenchException
* if the perspective could not be shown
*
* @since 2.0
*/
virtual SmartPointer<IWorkbenchPage> ShowPerspective(const std::string& perspectiveId,
IWorkbenchWindow::Pointer window) = 0;
/**
* Shows the specified perspective to the user. The caller should use this
* method when the perspective to be shown is dependent on the page's input.
* That is, the perspective can only open in any page with the specified
* input.
* <p>
* The perspective may be shown in the specified window, in another existing
* window, or in a new window depending on user preferences. The exact
* policy is controlled by the workbench to ensure consistency to the user.
* The policy is subject to change. The current policy is as follows:
* <ul>
* <li>If the specified window has the requested perspective open and the
* same requested input, then the window is given focus and the perspective
* is shown.</li>
* <li>If another window has the requested input and the requested
* perspective open and active, then that window is given focus.</li>
* <li>If the specified window has the same requested input but not the
* requested perspective, then the window is given focus and the perspective
* is opened and shown on condition that the user preference is not to open
* perspectives in a new window.</li>
* <li>Otherwise the requested perspective is opened and shown in a new
* window, and the window is given focus.</li>
* </ul>
* </p>
* <p>
* The workbench also defines a number of menu items to activate or open
* each registered perspective. A complete list of these perspectives is
* available from the perspective registry found on <code>IWorkbench</code>.
* </p>
*
* @param perspectiveId
* the perspective ID to show
* @param window
* the workbench window of the action calling this method.
* @param input
* the page input, or <code>null</code> if there is no current
* input. This is used to seed the input for the page's views
* @return the workbench page that the perspective was shown
* @exception WorkbenchException
* if the perspective could not be shown
*
* @since 2.0
*/
virtual SmartPointer<IWorkbenchPage> ShowPerspective(const std::string& perspectiveId,
IWorkbenchWindow::Pointer window, IAdaptable* input) = 0;
/**
* Save all dirty editors in the workbench. Opens a dialog to prompt the
* user if <code>confirm</code> is true. Return true if successful. Return
* false if the user has canceled the command.
*
* @param confirm <code>true</code> to ask the user before saving unsaved
* changes (recommended), and <code>false</code> to save
* unsaved changes without asking
* @return <code>true</code> if the command succeeded, and
* <code>false</code> if the operation was canceled by the user or
* an error occurred while saving
*/
virtual bool SaveAllEditors(bool confirm) = 0;
/**
* Return the intro manager for this workbench.
*
* @return the intro manager for this workbench. Guaranteed not to be
* <code>null</code>.
*/
virtual IIntroManager* GetIntroManager() = 0;
/**
* Returns a boolean indicating whether the workbench is in the process of
* closing.
*
* @return <code>true</code> if the workbench is in the process of
* closing, <code>false</code> otherwise
* @since 3.1
*/
virtual bool IsClosing() = 0;
/**
* Applies changes of the current theme to the user interface.
*/
virtual void UpdateTheme() = 0;
};
}
#endif /*BERRYIWORKBENCH_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIWorkbenchListener.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/berryIWorkbenchListener.cpp
index 68819f1462..ed06f77e41 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIWorkbenchListener.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIWorkbenchListener.cpp
@@ -1,41 +1,41 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryIWorkbenchListener.h"
namespace berry {
void
IWorkbenchListener::Events
::AddListener(IWorkbenchListener::Pointer listener)
{
if (listener.IsNull()) return;
preShutdown += Delegate2(listener.GetPointer(), &IWorkbenchListener::PreShutdown);
postShutdown += Delegate1(listener.GetPointer(), &IWorkbenchListener::PostShutdown);
}
void
IWorkbenchListener::Events
::RemoveListener(IWorkbenchListener::Pointer listener)
{
if (listener.IsNull()) return;
preShutdown -= Delegate2(listener.GetPointer(), &IWorkbenchListener::PreShutdown);
postShutdown -= Delegate1(listener.GetPointer(), &IWorkbenchListener::PostShutdown);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIWorkbenchListener.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryIWorkbenchListener.h
index 80e13a4728..1624614bf6 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIWorkbenchListener.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIWorkbenchListener.h
@@ -1,101 +1,101 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIWORKBENCHLISTENER_H_
#define BERRYIWORKBENCHLISTENER_H_
#include <org_blueberry_ui_Export.h>
#include <berryMacros.h>
#include <berryObject.h>
#include <berryMessage.h>
namespace berry
{
struct IWorkbench;
/**
* Interface for listening to workbench lifecycle events.
* <p>
* This interface may be implemented by clients.
* </p>
*
* @see IWorkbench#addWorkbenchListener
* @see IWorkbench#removeWorkbenchListener
* @since 3.2
*/
struct BERRY_UI IWorkbenchListener : public virtual Object {
berryInterfaceMacro(IWorkbenchListener, berry);
struct Events {
typedef Message2<IWorkbench*, bool, bool> PreShutdownEvent;
typedef Message1<IWorkbench*> PostShutdownEvent;
PreShutdownEvent preShutdown;
PostShutdownEvent postShutdown;
void AddListener(IWorkbenchListener::Pointer listener);
void RemoveListener(IWorkbenchListener::Pointer listener);
private:
typedef MessageDelegate2<IWorkbenchListener, IWorkbench*, bool, bool> Delegate2;
typedef MessageDelegate1<IWorkbenchListener, IWorkbench*> Delegate1;
};
/**
* Notifies that the workbench is about to shut down.
* <p>
* This method is called immediately prior to workbench shutdown before any
* windows have been closed.
* </p>
* <p>
* The listener may veto a regular shutdown by returning <code>false</code>,
* although this will be ignored if the workbench is being forced to shut down.
* </p>
* <p>
* Since other workbench listeners may veto the shutdown, the listener should
* not dispose resources or do any other work during this notification that would
* leave the workbench in an inconsistent state.
* </p>
*
* @param workbench the workbench
* @param forced <code>true</code> if the workbench is being forced to shutdown,
* <code>false</code> for a regular close
* @return <code>true</code> to allow the workbench to proceed with shutdown,
* <code>false</code> to veto a non-forced shutdown
*/
virtual bool PreShutdown(IWorkbench* /*workbench*/, bool /*forced*/) { return true; };
/**
* Performs arbitrary finalization after the workbench stops running.
* <p>
* This method is called during workbench shutdown after all windows
* have been closed.
* </p>
*
* @param workbench the workbench
*/
virtual void PostShutdown(IWorkbench* /*workbench*/) {};
};
}
#endif /* BERRYIWORKBENCHLISTENER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIWorkbenchPage.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/berryIWorkbenchPage.cpp
index 324a2e7049..b18bd52f8e 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIWorkbenchPage.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIWorkbenchPage.cpp
@@ -1,59 +1,59 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryIWorkbenchPage.h"
namespace berry {
const std::string IWorkbenchPage::EDITOR_ID_ATTR = "org.blueberry.ui.editorID"; //$NON-NLS-1$
const std::string IWorkbenchPage::CHANGE_RESET = "reset"; //$NON-NLS-1$
const std::string IWorkbenchPage::CHANGE_RESET_COMPLETE = "resetComplete"; //$NON-NLS-1$
const std::string IWorkbenchPage::CHANGE_VIEW_SHOW = "viewShow"; //$NON-NLS-1$
const std::string IWorkbenchPage::CHANGE_VIEW_HIDE = "viewHide"; //$NON-NLS-1$
const std::string IWorkbenchPage::CHANGE_EDITOR_OPEN = "editorOpen"; //$NON-NLS-1$
const std::string IWorkbenchPage::CHANGE_EDITOR_CLOSE = "editorClose"; //$NON-NLS-1$
const std::string IWorkbenchPage::CHANGE_EDITOR_AREA_SHOW = "editorAreaShow"; //$NON-NLS-1$
const std::string IWorkbenchPage::CHANGE_EDITOR_AREA_HIDE = "editorAreaHide"; //$NON-NLS-1$
const std::string IWorkbenchPage::CHANGE_ACTION_SET_SHOW = "actionSetShow"; //$NON-NLS-1$
const std::string IWorkbenchPage::CHANGE_ACTION_SET_HIDE = "actionSetHide"; //$NON-NLS-1$
const int IWorkbenchPage::VIEW_ACTIVATE = 1;
const int IWorkbenchPage::VIEW_VISIBLE = 2;
const int IWorkbenchPage::VIEW_CREATE = 3;
const int IWorkbenchPage::MATCH_NONE = 0;
const int IWorkbenchPage::MATCH_INPUT = 1;
const int IWorkbenchPage::MATCH_ID = 2;
IWorkbenchPage::~IWorkbenchPage()
{
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIWorkbenchPage.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryIWorkbenchPage.h
index 23b49b463d..2f9a42a307 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIWorkbenchPage.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIWorkbenchPage.h
@@ -1,860 +1,860 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 <berryMacros.h>
#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 <vector>
#include <list>
/**
* \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.
* <p>
* 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.
* <p>
* The number of views and editors within a page is restricted to simplify part
* management for the user. In particular:
* <ul>
* <li>Unless a view explicitly allows for multiple instances in its plugin
* declaration there will be only one instance in a given workbench page.</li>
* <li>Only one editor can exist for each editor input within a page.
* <li>
* </ul>
* </p>
* <p>
* This interface is not intended to be implemented by clients.
* </p>
*
* @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 (<code>IMarker</code>)
* which identifies the preferred editor type to be opened when
* <code>openEditor</code> 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
* <code>IDE.EDITOR_ID_ATTR</code>.
*/
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 <code>VIEW_CREATE</code>.
*
* @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.
* <p>
* If the page has an open editor with unsaved content, the user will be
* given the opportunity to save it.
* </p>
*
* @return <code>true</code> if the page was successfully closed, and
* <code>false</code> if it is still open
*/
virtual bool Close() = 0;
/**
* Closes all of the editors belonging to this workbench page.
* <p>
* If the page has open editors with unsaved content and <code>save</code>
* is <code>true</code>, the user will be given the opportunity to save
* them.
* </p>
*
* @param save
*
* @return <code>true</code> if all editors were successfully closed, and
* <code>false</code> if at least one is still open
*/
virtual bool CloseAllEditors(bool save) = 0;
/**
* Closes the given <code>Array</code> of editor references. The editors
* must belong to this workbench page.
* <p>
* If any of the editors have unsaved content and <code>save</code> is
* <code>true</code>, the user will be given the opportunity to save
* them.
* </p>
*
* @param editorRefs
* the editors to close
* @param save
* <code>true</code> to save the editor contents if required
* (recommended), and <code>false</code> to discard any unsaved
* changes
* @return <code>true</code> if the editors were successfully closed, and
* <code>false</code> if the editors are still open
* @since 3.0
*/
virtual bool CloseEditors(const std::list<IEditorReference::Pointer>& editorRefs, bool save) = 0;
/**
* Closes the given editor. The editor must belong to this workbench page.
* <p>
* If the editor has unsaved content and <code>save</code> is
* <code>true</code>, the user will be given the opportunity to save it.
* </p>
*
* @param editor
* the editor to close
* @param save
* <code>true</code> to save the editor contents if required
* (recommended), and <code>false</code> to discard any unsaved
* changes
* @return <code>true</code> if the editor was successfully closed, and
* <code>false</code> 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 <code>null</code> 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 <code>null</code> 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 <code>null</code> for no
* secondary id
* @return the view reference, or <code>null</code> 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.
* <p>
* 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.
* </p>
*
* @return the active editor, or <code>null</code> 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 <code>input</code>
*/
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 <code>null</code> if MATCH_INPUT is not
* specified in matchFlags
* @param editorId
* the editor id, or <code>null</code> 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<IEditorReference::Pointer> FindEditors(IEditorInput::Pointer input, const std::string& editorId,
int matchFlags) = 0;
/**
* Returns a list of the editors open in this page.
* <p>
* Note that each page has its own editors; editors are never shared between
* pages.
* </p>
*
* @return a list of open editors
*
* @deprecated use #getEditorReferences() instead
*/
virtual std::vector<IEditorPart::Pointer> GetEditors() = 0;
/**
* Returns an array of references to open editors in this page.
* <p>
* Note that each page has its own editors; editors are never shared between
* pages.
* </p>
*
* @return a list of open editors
*/
virtual std::list<IEditorReference::Pointer> GetEditorReferences() = 0;
/**
* Returns a list of dirty editors in this page.
*
* @return a list of dirty editors
*/
virtual std::vector<IEditorPart::Pointer> GetDirtyEditors() = 0;
/**
* Returns the input for this page.
*
* @return the input for this page, or <code>null</code> 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
* <code>null</code> if there is no current perspective.
*
* @return the current perspective descriptor or <code>null</code>
* @see #setPerspective
* @see #savePerspective
*/
virtual IPerspectiveDescriptor::Pointer GetPerspective() = 0;
/**
* Returns a list of the reference to views visible on this page.
* <p>
* Note that each page has its own views; views are never shared between
* pages.
* </p>
*
* @return a list of references to visible views
*/
virtual std::vector<IViewReference::Pointer> GetViewReferences() = 0;
/**
* Returns a list of the views visible on this page.
* <p>
* Note that each page has its own views; views are never shared between
* pages.
* </p>
*
* @return a list of visible views
*
* @deprecated use #getViewReferences() instead.
*/
virtual std::vector<IViewPart::Pointer> 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 whether the specified part is visible.
*
* @param part
* the part to test
* @return boolean <code>true</code> if part is visible
*/
virtual bool IsPartVisible(IWorkbenchPart::Pointer part) = 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.
* <p>
* 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
*
* <pre>
* input1.equals(input2) == true
* </pre>.
* </p>
* <p>
* The editor type is determined by mapping <code>editorId</code> 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.
* </p>
*
* @param input
* the editor input
* @param editorId
* the id of the editor extension to use
* @return an open and active editor, or <code>null</code> 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.
* <p>
* 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
* <code>Object.equals(Object)<code>
* and <code>IEditorInput</code>. If <code>activate == true</code> the editor
* will be activated.
* </p><p>
* The editor type is determined by mapping <code>editorId</code> 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.
* </p>
*
* @param input the editor input
* @param editorId the id of the editor extension to use
* @param activate if <code>true</code> the editor will be activated
* @return an open editor, or <code>null</code> 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.
* <p>
* 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
* <code>Object.equals(Object)<code>
* and <code>IEditorInput</code>. If <code>activate == true</code> the editor
* will be activated.
* </p><p>
* The editor type is determined by mapping <code>editorId</code> 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.
* </p>
*
* @param input the editor input
* @param editorId the id of the editor extension to use
* @param activate if <code>true</code> 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 <code>null</code> 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.
* <p>
* For more information on perspective change see
* <code>setPerspective()</code>.
* </p>
*/
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.
* <p>
* If <code>confirm</code> is <code>true</code> the user is prompted to
* confirm the command.
* </p>
* <p>
* Note that as of 3.2, this method also saves views that implement
* ISaveablePart and are dirty.
* </p>
*
* @param confirm <code>true</code> to ask the user before saving unsaved
* changes (recommended), and <code>false</code> to save
* unsaved changes without asking
* @return <code>true</code> if the command succeeded, and
* <code>false</code> 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.
* <p>
* If <code>confirm</code> is <code>true</code> the user is prompted to
* confirm the command. Otherwise, the save happens without prompt.
* </p>
* <p>
* The editor must belong to this workbench page.
* </p>
*
* @param editor
* the editor to close
* @param confirm
* <code>true</code> to ask the user before saving unsaved
* changes (recommended), and <code>false</code> to save
* unsaved changes without asking
* @return <code>true</code> if the command succeeded, and
* <code>false</code> 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.
* <p>
* 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.
* </p>
* <p>
* 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.
* </p>
* <p>
* 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.
* </p>
* <p>
* The open editors are not modified by this method.
* </p>
*
* @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
* <code>VIEW_ACTIVATE</code> is supplied, the view is focus. If
* <code>VIEW_VISIBLE</code> is supplied, then it is made visible but not
* given focus. Finally, if <code>VIEW_CREATE</code> 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.
* <p>
* 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.
* </p>
*
* @param viewId
* the id of the view extension to use
* @param secondaryId
* the secondary id to use, or <code>null</code> 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 <code>true</code> 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<std::string> 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<std::string> 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<IPerspectiveDescriptor::Pointer> 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<IPerspectiveDescriptor::Pointer> GetSortedPerspectives() = 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 <code>saveParts</code>
* is <code>true</code>, the user will be prompted to save any unsaved
* changes for parts that are being closed. The page itself is closed if
* <code>closePage</code> is <code>true</code>.
*
* @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 <code>saveEditors</code> is
* <code>true</code>. The page itself is closed if <code>closePage</code>
* is <code>true</code>.
*
* @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 <code>null</code>.
* @return The reference for the given part, or <code>null</code> 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/berryIWorkbenchPart.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryIWorkbenchPart.h
index ce4313b6ad..dfb7daf41a 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIWorkbenchPart.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIWorkbenchPart.h
@@ -1,271 +1,271 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 IWORKBENCHPART_H_
#define IWORKBENCHPART_H_
#include <org_blueberry_ui_Export.h>
#include "berryIPropertyChangeListener.h"
#include <berryMacros.h>
#include <map>
namespace berry {
struct IWorkbenchPartSite;
/**
* \ingroup org_blueberry_ui
*
* A workbench part is a visual component within a workbench page. There
* are two subtypes: view and editor, as defined by <code>IViewPart</code> and
* <code>IEditorPart</code>.
* <p>
* A view is typically used to navigate a hierarchy of information (like the
* workspace), open an editor, or display properties for the active editor.
* Modifications made in a view are saved immediately.
* </p><p>
* An editor is typically used to edit or browse a document or input object.
* The input is identified using an <code>IEditorInput</code>. Modifications made
* in an editor part follow an open-save-close lifecycle model.
* </p><p>
* This interface may be implemented directly. For convenience, a base
* implementation is defined in <code>WorkbenchPart</code>.
* </p><p>
* The lifecycle of a workbench part is as follows:
* <ul>
* <li>When a part extension is created:
* <ul>
* <li>instantiate the part</li>
* <li>create a part site</li>
* <li>call <code>part.init(site)</code></li>
* </ul>
* <li>When a part becomes visible in the workbench:
* <ul>
* <li>add part to presentation by calling
* <code>part.createControl(parent)</code> to create actual widgets</li>
* <li>fire <code>partOpened</code> event to all listeners</li>
* </ul>
* </li>
* <li>When a part is activated or gets focus:
* <ul>
* <li>call <code>part.setFocus()</code></li>
* <li>fire <code>partActivated</code> event to all listeners</li>
* </ul>
* </li>
* <li>When a part is closed:
* <ul>
* <li>if save is needed, do save; if it fails or is canceled return</li>
* <li>if part is active, deactivate part</li>
* <li>fire <code>partClosed</code> event to all listeners</li>
* <li>remove part from presentation; part controls are disposed as part
* of the SWT widget tree
* <li>call <code>part.dispose()</code></li>
* </ul>
* </li>
* </ul>
* </p>
* <p>
* After <code>createPartControl</code> has been called, the implementor may
* safely reference the controls created. When the part is closed
* these controls will be disposed as part of an SWT composite. This
* occurs before the <code>IWorkbenchPart.dispose</code> method is called.
* If there is a need to free SWT resources the part should define a dispose
* listener for its own control and free those resources from the dispose
* listener. If the part invokes any method on the disposed SWT controls
* after this point an <code>SWTError</code> will be thrown.
* </p>
* <p>
* The last method called on <code>IWorkbenchPart</code> is <code>dispose</code>.
* This signals the end of the part lifecycle.
* </p>
* <p>
* An important point to note about this lifecycle is that following
* a call to init, createControl may never be called. Thus in the dispose
* method, implementors must not assume controls were created.
* </p>
* <p>
* Workbench parts implement the <code>IAdaptable</code> interface; extensions
* are managed by the platform's adapter manager.
* </p>
*
* @see IViewPart
* @see IEditorPart
*/
struct BERRY_UI IWorkbenchPart : public virtual Object { // public IAdaptable {
berryInterfaceMacro(IWorkbenchPart, berry)
virtual ~IWorkbenchPart();
/**
* The property id for <code>getTitle</code>, <code>getTitleImage</code>
* and <code>getTitleToolTip</code>.
*/
//static const int PROP_TITLE = IWorkbenchPartConstants.PROP_TITLE;
/**
* Adds a listener for changes to properties of this workbench part.
* Has no effect if an identical listener is already registered.
* <p>
* The property ids are defined in {@link IWorkbenchPartConstants}.
* </p>
*
* @param listener a property listener
*/
virtual void AddPropertyListener(IPropertyChangeListener::Pointer listener) = 0;
/**
* Creates the controls for this workbench part.
* <p>
* Clients should not call this method (the workbench calls this method when
* it needs to, which may be never).
* </p>
* <p>
* For implementors this is a multi-step process:
* <ol>
* <li>Create one or more controls within the parent.</li>
* <li>Set the parent layout as needed.</li>
* <li>Register any global actions with the site's <code>IActionBars</code>.</li>
* <li>Register any context menus with the site.</li>
* <li>Register a selection provider with the site, to make it available to
* the workbench's <code>ISelectionService</code> (optional). </li>
* </ol>
* </p>
*
* @param parent the parent control
*/
virtual void CreatePartControl(void* parent) = 0;
/**
* Returns the site for this workbench part. The site can be
* <code>null</code> while the workbench part is being initialized. After
* the initialization is complete, this value must be non-<code>null</code>
* for the remainder of the part's life cycle.
*
* @return The part site; this value may be <code>null</code> if the part
* has not yet been initialized
*/
virtual SmartPointer<IWorkbenchPartSite> GetSite() const = 0;
/**
* Returns the name of this part. If this value changes the part must fire a
* property listener event with {@link IWorkbenchPartConstants#PROP_PART_NAME}.
*
* @return the name of this view, or the empty string if the name is being managed
* by the workbench (not <code>null</code>)
*/
virtual std::string GetPartName() const = 0;
/**
* Returns the content description of this part. The content description is an optional
* user-readable string that describes what is currently being displayed in the part.
* By default, the workbench will display the content description in a line
* near the top of the view or editor.
* An empty string indicates no content description
* text. If this value changes the part must fire a property listener event
* with {@link IWorkbenchPartConstants#PROP_CONTENT_DESCRIPTION}.
*
* @return the content description of this part (not <code>null</code>)
*/
virtual std::string GetContentDescription() const = 0;
/**
* Returns the title image of this workbench part. If this value changes
* the part must fire a property listener event with
* <code>PROP_TITLE</code>.
* <p>
* The title image is usually used to populate the title bar of this part's
* visual container. Since this image is managed by the part itself, callers
* must <b>not</b> dispose the returned image.
* </p>
*
* @return the title image
*/
virtual void* GetTitleImage() const = 0;
/**
* Returns the title tool tip text of this workbench part.
* An empty string result indicates no tool tip.
* If this value changes the part must fire a property listener event with
* <code>PROP_TITLE</code>.
* <p>
* The tool tip text is used to populate the title bar of this part's
* visual container.
* </p>
*
* @return the workbench part title tool tip (not <code>null</code>)
*/
virtual std::string GetTitleToolTip() const = 0;
/**
* Removes the given property listener from this workbench part.
* Has no affect if an identical listener is not registered.
*
* @param listener a property listener
*/
virtual void RemovePropertyListener(IPropertyChangeListener::Pointer listener) = 0;
/**
* Return the value for the arbitrary property key, or <code>null</code>.
*
* @param key
* the arbitrary property. Must not be <code>null</code>.
* @return the property value, or <code>null</code>.
*/
virtual std::string GetPartProperty(const std::string& key) const = 0;
/**
* Set an arbitrary property on the part. It is the implementor's
* responsibility to fire the corresponding PropertyChangeEvent.
* <p>
* A default implementation has been added to WorkbenchPart.
* </p>
*
* @param key
* the arbitrary property. Must not be <code>null</code>.
* @param value
* the property value. A <code>null</code> value will remove
* that property.
*/
virtual void SetPartProperty(const std::string& key, const std::string& value) = 0;
/**
* Return an unmodifiable map of the arbitrary properties. This method can
* be used to save the properties during workbench save/restore.
*
* @return A Map of the properties. Must not be <code>null</code>.
*/
virtual const std::map<std::string, std::string>& GetPartProperties() const = 0;
/**
* Asks this part to take focus within the workbench.
* <p>
* Clients should not call this method (the workbench calls this method at
* appropriate times). To have the workbench activate a part, use
* <code>IWorkbenchPage.activate(IWorkbenchPart) instead</code>.
* </p>
*/
virtual void SetFocus() = 0;
};
} // namespace berry
#endif /*IWORKBENCHPART_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIWorkbenchPartDescriptor.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryIWorkbenchPartDescriptor.h
index 2ba8e5fdb9..af8bb394a3 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIWorkbenchPartDescriptor.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIWorkbenchPartDescriptor.h
@@ -1,72 +1,72 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIWORKBENCHPARTDESCRIPTOR_H_
#define BERRYIWORKBENCHPARTDESCRIPTOR_H_
#include <org_blueberry_ui_Export.h>
#include <berryMacros.h>
#include <berryObject.h>
#include "berryImageDescriptor.h"
#include <string>
namespace berry
{
/**
* \ingroup org_blueberry_ui
*
* Description of a workbench part. The part descriptor contains
* the information needed to create part instances.
* <p>
* This interface is not intended to be implemented by clients.
* </p>
*/
struct BERRY_UI IWorkbenchPartDescriptor : public Object
{
berryInterfaceMacro(IWorkbenchPartDescriptor, berry);
/**
* Returns the part id.
*
* @return the id of the part
*/
virtual std::string GetId() const = 0;
/**
* Returns the descriptor of the image for this part.
*
* @return the descriptor of the image to display next to this part
*/
virtual SmartPointer<ImageDescriptor> GetImageDescriptor() const = 0;
/**
* Returns the label to show for this part.
*
* @return the part label
*/
virtual std::string GetLabel() const = 0;
virtual ~IWorkbenchPartDescriptor();
};
} // namespace berry
#endif /*BERRYIWORKBENCHPARTDESCRIPTOR_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIWorkbenchPartReference.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryIWorkbenchPartReference.h
index a7eb1d89ad..ce15c606f9 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIWorkbenchPartReference.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIWorkbenchPartReference.h
@@ -1,151 +1,151 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIWORKBENCHPARTREFERENCE_H_
#define BERRYIWORKBENCHPARTREFERENCE_H_
#include <berryMacros.h>
#include <org_blueberry_ui_Export.h>
#include "berryIPropertyChangeListener.h"
namespace berry {
struct IWorkbenchPart;
struct IWorkbenchPage;
/**
* \ingroup org_blueberry_ui
*
* Implements a reference to a IWorkbenchPart.
* The IWorkbenchPart will not be instanciated until the part
* becomes visible or the API getPart is sent with true;
* <p>
* This interface is not intended to be implemented by clients.
* </p>
*/
struct BERRY_UI IWorkbenchPartReference : public Object {
berryInterfaceMacro(IWorkbenchPartReference, berry);
~IWorkbenchPartReference();
/**
* Returns the IWorkbenchPart referenced by this object.
* Returns <code>null</code> if the editors was not instantiated or
* it failed to be restored. Tries to restore the editor
* if <code>restore</code> is true.
*/
virtual SmartPointer<IWorkbenchPart> GetPart(bool restore) = 0;
/**
* @see IWorkbenchPart#getTitleImage
*/
virtual void* GetTitleImage() = 0;
/**
* @see IWorkbenchPart#getTitleToolTip
*/
virtual std::string GetTitleToolTip() const = 0;
/**
* @see IWorkbenchPartSite#getId
*/
virtual std::string GetId() const = 0;
/**
* @see IWorkbenchPart#addPropertyListener
*/
virtual void AddPropertyListener(IPropertyChangeListener::Pointer listener) = 0;
/**
* @see IWorkbenchPart#removePropertyListener
*/
virtual void RemovePropertyListener(IPropertyChangeListener::Pointer listener) = 0;
/**
* Returns the workbench page that contains this part
*/
virtual SmartPointer<IWorkbenchPage> GetPage() const = 0;
/**
* Returns the name of the part, as it should be shown in tabs.
*
* @return the part name
*
* @since 3.0
*/
virtual std::string GetPartName() const = 0;
/**
* Returns the content description for the part (or the empty string if none)
*
* @return the content description for the part
*
* @since 3.0
*/
virtual std::string GetContentDescription() const = 0;
/**
* Returns true if the part is pinned otherwise returns false.
*/
virtual bool IsPinned() const = 0;
/**
* Returns whether the part is dirty (i.e. has unsaved changes).
*
* @return <code>true</code> if the part is dirty, <code>false</code> otherwise
*
* @since 3.2 (previously existed on IEditorReference)
*/
virtual bool IsDirty() const = 0;
/**
* Return an arbitrary property from the reference. If the part has been
* instantiated, it just delegates to the part. If not, then it looks in its
* own cache of properties. If the property is not available or the part has
* never been instantiated, it can return <code>null</code>.
*
* @param key
* The property to return. Must not be <code>null</code>.
* @return The String property, or <code>null</code>.
* @since 3.3
*/
virtual std::string GetPartProperty(const std::string& key) const = 0;
/**
* Add a listener for changes in the arbitrary properties set.
*
* @param listener
* Must not be <code>null</code>.
* @since 3.3
*/
//virtual void addPartPropertyListener(IPropertyChangeListener listener) = 0;
/**
* Remove a listener for changes in the arbitrary properties set.
*
* @param listener
* Must not be <code>null</code>.
* @since 3.3
*/
//virtual void removePartPropertyListener(IPropertyChangeListener listener) = 0;
};
} // namespace berry
#endif /*BERRYIWORKBENCHPARTREFERENCE_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIWorkbenchPartSite.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryIWorkbenchPartSite.h
index 88c21286a9..933d47ea52 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIWorkbenchPartSite.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIWorkbenchPartSite.h
@@ -1,85 +1,85 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 IWORKBENCHPARTSITE_H_
#define IWORKBENCHPARTSITE_H_
#include "berryIWorkbenchSite.h"
namespace berry {
struct IWorkbenchPart;
/**
* \ingroup org_blueberry_ui
*
* The primary interface between a workbench part and the workbench.
* <p>
* This interface is not intended to be implemented or extended by clients.
* </p>
* @noimplement This interface is not intended to be implemented by clients.
*/
struct BERRY_UI IWorkbenchPartSite : public IWorkbenchSite
{
berryInterfaceMacro(IWorkbenchPartSite, berry);
~IWorkbenchPartSite();
/**
* Returns the part registry extension id for this workbench site's part.
* <p>
* The name comes from the <code>id</code> attribute in the configuration
* element.
* </p>
*
* @return the registry extension id
*/
virtual std::string GetId() = 0;
/**
* Returns the part associated with this site
*
* @return the part associated with this site
*/
virtual SmartPointer<IWorkbenchPart> GetPart() = 0;
/**
* Returns the unique identifier of the plug-in that defines this workbench
* site's part.
*
* @return the unique identifier of the declaring plug-in
*/
virtual std::string GetPluginId() = 0;
/**
* Returns the registered name for this workbench site's part.
* <p>
* The name comes from the <code>name</code> attribute in the configuration
* element.
* </p>
*
* @return the part name
*/
virtual std::string GetRegisteredName() = 0;
};
} // namespace berry
#endif /*IWORKBENCHPARTSITE_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIWorkbenchSite.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryIWorkbenchSite.h
index f086ed141d..f29a571b5c 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIWorkbenchSite.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIWorkbenchSite.h
@@ -1,109 +1,109 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIWORKBENCHSITE_H_
#define BERRYIWORKBENCHSITE_H_
#include <berryMacros.h>
#include <org_blueberry_ui_Export.h>
#include "services/berryIServiceLocator.h"
namespace berry {
struct IWorkbenchPage;
struct ISelectionProvider;
struct IWorkbenchWindow;
class Shell;
/**
* \ingroup org_blueberry_ui
*
* The common interface between the workbench and its parts, including pages
* within parts.
* <p>
* The workbench site 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 site is disposed. The supported
* services are:
* </p>
* <ul>
* <li>{@link ICommandService}</li>
* <li>{@link IContextService}</li>
* <li>{@link IHandlerService}</li>
* <li>{@link IBindingService}. Resources allocated through this service will
* not be cleaned up until the workbench shuts down.</li>
* </ul>
* <p>
* This interface is not intended to be implemented or extended by clients.
* </p>
*
* @see org.blueberry.ui.IWorkbenchPartSite
* @see org.blueberry.ui.part.IPageSite
* @since 2.0
* @noimplement This interface is not intended to be implemented by clients.
*/
struct BERRY_UI IWorkbenchSite : public IServiceLocator { // IAdaptable, IShellProvider {
berryInterfaceMacro(IWorkbenchSite, berry);
virtual ~IWorkbenchSite();
/**
* Returns the page containing this workbench site.
*
* @return the page containing this workbench site
*/
virtual SmartPointer<IWorkbenchPage> GetPage() = 0;
/**
* Returns the selection provider for this workbench site.
*
* @return the selection provider, or <code>null</code> if none
*/
virtual SmartPointer<ISelectionProvider> GetSelectionProvider() = 0;
/**
* Returns the shell for this workbench site. Not intended to be called from
* outside the UI thread. Clients should call IWorkbench.getDisplay() to
* gain access to the display rather than calling getShell().getDisplay().
*
* @return the shell for this workbench site
*/
virtual SmartPointer<Shell> GetShell() = 0;
/**
* Returns the workbench window containing this workbench site.
*
* @return the workbench window containing this workbench site
*/
virtual SmartPointer<IWorkbenchWindow> GetWorkbenchWindow() = 0;
/**
* Sets the selection provider for this workbench site.
*
* @param provider
* the selection provider, or <code>null</code> to clear it
*/
virtual void SetSelectionProvider(SmartPointer<ISelectionProvider> provider) = 0;
};
}
#endif /*BERRYIWORKBENCHSITE_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIWorkbenchWindow.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryIWorkbenchWindow.h
index 59547e4de8..871f02e037 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIWorkbenchWindow.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIWorkbenchWindow.h
@@ -1,206 +1,206 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 <berryMacros.h>
#include <berryIAdaptable.h>
#include <org_blueberry_ui_Export.h>
#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.
* <p>
* 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.
* </p>
* <p>
* 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:
* </p>
* <ul>
* <li>{@link ICommandService}</li>
* <li>{@link IContextService}</li>
* <li>{@link IHandlerService}</li>
* <li>{@link IBindingService}. Resources allocated through this service will
* not be cleaned up until the workbench shuts down.</li>
* </ul>
* <p>
* This interface is not intended to be implemented by clients.
* </p>
*
* @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.
* <p>
* If the window has an open editor with unsaved content, the user will be
* given the opportunity to save it.
* </p>
*
* @return <code>true</code> if the window was successfully closed, and
* <code>false</code> if it is still open
*/
virtual bool Close() = 0;
/**
* Returns the currently active page for this workbench window.
*
* @return the active page, or <code>null</code> if none
*/
virtual SmartPointer<IWorkbenchPage> GetActivePage() = 0;
/**
* Sets or clears the currently active page for this workbench window.
*
* @param page
* the new active page
*/
virtual void SetActivePage(SmartPointer<IWorkbenchPage> 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 <code>null</code>
* 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).
* <p>
* 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.
* </p>
*
* @param menuId
* the menu id
* @return <code>true</code> if the specified menu is an application
* menu, and <code>false</code> 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.
* <p>
* <b>Note:</b> 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 <code>IWorkbench.showPerspective</code> APIs to
* programmatically show a perspective.
* </p>
*
* @param perspectiveId
* the perspective id for the window's initial page
* @param input
* the page input, or <code>null</code> 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<IWorkbenchPage> 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.
* <p>
* <b>Note:</b> 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 <code>IWorkbench.showPerspective</code> APIs to
* programmatically show a perspective.
* </p>
*
* @param input
* the page input, or <code>null</code> 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<IWorkbenchPage> OpenPage(IAdaptable* input) = 0;
virtual ~IWorkbenchWindow();
};
}
#endif /*BERRYIWORKBENCHWINDOW_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryImageDescriptor.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/berryImageDescriptor.cpp
index 8550767df8..371c100218 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryImageDescriptor.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryImageDescriptor.cpp
@@ -1,43 +1,43 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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/berryImageTweaklet.h"
#include "berryImageDescriptor.h"
namespace berry {
ImageDescriptor::Pointer ImageDescriptor::CreateFromFile(const std::string& filename, const std::string& pluginid)
{
return Tweaklets::Get(ImageTweaklet::KEY)->CreateFromFile(filename, pluginid);
}
ImageDescriptor::Pointer ImageDescriptor::CreateFromImage(void* img)
{
return Tweaklets::Get(ImageTweaklet::KEY)->CreateFromImage(img);
}
ImageDescriptor::Pointer ImageDescriptor::GetMissingImageDescriptor()
{
return Tweaklets::Get(ImageTweaklet::KEY)->GetMissingImageDescriptor();
}
ImageDescriptor::ImageDescriptor()
{
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryImageDescriptor.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryImageDescriptor.h
index e1da350d87..b158061b64 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryImageDescriptor.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryImageDescriptor.h
@@ -1,106 +1,106 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIIMAGEDESCRIPTOR_H_
#define BERRYIIMAGEDESCRIPTOR_H_
#include <berryObject.h>
#include <berryMacros.h>
#include <org_blueberry_ui_Export.h>
namespace berry {
/**
* An image descriptor is an object that knows how to create
* an image. Caching of images and resource management must be done
* in GUI toolkit specific classes. An image descriptor
* is intended to be a lightweight representation of an image.
* <p>
* To get an Image from an ImageDescriptor, the method
* CreateImage() must be called. When the caller is done with an image obtained from CreateImage,
* they must call DestroyImage() to give the GUI toolkit a chance to cleanup resources.
* </p>
*
* @see org.eclipse.swt.graphics.Image
*/
struct BERRY_UI ImageDescriptor : public Object {
berryObjectMacro(ImageDescriptor);
/**
* Returns a possibly cached image for this image descriptor. The
* returned image must be explicitly disposed by calling DestroyImage().
* The image will not be automatically garbage collected. In the event
* of an error, a default image is returned if
* <code>returnMissingImageOnError</code> is true, otherwise
* <code>0</code> is returned.
* <p>
* Note: Even if <code>returnMissingImageOnError</code> is true, it is
* still possible for this method to return <code>null</code> in extreme
* cases, for example if the underlying OS/GUI toolkit runs out of image handles.
* </p>
*
* @param returnMissingImageOnError
* flag that determines if a default image is returned on error
* @return the image or <code>0</code> if the image could not be
* created
*/
virtual void* CreateImage(bool returnMissingImageOnError = true) = 0;
virtual void DestroyImage(void* img) = 0;
virtual bool operator==(const Object* o) const = 0;
/**
* Creates and returns a new image descriptor from a file. If you specify <code>pluginid</code>, the
* given <code>filename</code> is interpreted relative to the plugins base directory. If no <code>pluginid</code>
* is given and <code>filename</code> is a relative path, the result is undefined.
*
* @param filename the file name.
* @param pluginid the plugin id of the plugin which contains the file
* @return a new image descriptor
*/
static Pointer CreateFromFile(const std::string& filename, const std::string& pluginid = "");
/**
* Creates and returns a new image descriptor for the given image. Note
* that disposing the original Image will cause the descriptor to become invalid.
*
* @since 3.1
*
* @param img image to create
* @return a newly created image descriptor
*/
static Pointer CreateFromImage(void* img);
/**
* Returns the shared image descriptor for a missing image.
*
* @return the missing image descriptor
*/
static Pointer GetMissingImageDescriptor();
protected:
ImageDescriptor();
};
}
#endif /* BERRYIIMAGEDESCRIPTOR_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryPlatformUI.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/berryPlatformUI.cpp
index 74f89cbd0e..8b3660da8b 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryPlatformUI.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryPlatformUI.cpp
@@ -1,96 +1,96 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryPlatformUI.h"
#include "berryPlatform.h"
#include "service/berryIConfigurationElement.h"
#include "service/berryIExtensionPointService.h"
#include "internal/berryWorkbench.h"
#include "berryUIException.h"
#include <vector>
namespace berry {
const std::string PlatformUI::PLUGIN_ID = "org.blueberry.ui";
const std::string PlatformUI::XP_WORKBENCH = PlatformUI::PLUGIN_ID + ".workbench";
const std::string PlatformUI::XP_VIEWS = PlatformUI::PLUGIN_ID + ".views";
const int PlatformUI::RETURN_OK = 0;
const int PlatformUI::RETURN_RESTART = 1;
const int PlatformUI::RETURN_UNSTARTABLE = 2;
const int PlatformUI::RETURN_EMERGENCY_CLOSE = 3;
int
PlatformUI::CreateAndRunWorkbench(Display* display, WorkbenchAdvisor* advisor)
{
// std::vector<IConfigurationElement::Pointer> extensions(
// Platform::GetExtensionPointService()->GetConfigurationElementsFor(PlatformUI::XP_WORKBENCH));
//
// for (unsigned int i = 0; i < extensions.size(); ++i)
// {
// if (extensions[i]->GetName() == "workbench")
// {
//
// m_Workbench = extensions[i]->CreateExecutableExtension<berry::Workbench>("berryWorkbench", "class");
// m_Workbench->InternalInit(advisor);
// return m_Workbench->RunUI();
// }
// }
//
// throw WorkbenchException("No registered workbench extension found");
return Workbench::CreateAndRunWorkbench(display, advisor);
}
Display* PlatformUI::CreateDisplay()
{
return Workbench::CreateDisplay();
}
IWorkbench*
PlatformUI::GetWorkbench()
{
if (Workbench::GetInstance() == 0)
{
// app forgot to call createAndRunWorkbench beforehand
throw Poco::IllegalStateException("Workbench has not been created yet.");
}
return Workbench::GetInstance();
}
bool
PlatformUI::IsWorkbenchRunning()
{
return Workbench::GetInstance() != 0
&& Workbench::GetInstance()->IsRunning();
}
TestableObject::Pointer
PlatformUI::GetTestableObject()
{
return Workbench::GetWorkbenchTestable();
}
PlatformUI::PlatformUI()
{
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryPlatformUI.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryPlatformUI.h
index cefdbb52f6..0b00006d10 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryPlatformUI.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryPlatformUI.h
@@ -1,174 +1,174 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYPLATFORMUI_H_
#define BERRYPLATFORMUI_H_
#include <org_blueberry_ui_Export.h>
#include "berryDisplay.h"
#include "application/berryWorkbenchAdvisor.h"
#include "testing/berryTestableObject.h"
namespace berry {
/**
* \ingroup org_blueberry_ui
*
* The central class for access to the BlueBerry Platform User Interface.
* This class cannot be instantiated; all functionality is provided by
* static methods.
*
* Features provided:
* <ul>
* <li>creation of the workbench.</li>
* <li>access to the workbench.</li>
* </ul>
* <p>
*
* @see IWorkbench
*/
class BERRY_UI PlatformUI
{
public:
static const std::string PLUGIN_ID;
static const std::string XP_WORKBENCH;
static const std::string XP_VIEWS;
/**
* Return code (value 0) indicating that the workbench terminated normally.
*
* @see #CreateAndRunWorkbench
* @since 3.0
*/
static const int RETURN_OK;
/**
* Return code (value 1) indicating that the workbench was terminated with
* a call to <code>IWorkbench.restart</code>.
*
* @see #CreateAndRunWorkbench
* @see IWorkbench#Restart
* @since 3.0
*/
static const int RETURN_RESTART;
/**
* Return code (value 2) indicating that the workbench failed to start.
*
* @see #CreateAndRunWorkbench
* @see IWorkbench#Restart
* @since 3.0
*/
static const int RETURN_UNSTARTABLE;
/**
* Return code (value 3) indicating that the workbench was terminated with
* a call to IWorkbenchConfigurer#emergencyClose.
*
* @see #CreateAndRunWorkbench
* @since 3.0
*/
static const int RETURN_EMERGENCY_CLOSE;
/**
* Creates the workbench and associates it with the given display and workbench
* advisor, and runs the workbench UI. This entails processing and dispatching
* events until the workbench is closed or restarted.
* <p>
* This method is intended to be called by the main class (the "application").
* Fails if the workbench UI has already been created.
* </p>
* <p>
* Use {@link #createDisplay createDisplay} to create the display to pass in.
* </p>
* <p>
* Note that this method is intended to be called by the application
* (<code>org.blueberry.core.boot.IPlatformRunnable</code>). It must be
* called exactly once, and early on before anyone else asks
* <code>getWorkbench()</code> for the workbench.
* </p>
*
* @param display the display to be used for all UI interactions with the workbench
* @param advisor the application-specific advisor that configures and
* specializes the workbench
* @return return code {@link #RETURN_OK RETURN_OK} for normal exit;
* {@link #RETURN_RESTART RETURN_RESTART} if the workbench was terminated
* with a call to {@link IWorkbench#restart IWorkbench.restart};
* {@link #RETURN_UNSTARTABLE RETURN_UNSTARTABLE} if the workbench could
* not be started;
* {@link #RETURN_EMERGENCY_CLOSE RETURN_EMERGENCY_CLOSE} if the UI quit
* because of an emergency; other values reserved for future use
*/
static int CreateAndRunWorkbench(Display* display, WorkbenchAdvisor* advisor);
/**
* Creates the <code>Display</code> to be used by the workbench.
* It is the caller's responsibility to dispose the resulting <code>Display</code>,
* not the workbench's.
*
* @return the display
*/
static Display* CreateDisplay();
/**
* Returns the workbench. Fails if the workbench has not been created yet.
*
* @return the workbench. A raw pointer is returned because you normally
* should not hold a smart pointer to it (and possibly create reference
* cycles)
*/
static IWorkbench* GetWorkbench();
/**
* Returns whether {@link #createAndRunWorkbench createAndRunWorkbench} has
* been called to create the workbench, and the workbench has yet to
* terminate.
* <p>
* Note that this method may return <code>true</code> while the workbench
* is still being initialized, so it may not be safe to call workbench API
* methods even if this method returns true. See bug 49316 for details.
* </p>
*
* @return <code>true</code> if the workbench has been created and is
* still running, and <code>false</code> if the workbench has not
* yet been created or has completed
* @since 3.0
*/
static bool IsWorkbenchRunning();
/**
* Returns the testable object facade, for use by the test harness.
* <p>
* IMPORTANT: This method is only for use by the test harness.
* Applications and regular plug-ins should not call this method.
* </p>
*
* @return the testable object facade
* @since 3.0
*/
static TestableObject::Pointer GetTestableObject();
private:
PlatformUI();
};
}
#endif /*BERRYPLATFORMUI_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryPoint.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/berryPoint.cpp
index 1ea341400b..e1c8317a00 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryPoint.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryPoint.cpp
@@ -1,48 +1,48 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryPoint.h"
#include <sstream>
namespace berry
{
Point::Point(int x, int y)
{
this->x = x;
this->y = y;
}
bool Point::operator==(const Point& p) const
{
if (&p == this) return true;
return (p.x == x) && (p.y == y);
}
int Point::HashCode()
{
return x ^ y;
}
std::string Point::ToString()
{
std::stringstream str;
str << "Point {" << x << ", " << y << "}";
return str.str();
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryPoint.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryPoint.h
index 48fef277a7..781a125967 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryPoint.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryPoint.h
@@ -1,110 +1,110 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYPOINT_H_
#define BERRYPOINT_H_
#include <string>
#include <org_blueberry_ui_Export.h>
namespace berry
{
/**
* Instances of this class represent places on the (x, y)
* coordinate plane.
* <p>
* The coordinate space for rectangles and points is considered
* to have increasing values downward and to the right from its
* origin making this the normal, computer graphics oriented notion
* of (x, y) coordinates rather than the strict mathematical one.
* </p>
* <p>
* The hashCode() method in this class uses the values of the public
* fields to compute the hash value. When storing instances of the
* class in hashed collections, do not modify these fields after the
* object has been inserted.
* </p>
* <p>
* Application code does <em>not</em> need to explicitly release the
* resources managed by each instance when those instances are no longer
* required, and thus no <code>dispose()</code> method is provided.
* </p>
*
* @see Rectangle
*/
class BERRY_UI Point
{
public:
/**
* the x coordinate of the point
*/
int x;
/**
* the y coordinate of the point
*/
int y;
/**
* Constructs a new point with the given x and y coordinates.
*
* @param x the x coordinate of the new point
* @param y the y coordinate of the new point
*/
Point(int x, int y);
/**
* Compares the argument to the receiver, and returns true
* if they represent the <em>same</em> object using a class
* specific comparison.
*
* @param object the object to compare with this object
* @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise
*
* @see #hashCode()
*/
bool operator==(const Point& p) const;
/**
* Returns an integer hash code for the receiver. Any two
* objects that return <code>true</code> when passed to
* <code>equals</code> must return the same value for this
* method.
*
* @return the receiver's hash
*
* @see #equals(Object)
*/
int HashCode();
/**
* Returns a string containing a concise, human-readable
* description of the receiver.
*
* @return a string representation of the point
*/
std::string ToString();
};
}
#endif /*BERRYPOINT_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryPropertyChangeEvent.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/berryPropertyChangeEvent.cpp
index 83130e1bc3..24ad373f21 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryPropertyChangeEvent.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryPropertyChangeEvent.cpp
@@ -1,52 +1,52 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryPropertyChangeEvent.h"
namespace berry
{
PropertyChangeEvent::PropertyChangeEvent(Object::Pointer source,
const std::string& property, Object::Pointer oldValue,
Object::Pointer newValue)
{
this->source = source;
this->propertyName = property;
this->oldValue = oldValue;
this->newValue = newValue;
}
Object::Pointer PropertyChangeEvent::GetNewValue()
{
return newValue;
}
Object::Pointer PropertyChangeEvent::GetOldValue()
{
return oldValue;
}
std::string PropertyChangeEvent::GetProperty()
{
return propertyName;
}
Object::Pointer PropertyChangeEvent::GetSource()
{
return source;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryPropertyChangeEvent.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryPropertyChangeEvent.h
index aad6b69b47..0d87b72f7b 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryPropertyChangeEvent.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryPropertyChangeEvent.h
@@ -1,128 +1,128 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYPROPERTYCHANGEEVENT_H_
#define BERRYPROPERTYCHANGEEVENT_H_
#include <berryMacros.h>
#include <berryObject.h>
#include <org_blueberry_ui_Export.h>
namespace berry {
/**
* An event object describing a change to a named property.
* <p>
* This concrete class was designed to be instantiated, but may
* also be subclassed if required.
* </p>
* <p>
* The JFace frameworks contain classes that report property
* change events for internal state changes that may be of interest
* to external parties. A special listener interface
* (<code>IPropertyChangeListener</code>) is defined for this purpose,
* and a typical class allow listeners to be registered via
* an <code>addPropertyChangeListener</code> method.
* </p>
*
* @see IPropertyChangeListener
*/
class BERRY_UI PropertyChangeEvent : public Object {
public:
berryObjectMacro(PropertyChangeEvent);
private:
/**
* The name of the changed property.
*/
std::string propertyName;
/**
* The old value of the changed property, or <code>null</code> if
* not known or not relevant.
*/
Object::Pointer oldValue;
/**
* The new value of the changed property, or <code>null</code> if
* not known or not relevant.
*/
Object::Pointer newValue;
/**
* The object on which the property change occured
*/
Object::Pointer source;
public:
/**
* Creates a new property change event.
*
* @param source the object whose property has changed
* @param property the property that has changed (must not be <code>null</code>)
* @param oldValue the old value of the property, or <code>null</code> if none
* @param newValue the new value of the property, or <code>null</code> if none
*/
PropertyChangeEvent(Object::Pointer source, const std::string& property, Object::Pointer oldValue,
Object::Pointer newValue);
/**
* Returns the new value of the property.
*
* @return the new value, or <code>null</code> if not known
* or not relevant (for instance if the property was removed).
*/
Object::Pointer GetNewValue();
/**
* Returns the old value of the property.
*
* @return the old value, or <code>null</code> if not known
* or not relevant (for instance if the property was just
* added and there was no old value).
*/
Object::Pointer GetOldValue();
/**
* Returns the name of the property that changed.
* <p>
* Warning: there is no guarantee that the property name returned
* is a constant string. Callers must compare property names using
* equals, not ==.
* </p>
*
* @return the name of the property that changed
*/
std::string GetProperty();
/**
* Returns the object whose property has changed
*
* @return the object whose property has changed
*/
Object::Pointer GetSource();
};
}
#endif /* BERRYPROPERTYCHANGEEVENT_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryRectangle.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/berryRectangle.cpp
index c77df4d5e7..5e1659c2ec 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryRectangle.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryRectangle.cpp
@@ -1,166 +1,166 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryRectangle.h"
#include <sstream>
namespace berry
{
Rectangle::Rectangle()
: x(0), y(0), width(0), height(0)
{
}
Rectangle::Rectangle(int x_, int y_, int w, int h) :
x(x_), y(y_), width(w), height(h)
{
}
void Rectangle::Add(const Rectangle& rect)
{
int left = x < rect.x ? x : rect.x;
int top = y < rect.y ? y : rect.y;
int lhs = x + width;
int rhs = rect.x + rect.width;
int right = lhs > rhs ? lhs : rhs;
lhs = y + height;
rhs = rect.y + rect.height;
int bottom = lhs > rhs ? lhs : rhs;
x = left;
y = top;
width = right - left;
height = bottom - top;
}
bool Rectangle::Contains(int x, int y) const
{
return (x >= this->x) && (y >= this->y) && ((x - this->x) < width) && ((y
- this->y) < height);
}
bool Rectangle::Contains(const Point& point) const
{
return this->Contains(point.x, point.y);
}
Rectangle& Rectangle::FlipXY()
{
int tmp = x;
x = y;
y = tmp;
tmp = width;
width = height;
height = tmp;
return *this;
}
bool Rectangle::operator==(const Rectangle& r) const
{
if (&r == this) return true;
return (r.x == this->x) && (r.y == this->y) && (r.width == this->width) && (r.height == this->height);
}
int Rectangle::HashCode() const
{
return x ^ y ^ width ^ height;
}
void Rectangle::Intersect(const Rectangle& rect)
{
if (this == &rect) return;
int left = x> rect.x ? x : rect.x;
int top = y> rect.y ? y : rect.y;
int lhs = x + width;
int rhs = rect.x + rect.width;
int right = lhs < rhs ? lhs : rhs;
lhs = y + height;
rhs = rect.y + rect.height;
int bottom = lhs < rhs ? lhs : rhs;
x = right < left ? 0 : left;
y = bottom < top ? 0 : top;
width = right < left ? 0 : right - left;
height = bottom < top ? 0 : bottom - top;
}
Rectangle Rectangle::Intersection(const Rectangle& rect) const
{
if (this == &rect) return Rectangle (x, y, width, height);
int left = x> rect.x ? x : rect.x;
int top = y> rect.y ? y : rect.y;
int lhs = x + width;
int rhs = rect.x + rect.width;
int right = lhs < rhs ? lhs : rhs;
lhs = y + height;
rhs = rect.y + rect.height;
int bottom = lhs < rhs ? lhs : rhs;
return Rectangle (
right < left ? 0 : left,
bottom < top ? 0 : top,
right < left ? 0 : right - left,
bottom < top ? 0 : bottom - top);
}
bool Rectangle::Intersects(int x, int y, int width, int height) const
{
return (x < this->x + this->width) && (y < this->y + this->height) &&
(x + width> this->x) && (y + height> this->y);
}
bool Rectangle::Intersects(const Rectangle& rect) const
{
return &rect == this || this->Intersects(rect.x, rect.y, rect.width, rect.height);
}
int Rectangle::GetDimension(bool width) const
{
if (width) {
return this->width;
}
return this->height;
}
bool Rectangle::IsEmpty () const
{
return (width <= 0) || (height <= 0);
}
std::string Rectangle::ToString () const
{
std::ostringstream stream;
stream << "Rectangle {" << x << ", " << y << ", " << width << ", " << height << "}";
return stream.str(); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
}
Rectangle Rectangle::Union(const Rectangle& rect) const
{
int left = x < rect.x ? x : rect.x;
int top = y < rect.y ? y : rect.y;
int lhs = x + width;
int rhs = rect.x + rect.width;
int right = lhs> rhs ? lhs : rhs;
lhs = y + height;
rhs = rect.y + rect.height;
int bottom = lhs> rhs ? lhs : rhs;
return Rectangle(left, top, right - left, bottom - top);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryRectangle.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryRectangle.h
index b2047a2c41..09851e44b1 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryRectangle.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryRectangle.h
@@ -1,295 +1,295 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYRECTANGLE_H_
#define BERRYRECTANGLE_H_
#include <org_blueberry_ui_Export.h>
#include "berryPoint.h"
#include <string>
namespace berry
{
/**
* Instances of this class represent rectangular areas in an
* (x, y) coordinate system. The top left corner of the rectangle
* is specified by its x and y values, and the extent of the
* rectangle is specified by its width and height.
* <p>
* The coordinate space for rectangles and points is considered
* to have increasing values downward and to the right from its
* origin making this the normal, computer graphics oriented notion
* of (x, y) coordinates rather than the strict mathematical one.
* </p>
* <p>
* The hashCode() method in this class uses the values of the
* fields to compute the hash value. When storing instances of the
* class in hashed collections, do not modify these fields after the
* object has been inserted.
* </p>
* <p>
* Application code does <em>not</em> need to explicitly release the
* resources managed by each instance when those instances are no longer
* required, and thus no <code>dispose()</code> method is provided.
* </p>
*
*/
struct BERRY_UI Rectangle
{
/**
* the x coordinate of the rectangle
*/
int x;
/**
* the y coordinate of the rectangle
*/
int y;
/**
* the width of the rectangle
*/
int width;
/**
* the height of the rectangle
*/
int height;
/**
* Constrcut a new instance of this class with
* x, y, width and height values set to zero.
*/
Rectangle();
/**
* Construct a new instance of this class given the
* x, y, width and height values.
*
* @param x the x coordinate of the origin of the rectangle
* @param y the y coordinate of the origin of the rectangle
* @param width the width of the rectangle
* @param height the height of the rectangle
*/
Rectangle(int x, int y, int width, int height);
/**
* Destructively replaces the x, y, width and height values
* in the receiver with ones which represent the union of the
* rectangles specified by the receiver and the given rectangle.
* <p>
* The union of two rectangles is the smallest single rectangle
* that completely covers both of the areas covered by the two
* given rectangles.
* </p>
*
* @param rect the rectangle to merge with the receiver
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
* </ul>
*/
void Add(const Rectangle& rect);
/**
* Returns <code>true</code> if the point specified by the
* arguments is inside the area specified by the receiver,
* and <code>false</code> otherwise.
*
* @param x the x coordinate of the point to test for containment
* @param y the y coordinate of the point to test for containment
* @return <code>true</code> if the rectangle contains the point and <code>false</code> otherwise
*/
bool Contains(int x, int y) const;
/**
* Returns <code>true</code> if the point specified by the
* arguments is inside the area specified by the receiver,
* and <code>false</code> otherwise.
*
* @param the point to test for containment
* @return <code>true</code> if the rectangle contains the point and <code>false</code> otherwise
*/
bool Contains(const Point& point) const;
/**
* Flips the x and y coordinates, i.e. rotates the rectangle about 90 degrees.
*
* @return the flipped rectangle
*/
Rectangle& FlipXY();
/**
* Compares the argument to the receiver, and returns true
* if they represent the <em>same</em> object using a class
* specific comparison.
*
* @param object the object to compare with this object
* @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise
*
* @see #hashCode()
*/
bool operator==(const Rectangle& object) const;
/**
* Returns an integer hash code for the receiver. Any two
* objects that return <code>true</code> when passed to
* <code>equals</code> must return the same value for this
* method.
*
* @return the receiver's hash
*
* @see #equals(Object)
*/
int HashCode() const;
/**
* Destructively replaces the x, y, width and height values
* in the receiver with ones which represent the intersection of the
* rectangles specified by the receiver and the given rectangle.
*
* @param rect the rectangle to intersect with the receiver
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
* </ul>
*
* since 3.0
*/
void Intersect(const Rectangle& rect);
/**
* Returns a new rectangle which represents the intersection
* of the receiver and the given rectangle.
* <p>
* The intersection of two rectangles is the rectangle that
* covers the area which is contained within both rectangles.
* </p>
*
* @param rect the rectangle to intersect with the receiver
* @return the intersection of the receiver and the argument
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
* </ul>
*/
Rectangle Intersection(const Rectangle& rect) const;
/**
* Returns <code>true</code> if the rectangle described by the
* arguments intersects with the receiver and <code>false</code>
* otherwise.
* <p>
* Two rectangles intersect if the area of the rectangle
* representing their intersection is not empty.
* </p>
*
* @param x the x coordinate of the origin of the rectangle
* @param y the y coordinate of the origin of the rectangle
* @param width the width of the rectangle
* @param height the height of the rectangle
* @return <code>true</code> if the rectangle intersects with the receiver, and <code>false</code> otherwise
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
* </ul>
*
* @see #intersection(Rectangle)
* @see #isEmpty()
*
* @since 3.0
*/
bool Intersects(int x, int y, int width, int height) const;
/**
* Returns <code>true</code> if the given rectangle intersects
* with the receiver and <code>false</code> otherwise.
* <p>
* Two rectangles intersect if the area of the rectangle
* representing their intersection is not empty.
* </p>
*
* @param rect the rectangle to test for intersection
* @return <code>true</code> if the rectangle intersects with the receiver, and <code>false</code> otherwise
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
* </ul>
*
* @see #intersection(Rectangle)
* @see #isEmpty()
*/
bool Intersects(const Rectangle& rect) const;
/**
* Returns the height or width
*
* @param width returns the width if true, and the height if false
* @return the width or height of the reciever
* @since 3.0
*/
int GetDimension(bool width) const;
/**
* Returns <code>true</code> if the receiver does not cover any
* area in the (x, y) coordinate plane, and <code>false</code> if
* the receiver does cover some area in the plane.
* <p>
* A rectangle is considered to <em>cover area</em> in the
* (x, y) coordinate plane if both its width and height are
* non-zero.
* </p>
*
* @return <code>true</code> if the receiver is empty, and <code>false</code> otherwise
*/
bool IsEmpty() const;
/**
* Returns a string containing a concise, human-readable
* description of the receiver.
*
* @return a string representation of the rectangle
*/
std::string ToString() const;
/**
* Returns a new rectangle which represents the union of
* the receiver and the given rectangle.
* <p>
* The union of two rectangles is the smallest single rectangle
* that completely covers both of the areas covered by the two
* given rectangles.
* </p>
*
* @param rect the rectangle to perform union with
* @return the union of the receiver and the argument
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
* </ul>
*
* @see #add(Rectangle)
*/
Rectangle Union(const Rectangle& rect) const;
};
}
#endif /*BERRYRECTANGLE_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berrySameShellProvider.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/berrySameShellProvider.cpp
index 1ca7d723af..89dcf28698 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berrySameShellProvider.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berrySameShellProvider.cpp
@@ -1,47 +1,47 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berrySameShellProvider.h"
#include "tweaklets/berryGuiWidgetsTweaklet.h"
namespace berry
{
SameShellProvider::SameShellProvider(void* target) :
targetControl(target)
{
}
SameShellProvider::SameShellProvider(Shell::Pointer sh) :
targetControl(0), shell(sh)
{
}
Shell::Pointer SameShellProvider::GetShell()
{
if (shell != 0)
{
return shell;
}
return targetControl == 0 ? Shell::Pointer(0)
: Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetShell(targetControl);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berrySameShellProvider.h b/BlueBerry/Bundles/org.blueberry.ui/src/berrySameShellProvider.h
index a151d8c20a..22bb2e5f56 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berrySameShellProvider.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berrySameShellProvider.h
@@ -1,74 +1,74 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYSAMESHELLPROVIDER_H_
#define BERRYSAMESHELLPROVIDER_H_
#include <org_blueberry_ui_Export.h>
#include "berryShell.h"
#include <berryMacros.h>
#include "berryIShellProvider.h"
namespace berry {
/**
* Standard shell provider that always returns the shell containing the given
* control. This will always return the correct shell for the control, even if
* the control is reparented.
*
* @since 3.1
*/
class BERRY_UI SameShellProvider : public IShellProvider {
private:
void* targetControl;
Shell::Pointer shell;
public:
berryObjectMacro(SameShellProvider);
/**
* Returns a shell provider that always returns the current
* shell for the given control.
*
* @param targetControl control whose shell will be tracked, or null if getShell() should always
* return null
*/
SameShellProvider(void* targetControl);
/**
* Returns a shell provider that always returns the given shell.
*
* @param shell the shell which should always be returned,
* or null if GetShell() should alway return null
*/
SameShellProvider(Shell::Pointer shell);
/* (non-javadoc)
* @see IShellProvider#getShell()
*/
Shell::Pointer GetShell();
};
}
#endif /* BERRYSAMESHELLPROVIDER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berrySaveable.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/berrySaveable.cpp
index 961fcd3020..4f47db8bdf 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berrySaveable.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berrySaveable.cpp
@@ -1,79 +1,79 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berrySaveable.h"
#include "berryIWorkbenchPage.h"
#include "berryIWorkbenchPart.h"
namespace berry
{
bool Saveable::Show(IWorkbenchPage::Pointer /*page*/)
{
return false;
}
/*IJobRunnable*/void Saveable::DoSave(/*IProgressMonitor monitor,
IShellProvider shellProvider*/)
{
this->DoSave(/*monitor*/);
//return 0;
}
void Saveable::DisableUI(const std::vector<IWorkbenchPart::Pointer>& /*parts*/,
bool /*closing*/)
{
//TODO Saveable DisableUI
// for (int i = 0; i < parts.length; i++) {
// IWorkbenchPart workbenchPart = parts[i];
// Composite paneComposite = (Composite) ((PartSite) workbenchPart
// .getSite()).getPane().getControl();
// Control[] paneChildren = paneComposite.getChildren();
// Composite toDisable = ((Composite) paneChildren[0]);
// toDisable.setEnabled(false);
// if (waitCursor == null) {
// waitCursor = new Cursor(workbenchPart.getSite().getWorkbenchWindow().getShell().getDisplay(), SWT.CURSOR_WAIT);
// }
// originalCursor = paneComposite.getCursor();
// paneComposite.setCursor(waitCursor);
// }
}
void Saveable::EnableUI(std::vector<IWorkbenchPart::Pointer>& /*parts*/)
{
//TODO Saveable EnableUI
// for (unsigned int i = 0; i < parts.size(); i++) {
// IWorkbenchPart::Pointer workbenchPart = parts[i];
// Composite paneComposite = (Composite) ((PartSite) workbenchPart
// .getSite()).getPane().getControl();
// Control[] paneChildren = paneComposite.getChildren();
// Composite toEnable = ((Composite) paneChildren[0]);
// paneComposite.setCursor(originalCursor);
// if (waitCursor!=null && !waitCursor.isDisposed()) {
// waitCursor.dispose();
// waitCursor = null;
// }
// toEnable.setEnabled(true);
// }
}
Poco::Any Saveable::GetAdapter(const std::string& /*adapter*/)
{
return Poco::Any();
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berrySaveable.h b/BlueBerry/Bundles/org.blueberry.ui/src/berrySaveable.h
index daac2ad828..50373e7cbd 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berrySaveable.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berrySaveable.h
@@ -1,298 +1,298 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYSAVEABLE_H_
#define BERRYSAVEABLE_H_
#include <berryMacros.h>
#include <berryObject.h>
#include <berryIAdaptable.h>
#include <set>
#include <vector>
#include <org_blueberry_ui_Export.h>
#include "berryImageDescriptor.h"
namespace berry {
struct IWorkbenchPage;
struct IWorkbenchPart;
/**
* A <code>Saveable</code> represents a unit of saveability, e.g. an editable
* subset of the underlying domain model that may contain unsaved changes.
* Different workbench parts (editors and views) may present the same saveables
* in different ways. This interface allows the workbench to provide more
* appropriate handling of operations such as saving and closing workbench
* parts. For example, if two editors sharing the same saveable with unsaved
* changes are closed simultaneously, the user is only prompted to save the
* changes once for the shared saveable, rather than once for each editor.
* <p>
* Workbench parts that work in terms of saveables should implement
* {@link ISaveablesSource}.
* </p>
*
* @see ISaveablesSource
* @since 3.2
*/
class BERRY_UI Saveable : /*public InternalSaveable*/ public virtual Object, public IAdaptable
{
public:
berryObjectMacro(Saveable);
private:
//Cursor waitCursor;
//Cursor originalCursor;
public:
struct SaveableCmp : public std::binary_function<Saveable::Pointer, Saveable::Pointer, bool>
{
bool operator()(const Saveable::Pointer& s1, const Saveable::Pointer& s2) const
{
return s1->operator<(s2.GetPointer());
}
};
typedef std::set<Saveable::Pointer, SaveableCmp> Set;
/**
* Attempts to show this saveable in the given page and returns
* <code>true</code> on success. The default implementation does nothing
* and returns <code>false</code>.
*
* @param page
* the workbench page in which to show this saveable
* @return <code>true</code> if this saveable is now visible to the user
* @since 3.3
*/
virtual bool Show(SmartPointer<IWorkbenchPage> page);
/**
* Returns the name of this saveable for display purposes.
*
* @return the model's name; never <code>null</code>.
*/
virtual std::string GetName() const = 0;
/**
* Returns the tool tip text for this saveable. This text is used to
* differentiate between two inputs with the same name. For instance,
* MyClass.java in folder X and MyClass.java in folder Y. The format of the
* text varies between input types.
*
* @return the tool tip text; never <code>null</code>
*/
virtual std::string GetToolTipText() const = 0;
/**
* Returns the image descriptor for this saveable.
*
* @return the image descriptor for this model; may be <code>null</code>
* if there is no image
*/
virtual SmartPointer<ImageDescriptor> GetImageDescriptor() const = 0;
/**
* Saves the contents of this saveable.
* <p>
* If the save is cancelled through user action, or for any other reason,
* the part should invoke <code>setCancelled</code> on the
* <code>IProgressMonitor</code> to inform the caller.
* </p>
* <p>
* This method is long-running; progress and cancellation are provided by
* the given progress monitor.
* </p>
*
* @param monitor
* the progress monitor
* @throws CoreException
* if the save fails; it is the caller's responsibility to
* report the failure to the user
*/
virtual void DoSave(/*IProgressMonitor monitor*/) = 0;
/**
* Returns whether the contents of this saveable have changed since the last
* save operation.
* <p>
* <b>Note:</b> this method is called frequently, for example by actions to
* determine their enabled status.
* </p>
*
* @return <code>true</code> if the contents have been modified and need
* saving, and <code>false</code> if they have not changed since
* the last save
*/
virtual bool IsDirty() const = 0;
/**
* Clients must implement equals and hashCode as defined in
* {@link Object#equals(Object)} and {@link Object#hashCode()}. Two
* saveables should be equal if their dirty state is shared, and saving one
* will save the other. If two saveables are equal, their names, tooltips,
* and images should be the same because only one of them will be shown when
* prompting the user to save.
*
* @param object
* @return true if this Saveable is equal to the given object
*/
virtual bool operator<(const Saveable* object) const = 0;
/**
* Clients must implement equals and hashCode as defined in
* {@link Object#equals(Object)} and {@link Object#hashCode()}. Two
* saveables should be equal if their dirty state is shared, and saving one
* will save the other. If two saveables are equal, their hash codes MUST be
* the same, and their names, tooltips, and images should be the same
* because only one of them will be shown when prompting the user to save.
* <p>
* IMPORTANT: Implementers should ensure that the hashCode returned is
* sufficiently unique so as not to collide with hashCodes returned by other
* implementations. It is suggested that the defining plug-in's ID be used
* as part of the returned hashCode, as in the following example:
* </p>
*
* <pre>
* int PRIME = 31;
* int hash = ...; // compute the &quot;normal&quot; hash code, e.g. based on some identifier unique within the defining plug-in
* return hash * PRIME + MY_PLUGIN_ID.hashCode();
* </pre>
*
* @return a hash code
*/
//virtual int hashCode();
/**
* Saves this saveable, or prepares this saveable for a background save
* operation. Returns null if this saveable has been successfully saved, or
* a job runnable that needs to be run to complete the save in the
* background. This method is called in the UI thread. If this saveable
* supports saving in the background, it should do only minimal work.
* However, since the job runnable returned by this method (if any) will not
* run on the UI thread, this method should copy any state that can only be
* accessed from the UI thread so that the job runnable will be able to
* access it.
* <p>
* The supplied shell provider can be used from within this method and from
* within the job runnable for the purpose of parenting dialogs. Care should
* be taken not to open dialogs gratuitously and only if user input is
* required for cases where the save cannot otherwise proceed - note that in
* any given save operation, many saveable objects may be saved at the same
* time. In particular, errors should be signaled by throwing an exception,
* or if an error occurs while running the job runnable, an error status
* should be returned.
* </p>
* <p>
* If the foreground part of the save is cancelled through user action, or
* for any other reason, the part should invoke <code>setCancelled</code>
* on the <code>IProgressMonitor</code> to inform the caller. If the
* background part of the save is cancelled, the job should return a
* {@link IStatus#CANCEL} status.
* </p>
* <p>
* This method is long-running; progress and cancellation are provided by
* the given progress monitor.
* </p>
* <p>
* The default implementation of this method calls
* {@link #doSave(IProgressMonitor)} and returns <code>null</code>.
* </p>
*
* @param monitor
* a progress monitor used for reporting progress and
* cancellation
* @param shellProvider
* an object that can provide a shell for parenting dialogs
* @return <code>null</code> if this saveable has been saved successfully,
* or a job runnable that needs to be run to complete the save in
* the background.
*
* @since 3.3
*/
//TODO Saveable IJobRunnable, IProgressMonitor, and IShellProvider
// virtual /*IJobRunnable*/void DoSave(/*IProgressMonitor monitor,
// IShellProvider shellProvider*/);
/**
* Disables the UI of the given parts containing this saveable if necessary.
* This method is not intended to be called by clients. A corresponding call
* to
* <p>
* Saveables that can be saved in the background should ensure that the user
* cannot make changes to their data from the UI, for example by disabling
* controls, unless they are prepared to handle this case. This method is
* called on the UI thread after a job runnable has been returned from
* {@link #doSave(IProgressMonitor, IShellProvider)} and before
* spinning the event loop. The <code>closing</code> flag indicates that
* this saveable is currently being saved in response to closing a workbench
* part, in which case further changes to this saveable through the UI must
* be prevented.
* </p>
* <p>
* The default implementation calls setEnabled(false) on the given parts'
* composites.
* </p>
*
* @param parts
* the workbench parts containing this saveable
* @param closing
* a boolean flag indicating whether the save was triggered by a
* request to close a workbench part, and all of the given parts
* will be closed after the save operation finishes successfully.
*
* @since 3.3
*/
virtual void DisableUI(const std::vector<SmartPointer<IWorkbenchPart> >& parts, bool closing);
/**
* Enables the UI of the given parts containing this saveable after a
* background save operation has finished. This method is not intended to be
* called by clients.
* <p>
* The default implementation calls setEnabled(true) on the given parts'
* composites.
* </p>
*
* @param parts
* the workbench parts containing this saveable
*
* @since 3.3
*/
virtual void EnableUI(std::vector<SmartPointer<IWorkbenchPart> >& parts);
protected:
/**
* This implementation of {@link IAdaptable#GetAdapterImpl(const std::type_info&)} returns
* <code>null</code>. Subclasses may override. This allows two unrelated
* subclasses of Saveable to implement {@link #equals(Object)} and
* {@link #hashCode()} based on an underlying implementation class that is
* shared by both Saveable subclasses.
*
* @since 3.3
*/
virtual Poco::Any GetAdapter(const std::string& adapter);
};
}
#endif /* BERRYSAVEABLE_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berrySaveablesLifecycleEvent.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/berrySaveablesLifecycleEvent.cpp
index ca01316dab..ca4d659c19 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berrySaveablesLifecycleEvent.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berrySaveablesLifecycleEvent.cpp
@@ -1,66 +1,66 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berrySaveablesLifecycleEvent.h"
namespace berry
{
const int SaveablesLifecycleEvent::POST_OPEN = 1;
const int SaveablesLifecycleEvent::PRE_CLOSE = 2;
const int SaveablesLifecycleEvent::POST_CLOSE = 3;
const int SaveablesLifecycleEvent::DIRTY_CHANGED = 4;
SaveablesLifecycleEvent::SaveablesLifecycleEvent(Object::Pointer source_,
int eventType_, const std::vector<Saveable::Pointer>& saveables_,
bool force_) :
eventType(eventType_), saveables(saveables_), force(force_), veto(false),
source(source_)
{
}
int SaveablesLifecycleEvent::GetEventType()
{
return eventType;
}
Object::Pointer SaveablesLifecycleEvent::GetSource()
{
return source;
}
std::vector<Saveable::Pointer> SaveablesLifecycleEvent::GetSaveables()
{
return saveables;
}
bool SaveablesLifecycleEvent::IsVeto()
{
return veto;
}
void SaveablesLifecycleEvent::SetVeto(bool veto)
{
this->veto = veto;
}
bool SaveablesLifecycleEvent::IsForce()
{
return force;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berrySaveablesLifecycleEvent.h b/BlueBerry/Bundles/org.blueberry.ui/src/berrySaveablesLifecycleEvent.h
index 8a559ea413..98bc8b3cae 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berrySaveablesLifecycleEvent.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berrySaveablesLifecycleEvent.h
@@ -1,143 +1,143 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYSAVEABLESLIFECYCLEEVENT_H_
#define BERRYSAVEABLESLIFECYCLEEVENT_H_
#include <berryMacros.h>
#include <org_blueberry_ui_Export.h>
#include "berrySaveable.h"
#include <vector>
namespace berry {
/**
* Event object describing a change to a set of Saveable objects.
*
* @since 3.2
*/
class BERRY_UI SaveablesLifecycleEvent : public Object {
public:
berryObjectMacro(SaveablesLifecycleEvent);
/**
* Event type constant specifying that the given saveables have been opened.
*/
static const int POST_OPEN; // = 1;
/**
* Event type constant specifying that the given saveables are about to be
* closed. Listeners may veto the closing if isForce() is false.
*/
static const int PRE_CLOSE; // = 2;
/**
* Event type constant specifying that the given saveables have been closed.
*/
static const int POST_CLOSE; // = 3;
/**
* Event type constant specifying that the dirty state of the given saveables
* has changed.
*/
static const int DIRTY_CHANGED; // = 4;
private:
int eventType;
std::vector<Saveable::Pointer> saveables;
bool force;
bool veto;
Object::Pointer source;
public:
/**
* Creates a new SaveablesLifecycleEvent.
*
* @param source
* The source of the event. If an ISaveablesSource notifies
* about changes to the saveables returned by
* {@link ISaveablesSource#getSaveables()}, the source must be
* the ISaveablesSource object.
* @param eventType
* the event type, currently one of POST_OPEN, PRE_CLOSE,
* POST_CLOSE, DIRTY_CHANGED
* @param saveables
* The affected saveables
* @param force
* true if the event type is PRE_CLOSE and this is a closed force
* that cannot be canceled.
*/
SaveablesLifecycleEvent(Object::Pointer source_, int eventType_,
const std::vector<Saveable::Pointer>& saveables_, bool force_);
/**
* Returns the eventType, currently one of POST_OPEN, PRE_CLOSE, POST_CLOSE,
* DIRTY_CHANGED. Listeners should silently ignore unknown event types since
* new event types might be added in the future.
*
* @return the eventType
*/
int GetEventType();
Object::Pointer GetSource();
/**
* Returns the affected saveables.
*
* @return the saveables
*/
std::vector<Saveable::Pointer> GetSaveables();
/**
* Returns the veto. This value is ignored for POST_OPEN,POST_CLOSE, and
* DIRTY_CHANGED.
*
* @return Returns the veto.
*/
bool IsVeto();
/**
* @param veto
* The veto to set.
*/
void SetVeto(bool veto);
/**
* Sets the force flag. This value is ignored for POST_OPEN, POST_CLOSE, and
* DIRTY_CHANGED.
*
* @return Returns the force.
*/
bool IsForce();
};
}
#endif /* BERRYSAVEABLESLIFECYCLEEVENT_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berrySelectionChangedEvent.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/berrySelectionChangedEvent.cpp
index 5d4b3fda20..375ab67aa8 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berrySelectionChangedEvent.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berrySelectionChangedEvent.cpp
@@ -1,49 +1,49 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berrySelectionChangedEvent.h"
#include "berryISelectionProvider.h"
namespace berry
{
SelectionChangedEvent::SelectionChangedEvent(
ISelectionProvider::Pointer source, ISelection::ConstPointer selection)
{
poco_assert(source.IsNotNull());
poco_assert(selection.IsNotNull());
this->source = source;
this->selection = selection;
}
ISelectionProvider::Pointer SelectionChangedEvent::GetSource() const
{
return source;
}
ISelection::ConstPointer SelectionChangedEvent::GetSelection() const
{
return selection;
}
ISelectionProvider::Pointer SelectionChangedEvent::GetSelectionProvider() const
{
return this->GetSource();
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryShell.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/berryShell.cpp
index 2ae0dfaccc..e522f93784 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryShell.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryShell.cpp
@@ -1,39 +1,39 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryShell.h"
namespace berry {
Object::Pointer Shell::GetData(const std::string& id) const
{
std::map<std::string, Object::Pointer>::const_iterator iter = data.find(id);
if (iter == data.end()) return Object::Pointer(0);
return iter->second;
}
void Shell::SetData(Object::Pointer data, const std::string& id)
{
this->data[id] = data;
}
void Shell::SetBounds(int x, int y, int width, int height)
{
Rectangle rect(x, y, width, height);
this->SetBounds(rect);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryShell.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryShell.h
index 1c8a9ef4a4..7623343d79 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryShell.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryShell.h
@@ -1,329 +1,329 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYSHELL_H_
#define BERRYSHELL_H_
#include <berryMacros.h>
#include <org_blueberry_ui_Export.h>
#include "berryIShellListener.h"
#include "guitk/berryGuiTkIControlListener.h"
#include "berryRectangle.h"
#include "berryPoint.h"
#include <map>
namespace berry {
/**
* Instances of this class represent the "windows"
* which the desktop or "window manager" is managing.
* Instances that do not have a parent (that is, they
* are built using the constructor, which takes a
* <code>Display</code> as the argument) are described
* as <em>top level</em> shells. Instances that do have
* a parent are described as <em>secondary</em> or
* <em>dialog</em> shells.
* <p>
* Instances are always displayed in one of the maximized,
* minimized or normal states:
* <ul>
* <li>
* When an instance is marked as <em>maximized</em>, the
* window manager will typically resize it to fill the
* entire visible area of the display, and the instance
* is usually put in a state where it can not be resized
* (even if it has style <code>RESIZE</code>) until it is
* no longer maximized.
* </li><li>
* When an instance is in the <em>normal</em> state (neither
* maximized or minimized), its appearance is controlled by
* the style constants which were specified when it was created
* and the restrictions of the window manager (see below).
* </li><li>
* When an instance has been marked as <em>minimized</em>,
* its contents (client area) will usually not be visible,
* and depending on the window manager, it may be
* "iconified" (that is, replaced on the desktop by a small
* simplified representation of itself), relocated to a
* distinguished area of the screen, or hidden. Combinations
* of these changes are also possible.
* </li>
* </ul>
* </p><p>
* The <em>modality</em> of an instance may be specified using
* style bits. The modality style bits are used to determine
* whether input is blocked for other shells on the display.
* The <code>PRIMARY_MODAL</code> style allows an instance to block
* input to its parent. The <code>APPLICATION_MODAL</code> style
* allows an instance to block input to every other shell in the
* display. The <code>SYSTEM_MODAL</code> style allows an instance
* to block input to all shells, including shells belonging to
* different applications.
* </p><p>
* Note: The styles supported by this class are treated
* as <em>HINT</em>s, since the window manager for the
* desktop on which the instance is visible has ultimate
* control over the appearance and behavior of decorations
* and modality. For example, some window managers only
* support resizable windows and will always assume the
* RESIZE style, even if it is not set. In addition, if a
* modality style is not supported, it is "upgraded" to a
* more restrictive modality style that is supported. For
* example, if <code>PRIMARY_MODAL</code> is not supported,
* it would be upgraded to <code>APPLICATION_MODAL</code>.
* A modality style may also be "downgraded" to a less
* restrictive style. For example, most operating systems
* no longer support <code>SYSTEM_MODAL</code> because
* it can freeze up the desktop, so this is typically
* downgraded to <code>APPLICATION_MODAL</code>.
* <dl>
* <dt><b>Styles:</b></dt>
* <dd>BORDER, CLOSE, MIN, MAX, NO_TRIM, RESIZE, TITLE, ON_TOP, TOOL</dd>
* <dd>APPLICATION_MODAL, MODELESS, PRIMARY_MODAL, SYSTEM_MODAL</dd>
* <dt><b>Events:</b></dt>
* <dd>Activate, Close, Deactivate, Deiconify, Iconify</dd>
* </dl>
* Class <code>SWT</code> provides two "convenience constants"
* for the most commonly required style combinations:
* <dl>
* <dt><code>SHELL_TRIM</code></dt>
* <dd>
* the result of combining the constants which are required
* to produce a typical application top level shell: (that
* is, <code>CLOSE | TITLE | MIN | MAX | RESIZE</code>)
* </dd>
* <dt><code>DIALOG_TRIM</code></dt>
* <dd>
* the result of combining the constants which are required
* to produce a typical application dialog shell: (that
* is, <code>TITLE | CLOSE | BORDER</code>)
* </dd>
* </dl>
* </p>
* <p>
* Note: Only one of the styles APPLICATION_MODAL, MODELESS,
* PRIMARY_MODAL and SYSTEM_MODAL may be specified.
* </p><p>
* IMPORTANT: This class is not intended to be subclassed.
* </p>
*
* @see Decorations
* @see SWT
* @see <a href="http://www.blueberry.org/swt/snippets/#shell">Shell snippets</a>
* @see <a href="http://www.blueberry.org/swt/examples.php">SWT Example: ControlExample</a>
* @see <a href="http://www.blueberry.org/swt/">Sample code and further information</a>
*/
class BERRY_UI Shell : public virtual Object
{
public:
berryObjectMacro(Shell);
Object::Pointer GetData(const std::string& id = "") const;
void SetData(Object::Pointer data, const std::string& id = "");
void SetBounds(int x, int y, int width, int height);
virtual void SetBounds(const Rectangle& bounds) = 0;
virtual Rectangle GetBounds() const = 0;
virtual void SetLocation(int x, int y) = 0;
virtual Point ComputeSize(int wHint, int hHint, bool changed) = 0;
/**
* Returns the receiver's text, which is the string that the
* window manager will typically display as the receiver's title.
* If the text has not previously been set, returns an empty string.
*
* @return the text
*/
virtual std::string GetText() const = 0;
/**
* Sets the receiver's text, which is the string that the window manager
* will typically display as the receiver's title, to the argument.
*/
virtual void SetText(const std::string& text) = 0;
virtual bool IsVisible() = 0;
virtual void SetVisible(bool visible) = 0;
virtual void* GetControl() = 0;
virtual void SetImages(const std::vector<void*>& images) = 0;
/**
* Returns <code>true</code> if the receiver is currently
* maximized, and false otherwise.
* <p>
*
* @return the maximized state
*
* @see #SetMaximized
*/
virtual bool GetMaximized() = 0;
/**
* Returns <code>true</code> if the receiver is currently
* minimized, and false otherwise.
* <p>
*
* @return the minimized state
*
* @see #SetMinimized
*/
virtual bool GetMinimized() = 0;
/**
* Sets the minimized stated of the receiver.
* If the argument is <code>true</code> causes the receiver
* to switch to the minimized state, and if the argument is
* <code>false</code> and the receiver was previously minimized,
* causes the receiver to switch back to either the maximized
* or normal states.
* <p>
* Note: The result of intermixing calls to <code>setMaximized(true)</code>
* and <code>setMinimized(true)</code> will vary by platform. Typically,
* the behavior will match the platform user's expectations, but not
* always. This should be avoided if possible.
* </p>
*
* @param minimized the new maximized state
*
* @see #SetMaximized
*/
virtual void SetMinimized(bool minimized) = 0;
/**
* Sets the maximized state of the receiver.
* If the argument is <code>true</code> causes the receiver
* to switch to the maximized state, and if the argument is
* <code>false</code> and the receiver was previously maximized,
* causes the receiver to switch back to either the minimized
* or normal states.
* <p>
* Note: The result of intermixing calls to <code>setMaximized(true)</code>
* and <code>setMinimized(true)</code> will vary by platform. Typically,
* the behavior will match the platform user's expectations, but not
* always. This should be avoided if possible.
* </p>
*
* @param maximized the new maximized state
*
* @see #SetMinimized
*/
virtual void SetMaximized(bool maximized) = 0;
/**
* Adds the listener to the collection of listeners who will
* be notified when operations are performed on the receiver,
* by sending the listener one of the messages defined in the
* <code>IShellListener</code> interface.
*
* @param listener the listener which should be notified
*
* @see IShellListener
* @see #RemoveShellListener
*/
virtual void AddShellListener(IShellListener::Pointer listener) = 0;
/**
* Removes the listener from the collection of listeners who will
* be notified when operations are performed on the receiver.
*
* @param listener the listener which should no longer be notified
*
* @see IShellListener
* @see #AddShellListener
*/
virtual void RemoveShellListener(IShellListener::Pointer listener) = 0;
/**
* Moves the receiver to the top of the drawing order for
* the display on which it was created (so that all other
* shells on that display, which are not the receiver's
* children will be drawn behind it), marks it visible,
* sets the focus and asks the window manager to make the
* shell active.
*/
virtual void Open(bool block = false) = 0;
/**
* Requests that the window manager close the receiver in
* the same way it would be closed when the user clicks on
* the "close box" or performs some other platform specific
* key or mouse combination that indicates the window
* should be removed.
*/
virtual void Close() = 0;
/**
* If the receiver is visible, moves it to the top of the
* drawing order for the display on which it was created
* (so that all other shells on that display, which are not
* the receiver's children will be drawn behind it) and
* asks the window manager to make the shell active.
*/
virtual void SetActive() = 0;
/**
* Returns an array containing all shells which are
* descendants of the receiver.
* <p>
* @return the dialog shells
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
virtual std::vector<Shell::Pointer> GetShells() = 0;
/**
* Returns the receiver's style information.
* <p>
* Note that the value which is returned by this method <em>may
* not match</em> the value which was provided to the constructor
* when the receiver was created. This can occur when the underlying
* operating system does not support a particular combination of
* requested styles. For example, if the platform widget used to
* implement a particular SWT widget always has scroll bars, the
* result of calling this method would always have the
* <code>SWT.H_SCROLL</code> and <code>SWT.V_SCROLL</code> bits set.
* </p>
*
* @return the style bits
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
virtual int GetStyle () = 0;
private:
std::map<std::string, Object::Pointer> data;
};
}
#endif /* BERRYSHELL_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryShellEvent.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/berryShellEvent.cpp
index b852419a5f..6e8d726805 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryShellEvent.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryShellEvent.cpp
@@ -1,35 +1,35 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryShellEvent.h"
#include "berryShell.h"
namespace berry
{
ShellEvent::ShellEvent(Shell::Pointer src) :
doit(true), source(src)
{
}
Shell::Pointer ShellEvent::GetSource()
{
return source;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryShellEvent.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryShellEvent.h
index 3a4c764c32..ce9550e6f3 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryShellEvent.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryShellEvent.h
@@ -1,68 +1,68 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYSHELLEVENT_H_
#define BERRYSHELLEVENT_H_
#include <org_blueberry_ui_Export.h>
#include <berryMacros.h>
#include <berryObject.h>
namespace berry {
class Shell;
/**
* Instances of this class are sent as a result of
* operations being performed on shells.
*
* @see ShellListener
* @see <a href="http://www.blueberry.org/swt/">Sample code and further information</a>
*/
class BERRY_UI ShellEvent : public Object {
public:
berryObjectMacro(ShellEvent);
/**
* A flag indicating whether the operation should be allowed.
* Setting this field to <code>false</code> will cancel the operation.
*/
bool doit;
/**
* Constructs a new instance of this class based on the
* information in the given untyped event.
*
* @param e the untyped event containing the information
*/
ShellEvent(SmartPointer<Shell> source) ;
SmartPointer<Shell> GetSource();
private:
SmartPointer<Shell> source;
};
}
#endif /* BERRYSHELLEVENT_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryUIException.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/berryUIException.cpp
index 391e22001a..fa20382642 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryUIException.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryUIException.cpp
@@ -1,29 +1,29 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryUIException.h"
#include <typeinfo>
namespace berry {
POCO_IMPLEMENT_EXCEPTION(UIException, PlatformException, "UI exception");
POCO_IMPLEMENT_EXCEPTION(WorkbenchException, UIException, "Workbench error");
POCO_IMPLEMENT_EXCEPTION(PartInitException, WorkbenchException, "Part initialization error");
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryUIException.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryUIException.h
index 7d4b90e9e5..ee94c0e975 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryUIException.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryUIException.h
@@ -1,40 +1,40 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYUIEXCEPTIONS_H_
#define BERRYUIEXCEPTIONS_H_
#include <org_blueberry_ui_Export.h>
#include <berryPlatformException.h>
namespace berry {
/**
* \ingroup org_blueberry_ui
* @{
*/
POCO_DECLARE_EXCEPTION(BERRY_UI, UIException, PlatformException);
POCO_DECLARE_EXCEPTION(BERRY_UI, WorkbenchException, UIException);
POCO_DECLARE_EXCEPTION(BERRY_UI, PartInitException, WorkbenchException);
/*@}*/
}
#endif /*BERRYUIEXCEPTIONS_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryViewPart.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/berryViewPart.cpp
index dbc9c2dc2a..df965aaafb 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryViewPart.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryViewPart.cpp
@@ -1,64 +1,64 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryViewPart.h"
#include "berryImageDescriptor.h"
#include <Poco/Exception.h>
namespace berry
{
ViewPart::ViewPart()
{
}
void ViewPart::Init(IViewSite::Pointer site, IMemento::Pointer /*memento*/)
{
/*
* Initializes this view with the given view site. A memento is passed to
* the view which contains a snapshot of the views state from a previous
* session. Where possible, the view should try to recreate that state
* within the part controls.
* <p>
* This implementation will ignore the memento and initialize the view in
* a fresh state. Subclasses may override the implementation to perform any
* state restoration as needed.
*/
this->SetSite(site);
}
void ViewPart::SaveState(IMemento::Pointer /*memento*/)
{
// do nothing
}
void ViewPart::CheckSite(IWorkbenchPartSite::Pointer site)
{
WorkbenchPart::CheckSite(site);
if (site.Cast<IViewSite>().IsNull())
throw Poco::AssertionViolationException("The site for a view must be an IViewSite"); //$NON-NLS-1$
}
IViewSite::Pointer ViewPart::GetViewSite()
{
return this->GetSite().Cast<IViewSite>();
}
} // namespace berry
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryViewPart.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryViewPart.h
index 5e0f6c9a20..af979b8bef 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryViewPart.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryViewPart.h
@@ -1,104 +1,104 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYVIEWPART_H_
#define BERRYVIEWPART_H_
#include "berryIViewPart.h"
#include "berryIViewSite.h"
#include "berryWorkbenchPart.h"
#include "berryIMemento.h"
namespace berry {
/**
* \ingroup org_blueberry_ui
*
* Abstract base implementation of all workbench views.
* <p>
* This class should be subclassed by clients wishing to define new views.
* The name of the subclass should be given as the <code>"class"</code>
* attribute in a <code>view</code> extension contributed to the workbench's
* view extension point (named <code>"org.blueberry.ui.views"</code>).
* For example, the plug-in's XML markup might contain:
* <pre>
* &LT;extension point="org.blueberry.ui.views"&GT;
* &LT;view id="com.example.myplugin.view"
* name="My View"
* class="com.example.myplugin.MyView"
* icon="images/eview.gif"
* /&GT;
* &LT;/extension&GT;
* </pre>
* where <code>com.example.myplugin.MyView</code> is the name of the
* <code>ViewPart</code> subclass.
* </p>
* <p>
* Subclasses must implement the following methods:
* <ul>
* <li><code>createPartControl</code> - to create the view's controls </li>
* <li><code>setFocus</code> - to accept focus</li>
* </ul>
* </p>
* <p>
* Subclasses may extend or reimplement the following methods as required:
* <ul>
* <li><code>setInitializationData</code> - extend to provide additional
* initialization when view extension is instantiated</li>
* <li><code>init(IWorkbenchPartSite)</code> - extend to provide additional
* initialization when view is assigned its site</li>
* <li><code>dispose</code> - extend to provide additional cleanup</li>
* <li><code>getAdapter</code> - reimplement to make their view adaptable</li>
* </ul>
* </p>
*/
class BERRY_UI ViewPart : public WorkbenchPart, public IViewPart
{
Q_OBJECT
Q_INTERFACES(berry::IViewPart)
protected:
ViewPart();
/**
* Checks that the given site is valid for this type of part.
* The site for a view must be an <code>IViewSite</code>.
*
* @param site the site to check
* @since 3.1
*/
void CheckSite(IWorkbenchPartSite::Pointer site);
public:
berryObjectMacro(ViewPart);
void Init(IViewSite::Pointer site, IMemento::Pointer memento = IMemento::Pointer(0));
void SaveState(IMemento::Pointer memento);
/*
* Method declared on IViewPart.
*/
IViewSite::Pointer GetViewSite();
};
} // namespace berry
#endif /*BERRYVIEWPART_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryWindow.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/berryWindow.cpp
index 6e18ecee1e..02e679d70e 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryWindow.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryWindow.cpp
@@ -1,530 +1,530 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryWindow.h"
#include "berryConstants.h"
#include "berrySameShellProvider.h"
#include "tweaklets/berryGuiWidgetsTweaklet.h"
namespace berry
{
const int Window::OK = 0;
const int Window::CANCEL = 1;
std::vector<void*> Window::defaultImages = std::vector<void*>();
Window::IExceptionHandler::Pointer Window::exceptionHandler(new DefaultExceptionHandler());
IShellProvider::Pointer Window::defaultModalParent(new DefaultModalParent());
Window::WindowShellListener::WindowShellListener(Window* wnd)
: window(wnd)
{
}
void Window::WindowShellListener::ShellClosed(ShellEvent::Pointer event)
{
event->doit = false; // don't close now
if (window->CanHandleShellCloseEvent())
{
window->HandleShellCloseEvent();
}
}
void Window::DefaultExceptionHandler::HandleException(const std::exception& t)
{
// Try to keep running.
std::cerr << t.what();
}
Shell::Pointer Window::DefaultModalParent::GetShell()
{
Shell::Pointer parent = Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetActiveShell();
// Make sure we don't pick a parent that has a modal child (this can lock the app)
if (parent == 0)
{
// If this is a top-level window, then there must not be any open modal windows.
parent = Window::GetModalChild(Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetShells());
}
else
{
// If we picked a parent with a modal child, use the modal child instead
Shell::Pointer modalChild = Window::GetModalChild(parent->GetShells());
if (modalChild != 0)
{
parent = modalChild;
}
}
return parent;
}
Shell::Pointer Window::GetModalChild(const std::vector<Shell::Pointer>& toSearch)
{
int modal = Constants::APPLICATION_MODAL | Constants::SYSTEM_MODAL | Constants::PRIMARY_MODAL;
size_t size = toSearch.size();
for (size_t i = size - 1; i < size; i--)
{
Shell::Pointer shell = toSearch[i];
// Check if this shell has a modal child
std::vector<Shell::Pointer> children = shell->GetShells();
Shell::Pointer modalChild = GetModalChild(children);
if (modalChild != 0)
{
return modalChild;
}
// If not, check if this shell is modal itself
if (shell->IsVisible() && (shell->GetStyle() & modal) != 0)
{
return shell;
}
}
return Shell::Pointer(0);
}
//void Window::RunEventLoop()
//{
//
// //Use the display provided by the shell if possible
// Display display;
// if (shell == null)
// {
// display = Display.getCurrent();
// }
// else
// {
// display = loopShell.getDisplay();
// }
//
// while (loopShell != null && !loopShell.isDisposed())
// {
// try
// {
// if (!display.readAndDispatch())
// {
// display.sleep();
// }
// } catch (Throwable e)
// {
// exceptionHandler.handleException(e);
// }
// }
// display.update();
//}
Window::Window(Shell::Pointer parentShell)
{
this->parentShell = new SameShellProvider(parentShell);
this->Init();
}
Window::Window(IShellProvider::Pointer shellProvider)
{
poco_assert(shellProvider != 0);
this->parentShell = shellProvider;
this->Init();
}
void Window::Init()
{
this->shellStyle = Constants::SHELL_TRIM;
this->returnCode = OK;
this->block = false;
}
bool Window::CanHandleShellCloseEvent()
{
return true;
}
void Window::ConfigureShell(Shell::Pointer newShell)
{
// The single image version of this code had a comment related to bug
// 46624,
// and some code that did nothing if the stored image was already
// disposed.
// The equivalent in the multi-image version seems to be to remove the
// disposed images from the array passed to the shell.
if (defaultImages.size() > 0)
{
// ArrayList nonDisposedImages = new ArrayList(defaultImages.length);
// for (int i = 0; i < defaultImages.length; ++i)
// {
// if (defaultImages[i] != null && !defaultImages[i].isDisposed())
// {
// nonDisposedImages.add(defaultImages[i]);
// }
// }
//
// if (nonDisposedImages.size() <= 0)
// {
// System.err.println("Window.configureShell: images disposed"); //$NON-NLS-1$
// }
// else
// {
// //Image[] array = new Image[nonDisposedImages.size()];
// nonDisposedImages.toArray(array);
newShell->SetImages(defaultImages);
// }
}
// Layout layout = getLayout();
// if (layout != null)
// {
// newShell.setLayout(layout);
// }
}
//voidWindow::ConstrainShellSize()
//{
// // limit the shell size to the display size
// Rectangle bounds = shell.getBounds();
// Rectangle constrained = getConstrainedShellBounds(bounds);
// if (!bounds.equals(constrained))
// {
// shell.setBounds(constrained);
// }
//}
void* Window::CreateContents(Shell::Pointer parent)
{
// by default, just create a composite
//return new Composite(parent, SWT.NONE);
return parent->GetControl();
}
Shell::Pointer Window::CreateShell()
{
Shell::Pointer newParent = this->GetParentShell();
// if (newParent != 0 && newParent.isDisposed())
// {
// parentShell = new SameShellProvider(null);
// newParent = getParentShell();//Find a better parent
// }
//Create the shell
Shell::Pointer newShell = Tweaklets::Get(GuiWidgetsTweaklet::KEY)->CreateShell(newParent, this->GetShellStyle());
// resizeListener = new Listener() {
// public void handleEvent(Event e) {
// resizeHasOccurred = true;
// }
// };
//newShell.addListener(SWT.Resize, resizeListener);
newShell->SetData(Object::Pointer(this));
//Add a listener
newShell->AddShellListener(this->GetShellListener());
//Set the layout
this->ConfigureShell(newShell);
// //Register for font changes
// if (fontChangeListener == null)
// {
// fontChangeListener = new FontChangeListener();
// }
// JFaceResources.getFontRegistry().addListener(fontChangeListener);
return newShell;
}
void* Window::GetContents()
{
return contents;
}
Point Window::GetInitialLocation(const Point& initialSize)
{
void* parent = Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetParent(shell->GetControl());
Point centerPoint(0,0);
Rectangle parentBounds(0,0,0,0);
if (parent != 0)
{
parentBounds = Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetBounds(parent);
centerPoint.x = parentBounds.x + parentBounds.width/2;
centerPoint.y = parentBounds.y - parentBounds.height/2;
}
else
{
parentBounds = Tweaklets::Get(GuiWidgetsTweaklet::KEY)
->GetScreenSize(Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetPrimaryScreenNumber());
centerPoint.x = parentBounds.width/2;
centerPoint.y = parentBounds.height/2;
}
return Point(centerPoint.x - (initialSize.x / 2),
std::max<int>(parentBounds.y,
std::min<int>(centerPoint.y - (initialSize.y * 2 / 3),
parentBounds.y + parentBounds.height - initialSize.y)));
}
Point Window::GetInitialSize()
{
return shell->ComputeSize(Constants::DEFAULT, Constants::DEFAULT, true);
}
Shell::Pointer Window::GetParentShell()
{
Shell::Pointer parent = parentShell->GetShell();
int modal = Constants::APPLICATION_MODAL | Constants::SYSTEM_MODAL | Constants::PRIMARY_MODAL;
if ((this->GetShellStyle() & modal) != 0)
{
// If this is a modal shell with no parent, pick a shell using defaultModalParent.
if (parent == 0)
{
parent = defaultModalParent->GetShell();
}
}
return parent;
}
IShellListener::Pointer Window::GetShellListener()
{
if (windowShellListener == 0)
windowShellListener = new WindowShellListener(this);
return windowShellListener;
}
int Window::GetShellStyle()
{
return shellStyle;
}
void Window::HandleShellCloseEvent()
{
this->SetReturnCode(CANCEL);
this->Close();
}
void Window::InitializeBounds()
{
// if (resizeListener != null)
// {
// shell.removeListener(SWT.Resize, resizeListener);
// }
// if (resizeHasOccurred)
// { // Check if shell size has been set already.
// return;
// }
Point size = this->GetInitialSize();
Point location = this->GetInitialLocation(size);
shell->SetBounds(this->GetConstrainedShellBounds(Rectangle(location.x, location.y, size.x, size.y)));
}
Rectangle Window::GetConstrainedShellBounds(const Rectangle& preferredSize)
{
Rectangle result(preferredSize);
GuiWidgetsTweaklet* guiTweaklet(Tweaklets::Get(GuiWidgetsTweaklet::KEY));
int screenNum = guiTweaklet->GetClosestScreenNumber(result);
Rectangle bounds(guiTweaklet->GetAvailableScreenSize(screenNum));
if (result.height > bounds.height) {
result.height = bounds.height;
}
if (result.width > bounds.width) {
result.width = bounds.width;
}
result.x = std::max<int>(bounds.x, std::min<int>(result.x, bounds.x
+ bounds.width - result.width));
result.y = std::max<int>(bounds.y, std::min<int>(result.y, bounds.y
+ bounds.height - result.height));
return result;
}
void Window::SetParentShell(Shell::Pointer newParentShell)
{
poco_assert(shell == 0); // "There must not be an existing shell."; //$NON-NLS-1$
parentShell = new SameShellProvider(newParentShell);
}
void Window::SetReturnCode(int code)
{
returnCode = code;
}
void Window::SetShellStyle(int newShellStyle)
{
shellStyle = newShellStyle;
}
bool Window::Close()
{
// BERRY_INFO << "Window::Close()";
// // stop listening for font changes
// if (fontChangeListener != null)
// {
// JFaceResources.getFontRegistry().removeListener(fontChangeListener);
// fontChangeListener = null;
// }
// remove this window from a window manager if it has one
if (windowManager != 0)
{
windowManager->Remove(Window::Pointer(this));
windowManager = 0;
}
if (shell == 0)
{
return true;
}
shell->RemoveShellListener(this->GetShellListener());
shell->SetData(Object::Pointer(0));
// If we "close" the shell recursion will occur.
// Instead, we need to "dispose" the shell to remove it from the
// display.
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->DisposeShell(shell);
shell = 0;
contents = 0;
return true;
}
void Window::Create()
{
shell = this->CreateShell();
contents = this->CreateContents(shell);
//initialize the bounds of the shell to that appropriate for the
// contents
this->InitializeBounds();
}
void* Window::GetDefaultImage()
{
return (defaultImages.size() < 1) ? 0
: defaultImages[0];
}
std::vector<void*> Window::GetDefaultImages()
{
return defaultImages;
}
int Window::GetReturnCode()
{
return returnCode;
}
Shell::Pointer Window::GetShell()
{
return shell;
}
WindowManager* Window::GetWindowManager()
{
return windowManager;
}
int Window::Open()
{
if (shell == 0)
{
// create the window
this->Create();
}
// limit the shell size to the display size
//constrainShellSize();
// open the window
shell->Open(block);
// // run the event loop if specified
// if (block)
// {
// this->RunEventLoop();
// }
return returnCode;
}
void Window::SetBlockOnOpen(bool shouldBlock)
{
block = shouldBlock;
}
void Window::SetDefaultImage(void* image)
{
if (image != 0)
defaultImages.push_back(image);
}
void Window::SetDefaultImages(const std::vector<void*>& images)
{
defaultImages = images;
}
void Window::SetWindowManager(WindowManager* manager)
{
windowManager = manager;
// Code to detect invalid usage
if (manager != 0)
{
std::vector<Window::Pointer> windows = manager->GetWindows();
for (unsigned int i = 0; i < windows.size(); i++)
{
if (windows[i] == this)
{
return;
}
}
manager->Add(Window::Pointer(this));
}
}
void Window::SetExceptionHandler(IExceptionHandler::Pointer handler)
{
if (exceptionHandler == 0)
{
exceptionHandler = handler;
}
}
void Window::SetDefaultModalParent(IShellProvider::Pointer provider)
{
defaultModalParent = provider;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryWindow.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryWindow.h
index 825896b762..a84c444377 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryWindow.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryWindow.h
@@ -1,673 +1,673 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYWINDOW_H_
#define BERRYWINDOW_H_
#include <org_blueberry_ui_Export.h>
#include "berryIShellProvider.h"
#include "berryIShellListener.h"
#include "berryPoint.h"
#include "internal/berryWindowManager.h"
#include "tweaklets/berryGuiWidgetsTweaklet.h"
#include <berryMacros.h>
#include <vector>
namespace berry
{
/**
* A JFace window is an object that has no visual representation (no widgets)
* until it is told to open.
* <p>
* Creating a window involves the following steps:
* <ul>
* <li>creating an instance of a concrete subclass of <code>Window</code>
* </li>
* <li>creating the window's shell and widget tree by calling
* <code>create</code> (optional)</li>
* <li>assigning the window to a window manager using
* <code>WindowManager.add</code> (optional)</li>
* <li>opening the window by calling <code>open</code></li>
* </ul>
* Opening the window will create its shell and widget tree if they have not
* already been created. When the window is closed, the shell and widget tree
* are disposed of and are no longer referenced, and the window is automatically
* removed from its window manager. A window may be reopened.
* </p>
* <p>
* The JFace window framework (this package) consists of this class,
* <code>Window</code>, the abstract base of all windows, and one concrete
* window classes (<code>ApplicationWindow</code>) which may also be
* subclassed. Clients may define additional window subclasses as required.
* </p>
* <p>
* The <code>Window</code> class provides methods that subclasses may
* override to configure the window, including:
* <ul>
* <li><code>close</code>- extend to free other SWT resources</li>
* <li><code>configureShell</code>- extend or reimplement to set shell
* properties before window opens</li>
* <li><code>createContents</code>- extend or reimplement to create controls
* before window opens</li>
* <li><code>getInitialSize</code>- reimplement to give the initial size for
* the shell</li>
* <li><code>getInitialLocation</code>- reimplement to give the initial
* location for the shell</li>
* <li><code>getShellListener</code>- extend or reimplement to receive shell
* events</li>
* <li><code>handleFontChange</code>- reimplement to respond to font changes
* </li>
* <li><code>handleShellCloseEvent</code>- extend or reimplement to handle
* shell closings</li>
* </ul>
* </p>
*/
class BERRY_UI Window: public IShellProvider
{
public:
berryObjectMacro(Window);
/**
* Standard return code constant (value 0) indicating that the window was
* opened.
*
* @see #open
*/
static const int OK; // = 0;
/**
* Standard return code constant (value 1) indicating that the window was
* canceled.
*
* @see #open
*/
static const int CANCEL; // = 1;
/**
* An array of images to be used for the window. It is expected that the
* array will contain the same icon rendered at different resolutions.
*/
static std::vector<void*> defaultImages;
/**
* This interface defines a Exception Handler which can be set as a global
* handler and will be called if an exception happens in the event loop.
*/
struct IExceptionHandler: public Object
{
berryObjectMacro(IExceptionHandler)
;
/**
* Handle the exception.
*
* @param t
* The exception that occured.
*/
virtual void HandleException(const std::exception& t) = 0;
};
private:
struct WindowShellListener : public IShellListener
{
WindowShellListener(Window* wnd);
void ShellClosed(ShellEvent::Pointer event);
private:
Window* window;
};
IShellListener::Pointer windowShellListener;
/**
* Defines a default exception handler.
*/
struct DefaultExceptionHandler: public IExceptionHandler
{
/*
* (non-Javadoc)
*
* @see org.blueberry.jface.window.Window.IExceptionHandler#handleException(java.lang.Throwable)
*/
void HandleException(const std::exception& t);
};
/**
* The exception handler for this application.
*/
static IExceptionHandler::Pointer exceptionHandler;
/**
* Object used to locate the default parent for modal shells
*/
struct DefaultModalParent: public IShellProvider
{
Shell::Pointer GetShell();
};
friend struct DefaultModalParent;
static IShellProvider::Pointer defaultModalParent;
/**
* Object that returns the parent shell.
*/
IShellProvider::Pointer parentShell;
/**
* Shell style bits.
*
* @see #setShellStyle
*/
int shellStyle; // = Constants::SHELL_TRIM;
/**
* Window manager, or <code>null</code> if none.
*
* @see #setWindowManager
*/
WindowManager* windowManager;
/**
* Window shell, or <code>null</code> if none.
*/
Shell::Pointer shell;
/**
* Top level SWT control, or <code>null</code> if none
*/
void* contents;
/**
* Window return code; initially <code>OK</code>.
*
* @see #setReturnCode
*/
int returnCode; // = OK;
/**
* <code>true</code> if the <code>open</code> method should not return
* until the window closes, and <code>false</code> if the
* <code>open</code> method should return immediately; initially
* <code>false</code> (non-blocking).
*
* @see #setBlockOnOpen
*/
bool block; // = false;
// /**
// * Internal class for informing this window when fonts change.
// */
// class FontChangeListener implements IPropertyChangeListener {
// public void propertyChange(PropertyChangeEvent event) {
// handleFontChange(event);
// }
// }
// /**
// * Internal font change listener.
// */
// private FontChangeListener fontChangeListener;
/**
* Internal fields to detect if shell size has been set
*/
//bool resizeHasOccurred = false;
//Listener resizeListener;
/**
* Returns the most specific modal child from the given list of Shells.
*
* @param toSearch shells to search for modal children
* @return the most specific modal child, or null if none
*
* @since 3.1
*/
static Shell::Pointer GetModalChild(
const std::vector<Shell::Pointer>& toSearch);
/**
* Runs the event loop for the given shell.
*
* @param loopShell
* the shell
*/
//void RunEventLoop();
protected:
/**
* Creates a window instance, whose shell will be created under the given
* parent shell. Note that the window will have no visual representation
* until it is told to open. By default, <code>open</code> does not block.
*
* @param parentShell
* the parent shell, or <code>null</code> to create a top-level
* shell. Try passing "(Shell)null" to this method instead of "null"
* if your compiler complains about an ambiguity error.
* @see #setBlockOnOpen
* @see #getDefaultOrientation()
*/
Window(Shell::Pointer parentShell);
/**
* Creates a new window which will create its shell as a child of whatever
* the given shellProvider returns.
*
* @param shellProvider object that will return the current parent shell. Not null.
*
* @since 3.1
*/
Window(IShellProvider::Pointer shellProvider);
/**
* Given the desired position of the window, this method returns an adjusted
* position such that the window is no larger than its monitor, and does not
* extend beyond the edge of the monitor. This is used for computing the
* initial window position, and subclasses can use this as a utility method
* if they want to limit the region in which the window may be moved.
*
* @param preferredSize
* the preferred position of the window
* @return a rectangle as close as possible to preferredSize that does not
* extend outside the monitor
*
*/
Rectangle GetConstrainedShellBounds(const Rectangle& preferredSize);
/**
* Initializes this windows variables
*/
virtual void Init();
/**
* Determines if the window should handle the close event or do nothing.
* <p>
* The default implementation of this framework method returns
* <code>true</code>, which will allow the
* <code>handleShellCloseEvent</code> method to be called. Subclasses may
* extend or reimplement.
* </p>
*
* @return whether the window should handle the close event.
*/
virtual bool CanHandleShellCloseEvent();
/**
* Configures the given shell in preparation for opening this window in it.
* <p>
* The default implementation of this framework method sets the shell's
* image and gives it a grid layout. Subclasses may extend or reimplement.
* </p>
*
* @param newShell
* the shell
*/
virtual void ConfigureShell(Shell::Pointer newShell);
/**
* Constrain the shell size to be no larger than the display bounds.
*
* @since 2.0
*/
//void ConstrainShellSize();
/**
* Creates and returns this window's contents. Subclasses may attach any
* number of children to the parent. As a convenience, the return value of
* this method will be remembered and returned by subsequent calls to
* getContents(). Subclasses may modify the parent's layout if they overload
* getLayout() to return null.
*
* <p>
* It is common practise to create and return a single composite that
* contains the entire window contents.
* </p>
*
* <p>
* The default implementation of this framework method creates an instance
* of <code>Composite</code>. Subclasses may override.
* </p>
*
* @param parent
* the parent composite for the controls in this window. The type
* of layout used is determined by getLayout()
*
* @return the control that will be returned by subsequent calls to
* getContents()
*/
virtual void* CreateContents(Shell::Pointer parent);
/**
* Creates and returns this window's shell.
* <p>
* The default implementation of this framework method creates a new shell
* and configures it using <code/>configureShell</code>. Rather than
* override this method, subclasses should instead override
* <code/>configureShell</code>.
* </p>
*
* @return the shell
*/
virtual Shell::Pointer CreateShell();
/**
* Returns the top level control for this window. The parent of this control
* is the shell.
*
* @return the top level control, or <code>null</code> if this window's
* control has not been created yet
*/
virtual void* GetContents();
/**
* Returns the initial location to use for the shell. The default
* implementation centers the shell horizontally (1/2 of the difference to
* the left and 1/2 to the right) and vertically (1/3 above and 2/3 below)
* relative to the parent shell, or display bounds if there is no parent
* shell.
*
* @param initialSize
* the initial size of the shell, as returned by
* <code>getInitialSize</code>.
* @return the initial location of the shell
*/
virtual Point GetInitialLocation(const Point& initialSize);
/**
* Returns the initial size to use for the shell. The default implementation
* returns the preferred size of the shell, using
* <code>Shell.computeSize(SWT.DEFAULT, SWT.DEFAULT, true)</code>.
*
* @return the initial size of the shell
*/
virtual Point GetInitialSize();
/**
* Returns parent shell, under which this window's shell is created.
*
* @return the parent shell, or <code>null</code> if there is no parent
* shell
*/
Shell::Pointer GetParentShell();
/**
* Returns a shell listener. This shell listener gets registered with this
* window's shell.
* <p>
* The default implementation of this framework method returns a new
* listener that makes this window the active window for its window manager
* (if it has one) when the shell is activated, and calls the framework
* method <code>handleShellCloseEvent</code> when the shell is closed.
* Subclasses may extend or reimplement.
* </p>
*
* @return a shell listener
*/
virtual IShellListener::Pointer GetShellListener();
/**
* Returns the shell style bits.
* <p>
* The default value is <code>SWT.CLOSE|SWT.MIN|SWT.MAX|SWT.RESIZE</code>.
* Subclassers should call <code>setShellStyle</code> to change this
* value, rather than overriding this method.
* </p>
*
* @return the shell style bits
*/
int GetShellStyle();
/**
* Notifies that the window's close button was pressed, the close menu was
* selected, or the ESCAPE key pressed.
* <p>
* The default implementation of this framework method sets the window's
* return code to <code>CANCEL</code> and closes the window using
* <code>close</code>. Subclasses may extend or reimplement.
* </p>
*/
virtual void HandleShellCloseEvent();
/**
* Initializes the location and size of this window's SWT shell after it has
* been created.
* <p>
* This framework method is called by the <code>create</code> framework
* method. The default implementation calls <code>getInitialSize</code>
* and <code>getInitialLocation</code> and passes the results to
* <code>Shell.setBounds</code>. This is only done if the bounds of the
* shell have not already been modified. Subclasses may extend or
* reimplement.
* </p>
*/
virtual void InitializeBounds();
/**
* Changes the parent shell. This is only safe to use when the shell is not
* yet realized (i.e., created). Once the shell is created, it must be
* disposed (i.e., closed) before this method can be called.
*
* @param newParentShell
* The new parent shell; this value may be <code>null</code> if
* there is to be no parent.
* @since 3.1
*/
void SetParentShell(Shell::Pointer newParentShell);
/**
* Sets this window's return code. The return code is automatically returned
* by <code>open</code> if block on open is enabled. For non-blocking
* opens, the return code needs to be retrieved manually using
* <code>getReturnCode</code>.
*
* @param code
* the return code
*/
void SetReturnCode(int code);
/**
* Sets the shell style bits. This method has no effect after the shell is
* created.
* <p>
* The shell style bits are used by the framework method
* <code>createShell</code> when creating this window's shell.
* </p>
*
* @param newShellStyle
* the new shell style bits
*/
void SetShellStyle(int newShellStyle);
public:
/**
* Closes this window, disposes its shell, and removes this window from its
* window manager (if it has one).
* <p>
* This framework method may be extended (<code>super.close</code> must
* be called).
* </p>
* <p>
* Note that in order to prevent recursive calls to this method
* it does not call <code>Shell#close()</code>. As a result <code>ShellListener</code>s
* will not receive a <code>shellClosed</code> event.
* </p>
*
* @return <code>true</code> if the window is (or was already) closed, and
* <code>false</code> if it is still open
*/
virtual bool Close();
/**
* Creates this window's widgetry in a new top-level shell.
* <p>
* The default implementation of this framework method creates this window's
* shell (by calling <code>createShell</code>), and its controls (by
* calling <code>createContents</code>), then initializes this window's
* shell bounds (by calling <code>initializeBounds</code>).
* </p>
*/
virtual void Create();
/**
* Returns the default image. This is the image that will be used for
* windows that have no shell image at the time they are opened. There is no
* default image unless one is installed via <code>setDefaultImage</code>.
*
* @return the default image, or <code>null</code> if none
* @see #setDefaultImage
*/
static void* GetDefaultImage();
/**
* Returns the array of default images to use for newly opened windows. It
* is expected that the array will contain the same icon rendered at
* different resolutions.
*
* @see org.blueberry.swt.widgets.Decorations#setImages(org.blueberry.swt.graphics.Image[])
*
* @return the array of images to be used when a new window is opened
* @see #setDefaultImages
* @since 3.0
*/
static std::vector<void*> GetDefaultImages();
/**
* Returns this window's return code. A window's return codes are
* window-specific, although two standard return codes are predefined:
* <code>OK</code> and <code>CANCEL</code>.
*
* @return the return code
*/
int GetReturnCode();
/**
* Returns this window's shell.
*
* @return this window's shell, or <code>null</code> if this window's
* shell has not been created yet
*/
Shell::Pointer GetShell();
/**
* Returns the window manager of this window.
*
* @return the WindowManager, or <code>null</code> if none
*/
WindowManager* GetWindowManager();
/**
* Opens this window, creating it first if it has not yet been created.
* <p>
* If this window has been configured to block on open (
* <code>setBlockOnOpen</code>), this method waits until the window is
* closed by the end user, and then it returns the window's return code;
* otherwise, this method returns immediately. A window's return codes are
* window-specific, although two standard return codes are predefined:
* <code>OK</code> and <code>CANCEL</code>.
* </p>
*
* @return the return code
*
* @see #create()
*/
int Open();
/**
* Sets whether the <code>open</code> method should block until the window
* closes.
*
* @param shouldBlock
* <code>true</code> if the <code>open</code> method should
* not return until the window closes, and <code>false</code>
* if the <code>open</code> method should return immediately
*/
void SetBlockOnOpen(bool shouldBlock);
/**
* Sets the default image. This is the image that will be used for windows
* that have no shell image at the time they are opened. There is no default
* image unless one is installed via this method.
*
* @param image
* the default image, or <code>null</code> if none
*/
static void SetDefaultImage(void* image);
/**
* Sets the array of default images to use for newly opened windows. It is
* expected that the array will contain the same icon rendered at different
* resolutions.
*
* @see org.blueberry.swt.widgets.Decorations#setImages(org.blueberry.swt.graphics.Image[])
*
* @param images
* the array of images to be used when this window is opened
* @since 3.0
*/
static void SetDefaultImages(const std::vector<void*>& images);
/**
* Sets the window manager of this window.
* <p>
* Note that this method is used by <code>WindowManager</code> to maintain
* a backpointer. Clients must not call the method directly.
* </p>
*
* @param manager
* the window manager, or <code>null</code> if none
*/
void SetWindowManager(WindowManager* manager);
/**
* Sets the exception handler for this application.
* <p>
* Note that the handler may only be set once. Subsequent calls to this method will be
* ignored.
* <p>
*
* @param handler
* the exception handler for the application.
*/
static void SetExceptionHandler(IExceptionHandler::Pointer handler);
/**
* Sets the default parent for modal Windows. This will be used to locate
* the parent for any modal Window constructed with a null parent.
*
* @param provider shell provider that will be used to locate the parent shell
* whenever a Window is created with a null parent
* @since 3.1
*/
static void SetDefaultModalParent(IShellProvider::Pointer provider);
};
}
#endif /* BERRYWINDOW_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryWorkbenchPart.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/berryWorkbenchPart.cpp
index 85a1958008..d3beff159e 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryWorkbenchPart.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryWorkbenchPart.cpp
@@ -1,320 +1,320 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryWorkbenchPart.h"
#include "berryAbstractUIPlugin.h"
#include "berryIWorkbenchPartConstants.h"
#include "berryImageDescriptor.h"
#include <berrySafeRunner.h>
#include <util/berrySafeRunnable.h>
#include "internal/berryWorkbenchPlugin.h"
#include <berryObjectString.h>
#include <berryObjects.h>
namespace berry
{
class PropChangedRunnable : public SafeRunnable
{
public:
berryObjectMacro(PropChangedRunnable)
IPropertyChangeListener::Events::EventType::AbstractDelegate* delegate;
PropChangedRunnable(PropertyChangeEvent::Pointer event)
: event(event)
{}
void Run()
{
delegate->Execute(event);
}
private:
PropertyChangeEvent::Pointer event;
};
WorkbenchPart::~WorkbenchPart()
{
if (m_TitleImage && m_ImageDescriptor)
m_ImageDescriptor->DestroyImage(m_TitleImage);
}
WorkbenchPart::WorkbenchPart()
:m_Title(""),
m_TitleImage(0),
m_ToolTip(""),
m_PartName(""),
m_ContentDescription("")
{
}
void WorkbenchPart::InternalSetContentDescription(
const std::string& description)
{
//assert(description != 0)
//Do not send changes if they are the same
if (this->m_ContentDescription == description)
{
return;
}
this->m_ContentDescription = description;
this->FirePropertyChange(IWorkbenchPartConstants::PROP_CONTENT_DESCRIPTION);
}
void WorkbenchPart::InternalSetPartName(const std::string& partName)
{
//partName = Util.safeString(partName);
//assert(partName != 0);
//Do not send changes if they are the same
if (this->m_PartName == partName)
{
return;
}
this->m_PartName = partName;
this->FirePropertyChange(IWorkbenchPartConstants::PROP_PART_NAME);
}
// IConfigurationElement* GetConfigurationElement()
// {
// return m_ConfigElement;
// }
// protected Image getDefaultImage() {
// return PlatformUI.getWorkbench().getSharedImages().getImage(
// ISharedImages.IMG_DEF_VIEW);
// }
void WorkbenchPart::SetSite(IWorkbenchPartSite::Pointer site)
{
this->CheckSite(site);
this->m_PartSite = site;
}
void WorkbenchPart::CheckSite(IWorkbenchPartSite::Pointer /*site*/)
{
// do nothing
}
void WorkbenchPart::SetTitleImage(void* titleImage)
{
//assert(titleImage == 0 || !titleImage.isDisposed());
//Do not send changes if they are the same
if (this->m_TitleImage == titleImage)
{
return;
}
m_ImageDescriptor->DestroyImage(m_TitleImage);
this->m_TitleImage = titleImage;
this->FirePropertyChange(IWorkbenchPartConstants::PROP_TITLE);
if (m_ImageDescriptor) {
//JFaceResources.getResources().destroyImage(imageDescriptor);
m_ImageDescriptor = 0;
}
}
void WorkbenchPart::SetTitleToolTip(const std::string& toolTip)
{
//toolTip = Util.safeString(toolTip);
//Do not send changes if they are the same
if (this->m_ToolTip == toolTip)
{
return;
}
this->m_ToolTip = toolTip;
this->FirePropertyChange(IWorkbenchPartConstants::PROP_TITLE);
}
void WorkbenchPart::SetPartName(const std::string& partName)
{
InternalSetPartName(partName);
//setDefaultTitle();
}
void WorkbenchPart::SetContentDescription(const std::string& description)
{
InternalSetContentDescription(description);
//setDefaultTitle();
}
void WorkbenchPart::FirePropertyChanged(const std::string& key,
const std::string& oldValue, const std::string& newValue)
{
ObjectString::Pointer objOldVal(new ObjectString(oldValue));
ObjectString::Pointer objNewVal(new ObjectString(newValue));
Object::Pointer source(this);
PropertyChangeEvent::Pointer event(
new PropertyChangeEvent(source, key, objOldVal, objNewVal));
typedef IPropertyChangeListener::Events::EventType::ListenerList ListenerList;
PropChangedRunnable::Pointer runnable(new PropChangedRunnable(event));
const ListenerList& listeners =
partChangeEvents.propertyChange.GetListeners();
for (ListenerList::const_iterator iter = listeners.begin(); iter
!= listeners.end(); ++iter)
{
runnable->delegate = *iter;
SafeRunner::Run(runnable);
}
}
void WorkbenchPart::FirePropertyChange(int propertyId)
{
ObjectInt::Pointer val(new ObjectInt(propertyId));
Object::Pointer source(this);
PropertyChangeEvent::Pointer event(
new PropertyChangeEvent(source, IWorkbenchPartConstants::INTEGER_PROPERTY, val, val));
typedef IPropertyChangeListener::Events::EventType::ListenerList ListenerList;
PropChangedRunnable::Pointer runnable(new PropChangedRunnable(event));
const ListenerList& listeners =
partChangeEvents.propertyChange.GetListeners();
for (ListenerList::const_iterator iter = listeners.begin(); iter
!= listeners.end(); ++iter)
{
runnable->delegate = *iter;
SafeRunner::Run(runnable);
}
}
void WorkbenchPart::AddPropertyListener(IPropertyChangeListener::Pointer l)
{
partChangeEvents.AddListener(l);
}
void WorkbenchPart::RemovePropertyListener(IPropertyChangeListener::Pointer l)
{
partChangeEvents.RemoveListener(l);
}
void WorkbenchPart::SetPartProperty(const std::string& key,
const std::string& value)
{
std::map<std::string, std::string>::iterator iter = partProperties.find(
key);
std::string oldValue;
if (iter != partProperties.end())
oldValue = iter->second;
if (value == "")
{
partProperties.erase(key);
}
else
{
partProperties.insert(std::make_pair(key, value));
}
this->FirePropertyChanged(key, oldValue, value);
}
std::string WorkbenchPart::GetPartProperty(const std::string& key) const
{
std::map<std::string, std::string>::const_iterator itr = partProperties.find(key);
if (itr == partProperties.end()) return "";
return itr->second;
}
const std::map<std::string, std::string>& WorkbenchPart::GetPartProperties() const
{
return partProperties;
}
IWorkbenchPartSite::Pointer WorkbenchPart::GetSite() const
{
return this->m_PartSite;
}
std::string WorkbenchPart::GetPartName() const
{
return this->m_PartName;
}
std::string WorkbenchPart::GetContentDescription() const
{
return this->m_ContentDescription;
}
void* WorkbenchPart::GetTitleImage() const
{
if (this->m_TitleImage != 0)
{
return this->m_TitleImage;
}
return 0;
//return GetDefaultImage();
}
std::string WorkbenchPart::GetTitleToolTip() const
{
return this->m_ToolTip;
}
void WorkbenchPart::SetInitializationData(IConfigurationElement::Pointer cfig,
const std::string& /*propertyName*/, Object::Pointer /*data*/)
{
// Save config element.
m_ConfigElement = cfig;
// Part name and title.
cfig->GetAttribute("name", m_PartName);
m_Title = m_PartName;
// Icon.
std::string strIcon;
cfig->GetAttribute("icon", strIcon);//$NON-NLS-1$
if (strIcon.empty()) {
return;
}
m_ImageDescriptor = AbstractUICTKPlugin::ImageDescriptorFromPlugin(
m_ConfigElement->GetContributor(), strIcon);
if (!m_ImageDescriptor)
{
// try legacy BlueBerry code
m_ImageDescriptor = AbstractUIPlugin::ImageDescriptorFromPlugin(
m_ConfigElement->GetContributor(), strIcon);
}
if (!m_ImageDescriptor) {
return;
}
//titleImage = JFaceResources.getResources().createImageWithDefault(imageDescriptor);
m_TitleImage = m_ImageDescriptor->CreateImage();
}
} // namespace berry
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryWorkbenchPart.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryWorkbenchPart.h
index d58e069fc4..37ae3377ea 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryWorkbenchPart.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryWorkbenchPart.h
@@ -1,257 +1,257 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 __BERRY_WORKBENCH_PART_H__
#define __BERRY_WORKBENCH_PART_H__
#include "berryIWorkbenchPart.h"
#include "berryIWorkbenchPartSite.h"
#include <berryIConfigurationElement.h>
#include <berryIExecutableExtension.h>
#include "berryImageDescriptor.h"
namespace berry {
/**
* \ingroup org_blueberry_ui
*
* Abstract base implementation of all workbench parts.
* <p>
* This class is not intended to be subclassed by clients outside this
* package; clients should instead subclass <code>ViewPart</code> or
* <code>EditorPart</code>.
* </p>
*
* @see org.blueberry.ui.part.ViewPart
* @see org.blueberry.ui.part.EditorPart
* @noextend This class is not intended to be subclassed by clients.
*/
class BERRY_UI WorkbenchPart : public QObject,
public virtual IWorkbenchPart, public IExecutableExtension
{
Q_OBJECT
Q_INTERFACES(berry::IExecutableExtension)
public:
berryObjectMacro(WorkbenchPart);
~WorkbenchPart();
private:
std::string m_Title;
SmartPointer<ImageDescriptor> m_ImageDescriptor;
void* m_TitleImage;
std::string m_ToolTip;
IConfigurationElement::Pointer m_ConfigElement;
IWorkbenchPartSite::Pointer m_PartSite;
std::string m_PartName;
std::string m_ContentDescription;
std::map<std::string, std::string> partProperties;
IPropertyChangeListener::Events partChangeEvents;
void InternalSetContentDescription(const std::string& description);
void InternalSetPartName(const std::string& partName);
protected:
WorkbenchPart();
/**
* Returns the configuration element for this part. The configuration element
* comes from the plug-in registry entry for the extension defining this part.
*
* @return the configuration element for this part
*/
IConfigurationElement::Pointer GetConfigurationElement() const
{
return m_ConfigElement;
}
/**
* Returns the default title image.
*
* @return the default image
*/
// protected Image getDefaultImage() {
// return PlatformUI.getWorkbench().getSharedImages().getImage(
// ISharedImages.IMG_DEF_VIEW);
// }
/**
* Sets the part site.
* <p>
* Subclasses must invoke this method from <code>IEditorPart.init</code>
* and <code>IViewPart.init</code>.
*
* @param site the workbench part site
*/
void SetSite(IWorkbenchPartSite::Pointer site);
/**
* Checks that the given site is valid for this type of part.
* The default implementation does nothing.
*
* @param site the site to check
*/
virtual void CheckSite(IWorkbenchPartSite::Pointer site);
/**
* Sets or clears the title image of this part.
*
* @param titleImage the title image, or <code>null</code> to clear
*/
virtual void SetTitleImage(void* titleImage);
/**
* Sets or clears the title tool tip text of this part. Clients should
* call this method instead of overriding <code>getTitleToolTip</code>
*
* @param toolTip the new tool tip text, or <code>null</code> to clear
*/
virtual void SetTitleToolTip(const std::string& toolTip);
/**
* Sets the name of this part. The name will be shown in the tab area for
* the part. Clients should call this method instead of overriding getPartName.
* Setting this to the empty string will cause a default part name to be used.
*
* @param partName the part name, as it should be displayed in tabs.
*/
virtual void SetPartName(const std::string& partName);
/**
* Sets the content description for this part. The content description is typically
* a short string describing the current contents of the part. Setting this to the
* empty string will cause a default content description to be used. Clients should
* call this method instead of overriding getContentDescription(). For views, the
* content description is shown (by default) in a line near the top of the view. For
* editors, the content description is shown beside the part name when showing a
* list of editors. If the editor is open on a file, this typically contains the path
* to the input file, without the filename or trailing slash.
*
* @param description the content description
*/
virtual void SetContentDescription(const std::string& description);
void FirePropertyChanged(const std::string& key,
const std::string& oldValue, const std::string& newValue);
void FirePropertyChange(int propertyId);
public:
/* (non-Javadoc)
* Method declared on IWorkbenchPart.
*/
void AddPropertyListener(IPropertyChangeListener::Pointer l);
void RemovePropertyListener(IPropertyChangeListener::Pointer l);
void SetPartProperty(const std::string& key, const std::string& value);
/* (non-Javadoc)
* @see org.blueberry.ui.IWorkbenchPart3#getPartProperty(java.lang.String)
*/
std::string GetPartProperty(const std::string& key) const;
/* (non-Javadoc)
* @see org.blueberry.ui.IWorkbenchPart3#getPartProperties()
*/
const std::map<std::string, std::string>& GetPartProperties() const;
/**
* {@inheritDoc}
* The <code>WorkbenchPart</code> implementation of this
* <code>IExecutableExtension</code> records the configuration element in
* and internal state variable (accessible via <code>getConfigElement</code>).
* It also loads the title image, if one is specified in the configuration element.
* Subclasses may extend.
*
* Should not be called by clients. It is called by the core plugin when creating
* this executable extension.
*/
void SetInitializationData(IConfigurationElement::Pointer cfig,
const std::string& propertyName, Object::Pointer data);
/*
* Creates the controls for this workbench part.
* <p>
* Subclasses must implement this method. For a detailed description of the
* requirements see <code>IWorkbenchPart</code>
* </p>
*
* @param parent the parent control
* @see IWorkbenchPart
*/
virtual void CreatePartControl(void* parent) = 0;
/* (non-Javadoc)
* Asks this part to take focus within the workbench.
* <p>
* Subclasses must implement this method. For a detailed description of the
* requirements see <code>IWorkbenchPart</code>
* </p>
*
* @see IWorkbenchPart
*/
virtual void SetFocus() = 0;
/*
* Method declared on IWorkbenchPart.
*/
IWorkbenchPartSite::Pointer GetSite() const;
/**
* {@inheritDoc}
* <p>
* It is considered bad practise to overload or extend this method.
* Parts should call setPartName to change their part name.
* </p>
*/
std::string GetPartName() const;
/**
* {@inheritDoc}
* <p>
* It is considered bad practise to overload or extend this method.
* Parts should call setContentDescription to change their content description.
* </p>
*/
std::string GetContentDescription() const;
/* (non-Javadoc)
* Method declared on IWorkbenchPart.
*/
void* GetTitleImage() const;
/* (non-Javadoc)
* Gets the title tool tip text of this part.
*
* @return the tool tip text
*/
std::string GetTitleToolTip() const;
};
} // namespace berry
#endif // __BERRY_WORKBENCH_PART_H__
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryWorkbenchPreferenceConstants.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/berryWorkbenchPreferenceConstants.cpp
index ae844a179c..04728d652d 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryWorkbenchPreferenceConstants.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryWorkbenchPreferenceConstants.cpp
@@ -1,115 +1,115 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryWorkbenchPreferenceConstants.h"
namespace berry
{
const std::string WorkbenchPreferenceConstants::LINK_NAVIGATOR_TO_EDITOR =
"LINK_NAVIGATOR_TO_EDITOR";
const std::string WorkbenchPreferenceConstants::OPEN_NEW_PERSPECTIVE =
"OPEN_NEW_PERSPECTIVE";
const std::string WorkbenchPreferenceConstants::OPEN_PERSPECTIVE_WINDOW =
"OPEN_PERSPECTIVE_WINDOW";
const std::string WorkbenchPreferenceConstants::OPEN_PERSPECTIVE_PAGE =
"OPEN_PERSPECTIVE_PAGE";
const std::string WorkbenchPreferenceConstants::OPEN_PERSPECTIVE_REPLACE =
"OPEN_PERSPECTIVE_REPLACE";
const std::string WorkbenchPreferenceConstants::NO_NEW_PERSPECTIVE =
"NO_NEW_PERSPECTIVE";
const std::string WorkbenchPreferenceConstants::DEFAULT_PERSPECTIVE_ID =
"defaultPerspectiveId";
const std::string WorkbenchPreferenceConstants::PRESENTATION_FACTORY_ID =
"presentationFactoryId";
const std::string WorkbenchPreferenceConstants::DOCK_PERSPECTIVE_BAR =
"DOCK_PERSPECTIVE_BAR";
const std::string WorkbenchPreferenceConstants::PERSPECTIVE_BAR_SIZE =
"PERSPECTIVE_BAR_SIZE";
const std::string WorkbenchPreferenceConstants::INITIAL_FAST_VIEW_BAR_LOCATION =
"initialFastViewBarLocation";
const std::string WorkbenchPreferenceConstants::PREFERRED_SASH_LAYOUT =
"preferredSashLayout";
const std::string WorkbenchPreferenceConstants::TOP_RIGHT = "topRight";
const std::string WorkbenchPreferenceConstants::TOP_LEFT = "topLeft";
const std::string WorkbenchPreferenceConstants::LEFT = "left";
const std::string WorkbenchPreferenceConstants::BOTTOM = "bottom";
const std::string WorkbenchPreferenceConstants::RIGHT = "right";
const std::string WorkbenchPreferenceConstants::SHOW_INTRO = "showIntro";
const std::string WorkbenchPreferenceConstants::SHOW_TRADITIONAL_STYLE_TABS =
"SHOW_TRADITIONAL_STYLE_TABS";
const std::string WorkbenchPreferenceConstants::SHOW_TEXT_ON_PERSPECTIVE_BAR =
"SHOW_TEXT_ON_PERSPECTIVE_BAR";
const std::string WorkbenchPreferenceConstants::SHOW_OPEN_ON_PERSPECTIVE_BAR =
"SHOW_OPEN_ON_PERSPECTIVE_BAR";
const std::string WorkbenchPreferenceConstants::SHOW_OTHER_IN_PERSPECTIVE_MENU =
"SHOW_OTHER_IN_PERSPECTIVE_MENU";
const std::string WorkbenchPreferenceConstants::HELP_CONTENTS_ACTION_TEXT =
"helpContentsActionText";
const std::string WorkbenchPreferenceConstants::HELP_SEARCH_ACTION_TEXT =
"helpSearchActionText";
const std::string WorkbenchPreferenceConstants::DYNAMIC_HELP_ACTION_TEXT =
"dynamicHelpActionText";
const std::string WorkbenchPreferenceConstants::ENABLE_ANIMATIONS =
"ENABLE_ANIMATIONS";
const std::string WorkbenchPreferenceConstants::USE_COLORED_LABELS =
"USE_COLORED_LABELS";
const std::string WorkbenchPreferenceConstants::KEY_CONFIGURATION_ID =
"KEY_CONFIGURATION_ID";
const std::string WorkbenchPreferenceConstants::EDITOR_MINIMUM_CHARACTERS =
"EDITOR_MINIMUM_CHARACTERS";
const std::string WorkbenchPreferenceConstants::VIEW_MINIMUM_CHARACTERS =
"VIEW_MINIMUM_CHARACTERS";
const std::string WorkbenchPreferenceConstants::SHOW_SYSTEM_JOBS =
"SHOW_SYSTEM_JOBS";
const std::string WorkbenchPreferenceConstants::CURRENT_THEME_ID =
"CURRENT_THEME_ID";
const std::string WorkbenchPreferenceConstants::CLOSE_EDITORS_ON_EXIT =
"CLOSE_EDITORS_ON_EXIT";
const std::string WorkbenchPreferenceConstants::SHOW_PROGRESS_ON_STARTUP =
"SHOW_PROGRESS_ON_STARTUP";
const std::string WorkbenchPreferenceConstants::SHOW_MEMORY_MONITOR =
"SHOW_MEMORY_MONITOR";
const std::string
WorkbenchPreferenceConstants::USE_WINDOW_WORKING_SET_BY_DEFAULT =
"USE_WINDOW_WORKING_SET_BY_DEFAULT";
const std::string WorkbenchPreferenceConstants::SHOW_FILTERED_TEXTS =
"SHOW_FILTERED_TEXTS";
const std::string WorkbenchPreferenceConstants::ENABLE_DETACHED_VIEWS =
"ENABLE_DETACHED_VIEWS";
const std::string
WorkbenchPreferenceConstants::PROMPT_WHEN_SAVEABLE_STILL_OPEN =
"PROMPT_WHEN_SAVEABLE_STILL_OPEN";
const std::string WorkbenchPreferenceConstants::PERSPECTIVE_BAR_EXTRAS =
"PERSPECTIVE_BAR_EXTRAS";
const std::string WorkbenchPreferenceConstants::LOCK_TRIM = "LOCK_TRIM";
const std::string WorkbenchPreferenceConstants::ENABLE_NEW_MIN_MAX =
"ENABLE_MIN_MAX";
const std::string WorkbenchPreferenceConstants::DISABLE_NEW_FAST_VIEW =
"disableNewFastView";
const std::string
WorkbenchPreferenceConstants::ENABLE_32_STICKY_CLOSE_BEHAVIOR =
"ENABLE_32_STICKY_CLOSE_BEHAVIOR";
const std::string WorkbenchPreferenceConstants::VIEW_TAB_POSITION =
"VIEW_TAB_POSITION";
const std::string WorkbenchPreferenceConstants::EDITOR_TAB_POSITION =
"EDITOR_TAB_POSITION";
const std::string WorkbenchPreferenceConstants::SHOW_MULTIPLE_EDITOR_TABS =
"SHOW_MULTIPLE_EDITOR_TABS";
const std::string WorkbenchPreferenceConstants::DISABLE_OPEN_EDITOR_IN_PLACE =
"DISABLE_OPEN_EDITOR_IN_PLACE";
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryWorkbenchPreferenceConstants.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryWorkbenchPreferenceConstants.h
index 51c845e9ba..178f1002c4 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryWorkbenchPreferenceConstants.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryWorkbenchPreferenceConstants.h
@@ -1,570 +1,570 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYWORKBENCHPREFERENCECONSTANTS_H_
#define BERRYWORKBENCHPREFERENCECONSTANTS_H_
#include <string>
#include <org_blueberry_ui_Export.h>
namespace berry
{
/**
* Preference ids exposed by the BlueBerry Platform User Interface. These
* preference settings can be obtained from the UI plug-in's preference store.
* <p>
* <b>Note:</b>This interface should not be implemented or extended.
* </p>
*
* @see PlatformUI#PLUGIN_ID
* @noextend This class is not intended to be extended by clients.
*/
struct BERRY_UI WorkbenchPreferenceConstants
{
/**
* A named preference for whether to show an editor when its input file is
* selected in the Navigator (and vice versa).
* <p>
* Value is of type <code>boolean</code>.
* </p>
*/
static const std::string LINK_NAVIGATOR_TO_EDITOR; // "LINK_NAVIGATOR_TO_EDITOR";
/**
* A named preference for how a new perspective is opened.
* <p>
* Value is of type <code>std::string</code>. The possible values are defined
* by <code>OPEN_PERSPECTIVE_WINDOW, OPEN_PERSPECTIVE_PAGE and
* OPEN_PERSPECTIVE_REPLACE</code>.
* </p>
*
* @see #OPEN_PERSPECTIVE_WINDOW
* @see #OPEN_PERSPECTIVE_PAGE
* @see #OPEN_PERSPECTIVE_REPLACE
* @see #NO_NEW_PERSPECTIVE
*/
static const std::string OPEN_NEW_PERSPECTIVE; // "OPEN_NEW_PERSPECTIVE";
/**
* A preference value indicating that an action should open a new
* perspective in a new window.
*
* @see #PROJECT_OPEN_NEW_PERSPECTIVE
*/
static const std::string OPEN_PERSPECTIVE_WINDOW; // "OPEN_PERSPECTIVE_WINDOW";
/**
* A preference value indicating that an action should open a new
* perspective in a new page.
*
* @see #PROJECT_OPEN_NEW_PERSPECTIVE
* @deprecated Opening a Perspective in a new page is no longer supported
* functionality as of 2.0.
*/
static const std::string OPEN_PERSPECTIVE_PAGE; // "OPEN_PERSPECTIVE_PAGE";
/**
* A preference value indicating that an action should open a new
* perspective by replacing the current perspective.
*
* @see #PROJECT_OPEN_NEW_PERSPECTIVE
*/
static const std::string OPEN_PERSPECTIVE_REPLACE; // "OPEN_PERSPECTIVE_REPLACE";
/**
* A preference value indicating that an action should not open a new
* perspective.
*
* @see #PROJECT_OPEN_NEW_PERSPECTIVE
*/
static const std::string NO_NEW_PERSPECTIVE; // "NO_NEW_PERSPECTIVE";
/**
* A named preference indicating the default workbench perspective.
*/
static const std::string DEFAULT_PERSPECTIVE_ID; // "defaultPerspectiveId";
/**
* A named preference indicating the presentation factory to use for the
* workbench look and feel.
*
* @since 3.0
*/
static const std::string PRESENTATION_FACTORY_ID; // "presentationFactoryId";
/**
* A named preference indicating where the perspective bar should be docked.
* The default value (when this preference is not set) is
* <code>TOP_RIGHT</code>.
* <p>
* This preference may be one of the following values: {@link #TOP_RIGHT},
* {@link #TOP_LEFT}, or {@link #LEFT}.
* </p>
*
* @since 3.0
*/
static const std::string DOCK_PERSPECTIVE_BAR; // "DOCK_PERSPECTIVE_BAR";
/**
* A preference indication the initial size of the perspective bar. The default value is 160.
* This preference only works when <code>configurer.setShowPerspectiveBar(true)</code> is set in
* WorkbenchWindowAdvisor#preWindowOpen()
*
* This preference only uses integer values
* bug 84603: [RCP] [PerspectiveBar] New API or pref to set default perspective bar size
*
* @since 3.5
*/
static const std::string PERSPECTIVE_BAR_SIZE; // "PERSPECTIVE_BAR_SIZE";
/**
* A named preference indicating where the fast view bar should be docked in
* a fresh workspace. This preference is meaningless after a workspace has
* been setup, since the fast view bar state is then persisted in the
* workbench. This preference is intended for applications that want the
* initial docking location to be somewhere specific. The default value
* (when this preference is not set) is the bottom.
*
* @see #LEFT
* @see #BOTTOM
* @see #RIGHT
* @since 3.0
*/
static const std::string INITIAL_FAST_VIEW_BAR_LOCATION; // "initialFastViewBarLocation";
/**
* A named preference indicating the preferred layout direction of parts
* inside a sash container. The default value (when this preference is not set)
* is <code>LEFT</code>.
* <p>
* This preference may be one of the following values: {@link #LEFT} or {@link #RIGHT}.
* </p>
*/
static const std::string PREFERRED_SASH_LAYOUT; // "preferredSashLayout";
/**
* Constant to be used when referring to the top right of the workbench
* window.
*
* @see #DOCK_PERSPECTIVE_BAR
* @since 3.0
*/
static const std::string TOP_RIGHT; // "topRight";
/**
* Constant to be used when referring to the top left of the workbench
* window.
*
* @see #DOCK_PERSPECTIVE_BAR
* @since 3.0
*/
static const std::string TOP_LEFT; // "topLeft";
/**
* Constant to be used when referring to the left side of the workbench
* window.
*
* @see #DOCK_PERSPECTIVE_BAR
* @see #INITIAL_FAST_VIEW_BAR_LOCATION
* @since 3.0
*/
static const std::string LEFT; // "left";
/**
* Constant to be used when referring to the bottom of the workbench window.
*
* @see #INITIAL_FAST_VIEW_BAR_LOCATION
* @since 3.0
*/
static const std::string BOTTOM; // "bottom";
/**
* Constant to be used when referring to the right side of the workbench
* window.
*
* @see #INITIAL_FAST_VIEW_BAR_LOCATION
* @since 3.0
*/
static const std::string RIGHT; // "right";
/**
* A named preference indicating whether the workbench should show the
* introduction component (if available) on startup.
*
* <p>
* The default value for this preference is: <code>true</code> (show
* intro)
* </p>
*
* @see org.eclipse.ui.application.WorkbenchWindowAdvisor#openIntro()
* @since 3.0
*/
static const std::string SHOW_INTRO; // "showIntro";
/**
* A named preference for whether the workbench should show traditional
* style tabs in editors and views.
*
* Boolean-valued: <code>true</code> if editors and views should use a
* traditional style of tab and <code>false</code> if editors should show
* new style tab (3.0 style)
* <p>
* The default value for this preference is: <code>true</code>
* </p>
*
* @since 3.0
*/
static const std::string SHOW_TRADITIONAL_STYLE_TABS; // "SHOW_TRADITIONAL_STYLE_TABS";
/**
* A named preference for whether the workbench should show text on the
* perspective bar.
*
* Boolean-valued: <code>true</code>, if editors should show text on the
* perspective bar, <code>false</code> otherwise.
* <p>
* The default value for this preference is: <code>true</code> (show text
* on the perspective bar)
* </p>
*
* @since 3.0
*/
static const std::string SHOW_TEXT_ON_PERSPECTIVE_BAR; // "SHOW_TEXT_ON_PERSPECTIVE_BAR";
/**
* A named preference for whether the workbench should show the "open
* perspective" button on the perspective bar.
*
* Boolean-valued: <code>true</code>, if editors should show "open
* perspective" button on the perspective bar, <code>false</code>
* otherwise.
* <p>
* The default value for this preference is: <code>true</code> (show "open
* perspective" button on the perspective bar)
* </p>
*
* @since 3.4
*/
static const std::string SHOW_OPEN_ON_PERSPECTIVE_BAR; // "SHOW_OPEN_ON_PERSPECTIVE_BAR";
/**
* A named preference for whether the workbench should show the "Other..."
* menu item in the perspective menu.
*
* Boolean-valued: <code>true</code>, if editors should show text on the
* "Other..." menu item, <code>false</code> otherwise.
* <p>
* The default value for this preference is: <code>true</code> (show the
* "Other..." menu item in the perspective menu)
* </p>
*
* @since 3.4
*/
static const std::string SHOW_OTHER_IN_PERSPECTIVE_MENU; // "SHOW_OTHER_IN_PERSPECTIVE_MENU";
/**
* A named preference for the text of the Help Contents action.
*
* String-valued. If not specified, <code>"&Help Contents"</code> is used.
* <p>
* The default value for this preference is: <code>null</code>
* </p>
*
* @since 3.0
*/
static const std::string HELP_CONTENTS_ACTION_TEXT; // "helpContentsActionText";
/**
* A named preference for the text of the Help Search action.
*
* String-valued. If not specified, <code>"S&earch"</code> is used.
* <p>
* The default value for this preference is: <code>null</code>
* </p>
*
* @since 3.1
*/
static const std::string HELP_SEARCH_ACTION_TEXT; // "helpSearchActionText";
/**
* A named preference for the text of the Dynamic Help action.
*
* String-valued. If not specified, <code>"&Dynamic Help"</code> is used.
* <p>
* The default value for this preference is: <code>null</code>
* </p>
*
* @since 3.1
*/
static const std::string DYNAMIC_HELP_ACTION_TEXT; // "dynamicHelpActionText";
/**
* A named preference for enabling animations when a layout transition
* occurs
* <p>
* The default value for this preference is: <code>true</code> (show
* animations when a transition occurs)
* </p>
*
* @since 3.1
*/
static const std::string ENABLE_ANIMATIONS; // "ENABLE_ANIMATIONS";
/**
* A named preference that view implementors can used to determine whether
* or not they should utilize colored labels.
*
* <p>
* The default value for this preference is: <code>true</code> (show
* colored labels)
* </p>
*
* @since 3.4
*/
static const std::string USE_COLORED_LABELS; // "USE_COLORED_LABELS";
/**
* <p>
* Workbench preference id for the key configuration identifier to be
* treated as the default.
* </p>
* <p>
* The default value for this preference is
* <code>"org.eclipse.ui.defaultAcceleratorConfiguration"</code>.
* <p>
*
* @since 3.1
*/
static const std::string KEY_CONFIGURATION_ID; // "KEY_CONFIGURATION_ID";
/**
* <p>
* Workbench preference identifier for the minimum width of editor tabs. By
* default, Eclipse does not define this value and allows SWT to determine
* this constant. We use <code>-1</code> internally to signify "use
* default".
* </p>
* <p>
* The default value for this preference is <code>-1</code>.
* </p>
*
* @since 3.1
*/
static const std::string EDITOR_MINIMUM_CHARACTERS; // "EDITOR_MINIMUM_CHARACTERS";
/**
* <p>
* Workbench preference identifier for the minimum width of view tabs.
* </p>
* <p>
* The default value for this preference is <code>1</code>.
* </p>
*
* @since 3.2
*/
static const std::string VIEW_MINIMUM_CHARACTERS; // "VIEW_MINIMUM_CHARACTERS";
/**
* Stores whether or not system jobs are being shown.
*
* @since 3.1
*/
static const std::string SHOW_SYSTEM_JOBS; // "SHOW_SYSTEM_JOBS";
/**
* Workbench preference for the current theme.
*
* @since 3.1
*/
static const std::string CURRENT_THEME_ID; // "CURRENT_THEME_ID";
/**
* A preference value indicating whether editors should be closed before
* saving the workbench state when exiting. The default is
* <code>false</code>.
*
* @since 3.1
*/
static const std::string CLOSE_EDITORS_ON_EXIT; // "CLOSE_EDITORS_ON_EXIT";
/**
* Stores whether or not to show progress while starting the workbench. The
* default is <code>false</code>.
*
* @since 3.1
*/
static const std::string SHOW_PROGRESS_ON_STARTUP; // "SHOW_PROGRESS_ON_STARTUP";
/**
* Stores whether or not to show the memory monitor in the workbench window.
*
* @since 3.1
*/
static const std::string SHOW_MEMORY_MONITOR; // "SHOW_MEMORY_MONITOR";
/**
* Stores whether or not to use the window working set as the default
* working set for newly created views (without previously stored state).
* This is a hint that view implementors should honor.
*
* @since 3.2
*/
static const std::string USE_WINDOW_WORKING_SET_BY_DEFAULT; // "USE_WINDOW_WORKING_SET_BY_DEFAULT";
/**
* Stores whether or not to show the text widget that allows type-ahead
* search in the case where a FilteredTree is used to display and filter
* tree items.
*
* @since 3.2
*/
static const std::string SHOW_FILTERED_TEXTS; // "SHOW_FILTERED_TEXTS";
/**
* Stores whether or not views may be detached. The default is
* <code>true</code>.
*
* @since 3.2
*/
static const std::string ENABLE_DETACHED_VIEWS; // "ENABLE_DETACHED_VIEWS";
/**
* Stores whether or not the workbench prompts for saving when a dirty
* editor or view is closed, but the Saveable objects are still open in
* other parts. If
* <code>true<code> (default), the user will be prompted. If <code>false</code>, there will be
* no prompt.
*
* @see Saveable
* @since 3.2
*/
static const std::string PROMPT_WHEN_SAVEABLE_STILL_OPEN; // "PROMPT_WHEN_SAVEABLE_STILL_OPEN";
/**
* Lists the extra perspectives to show in the perspective bar. The value is
* a comma-separated list of perspective ids. The default is the empty
* string.
*
* @since 3.2
*/
static const std::string PERSPECTIVE_BAR_EXTRAS; // "PERSPECTIVE_BAR_EXTRAS";
/**
* Allows locking the trim to prevent user dragging on startup. The default
* is <code>false</code>.
*
* @since 3.2
*/
static const std::string LOCK_TRIM; // "LOCK_TRIM";
/**
* A named preference for providing the 3.3 presentation's min/max behaviour
* <p>
* The default value for this preference is: <code>false</code>; use the
* 3.2 behaviour.
* </p>
*
* @since 3.3
*/
static const std::string ENABLE_NEW_MIN_MAX; // "ENABLE_MIN_MAX";
/**
* A named preference for disabling opening a new fast view from the fast
* view bar controls ("Show View as a fast view" button or "New Fast View"
* submenu).
* <p>
* Value is of type <code>boolean</code>.
* </p>
* <p>
* The default is <code>false</code>.
* </p>
*
* @since 3.3
*/
static const std::string DISABLE_NEW_FAST_VIEW; // "disableNewFastView";
/**
* A named preference for enabling the 3.2 behavior for closing sticky
* views. When not enabled a sticky view is closed in all perspectives when
* the view is closed.
* <p>
* The default value for this preference is: <code>false</code>; use the
* 3.2 behaviour.
* </p>
*
* @since 3.3
*/
static const std::string ENABLE_32_STICKY_CLOSE_BEHAVIOR; // "ENABLE_32_STICKY_CLOSE_BEHAVIOR";
/**
* An named preference for whether or not tabs are on the top or bottom
* for views. Values are either {@link SWT#TOP} or {@link SWT#BOTTOM}.
* <p>
* The default value for this preference is: <code>SWT.TOP</code>.
* </p>
*
* @since 3.4
*/
static const std::string VIEW_TAB_POSITION; // "VIEW_TAB_POSITION";
/**
* An named preference for whether or not tabs are on the top or bottom
* for editors. Values are either {@link SWT#TOP} or {@link SWT#BOTTOM}.
* <p>
* The default value for this preference is: <code>SWT.TOP</code>.
* </p>
*
* @since 3.4
*/
static const std::string EDITOR_TAB_POSITION; // "EDITOR_TAB_POSITION";
/**
* Workbench preference id for whether the workbench should show multiple
* editor tabs.
*
* Boolean-valued: <code>true</code> if editors should show multiple
* editor tabs, and <code>false</code> if editors should show a single
* editor tab.
* <p>
* The default value for this preference is: <code>true</code>
* </p>
*
* @since 3.4
*/
static const std::string SHOW_MULTIPLE_EDITOR_TABS; // "SHOW_MULTIPLE_EDITOR_TABS";
/**
* Workbench preference id for whether the workbench may open editors
* in-place. Note that editors will only be opened in-place if this
* preference is <code>false</code> and if the current platform supports
* in-place editing.
*
* Boolean-valued: <code>false</code> if editors may be opened in-place,
* and <code>true</code> if editors should never be opened in-place.
* <p>
* The default value for this preference is: <code>false</code>
* </p>
*
* @since 3.4
*/
static const std::string DISABLE_OPEN_EDITOR_IN_PLACE; // "DISABLE_OPEN_EDITOR_IN_PLACE";
};
}
#endif /* BERRYWORKBENCHPREFERENCECONSTANTS_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryXMLMemento.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/berryXMLMemento.cpp
index 5869eca064..c1c3bc41ba 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryXMLMemento.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryXMLMemento.cpp
@@ -1,431 +1,431 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryXMLMemento.h"
#include "internal/berryWorkbenchPlugin.h"
#include <Poco/NumberParser.h>
#include <Poco/NumberFormatter.h>
#include <Poco/DOM/NodeList.h>
#include <Poco/XML/NamePool.h>
#include <Poco/DOM/NamedNodeMap.h>
#include <Poco/DOM/Text.h>
#include <Poco/DOM/Attr.h>
#include <Poco/DOM/DOMWriter.h>
#include <Poco/DOM/DOMParser.h>
#include <Poco/DOM/DOMBuilder.h>
#include <Poco/SAX/InputSource.h>
#include <Poco/SAX/SAXException.h>
#include <sstream>
#include <limits>
const std::string EMPTY_STRING;
berry::XMLMemento::XMLMemento(Poco::XML::Document* document,
Poco::XML::Element* elem) :
factory(document), element(elem)
{
factory->duplicate();
element->duplicate();
}
berry::XMLMemento::~XMLMemento()
{
element->release();
factory->release();
}
berry::XMLMemento::Pointer berry::XMLMemento::CreateReadRoot(
berry::XMLMemento::XMLByteInputStream& reader) throw (WorkbenchException)
{
return CreateReadRoot(reader, "");
}
berry::XMLMemento::Pointer berry::XMLMemento::CreateReadRoot(
berry::XMLMemento::XMLByteInputStream& reader, const std::string& baseDir)
throw (WorkbenchException)
{
std::string errorMessage;
Poco::Exception exception("");
try
{
Poco::XML::DOMParser parser;
Poco::XML::InputSource source(reader);
source.setSystemId(baseDir);
Poco::XML::Document* doc = parser.parse(&source);
Poco::XML::Element* elem = doc->documentElement();
XMLMemento::Pointer memento = XMLMemento::New(doc, elem);
doc->release();
return memento;
} catch (Poco::XML::SAXParseException& e)
{
errorMessage = "Could not parse content of XML file.";
exception = e;
}
std::string problemText = exception.message();
if (problemText.empty())
{
problemText = errorMessage.empty() ? "Could not find root element node of XML file." : errorMessage;
}
throw WorkbenchException(problemText, exception);
}
berry::XMLMemento::Pointer berry::XMLMemento::CreateWriteRoot(
const std::string& type)
{
// TODO
// try{
Poco::XML::Document* doc = new Poco::XML::Document();
Poco::XML::Element* elem = doc->createElement(type);
doc->appendChild(elem)->release();
XMLMemento::Pointer memento = XMLMemento::New(doc, elem);
doc->release();
return memento;
//}catch() //TODO: look for poco exceptions
//{
//}
}
berry::IMemento::Pointer berry::XMLMemento::CreateChild(
const std::string& type)
{
Poco::XML::Element* child = factory->createElement(type);
element->appendChild(child)->release();
return XMLMemento::New(factory, child);
}
berry::IMemento::Pointer berry::XMLMemento::CreateChild(
const std::string& type, const std::string& id)
{
Poco::XML::Element* child = factory->createElement(type);
child->setAttribute(TAG_ID, id); //$NON-NLS-1$
element->appendChild(child)->release();
return XMLMemento::New(factory, child);
}
berry::IMemento::Pointer berry::XMLMemento::CopyChild(IMemento::Pointer child)
{
//TODO check any casting errors
Poco::XML::Element* elem = child.Cast<berry::XMLMemento> ()->GetElement();
Poco::XML::Element* newElement =
dynamic_cast<Poco::XML::Element*> (factory->importNode(elem, true));
element->appendChild(newElement)->release();
return XMLMemento::New(factory, newElement);
}
berry::IMemento::Pointer berry::XMLMemento::GetChild(const std::string& type) const
{
// Get the nodes.
berry::XMLMemento::Pointer memento;
Poco::XML::Element* child = element->getChildElement(type); // Find the first node which is a child of this node
if (child)
{
memento = berry::XMLMemento::New(factory, child);
return memento;
}
// A child was not found.
return memento;
}
std::vector<berry::IMemento::Pointer> berry::XMLMemento::GetChildren(
const std::string& type) const
{
std::vector<IMemento::Pointer> mementos;
Poco::XML::NodeList* elementList = element->getElementsByTagName(type);
mementos.resize(elementList->length());
for (unsigned long i = 0; i < elementList->length(); i++)
{
Poco::XML::Element* elem =
dynamic_cast<Poco::XML::Element*> (elementList->item(i));
mementos[i] = berry::XMLMemento::New(factory, elem);
}
return mementos;
}
bool berry::XMLMemento::GetFloat(const std::string& key, double& value) const
{
if (!element->hasAttribute(key)) return false;
const std::string& attr = element->getAttribute(key);
try
{
value = Poco::NumberParser::parseFloat(attr);
} catch (const Poco::SyntaxException& e)
{
std::string _qnan = Poco::NumberFormatter::format(std::numeric_limits<double>::quiet_NaN());
if (_qnan == attr)
{
value = std::numeric_limits<double>::quiet_NaN();
return true;
}
std::string _inf = Poco::NumberFormatter::format(std::numeric_limits<double>::infinity());
if (_inf == attr)
{
value = std::numeric_limits<double>::infinity();
return true;
}
WorkbenchPlugin::Log("Memento problem - invalid float for key: " + key
+ " value: " + attr, e);
return false;
}
return true;
}
std::string berry::XMLMemento::GetType() const
{
return element->nodeName();
}
std::string berry::XMLMemento::GetID() const
{
//TODO: make error handling!
return element->getAttribute(TAG_ID);
}
bool berry::XMLMemento::GetInteger(const std::string& key, int& value) const
{
if (!element->hasAttribute(key)) return false;
const std::string& attr = element->getAttribute(key);
try
{
value = Poco::NumberParser::parse(attr);
} catch (const Poco::SyntaxException& e)
{
WorkbenchPlugin::Log("Memento problem - invalid integer for key: " + key
+ " value: " + attr, e);
return false;
}
return true;
}
bool berry::XMLMemento::GetBoolean(const std::string& key, bool& value) const
{
std::string attr = element->getAttribute(key);
if (attr.empty())
return false;
else if (attr == "true")
{
value = true;
return true;
}
else
{
value = false;
return true;
}
}
bool berry::XMLMemento::GetString(const std::string& key, std::string& value) const
{
std::string v = element->getAttribute(key);
if (v.empty())
return false;
value = v;
return true;
}
const std::string& berry::XMLMemento::GetTextData() const
{
Poco::XML::Text* textNode = GetTextNode();
if (textNode != NULL)
{
return textNode->getData();
}
return EMPTY_STRING;
}
std::vector<std::string> berry::XMLMemento::GetAttributeKeys() const
{
std::vector<std::string> values;
Poco::XML::NamedNodeMap* nnMap = element->attributes();
values.resize(nnMap->length());
for (unsigned long i = 0; i < nnMap->length(); i++)
{
values[i] = nnMap->item(i)->nodeName(); //TODO check if right
}
return values;
}
Poco::XML::Text* berry::XMLMemento::GetTextNode() const
{
//Get the nodes
Poco::XML::NodeList* nodes = element->childNodes();
unsigned long size = nodes->length();
if (size == 0)
return NULL;
//Search for the text node
for (unsigned long index = 0; index < size; index++)
{
if (nodes->item(index)->nodeType() == Poco::XML::Node::TEXT_NODE)
{
return dynamic_cast<Poco::XML::Text*> (nodes->item(index));
}
}
// a Text node was not found
return NULL;
}
void berry::XMLMemento::PutElement(Poco::XML::Element* element, bool copyText)
{
Poco::XML::NamedNodeMap* nodeMap = element->attributes();
unsigned long size = nodeMap->length();
for (unsigned long index = 0; index < size; index++)
{
Poco::XML::Node* node = nodeMap->item(index);
Poco::XML::Attr* attr = dynamic_cast<Poco::XML::Attr*> (node);
PutString(attr->nodeName(), attr->nodeValue());
}
nodeMap->release();
bool needToCopyText = copyText;
Poco::XML::Node* child = element->firstChild();
while (child)
{
unsigned short nodeType = child->nodeType();
switch (nodeType)
{
case Poco::XML::Node::ELEMENT_NODE:
{
Poco::XML::Element* elem = dynamic_cast<Poco::XML::Element*> (child);
XMLMemento::Pointer child = CreateChild(elem->nodeName()).Cast<
berry::XMLMemento> ();
child->PutElement(elem, true);
}
break;
case Poco::XML::Node::TEXT_NODE:
if (needToCopyText)
{
Poco::XML::Text* text = dynamic_cast<Poco::XML::Text*> (child);
PutTextData(text->getData());
needToCopyText = false;
}
break;
default:
break;
}
child = child->nextSibling();
}
}
void berry::XMLMemento::PutFloat(const std::string& key, double value)
{
std::string xmlValue = Poco::NumberFormatter::format(value);
element->setAttribute(key, xmlValue);
}
void berry::XMLMemento::PutInteger(const std::string& key, int value)
{
std::string xmlValue = Poco::NumberFormatter::format(value);
element->setAttribute(key, xmlValue);
}
void berry::XMLMemento::PutMemento(IMemento::Pointer memento)
{
// Do not copy the element's top level text node (this would overwrite the existing text).
// Text nodes of children are copied.
PutElement(memento.Cast<berry::XMLMemento> ()->GetElement(), false);
}
void berry::XMLMemento::PutString(const std::string& key,
const std::string& value)
{
element->setAttribute(key, value);
//if (value == null) {
// return;}
//element.setAttribute(key, value);
}
void berry::XMLMemento::PutBoolean(const std::string& key, bool value)
{
if (value)
{
element->setAttribute(key, "true");
}
else
{
element->setAttribute(key, "false");
}
}
void berry::XMLMemento::PutTextData(const std::string& data)
{
Poco::XML::Text* textNode = GetTextNode();
if (textNode == NULL)
{
textNode = factory->createTextNode(data);
element->insertBefore(textNode, element->firstChild())->release();
}
else
{
textNode->setData(data);
}
}
void berry::XMLMemento::Save(berry::XMLMemento::XMLByteOutputStream& writer)
{
if (writer.good())
{
Poco::XML::DOMWriter out;
out.setOptions(3); //write declaration and pretty print
out.writeNode(writer, factory);
}
else
{
//TODO
}
}
Poco::XML::Element* berry::XMLMemento::GetElement() const
{
return element;
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryXMLMemento.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryXMLMemento.h
index c0fda0881e..e92723a23b 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/berryXMLMemento.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryXMLMemento.h
@@ -1,287 +1,287 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYXMLMEMENTO_H_
#define BERRYXMLMEMENTO_H_
#include <berryMacros.h>
#include "berryIMemento.h"
#include "berryUIException.h"
#include "Poco/DOM/Document.h"
#include "Poco/DOM/Element.h"
#include "Poco/SAX/XMLReader.h"
#include <iostream>
namespace berry {
/**
* This class represents the default implementation of the
* <code>IMemento</code> interface.
* <p>
* This class is not intended to be extended by clients.
* </p>
*
* @see IMemento
*/
class BERRY_UI XMLMemento : public IMemento {
public:
berryObjectMacro(XMLMemento);
berryNewMacro2Param(XMLMemento, Poco::XML::Document*, Poco::XML::Element*);
/**
* Defines a std::ostream as XML output stream
*/
typedef std::ostream XMLByteOutputStream;
/**
* Defines a std::istream as XML input stream
*/
typedef std::istream XMLByteInputStream;
/**
* Creates a memento for the specified document and element.
* <p>
* Clients should use <code>CreateReadRoot</code> and
* <code>CreateWriteRoot</code> to create the initial
* memento on a document.
* </p>
*
* @param document the document for the memento
* @param element the element node for the memento
*/
XMLMemento(Poco::XML::Document* document, Poco::XML::Element* elem);
~XMLMemento();
/**
* Creates a <code>Document</code> from the <code>Reader</code>
* and returns a memento on the first <code>Element</code> for reading
* the document.
*
* @param reader the <code>Reader</code> used to create the memento's document
* @return a memento on the first <code>Element</code> for reading the document
* @throws WorkbenchException if IO problems, invalid format, or no element.
*/
static XMLMemento::Pointer CreateReadRoot(berry::XMLMemento::XMLByteInputStream& reader) throw(WorkbenchException);
/**
* Creates a <code>Document</code> from the <code>Reader</code>
* and returns a memento on the first <code>Element</code> for reading
* the document.
*
* @param reader the <code>Reader</code> used to create the memento's document
* @param baseDir the directory used to resolve relative file names
* in the XML document. This directory must exist and include the
* trailing separator. The directory format, including the separators,
* must be valid for the platform. Can be <code>null</code> if not
* needed.
* @return a memento on the first <code>Element</code> for reading the document
* @throws WorkbenchException if IO problems, invalid format, or no element.
*/
static XMLMemento::Pointer CreateReadRoot(berry::XMLMemento::XMLByteInputStream& reader, const std::string& baseDir) throw(WorkbenchException);
/**
* Returns a root memento for writing a document.
*
* @param type the element node type to create on the document
* @return the root memento for writing a document
*/
static XMLMemento::Pointer CreateWriteRoot(const std::string& type);
/**
* Copies another Memento into this memento
*
* @param child the new child memento
* @return the new child memento
*/
IMemento::Pointer CopyChild(IMemento::Pointer child);
/**
* Creates a new child of this memento with the given type
*
* @param type the type
* @return a new child memento with the given type
*/
virtual IMemento::Pointer CreateChild(const std::string& type);
/**
* Creates a new child of this memento with the given type and id.
* The id is stored in the child memento (using a special reserved
* key, <code>TAG_ID</code>) and can be retrieved using <code>getId</code>.
* <p>
* The <code>getChild</code> and <code>getChildren</code> methods
* are used to retrieve children of a given type.
* </p>
*
* @param type the type
* @param id the child id
* @return a new child memento with the given type and id
* @see #getID
*/
virtual IMemento::Pointer CreateChild(const std::string& type, const std::string& id);
/**
* Returns the first child with the given type id.
*
* @param type the type id
* @return the first child with the given type
*/
virtual IMemento::Pointer GetChild(const std::string& type) const;
/**
* Returns all children with the given type id.
*
* @param type the type id
* @return an array of children with the given type
*/
virtual std::vector< IMemento::Pointer > GetChildren(const std::string& type) const;
/**
* Returns the Type of this memento
*/
virtual std::string GetType() const;
/**
* Returns the ID of this memento
*/
virtual std::string GetID() const;
/**
* @see IMemento#GetInteger
*/
virtual bool GetInteger(const std::string& key, int& value) const;
/**
* @see IMemento#GetFloat
*/
virtual bool GetFloat(const std::string& key, double& value) const;
/**
* @see IMemento#GetString
*/
virtual bool GetString(const std::string& key, std::string& value) const;
/**
* @see IMemento#GetString
*/
virtual bool GetBoolean(const std::string& key, bool& value) const;
/**
* Returns the data of the Text node of the memento. Each memento is allowed
* only one Text node.
*
* @return the data of the Text node of the memento, or <code>null</code>
* if the memento has no Text node.
*/
virtual const std::string& GetTextData() const;
/**
* Returns an array of all the attribute keys of the memento. This will not
* be <code>null</code>. If there are no keys, an array of length zero will
* be returned.
* @return an vector with all the attribute keys of the memento
*/
virtual std::vector< std::string > GetAttributeKeys() const;
/**
* Puts a float in this memento
*
* @param key the key
* @param value the value
*/
virtual void PutFloat(const std::string& key, double value);
/**
* Puts a integer in this memento
*
* @param key the key
* @param value the value
*/
virtual void PutInteger(const std::string& key, int value);
/**
* Puts another memento in this memento as a child
*
* @param key the key
* @param value the value
*/
virtual void PutMemento(IMemento::Pointer memento);
/**
* Puts a string in this memento
*
* @param key the key
* @param value the value
*/
virtual void PutString(const std::string& key, const std::string& value);
/**
* Puts a boolean in this memento
*
* @param key the key
* @param value the value
*/
virtual void PutBoolean(const std::string& key, bool value);
/**
* Puts a text in this memento
*
* @param data the text
*/
virtual void PutTextData(const std::string& data);
/**
* Saves this memento's document current values to the
* specified writer.
*
* @param writer the writer used to save the memento's document
* @throws IOException if there is a problem serializing the document to the stream.
*/
void Save(XMLByteOutputStream& writer); //TODO: throw(IOException)
/**
* Returns the element of the memento
*
* @return the xml element
*/
virtual Poco::XML::Element* GetElement() const;
private:
/**
* Returns the Text node of the memento. Each memento is allowed only
* one Text node.
*
* @return the Text node of the memento, or <code>null</code> if
* the memento has no Text node.
*/
Poco::XML::Text* GetTextNode() const;
/**
* Places the element's attributes into the document.
* @param copyText true if the first text node should be copied
*/
void PutElement(Poco::XML::Element* element, bool copyText);
Poco::XML::Document* factory;
Poco::XML::Element* element;
};
}//namespace berry
#endif /* BERRYXMLMEMENTO_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/dialogs/berryIDialog.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/dialogs/berryIDialog.cpp
index 3a732beaa5..9f276bb160 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/dialogs/berryIDialog.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/dialogs/berryIDialog.cpp
@@ -1,32 +1,32 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryIDialog.h"
namespace berry {
const int IDialog::NONE = 0;
const int IDialog::ERR = 1;
const int IDialog::INFORMATION = 2;
const int IDialog::QUESTION = 3;
const int IDialog::WARNING = 4;
IDialog::~IDialog()
{
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/dialogs/berryIDialog.h b/BlueBerry/Bundles/org.blueberry.ui/src/dialogs/berryIDialog.h
index 404cead286..97db5b77f1 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/dialogs/berryIDialog.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/dialogs/berryIDialog.h
@@ -1,70 +1,70 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIDIALOG_H_
#define BERRYIDIALOG_H_
#include <berryMacros.h>
#include <berryObject.h>
#include <org_blueberry_ui_Export.h>
namespace berry {
/**
* \ingroup org_blueberry_ui
*
*/
struct BERRY_UI IDialog : public virtual Object
{
berryInterfaceMacro(IDialog, berry);
/**
* Constant for a dialog with no image (value 0).
*/
const static int NONE; // = 0;
/**
* Constant for a dialog with an error image (value 1).
*/
const static int ERR; // = 1;
/**
* Constant for a dialog with an info image (value 2).
*/
const static int INFORMATION; // = 2;
/**
* Constant for a dialog with a question image (value 3).
*/
const static int QUESTION; // = 3;
/**
* Constant for a dialog with a warning image (value 4).
*/
const static int WARNING; // = 4;
enum ReturnCode { OK, CANCEL };
~IDialog();
virtual int Open() = 0;
};
}
#endif /*BERRYIDIALOG_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/dialogs/berryIShowViewDialog.h b/BlueBerry/Bundles/org.blueberry.ui/src/dialogs/berryIShowViewDialog.h
index be4019c112..9384a4abfb 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/dialogs/berryIShowViewDialog.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/dialogs/berryIShowViewDialog.h
@@ -1,44 +1,44 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYISHOWVIEWDIALOG_H_
#define BERRYISHOWVIEWDIALOG_H_
#include "berryIDialog.h"
#include <vector>
#include "berryIViewDescriptor.h"
namespace berry {
/**
* \ingroup org_blueberry_ui
*
*/
struct BERRY_UI IShowViewDialog : public IDialog
{
berryInterfaceMacro(IShowViewDialog, berry);
~IShowViewDialog();
virtual std::vector<IViewDescriptor::Pointer> GetSelection() = 0;
};
}
#endif /*BERRYISHOWVIEWDIALOG_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/dialogs/berryMessageDialog.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/dialogs/berryMessageDialog.cpp
index 215b05c538..a8a4cbd21c 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/dialogs/berryMessageDialog.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/dialogs/berryMessageDialog.cpp
@@ -1,67 +1,67 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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/berryMessageDialogTweaklet.h"
#include "berryMessageDialog.h"
namespace berry
{
bool MessageDialog::OpenConfirm(Shell::Pointer parent,
const std::string& title, const std::string& message)
{
return Tweaklets::Get(MessageDialogTweaklet::KEY)->OpenConfirm(parent, title,
message);
}
void MessageDialog::OpenError(Shell::Pointer parent, const std::string& title,
const std::string& message)
{
Tweaklets::Get(MessageDialogTweaklet::KEY)->OpenError(parent, title, message);
}
void MessageDialog::OpenInformation(Shell::Pointer parent,
const std::string& title, const std::string& message)
{
Tweaklets::Get(MessageDialogTweaklet::KEY)->OpenInformation(parent, title,
message);
}
bool MessageDialog::OpenQuestion(Shell::Pointer parent,
const std::string& title, const std::string& message)
{
return Tweaklets::Get(MessageDialogTweaklet::KEY)->OpenQuestion(parent, title,
message);
}
void MessageDialog::OpenWarning(Shell::Pointer parent,
const std::string& title, const std::string& message)
{
Tweaklets::Get(MessageDialogTweaklet::KEY)->OpenWarning(parent, title,
message);
}
IDialog::Pointer MessageDialog::CreateMessageDialog(Shell::Pointer parentShell, const std::string& dialogTitle,
void* dialogTitleImage, const std::string& dialogMessage, int dialogImageType,
const std::vector<std::string>& dialogButtonLabels, int defaultIndex)
{
return Tweaklets::Get(MessageDialogTweaklet::KEY)->MessageDialog(parentShell, dialogTitle,
dialogTitleImage, dialogMessage, dialogImageType,
dialogButtonLabels, defaultIndex);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/dialogs/berryMessageDialog.h b/BlueBerry/Bundles/org.blueberry.ui/src/dialogs/berryMessageDialog.h
index fb21074915..0d5cd45b5e 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/dialogs/berryMessageDialog.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/dialogs/berryMessageDialog.h
@@ -1,147 +1,147 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYMESSAGEDIALOG_H_
#define BERRYMESSAGEDIALOG_H_
#include "berryIDialog.h"
#include "berryShell.h"
#include <string>
#include <vector>
namespace berry {
struct MessageDialog
{
/**
* Convenience method to open a simple confirm (OK/Cancel) dialog.
*
* @param parent
* the parent shell of the dialog, or <code>null</code> if none
* @param title
* the dialog's title, or <code>null</code> if none
* @param message
* the message
* @return <code>true</code> if the user presses the OK button,
* <code>false</code> otherwise
*/
static bool OpenConfirm(Shell::Pointer parent, const std::string& title, const std::string& message);
/**
* Convenience method to open a standard error dialog.
*
* @param parent
* the parent shell of the dialog, or <code>null</code> if none
* @param title
* the dialog's title, or <code>null</code> if none
* @param message
* the message
*/
static void OpenError(Shell::Pointer parent, const std::string& title, const std::string& message);
/**
* Convenience method to open a standard information dialog.
*
* @param parent
* the parent shell of the dialog, or <code>null</code> if none
* @param title
* the dialog's title, or <code>null</code> if none
* @param message
* the message
*/
static void OpenInformation(Shell::Pointer parent, const std::string& title,
const std::string& message);
/**
* Convenience method to open a simple Yes/No question dialog.
*
* @param parent
* the parent shell of the dialog, or <code>null</code> if none
* @param title
* the dialog's title, or <code>null</code> if none
* @param message
* the message
* @return <code>true</code> if the user presses the OK button,
* <code>false</code> otherwise
*/
static bool OpenQuestion(Shell::Pointer parent, const std::string& title,
const std::string& message);
/**
* Convenience method to open a standard warning dialog.
*
* @param parent
* the parent shell of the dialog, or <code>null</code> if none
* @param title
* the dialog's title, or <code>null</code> if none
* @param message
* the message
*/
static void OpenWarning(Shell::Pointer parent, const std::string& title, const std::string& message);
/**
* Create a message dialog. Note that the dialog will have no visual
* representation (no widgets) until it is told to open.
* <p>
* The labels of the buttons to appear in the button bar are supplied in
* this constructor as an array. The <code>open</code> method will return
* the index of the label in this array corresponding to the button that was
* pressed to close the dialog. If the dialog was dismissed without pressing
* a button (ESC, etc.) then -1 is returned. Note that the <code>open</code>
* method blocks.
* </p>
*
* @param parentShell
* the parent shell
* @param dialogTitle
* the dialog title, or <code>null</code> if none
* @param dialogTitleImage
* the dialog title image, or <code>null</code> if none
* @param dialogMessage
* the dialog message
* @param dialogImageType
* one of the following values:
* <ul>
* <li><code>IDialog::NONE</code> for a dialog with no
* image</li>
* <li><code>IDialog::ERR</code> for a dialog with an
* error image</li>
* <li><code>IDialog::INFORMATION</code> for a dialog
* with an information image</li>
* <li><code>IDialog::QUESTION </code> for a dialog with a
* question image</li>
* <li><code>IDialog::WARNING</code> for a dialog with a
* warning image</li>
* </ul>
* @param dialogButtonLabels
* an array of labels for the buttons in the button bar
* @param defaultIndex
* the index in the button label array of the default button
*/
static IDialog::Pointer CreateMessageDialog(Shell::Pointer parentShell, const std::string& dialogTitle,
void* dialogTitleImage, const std::string& dialogMessage, int dialogImageType,
const std::vector<std::string>& dialogButtonLabels, int defaultIndex);
};
}
#endif /* BERRYMESSAGEDIALOG_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/guitk/berryGuiTkControlEvent.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/guitk/berryGuiTkControlEvent.cpp
index 4d4f58d6ea..fd7c4af270 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/guitk/berryGuiTkControlEvent.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/guitk/berryGuiTkControlEvent.cpp
@@ -1,42 +1,42 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryGuiTkControlEvent.h"
namespace berry
{
namespace GuiTk
{
ControlEvent::ControlEvent() :
Event()
{
}
ControlEvent::ControlEvent(void* item, int x, int y, int width, int height) :
Event()
{
this->item = item;
this->x = x;
this->y = y;
this->width = width;
this->height = height;
}
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/guitk/berryGuiTkControlEvent.h b/BlueBerry/Bundles/org.blueberry.ui/src/guitk/berryGuiTkControlEvent.h
index 44de547de4..f9151c16d8 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/guitk/berryGuiTkControlEvent.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/guitk/berryGuiTkControlEvent.h
@@ -1,55 +1,55 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYGUITKCONTROLEVENT_H_
#define BERRYGUITKCONTROLEVENT_H_
#include "berryGuiTkEvent.h"
namespace berry
{
namespace GuiTk
{
/**
* Instances of this class are sent as a result of
* controls being moved or resized.
*
* @see ControlListener
* @see <a href="http://www.blueberry.org/swt/">Sample code and further information</a>
*/
class BERRY_UI ControlEvent: public Event
{
public:
berryObjectMacro(ControlEvent);
ControlEvent();
ControlEvent(void* item, int x = 0, int y = 0, int width = 0, int height = 0);
};
}
}
#endif /* BERRYGUITKCONTROLEVENT_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/guitk/berryGuiTkEvent.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/guitk/berryGuiTkEvent.cpp
index 89a6b07b64..6a38b209a4 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/guitk/berryGuiTkEvent.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/guitk/berryGuiTkEvent.cpp
@@ -1,47 +1,47 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryGuiTkEvent.h"
#include <sstream>
namespace berry {
namespace GuiTk {
Event::Event() :
item(0), detail(0), x(0), y(0),
width(0), height(0), button(0),
character(0), keyCode(0), stateMask(0),
text(""), doit(true)
{
}
std::string Event::ToString() const
{
std::stringstream stream;
stream << "GUI SelectionEvent: " << " item=" << item << " detail=" << detail
<< " x=" << x << " y=" << y << " width=" << width << " height=" << height
<< " stateMask=" << stateMask << " text=" << text << " doit=" << doit
<< std::endl;
return stream.str();
}
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/guitk/berryGuiTkEvent.h b/BlueBerry/Bundles/org.blueberry.ui/src/guitk/berryGuiTkEvent.h
index 0cb4c707c5..092d44999f 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/guitk/berryGuiTkEvent.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/guitk/berryGuiTkEvent.h
@@ -1,146 +1,146 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYGUITKEVENT_H_
#define BERRYGUITKEVENT_H_
#include <berryObject.h>
#include <berryMacros.h>
#include <org_blueberry_ui_Export.h>
namespace berry
{
namespace GuiTk
{
/**
* Instances of this class are sent as a result of
* GUI events.
* <p>
* Note: The fields that are filled in depend on the widget.
* </p>
*
*/
class BERRY_UI Event: public Object
{
public:
berryObjectMacro(Event);
Event();
/**
* the widget that issued the event
*/
void* item;
/**
* the event specific detail field, as defined by the detail constants
* in class <code>Constants</code>
*/
int detail;
/**
* depending on the event type, the x offset of the bounding
* rectangle of the region that requires painting or the
* widget-relative, x coordinate of the pointer at the
* time the mouse button was pressed or released
*/
int x;
/**
* depending on the event type, the y offset of the bounding
* rectangle of the region that requires painting or the
* widget-relative, y coordinate of the pointer at the
* time the mouse button was pressed or released
*/
int y;
/**
* the width of the bounding rectangle of the
* region that requires painting
*/
int width;
/**
* the height of the bounding rectangle of the
* region that requires painting
*/
int height;
/**
* the button that was pressed or released; 1 for the
* first button, 2 for the second button, and 3 for the
* third button, etc.
*/
int button;
/**
* depending on the event, the character represented by the key
* that was typed. This is the final character that results
* after all modifiers have been applied. For example, when the
* user types Ctrl+A, the character value is 0x01 (ASCII SOH).
* It is important that applications do not attempt to modify the
* character value based on a stateMask (such as SWT.CTRL) or the
* resulting character will not be correct.
*/
char character;
/**
* depending on the event, the key code of the key that was typed,
* as defined by the key code constants in class <code>SWT</code>.
* When the character field of the event is ambiguous, this field
* contains the unaffected value of the original character. For
* example, typing Ctrl+M or Enter both result in the character '\r'
* but the keyCode field will also contain '\r' when Enter was typed
* and 'm' when Ctrl+M was typed.
*/
int keyCode;
/**
* depending on the event, the state of the keyboard modifier
* keys and mouse masks at the time the event was generated.
*/
int stateMask;
/**
* depending on the event, the new text that will be inserted.
* Setting this field will change the text that is about to
* be inserted or deleted.
*/
std::string text;
/**
* depending on the event, a flag indicating whether the operation
* should be allowed. Setting this field to false will cancel the
* operation.
*/
bool doit;
std::string ToString() const;
};
}
}
#endif /* BERRYGUITKEVENT_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/guitk/berryGuiTkIControlListener.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/guitk/berryGuiTkIControlListener.cpp
index 7ac0560745..8fcdcb93ef 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/guitk/berryGuiTkIControlListener.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/guitk/berryGuiTkIControlListener.cpp
@@ -1,59 +1,59 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryGuiTkIControlListener.h"
namespace berry {
namespace GuiTk {
IControlListener::~IControlListener()
{
}
void
IControlListener::Events
::AddListener(IControlListener::Pointer l)
{
if (l.IsNull()) return;
Types types = l->GetEventTypes();
if (types & MOVED)
movedEvent += Delegate(l.GetPointer(), &IControlListener::ControlMoved);
if (types & RESIZED)
resizedEvent += Delegate(l.GetPointer(), &IControlListener::ControlResized);
if (types & ACTIVATED)
activatedEvent += Delegate(l.GetPointer(), &IControlListener::ControlActivated);
if (types & DESTROYED)
destroyedEvent += Delegate(l.GetPointer(), &IControlListener::ControlDestroyed);
}
void
IControlListener::Events
::RemoveListener(IControlListener::Pointer l)
{
if (l.IsNull()) return;
movedEvent -= Delegate(l.GetPointer(), &IControlListener::ControlMoved);
resizedEvent -= Delegate(l.GetPointer(), &IControlListener::ControlResized);
activatedEvent -= Delegate(l.GetPointer(), &IControlListener::ControlActivated);
destroyedEvent -= Delegate(l.GetPointer(), &IControlListener::ControlDestroyed);
}
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/guitk/berryGuiTkIControlListener.h b/BlueBerry/Bundles/org.blueberry.ui/src/guitk/berryGuiTkIControlListener.h
index 9286ad489a..64547f3129 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/guitk/berryGuiTkIControlListener.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/guitk/berryGuiTkIControlListener.h
@@ -1,240 +1,240 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYGUITKICONTROLLISTENER_H_
#define BERRYGUITKICONTROLLISTENER_H_
#include <berryMacros.h>
#include <berryMessage.h>
#include <org_blueberry_ui_Export.h>
#include "berryGuiTkControlEvent.h"
namespace berry
{
namespace GuiTk
{
/**
* Classes which implement this interface provide methods
* that deal with the events that are generated by moving
* and resizing controls.
* <p>
* After creating an instance of a class that implements
* this interface it can be added to a control using the
* <code>addControlListener</code> method and removed using
* the <code>removeControlListener</code> method. When a
* control is moved or resized, the appropriate method will
* be invoked.
* </p>
*
* @see ControlAdapter
* @see ControlEvent
*/
struct BERRY_UI IControlListener: public virtual Object
{
berryInterfaceMacro(IControlListener, berry);
struct BERRY_UI Events {
enum Type {
NONE = 0x00000000,
MOVED = 0x00000001,
RESIZED = 0x00000002,
ACTIVATED = 0x00000004,
DESTROYED = 0x00000008,
ALL = 0xffffffff
};
BERRY_DECLARE_FLAGS(Types, Type)
typedef Message1<ControlEvent::Pointer> EventType;
EventType movedEvent;
EventType resizedEvent;
EventType activatedEvent;
EventType destroyedEvent;
void AddListener(IControlListener::Pointer listener);
void RemoveListener(IControlListener::Pointer listener);
private:
typedef MessageDelegate1<IControlListener, ControlEvent::Pointer> Delegate;
};
virtual ~IControlListener();
virtual Events::Types GetEventTypes() const = 0;
/**
* Sent when the location (x, y) of a control changes relative
* to its parent (or relative to the display, for <code>Shell</code>s).
*
* @param e an event containing information about the move
*/
virtual void ControlMoved(ControlEvent::Pointer /*e*/)
{
}
/**
* Sent when the size (width, height) of a control changes.
*
* @param e an event containing information about the resize
*/
virtual void ControlResized(ControlEvent::Pointer /*e*/)
{
}
virtual void ControlActivated(ControlEvent::Pointer /*e*/)
{
}
virtual void ControlDestroyed(ControlEvent::Pointer /*e*/)
{
}
};
template<typename R>
struct ControlMovedAdapter: public IControlListener
{
typedef R Listener;
typedef void
(R::*Callback)(ControlEvent::Pointer);
ControlMovedAdapter(R* l, Callback c) :
listener(l), callback(c)
{
poco_assert(listener);
poco_assert(callback);
}
Events::Types GetEventTypes() const
{
return Events::MOVED;
}
void ControlMoved(ControlEvent::Pointer e)
{
(listener->*callback)(e);
}
private:
Listener* listener;
Callback callback;
};
template<typename R>
struct ControlResizedAdapter: public IControlListener
{
typedef R Listener;
typedef void
(R::*Callback)(ControlEvent::Pointer);
ControlResizedAdapter(R* l, Callback c) :
listener(l), callback(c)
{
poco_assert(listener);
poco_assert(callback);
}
Events::Types GetEventTypes() const
{
return Events::RESIZED;
}
void ControlResized(ControlEvent::Pointer e)
{
(listener->*callback)(e);
}
private:
Listener* listener;
Callback callback;
};
template<typename R>
struct ControlActivatedAdapter: public IControlListener
{
typedef R Listener;
typedef void
(R::*Callback)(ControlEvent::Pointer);
ControlActivatedAdapter(R* l, Callback c) :
listener(l), callback(c)
{
poco_assert(listener);
poco_assert(callback);
}
Events::Types GetEventTypes() const
{
return Events::ACTIVATED;
}
void ControlActivated(ControlEvent::Pointer e)
{
(listener->*callback)(e);
}
private:
Listener* listener;
Callback callback;
};
template<typename R>
struct ControlDestroyedAdapter: public IControlListener
{
typedef R Listener;
typedef void
(R::*Callback)(ControlEvent::Pointer);
ControlDestroyedAdapter(R* l, Callback c) :
listener(l), callback(c)
{
poco_assert(listener);
poco_assert(callback);
}
Events::Types GetEventTypes() const
{
return Events::DESTROYED;
}
void ControlDestroyed(ControlEvent::Pointer e)
{
(listener->*callback)(e);
}
private:
Listener* listener;
Callback callback;
};
}
}
BERRY_DECLARE_OPERATORS_FOR_FLAGS(berry::GuiTk::IControlListener::Events::Types)
#endif /* BERRYGUITKICONTROLLISTENER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/guitk/berryGuiTkIMenuListener.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/guitk/berryGuiTkIMenuListener.cpp
index d8e15424c3..6355e5adbd 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/guitk/berryGuiTkIMenuListener.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/guitk/berryGuiTkIMenuListener.cpp
@@ -1,45 +1,45 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryGuiTkIMenuListener.h"
namespace berry {
namespace GuiTk {
void
IMenuListener::Events
::AddListener(IMenuListener::Pointer l)
{
if (l.IsNull()) return;
menuAboutToShow += Delegate(l.GetPointer(), &IMenuListener::MenuAboutToShow);
menuAboutToHide += Delegate(l.GetPointer(), &IMenuListener::MenuAboutToHide);
}
void
IMenuListener::Events
::RemoveListener(IMenuListener::Pointer l)
{
if (l.IsNull()) return;
menuAboutToShow -= Delegate(l.GetPointer(), &IMenuListener::MenuAboutToShow);
menuAboutToHide -= Delegate(l.GetPointer(), &IMenuListener::MenuAboutToHide);
}
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/guitk/berryGuiTkIMenuListener.h b/BlueBerry/Bundles/org.blueberry.ui/src/guitk/berryGuiTkIMenuListener.h
index 5fd09b4f71..aa28a3c47f 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/guitk/berryGuiTkIMenuListener.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/guitk/berryGuiTkIMenuListener.h
@@ -1,90 +1,90 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYGUITKIMENULISTENER_H_
#define BERRYGUITKIMENULISTENER_H_
#include <berryObject.h>
#include <berryMacros.h>
#include <berryMessage.h>
#include <org_blueberry_ui_Export.h>
namespace berry
{
namespace GuiTk
{
/**
* Classes which implement this interface provide methods
* that deal with the events that are generated by moving
* and resizing controls.
* <p>
* After creating an instance of a class that implements
* this interface it can be added to a control using the
* <code>addControlListener</code> method and removed using
* the <code>removeControlListener</code> method. When a
* control is moved or resized, the appropriate method will
* be invoked.
* </p>
*
* @see ControlAdapter
* @see ControlEvent
*/
struct BERRY_UI IMenuListener: public virtual Object
{
berryInterfaceMacro(IMenuListener, berry);
struct Events {
typedef Message<> MenuEvent;
MenuEvent menuAboutToShow;
MenuEvent menuAboutToHide;
void AddListener(IMenuListener::Pointer listener);
void RemoveListener(IMenuListener::Pointer listener);
private:
typedef MessageDelegate<IMenuListener> Delegate;
};
/**
* Notifies this listener that the menu is about to be shown by
* the given menu manager.
*
* @param manager the menu manager
*/
virtual void MenuAboutToShow() = 0;
/**
* Notifies this listener that the menu is about to be hidden by
* the given menu manager.
*
* @param manager the menu manager
*/
virtual void MenuAboutToHide() = 0;
};
}
}
#endif /* BERRYGUITKIMENULISTENER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/guitk/berryGuiTkISelectionListener.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/guitk/berryGuiTkISelectionListener.cpp
index 226d69c6af..f2436a46dc 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/guitk/berryGuiTkISelectionListener.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/guitk/berryGuiTkISelectionListener.cpp
@@ -1,49 +1,49 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryGuiTkISelectionListener.h"
namespace berry {
namespace GuiTk {
ISelectionListener::~ISelectionListener()
{
}
void
ISelectionListener::Events
::AddListener(ISelectionListener::Pointer l)
{
if (l.IsNull()) return;
selected += Delegate(l.GetPointer(), &ISelectionListener::WidgetSelected);
defaultSelected += Delegate(l.GetPointer(), &ISelectionListener::WidgetDefaultSelected);
}
void
ISelectionListener::Events
::RemoveListener(ISelectionListener::Pointer l)
{
if (l.IsNull()) return;
selected -= Delegate(l.GetPointer(), &ISelectionListener::WidgetSelected);
defaultSelected -= Delegate(l.GetPointer(), &ISelectionListener::WidgetDefaultSelected);
}
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/guitk/berryGuiTkISelectionListener.h b/BlueBerry/Bundles/org.blueberry.ui/src/guitk/berryGuiTkISelectionListener.h
index 16911c078f..9816167ee7 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/guitk/berryGuiTkISelectionListener.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/guitk/berryGuiTkISelectionListener.h
@@ -1,102 +1,102 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYGUITKISELECTIONLISTENER_H_
#define BERRYGUITKISELECTIONLISTENER_H_
#include <berryMacros.h>
#include <berryMessage.h>
#include "berryGuiTkSelectionEvent.h"
namespace berry
{
namespace GuiTk
{
/**
* Classes which implement this interface provide methods
* that deal with the events that are generated when selection
* occurs in a control.
* <p>
* After creating an instance of a class that implements
* this interface it can be added to a control using the
* <code>addSelectionListener</code> method and removed using
* the <code>removeSelectionListener</code> method. When
* selection occurs in a control the appropriate method
* will be invoked.
* </p>
*
* @see SelectionAdapter
* @see SelectionEvent
*/
struct BERRY_UI ISelectionListener: public virtual Object
{
berryInterfaceMacro(ISelectionListener, berry);
struct BERRY_UI Events {
typedef Message1<SelectionEvent::Pointer> EventType;
EventType selected;
EventType defaultSelected;
void AddListener(ISelectionListener::Pointer listener);
void RemoveListener(ISelectionListener::Pointer listener);
private:
typedef MessageDelegate1<ISelectionListener, SelectionEvent::Pointer> Delegate;
};
virtual ~ISelectionListener();
/**
* Sent when selection occurs in the control.
* <p>
* For example, selection occurs in a List when the user selects
* an item or items with the keyboard or mouse. On some platforms,
* the event occurs when a mouse button or key is pressed. On others,
* it happens when the mouse or key is released. The exact key or
* mouse gesture that causes this event is platform specific.
* </p>
*
* @param e an event containing information about the selection
*/
virtual void WidgetSelected(SelectionEvent::Pointer /*e*/) {}
/**
* Sent when default selection occurs in the control.
* <p>
* For example, on some platforms default selection occurs in a List
* when the user double-clicks an item or types return in a Text.
* On some platforms, the event occurs when a mouse button or key is
* pressed. On others, it happens when the mouse or key is released.
* The exact key or mouse gesture that causes this event is platform
* specific.
* </p>
*
* @param e an event containing information about the default selection
*/
virtual void WidgetDefaultSelected(SelectionEvent::Pointer /*e*/) {}
};
}
}
#endif /* BERRYGUITKISELECTIONLISTENER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/guitk/berryGuiTkSelectionEvent.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/guitk/berryGuiTkSelectionEvent.cpp
index 3a869ff324..2356bfd558 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/guitk/berryGuiTkSelectionEvent.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/guitk/berryGuiTkSelectionEvent.cpp
@@ -1,35 +1,35 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryGuiTkSelectionEvent.h"
#include <sstream>
namespace berry
{
namespace GuiTk
{
SelectionEvent::SelectionEvent(void* item) :
Event()
{
this->item = item;
}
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/guitk/berryGuiTkSelectionEvent.h b/BlueBerry/Bundles/org.blueberry.ui/src/guitk/berryGuiTkSelectionEvent.h
index 055ee2d3ff..0ddeb27667 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/guitk/berryGuiTkSelectionEvent.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/guitk/berryGuiTkSelectionEvent.h
@@ -1,56 +1,56 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYGUITKSELECTIONEVENT_H_
#define BERRYGUITKSELECTIONEVENT_H_
#include "berryGuiTkEvent.h"
namespace berry
{
namespace GuiTk
{
/**
* Instances of this class are sent as a result of
* widgets being selected.
*
* @see ISelectionListener
*/
class BERRY_UI SelectionEvent: public Event
{
public:
berryObjectMacro(SelectionEvent);
/**
* Constructs a new instance of this class based on the
* information in the given untyped event.
*
* @param item the GUI dependent widget which has been selected
*/
SelectionEvent(void* item);
};
}
}
#endif /* BERRYGUITKSELECTIONEVENT_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/handlers/berryHandlerUtil.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/handlers/berryHandlerUtil.cpp
index c93569303c..13c0dfe719 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/handlers/berryHandlerUtil.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/handlers/berryHandlerUtil.cpp
@@ -1,348 +1,348 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryHandlerUtil.h"
#include <berryIEvaluationContext.h>
#include <berryCommandExceptions.h>
#include "berryISources.h"
namespace berry
{
void HandlerUtil::NoVariableFound(ExecutionEvent::Pointer event,
const std::string& name)
{
throw ExecutionException("No " + name //$NON-NLS-1$
+ " found while executing " + event->GetCommand()->GetId()); //$NON-NLS-1$
}
void HandlerUtil::IncorrectTypeFound(ExecutionEvent::Pointer event,
const std::string& name, const std::string& expectedType,
const std::string& wrongType)
{
throw ExecutionException("Incorrect type for " //$NON-NLS-1$
+ name
+ " found while executing " //$NON-NLS-1$
+ event->GetCommand()->GetId()
+ ", expected " + expectedType //$NON-NLS-1$
+ " found " + wrongType); //$NON-NLS-1$
}
Object::Pointer HandlerUtil::GetVariable(
ExecutionEvent::Pointer event, const std::string& name)
{
return event->GetApplicationContext().Cast<const IEvaluationContext>()->GetVariable(name);
}
Object::Pointer HandlerUtil::GetVariableChecked(
ExecutionEvent::Pointer event, const std::string& name)
{
Object::Pointer o(HandlerUtil::GetVariable(event, name));
if (o.IsNull())
{
HandlerUtil::NoVariableFound(event, name);
}
return o;
}
Object::Pointer HandlerUtil::GetVariable(
Object::Pointer context, const std::string& name)
{
IEvaluationContext::Pointer eval(context.Cast<IEvaluationContext>());
if (eval.IsNotNull())
{
return eval->GetVariable(name);
}
return Object::Pointer(0);
}
HandlerUtil::StringVectorType::Pointer HandlerUtil::GetActiveContexts(
ExecutionEvent::Pointer event)
{
Object::Pointer o(HandlerUtil::GetVariable(event,
ISources::ACTIVE_CONTEXT_NAME()));
return o.Cast<StringVectorType>();
}
HandlerUtil::StringVectorType::Pointer HandlerUtil::GetActiveContextsChecked(
ExecutionEvent::Pointer event)
{
Object::Pointer o(HandlerUtil::GetVariableChecked(event,
ISources::ACTIVE_CONTEXT_NAME()));
if (o.Cast<StringVectorType>().IsNull())
{
HandlerUtil::IncorrectTypeFound(event, ISources::ACTIVE_CONTEXT_NAME(),
"StringVectorType", o->GetClassName());
}
return o.Cast<StringVectorType>();
}
//IEditorPart::Pointer HandlerUtil::GetActiveEditor(ExecutionEvent::Pointer event)
//{
// Object::Pointer o(HandlerUtil::GetVariable(event,
// ISources::ACTIVE_EDITOR_NAME));
// return o.Cast<IEditorPart>();
//}
//IEditorPart::Pointer HandlerUtil::GetActiveEditorChecked(
// ExecutionEvent::Pointer event)
//{
// Object::Pointer o = HandlerUtil::GetVariableChecked(event,
// ISources::ACTIVE_EDITOR_NAME);
// if (o.Cast<IEditorPart>().IsNull())
// {
// HandlerUtil::IncorrectTypeFound(event, ISources::ACTIVE_EDITOR_NAME,
// "IEditorPart", o->GetClassName());
// }
// return (IEditorPart) o;
//}
ObjectString::Pointer HandlerUtil::GetActiveEditorId(ExecutionEvent::Pointer event)
{
Object::Pointer o = HandlerUtil::GetVariable(event,
ISources::ACTIVE_EDITOR_ID_NAME());
return o.Cast<ObjectString>();
}
ObjectString::Pointer HandlerUtil::GetActiveEditorIdChecked(
ExecutionEvent::Pointer event)
{
Object::Pointer o = HandlerUtil::GetVariableChecked(event,
ISources::ACTIVE_EDITOR_ID_NAME());
if (o.Cast<ObjectString>().IsNull())
{
HandlerUtil::IncorrectTypeFound(event, ISources::ACTIVE_EDITOR_ID_NAME(),
"std::string", o->GetClassName());
}
return o.Cast<ObjectString>();
}
IWorkbenchPart::Pointer HandlerUtil::GetActivePart(ExecutionEvent::Pointer event)
{
Object::Pointer o = HandlerUtil::GetVariable(event,
ISources::ACTIVE_PART_NAME());
return o.Cast<IWorkbenchPart>();
}
IWorkbenchPart::Pointer HandlerUtil::GetActivePartChecked(
ExecutionEvent::Pointer event)
{
Object::Pointer o = HandlerUtil::GetVariableChecked(event,
ISources::ACTIVE_PART_NAME());
if (o.Cast<IWorkbenchPart>().IsNull())
{
HandlerUtil::IncorrectTypeFound(event, ISources::ACTIVE_PART_NAME(),
"IWorkbenchPart", o->GetClassName());
}
return o.Cast<IWorkbenchPart>();
}
ObjectString::Pointer HandlerUtil::GetActivePartId(ExecutionEvent::Pointer event)
{
Object::Pointer o = HandlerUtil::GetVariable(event,
ISources::ACTIVE_PART_ID_NAME());
return o.Cast<ObjectString>();
}
ObjectString::Pointer HandlerUtil::GetActivePartIdChecked(
ExecutionEvent::Pointer event)
{
Object::Pointer o = HandlerUtil::GetVariableChecked(event,
ISources::ACTIVE_PART_ID_NAME());
if (o.Cast<ObjectString>().IsNull())
{
HandlerUtil::IncorrectTypeFound(event, ISources::ACTIVE_PART_ID_NAME(),
"std::string", o->GetClassName());
}
return o.Cast<ObjectString>();
}
IWorkbenchPartSite::Pointer HandlerUtil::GetActiveSite(
ExecutionEvent::Pointer event)
{
Object::Pointer o = HandlerUtil::GetVariable(event,
ISources::ACTIVE_SITE_NAME());
return o.Cast<IWorkbenchPartSite>();
}
IWorkbenchPartSite::Pointer HandlerUtil::GetActiveSiteChecked(
ExecutionEvent::Pointer event)
{
Object::Pointer o = HandlerUtil::GetVariableChecked(event,
ISources::ACTIVE_SITE_NAME());
if (o.Cast<IWorkbenchPartSite>().IsNull())
{
HandlerUtil::IncorrectTypeFound(event, ISources::ACTIVE_SITE_NAME(),
"IWorkbenchSitePart", o->GetClassName());
}
return o.Cast<IWorkbenchPartSite>();
}
ISelection::Pointer HandlerUtil::GetCurrentSelection(
ExecutionEvent::Pointer event)
{
Object::Pointer o = HandlerUtil::GetVariable(event,
ISources::ACTIVE_CURRENT_SELECTION_NAME());
return o.Cast<ISelection>();
}
ISelection::Pointer HandlerUtil::GetCurrentSelectionChecked(
ExecutionEvent::Pointer event)
{
Object::Pointer o = HandlerUtil::GetVariableChecked(event,
ISources::ACTIVE_CURRENT_SELECTION_NAME());
if (o.Cast<ISelection>().IsNull())
{
HandlerUtil::IncorrectTypeFound(event,
ISources::ACTIVE_CURRENT_SELECTION_NAME(), "ISelection",
o->GetClassName());
}
return o.Cast<ISelection>();
}
HandlerUtil::StringVectorType::Pointer HandlerUtil::GetActiveMenus(
ExecutionEvent::Pointer event)
{
Object::Pointer o = HandlerUtil::GetVariable(event,
ISources::ACTIVE_MENU_NAME());
return o.Cast<StringVectorType>();
}
HandlerUtil::StringVectorType::Pointer HandlerUtil::GetActiveMenusChecked(
ExecutionEvent::Pointer event)
{
Object::Pointer o = HandlerUtil::GetVariableChecked(event,
ISources::ACTIVE_MENU_NAME());
if (o.Cast<StringVectorType>().IsNull())
{
HandlerUtil::IncorrectTypeFound(event, ISources::ACTIVE_MENU_NAME(),
"StringVectorType", o->GetClassName());
}
return o.Cast<StringVectorType>();
}
ISelection::Pointer HandlerUtil::GetActiveMenuSelection(
ExecutionEvent::Pointer event)
{
Object::Pointer o = HandlerUtil::GetVariable(event,
ISources::ACTIVE_MENU_SELECTION_NAME());
return o.Cast<ISelection>();
}
ISelection::Pointer HandlerUtil::GetActiveMenuSelectionChecked(
ExecutionEvent::Pointer event)
{
Object::Pointer o = HandlerUtil::GetVariableChecked(event,
ISources::ACTIVE_MENU_SELECTION_NAME());
if (o.Cast<ISelection>().IsNull())
{
HandlerUtil::IncorrectTypeFound(event,
ISources::ACTIVE_MENU_SELECTION_NAME(), "ISelection", o->GetClassName());
}
return o.Cast<ISelection>();
}
IWorkbenchWindow::Pointer HandlerUtil::GetActiveWorkbenchWindow(
ExecutionEvent::Pointer event)
{
Object::Pointer o = HandlerUtil::GetVariable(event,
ISources::ACTIVE_WORKBENCH_WINDOW_NAME());
return o.Cast<IWorkbenchWindow>();
}
IWorkbenchWindow::Pointer HandlerUtil::GetActiveWorkbenchWindowChecked(
ExecutionEvent::Pointer event)
{
Object::Pointer o = HandlerUtil::GetVariableChecked(event,
ISources::ACTIVE_WORKBENCH_WINDOW_NAME());
if (o.Cast<IWorkbenchWindow>().IsNull())
{
HandlerUtil::IncorrectTypeFound(event,
ISources::ACTIVE_WORKBENCH_WINDOW_NAME(), "IWorkbenchWindow",
o->GetClassName());
}
return o.Cast<IWorkbenchWindow>();
}
ISelection::Pointer HandlerUtil::GetActiveMenuEditorInput(
ExecutionEvent::Pointer event)
{
Object::Pointer o = HandlerUtil::GetVariable(event,
ISources::ACTIVE_MENU_EDITOR_INPUT_NAME());
return o.Cast<ISelection>();
}
ISelection::Pointer HandlerUtil::GetActiveMenuEditorInputChecked(
ExecutionEvent::Pointer event)
{
Object::Pointer o = HandlerUtil::GetVariableChecked(event,
ISources::ACTIVE_MENU_EDITOR_INPUT_NAME());
if (o.Cast<ISelection>().IsNull())
{
HandlerUtil::IncorrectTypeFound(event,
ISources::ACTIVE_MENU_EDITOR_INPUT_NAME(), "ISelection",
o->GetClassName());
}
return o.Cast<ISelection>();
}
ISelection::Pointer HandlerUtil::GetShowInSelection(
ExecutionEvent::Pointer event)
{
Object::Pointer o = HandlerUtil::GetVariable(event,
ISources::SHOW_IN_SELECTION());
return o.Cast<ISelection>();
}
ISelection::Pointer HandlerUtil::GetShowInSelectionChecked(
ExecutionEvent::Pointer event)
{
Object::Pointer o = HandlerUtil::GetVariableChecked(event,
ISources::SHOW_IN_SELECTION());
if (o.Cast<ISelection>().IsNull())
{
HandlerUtil::IncorrectTypeFound(event, ISources::SHOW_IN_SELECTION(),
"ISelection", o->GetClassName());
}
return o.Cast<ISelection>();
}
Object::Pointer HandlerUtil::GetShowInInput(
ExecutionEvent::Pointer event)
{
Object::Pointer var = HandlerUtil::GetVariable(event,
ISources::SHOW_IN_INPUT());
// if (var == IEvaluationContext.UNDEFINED_VARIABLE) {
// return null;
// }
return var;
}
Object::Pointer HandlerUtil::GetShowInInputChecked(
ExecutionEvent::Pointer event)
{
Object::Pointer var = HandlerUtil::GetVariableChecked(event,
ISources::SHOW_IN_INPUT());
// if (var == IEvaluationContext.UNDEFINED_VARIABLE) {
// HandlerUtil::IncorrectTypeFound(event, ISources::SHOW_IN_INPUT, Object.class, var
// .getClass());
// }
return var;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/handlers/berryHandlerUtil.h b/BlueBerry/Bundles/org.blueberry.ui/src/handlers/berryHandlerUtil.h
index aeae64746c..387ed49d93 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/handlers/berryHandlerUtil.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/handlers/berryHandlerUtil.h
@@ -1,410 +1,410 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYHANDLERUTIL_H_
#define BERRYHANDLERUTIL_H_
#include <berryExecutionEvent.h>
#include <berryObjectVector.h>
#include <berryObjectString.h>
#include <org_blueberry_ui_Export.h>
#include "berryIWorkbenchPart.h"
#include "berryIWorkbenchPartSite.h"
#include "berryISelection.h"
#include "berryIWorkbenchWindow.h"
#include "berryISources.h"
namespace berry {
/**
* \ingroup org_blueberry_ui
*
* Some common utilities for working with handlers in Platform UI.
* <p>
* <b>Note</b>: this class should not be instantiated or extended by clients.
* </p>
*
* @since 3.3
*/
class BERRY_UI HandlerUtil {
private:
static void NoVariableFound(ExecutionEvent::Pointer event, const std::string& name);
static void IncorrectTypeFound(ExecutionEvent::Pointer event, const std::string& name,
const std::string& expectedType, const std::string& wrongType);
public:
typedef ObjectVector<ObjectString::Pointer> StringVectorType;
/**
* Extract the variable.
*
* @param event
* The execution event that contains the application context
* @param name
* The variable name to extract.
* @return The object from the application context, or <code>null</code>
* if it could not be found.
*/
static Object::Pointer GetVariable(ExecutionEvent::Pointer event, const std::string& name);
/**
* Extract the variable.
*
* @param event
* The execution event that contains the application context
* @param name
* The variable name to extract.
* @return The object from the application context. Will not return
* <code>null</code>.
* @throws ExecutionException
* if the variable is not found.
*/
static Object::Pointer GetVariableChecked(ExecutionEvent::Pointer event, const std::string& name);
/**
* Extract the variable.
*
* @param context
* The IEvaluationContext or <code>null</code>
* @param name
* The variable name to extract.
* @return The object from the application context, or <code>null</code>
* if it could not be found.
* @since 3.4
*/
static Object::Pointer GetVariable(Object::Pointer context, const std::string& name);
/**
* Return the active contexts.
*
* @param event
* The execution event that contains the application context
* @return a collection of String contextIds, or <code>null</code>.
*/
static StringVectorType::Pointer GetActiveContexts(ExecutionEvent::Pointer event);
/**
* Return the active contexts.
*
* @param event
* The execution event that contains the application context
* @return a collection of String contextIds. Will not return
* <code>null</code>.
* @throws ExecutionException
* If the context variable is not found.
*/
static StringVectorType::Pointer GetActiveContextsChecked(ExecutionEvent::Pointer event);
/**
* Return the active shell. Is not necessarily the active workbench window
* shell.
*
* @param event
* The execution event that contains the application context
* @return the active shell, or <code>null</code>.
*/
// static Shell GetActiveShell(ExecutionEvent::Pointer event) {
// Object::Pointer o = getVariable(event, ISources.ACTIVE_SHELL_NAME);
// if (o instanceof Shell) {
// return (Shell) o;
// }
// return null;
// }
/**
* Return the active shell. Is not necessarily the active workbench window
* shell.
*
* @param event
* The execution event that contains the application context
* @return the active shell. Will not return <code>null</code>.
* @throws ExecutionException
* If the active shell variable is not found.
*/
// static Shell GetActiveShellChecked(ExecutionEvent::Pointer event)
// {
// Object::Pointer o = getVariableChecked(event, ISources.ACTIVE_SHELL_NAME);
// if (!(o instanceof Shell)) {
// incorrectTypeFound(event, ISources.ACTIVE_SHELL_NAME, Shell.class,
// o.getClass());
// }
// return (Shell) o;
// }
/**
* Return the active workbench window.
*
* @param event
* The execution event that contains the application context
* @return the active workbench window, or <code>null</code>.
*/
static IWorkbenchWindow::Pointer GetActiveWorkbenchWindow(ExecutionEvent::Pointer event);
/**
* Return the active workbench window.
*
* @param event
* The execution event that contains the application context
* @return the active workbench window. Will not return <code>null</code>.
* @throws ExecutionException
* If the active workbench window variable is not found.
*/
static IWorkbenchWindow::Pointer GetActiveWorkbenchWindowChecked(
ExecutionEvent::Pointer event);
/**
* Return the active editor.
*
* @param event
* The execution event that contains the application context
* @return the active editor, or <code>null</code>.
*/
//static IEditorPart::Pointer GetActiveEditor(ExecutionEvent::Pointer event);
/**
* Return the active editor.
*
* @param event
* The execution event that contains the application context
* @return the active editor. Will not return <code>null</code>.
* @throws ExecutionException
* If the active editor variable is not found.
*/
//static IEditorPart::Pointer GetActiveEditorChecked(ExecutionEvent::Pointer event);
/**
* Return the part id of the active editor.
*
* @param event
* The execution event that contains the application context
* @return the part id of the active editor, or <code>null</code>.
*/
static ObjectString::Pointer GetActiveEditorId(ExecutionEvent::Pointer event);
/**
* Return the part id of the active editor.
*
* @param event
* The execution event that contains the application context
* @return the part id of the active editor. Will not return
* <code>null</code>.
* @throws ExecutionException
* If the active editor id variable is not found.
*/
static ObjectString::Pointer GetActiveEditorIdChecked(ExecutionEvent::Pointer event);
/**
* Return the active part.
*
* @param event
* The execution event that contains the application context
* @return the active part, or <code>null</code>.
*/
static IWorkbenchPart::Pointer GetActivePart(ExecutionEvent::Pointer event);
/**
* Return the active part.
*
* @param event
* The execution event that contains the application context
* @return the active part. Will not return <code>null</code>.
* @throws ExecutionException
* If the active part variable is not found.
*/
static IWorkbenchPart::Pointer GetActivePartChecked(ExecutionEvent::Pointer event);
/**
* Return the part id of the active part.
*
* @param event
* The execution event that contains the application context
* @return the part id of the active part, or <code>null</code>.
*/
static ObjectString::Pointer GetActivePartId(ExecutionEvent::Pointer event);
/**
* Return the part id of the active part.
*
* @param event
* The execution event that contains the application context
* @return the part id of the active part. Will not return <code>null</code>.
* @throws ExecutionException
* If the active part id variable is not found.
*/
static ObjectString::Pointer GetActivePartIdChecked(ExecutionEvent::Pointer event);
/**
* Return the active part site.
*
* @param event
* The execution event that contains the application context
* @return the active part site, or <code>null</code>.
*/
static IWorkbenchPartSite::Pointer GetActiveSite(ExecutionEvent::Pointer event);
/**
* Return the active part site.
*
* @param event
* The execution event that contains the application context
* @return the active part site. Will not return <code>null</code>.
* @throws ExecutionException
* If the active part site variable is not found.
*/
static IWorkbenchPartSite::Pointer GetActiveSiteChecked(ExecutionEvent::Pointer event);
/**
* Return the current selection.
*
* @param event
* The execution event that contains the application context
* @return the current selection, or <code>null</code>.
*/
static ISelection::Pointer GetCurrentSelection(ExecutionEvent::Pointer event);
/**
* Return the current selection.
*
* @param event
* The execution event that contains the application context
* @return the current selection. Will not return <code>null</code>.
* @throws ExecutionException
* If the current selection variable is not found.
*/
static ISelection::Pointer GetCurrentSelectionChecked(ExecutionEvent::Pointer event);
/**
* Return the menu IDs that were applied to the registered context menu. For
* example, #CompilationUnitEditorContext.
*
* @param event
* The execution event that contains the application context
* @return the menu IDs, or <code>null</code>.
*/
static StringVectorType::Pointer GetActiveMenus(ExecutionEvent::Pointer event);
/**
* Return the menu IDs that were applied to the registered context menu. For
* example, #CompilationUnitEditorContext.
*
* @param event
* The execution event that contains the application context
* @return the menu IDs. Will not return <code>null</code>.
* @throws ExecutionException
* If the active menus variable is not found.
*/
static StringVectorType::Pointer GetActiveMenusChecked(ExecutionEvent::Pointer event);
/**
* Return the active menu selection. The active menu is a registered context
* menu.
*
* @param event
* The execution event that contains the application context
* @return the active menu selection, or <code>null</code>.
*/
static ISelection::Pointer GetActiveMenuSelection(ExecutionEvent::Pointer event);
/**
* Return the active menu selection. The active menu is a registered context
* menu.
*
* @param event
* The execution event that contains the application context
* @return the active menu selection. Will not return <code>null</code>.
* @throws ExecutionException
* If the active menu selection variable is not found.
*/
static ISelection::Pointer GetActiveMenuSelectionChecked(ExecutionEvent::Pointer event);
/**
* Return the active menu editor input, if available. The active menu is a
* registered context menu.
*
* @param event
* The execution event that contains the application context
* @return the active menu editor, or <code>null</code>.
*/
static ISelection::Pointer GetActiveMenuEditorInput(ExecutionEvent::Pointer event);
/**
* Return the active menu editor input. The active menu is a registered
* context menu. Some context menus do not include the editor input which
* will throw an exception.
*
* @param event
* The execution event that contains the application context
* @return the active menu editor input. Will not return <code>null</code>.
* @throws ExecutionException
* If the active menu editor input variable is not found.
*/
static ISelection::Pointer GetActiveMenuEditorInputChecked(
ExecutionEvent::Pointer event);
/**
* Return the ShowInContext selection.
*
* @param event
* The execution event that contains the application context
* @return the show in selection, or <code>null</code>.
* @since 3.4
*/
static ISelection::Pointer GetShowInSelection(ExecutionEvent::Pointer event);
/**
* Return the ShowInContext selection. Will not return <code>null</code>.
*
* @param event
* The execution event that contains the application context
* @return the show in selection, or <code>null</code>.
* @throws ExecutionException
* If the show in selection variable is not found.
* @since 3.4
*/
static ISelection::Pointer GetShowInSelectionChecked(ExecutionEvent::Pointer event);
/**
* Return the ShowInContext input.
*
* @param event
* The execution event that contains the application context
* @return the show in input, or <code>null</code>.
* @since 3.4
*/
static Object::Pointer GetShowInInput(ExecutionEvent::Pointer event);
/**
* Return the ShowInContext input. Will not return <code>null</code>.
*
* @param event
* The execution event that contains the application context
* @return the show in input, or <code>null</code>.
* @throws ExecutionException
* If the show in input variable is not found.
* @since 3.4
*/
static Object::Pointer GetShowInInputChecked(ExecutionEvent::Pointer event);
};
}
#endif /*BERRYHANDLERUTIL_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/handlers/berryIHandlerActivation.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/handlers/berryIHandlerActivation.cpp
index 8a0be19aed..061516dc37 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/handlers/berryIHandlerActivation.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/handlers/berryIHandlerActivation.cpp
@@ -1,32 +1,32 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryIHandlerActivation.h"
#include <berryIHandler.h>
#include "berryIHandlerService.h"
namespace berry {
const int IHandlerActivation::ROOT_DEPTH = 1;
IHandlerActivation::~IHandlerActivation()
{
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/handlers/berryIHandlerActivation.h b/BlueBerry/Bundles/org.blueberry.ui/src/handlers/berryIHandlerActivation.h
index 8a03749cda..2d868562f7 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/handlers/berryIHandlerActivation.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/handlers/berryIHandlerActivation.h
@@ -1,122 +1,122 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIHANDLERACTIVATION_H_
#define BERRYIHANDLERACTIVATION_H_
#include "internal/berryIEvaluationResultCache.h"
#include <org_blueberry_ui_Export.h>
namespace berry {
struct IHandler;
struct IHandlerService;
/**
* <p>
* A token representing the activation of a handler. This token can later be
* used to cancel that activation. Without this token, then handler will only
* become inactive if the component in which the handler was activated is
* destroyed.
* </p>
* <p>
* This interface is not intended to be implemented or extended by clients.
* </p>
*
* @since 3.1
* @see org.eclipse.ui.ISources
* @see org.eclipse.ui.ISourceProvider
*/
struct BERRY_UI IHandlerActivation : public IEvaluationResultCache {
berryInterfaceMacro(IHandlerActivation, berry)
~IHandlerActivation();
/**
* The depth at which the root exists.
*
* @since 3.2
*/
static const int ROOT_DEPTH; // = 1;
/**
* Clears the cached computation of the <code>isActive</code> method, if
* any. This method is only intended for internal use. It provides a
* mechanism by which <code>ISourceProvider</code> events can invalidate
* state on a <code>IHandlerActivation</code> instance.
*
* @deprecated Use {@link IEvaluationResultCache#clearResult()} instead.
*/
virtual void ClearActive() = 0;
/**
* Returns the identifier of the command whose handler is being activated.
*
* @return The command identifier; never <code>null</code>.
*/
virtual std::string GetCommandId() const = 0;
/**
* Returns the depth at which this activation was created within the
* services hierarchy. The root of the hierarchy is at a depth of
* <code>1</code>. This is used as the final tie-breaker in the event
* that no other method can be used to determine a winner.
*
* @return The depth at which the handler was inserted into the services
* hierarchy; should be a positive integer.
* @since 3.2
*/
virtual int GetDepth() const = 0;
/**
* Returns the handler that should be activated.
*
* @return The handler; may be <code>null</code>.
*/
virtual SmartPointer<IHandler> GetHandler() const = 0;
/**
* Returns the handler service from which this activation was requested.
* This is used to ensure that an activation can only be retracted from the
* same service which issued it.
*
* @return The handler service; never <code>null</code>.
*/
virtual SmartPointer<IHandlerService> GetHandlerService() const = 0;
/**
* Returns whether this handler activation is currently active -- given the
* current state of the workbench. This method should cache its computation.
* The cache will be cleared by a call to <code>clearActive</code>.
*
* @param context
* The context in which this state should be evaluated; must not
* be <code>null</code>.
* @return <code>true</code> if the activation is currently active;
* <code>false</code> otherwise.
* @deprecated Use
* {@link IEvaluationResultCache#evaluate(IEvaluationContext)}
* instead.
*/
virtual bool IsActive(SmartPointer<IEvaluationContext> context) const = 0;
};
}
#endif /* BERRYIHANDLERACTIVATION_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/handlers/berryIHandlerService.h b/BlueBerry/Bundles/org.blueberry.ui/src/handlers/berryIHandlerService.h
index bad39e1a2d..659bdf5888 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/handlers/berryIHandlerService.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/handlers/berryIHandlerService.h
@@ -1,434 +1,434 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIHANDLERSERVICE_H_
#define BERRYIHANDLERSERVICE_H_
#include "services/berryIServiceWithSources.h"
#include "common/berryCommandExceptions.h"
namespace berry {
class Command;
class ExecutionEvent;
class ParameterizedCommand;
class Expression;
class UIElement;
class IEvaluationContext;
struct IHandler;
struct IHandlerActivation;
/**
* <p>
* Provides services related to activating and deactivating handlers within the
* workbench.
* </p>
* <p>
* This service can be acquired from your service locator:
* <pre>
* IHandlerService service = (IHandlerService) getSite().getService(IHandlerService.class);
* </pre>
* <ul>
* <li>This service is available globally.</li>
* </ul>
* </p>
* @noimplement This interface is not intended to be implemented by clients.
* @noextend This interface is not intended to be extended by clients.
*
* @since 3.1
*/
struct BERRY_UI IHandlerService : public IServiceWithSources {
berryInterfaceMacro(IHandlerService, berry)
~IHandlerService();
/**
* <p>
* Activates the given handler from a child service. This is used by slave
* and nested services to promote handler activations up to the root. By
* using this method, it is possible for handlers coming from a more nested
* component to override the nested component.
* </p>
*
* @param activation
* The activation that is local to the child service; must not be
* <code>null</code>.
* @return A token which can be used to later cancel the activation. Only
* someone with access to this token can cancel the activation. The
* activation will automatically be cancelled if the service locator
* context from which this service was retrieved is destroyed. This
* activation is local to this service (i.e., it is not the
* activation that is passed as a parameter).
* @since 3.2
*/
virtual SmartPointer<IHandlerActivation> ActivateHandler(SmartPointer<IHandlerActivation> activation) = 0;
/**
* <p>
* Activates the given handler within the context of this service. If this
* service was retrieved from the workbench, then this handler will be
* active globally. If the service was retrieved from a nested component,
* then the handler will only be active within that component.
* </p>
* <p>
* Also, it is guaranteed that the handlers submitted through a particular
* service will be cleaned up when that services is destroyed. So, for
* example, a service retrieved from a <code>IWorkbenchPartSite</code>
* would deactivate all of its handlers when the site is destroyed.
* </p>
*
* @param commandId
* The identifier for the command which this handler handles;
* must not be <code>null</code>.
* @param handler
* The handler to activate; must not be <code>null</code>.
* @return A token which can be used to later cancel the activation. Only
* someone with access to this token can cancel the activation. The
* activation will automatically be cancelled if the context from
* which this service was retrieved is destroyed.
*/
virtual SmartPointer<IHandlerActivation> ActivateHandler(
const std::string& commandId, SmartPointer<IHandler> handler) = 0;
/**
* <p>
* Activates the given handler within the context of this service. The
* handler becomes active when <code>expression</code> evaluates to
* <code>true</code>. This is the same as calling
* {@link #activateHandler(String, IHandler, Expression, boolean)} with
* global==false.
* </p>
* <p>
* Also, it is guaranteed that the handlers submitted through a particular
* service will be cleaned up when that service is destroyed. So, for
* example, a service retrieved from a <code>IWorkbenchPartSite</code>
* would deactivate all of its handlers when the site is destroyed.
* </p>
*
* @param commandId
* The identifier for the command which this handler handles;
* must not be <code>null</code>.
* @param handler
* The handler to activate; must not be <code>null</code>.
* @param expression
* This expression must evaluate to <code>true</code> before
* this handler will really become active. The expression may be
* <code>null</code> if the handler should always be active.
* @return A token which can be used to later cancel the activation. Only
* someone with access to this token can cancel the activation. The
* activation will automatically be cancelled if the context from
* which this service was retrieved is destroyed.
*
* @see org.eclipse.ui.ISources
* @since 3.2
*/
virtual SmartPointer<IHandlerActivation> ActivateHandler(
const std::string& commandId,
SmartPointer<IHandler> handler, SmartPointer<Expression> expression) = 0;
/**
* <p>
* Activates the given handler within the context of this service. The
* handler becomes active when <code>expression</code> evaluates to
* <code>true</code>. if global==<code>false</code>, then this
* handler service must also be the active service to active the handler.
* For example, the handler service on a part is active when that part is
* active.
* </p>
* <p>
* Also, it is guaranteed that the handlers submitted through a particular
* service will be cleaned up when that services is destroyed. So, for
* example, a service retrieved from a <code>IWorkbenchPartSite</code>
* would deactivate all of its handlers when the site is destroyed.
* </p>
*
* @param commandId
* The identifier for the command which this handler handles;
* must not be <code>null</code>.
* @param handler
* The handler to activate; must not be <code>null</code>.
* @param expression
* This expression must evaluate to <code>true</code> before
* this handler will really become active. The expression may be
* <code>null</code> if the handler should always be active.
* @param global
* Indicates that the handler should be activated irrespectively
* of whether the corresponding workbench component (e.g.,
* window, part, etc.) is active.
* @return A token which can be used to later cancel the activation. Only
* someone with access to this token can cancel the activation. The
* activation will automatically be cancelled if the context from
* which this service was retrieved is destroyed.
*
* @see org.eclipse.ui.ISources
* @since 3.2
*/
virtual SmartPointer<IHandlerActivation> ActivateHandler(const std::string& commandId,
SmartPointer<IHandler> handler, SmartPointer<Expression> expression, bool global) = 0;
/**
* <p>
* Activates the given handler within the context of this service. The
* handler becomes active when <code>expression</code> evaluates to
* <code>true</code>.
* </p>
* <p>
* Also, it is guaranteed that the handlers submitted through a particular
* service will be cleaned up when that services is destroyed. So, for
* example, a service retrieved from a <code>IWorkbenchPartSite</code>
* would deactivate all of its handlers when the site is destroyed.
* </p>
*
* @param commandId
* The identifier for the command which this handler handles;
* must not be <code>null</code>.
* @param handler
* The handler to activate; must not be <code>null</code>.
* @param expression
* This expression must evaluate to <code>true</code> before
* this handler will really become active. The expression may be
* <code>null</code> if the handler should always be active.
* @param sourcePriorities
* The source priorities for the expression.
* @return A token which can be used to later cancel the activation. Only
* someone with access to this token can cancel the activation. The
* activation will automatically be cancelled if the context from
* which this service was retrieved is destroyed.
*
* @see org.eclipse.ui.ISources
* @deprecated Use
* {@link IHandlerService#activateHandler(String, IHandler, Expression)}
* instead.
*/
virtual SmartPointer<IHandlerActivation> ActivateHandler(const std::string& commandId,
SmartPointer<IHandler> handler, SmartPointer<Expression> expression,
int sourcePriorities) = 0;
/**
* Creates an execution event based on an SWT event. This execution event
* can then be passed to a command for execution.
*
* @param command
* The command for which an execution event should be created;
* must not be <code>null</code>.
* @param event
* The SWT event triggering the command execution; may be
* <code>null</code>.
* @return An execution event suitable for calling
* {@link Command#executeWithChecks(ExecutionEvent)}.
* @since 3.2
* @see Command#executeWithChecks(ExecutionEvent)
*/
virtual SmartPointer<const ExecutionEvent> CreateExecutionEvent(
SmartPointer<const Command> command, SmartPointer<const UIElement> uielement) = 0;
/**
* Creates a parameterized execution event based on an SWT event and a
* parameterized command. This execution event can then be passed to a
* command for execution.
*
* @param command
* The parameterized command for which an execution event should
* be created; must not be <code>null</code>.
* @param event
* The SWT event triggering the command execution; may be
* <code>null</code>.
* @return An execution event suitable for calling
* {@link Command#executeWithChecks(ExecutionEvent)}.
* @since 3.2
* @see ParameterizedCommand#getCommand()
* @see Command#executeWithChecks(ExecutionEvent)
*/
virtual SmartPointer<const ExecutionEvent> CreateExecutionEvent(
SmartPointer<const ParameterizedCommand> command,
SmartPointer<const UIElement> uielement) = 0;
/**
* Deactivates the given handler within the context of this service. If the
* handler was activated with a different service, then it must be
* deactivated from that service instead. It is only possible to retract a
* handler activation with this method. That is, you must have the same
* <code>IHandlerActivation</code> used to activate the handler.
*
* @param activation
* The token that was returned from a call to
* <code>activateHandler</code>; must not be <code>null</code>.
*/
virtual void DeactivateHandler(SmartPointer<IHandlerActivation> activation) = 0;
/**
* Deactivates the given handlers within the context of this service. If the
* handler was activated with a different service, then it must be
* deactivated from that service instead. It is only possible to retract a
* handler activation with this method. That is, you must have the same
* <code>IHandlerActivation</code> used to activate the handler.
*
* @param activations
* The tokens that were returned from a call to
* <code>activateHandler</code>. This collection must only
* contain instances of <code>IHandlerActivation</code>. The
* collection must not be <code>null</code>.
*/
virtual void DeactivateHandlers(
const std::vector<SmartPointer<IHandlerActivation> >& activations) = 0;
/**
* Executes the command with the given identifier and no parameters.
*
* @param commandId
* The identifier of the command to execute; must not be
* <code>null</code>.
* @param event
* The SWT event triggering the command execution; may be
* <code>null</code>.
* @return The return value from the execution; may be <code>null</code>.
* @throws ExecutionException
* If the handler has problems executing this command.
* @throws NotDefinedException
* If the command you are trying to execute is not defined.
* @throws NotEnabledException
* If the command you are trying to execute is not enabled.
* @throws NotHandledException
* If there is no handler.
* @since 3.2
* @see Command#executeWithChecks(ExecutionEvent)
*/
virtual Object::Pointer ExecuteCommand(const std::string& commandId,
SmartPointer<const UIElement> uielement)
throw(ExecutionException, NotDefinedException,
NotEnabledException, NotHandledException) = 0;
/**
* Executes the given parameterized command.
*
* @param command
* The parameterized command to be executed; must not be
* <code>null</code>.
* @param event
* The SWT event triggering the command execution; may be
* <code>null</code>.
* @return The return value from the execution; may be <code>null</code>.
* @throws ExecutionException
* If the handler has problems executing this command.
* @throws NotDefinedException
* If the command you are trying to execute is not defined.
* @throws NotEnabledException
* If the command you are trying to execute is not enabled.
* @throws NotHandledException
* If there is no handler.
* @since 3.2
* @see Command#executeWithChecks(ExecutionEvent)
*/
virtual Object::Pointer ExecuteCommand(
SmartPointer<ParameterizedCommand> command,
SmartPointer<const UIElement> uielement)
throw(ExecutionException, NotDefinedException,
NotEnabledException, NotHandledException) = 0;
/**
* Executes the given parameterized command in the provided context. It
* takes care of finding the correct active handler given the context, calls
* {@link IHandler2#setEnabled(Object)} to update the enabled state if
* supported, and executes with that handler.
*
* @param command
* The parameterized command to be executed; must not be
* <code>null</code>.
* @param event
* The SWT event triggering the command execution; may be
* <code>null</code>.
* @param context
* the evaluation context to run against. Must not be
* <code>null</code>
* @return The return value from the execution; may be <code>null</code>.
* @throws ExecutionException
* If the handler has problems executing this command.
* @throws NotDefinedException
* If the command you are trying to execute is not defined.
* @throws NotEnabledException
* If the command you are trying to execute is not enabled.
* @throws NotHandledException
* If there is no handler.
* @since 3.4
* @see Command#executeWithChecks(ExecutionEvent)
* @see #createContextSnapshot(boolean)
*/
virtual Object::Pointer ExecuteCommandInContext(
SmartPointer<ParameterizedCommand> command,
SmartPointer<const UIElement> uielement,
SmartPointer<IEvaluationContext> context)
throw(ExecutionException,
NotDefinedException, NotEnabledException, NotHandledException) = 0;
/**
* This method creates a copy of the application context returned by
* {@link #getCurrentState()}.
*
* @param includeSelection
* if <code>true</code>, include the default variable and
* selection variables
* @return an context filled with the current set of variables. If selection
* is not included, the default variable is an empty collection
* @since 3.4
*/
virtual SmartPointer<IEvaluationContext> CreateContextSnapshot(bool includeSelection) = 0;
/**
* Returns an evaluation context representing the current state of the
* world. This is equivalent to the application context required by
* {@link ExecutionEvent}.
*
* @return the current state of the application; never <code>null</code>.
* @see ParameterizedCommand#executeWithChecks(Object, Object)
* @see ExecutionEvent#ExecutionEvent(Command, java.util.Map, Object,
* Object)
* @see org.eclipse.ui.services.IEvaluationService
*/
virtual SmartPointer<IEvaluationContext> GetCurrentState() const = 0;
/**
* <p>
* Reads the handler information from the registry. This will overwrite any
* of the existing information in the handler service. This method is
* intended to be called during start-up. When this method completes, this
* handler service will reflect the current state of the registry.
* </p>
*/
virtual void ReadRegistry() = 0;
/**
* Sets the help context identifier to associate with a particular handler.
*
* @param handler
* The handler with which to register a help context identifier;
* must not be <code>null</code>.
* @param helpContextId
* The help context identifier to register; may be
* <code>null</code> if the help context identifier should be
* removed.
* @since 3.2
*/
virtual void SetHelpContextId(SmartPointer<IHandler> handler, const std::string& helpContextId) = 0;
};
}
#endif /* BERRYIHANDLERSERVICE_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/handlers/berryShowViewHandler.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/handlers/berryShowViewHandler.cpp
index 8a171a56bc..e6e52fb35d 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/handlers/berryShowViewHandler.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/handlers/berryShowViewHandler.cpp
@@ -1,117 +1,117 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryShowViewHandler.h"
#include "berryHandlerUtil.h"
#include "tweaklets/berryWorkbenchTweaklet.h"
#include "dialogs/berryIShowViewDialog.h"
#include "berryUIException.h"
#include "berryIWorkbenchPage.h"
#include "berryIViewDescriptor.h"
#include "berryPlatformUI.h"
#include <berryCommandExceptions.h>
#include <vector>
namespace berry
{
const std::string ShowViewHandler::PARAMETER_NAME_VIEW_ID = "org.blueberry.ui.showView.viewId"; //$NON-NLS-1$
ShowViewHandler::ShowViewHandler()
{
}
Object::Pointer ShowViewHandler::Execute(
const ExecutionEvent::Pointer event)
{
IWorkbenchWindow::Pointer window = HandlerUtil::GetActiveWorkbenchWindowChecked(event);
// Get the view identifier, if any.
const ExecutionEvent::ParameterMap& parameters = event->GetParameters();
ExecutionEvent::ParameterMap::const_iterator result = parameters.find(PARAMETER_NAME_VIEW_ID);
std::string value;
if (result != parameters.end()) value = result->second;
if (value == "")
{
this->OpenOther(window);
}
else
{
try
{
this->OpenView(value, window);
}
catch (PartInitException e)
{
throw ExecutionException("Part could not be initialized", e); //$NON-NLS-1$
}
}
return Object::Pointer(0);
}
void ShowViewHandler::OpenOther(IWorkbenchWindow::Pointer window)
{
const IWorkbenchPage::Pointer page = window->GetActivePage();
if (page.IsNull())
{
return;
}
IShowViewDialog::Pointer dialog = Tweaklets::Get(WorkbenchTweaklet::KEY)->CreateStandardDialog(WorkbenchTweaklet::DIALOG_ID_SHOW_VIEW).Cast<IShowViewDialog>();
if (dialog.IsNull()) return;
int returnCode = dialog->Open();
if (returnCode == IDialog::CANCEL)
{
return;
}
const std::vector<IViewDescriptor::Pointer> descriptors =
dialog->GetSelection();
for (unsigned int i = 0; i < descriptors.size(); ++i)
{
try
{
this->OpenView(descriptors[i]->GetId(), window);
}
catch (PartInitException e)
{
// StatusUtil.handleStatus(e.getStatus(),
// WorkbenchMessages.ShowView_errorTitle
// + ": " + e.getMessage(), //$NON-NLS-1$
// StatusManager.SHOW);
}
}
}
void ShowViewHandler::OpenView(const std::string& viewId, IWorkbenchWindow::Pointer activeWorkbenchWindow)
{
const IWorkbenchPage::Pointer activePage = activeWorkbenchWindow->GetActivePage();
if (activePage.IsNull())
{
return;
}
activePage->ShowView(viewId);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/handlers/berryShowViewHandler.h b/BlueBerry/Bundles/org.blueberry.ui/src/handlers/berryShowViewHandler.h
index 7cb6b6a844..f5c1256ac0 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/handlers/berryShowViewHandler.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/handlers/berryShowViewHandler.h
@@ -1,80 +1,80 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYSHOWVIEWHANDLER_H_
#define BERRYSHOWVIEWHANDLER_H_
#include <berryAbstractHandler.h>
#include <berryExecutionEvent.h>
#include "berryIWorkbenchWindow.h"
#include <org_blueberry_ui_Export.h>
namespace berry
{
/**
* \ingroup org_blueberry_ui
*
* Shows the given view. If no view is specified in the parameters, then this
* opens the view selection dialog.
*
* @since 3.1
*/
class BERRY_UI ShowViewHandler : public AbstractHandler
{
public:
berryObjectMacro(ShowViewHandler)
private:
/**
* The name of the parameter providing the view identifier.
*/
static const std::string PARAMETER_NAME_VIEW_ID;
public:
/**
* Creates a new ShowViewHandler that will open the view in its default location.
*/
ShowViewHandler();
Object::Pointer Execute(
const ExecutionEvent::Pointer event);
private:
/**
* Opens a view selection dialog, allowing the user to chose a view.
*/
void OpenOther(IWorkbenchWindow::Pointer window);
/**
* Opens the view with the given identifier.
*
* @param viewId
* The view to open; must not be <code>null</code>
* @throws PartInitException
* If the part could not be initialized.
*/
void OpenView(const std::string& viewId, IWorkbenchWindow::Pointer activeWorkbenchWindow);
};
}
#endif /*BERRYSHOWVIEWHANDLER_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryAbstractDropTarget.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryAbstractDropTarget.h
index 1077c35529..7601432239 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryAbstractDropTarget.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryAbstractDropTarget.h
@@ -1,44 +1,44 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYABSTRACTDROPTARGET_H_
#define BERRYABSTRACTDROPTARGET_H_
#include "berryIDropTarget.h"
namespace berry {
struct AbstractDropTarget : public IDropTarget
{
/*
* @see IDropTarget#GetSnapRectangle()
*/
Rectangle GetSnapRectangle()
{
return Rectangle();
}
void DragFinished(bool /*dropPerformed*/)
{
}
};
}
#endif /* BERRYABSTRACTDROPTARGET_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryAbstractPartSelectionTracker.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryAbstractPartSelectionTracker.cpp
index d8c181a75c..8b4fcda62d 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryAbstractPartSelectionTracker.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryAbstractPartSelectionTracker.cpp
@@ -1,130 +1,130 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryAbstractPartSelectionTracker.h"
#include "berryIPostSelectionProvider.h"
#include "berryINullSelectionListener.h"
#include "util/berrySafeRunnable.h"
#include <berrySafeRunner.h>
namespace berry
{
class SafeSelectionRunnable : public SafeRunnable
{
public:
berryObjectMacro(SafeSelectionRunnable)
ISelectionListener::Pointer l;
SafeSelectionRunnable(IWorkbenchPart::Pointer part, ISelection::ConstPointer sel)
: p(part), s(sel)
{}
void Run()
{
l->SelectionChanged(p, s);
}
private:
IWorkbenchPart::Pointer p;
ISelection::ConstPointer s;
};
AbstractPartSelectionTracker::AbstractPartSelectionTracker(
const std::string& partId)
{
this->SetPartId(partId);
}
void AbstractPartSelectionTracker::AddSelectionListener(
ISelectionListener::Pointer listener)
{
fListeners.push_back(listener);
}
void AbstractPartSelectionTracker::AddPostSelectionListener(
ISelectionListener::Pointer listener)
{
fPostListeners.push_back(listener);
}
void AbstractPartSelectionTracker::RemoveSelectionListener(
ISelectionListener::Pointer listener)
{
fListeners.remove(listener);
}
void AbstractPartSelectionTracker::RemovePostSelectionListener(
ISelectionListener::Pointer listener)
{
fPostListeners.remove(listener);
}
AbstractPartSelectionTracker::~AbstractPartSelectionTracker()
{
}
void AbstractPartSelectionTracker::FireSelection(IWorkbenchPart::Pointer part,
ISelection::ConstPointer sel)
{
SafeSelectionRunnable::Pointer runnable(new SafeSelectionRunnable(part, sel));
for (std::list<ISelectionListener::Pointer>::iterator i = fListeners.begin();
i != fListeners.end(); ++i)
{
ISelectionListener::Pointer l = *i;
if ((part && sel) || l.Cast<INullSelectionListener>())
{
runnable->l = l;
SafeRunner::Run(runnable);
}
}
}
void AbstractPartSelectionTracker::FirePostSelection(IWorkbenchPart::Pointer part,
ISelection::ConstPointer sel)
{
SafeSelectionRunnable::Pointer runnable(new SafeSelectionRunnable(part, sel));
for (std::list<ISelectionListener::Pointer>::iterator i = fPostListeners.begin();
i != fPostListeners.end(); ++i)
{
ISelectionListener::Pointer l = *i;
if ((part && sel) || l.Cast<INullSelectionListener>())
{
runnable->l = l;
SafeRunner::Run(runnable);
}
}
}
std::string AbstractPartSelectionTracker::GetPartId()
{
return fPartId;
}
void AbstractPartSelectionTracker::SetPartId(const std::string& partId)
{
fPartId = partId;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryAbstractPartSelectionTracker.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryAbstractPartSelectionTracker.h
index a1ff794279..39596a00a2 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryAbstractPartSelectionTracker.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryAbstractPartSelectionTracker.h
@@ -1,144 +1,144 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYABSTRACTPARTSELECTIONTRACKER_H_
#define BERRYABSTRACTPARTSELECTIONTRACKER_H_
#include <berryObject.h>
#include <berryMacros.h>
#include "berryISelectionService.h"
#include "berryISelectionListener.h"
#include "berryIWorkbenchPart.h"
#include <list>
namespace berry {
class AbstractPartSelectionTracker : public virtual Object
{
public:
berryObjectMacro(AbstractPartSelectionTracker);
private:
/**
* List of selection listeners for this tracker
*/
std::list<ISelectionListener::Pointer> fListeners;
/**
* List of post selection listeners for this tracker
*/
std::list<ISelectionListener::Pointer> fPostListeners;
/**
* The id of the part this tracker tracks
*/
std::string fPartId;
public:
/**
* Constructs a part selection tracker for the part with the given id.
*
* @param id part identifier
*/
AbstractPartSelectionTracker(const std::string& partId);
/**
* Adds a selection listener to this tracker
*
* @param listener the listener to add
*/
void AddSelectionListener(ISelectionListener::Pointer listener);
/**
* Adds a post selection listener to this tracker
*
* @param listener the listener to add
*/
void AddPostSelectionListener(ISelectionListener::Pointer listener);
/**
* Returns the selection from the part being tracked,
* or <code>null</code> if the part is closed or has no selection.
*/
virtual ISelection::ConstPointer GetSelection() = 0;
/**
* Removes a selection listener from this tracker.
*
* @param listener the listener to remove
*/
void RemoveSelectionListener(ISelectionListener::Pointer listener);
/**
* Removes a post selection listener from this tracker.
*
* @param listener the listener to remove
*/
void RemovePostSelectionListener(ISelectionListener::Pointer listener);
/**
* Disposes this selection tracker. This removes all listeners currently registered.
*/
~AbstractPartSelectionTracker();
protected:
/**
* Fires a selection event to the listeners.
*
* @param part the part or <code>null</code> if no active part
* @param sel the selection or <code>null</code> if no active selection
* @param listeners the list of listeners to notify
*/
void FireSelection(IWorkbenchPart::Pointer part, ISelection::ConstPointer sel);
/**
* Fires a post selection event to the listeners.
*
* @param part the part or <code>null</code> if no active part
* @param sel the selection or <code>null</code> if no active selection
* @param listeners the list of listeners to notify
*/
void FirePostSelection(IWorkbenchPart::Pointer part, ISelection::ConstPointer sel);
/**
* Returns the id of the part that this tracks.
*
* @return part identifier
*/
std::string GetPartId();
private:
/**
* Sets the id of the part that this tracks.
*
* @param id view identifier
*/
void SetPartId(const std::string& partId);
};
}
#endif /* BERRYABSTRACTPARTSELECTIONTRACKER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryAbstractSelectionService.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryAbstractSelectionService.cpp
index 693f05f1d0..ffbc5a47ca 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryAbstractSelectionService.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryAbstractSelectionService.cpp
@@ -1,264 +1,264 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryAbstractSelectionService.h"
#include "berryWorkbenchPlugin.h"
#include "berryIPostSelectionProvider.h"
#include "berryINullSelectionListener.h"
namespace berry
{
//ISelectionService::SelectionEvents& AbstractSelectionService::GetSelectionEvents(const std::string& partId)
//{
// if (partId.empty())
// {
// return selectionEvents;
// }
//
// return this->GetPerPartTracker(partId)->GetSelectionEvents();
//}
AbstractSelectionService::AbstractSelectionService()
{
selListener = new SelectionListener(this);
postSelListener = new PostSelectionListener(this);
}
AbstractSelectionService::SelectionListener::SelectionListener(AbstractSelectionService* service)
: m_SelectionService(service)
{ }
void AbstractSelectionService::SelectionListener::SelectionChanged(SelectionChangedEvent::Pointer event)
{
m_SelectionService->FireSelection(m_SelectionService->activePart, event->GetSelection());
}
AbstractSelectionService::PostSelectionListener::PostSelectionListener(AbstractSelectionService* service)
: m_SelectionService(service)
{ }
void AbstractSelectionService::PostSelectionListener::SelectionChanged(
SelectionChangedEvent::Pointer event)
{
m_SelectionService->FirePostSelection(m_SelectionService->activePart, event->GetSelection());
}
void AbstractSelectionService::AddSelectionListener(ISelectionListener::Pointer l)
{
fListeners.push_back(l);
}
void AbstractSelectionService::AddSelectionListener(const std::string& partId,
ISelectionListener::Pointer listener)
{
this->GetPerPartTracker(partId)->AddSelectionListener(listener);
}
void AbstractSelectionService::AddPostSelectionListener(
ISelectionListener::Pointer l)
{
fPostListeners.push_back(l);
}
void AbstractSelectionService::AddPostSelectionListener(const std::string& partId,
ISelectionListener::Pointer listener)
{
this->GetPerPartTracker(partId)->AddPostSelectionListener(listener);
}
void AbstractSelectionService::RemoveSelectionListener(ISelectionListener::Pointer l)
{
fListeners.remove(l);
}
void AbstractSelectionService::RemovePostSelectionListener(
const std::string& partId, ISelectionListener::Pointer listener)
{
this->GetPerPartTracker(partId)->RemovePostSelectionListener(listener);
}
void AbstractSelectionService::RemovePostSelectionListener(
ISelectionListener::Pointer l)
{
fPostListeners.remove(l);
}
void AbstractSelectionService::RemoveSelectionListener(const std::string& partId,
ISelectionListener::Pointer listener)
{
this->GetPerPartTracker(partId)->RemoveSelectionListener(listener);
}
void AbstractSelectionService::FireSelection(IWorkbenchPart::Pointer part,
ISelection::ConstPointer sel)
{
for (std::list<ISelectionListener::Pointer>::iterator i = fListeners.begin();
i != fListeners.end(); ++i)
{
ISelectionListener::Pointer l = *i;
if ((part && sel) || l.Cast<INullSelectionListener>())
{
try
{
l->SelectionChanged(part, sel);
}
catch (const Poco::RuntimeException& rte)
{
WorkbenchPlugin::Log(rte);
}
catch (const std::exception& e)
{
WorkbenchPlugin::Log(e.what());
}
}
}
}
void AbstractSelectionService::FirePostSelection(IWorkbenchPart::Pointer part,
ISelection::ConstPointer sel)
{
for (std::list<ISelectionListener::Pointer>::iterator i = fPostListeners.begin();
i != fPostListeners.end(); ++i)
{
ISelectionListener::Pointer l = *i;
if ((part && sel) || l.Cast<INullSelectionListener>())
{
try
{
l->SelectionChanged(part, sel);
}
catch (const Poco::RuntimeException& rte)
{
WorkbenchPlugin::Log(rte);
}
catch (const std::exception& e)
{
WorkbenchPlugin::Log(e.what());
}
}
}
}
AbstractPartSelectionTracker::Pointer AbstractSelectionService::GetPerPartTracker(
const std::string& partId)
{
AbstractPartSelectionTracker::Pointer tracker;
std::map<std::string, AbstractPartSelectionTracker::Pointer>::const_iterator res = perPartTrackers.find(partId);
if (res == perPartTrackers.end())
{
tracker = this->CreatePartTracker(partId);
perPartTrackers[partId] = tracker;
}
else
{
tracker = res->second;
}
return tracker;
}
ISelection::ConstPointer AbstractSelectionService::GetSelection() const
{
if (activeProvider.IsNotNull())
{
return activeProvider->GetSelection();
}
else
{
return ISelection::ConstPointer(0);
}
}
ISelection::ConstPointer AbstractSelectionService::GetSelection(const std::string& partId)
{
return this->GetPerPartTracker(partId)->GetSelection();
}
void AbstractSelectionService::SetActivePart(IWorkbenchPart::Pointer newPart)
{
// Optimize.
if (newPart == activePart)
{
return;
}
ISelectionProvider::Pointer selectionProvider;
if (newPart.IsNotNull())
{
selectionProvider = newPart->GetSite()->GetSelectionProvider();
if (selectionProvider.IsNull())
{
newPart = 0;
}
}
if (newPart == activePart)
{
return;
}
if (activePart.IsNotNull())
{
if (activeProvider.IsNotNull())
{
activeProvider->RemoveSelectionChangedListener(selListener);
if (activeProvider.Cast<IPostSelectionProvider>().IsNotNull())
{
activeProvider.Cast<IPostSelectionProvider>()
->RemovePostSelectionChangedListener(postSelListener);
}
else
{
activeProvider
->RemoveSelectionChangedListener(postSelListener);
}
activeProvider = 0;
}
activePart = 0;
}
activePart = newPart;
if (newPart.IsNotNull())
{
activeProvider = selectionProvider;
// Fire an event if there's an active provider
activeProvider->AddSelectionChangedListener(selListener);
ISelection::ConstPointer sel = activeProvider->GetSelection();
this->FireSelection(newPart, sel);
if (activeProvider.Cast<IPostSelectionProvider>().IsNotNull())
{
activeProvider.Cast<IPostSelectionProvider>()
->AddPostSelectionChangedListener(postSelListener);
}
else
{
activeProvider->AddSelectionChangedListener(postSelListener);
}
this->FirePostSelection(newPart, sel);
}
else
{
this->FireSelection(IWorkbenchPart::Pointer(0), ISelection::ConstPointer(0));
this->FirePostSelection(IWorkbenchPart::Pointer(0), ISelection::ConstPointer(0));
}
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryAbstractSelectionService.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryAbstractSelectionService.h
index acdd5922ea..714ffcbb7a 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryAbstractSelectionService.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryAbstractSelectionService.h
@@ -1,320 +1,320 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYABSTRACTSELECTIONSERVICE_H_
#define BERRYABSTRACTSELECTIONSERVICE_H_
#include "berryISelectionService.h"
#include "berryIWorkbenchPage.h"
#include "berryISelectionChangedListener.h"
#include "berryISelectionProvider.h"
#include "berryAbstractPartSelectionTracker.h"
#include <map>
namespace berry
{
/**
* \ingroup org_blueberry_ui_internal
*
* The selection service for a page
*/
class AbstractSelectionService : public ISelectionService {
private:
IWorkbenchPage* page;
/**
* The list of selection listeners (not per-part).
*/
std::list<ISelectionListener::Pointer> fListeners;
/**
* The list of post selection listeners (not per-part).
*/
std::list<ISelectionListener::Pointer> fPostListeners;
/**
* The currently active part.
*/
IWorkbenchPart::Pointer activePart;
/**
* The active part's selection provider, remembered in case the part
* replaces its selection provider after we hooked a listener.
*/
ISelectionProvider::Pointer activeProvider;
/**
* Map from part id (String) to per-part tracker (AbstractPartSelectionTracker).
*/
std::map<std::string, AbstractPartSelectionTracker::Pointer> perPartTrackers;
struct SelectionListener : public ISelectionChangedListener
{
SelectionListener(AbstractSelectionService* tracker);
void SelectionChanged(SelectionChangedEvent::Pointer event);
AbstractSelectionService* m_SelectionService;
};
friend class PostSelectionListener;
struct PostSelectionListener : public ISelectionChangedListener
{
PostSelectionListener(AbstractSelectionService* tracker);
void SelectionChanged(SelectionChangedEvent::Pointer event);
AbstractSelectionService* m_SelectionService;
};
friend struct PostSelectionListener;
/**
* The JFace selection listener to hook on the active part's selection provider.
*/
ISelectionChangedListener::Pointer selListener;
/**
* The JFace post selection listener to hook on the active part's selection provider.
*/
ISelectionChangedListener::Pointer postSelListener;
public:
//SelectionEvents& GetSelectionEvents(const std::string& partId = "");
/* (non-Javadoc)
* Method declared on ISelectionService.
*/
void AddSelectionListener(ISelectionListener::Pointer l);
/* (non-Javadoc)
* Method declared on ISelectionService.
*/
void AddSelectionListener(const std::string& partId, ISelectionListener::Pointer listener);
/* (non-Javadoc)
* Method declared on ISelectionService.
*/
void AddPostSelectionListener(ISelectionListener::Pointer l);
/* (non-Javadoc)
* Method declared on ISelectionService.
*/
void AddPostSelectionListener(const std::string& partId,
ISelectionListener::Pointer listener);
/* (non-Javadoc)
* Method declared on ISelectionService.
*/
void RemoveSelectionListener(ISelectionListener::Pointer l);
/*
* (non-Javadoc)
* Method declared on ISelectionListener.
*/
void RemovePostSelectionListener(const std::string& partId,
ISelectionListener::Pointer listener);
/* (non-Javadoc)
* Method declared on ISelectionService.
*/
void RemovePostSelectionListener(ISelectionListener::Pointer l);
/*
* (non-Javadoc)
* Method declared on ISelectionListener.
*/
void RemoveSelectionListener(const std::string& partId,
ISelectionListener::Pointer listener);
protected:
AbstractSelectionService();
/**
* Fires a selection event to the given listeners.
*
* @param part the part or <code>null</code> if no active part
* @param sel the selection or <code>null</code> if no active selection
*/
void FireSelection(IWorkbenchPart::Pointer part, ISelection::ConstPointer sel);
/**
* Fires a selection event to the given listeners.
*
* @param part the part or <code>null</code> if no active part
* @param sel the selection or <code>null</code> if no active selection
*/
void FirePostSelection(IWorkbenchPart::Pointer part,
ISelection::ConstPointer sel);
/**
* Returns the per-part selection tracker for the given part id.
*
* @param partId part identifier
* @return per-part selection tracker
*/
AbstractPartSelectionTracker::Pointer GetPerPartTracker(const std::string& partId);
/**
* Creates a new per-part selection tracker for the given part id.
*
* @param partId part identifier
* @return per-part selection tracker
*/
virtual AbstractPartSelectionTracker::Pointer CreatePartTracker(
const std::string& partId) const = 0;
public:
/**
* Returns the selection.
*/
ISelection::ConstPointer GetSelection() const;
/*
* @see ISelectionService#getSelection(String)
*/
ISelection::ConstPointer GetSelection(const std::string& partId);
/**
* Sets the current-active part (or null if none)
*
* @since 3.1
*
* @param newPart the new active part (or null if none)
*/
void SetActivePart(IWorkbenchPart::Pointer newPart);
// /**
// * Notifies the listener that a part has been activated.
// */
// public void partActivated(IWorkbenchPart newPart) {
// // Optimize.
// if (newPart == activePart)
// return;
//
// // Unhook selection from the old part.
// reset();
//
// // Update active part.
// activePart = newPart;
//
// // Hook selection on the new part.
// if (activePart != null) {
// activeProvider = activePart.getSite().getSelectionProvider();
// if (activeProvider != null) {
// // Fire an event if there's an active provider
// activeProvider.addSelectionChangedListener(selListener);
// ISelection sel = activeProvider.getSelection();
// fireSelection(newPart, sel);
// if (activeProvider instanceof IPostSelectionProvider)
// ((IPostSelectionProvider) activeProvider)
// .addPostSelectionChangedListener(postSelListener);
// else
// activeProvider.addSelectionChangedListener(postSelListener);
// firePostSelection(newPart, sel);
// } else {
// //Reset active part. activeProvider may not be null next time this method is called.
// activePart = null;
// }
// }
// // No need to fire an event if no active provider, since this was done in reset()
// }
//
// /**
// * Notifies the listener that a part has been brought to the front.
// */
// public void partBroughtToTop(IWorkbenchPart newPart) {
// // do nothing, the active part has not changed,
// // so the selection is unaffected
// }
//
// /**
// * Notifies the listener that a part has been closed
// */
// public void partClosed(IWorkbenchPart part) {
// // Unhook selection from the part.
// if (part == activePart) {
// reset();
// }
// }
//
// /**
// * Notifies the listener that a part has been deactivated.
// */
// public void partDeactivated(IWorkbenchPart part) {
// // Unhook selection from the part.
// if (part == activePart) {
// reset();
// }
// }
//
// /**
// * Notifies the listener that a part has been opened.
// */
// public void partOpened(IWorkbenchPart part) {
// // Wait for activation.
// }
//
// /**
// * Notifies the listener that a part has been opened.
// */
// public void partInputChanged(IWorkbenchPart part) {
// // 36501 - only process if part is active
// if (activePart == part) {
// reset();
// partActivated(part);
// }
// }
//
// /**
// * Resets the service. The active part and selection provider are
// * dereferenced.
// */
// public void reset() {
// if (activePart != null) {
// fireSelection(null, null);
// firePostSelection(null, null);
// if (activeProvider != null) {
// activeProvider.removeSelectionChangedListener(selListener);
// if (activeProvider instanceof IPostSelectionProvider)
// ((IPostSelectionProvider) activeProvider)
// .removePostSelectionChangedListener(postSelListener);
// else
// activeProvider
// .removeSelectionChangedListener(postSelListener);
// activeProvider = null;
// }
// activePart = null;
// }
// }
};
}
#endif /*BERRYABSTRACTSELECTIONSERVICE_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryBundleUtility.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryBundleUtility.cpp
index 992e4af041..3136ec72c8 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryBundleUtility.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryBundleUtility.cpp
@@ -1,114 +1,114 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryBundleUtility.h"
#include "berryWorkbenchPlugin.h"
#include <berryPlatform.h>
namespace berry
{
bool BundleUtility::IsActive(IBundle::Pointer bundle)
{
if (!bundle)
{
return false;
}
return bundle->GetState() == IBundle::BUNDLE_ACTIVE;
}
bool BundleUtility::IsActivated(IBundle::Pointer bundle)
{
if (bundle && bundle->GetState() == IBundle::BUNDLE_STARTING)
return true;
//return WorkbenchPlugin::GetDefault()->IsStarting(bundle);
return bundle && (bundle->GetState() == IBundle::BUNDLE_ACTIVE
|| bundle->GetState() == IBundle::BUNDLE_STOPPING);
}
bool BundleUtility::IsReady(IBundle::Pointer bundle)
{
return bundle && IsReady(bundle->GetState());
}
bool BundleUtility::IsReady(QSharedPointer<ctkPlugin> plugin)
{
return !plugin.isNull() && IsReady(plugin->getState());
}
bool BundleUtility::IsReady(IBundle::State bundleState)
{
return (bundleState == IBundle::BUNDLE_RESOLVED ||
bundleState == IBundle::BUNDLE_STARTING ||
bundleState == IBundle::BUNDLE_ACTIVE ||
bundleState == IBundle::BUNDLE_STOPPING);
}
bool BundleUtility::IsReady(ctkPlugin::State pluginState)
{
return (pluginState == ctkPlugin::RESOLVED ||
pluginState == ctkPlugin::STARTING ||
pluginState == ctkPlugin::ACTIVE ||
pluginState == ctkPlugin::STOPPING);
}
bool BundleUtility::IsActive(const std::string& bundleId)
{
return IsActive(Platform::GetBundle(bundleId));
}
bool BundleUtility::IsActivated(const std::string& bundleId)
{
return IsActivated(Platform::GetBundle(bundleId));
}
bool BundleUtility::IsReady(const std::string& bundleId)
{
return IsReady(Platform::GetBundle(bundleId));
}
QSharedPointer<ctkPlugin> BundleUtility::FindPlugin(const QString& symbolicName)
{
ctkPluginContext* context = WorkbenchPlugin::GetDefault()->GetPluginContext();
foreach (QSharedPointer<ctkPlugin> plugin, context->getPlugins())
{
if (plugin->getSymbolicName() == symbolicName)
{
return plugin;
}
}
return QSharedPointer<ctkPlugin>();
}
//void BundleUtility::Log(const std::string& bundleId,
// const Poco::Exception* exception)
//{
// IBundle::Pointer bundle = Platform::GetBundle(bundleId);
// if (!bundle)
// {
// return;
// }
//
// IStatus status =
// new Status(IStatus.ERROR, bundleId, IStatus.ERROR, exception.getMessage()
// == null ? "" : exception.getMessage(), //$NON-NLS-1$
// exception);
// Platform.getLog(bundle).log(status);
//}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryBundleUtility.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryBundleUtility.h
index 5c81c9e72a..f81fadc584 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryBundleUtility.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryBundleUtility.h
@@ -1,75 +1,75 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYBUNDLEUTILITY_H_
#define BERRYBUNDLEUTILITY_H_
#include <berryIBundle.h>
#include <ctkPlugin.h>
#include <QSharedPointer>
namespace berry
{
/**
* A set of static methods that provide an nicer interface to common platform
* operations related to bundle management.
*/
class BundleUtility
{
public:
static bool IsActive(IBundle::Pointer bundle);
static bool IsActivated(IBundle::Pointer bundle);
// TODO: needs a better name
static bool IsReady(IBundle::Pointer bundle);
static bool IsReady(QSharedPointer<ctkPlugin> plugin);
static bool IsReady(IBundle::State bundleState);
static bool IsReady(ctkPlugin::State pluginState);
static bool IsActive(const std::string& bundleId);
static bool IsActivated(const std::string& bundleId);
static bool IsReady(const std::string& bundleId);
static QSharedPointer<ctkPlugin> FindPlugin(const QString& symbName);
// static URL find(Bundle bundle, String path) {
// if (bundle == null) {
// return null;
// }
// return Platform.find(bundle, new Path(path));
// }
//
// static URL find(String bundleId, String path) {
// return find(Platform.getBundle(bundleId), path);
// }
// static void
// Log(const std::string& bundleId, const Poco::Exception* exception);
};
}
#endif /* BERRYBUNDLEUTILITY_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryCategory.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryCategory.h
index 3743c0e3d5..f0c8c4ffe3 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryCategory.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryCategory.h
@@ -1,185 +1,185 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYCATEGORY_H_
#define BERRYCATEGORY_H_
#include <berryIAdaptable.h>
#include <berryMacros.h>
namespace berry
{
/**
* \ingroup org_blueberry_ui_internal
*
* Category provides for hierarchical grouping of elements
* registered in the registry. One extension normally defines
* a category, and other reference it via its ID.
* <p>
* A category may specify its parent category in order to
* achieve hierarchy.
* </p>
*/
template<class T> class Category : /*IWorkbenchAdapter*/public IAdaptable, public Object
{
public:
berryObjectMacro(Category<T>);
typedef T ElementType;
/**
* Name of the miscellaneous category
*/
const static std::string MISC_NAME;
/**
* Identifier of the miscellaneous category
*/
const static std::string MISC_ID;
private:
std::string id;
std::string name;
std::vector<std::string> parentPath;
std::vector<ElementType> elements;
IConfigurationElement::Pointer configurationElement;
public:
/**
* Creates an instance of <code>Category</code> as a
* miscellaneous category.
*/
Category();
/**
* Creates an instance of <code>Category</code> with
* an ID and label.
*
* @param id the unique identifier for the category
* @param label the presentation label for this category
*/
Category(const std::string& id, const std::string& label);
/**
* Creates an instance of <code>Category</code> using the
* information from the specified configuration element.
*
* @param configElement the <code>IConfigurationElement<code> containing
* the ID, label, and optional parent category path.
* @throws WorkbenchException if the ID or label is <code>null</code
*/
Category(IConfigurationElement::Pointer configElement);
/**
* Add an element to this category.
*
* @param element the element to add
*/
void AddElement(ElementType element);
/* (non-Javadoc)
* Method declared on IWorkbenchAdapter.
*/
SmartPointer<ImageDescriptor> GetImageDescriptor() const;
/**
* Return the id for this category.
* @return the id
*/
const std::string& GetId() const;
/**
* Return the label for this category.
*
* @return the label
*/
std::string GetLabel() const;
/**
* Return the parent path for this category.
*
* @return the parent path
*/
const std::vector<std::string>& GetParentPath();
/**
* Return the unparsed parent path. May be <code>null</code>.
*
* @return the unparsed parent path or <code>null</code>
*/
std::string GetRawParentPath() const;
/**
* Return the root path for this category.
*
* @return the root path
*/
std::string GetRootPath();
/**
* Return the elements contained in this category.
*
* @return the elements
*/
const std::vector<ElementType>& GetElements() const;
/**
* Return whether a given object exists in this category.
*
* @param o the object to search for
* @return whether the object is in this category
*/
bool HasElement(const ElementType& o) const;
/**
* Return whether this category has child elements.
*
* @return whether this category has child elements
*/
bool HasElements() const;
/* (non-Javadoc)
* @see org.blueberry.ui.model.IWorkbenchAdapter#getParent(java.lang.Object)
*/
ElementType* GetParent(const ElementType& o);
/**
* Clear all elements from this category.
*
*/
void Clear();
protected:
/* (non-Javadoc)
* Method declared on IAdaptable.
*/
Poco::Any GetAdapter(const std::string& adapter);
};
} // namespace berry
#include "berryCategory.txx"
#endif /*BERRYCATEGORY_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryCategory.txx b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryCategory.txx
index c06a907d4b..ddcd02ad78 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryCategory.txx
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryCategory.txx
@@ -1,184 +1,184 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 __BERRY_CATEGORY_TXX__
#define __BERRY_CATEGORY_TXX__
#include "berryWorkbenchRegistryConstants.h"
#include "../berryUIException.h"
#include <Poco/StringTokenizer.h>
namespace berry
{
template<class T>
const std::string Category<T>::MISC_NAME = "Other";
template<class T>
const std::string Category<T>::MISC_ID =
"org.blueberry.ui.internal.otherCategory"; //$NON-NLS-1$
template<class T> Category<T>::Category()
{
this->id = MISC_ID;
this->name = MISC_NAME;
}
template<class T> Category<T>::Category(const std::string& ID,
const std::string& label)
: id(ID), name(label) {
}
template<class T>
Category<T>::Category(IConfigurationElement::Pointer configElement)
: configurationElement(configElement) {
std::string id;
configElement->GetAttribute(WorkbenchRegistryConstants::ATT_ID, id);
if (id == "" || GetLabel() == "")
{
throw WorkbenchException("Invalid category", id);
}
}
template<class T>
void Category<T>::AddElement(ElementType element)
{
elements.push_back(element);
}
template<class T>
Poco::Any Category<T>::GetAdapter(const std::string& adapter)
{
if (adapter == IConfigurationElement::GetStaticClassName())
{
return Poco::Any(configurationElement);
}
else
{
return Poco::Any();
}
}
//template<class T>
//ImageDescriptor Category<T>::GetImageDescriptor()
//{
// return WorkbenchImages.getImageDescriptor(ISharedImages.IMG_OBJ_FOLDER);
//}
template<class T>
const std::string& Category<T>::GetId() const
{
return id;
}
template<class T>
std::string Category<T>::GetLabel() const
{
if (configurationElement.IsNull())
return name;
std::string val;
configurationElement->GetAttribute(WorkbenchRegistryConstants::ATT_NAME, val);
return val;
}
template<class T>
const std::vector<std::string>& Category<T>::GetParentPath()
{
if (parentPath.size() > 0)
{
return parentPath;
}
std::string unparsedPath(this->GetRawParentPath());
Poco::StringTokenizer stok(unparsedPath, "/", Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM); //$NON-NLS-1$
for (Poco::StringTokenizer::Iterator iter = stok.begin(); iter != stok.end(); ++iter)
{
parentPath.push_back(*iter);
}
return parentPath;
}
template<class T>
std::string Category<T>::GetRawParentPath() const
{
if (configurationElement.IsNull())
return "";
std::string raw;
configurationElement->GetAttribute(WorkbenchRegistryConstants::ATT_PARENT_CATEGORY, raw);
return raw;
}
template<class T>
std::string Category<T>::GetRootPath()
{
if (this->GetParentPath().size() > 0)
{
return GetParentPath()[0];
}
return id;
}
template<class T>
const std::vector<T>& Category<T>::GetElements() const
{
return elements;
}
template<class T>
bool Category<T>::HasElement(const ElementType& o) const
{
if (elements.empty())
{
return false;
}
for (typename std::vector<ElementType>::const_iterator iter = elements.begin(); iter != elements.end(); ++iter)
{
if (*iter == o) return true;
}
return false;
}
template<class T>
bool Category<T>::HasElements() const
{
return !elements.empty();
}
template<class T>
T* Category<T>::GetParent(const ElementType& o)
{
return 0;
}
template<class T>
void Category<T>::Clear()
{
elements.clear();
}
} // namespace berry
#endif // __BERRY_CATEGORY_TXX__
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryContainerPlaceholder.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryContainerPlaceholder.cpp
index 249ed52482..3974e0e32d 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryContainerPlaceholder.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryContainerPlaceholder.cpp
@@ -1,142 +1,142 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryContainerPlaceholder.h"
#include "berryPartPlaceholder.h"
#include "berryILayoutContainer.h"
namespace berry
{
int ContainerPlaceholder::nextId = 0;
ContainerPlaceholder::ContainerPlaceholder(const std::string& id) :
LayoutPart(id == "" ? "Container Placeholder " + nextId++ : id)
{
}
void ContainerPlaceholder::CreateControl(void* /*parent*/)
{
}
void* ContainerPlaceholder::GetControl()
{
return 0;
}
void ContainerPlaceholder::Add(StackablePart::Pointer child)
{
if (child.Cast<PartPlaceholder>() == 0)
{
return;
}
realContainer->Add(child);
}
bool ContainerPlaceholder::AllowsAdd(StackablePart::Pointer /*toAdd*/)
{
return false;
}
std::list<StackablePart::Pointer> ContainerPlaceholder::GetChildren() const
{
return realContainer->GetChildren();
}
std::string ContainerPlaceholder::GetID() const
{
return LayoutPart::GetID();
}
IStackableContainer::Pointer ContainerPlaceholder::GetRealContainer()
{
return realContainer;
}
void ContainerPlaceholder::Remove(StackablePart::Pointer child)
{
if (child.Cast<PartPlaceholder> () == 0)
{
return;
}
realContainer->Remove(child);
}
void ContainerPlaceholder::Replace(StackablePart::Pointer oldChild,
StackablePart::Pointer newChild)
{
if (oldChild.Cast<PartPlaceholder>() == 0 && newChild.Cast<PartPlaceholder>()
== 0)
{
return;
}
realContainer->Replace(oldChild, newChild);
}
void ContainerPlaceholder::SetRealContainer(
IStackableContainer::Pointer container)
{
if (container == 0)
{
// set the parent container of the children back to the real container
if (realContainer != 0)
{
std::list<StackablePart::Pointer> children = realContainer->GetChildren();
for (std::list<StackablePart::Pointer>::iterator iter = children.begin(); iter
!= children.end(); ++iter)
{
(*iter)->SetContainer(realContainer);
}
}
}
else
{
// replace the real container with this place holder
std::list<StackablePart::Pointer> children = container->GetChildren();
for (std::list<StackablePart::Pointer>::iterator iter = children.begin(); iter
!= children.end(); ++iter)
{
(*iter)->SetContainer(IStackableContainer::Pointer(this));
}
}
this->realContainer = container;
}
void ContainerPlaceholder::FindSashes(PartPane::Sashes& sashes)
{
ILayoutContainer::Pointer container = this->GetContainer();
if (container != 0) {
container->FindSashes(LayoutPart::Pointer(this), sashes);
}
}
void ContainerPlaceholder::ResizeChild(StackablePart::Pointer /*childThatChanged*/)
{
}
bool ContainerPlaceholder::AllowsAutoFocus()
{
return false;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryContainerPlaceholder.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryContainerPlaceholder.h
index 18a1dda4ff..849a6149fd 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryContainerPlaceholder.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryContainerPlaceholder.h
@@ -1,112 +1,112 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYCONTAINERPLACEHOLDER_H_
#define BERRYCONTAINERPLACEHOLDER_H_
#include "berryIStackableContainer.h"
#include "berryLayoutPart.h"
#include <Poco/SharedPtr.h>
#include <list>
namespace berry {
/**
* \ingroup org_blueberry_ui_internal
*
*/
class ContainerPlaceholder : public LayoutPart, public IStackableContainer {
private:
static int nextId;
IStackableContainer::Pointer realContainer;
public:
berryObjectMacro(ContainerPlaceholder);
/**
* ContainerPlaceholder constructor comment.
* @param id java.lang.String
* @param label java.lang.String
*/
ContainerPlaceholder(const std::string& id);
/**
* Creates the SWT control
*/
void CreateControl(void* parent);
/**
* Get the part control. This method may return null.
*/
void* GetControl();
/**
* add method comment.
*/
void Add(StackablePart::Pointer child);
bool AllowsAdd(StackablePart::Pointer toAdd);
/**
* getChildren method comment.
*/
std::list<StackablePart::Pointer> GetChildren() const;
std::string GetID() const;
/**
* getFocus method comment.
*/
IStackableContainer::Pointer GetRealContainer();
/**
* remove method comment.
*/
void Remove(StackablePart::Pointer child);
/**
* replace method comment.
*/
void Replace(StackablePart::Pointer oldChild, StackablePart::Pointer newChild);
void SetRealContainer(IStackableContainer::Pointer container);
void FindSashes(PartPane::Sashes& sashes);
void ResizeChild(StackablePart::Pointer childThatChanged);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.ILayoutContainer#allowsAutoFocus()
*/
bool AllowsAutoFocus();
/* (non-Javadoc)
* @see org.blueberry.ui.internal.ILayoutContainer#isZoomed(org.blueberry.ui.internal.LayoutPart)
*/
// bool childIsZoomed(LayoutPart toTest) {
// return false;
// }
};
}
#endif /*BERRYCONTAINERPLACEHOLDER_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryDefaultSaveable.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryDefaultSaveable.cpp
index 5e5db3fd07..2a83d73ea0 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryDefaultSaveable.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryDefaultSaveable.cpp
@@ -1,116 +1,116 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryDefaultSaveable.h"
#include "berryIWorkbenchPart.h"
#include "berryIWorkbenchPage.h"
#include "berryUIException.h"
#include "berryImageDescriptor.h"
namespace berry
{
DefaultSaveable::DefaultSaveable(IWorkbenchPart::Pointer _part) :
part(_part)
{
}
void DefaultSaveable::DoSave(/*IProgressMonitor monitor*/)
{
IWorkbenchPart::Pointer _part(part);
if (_part.Cast<ISaveablePart> () != 0)
{
_part.Cast<ISaveablePart> ()->DoSave(/*monitor*/);
}
}
std::string DefaultSaveable::GetName() const
{
return part.Lock()->GetPartName();
}
ImageDescriptor::Pointer DefaultSaveable::GetImageDescriptor() const
{
//TODO DefaultSaveable GetImageDescriptor
// Image image = part.getTitleImage();
// if (image == null)
// {
// return null;
// }
// return ImageDescriptor.createFromImage(image);
return ImageDescriptor::Pointer(0);
}
std::string DefaultSaveable::GetToolTipText() const
{
return part.Lock()->GetTitleToolTip();
}
bool DefaultSaveable::IsDirty() const
{
IWorkbenchPart::Pointer _part(part);
if (_part.Cast<ISaveablePart> () != 0)
{
return _part.Cast<ISaveablePart> ()->IsDirty();
}
return false;
}
bool DefaultSaveable::operator<(const Saveable* obj) const
{
if (this == obj)
return false;
if (obj == 0)
return true;
const DefaultSaveable* other = dynamic_cast<const DefaultSaveable*> (obj);
if (part.Expired())
{
return !other->part.Expired();
}
else
return part < other->part;
}
bool DefaultSaveable::Show(IWorkbenchPage::Pointer page)
{
IWorkbenchPart::Pointer _part(part);
IWorkbenchPartReference::Pointer reference = page->GetReference(_part);
if (reference != 0)
{
page->Activate(_part);
return true;
}
if (_part.Cast<IViewPart> () != 0)
{
IViewPart::Pointer viewPart = _part.Cast<IViewPart> ();
try
{
page->ShowView(viewPart->GetViewSite()->GetId(),
viewPart ->GetViewSite()->GetSecondaryId(),
IWorkbenchPage::VIEW_ACTIVATE);
} catch (PartInitException& /*e*/)
{
return false;
}
return true;
}
return false;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryDefaultSaveable.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryDefaultSaveable.h
index b94965c60a..be2f7f9bb0 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryDefaultSaveable.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryDefaultSaveable.h
@@ -1,97 +1,97 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYDEFAULTSAVEABLE_H_
#define BERRYDEFAULTSAVEABLE_H_
#include "berrySaveable.h"
namespace berry {
/**
* A default {@link Saveable} implementation that wrappers a regular
* workbench part (one that does not itself adapt to Saveable).
*
* @since 3.2
*/
class DefaultSaveable : public Saveable {
private:
WeakPointer<IWorkbenchPart> part;
public:
/**
* Creates a new DefaultSaveable.
*
* @param part
* the part represented by this model
*/
DefaultSaveable(SmartPointer<IWorkbenchPart> part);
/*
* (non-Javadoc)
*
* @see org.blueberry.ui.Saveable#doSave(org.blueberry.core.runtime.IProgressMonitor)
*/
void DoSave(/*IProgressMonitor monitor*/);
/*
* (non-Javadoc)
*
* @see org.blueberry.ui.Saveable#getName()
*/
std::string GetName() const;
/*
* (non-Javadoc)
*
* @see org.blueberry.ui.Saveable#getImageDescriptor()
*/
SmartPointer<ImageDescriptor> GetImageDescriptor() const;
/*
* (non-Javadoc)
*
* @see org.blueberry.ui.Saveable#getToolTipText()
*/
std::string GetToolTipText() const;
/*
* (non-Javadoc)
*
* @see org.blueberry.ui.Saveable#isDirty()
*/
bool IsDirty() const;
/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
bool operator<(const Saveable* obj) const;
/* (non-Javadoc)
* @see org.blueberry.ui.Saveable#show(org.blueberry.ui.IWorkbenchPage)
*/
bool Show(SmartPointer<IWorkbenchPage> page);
};
}
#endif /* BERRYDEFAULTSAVEABLE_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryDefaultStackPresentationSite.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryDefaultStackPresentationSite.cpp
index 9ab6479df2..41675215d8 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryDefaultStackPresentationSite.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryDefaultStackPresentationSite.cpp
@@ -1,113 +1,113 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryDefaultStackPresentationSite.h"
namespace berry {
DefaultStackPresentationSite::DefaultStackPresentationSite()
: state(IStackPresentationSite::STATE_RESTORED),
activeState(StackPresentation::AS_INACTIVE)
{}
void DefaultStackPresentationSite::SetPresentation(StackPresentation::Pointer newPresentation) {
presentation = newPresentation;
if (presentation != 0) {
presentation->SetState(state);
presentation->SetActive(activeState);
}
}
StackPresentation::Pointer DefaultStackPresentationSite::GetPresentation() {
return presentation;
}
int DefaultStackPresentationSite::GetState() {
return state;
}
void DefaultStackPresentationSite::SetActive(int activeState) {
if (activeState != this->activeState) {
this->activeState = activeState;
if (presentation != 0) {
presentation->SetActive(activeState);
}
}
}
int DefaultStackPresentationSite::GetActive() {
return activeState;
}
/* (non-Javadoc)
* @see org.blueberry.ui.internal.skins.IStackPresentationSite#selectPart(org.blueberry.ui.internal.skins.IPresentablePart)
*/
void DefaultStackPresentationSite::SelectPart(IPresentablePart::Pointer toSelect) {
if (presentation != 0) {
presentation->SelectPart(toSelect);
}
}
/* (non-Javadoc)
* @see org.blueberry.ui.internal.skins.IPresentationSite#setState(int)
*/
void DefaultStackPresentationSite::SetState(int newState) {
this->SetPresentationState(newState);
}
void DefaultStackPresentationSite::SetPresentationState(int newState) {
state = newState;
if (presentation != 0) {
presentation->SetState(newState);
}
}
/* (non-Javadoc)
* @see org.blueberry.ui.internal.skins.IPresentablePart#isClosable()
*/
bool DefaultStackPresentationSite::IsCloseable(IPresentablePart::Pointer part) {
return part->IsCloseable();
}
/* (non-Javadoc)
* @see org.blueberry.ui.internal.skins.IPresentationSite#dragStart(org.blueberry.ui.internal.skins.IPresentablePart, boolean)
*/
void DefaultStackPresentationSite::DragStart(IPresentablePart::Pointer /*beingDragged*/, Point& /*initialPosition*/,
bool /*keyboard*/) {
}
/* (non-Javadoc)
* @see org.blueberry.ui.internal.skins.IPresentationSite#close(org.blueberry.ui.internal.skins.IPresentablePart)
*/
void DefaultStackPresentationSite::Close(IPresentablePart::Pointer /*toClose*/) {
}
/* (non-Javadoc)
* @see org.blueberry.ui.internal.skins.IPresentationSite#dragStart(boolean)
*/
void DefaultStackPresentationSite::DragStart(Point& /*initialPosition*/, bool /*keyboard*/) {
}
/* (non-Javadoc)
* @see org.blueberry.ui.presentations.IStackPresentationSite#supportsState(int)
*/
bool DefaultStackPresentationSite::SupportsState(int /*state*/) {
return true;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryDefaultStackPresentationSite.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryDefaultStackPresentationSite.h
index 3fbfa4d588..19ae691774 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryDefaultStackPresentationSite.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryDefaultStackPresentationSite.h
@@ -1,99 +1,99 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYDEFAULTSTACKPRESENTATIONSITE_H_
#define BERRYDEFAULTSTACKPRESENTATIONSITE_H_
#include "presentations/berryIStackPresentationSite.h"
#include "presentations/berryStackPresentation.h"
namespace berry
{
class DefaultStackPresentationSite: public IStackPresentationSite
{
private:
StackPresentation::Pointer presentation;
int state;
int activeState;
public:
berryObjectMacro(DefaultStackPresentationSite);
DefaultStackPresentationSite();
void SetPresentation(StackPresentation::Pointer newPresentation);
StackPresentation::Pointer GetPresentation();
int GetState();
void SetActive(int activeState);
int GetActive();
/* (non-Javadoc)
* @see org.blueberry.ui.internal.skins.IStackPresentationSite#selectPart(org.blueberry.ui.internal.skins.IPresentablePart)
*/
void SelectPart(IPresentablePart::Pointer toSelect);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.skins.IPresentationSite#setState(int)
*/
void SetState(int newState);
void SetPresentationState(int newState);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.skins.IPresentablePart#isClosable()
*/
bool IsCloseable(IPresentablePart::Pointer part);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.skins.IPresentationSite#dragStart(org.blueberry.ui.internal.skins.IPresentablePart, boolean)
*/
void DragStart(IPresentablePart::Pointer beingDragged,
Point& initialPosition, bool keyboard);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.skins.IPresentationSite#close(org.blueberry.ui.internal.skins.IPresentablePart)
*/
void Close(IPresentablePart::Pointer toClose);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.skins.IPresentationSite#dragStart(boolean)
*/
void DragStart(Point& initialPosition, bool keyboard);
/* (non-Javadoc)
* @see org.blueberry.ui.presentations.IStackPresentationSite#supportsState(int)
*/
bool SupportsState(int state);
// void AddSystemActions(IMenuManager menuManager) {
//
// }
};
}
#endif /* BERRYDEFAULTSTACKPRESENTATIONSITE_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryDetachedPlaceHolder.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryDetachedPlaceHolder.cpp
index 97b1c94fc4..82cc1a3e7c 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryDetachedPlaceHolder.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryDetachedPlaceHolder.cpp
@@ -1,124 +1,124 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryDetachedPlaceHolder.h"
#include "berryILayoutContainer.h"
#include "berryPartPlaceholder.h"
#include "berryWorkbenchConstants.h"
namespace berry
{
DetachedPlaceHolder::DetachedPlaceHolder(const std::string& id,
const Rectangle& b) :
ContainerPlaceholder(id), bounds(b)
{
}
void DetachedPlaceHolder::Add(StackablePart::Pointer newPart)
{
if (newPart.Cast<PartPlaceholder> () == 0)
{
return;
}
children.push_back(newPart);
}
bool DetachedPlaceHolder::AllowsBorder()
{
return false;
}
Rectangle DetachedPlaceHolder::GetBounds()
{
return bounds;
}
std::list<StackablePart::Pointer> DetachedPlaceHolder::GetChildren()
{
return children;
}
void DetachedPlaceHolder::Remove(StackablePart::Pointer part)
{
children.remove(part);
}
void DetachedPlaceHolder::Replace(StackablePart::Pointer oldPart,
StackablePart::Pointer newPart)
{
this->Remove(oldPart);
this->Add(newPart);
}
void DetachedPlaceHolder::RestoreState(IMemento::Pointer memento)
{
// Read the bounds.
int x = 0;
memento->GetInteger(WorkbenchConstants::TAG_X, x);
int y = 0;
memento->GetInteger(WorkbenchConstants::TAG_Y, y);
int width = 0;
memento->GetInteger(WorkbenchConstants::TAG_WIDTH, width);
int height = 0;
memento->GetInteger(WorkbenchConstants::TAG_HEIGHT, height);
bounds = Rectangle(x, y, width, height);
// Restore the placeholders.
std::vector<IMemento::Pointer> childrenMem(memento
->GetChildren(WorkbenchConstants::TAG_VIEW));
for (std::size_t i = 0; i < childrenMem.size(); i++) {
std::string id;
childrenMem[i]->GetString(WorkbenchConstants::TAG_ID, id);
PartPlaceholder::Pointer holder(new PartPlaceholder(id));
holder->SetContainer(IStackableContainer::Pointer(this));
children.push_back(holder);
}
}
void DetachedPlaceHolder::SaveState(IMemento::Pointer memento)
{
// Save the bounds.
memento->PutInteger(WorkbenchConstants::TAG_X, bounds.x);
memento->PutInteger(WorkbenchConstants::TAG_Y, bounds.y);
memento->PutInteger(WorkbenchConstants::TAG_WIDTH, bounds.width);
memento->PutInteger(WorkbenchConstants::TAG_HEIGHT, bounds.height);
// Save the views.
for (std::list<StackablePart::Pointer>::iterator i = children.begin();
i != children.end(); ++i) {
IMemento::Pointer childMem = memento
->CreateChild(WorkbenchConstants::TAG_VIEW);
childMem->PutString(WorkbenchConstants::TAG_ID, (*i)->GetId());
}
}
void DetachedPlaceHolder::FindSashes(LayoutPart::Pointer /*part*/,
PartPane::Sashes& sashes)
{
ILayoutContainer::Pointer container = this->GetContainer();
if (container != 0)
{
container->FindSashes(LayoutPart::Pointer(this), sashes);
}
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryDetachedPlaceHolder.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryDetachedPlaceHolder.h
index 70b7720937..ce3672ce89 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryDetachedPlaceHolder.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryDetachedPlaceHolder.h
@@ -1,103 +1,103 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYDETACHEDPLACEHOLDER_H_
#define BERRYDETACHEDPLACEHOLDER_H_
#include "berryContainerPlaceholder.h"
#include "berryIMemento.h"
#include "berryRectangle.h"
#include <list>
namespace berry {
/**
* DetachedPlaceHolder is the placeholder for detached views.
*
*/
class DetachedPlaceHolder : public ContainerPlaceholder
{
private:
std::list<StackablePart::Pointer> children;
Rectangle bounds;
public:
berryObjectMacro(DetachedPlaceHolder);
/**
* DetachedPlaceHolder constructor comment.
* @param id java.lang.String
* @param bounds the size of the placeholder
*/
DetachedPlaceHolder(const std::string& id, const Rectangle& b);
/**
* Add a child to the container.
*/
void Add(StackablePart::Pointer newPart);
/**
* Return true if the container allows its
* parts to show a border if they choose to,
* else false if the container does not want
* its parts to show a border.
* @return boolean
*/
bool AllowsBorder();
Rectangle GetBounds();
/**
* Returns a list of layout children.
*/
std::list<StackablePart::Pointer> GetChildren();
/**
* Remove a child from the container.
*/
void Remove(StackablePart::Pointer part);
/**
* Replace one child with another
*/
void Replace(StackablePart::Pointer oldPart, StackablePart::Pointer newPart);
/**
* Restore the state from the memento.
* @param memento
*/
void RestoreState(IMemento::Pointer memento);
/**
* Save state to the memento.
* @param memento
*/
void SaveState(IMemento::Pointer memento);
void FindSashes(LayoutPart::Pointer part, PartPane::Sashes& sashes);
};
}
#endif /* BERRYDETACHEDPLACEHOLDER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryDetachedWindow.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryDetachedWindow.cpp
index 7ea7a30262..f55c3c36c1 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryDetachedWindow.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryDetachedWindow.cpp
@@ -1,544 +1,544 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryDetachedWindow.h"
#include "berryIWorkbenchPartConstants.h"
#include "berryISaveablePart.h"
#include "berryWorkbenchWindow.h"
#include "tweaklets/berryGuiWidgetsTweaklet.h"
#include "berryWorkbenchConstants.h"
#include "berryEditorManager.h"
#include "berryDragUtil.h"
namespace berry
{
DetachedWindow::ShellListener::ShellListener(DetachedWindow* wnd) :
window(wnd)
{
}
void DetachedWindow::ShellListener::ShellClosed(ShellEvent::Pointer e)
{
// hold on to a reference of the DetachedWindow instance
// (otherwise, wnd->HandleClose() woulde delete the DetachedWindow
// instance too early, trying to write to members afterwards)
DetachedWindow::Pointer wnd(window);
// only continue to close if the handleClose
// wasn't canceled
e->doit = wnd->HandleClose();
}
DetachedWindow::ShellControlListener::ShellControlListener(DetachedWindow* wnd) :
window(wnd)
{
}
GuiTk::IControlListener::Events::Types DetachedWindow::ShellControlListener::GetEventTypes() const
{
return Events::RESIZED;
}
void DetachedWindow::ShellControlListener::ControlResized(
GuiTk::ControlEvent::Pointer e)
{
window->folder->SetBounds(
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetClientArea(e->item));
}
DetachedWindow::DetachedWindow(WorkbenchPage* workbenchPage)
{
shellListener = new ShellListener(this);
resizeListener = new ShellControlListener(this);
this->page = workbenchPage;
hideViewsOnClose = true;
folder = new PartStack(page, false);
}
void DetachedWindow::PropertyChange(Object::Pointer /*source*/, int propId)
{
if (propId == IWorkbenchPartConstants::PROP_TITLE)
{
this->UpdateTitle();
}
else if (propId == PartStack::PROP_SELECTION)
{
this->ActivePartChanged(this->GetPartReference(folder->GetSelection()));
}
}
Shell::Pointer DetachedWindow::GetShell()
{
return windowShell;
}
void DetachedWindow::Create()
{
folder->AddListener(IPropertyChangeListener::Pointer(this));
windowShell
= page->GetWorkbenchWindow().Cast<WorkbenchWindow> () ->GetDetachedWindowPool()->AllocateShell(
shellListener);
windowShell->SetData(Object::Pointer(this));
windowShell->SetText(""); //$NON-NLS-1$
DragUtil::AddDragTarget(windowShell->GetControl(),
IDragOverListener::Pointer(this));
hideViewsOnClose = true;
if (bounds.IsEmpty())
{
Rectangle windowRect = page->GetWorkbenchWindow()->GetShell()->GetBounds();
Point center(windowRect.x + windowRect.width / 2, windowRect.y
- windowRect.height / 2);
bounds = Rectangle(center.x - 150, center.y + 100, 300, 200);
}
// Force the rect into the current display
Rectangle dispBounds =
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetAvailableScreenSize();
if (bounds.width > dispBounds.width)
bounds.width = dispBounds.width;
if (bounds.height > dispBounds.height)
bounds.height = dispBounds.height;
if (bounds.x + bounds.width > dispBounds.width)
bounds.x = dispBounds.width - bounds.width;
if (bounds.y + bounds.height > dispBounds.height)
bounds.y = dispBounds.height - bounds.height;
this->GetShell()->SetBounds(bounds);
this->ConfigureShell(windowShell);
this->CreateContents(windowShell->GetControl());
//windowShell->Layout(true);
//folder->SetBounds(Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetClientArea(windowShell->GetControl()));
}
void DetachedWindow::Add(StackablePart::Pointer part)
{
Shell::Pointer shell = this->GetShell();
if (shell != 0)
{
part->Reparent(shell->GetControl());
}
folder->Add(part);
this->UpdateMinimumSize();
}
bool DetachedWindow::BelongsToWorkbenchPage(
IWorkbenchPage::Pointer workbenchPage)
{
return (workbenchPage == this->page);
}
bool DetachedWindow::Close()
{
hideViewsOnClose = false;
Shell::Pointer shell = this->GetShell();
if (shell != 0)
{
shell->Close();
}
return true;
}
IDropTarget::Pointer DetachedWindow::Drag(void* /*currentControl*/,
Object::Pointer draggedObject, const Point& position, const Rectangle& /*dragRectangle*/)
{
if (draggedObject.Cast<PartPane> () == 0)
{
return IDropTarget::Pointer(0);
}
PartPane::Pointer sourcePart = draggedObject.Cast<PartPane> ();
if (sourcePart->GetWorkbenchWindow() != page->GetWorkbenchWindow())
{
return IDropTarget::Pointer(0);
}
// Only handle the event if the source part is acceptable to the particular PartStack
IDropTarget::Pointer target;
if (folder->AllowsDrop(sourcePart))
{
target = folder->GetDropTarget(draggedObject, position);
if (target == 0)
{
Rectangle displayBounds =
DragUtil::GetDisplayBounds(folder->GetControl());
if (displayBounds.Contains(position))
{
StackDropResult::Pointer stackDropResult(new StackDropResult(
displayBounds, Object::Pointer(0)));
target = folder->CreateDropTarget(sourcePart, stackDropResult);
}
else
{
return IDropTarget::Pointer(0);
}
}
}
return target;
}
IStackableContainer::ChildrenType DetachedWindow::GetChildren() const
{
return folder->GetChildren();
}
WorkbenchPage::Pointer DetachedWindow::GetWorkbenchPage()
{
return WorkbenchPage::Pointer(this->page);
}
void DetachedWindow::RestoreState(IMemento::Pointer memento)
{
// Read the bounds.
int x = 0;
memento->GetInteger(WorkbenchConstants::TAG_X, x);
int y = 0;
memento->GetInteger(WorkbenchConstants::TAG_Y, y);
int width = 0;
memento->GetInteger(WorkbenchConstants::TAG_WIDTH, width);
int height = 0;
memento->GetInteger(WorkbenchConstants::TAG_HEIGHT, height);
// memento->GetInteger(WorkbenchConstants::TAG_FLOAT);
// Set the bounds.
bounds = Rectangle(x, y, width, height);
if (GetShell())
{
GetShell()->SetBounds(bounds);
}
// Create the folder.
IMemento::Pointer childMem =
memento->GetChild(WorkbenchConstants::TAG_FOLDER);
if (childMem)
{
folder->RestoreState(childMem);
}
}
void DetachedWindow::SaveState(IMemento::Pointer memento)
{
if (GetShell())
{
bounds = GetShell()->GetBounds();
}
// Save the bounds.
memento->PutInteger(WorkbenchConstants::TAG_X, bounds.x);
memento->PutInteger(WorkbenchConstants::TAG_Y, bounds.y);
memento->PutInteger(WorkbenchConstants::TAG_WIDTH, bounds.width);
memento->PutInteger(WorkbenchConstants::TAG_HEIGHT, bounds.height);
// Save the views.
IMemento::Pointer childMem = memento->CreateChild(
WorkbenchConstants::TAG_FOLDER);
folder->SaveState(childMem);
}
void* DetachedWindow::GetControl()
{
return folder->GetControl();
}
int DetachedWindow::Open()
{
if (this->GetShell() == 0)
{
this->Create();
}
Rectangle bounds = this->GetShell()->GetBounds();
if (!(bounds == this->GetShell()->GetBounds()))
{
this->GetShell()->SetBounds(bounds);
}
this->GetShell()->SetVisible(true);
folder->SetBounds(Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetClientArea(this->GetShell()->GetControl()));
return 0;
}
void DetachedWindow::ActivePartChanged(
IWorkbenchPartReference::Pointer partReference)
{
if (activePart == partReference)
{
return;
}
if (activePart != 0)
{
activePart->RemovePropertyListener(IPropertyChangeListener::Pointer(this));
}
activePart = partReference;
if (partReference != 0)
{
partReference->AddPropertyListener(IPropertyChangeListener::Pointer(this));
}
this->UpdateTitle();
}
void DetachedWindow::ConfigureShell(Shell::Pointer shell)
{
this->UpdateTitle();
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->AddControlListener(
shell->GetControl(), resizeListener);
//shell.addListener(SWT.Activate, activationListener);
//shell.addListener(SWT.Deactivate, activationListener);
//TODO DetachedWindow key bindings
// // Register this detached view as a window (for key bindings).
// IContextService contextService = (IContextService) getWorkbenchPage()
// .getWorkbenchWindow().getWorkbench().getService(IContextService.class);
// contextService.registerShell(shell, IContextService.TYPE_WINDOW);
//
// page.getWorkbenchWindow().getWorkbench().getHelpSystem().setHelp(shell,
// IWorkbenchHelpContextIds.DETACHED_WINDOW);
}
void* DetachedWindow::CreateContents(void* parent)
{
// Create the tab folder.
folder->CreateControl(parent);
// Reparent each view in the tab folder.
std::list<PartPane::Pointer> detachedChildren;
this->CollectViewPanes(detachedChildren, this->GetChildren());
for (std::list<PartPane::Pointer>::iterator itr = detachedChildren.begin(); itr
!= detachedChildren.end(); ++itr)
{
PartPane::Pointer part = *itr;
part->Reparent(parent);
}
//TODO DetachedWindow listen to folder events (update size?)
// if (folder->GetPresentation()
// instanceof TabbedStackPresentation)
// {
// TabbedStackPresentation stack = (TabbedStackPresentation) folder.getPresentation();
// AbstractTabFolder tabFolder = stack.getTabFolder();
// tabFolder.addListener(new TabFolderListener()
// {
// public void handleEvent(TabFolderEvent e)
// {
// switch (e.type)
// {
// case TabFolderEvent.EVENT_CLOSE:
// {
// updateMinimumSize();
// break;
// }
// case TabFolderEvent.EVENT_PREFERRED_SIZE:
// {
// updateMinimumSize();
// break;
// }
// }
// }
// });
// }
// Return tab folder control.
return folder->GetControl();
}
void DetachedWindow::UpdateTitle()
{
if (activePart != 0)
{
// Uncomment to set the shell title to match the title of the active part
// String text = activePart.getTitle();
//
// if (!text.equals(s.getText())) {
// s.setText(text);
// }
}
}
void DetachedWindow::UpdateMinimumSize()
{
// // We can only do this for 'Tabbed' stacked presentations.
// if (folder.getPresentation().Cast<TabbedStackPresentation>() != 0)
// {
// TabbedStackPresentation stack = (TabbedStackPresentation) folder.getPresentation();
//
// if (stack->GetPartList().size() == 1)
// {
// // Get the minimum space required for the part
// int width = stack->ComputePreferredSize(true, Constants::INF, Constants::INF, 0);
// int height = stack->ComputePreferredSize(false, Constants::INF, Constants::INF, 0);
//
// // Take the current shell 'trim' into account
// int shellHeight = windowShell->GetBounds().height - windowShell->GetClientArea().height;
// int shellWidth = windowShell->GetBounds().width - windowShell->GetClientArea().width;
//
// windowShell->SetMinimumSize(width + shellWidth, height + shellHeight);
// }
// }
}
IWorkbenchPartReference::Pointer DetachedWindow::GetPartReference(
StackablePart::Pointer pane)
{
if (pane == 0 || pane.Cast<PartPane> () == 0)
{
return IWorkbenchPartReference::Pointer(0);
}
return pane.Cast<PartPane> ()->GetPartReference();
}
bool DetachedWindow::HandleClose()
{
if (hideViewsOnClose)
{
std::list<PartPane::Pointer> views;
this->CollectViewPanes(views, this->GetChildren());
// Save any dirty views
if (!this->HandleSaves(views))
{
return false; // User canceled the save
}
// OK, go on with the closing
for (std::list<PartPane::Pointer>::iterator itr = views.begin(); itr
!= views.end(); ++itr)
{
PartPane::Pointer child = *itr;
// Only close if closable...
if (child->IsCloseable())
{
page->HideView(child->GetPartReference().Cast<IViewReference> ());
// Was the close cancelled?
if (child->GetContainer() != 0)
return false;
}
else
{
page->AttachView(child->GetPartReference().Cast<IViewReference> ());
}
}
}
if (folder != 0)
{
folder->Dispose();
}
if (windowShell != 0)
{
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->RemoveControlListener(
windowShell->GetControl(), resizeListener);
// windowShell.removeListener(SWT.Activate, activationListener);
// windowShell.removeListener(SWT.Deactivate, activationListener);
DragUtil::RemoveDragTarget(windowShell->GetControl(),
IDragOverListener::Pointer(this));
bounds = windowShell->GetBounds();
//TODO DetachedWindow unregister key bindings
// // Unregister this detached view as a window (for key bindings).
// final IContextService contextService = (IContextService) getWorkbenchPage().getWorkbenchWindow().getWorkbench().getService(IContextService.class);
// contextService.unregisterShell(windowShell);
windowShell->SetData(Object::Pointer(0));
windowShell = 0;
}
return true;
}
bool DetachedWindow::HandleSaves(std::list<PartPane::Pointer> views)
{
std::vector<IWorkbenchPart::Pointer> dirtyViews;
for (std::list<PartPane::Pointer>::iterator iterator = views.begin(); iterator
!= views.end(); ++iterator)
{
PartPane::Pointer pane = *iterator;
IViewReference::Pointer ref =
pane->GetPartReference().Cast<IViewReference> ();
IViewPart::Pointer part = ref->GetView(false);
if (part.Cast<ISaveablePart> () != 0)
{
ISaveablePart::Pointer saveable = part.Cast<ISaveablePart> ();
if (saveable->IsDirty() && saveable->IsSaveOnCloseNeeded())
{
dirtyViews.push_back(part);
}
}
}
// If there are any prompt to save -before- any closing happens
// FIXME: This code will result in a double prompt if the user
// decides not to save a particular view at this stage they'll
// get a second one from the 'hideView' call...
if (dirtyViews.size() > 0)
{
IWorkbenchWindow::Pointer window = page->GetWorkbenchWindow();
bool success =
EditorManager::SaveAll(dirtyViews, true, true, false, window);
if (!success)
{
return false; // the user canceled.
}
}
return true;
}
void DetachedWindow::CollectViewPanes(std::list<PartPane::Pointer>& result,
const std::list<StackablePart::Pointer>& parts)
{
for (std::list<StackablePart::Pointer>::const_iterator iter = parts.begin(); iter
!= parts.end(); ++iter)
{
StackablePart::Pointer part = *iter;
if (part.Cast<PartPane> () != 0)
{
result.push_back(part.Cast<PartPane> ());
}
}
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryDetachedWindow.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryDetachedWindow.h
index def87c58c4..99000dd580 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryDetachedWindow.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryDetachedWindow.h
@@ -1,198 +1,198 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYDETACHEDWINDOW_H_
#define BERRYDETACHEDWINDOW_H_
#include "berryPartStack.h"
#include "berryWorkbenchPage.h"
#include "berryLayoutPart.h"
#include "berryIDragOverListener.h"
#include "berryIShellListener.h"
#include "guitk/berryGuiTkIControlListener.h"
#include "berryRectangle.h"
#include "berryShell.h"
namespace berry
{
/**
* TODO: Drag from detached to fast view bar back to detached causes NPE
*
* @since 3.1
*/
class DetachedWindow: public IPropertyChangeListener,
public IDragOverListener
{
public:
berryObjectMacro(DetachedWindow);
private:
PartStack::Pointer folder;
WorkbenchPage* page;
Rectangle bounds;
Shell::Pointer windowShell;
bool hideViewsOnClose;
struct ShellListener: public IShellListener
{
ShellListener(DetachedWindow* wnd);
void ShellClosed(ShellEvent::Pointer e);
private:
DetachedWindow* window;
};
IShellListener::Pointer shellListener;
struct ShellControlListener: public GuiTk::IControlListener
{
ShellControlListener(DetachedWindow* wnd);
Events::Types GetEventTypes() const;
void ControlResized(GuiTk::ControlEvent::Pointer e);
private:
DetachedWindow* window;
};
GuiTk::IControlListener::Pointer resizeListener;
// Listener activationListener = new Listener() {
// public void handleEvent(Event event) {
// switch (event.type) {
// case SWT.Activate:
// page.window.liftRestrictions();
// break;
// case SWT.Deactivate:
// page.window.imposeRestrictions();
// break;
// }
// }
// };
IWorkbenchPartReference::Pointer activePart;
public:
/**
* Create a new FloatingWindow.
*/
DetachedWindow(WorkbenchPage* workbenchPage);
void PropertyChange(Object::Pointer source, int propId);
Shell::Pointer GetShell();
void Create();
/**
* Adds a visual part to this window.
* Supports reparenting.
*/
void Add(StackablePart::Pointer part);
bool BelongsToWorkbenchPage(IWorkbenchPage::Pointer workbenchPage);
bool Close();
/*
* @see org.blueberry.ui.internal.IDragOverListener#Drag(void*, Object::Pointer, const Point&, const Rectangle& )
*/
IDropTarget::Pointer Drag(void* currentControl,
Object::Pointer draggedObject, const Point& position,
const Rectangle& dragRectangle);
IStackableContainer::ChildrenType GetChildren() const;
WorkbenchPage::Pointer GetWorkbenchPage();
/**
* @see IPersistablePart
*/
void RestoreState(IMemento::Pointer memento);
/**
* @see IPersistablePart
*/
void SaveState(IMemento::Pointer memento);
void* GetControl();
/**
* Opens the detached window.
*/
int Open();
protected:
void ActivePartChanged(IWorkbenchPartReference::Pointer partReference);
/**
* This method will be called to initialize the given Shell's layout
*/
void ConfigureShell(Shell::Pointer shell);
/**
* Override this method to create the widget tree that is used as the window's contents.
*/
void* CreateContents(void* parent);
private:
void UpdateTitle();
/**
* Ensure that the shell's minimum size is equal to the minimum size
* of the first part added to the shell.
*/
void UpdateMinimumSize();
static IWorkbenchPartReference::Pointer GetPartReference(
StackablePart::Pointer pane);
/**
* Closes this window and disposes its shell.
*/
bool HandleClose();
/**
* Prompts for and handles the saving of dirty, saveable views
* @param views The list of ViewPanes
* @return <code>true</code> unless the user cancels the save(s)
*/
bool HandleSaves(std::list<PartPane::Pointer> views);
/**
* Answer a list of the view panes.
*/
void CollectViewPanes(std::list<PartPane::Pointer>& result,
const std::list<StackablePart::Pointer>& parts);
};
}
#endif /* BERRYDETACHEDWINDOW_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryDragUtil.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryDragUtil.cpp
index b4a464df30..9e92dbd471 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryDragUtil.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryDragUtil.cpp
@@ -1,362 +1,362 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryDragUtil.h"
#include "berryGeometry.h"
#include "tweaklets/berryGuiWidgetsTweaklet.h"
#include "tweaklets/berryDnDTweaklet.h"
#include "tweaklets/berryITracker.h"
namespace berry
{
const std::string DragUtil::DROP_TARGET_ID =
"org.blueberry.ui.internal.dropTarget";
TestDropLocation::Pointer DragUtil::forcedDropTarget(0);
std::list<IDragOverListener::Pointer> DragUtil::defaultTargets = std::list<
IDragOverListener::Pointer>();
DragUtil::TrackerMoveListener::TrackerMoveListener(Object::Pointer draggedItem,
const Rectangle& sourceBounds, const Point& initialLocation,
bool allowSnapping) :
allowSnapping(allowSnapping), draggedItem(draggedItem), sourceBounds(
sourceBounds), initialLocation(initialLocation)
{
}
GuiTk::IControlListener::Events::Types DragUtil::TrackerMoveListener::GetEventTypes() const
{
return Events::MOVED;
}
void DragUtil::TrackerMoveListener::ControlMoved(
GuiTk::ControlEvent::Pointer event)
{
// Get the curslor location as a point
Point location(event->x, event->y);
// Select a drop target; use the global one by default
IDropTarget::Pointer target;
void* targetControl =
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetCursorControl();
// Get the ITracker which fired the event
ITracker* tracker = static_cast<ITracker*> (event->item);
// Get the drop target for this location
target = DragUtil::GetDropTarget(targetControl, draggedItem, location,
tracker->GetRectangle());
// Set up the tracker feedback based on the target
Rectangle snapTarget;
if (target != 0)
{
snapTarget = target->GetSnapRectangle();
tracker->SetCursor(target->GetCursor());
}
else
{
tracker->SetCursor(DnDTweaklet::CURSOR_INVALID);
}
// If snapping then reset the tracker's rectangle based on the current drop target
if (allowSnapping)
{
if (snapTarget.width == 0 || snapTarget.height == 0)
{
snapTarget = Rectangle(sourceBounds.x + location.x - initialLocation.x,
sourceBounds.y + location.y - initialLocation.y, sourceBounds.width,
sourceBounds.height);
}
// Try to prevent flicker: don't change the rectangles if they're already in
// the right location
Rectangle currentRectangle = tracker->GetRectangle();
if (!(currentRectangle == snapTarget))
{
tracker->SetRectangle(snapTarget);
}
}
}
DragUtil::TargetListType::Pointer DragUtil::GetTargetList(void* control)
{
Object::Pointer data = Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetData(
control, DROP_TARGET_ID);
TargetListType::Pointer list = data.Cast<TargetListType> ();
return list;
}
IDropTarget::Pointer DragUtil::GetDropTarget(const std::list<
IDragOverListener::Pointer>& toSearch, void* mostSpecificControl,
Object::Pointer draggedObject, const Point& position,
const Rectangle& dragRectangle)
{
for (std::list<IDragOverListener::Pointer>::const_iterator iter =
toSearch.begin(); iter != toSearch.end(); ++iter)
{
IDragOverListener::Pointer next = *iter;
IDropTarget::Pointer dropTarget = next->Drag(mostSpecificControl,
draggedObject, position, dragRectangle);
if (dropTarget != 0)
{
return dropTarget;
}
}
return IDropTarget::Pointer(0);
}
void DragUtil::AddDragTarget(void* control, IDragOverListener::Pointer target)
{
if (control == 0)
{
defaultTargets.push_back(target);
}
else
{
TargetListType::Pointer targetList = GetTargetList(control);
if (targetList == 0)
{
targetList = new TargetListType();
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->SetData(control, DROP_TARGET_ID,
targetList);
}
targetList->push_back(target);
}
}
void DragUtil::RemoveDragTarget(void* control,
IDragOverListener::Pointer target)
{
if (control == 0)
{
defaultTargets.remove(target);
}
else
{
TargetListType::Pointer targetList = GetTargetList(control);
if (targetList != 0)
{
targetList->remove(target);
if (targetList->empty())
{
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->SetData(control,
DROP_TARGET_ID, Object::Pointer(0));
}
}
}
}
Rectangle DragUtil::GetDisplayBounds(void* boundsControl)
{
void* parent = Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetParent(
boundsControl);
if (parent == 0)
{
return Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetBounds(boundsControl);
}
Rectangle rect = Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetBounds(
boundsControl);
return Geometry::ToDisplay(parent, rect);
}
bool DragUtil::PerformDrag(Object::Pointer draggedItem,
const Rectangle& sourceBounds, const Point& initialLocation,
bool allowSnapping)
{
IDropTarget::Pointer target = DragToTarget(draggedItem, sourceBounds,
initialLocation, allowSnapping);
if (target == 0)
{
return false;
}
target->Drop();
target->DragFinished(true);
return true;
}
void DragUtil::ForceDropLocation(TestDropLocation::Pointer forcedLocation)
{
forcedDropTarget = forcedLocation;
}
IDropTarget::Pointer DragUtil::DragToTarget(Object::Pointer draggedItem,
const Rectangle& sourceBounds, const Point& initialLocation,
bool allowSnapping)
{
//final Display display = Display.getCurrent();
// Testing...immediately 'drop' onto the test target
if (forcedDropTarget != 0)
{
Point location = forcedDropTarget->GetLocation();
void* currentControl =
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->FindControl(
forcedDropTarget->GetShells(), location);
return GetDropTarget(currentControl, draggedItem, location, sourceBounds);
}
// Create a tracker. This is just an XOR rect on the screen.
// As it moves we notify the drag listeners.
ITracker* tracker = Tweaklets::Get(DnDTweaklet::KEY)->CreateTracker();
//tracker.setStippled(true);
GuiTk::IControlListener::Pointer trackerListener(new TrackerMoveListener(
draggedItem, sourceBounds, initialLocation, allowSnapping));
tracker->AddControlListener(trackerListener);
// Setup...when the drag starts we might already be over a valid target, check this...
// If there is a 'global' target then skip the check
IDropTarget::Pointer target;
void* startControl =
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetCursorControl();
if (startControl != 0 && allowSnapping)
{
target = GetDropTarget(startControl, draggedItem, initialLocation,
sourceBounds);
}
// Set up an initial tracker rectangle
Rectangle startRect = sourceBounds;
if (target != 0)
{
Rectangle rect = target->GetSnapRectangle();
if (rect.width != 0 && rect.height != 0)
{
startRect = rect;
}
tracker->SetCursor(target->GetCursor());
}
if (startRect.width != 0 && startRect.height != 0)
{
tracker->SetRectangle(startRect);
}
// Tracking Loop...tracking is preformed on the 'SWT.Move' listener registered
// against the tracker.
// // HACK:
// // Some control needs to capture the mouse during the drag or other
// // controls will interfere with the cursor
// Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
// if (shell != null)
// {
// shell.setCapture(true);
// }
// Run tracker until mouse up occurs or escape key pressed.
bool trackingOk = tracker->Open();
// // HACK:
// // Release the mouse now
// if (shell != null)
// {
// shell.setCapture(false);
// }
// Done tracking...
// Get the current drop target
IDropTarget::Pointer dropTarget;
Point finalLocation =
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetCursorLocation();
void* targetControl =
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetCursorControl();
dropTarget = GetDropTarget(targetControl, draggedItem, finalLocation,
tracker->GetRectangle());
// Cleanup...
delete tracker;
// if we're going to perform a 'drop' then delay the issuing of the 'finished'
// callback until after it's done...
if (trackingOk)
{
return dropTarget;
}
else if (dropTarget != 0)
{
// If the target can handle a 'finished' notification then send one
dropTarget->DragFinished(false);
}
return IDropTarget::Pointer(0);
}
IDropTarget::Pointer DragUtil::GetDropTarget(void* toSearch,
Object::Pointer draggedObject, const Point& position,
const Rectangle& dragRectangle)
{
// Search for a listener by walking the control's parent hierarchy
for (void* current = toSearch; current != 0; current = Tweaklets::Get(
GuiWidgetsTweaklet::KEY)->GetParent(current))
{
TargetListType::Pointer targetList = GetTargetList(current);
std::list<IDragOverListener::Pointer> targets;
if (targetList != 0)
targets.assign(targetList->begin(), targetList->end());
IDropTarget::Pointer dropTarget = GetDropTarget(targets, toSearch,
draggedObject, position, dragRectangle);
if (dropTarget != 0)
{
return dropTarget;
}
// // Don't look to parent shells for drop targets
// if (current instanceof Shell) {
// break;
// }
}
// No controls could handle this event -- check for default targets
return GetDropTarget(defaultTargets, toSearch, draggedObject, position,
dragRectangle);
}
//Point DragUtil::GetEventLoc(GuiTk::ControlEvent::Pointer event)
//{
// Control ctrl = (Control) event.widget;
// return ctrl.toDisplay(new Point(event.x, event.y));
//}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryDragUtil.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryDragUtil.h
index e972d2c803..2093fb9f5f 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryDragUtil.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryDragUtil.h
@@ -1,214 +1,214 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYDRAGUTIL_H_
#define BERRYDRAGUTIL_H_
#include <org_blueberry_ui_Export.h>
#include "berryRectangle.h"
#include "guitk/berryGuiTkIControlListener.h"
#include "berryTestDropLocation.h"
#include "berryIDragOverListener.h"
#include "berryIDropTarget.h"
#include <berryObjectList.h>
#include <list>
namespace berry {
/**
* Provides the methods for attaching drag-and-drop listeners to SWT controls.
*/
class BERRY_UI DragUtil {
public:
typedef ObjectList<IDragOverListener::Pointer> TargetListType;
private:
static const std::string DROP_TARGET_ID; //$NON-NLS-1$
/**
* The location where all drags will end. If this is non-null, then
* all user input is ignored in drag/drop. If null, we use user input
* to determine where objects should be dropped.
*/
static TestDropLocation::Pointer forcedDropTarget;
/**
* List of IDragOverListener
*/
static std::list<IDragOverListener::Pointer> defaultTargets;
/**
* Return the list of 'IDragOverListener' elements associated with
* the given control. If there's a 'global' listener then always
* return it.
*
* @param control
* @return
*/
static TargetListType::Pointer GetTargetList(void* control);
/**
* Given a list of IDragOverListeners and a description of what is being dragged, it returns
* a IDropTarget for the current drop.
*
* @param toSearch
* @param mostSpecificControl
* @param draggedObject
* @param position
* @param dragRectangle
* @return
*/
static IDropTarget::Pointer GetDropTarget(const std::list<IDragOverListener::Pointer>& toSearch,
void* mostSpecificControl, Object::Pointer draggedObject, const Point &position,
const Rectangle& dragRectangle);
struct TrackerMoveListener : public GuiTk::IControlListener {
TrackerMoveListener(Object::Pointer draggedItem, const Rectangle& sourceBounds,
const Point& initialLocation, bool allowSnapping);
Events::Types GetEventTypes() const;
void ControlMoved(GuiTk::ControlEvent::Pointer event);
private:
bool allowSnapping;
Object::Pointer draggedItem;
Rectangle sourceBounds;
Point initialLocation;
};
public:
/**
* Sets the drop target for the given control. It is possible to add one or more
* targets for a "null" control. This becomes a default target that is used if no
* other targets are found (for example, when dragging objects off the application
* window).
*
* @param control the control that should be treated as a drag target, or null
* to indicate the default target
* @param target the drag target to handle the given control
*/
static void AddDragTarget(void* control, IDragOverListener::Pointer target);
/**
* Removes a drop target from the given control.
*
* @param control
* @param target
*/
static void RemoveDragTarget(void* control,
IDragOverListener::Pointer target);
/**
* Shorthand method. Returns the bounding rectangle for the given control, in
* display coordinates.
*
* @param draggedItem
* @param boundsControl
* @return
*/
static Rectangle GetDisplayBounds(void* boundsControl);
static bool PerformDrag(Object::Pointer draggedItem,
const Rectangle& sourceBounds, const Point& initialLocation, bool allowSnapping);
// /**
// * Drags the given item to the given location (in display coordinates). This
// * method is intended for use by test suites.
// *
// * @param draggedItem object being dragged
// * @param finalLocation location being dragged to
// * @return true iff the drop was accepted
// */
// static bool DragTo(Display display, Object draggedItem,
// Point finalLocation, Rectangle dragRectangle) {
// Control currentControl = SwtUtil.findControl(display, finalLocation);
//
// IDropTarget target = getDropTarget(currentControl, draggedItem,
// finalLocation, dragRectangle);
//
// if (target == null) {
// return false;
// }
//
// target.drop();
//
// return true;
// }
/**
* Forces all drags to end at the given position (display coordinates). Intended
* for use by test suites. If this method is called, then all subsequent calls
* to performDrag will terminate immediately and behave as though the object were
* dragged to the given location. Calling this method with null cancels this
* behavior and causes performDrag to behave normally.
*
* @param forcedLocation location where objects will be dropped (or null to
* cause drag/drop to behave normally).
*/
static void ForceDropLocation(TestDropLocation::Pointer forcedLocation);
/**
* Drags the given item, given an initial bounding rectangle in display coordinates.
* Due to a quirk in the Tracker class, changing the tracking rectangle when using the
* keyboard will also cause the mouse cursor to move. Since "snapping" causes the tracking
* rectangle to change based on the position of the mouse cursor, it is impossible to do
* drag-and-drop with the keyboard when snapping is enabled.
*
* @param draggedItem object being dragged
* @param sourceBounds initial bounding rectangle for the dragged item
* @param initialLocation initial position of the mouse cursor
* @param allowSnapping true iff the rectangle should snap to the drop location. This must
* be false if the user might be doing drag-and-drop using the keyboard.
*
* @return
*/
static IDropTarget::Pointer DragToTarget(Object::Pointer draggedItem,
const Rectangle& sourceBounds, const Point& initialLocation,
bool allowSnapping);
/**
* Returns the drag target for the given control or null if none.
*
* @param toSearch
* @param e
* @return
*/
static IDropTarget::Pointer GetDropTarget(void* toSearch,
Object::Pointer draggedObject, const Point& position, const Rectangle& dragRectangle);
/**
* Returns the location of the given event, in display coordinates
* @return
*/
//static Point GetEventLoc(GuiTk::ControlEvent::Pointer event);
};
}
#endif /* BERRYDRAGUTIL_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorAreaHelper.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorAreaHelper.cpp
index caadc4c703..2ce24cbfaa 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorAreaHelper.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorAreaHelper.cpp
@@ -1,267 +1,267 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryEditorAreaHelper.h"
#include "berryEditorSashContainer.h"
#include "berryPartSite.h"
#include "berryIPageLayout.h"
#include "berryPartPane.h"
namespace berry
{
void EditorAreaHelper::CloseEditor(PartPane::Pointer pane)
{
if (pane != 0)
{
editorArea->RemoveEditor(pane);
}
}
void EditorAreaHelper::AddToLayout(PartPane::Pointer pane,
PartStack::Pointer stack)
{
//EditorStack stack = editorArea.getActiveWorkbook();
pane->SetContainer(stack);
editorArea->AddEditor(pane, stack);
}
EditorAreaHelper::EditorAreaHelper(WorkbenchPage* page)
{
this->editorArea
= new EditorSashContainer(IPageLayout::ID_EDITOR_AREA, page, page->GetClientComposite());
this->editorArea->CreateControl(page->GetClientComposite());
this->editorArea->SetActive(true);
}
void EditorAreaHelper::DisplayEditorList()
{
PartStack::Pointer activeWorkbook = editorArea->GetActiveWorkbook();
if (activeWorkbook != 0)
{
activeWorkbook->ShowPartList();
}
}
void EditorAreaHelper::CloseEditor(IEditorReference::Pointer ref)
{
PartPane::Pointer pane = ref.Cast<WorkbenchPartReference>()->GetPane();
this->CloseEditor(pane);
}
void EditorAreaHelper::CloseEditor(IEditorPart::Pointer part)
{
PartPane::Pointer pane = part->GetSite().Cast<PartSite>()->GetPane();
this->CloseEditor(pane);
}
void EditorAreaHelper::DerefPart(StackablePart::Pointer part)
{
// Get vital part stats before reparenting.
IStackableContainer::Pointer oldContainer = part->GetContainer();
// Reparent the part back to the main window
//part.reparent(editorArea.getParent());
// Update container.
if (oldContainer == 0)
{
return;
}
oldContainer->Remove(part);
std::list<StackablePart::Pointer> children = oldContainer->GetChildren();
if (children.empty())
{
// There are no more children in this container, so get rid of it
if (oldContainer.Cast<LayoutPart>())
{
LayoutPart::Pointer parent = oldContainer.Cast<LayoutPart>();
ILayoutContainer::Pointer parentContainer = parent->GetContainer();
if (parentContainer != 0)
{
parentContainer->Remove(parent);
parent->Dispose();
}
}
}
}
EditorAreaHelper::~EditorAreaHelper()
{
if (editorArea != 0)
{
editorArea->SetActive(false);
editorArea->Dispose();
}
}
std::string EditorAreaHelper::GetActiveEditorWorkbookID()
{
return editorArea->GetActiveWorkbookID();
}
PartStack::Pointer EditorAreaHelper::GetActiveWorkbook()
{
return editorArea->GetActiveWorkbook();
}
LayoutPart::Pointer EditorAreaHelper::GetLayoutPart()
{
LayoutPart::Pointer layoutPart = editorArea.Cast<LayoutPart>();
return layoutPart;
}
IEditorReference::Pointer EditorAreaHelper::GetVisibleEditor()
{
PartStack::Pointer activeWorkbook = editorArea->GetActiveWorkbook();
PartPane::Pointer pane = activeWorkbook->GetSelection().Cast<PartPane>();
if (pane != 0)
{
IEditorReference::Pointer result = pane->GetPartReference().Cast<IEditorReference>();
return result;
}
return IEditorReference::Pointer(0);
}
void EditorAreaHelper::MoveEditor(IEditorPart::Pointer /*part*/, int /*position*/)
{
///*EditorPane pane = (EditorPane)*/((EditorSite) part.getSite()).getPane();
//TODO commented this out during presentations works
//pane.getWorkbook().reorderTab(pane, position);
}
void EditorAreaHelper::AddEditor(EditorReference::Pointer ref,
const std::string& workbookId)
{
std::list<IEditorReference::Pointer> refs = editorArea->GetPage()->GetEditorReferences();
for (std::list<IEditorReference::Pointer>::iterator iter = refs.begin();
iter != refs.end(); ++iter)
{
if (ref == (*iter))
{
return;
}
}
PartStack::Pointer stack = this->GetWorkbookFromID(workbookId);
if (stack == 0)
{
stack = this->GetActiveWorkbook();
}
this->AddToLayout(ref->GetPane(), stack);
editorArea->GetPage()->PartAdded(ref);
}
bool EditorAreaHelper::RestoreState(IMemento::Pointer memento)
{
// Restore the editor area workbooks layout/relationship
return editorArea->RestoreState(memento);
}
bool EditorAreaHelper::RestorePresentationState(IMemento::Pointer areaMem)
{
return editorArea->RestorePresentationState(areaMem);
}
bool EditorAreaHelper::SaveState(IMemento::Pointer memento)
{
// Save the editor area workbooks layout/relationship
return editorArea->SaveState(memento);
}
void EditorAreaHelper::SetActiveEditorWorkbookFromID(const std::string& id)
{
editorArea->SetActiveWorkbookFromID(id);
}
void EditorAreaHelper::SetActiveWorkbook(PartStack::Pointer workbook, bool hasFocus)
{
editorArea->SetActiveWorkbook(workbook, hasFocus);
}
bool EditorAreaHelper::SetVisibleEditor(IEditorReference::Pointer ref, bool setFocus)
{
IEditorReference::Pointer visibleEditor = this->GetVisibleEditor();
if (ref != visibleEditor)
{
IWorkbenchPart::Pointer part = ref->GetPart(true);
PartPane::Pointer pane;
if (part != 0)
{
pane = part->GetSite().Cast<PartSite>()->GetPane();
}
if (pane != 0)
{
pane->GetContainer().Cast<PartStack>()->SetSelection(pane);
if (setFocus)
{
part->SetFocus();
}
return true;
}
}
return false;
}
std::list<PartStack::Pointer> EditorAreaHelper::GetWorkbooks()
{
return editorArea->GetEditorWorkbooks();
}
std::list<IEditorReference::Pointer> EditorAreaHelper::GetEditors()
{
std::list<IEditorReference::Pointer> result;
std::list<PartStack::Pointer> workbooks = editorArea->GetEditorWorkbooks();
for (std::list<PartStack::Pointer>::iterator iter = workbooks.begin();
iter != workbooks.end(); ++iter)
{
PartStack::Pointer stack = *iter;
std::list<StackablePart::Pointer> children = stack->GetChildren();
for (std::list<StackablePart::Pointer>::iterator childIter = children.begin();
childIter != children.end(); ++childIter)
{
StackablePart::Pointer part = *childIter;
result.push_back(part.Cast<PartPane>()->GetPartReference().Cast<IEditorReference>());
}
}
return result;
}
PartStack::Pointer EditorAreaHelper::GetWorkbookFromID(const std::string& workbookId)
{
return editorArea->GetWorkbookFromID(workbookId);
}
void EditorAreaHelper::UpdateStackButtons()
{
editorArea->UpdateStackButtons();
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorAreaHelper.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorAreaHelper.h
index 7137831570..d4fb5ee0d6 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorAreaHelper.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorAreaHelper.h
@@ -1,175 +1,175 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYEDITORAREAHELPER_H_
#define BERRYEDITORAREAHELPER_H_
#include "berryLayoutPart.h"
#include "berryStackablePart.h"
#include "berryEditorReference.h"
#include <vector>
#include <list>
namespace berry {
class EditorSashContainer;
class WorkbenchPage;
class PartPane;
class PartStack;
/**
* EditorAreaHelper is a wrapper for PartTabworkbook.
*/
class EditorAreaHelper {
//private ArrayList editorTable = new ArrayList(4);
private:
SmartPointer<EditorSashContainer> editorArea;
/**
* Closes an editor.
*
* @param part the editor to close
*/
void CloseEditor(SmartPointer<PartPane> pane);
void AddToLayout(SmartPointer<PartPane> pane, SmartPointer<PartStack> stack);
public:
/**
* Creates a new EditorAreaHelper.
*/
EditorAreaHelper(WorkbenchPage* page);
/**
* Displays a list of open editors
*/
void DisplayEditorList();
/**
* Closes an editor.
*
* @param part the editor to close
*/
void CloseEditor(IEditorReference::Pointer ref);
/**
* Closes an editor.
*
* @param part the editor to close
*/
void CloseEditor(IEditorPart::Pointer part);
/**
* Deref a given part. Deconstruct its container as required.
* Do not remove drag listeners.
*/
static void DerefPart(StackablePart::Pointer part);
/**
* Dispose of the editor presentation.
*/
~EditorAreaHelper();
/**
* @see IEditorPresentation
*/
std::string GetActiveEditorWorkbookID();
SmartPointer<PartStack> GetActiveWorkbook();
/**
* Returns the editor area.
*/
LayoutPart::Pointer GetLayoutPart();
/**
* Returns the active editor in this perspective. If the editors appear
* in a workbook this will be the visible editor. If the editors are
* scattered around the workbench this will be the most recent editor
* to hold focus.
*
* @return the active editor, or <code>null</code> if no editor is active
*/
IEditorReference::Pointer GetVisibleEditor();
void MoveEditor(IEditorPart::Pointer part, int position);
/**
* Main entry point for adding an editor. Adds the editor to the layout in the given
* stack, and notifies the workbench page when done.
*
* @param ref editor to add
* @param workbookId workbook that will contain the editor (or null if the editor
* should be added to the default workbook)
*/
void AddEditor(EditorReference::Pointer ref, const std::string& workbookId);
/**
* @see IPersistablePart
*/
bool RestoreState(IMemento::Pointer memento);
/**
* Restore the presentation
* @param areaMem
* @return
*/
bool RestorePresentationState(IMemento::Pointer areaMem);
/**
* @see IPersistablePart
*/
bool SaveState(IMemento::Pointer memento);
/**
* @see IEditorPresentation
*/
void SetActiveEditorWorkbookFromID(const std::string& id);
void SetActiveWorkbook(SmartPointer<PartStack> workbook, bool hasFocus);
/**
* Brings an editor to the front and optionally gives it focus.
*
* @param part the editor to make visible
* @param setFocus whether to give the editor focus
* @return true if the visible editor was changed, false if not.
*/
bool SetVisibleEditor(IEditorReference::Pointer ref, bool setFocus);
/**
* Method getWorkbooks.
* @return ArrayList
*/
std::list<SmartPointer<PartStack> > GetWorkbooks();
std::list<IEditorReference::Pointer> GetEditors();
SmartPointer<PartStack> GetWorkbookFromID(const std::string& workbookId);
void UpdateStackButtons();
};
}
#endif /* BERRYEDITORAREAHELPER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorDescriptor.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorDescriptor.cpp
index feece34f65..8c1c021fda 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorDescriptor.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorDescriptor.cpp
@@ -1,449 +1,449 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryEditorDescriptor.h"
#include "berryWorkbenchRegistryConstants.h"
#include "berryWorkbenchPlugin.h"
#include "berryEditorPart.h"
#include "berryImageDescriptor.h"
namespace berry
{
const int EditorDescriptor::OPEN_INTERNAL = 0x01;
const int EditorDescriptor::OPEN_INPLACE = 0x02;
const int EditorDescriptor::OPEN_EXTERNAL = 0x04;
EditorDescriptor::EditorDescriptor(const std::string& id2,
IConfigurationElement::Pointer element) :
testImage(true), matchingStrategyChecked(false), openMode(0)
{
this->SetID(id2);
this->SetConfigurationElement(element);
}
EditorDescriptor::EditorDescriptor() :
testImage(true), matchingStrategyChecked(false), openMode(0)
{
}
//IEditorActionBarContributor::Pointer EditorDescriptor::CreateActionBarContributor()
//{
// // Handle case for predefined editor descriptors, like the
// // one for IEditorRegistry.SYSTEM_INPLACE_EDITOR_ID, which
// // don't have a configuration element.
// if (configurationElement.IsNull())
// {
// return IEditorActionBarContributor::Pointer();
// }
//
// // Get the contributor class name.
// std::string className;
// if (!configurationElement->GetAttribute(IWorkbenchRegistryConstants::ATT_CONTRIBUTOR_CLASS, className))
// {
// return IEditorActionBarContributor::Pointer();
// }
//
// // Create the contributor object.
// IEditorActionBarContributor contributor;
// try
// {
// contributor = configurationElement->CreateExecutableExtension<IEditorActionBarContributor>(
// IWorkbenchRegistryConstants::ATT_CONTRIBUTOR_CLASS);
// }
// catch (CoreException e)
// {
// WorkbenchPlugin::Log("Unable to create editor contributor: " + //$NON-NLS-1$
// id, e);
// }
// return contributor;
//}
std::string EditorDescriptor::GetEditorClassName() const
{
if (configurationElement.IsNull())
{
return className;
}
return RegistryReader::GetClassValue(configurationElement,
WorkbenchRegistryConstants::ATT_CLASS);
}
IConfigurationElement::Pointer EditorDescriptor::GetConfigurationElement() const
{
return configurationElement;
}
IEditorPart::Pointer EditorDescriptor::CreateEditor()
{
IEditorPart::Pointer extension(
configurationElement->CreateExecutableExtension<IEditorPart> (
WorkbenchRegistryConstants::ATT_CLASS));
if (extension.IsNull())
{
// support legacy BlueBerry extensions
extension = configurationElement->CreateExecutableExtension<IEditorPart> (
WorkbenchRegistryConstants::ATT_CLASS, IEditorPart::GetManifestName());
}
return extension;
}
std::string EditorDescriptor::GetFileName() const
{
//if (program == null)
//{
if (configurationElement.IsNull())
{
return fileName;
}
std::string val;
configurationElement->GetAttribute(WorkbenchRegistryConstants::ATT_COMMAND,
val);
return val;
//}
//return program.getName();
}
std::string EditorDescriptor::GetId() const
{
//if (program == null)
//{
if (configurationElement.IsNull())
{
return id;
}
std::string val;
configurationElement->GetAttribute(WorkbenchRegistryConstants::ATT_ID, val);
return val;
//}
//return Util.safeString(program.getName());
}
SmartPointer<ImageDescriptor> EditorDescriptor::GetImageDescriptor() const
{
if (testImage)
{
testImage = false;
if (!imageDesc)
{
std::string imageFileName(this->GetImageFilename());
std::string command(this->GetFileName());
if (!imageFileName.empty() && configurationElement)
{
imageDesc = AbstractUICTKPlugin::ImageDescriptorFromPlugin(
configurationElement->GetContributor(), imageFileName);
}
else if (!command.empty())
{
//imageDesc = WorkbenchImages.getImageDescriptorFromProgram(
// command, 0);
}
}
this->VerifyImage();
}
return imageDesc;
}
void EditorDescriptor::VerifyImage() const
{
//TODO Editor verify image
// if (!imageDesc) {
// imageDesc = WorkbenchImages
// .getImageDescriptor(ISharedImages.IMG_OBJ_FILE);
// }
// else {
// Image img = imageDesc.createImage(false);
// if (img == null) {
// // @issue what should be the default image?
// imageDesc = WorkbenchImages
// .getImageDescriptor(ISharedImages.IMG_OBJ_FILE);
// } else {
// img.dispose();
// }
// }
}
std::string EditorDescriptor::GetImageFilename() const
{
if (!configurationElement)
{
return imageFilename;
}
std::string filename;
configurationElement->GetAttribute(WorkbenchRegistryConstants::ATT_ICON,
filename);
return filename;
}
std::string EditorDescriptor::GetLabel() const
{
//if (program == null)
//{
if (configurationElement.IsNull())
{
return editorName;
}
std::string val;
configurationElement->GetAttribute(WorkbenchRegistryConstants::ATT_NAME, val);
return val;
//}
//return program.getName();
}
std::string EditorDescriptor::GetLauncher() const
{
if (configurationElement.IsNull())
{
return launcherName;
}
std::string val;
configurationElement->GetAttribute(WorkbenchRegistryConstants::ATT_LAUNCHER,
val);
return val;
}
std::string EditorDescriptor::GetPluginID() const
{
if (!configurationElement.IsNull())
{
return configurationElement->GetContributor();
}
return pluginIdentifier;
}
bool EditorDescriptor::IsInternal() const
{
return this->GetOpenMode() == OPEN_INTERNAL;
}
bool EditorDescriptor::IsOpenInPlace() const
{
return this->GetOpenMode() == OPEN_INPLACE;
}
bool EditorDescriptor::IsOpenExternal() const
{
return this->GetOpenMode() == OPEN_EXTERNAL;
}
bool EditorDescriptor::LoadValues(IMemento::Pointer /*memento*/)
{
// editorName = memento.getString(IWorkbenchConstants.TAG_LABEL);
// imageFilename = memento.getString(IWorkbenchConstants.TAG_IMAGE);
// className = memento.getString(IWorkbenchConstants.TAG_CLASS);
// launcherName = memento.getString(IWorkbenchConstants.TAG_LAUNCHER);
// fileName = memento.getString(IWorkbenchConstants.TAG_FILE);
// id = Util.safeString(memento.getString(IWorkbenchConstants.TAG_ID));
// pluginIdentifier = memento.getString(IWorkbenchConstants.TAG_PLUGIN);
//
// Integer openModeInt = memento
// .getInteger(IWorkbenchConstants.TAG_OPEN_MODE);
// if (openModeInt != null)
// {
// openMode = openModeInt.intValue();
// }
// else
// {
// // legacy: handle the older attribute names, needed to allow reading of pre-3.0-RCP workspaces
// boolean internal = new Boolean(memento
// .getString(IWorkbenchConstants.TAG_INTERNAL))
// .booleanValue();
// boolean openInPlace = new Boolean(memento
// .getString(IWorkbenchConstants.TAG_OPEN_IN_PLACE))
// .booleanValue();
// if (internal)
// {
// openMode = OPEN_INTERNAL;
// }
// else
// {
// if (openInPlace)
// {
// openMode = OPEN_INPLACE;
// }
// else
// {
// openMode = OPEN_EXTERNAL;
// }
// }
// }
// if (openMode != OPEN_EXTERNAL && openMode != OPEN_INTERNAL && openMode
// != OPEN_INPLACE)
// {
// WorkbenchPlugin
// .log("Ignoring editor descriptor with invalid openMode: " + this); //$NON-NLS-1$
// return false;
// }
//
// String programName = memento
// .getString(IWorkbenchConstants.TAG_PROGRAM_NAME);
// if (programName != null)
// {
// this.program = findProgram(programName);
// }
return true;
}
void EditorDescriptor::SaveValues(IMemento::Pointer /*memento*/)
{
// memento.putString(IWorkbenchConstants.TAG_LABEL, getLabel());
// memento.putString(IWorkbenchConstants.TAG_IMAGE, getImageFilename());
// memento.putString(IWorkbenchConstants.TAG_CLASS, getEditorClassName());
// memento.putString(IWorkbenchConstants.TAG_LAUNCHER, getLauncher());
// memento.putString(IWorkbenchConstants.TAG_FILE, getFileName());
// memento.putString(IWorkbenchConstants.TAG_ID, getId());
// memento.putString(IWorkbenchConstants.TAG_PLUGIN, getPluginId());
//
// memento.putInteger(IWorkbenchConstants.TAG_OPEN_MODE, getOpenMode());
// // legacy: handle the older attribute names, needed to allow reading of workspace by pre-3.0-RCP
// memento.putString(IWorkbenchConstants.TAG_INTERNAL, String
// .valueOf(isInternal()));
// memento.putString(IWorkbenchConstants.TAG_OPEN_IN_PLACE, String
// .valueOf(isOpenInPlace()));
//
// if (this.program != null)
// {
// memento.putString(IWorkbenchConstants.TAG_PROGRAM_NAME,
// this.program.getName());
// }
}
int EditorDescriptor::GetOpenMode() const
{
if (configurationElement.IsNull())
{ // if we've been serialized, return our serialized value
return openMode;
}
else if (this->GetLauncher() != "")
{
// open using a launcer
return EditorDescriptor::OPEN_EXTERNAL;
}
else if (this->GetFileName() != "")
{
// open using an external editor
return EditorDescriptor::OPEN_EXTERNAL;
}
else if (this->GetPluginId() != "")
{
// open using an internal editor
return EditorDescriptor::OPEN_INTERNAL;
}
else
{
return 0; // default for system editor
}
}
void EditorDescriptor::SetClassName(const std::string& newClassName)
{
className = newClassName;
}
void EditorDescriptor::SetConfigurationElement(
IConfigurationElement::Pointer newConfigurationElement)
{
configurationElement = newConfigurationElement;
}
void EditorDescriptor::SetFileName(const std::string& aFileName)
{
fileName = aFileName;
}
void EditorDescriptor::SetID(const std::string& anID)
{
id = anID;
}
void EditorDescriptor::SetLauncher(const std::string& newLauncher)
{
launcherName = newLauncher;
}
void EditorDescriptor::SetName(const std::string& newName)
{
editorName = newName;
}
void EditorDescriptor::SetOpenMode(int mode)
{
openMode = mode;
}
void EditorDescriptor::SetPluginIdentifier(const std::string& anID)
{
pluginIdentifier = anID;
}
std::string EditorDescriptor::ToString() const
{
return "EditorDescriptor(id=" + this->GetId() + ", label=" + this->GetLabel()
+ ")"; //$NON-NLS-2$ //$NON-NLS-3$//$NON-NLS-1$
}
std::string EditorDescriptor::GetLocalId() const
{
return this->GetId();
}
std::string EditorDescriptor::GetPluginId() const
{
return this->GetPluginID();
}
IEditorMatchingStrategy::Pointer EditorDescriptor::GetEditorMatchingStrategy()
{
if (matchingStrategy.IsNull() && !matchingStrategyChecked)
{
matchingStrategyChecked = true;
if (/*program == null &&*/!configurationElement.IsNull())
{
std::string strategy;
if (configurationElement->GetAttribute(
WorkbenchRegistryConstants::ATT_MATCHING_STRATEGY, strategy))
{
try
{
matchingStrategy = configurationElement->CreateExecutableExtension<
IEditorMatchingStrategy> (
WorkbenchRegistryConstants::ATT_MATCHING_STRATEGY);
if (matchingStrategy.IsNull())
{
// support legacy BlueBerry extensions
matchingStrategy = configurationElement->CreateExecutableExtension<
IEditorMatchingStrategy> (
WorkbenchRegistryConstants::ATT_MATCHING_STRATEGY,
IEditorMatchingStrategy::GetManifestName());
}
} catch (CoreException e)
{
WorkbenchPlugin::Log(
"Error creating editor management policy for editor id "
+ this->GetId(), e); //$NON-NLS-1$
}
}
}
}
return matchingStrategy;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorDescriptor.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorDescriptor.h
index aacfd66949..d36c124de6 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorDescriptor.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorDescriptor.h
@@ -1,390 +1,390 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYEDITORDESCRIPTOR_H_
#define BERRYEDITORDESCRIPTOR_H_
#include "berryIEditorDescriptor.h"
#include "berryIMemento.h"
#include <berryIConfigurationElement.h>
namespace berry
{
struct IEditorPart;
/**
* \ingroup org_blueberry_ui_internal
*
* @see IEditorDescriptor
*/
class BERRY_UI EditorDescriptor : public IEditorDescriptor
{ //, Serializable, IPluginContribution {
public:
berryObjectMacro(EditorDescriptor)
// @issue the following constants need not be public; see bug 47600
/**
* Open internal constant. Value <code>0x01</code>.
*/
static const int OPEN_INTERNAL; // = 0x01;
/**
* Open in place constant. Value <code>0x02</code>.
*/
static const int OPEN_INPLACE; // = 0x02;
/**
* Open external constant. Value <code>0x04</code>.
*/
static const int OPEN_EXTERNAL; // = 0x04;
private:
std::string editorName;
std::string imageFilename;
mutable SmartPointer<ImageDescriptor> imageDesc;
mutable bool testImage;
std::string className;
std::string launcherName;
std::string fileName;
std::string id;
bool matchingStrategyChecked;
IEditorMatchingStrategy::Pointer matchingStrategy;
//Program program;
//The id of the plugin which contributed this editor, null for external editors
std::string pluginIdentifier;
int openMode;
IConfigurationElement::Pointer configurationElement;
/**
* Create a new instance of an editor descriptor. Limited
* to internal framework calls.
* @param element
* @param id2
*/
/* package */
public: EditorDescriptor(const std::string& id2, IConfigurationElement::Pointer element);
/**
* Create a new instance of an editor descriptor. Limited
* to internal framework calls.
*/
/* package */
public: EditorDescriptor();
/**
* Creates a descriptor for an external program.
*
* @param filename the external editor full path and filename
* @return the editor descriptor
*/
//public: static EditorDescriptor::Pointer CreateForProgram(const std::string& filename) {
// if (filename == null) {
// throw new IllegalArgumentException();
// }
// EditorDescriptor editor = new EditorDescriptor();
//
// editor.setFileName(filename);
// editor.setID(filename);
// editor.setOpenMode(OPEN_EXTERNAL);
//
// //Isolate the program name (no directory or extension)
// int start = filename.lastIndexOf(File.separator);
// String name;
// if (start != -1) {
// name = filename.substring(start + 1);
// } else {
// name = filename;
// }
// int end = name.lastIndexOf('.');
// if (end != -1) {
// name = name.substring(0, end);
// }
// editor.setName(name);
//
// // get the program icon without storing it in the registry
// ImageDescriptor imageDescriptor = new ProgramImageDescriptor(filename,
// 0);
// editor.setImageDescriptor(imageDescriptor);
//
// return editor;
// }
/**
* Return the program called programName. Return null if it is not found.
* @return org.blueberry.swt.program.Program
*/
//private: static Program FindProgram(const std::string& programName) {
//
// Program[] programs = Program.getPrograms();
// for (int i = 0; i < programs.length; i++) {
// if (programs[i].getName().equals(programName)) {
// return programs[i];
// }
// }
//
// return null;
// }
/**
* Create the editor action bar contributor for editors of this type.
*
* @return the action bar contributor, or <code>null</code>
*/
//public: IEditorActionBarContributor::Pointer CreateActionBarContributor();
/**
* Return the editor class name.
*
* @return the class name
*/
public: std::string GetEditorClassName() const;
/**
* Return the configuration element used to define this editor, or <code>null</code>.
*
* @return the element or null
*/
public: IConfigurationElement::Pointer GetConfigurationElement() const;
/**
* Create an editor part based on this descriptor.
*
* @return the editor part
* @throws CoreException thrown if there is an issue creating the editor
*/
public: SmartPointer<IEditorPart> CreateEditor();
/**
* Return the file name of the command to execute for this editor.
*
* @return the file name to execute
*/
public: std::string GetFileName() const;
/**
* Return the id for this editor.
*
* @return the id
*/
public: std::string GetId() const;
/**
* Return the image descriptor describing this editor.
*
* @return the image descriptor
*/
public: SmartPointer<ImageDescriptor> GetImageDescriptor() const;
/**
* Verifies that the image descriptor generates an image. If not, the
* descriptor is replaced with the default image.
*
* @since 3.1
*/
private: void VerifyImage() const;
/**
* The name of the image describing this editor.
*
* @return the image file name
*/
public: std::string GetImageFilename() const;
/**
* Return the user printable label for this editor.
*
* @return the label
*/
public: std::string GetLabel() const;
/**
* Returns the class name of the launcher.
*
* @return the launcher class name
*/
public: std::string GetLauncher() const;
/**
* Return the contributing plugin id.
*
* @return the contributing plugin id
*/
public: std::string GetPluginID() const;
/**
* Get the program for the receiver if there is one.
* @return Program
*/
//public: Program GetProgram() {
// return this.program;
// }
/* (non-Javadoc)
* @see org.blueberry.ui.IEditorDescriptor#isInternal
*/
public: bool IsInternal() const;
/* (non-Javadoc)
* @see org.blueberry.ui.IEditorDescriptor#isOpenInPlace
*/
public: bool IsOpenInPlace() const;
/* (non-Javadoc)
* @see org.blueberry.ui.IEditorDescriptor#isOpenExternal
*/
public: bool IsOpenExternal() const;
/**
* Load the object properties from a memento.
*
* @return <code>true</code> if the values are valid, <code>false</code> otherwise
*/
protected: bool LoadValues(IMemento::Pointer memento);
/**
* Save the object values in a IMemento
*/
protected: void SaveValues(IMemento::Pointer memento);
/**
* Return the open mode of this editor.
*
* @return the open mode of this editor
* @since 3.1
*/
private: int GetOpenMode() const;
/**
* Set the class name of an internal editor.
*/
/* package */public: void SetClassName(const std::string& newClassName);
/**
* Set the configuration element which contributed this editor.
*/
/* package */public: void SetConfigurationElement(
IConfigurationElement::Pointer newConfigurationElement);
/**
* Set the filename of an external editor.
*/
/* package */public: void SetFileName(const std::string& aFileName);
/**
* Set the id of the editor.
* For internal editors this is the id as provided in the extension point
* For external editors it is path and filename of the editor
*/
/* package */public: void SetID(const std::string& anID);
/**
* The Image to use to repesent this editor
*/
/* package */
// public : void SetImageDescriptor(ImageDescriptor desc) {
// imageDesc = desc;
// testImage = true;
// }
/**
* The name of the image to use for this editor.
*/
/* package */
// public: void SetImageFilename(const std::string& aFileName) {
// imageFilename = aFileName;
// }
/**
* Sets the new launcher class name
*
* @param newLauncher the new launcher
*/
/* package */public: void SetLauncher(const std::string& newLauncher);
/**
* The label to show for this editor.
*/
/* package */public: void SetName(const std::string& newName);
/**
* Sets the open mode of this editor descriptor.
*
* @param mode the open mode
*
* @issue this method is public as a temporary fix for bug 47600
*/
public: void SetOpenMode(int mode);
/**
* The id of the plugin which contributed this editor, null for external editors.
*/
/* package */public: void SetPluginIdentifier(const std::string& anID);
/**
* Set the receivers program.
* @param newProgram
*/
/* package */
// public: void SetProgram(Program newProgram) {
//
// this.program = newProgram;
// if (editorName == null) {
// setName(newProgram.getName());
// }
// }
/**
* For debugging purposes only.
*/
public: std::string ToString() const;
/* (non-Javadoc)
* @see org.blueberry.ui.activities.support.IPluginContribution#getLocalId()
*/
public: std::string GetLocalId() const;
/* (non-Javadoc)
* @see org.blueberry.ui.activities.support.IPluginContribution#getPluginId()
*/
public: std::string GetPluginId() const;
/* (non-Javadoc)
* @see org.blueberry.ui.IEditorDescriptor#getEditorManagementPolicy()
*/
public: IEditorMatchingStrategy::Pointer GetEditorMatchingStrategy();
};
}
#endif /*BERRYEDITORDESCRIPTOR_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorManager.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorManager.cpp
index d6a939b8d8..0711758e21 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorManager.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorManager.cpp
@@ -1,1295 +1,1295 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryEditorManager.h"
#include "berryIWorkbenchPart.h"
#include "berryIWorkbenchWindow.h"
#include "berryIEditorRegistry.h"
#include "berryUIException.h"
#include "berryWorkbenchWindow.h"
#include "berryWorkbenchPage.h"
#include "berryEditorSite.h"
#include "berryEditorReference.h"
#include "berryWorkbenchPlugin.h"
#include "berryWorkbenchConstants.h"
#include "berryNullEditorInput.h"
#include "berryEditorAreaHelper.h"
#include "berryPartStack.h"
#include <Poco/Bugcheck.h>
namespace berry
{
const std::string EditorManager::PIN_EDITOR_KEY = "PIN_EDITOR";
const std::string EditorManager::RESOURCES_TO_SAVE_MESSAGE = "Select resources to save:";
const std::string EditorManager::SAVE_RESOURCES_TITLE = "Save Resources";
EditorManager::EditorManager(WorkbenchWindow::Pointer wind,
WorkbenchPage::Pointer workbenchPage,
EditorAreaHelper* pres)
: editorPresentation(pres), window(wind.GetPointer()), page(workbenchPage.GetPointer()) {
poco_check_ptr(editorPresentation);
poco_assert(window != 0);
poco_assert(page != 0);
//page.getExtensionTracker().registerHandler(this, null);
}
void EditorManager::CheckDeleteEditorResources()
{
// // get the current number of editors
// IEditorReference[] editors = page.getEditorReferences();
// // If there are no editors
// if (editors.length == 0)
// {
// if (editorPropChangeListnener != null)
// {
// // remove property change listener for editors
// IPreferenceStore prefStore = WorkbenchPlugin.getDefault()
// .getPreferenceStore();
// prefStore
// .removePropertyChangeListener(editorPropChangeListnener);
// editorPropChangeListnener = null;
// }
// if (pinEditorHandlerActivation != null)
// {
// // remove pin editor keyboard shortcut handler
// final IHandlerService handlerService = (IHandlerService) window.getWorkbench().getService(IHandlerService.class);
// handlerService.deactivateHandler(pinEditorHandlerActivation);
// pinEditorHandlerActivation = null;
// }
// }
}
//void EditorManager::CheckCreateEditorPropListener()
//{
// if (editorPropChangeListnener == null)
// {
// // Add a property change listener for closing editors automatically
// // preference
// // Add or remove the pin icon accordingly
// editorPropChangeListnener = new IPropertyChangeListener()
// {
// public void propertyChange(PropertyChangeEvent event)
// {
// if (event.getProperty().equals(
// IPreferenceConstants.REUSE_EDITORS_BOOLEAN))
// {
// IEditorReference[] editors = getEditors();
// for (int i = 0; i < editors.length; i++)
// {
// ((EditorReference) editors[i]).pinStatusUpdated();
// }
// }
// }
// };
// WorkbenchPlugin.getDefault().getPreferenceStore()
// .addPropertyChangeListener(editorPropChangeListnener);
// }
//}
//void EditorManager::CheckCreatePinEditorShortcutKeyHandler()
//{
// if (pinEditorHandlerActivation == null)
// {
// final Shell shell = window.getShell();
// final IHandler pinEditorHandler = new AbstractHandler()
// {
// public final Object execute(final ExecutionEvent event)
// {
// // check if the "Close editors automatically" preference is
// // set
// IPreferenceStore store = WorkbenchPlugin.getDefault().getPreferenceStore();
// if (store
// .getBoolean(IPreferenceConstants.REUSE_EDITORS_BOOLEAN)
// || ((TabBehaviour)Tweaklets.get(TabBehaviour.KEY)).alwaysShowPinAction())
// {
//
// IWorkbenchPartReference ref = editorPresentation
// .getVisibleEditor();
// if (ref instanceof WorkbenchPartReference)
// {
// WorkbenchPartReference concreteRef = (WorkbenchPartReference) ref;
//
// concreteRef.setPinned(concreteRef.isPinned());
// }
// }
// return null;
// }
// };
//
// // Assign the handler for the pin editor keyboard shortcut.
// final IHandlerService handlerService = (IHandlerService) window.getWorkbench().getService(IHandlerService.class);
// pinEditorHandlerActivation = handlerService.activateHandler(
// "org.blueberry.ui.window.pinEditor", pinEditorHandler, //$NON-NLS-1$
// new ActiveShellExpression(shell));
// }
//}
std::vector<IEditorPart::Pointer> EditorManager::CollectDirtyEditors()
{
std::vector<IEditorPart::Pointer> result;
std::list<IEditorReference::Pointer> editors(page->GetEditorReferences());
for (std::list<IEditorReference::Pointer>::iterator i = editors.begin();
i != editors.end(); ++i)
{
IEditorPart::Pointer part = (*i)->GetPart(false).Cast<IEditorPart>();
if (part.IsNotNull() && part->IsDirty())
{
result.push_back(part);
}
}
return result;
}
bool EditorManager::ContainsEditor(IEditorReference::Pointer ref)
{
std::list<IEditorReference::Pointer> editors(page->GetEditorReferences());
return std::find(editors.begin(), editors.end(), ref) != editors.end();
}
//EditorActionBars* EditorManager::CreateEditorActionBars(
// EditorDescriptor::Pointer desc, IEditorSite::Pointer site)
//{
// // Get the editor type.
// String type = desc.getId();
//
// // If an action bar already exists for this editor type return it.
// EditorActionBars actionBars = (EditorActionBars) actionCache.get(type);
// if (actionBars != null)
// {
// actionBars.addRef();
// return actionBars;
// }
//
// // Create a new action bar set.
// actionBars = new EditorActionBars(page, site.getWorkbenchWindow(), type);
// actionBars.addRef();
// actionCache.put(type, actionBars);
//
// // Read base contributor.
// IEditorActionBarContributor contr = desc.createActionBarContributor();
// if (contr != null)
// {
// actionBars.setEditorContributor(contr);
// contr.init(actionBars, page);
// }
//
// // Read action extensions.
// EditorActionBuilder builder = new EditorActionBuilder();
// contr = builder.readActionExtensions(desc);
// if (contr != null)
// {
// actionBars.setExtensionContributor(contr);
// contr.init(actionBars, page);
// }
//
// // Return action bars.
// return actionBars;
//}
//EditorActionBars* EditorManager::CreateEmptyEditorActionBars(
// IEditorSite::Pointer site)
//{
// // Get the editor type.
// String type = String.valueOf(System.currentTimeMillis());
//
// // Create a new action bar set.
// // Note: It is an empty set.
// EditorActionBars actionBars = new EditorActionBars(page, site.getWorkbenchWindow(), type);
// actionBars.addRef();
// actionCache.put(type, actionBars);
//
// // Return action bars.
// return actionBars;
//}
//void EditorManager::DisposeEditorActionBars(EditorActionBars* actionBars)
//{
// actionBars.removeRef();
// if (actionBars.getRef() <= 0)
// {
// String type = actionBars.getEditorType();
// actionCache.remove(type);
// // refresh the cool bar manager before disposing of a cool item
// ICoolBarManager2 coolBar = (ICoolBarManager2) window.getCoolBarManager2();
// if (coolBar != null)
// {
// coolBar.refresh();
// }
// actionBars.dispose();
// }
//}
IEditorPart::Pointer EditorManager::FindEditor(IEditorInput::Pointer input)
{
return this->FindEditor("", input, IWorkbenchPage::MATCH_INPUT);
}
IEditorPart::Pointer EditorManager::FindEditor(const std::string& editorId,
IEditorInput::Pointer input, int matchFlags)
{
std::vector<IEditorReference::Pointer> refs(this->FindEditors(input, editorId, matchFlags));
if (refs.size() == 0)
{
return IEditorPart::Pointer();
}
return refs[0]->GetEditor(true);
}
std::vector<IEditorReference::Pointer> EditorManager::FindEditors(
IEditorInput::Pointer input, const std::string& editorId, int matchFlags)
{
if (matchFlags == IWorkbenchPage::MATCH_NONE)
{
return std::vector<IEditorReference::Pointer>();
}
std::vector<IEditorReference::Pointer> result;
std::list<IEditorReference::Pointer> othersList(page->GetEditorReferences());
if (!othersList.empty())
{
IEditorReference::Pointer active = page->GetActiveEditorReference();
if (active.IsNotNull())
{
othersList.remove(active);
std::list<IEditorReference::Pointer> activeList;
activeList.push_back(active);
this->FindEditors(activeList, input, editorId, matchFlags, result);
}
this->FindEditors(othersList, input, editorId, matchFlags, result);
}
return result;
}
void EditorManager::FindEditors(
std::list<IEditorReference::Pointer>& editorList,
IEditorInput::Pointer input, const std::string& editorId, int matchFlags,
std::vector<IEditorReference::Pointer>& result)
{
if (matchFlags == IWorkbenchPage::MATCH_NONE)
{
return;
}
// Phase 0: Remove editors whose ids don't match (if matching by id)
if (((matchFlags & IWorkbenchPage::MATCH_ID) != 0) && !editorId.empty())
{
for (std::list<IEditorReference::Pointer>::iterator i = editorList.begin();
i != editorList.end();)
{
if (editorId != (*i)->GetId())
{
i = editorList.erase(i);
continue;
}
++i;
}
}
// If not matching on editor input, just return the remaining editors.
// In practice, this case is never used.
if ((matchFlags & IWorkbenchPage::MATCH_INPUT) == 0)
{
result.insert(result.end(), editorList.begin(), editorList.end());
return;
}
// Phase 1: check editors that have their own matching strategy
for (std::list<IEditorReference::Pointer>::iterator i = editorList.begin();
i != editorList.end();)
{
EditorReference::Pointer editor = i->Cast<EditorReference>();
IEditorDescriptor::Pointer desc = editor->GetDescriptor();
if (desc.IsNotNull())
{
IEditorMatchingStrategy::Pointer matchingStrategy = desc
->GetEditorMatchingStrategy();
if (matchingStrategy.IsNotNull())
{
i = editorList.erase(i); // We're handling this one here, so remove it
// from the list.
if (matchingStrategy->Matches(editor, input))
{
result.push_back(editor);
}
continue;
}
}
++i;
}
// Phase 2: check materialized editors (without their own matching
// strategy)
for (std::list<IEditorReference::Pointer>::iterator i = editorList.begin();
i != editorList.end();)
{
EditorReference::Pointer editor = i->Cast<EditorReference>();
IEditorPart::Pointer part = editor->GetPart(false).Cast<IEditorPart>();
if (part.IsNotNull())
{
i = editorList.erase(i); // We're handling this one here, so remove it from
// the list.
if (part->GetEditorInput().IsNotNull() && part->GetEditorInput() == input)
{
result.push_back(editor);
}
}
else ++i;
}
// Phase 3: check unmaterialized editors for input equality,
// delaying plug-in activation further by only restoring the editor
// input
// if the editor reference's factory id and name match.
// std::string name = input->GetName();
// IPersistableElement persistable = input.getPersistable();
// if (name == null || persistable == null)
// {
// return;
// }
// String id = persistable.getFactoryId();
// if (id == null)
// {
// return;
// }
// for (Iterator i = editorList.iterator(); i.hasNext();)
// {
// EditorReference editor = (EditorReference) i.next();
// if (name.equals(editor.getName()) && id.equals(editor.getFactoryId()))
// {
// IEditorInput restoredInput;
// try
// {
// restoredInput = editor.getEditorInput();
// if (Util.equals(restoredInput, input))
// {
// result.add(editor);
// }
// }
// catch (PartInitException e1)
// {
// WorkbenchPlugin.log(e1);
// }
// }
// }
}
std::size_t EditorManager::GetEditorCount()
{
return page->GetEditorReferences().size();
}
IEditorRegistry* EditorManager::GetEditorRegistry()
{
return WorkbenchPlugin::GetDefault()->GetEditorRegistry();
}
std::vector<IEditorPart::Pointer> EditorManager::GetDirtyEditors()
{
return this->CollectDirtyEditors();
}
std::list<IEditorReference::Pointer> EditorManager::GetEditors()
{
return page->GetEditorReferences();
}
IEditorPart::Pointer EditorManager::GetVisibleEditor()
{
IEditorReference::Pointer ref = editorPresentation->GetVisibleEditor();
if (ref.IsNull())
{
return IEditorPart::Pointer(0);
}
return ref->GetPart(true).Cast<IEditorPart>();
}
bool EditorManager::IsSaveAllNeeded()
{
std::list<IEditorReference::Pointer> editors(page->GetEditorReferences());
for (std::list<IEditorReference::Pointer>::iterator i = editors.begin();
i != editors.end(); ++i)
{
if ((*i)->IsDirty())
{
return true;
}
}
return false;
}
IEditorReference::Pointer EditorManager::FindReusableEditor(
EditorDescriptor::Pointer /*desc*/)
{
//return ((TabBehaviour)Tweaklets.get(TabBehaviour.KEY)).findReusableEditor(page);
return IEditorReference::Pointer(0);
}
IEditorReference::Pointer EditorManager::OpenEditor(
const std::string& editorId, IEditorInput::Pointer input, bool /*setVisible*/,
IMemento::Pointer editorState)
{
if (input.IsNull())
{
throw Poco::InvalidArgumentException();
}
IEditorRegistry* reg = this->GetEditorRegistry();
EditorDescriptor::Pointer desc = reg->FindEditor(editorId).Cast<EditorDescriptor>();
if (desc.IsNull())
{
throw PartInitException("Unable to open editor, unknown editor id", editorId);
}
return this->OpenEditorFromDescriptor(desc, input, editorState);
}
IEditorReference::Pointer EditorManager::OpenEditorFromDescriptor(
EditorDescriptor::Pointer desc, IEditorInput::Pointer input,
IMemento::Pointer editorState)
{
IEditorReference::Pointer result;
if (desc->IsInternal())
{
result = this->ReuseInternalEditor(desc, input);
if (result.IsNull())
{
result = new EditorReference(this, input, desc, editorState);
}
}
// else if (desc->GetId() == IEditorRegistry::SYSTEM_INPLACE_EDITOR_ID)
// {
// if (ComponentSupport.inPlaceEditorSupported())
// {
// result = new EditorReference(this, input, desc);
// }
// }
// else if (desc->GetId() == IEditorRegistry::SYSTEM_EXTERNAL_EDITOR_ID)
// {
// IPathEditorInput pathInput = getPathEditorInput(input);
// if (pathInput != null)
// {
// result = openSystemExternalEditor(pathInput.getPath());
// }
// else
// {
// throw new PartInitException(
// WorkbenchMessages.EditorManager_systemEditorError);
// }
// }
// else if (desc->IsOpenExternal())
// {
// result = openExternalEditor(desc, input);
// }
else
{
// this should never happen
throw PartInitException("Invalid editor descriptor for id", desc->GetId());
}
if (result.IsNotNull())
{
this->CreateEditorTab(result.Cast<EditorReference>(), ""); //$NON-NLS-1$
}
// Workbench wb = (Workbench) window.getWorkbench();
// wb.getEditorHistory().add(input, desc);
return result;
}
//IEditorReference::Pointer EditorManager::OpenExternalEditor(
// EditorDescriptor::Pointer desc, IEditorInput::Pointer input)
//{
// final CoreException ex[] = new CoreException[1];
//
// final IPathEditorInput pathInput = getPathEditorInput(input);
// if (pathInput != null && pathInput.getPath() != null)
// {
// BusyIndicator.showWhile(getDisplay(), new Runnable()
// {
// public void run()
// {
// try
// {
// if (desc.getLauncher() != null)
// {
// // open using launcher
// Object launcher = WorkbenchPlugin.createExtension(
// desc.getConfigurationElement(), "launcher"); //$NON-NLS-1$
// ((IEditorLauncher) launcher).open(pathInput
// .getPath());
// }
// else
// {
// // open using command
// ExternalEditor oEditor = new ExternalEditor(
// pathInput.getPath(), desc);
// oEditor.open();
// }
// }
// catch (CoreException e)
// {
// ex[0] = e;
// }
// }
// }
// );
// }
// else
// {
// throw new PartInitException(NLS.bind(
// WorkbenchMessages.EditorManager_errorOpeningExternalEditor,
// desc.getFileName(), desc.getId()));
// }
//
// if (ex[0] != null)
// {
// throw new PartInitException(NLS.bind(
// WorkbenchMessages.EditorManager_errorOpeningExternalEditor,
// desc.getFileName(), desc.getId()), ex[0]);
// }
//
// // we do not have an editor part for external editors
// return null;
//}
void EditorManager::CreateEditorTab(EditorReference::Pointer ref, const std::string& workbookId)
{
editorPresentation->AddEditor(ref, workbookId);
}
EditorSite::Pointer EditorManager::CreateSite(IEditorReference::Pointer ref,
IEditorPart::Pointer part, EditorDescriptor::Pointer desc,
IEditorInput::Pointer input) const
{
EditorSite::Pointer site(new EditorSite(ref, part, page, desc));
if (desc.IsNotNull())
{
//site.setActionBars(createEditorActionBars(desc, site));
}
else
{
//site.setActionBars(createEmptyEditorActionBars(site));
}
const std::string label = part->GetPartName(); // debugging only
try
{
part->Init(site, input);
// Sanity-check the site
if (!(part->GetSite() == site) || !(part->GetEditorSite() == site))
{
throw PartInitException("Editor initialization failed: " + desc->GetId() + ". Site is incorrect.");
}
}
catch (PartInitException e)
{
throw e;
}
catch (std::exception e)
{
throw PartInitException("An exception was thrown during initialization", e.what());
}
return site;
}
IEditorReference::Pointer EditorManager::ReuseInternalEditor(
EditorDescriptor::Pointer /*desc*/, IEditorInput::Pointer /*input*/)
{
// poco_assert(desc.IsNotNull()); // "descriptor must not be null"); //$NON-NLS-1$
// poco_assert(input.IsNotNull()); // "input must not be null"); //$NON-NLS-1$
//
// IEditorReference::Pointer reusableEditorRef = this->FindReusableEditor(desc);
// if (reusableEditorRef.IsNotNull())
// {
// return this->ReuseInternalEditor(page, this, editorPresentation, desc, input,
// reusableEditorRef);
// }
return IEditorReference::Pointer(0);
}
IEditorPart::Pointer EditorManager::CreatePart(EditorDescriptor::Pointer desc) const
{
// try
// {
IEditorPart::Pointer result = desc->CreateEditor();
// IConfigurationElement element = desc.getConfigurationElement();
// if (element != null)
// {
// page.getExtensionTracker().registerObject(
// element.getDeclaringExtension(), result,
// IExtensionTracker.REF_WEAK);
// }
return result;
// }
// catch (CoreException e)
// {
// throw PartInitException(StatusUtil.newStatus(
// desc.getPluginID(),
// WorkbenchMessages.EditorManager_instantiationError, e));
// }
}
//IEditorReference::Pointer EditorManager::OpenSystemExternalEditor(
// Poco::Path location)
//{
// if (location == null)
// {
// throw new IllegalArgumentException();
// }
//
// final boolean result[] =
// { false};
// BusyIndicator.showWhile(getDisplay(), new Runnable()
// {
// public void run()
// {
// if (location != null)
// {
// result[0] = Program.launch(location.toOSString());
// }
// }
// }
// );
//
// if (!result[0])
// {
// throw new PartInitException(NLS.bind(
// WorkbenchMessages.EditorManager_unableToOpenExternalEditor,
// location));
// }
//
// // We do not have an editor part for external editors
// return null;
// }
// ImageDescriptor EditorManager::FindImage(EditorDescriptor::Pointer desc,
// Poco::Path path)
// {
// if (desc == null)
// {
// // @issue what should be the default image?
// return ImageDescriptor.getMissingImageDescriptor();
// }
//
// if (desc.isOpenExternal() && path != null)
// {
// return PlatformUI.getWorkbench().getEditorRegistry()
// .getImageDescriptor(path.toOSString());
// }
//
// return desc.getImageDescriptor();
// }
bool EditorManager::RestoreState(IMemento::Pointer memento)
{
// Restore the editor area workbooks layout/relationship
// MultiStatus result = new MultiStatus(PlatformUI.PLUGIN_ID,
// IStatus.OK,
// WorkbenchMessages.EditorManager_problemsRestoringEditors, null);
bool result = true;
std::string activeWorkbookID;
std::vector<IEditorReference::Pointer> visibleEditors;
std::vector<IEditorReference::Pointer> activeEditor;
IMemento::Pointer areaMem = memento->GetChild(WorkbenchConstants::TAG_AREA);
if (areaMem)
{
//result.add(editorPresentation.restoreState(areaMem));
editorPresentation->RestoreState(areaMem);
areaMem->GetString(WorkbenchConstants::TAG_ACTIVE_WORKBOOK, activeWorkbookID);
}
// Loop through the editors.
std::vector<IMemento::Pointer> editorMems(memento->GetChildren(WorkbenchConstants::TAG_EDITOR));
for (std::size_t x = 0; x < editorMems.size(); x++)
{
// for dynamic UI - call restoreEditorState to replace code which is
// commented out
RestoreEditorState(editorMems[x], visibleEditors, activeEditor); //, result);
}
// restore the presentation
if (areaMem)
{
//result.add(editorPresentation.restorePresentationState(areaMem));
result &= editorPresentation->RestorePresentationState(areaMem);
}
try
{
// StartupThreading.runWithThrowable(new StartupRunnable()
// {
//
// public void runWithException() throws Throwable
// {
// Update each workbook with its visible editor.
for (std::size_t i = 0; i < visibleEditors.size(); i++)
{
SetVisibleEditor(visibleEditors[i], false);
}
// Update the active workbook
if (!activeWorkbookID.empty())
{
editorPresentation->SetActiveEditorWorkbookFromID(activeWorkbookID);
}
if (!activeEditor.empty() && activeEditor[0])
{
IWorkbenchPart::Pointer editor = activeEditor[0]->GetPart(true);
if (editor)
{
page->Activate(editor);
}
}
// }});
}
catch (...)
{
// The exception is already logged.
// result
// .add(new Status(
// IStatus.ERR,
// PlatformUI.PLUGIN_ID,
// 0,
// WorkbenchMessages.EditorManager_exceptionRestoringEditor,
// t));
result &= false;
}
return result;
}
bool EditorManager::SaveAll(bool confirm, bool closing,
bool addNonPartSources)
{
// Get the list of dirty editors and views. If it is
// empty just return.
std::vector<ISaveablePart::Pointer> parts(page->GetDirtyParts());
if (parts.empty())
{
return true;
}
std::vector<IWorkbenchPart::Pointer> wbParts;
for (std::vector<ISaveablePart::Pointer>::const_iterator i = parts.begin();
i != parts.end(); ++i)
{
if (IWorkbenchPart::Pointer part = i->Cast<IWorkbenchPart>())
{
wbParts.push_back(part);
}
}
// If confirmation is required ..
return this->SaveAll(wbParts, confirm, closing, addNonPartSources, IWorkbenchWindow::Pointer(window));
}
bool EditorManager::SaveAll(
const std::vector<IWorkbenchPart::Pointer>& /*dirtyParts*/, bool /*confirm*/,
bool /*closing*/, bool /*addNonPartSources*/, SmartPointer<IWorkbenchWindow> /*window*/)
{
// // clone the input list
// dirtyParts = new ArrayList(dirtyParts);
// List modelsToSave;
// if (confirm) {
// boolean saveable2Processed = false;
// // Process all parts that implement ISaveablePart2.
// // These parts are removed from the list after saving
// // them. We then need to restore the workbench to
// // its previous state, for now this is just last
// // active perspective.
// // Note that the given parts may come from multiple
// // windows, pages and perspectives.
// ListIterator listIterator = dirtyParts.listIterator();
//
// WorkbenchPage currentPage = null;
// Perspective currentPageOriginalPerspective = null;
// while (listIterator.hasNext()) {
// IWorkbenchPart part = (IWorkbenchPart) listIterator.next();
// if (part instanceof ISaveablePart2) {
// WorkbenchPage page = (WorkbenchPage) part.getSite()
// .getPage();
// if (!Util.equals(currentPage, page)) {
// if (currentPage != null
// && currentPageOriginalPerspective != null) {
// if (!currentPageOriginalPerspective
// .equals(currentPage.getActivePerspective())) {
// currentPage
// .setPerspective(currentPageOriginalPerspective
// .getDesc());
// }
// }
// currentPage = page;
// currentPageOriginalPerspective = page
// .getActivePerspective();
// }
// if (confirm) {
// if (part instanceof IViewPart) {
// Perspective perspective = page
// .getFirstPerspectiveWithView((IViewPart) part);
// if (perspective != null) {
// page.setPerspective(perspective.getDesc());
// }
// }
// // show the window containing the page?
// IWorkbenchWindow partsWindow = page
// .getWorkbenchWindow();
// if (partsWindow != partsWindow.getWorkbench()
// .getActiveWorkbenchWindow()) {
// Shell shell = partsWindow.getShell();
// if (shell.getMinimized()) {
// shell.setMinimized(false);
// }
// shell.setActive();
// }
// page.bringToTop(part);
// }
// // try to save the part
// int choice = SaveableHelper.savePart((ISaveablePart2) part,
// page.getWorkbenchWindow(), confirm);
// if (choice == ISaveablePart2.CANCEL) {
// // If the user cancels, don't restore the previous
// // workbench state, as that will
// // be an unexpected switch from the current state.
// return false;
// } else if (choice != ISaveablePart2.DEFAULT) {
// saveable2Processed = true;
// listIterator.remove();
// }
// }
// }
//
// // try to restore the workbench to its previous state
// if (currentPage != null && currentPageOriginalPerspective != null) {
// if (!currentPageOriginalPerspective.equals(currentPage
// .getActivePerspective())) {
// currentPage.setPerspective(currentPageOriginalPerspective
// .getDesc());
// }
// }
//
// // if processing a ISaveablePart2 caused other parts to be
// // saved, remove them from the list presented to the user.
// if (saveable2Processed) {
// listIterator = dirtyParts.listIterator();
// while (listIterator.hasNext()) {
// ISaveablePart part = (ISaveablePart) listIterator.next();
// if (!part.isDirty()) {
// listIterator.remove();
// }
// }
// }
//
// modelsToSave = convertToSaveables(dirtyParts, closing, addNonPartSources);
//
// // If nothing to save, return.
// if (modelsToSave.isEmpty()) {
// return true;
// }
// boolean canceled = SaveableHelper.waitForBackgroundSaveJobs(modelsToSave);
// if (canceled) {
// return false;
// }
// // Use a simpler dialog if there's only one
// if (modelsToSave.size() == 1) {
// Saveable model = (Saveable) modelsToSave.get(0);
// String message = NLS.bind(WorkbenchMessages.EditorManager_saveChangesQuestion, model.getName());
// // Show a dialog.
// String[] buttons = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL };
// MessageDialog d = new MessageDialog(
// shellProvider.getShell(), WorkbenchMessages.Save_Resource,
// null, message, MessageDialog.QUESTION, buttons, 0);
//
// int choice = SaveableHelper.testGetAutomatedResponse();
// if (SaveableHelper.testGetAutomatedResponse() == SaveableHelper.USER_RESPONSE) {
// choice = d.open();
// }
//
// // Branch on the user choice.
// // The choice id is based on the order of button labels
// // above.
// switch (choice) {
// case ISaveablePart2.YES: // yes
// break;
// case ISaveablePart2.NO: // no
// return true;
// default:
// case ISaveablePart2.CANCEL: // cancel
// return false;
// }
// }
// else {
// ListSelectionDialog dlg = new ListSelectionDialog(
// shellProvider.getShell(), modelsToSave,
// new ArrayContentProvider(),
// new WorkbenchPartLabelProvider(), RESOURCES_TO_SAVE_MESSAGE);
// dlg.setInitialSelections(modelsToSave.toArray());
// dlg.setTitle(SAVE_RESOURCES_TITLE);
//
// // this "if" statement aids in testing.
// if (SaveableHelper.testGetAutomatedResponse()==SaveableHelper.USER_RESPONSE) {
// int result = dlg.open();
// //Just return false to prevent the operation continuing
// if (result == IDialogConstants.CANCEL_ID) {
// return false;
// }
//
// modelsToSave = Arrays.asList(dlg.getResult());
// }
// }
// }
// else {
// modelsToSave = convertToSaveables(dirtyParts, closing, addNonPartSources);
// }
//
// // If the editor list is empty return.
// if (modelsToSave.isEmpty()) {
// return true;
// }
//
// // Create save block.
// final List finalModels = modelsToSave;
// IRunnableWithProgress progressOp = new IRunnableWithProgress() {
// public void run(IProgressMonitor monitor) {
// IProgressMonitor monitorWrap = new EventLoopProgressMonitor(
// monitor);
// monitorWrap.beginTask("", finalModels.size()); //$NON-NLS-1$
// for (Iterator i = finalModels.iterator(); i.hasNext();) {
// Saveable model = (Saveable) i.next();
// // handle case where this model got saved as a result of saving another
// if (!model.isDirty()) {
// monitor.worked(1);
// continue;
// }
// SaveableHelper.doSaveModel(model, new SubProgressMonitor(monitorWrap, 1), shellProvider, closing || confirm);
// if (monitorWrap.isCanceled()) {
// break;
// }
// }
// monitorWrap.done();
// }
// };
//
// // Do the save.
// return SaveableHelper.runProgressMonitorOperation(
// WorkbenchMessages.Save_All, progressOp, runnableContext, shellProvider);
return true;
}
bool EditorManager::SavePart(ISaveablePart::Pointer /*saveable*/, IWorkbenchPart::Pointer /*part*/, bool /*confirm*/)
{
//TODO EditorManager save part (SaveableHelper)
//return SaveableHelper.savePart(saveable, part, window, confirm);
return true;
}
bool EditorManager::SaveState(const IMemento::Pointer memento)
{
// final MultiStatus result = new MultiStatus(PlatformUI.PLUGIN_ID,
// IStatus.OK,
// WorkbenchMessages.EditorManager_problemsSavingEditors, null);
bool result = true;
// Save the editor area workbooks layout/relationship
IMemento::Pointer editorAreaMem = memento->CreateChild(WorkbenchConstants::TAG_AREA);
//result.add(editorPresentation.saveState(editorAreaMem));
result &= editorPresentation->SaveState(editorAreaMem);
// Save the active workbook id
editorAreaMem->PutString(WorkbenchConstants::TAG_ACTIVE_WORKBOOK,
editorPresentation->GetActiveEditorWorkbookID());
// Get each workbook
std::list<PartStack::Pointer> workbooks(editorPresentation->GetWorkbooks());
for (std::list<PartStack::Pointer>::iterator iter = workbooks.begin();
iter != workbooks.end(); ++iter)
{
PartStack::Pointer workbook = *iter;
// Use the list of editors found in EditorStack; fix for 24091
std::list<StackablePart::Pointer> editorPanes(workbook->GetChildren());
for (std::list<StackablePart::Pointer>::iterator i = editorPanes.begin();
i != editorPanes.end(); ++i)
{
// Save each open editor.
EditorReference::Pointer editorReference = i->Cast<PartPane>()->GetPartReference().Cast<EditorReference>();
IEditorPart::Pointer editor = editorReference->GetEditor(false);
if (!editor)
{
if (editorReference->GetMemento())
{
IMemento::Pointer editorMem = memento
->CreateChild(WorkbenchConstants::TAG_EDITOR);
editorMem->PutMemento(editorReference->GetMemento());
}
continue;
}
// for dynamic UI - add the next line to replace the subsequent
// code which is commented out
SaveEditorState(memento, editorReference); //, result);
}
}
return result;
}
bool EditorManager::SetVisibleEditor(IEditorReference::Pointer newEd,
bool setFocus)
{
return editorPresentation->SetVisibleEditor(newEd, setFocus);
}
IPathEditorInput::Pointer EditorManager::GetPathEditorInput(
IEditorInput::Pointer input)
{
if (input.Cast<IPathEditorInput>().IsNotNull())
{
return input.Cast<IPathEditorInput>();
}
// return (IPathEditorInput)
// Util.getAdapter(input, IPathEditorInput.class);
return IPathEditorInput::Pointer(0);
}
void EditorManager::RestoreEditorState(IMemento::Pointer /*editorMem*/,
std::vector<IEditorReference::Pointer>& /*visibleEditors*/,
std::vector<IEditorReference::Pointer>& /*activeEditor*/)
{
// MultiStatus result) {
//TODO Restore editor state
// String strFocus = editorMem.getString(IWorkbenchConstants.TAG_FOCUS);
// boolean visibleEditor = "true".equals(strFocus); //$NON-NLS-1$
// EditorReference::Pointer e = new EditorReference(this, editorMem);
//
// try
// {
// StartupThreading.runWithPartInitExceptions(new StartupRunnable ()
// {
//
// public void runWithException() throws Throwable
// {
// createEditorTab(e, workbookID);
// }});
//
// }
// catch (PartInitException ex)
// {
// result.add(ex.getStatus());
// }
//
// String strActivePart = editorMem
// .getString(IWorkbenchConstants.TAG_ACTIVE_PART);
// if ("true".equals(strActivePart))
// { //$NON-NLS-1$
// activeEditor[0] = e;
// }
//
// String strFocus = editorMem.getString(IWorkbenchConstants.TAG_FOCUS);
// boolean visibleEditor = "true".equals(strFocus); //$NON-NLS-1$
// if (visibleEditor)
// {
// visibleEditors.add(e);
// }
}
void EditorManager::SaveEditorState(IMemento::Pointer /*mem*/,
IEditorReference::Pointer /*ed*/)
{
//TODO Save editor state
// final EditorReference editorRef = (EditorReference) ed;
// final IEditorPart editor = ed.getEditor(false);
// final IMemento memento = mem;
// final MultiStatus result = res;
// if (!(editor.getEditorSite() instanceof EditorSite))
// {
// return;
// }
// final EditorSite site = (EditorSite) editor.getEditorSite();
// if (site.getPane() instanceof MultiEditorInnerPane)
// {
// return;
// }
//
// SafeRunner.run(new SafeRunnable()
// {
// public void run()
// {
// // Get the input.
// IEditorInput input = editor.getEditorInput();
// if (!input.exists())
// {
// return;
// }
// IPersistableElement persistable = input.getPersistable();
// if (persistable == null)
// {
// return;
// }
//
// // Save editor.
// IMemento editorMem = memento
// .createChild(IWorkbenchConstants.TAG_EDITOR);
// editorMem.putString(IWorkbenchConstants.TAG_TITLE, editorRef
// .getTitle());
// editorMem.putString(IWorkbenchConstants.TAG_NAME, editorRef
// .getName());
// editorMem.putString(IWorkbenchConstants.TAG_ID, editorRef
// .getId());
// editorMem.putString(IWorkbenchConstants.TAG_TOOLTIP, editorRef
// .getTitleToolTip());
//
// editorMem.putString(IWorkbenchConstants.TAG_PART_NAME,
// editorRef.getPartName());
//
// if (editor instanceof IWorkbenchPart3)
// {
// Map properties = ((IWorkbenchPart3) editor)
// .getPartProperties();
// if (!properties.isEmpty())
// {
// IMemento propBag = editorMem
// .createChild(IWorkbenchConstants.TAG_PROPERTIES);
// Iterator i = properties.entrySet().iterator();
// while (i.hasNext())
// {
// Map.Entry entry = (Map.Entry) i.next();
// IMemento p = propBag.createChild(
// IWorkbenchConstants.TAG_PROPERTY,
// (String) entry.getKey());
// p.putTextData((String) entry.getValue());
// }
// }
// }
//
// if (editorRef.isPinned())
// {
// editorMem.putString(IWorkbenchConstants.TAG_PINNED, "true"); //$NON-NLS-1$
// }
//
// EditorPane editorPane = (EditorPane) ((EditorSite) editor
// .getEditorSite()).getPane();
// editorMem.putString(IWorkbenchConstants.TAG_WORKBOOK,
// editorPane.getWorkbook().getID());
//
// if (editor == page.getActivePart())
// {
// editorMem.putString(IWorkbenchConstants.TAG_ACTIVE_PART,
// "true"); //$NON-NLS-1$
// }
//
// if (editorPane == editorPane.getWorkbook().getSelection())
// {
// editorMem.putString(IWorkbenchConstants.TAG_FOCUS, "true"); //$NON-NLS-1$
// }
//
// if (input instanceof IPathEditorInput)
// {
// IPath path = ((IPathEditorInput) input).getPath();
// if (path != null)
// {
// editorMem.putString(IWorkbenchConstants.TAG_PATH, path
// .toString());
// }
// }
//
// // Save input.
// IMemento inputMem = editorMem
// .createChild(IWorkbenchConstants.TAG_INPUT);
// inputMem.putString(IWorkbenchConstants.TAG_FACTORY_ID,
// persistable.getFactoryId());
// persistable.saveState(inputMem);
//
// // any editors that want to persist state
// if (editor instanceof IPersistableEditor)
// {
// IMemento editorState = editorMem
// .createChild(IWorkbenchConstants.TAG_EDITOR_STATE);
// ((IPersistableEditor) editor).saveState(editorState);
// }
// }
//
// public void handleException(Throwable e)
// {
// result
// .add(new Status(
// IStatus.ERR,
// PlatformUI.PLUGIN_ID,
// 0,
// NLS
// .bind(
// WorkbenchMessages.EditorManager_unableToSaveEditor,
// editorRef.getTitle()), e));
// }
// }
// );
}
IMemento::Pointer EditorManager::GetMemento(IEditorReference::Pointer e)
{
if (e.Cast<EditorReference>().IsNotNull())
{
return e.Cast<EditorReference>()->GetMemento();
}
return IMemento::Pointer(0);
}
IEditorReference::Pointer EditorManager::OpenEmptyTab()
{
IEditorInput::Pointer input(new NullEditorInput());
EditorDescriptor::Pointer desc = (dynamic_cast<EditorRegistry*>(this->GetEditorRegistry()))
->FindEditor(EditorRegistry::EMPTY_EDITOR_ID).Cast<EditorDescriptor>();
EditorReference::Pointer result(new EditorReference(this, input, desc));
try
{
this->CreateEditorTab(result, ""); //$NON-NLS-1$
return result;
}
catch (PartInitException e)
{
// StatusManager.getManager().handle(
// StatusUtil.newStatus(WorkbenchPlugin.PI_WORKBENCH, e));
BERRY_ERROR << e.displayText() << std::endl;
}
return IEditorReference::Pointer(0);
}
bool EditorManager::UseIPersistableEditor()
{
// IPreferenceStore store = WorkbenchPlugin.getDefault()
// .getPreferenceStore();
// return store.getBoolean(IPreferenceConstants.USE_IPERSISTABLE_EDITORS);
return false;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorManager.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorManager.h
index e78f8bf9a9..701dae497d 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorManager.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorManager.h
@@ -1,432 +1,432 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYEDITORMANAGER_H_
#define BERRYEDITORMANAGER_H_
#include <berrySmartPointer.h>
#include "berryIEditorPart.h"
#include "berryIEditorReference.h"
#include "berryIPathEditorInput.h"
#include "berryIMemento.h"
#include "berryEditorDescriptor.h"
#include <list>
#include <vector>
namespace berry
{
struct IWorkbenchPart;
struct IWorkbenchWindow;
class WorkbenchWindow;
class WorkbenchPage;
class EditorSite;
class EditorReference;
struct IEditorRegistry;
class EditorAreaHelper;
/**
* \ingroup org_blueberry_ui_internal
*
* Manage a group of element editors. Prevent the creation of two editors on the
* same element.
*
* 06/12/00 - DS - Given the ambiguous editor input type, the manager delegates
* a number of responsibilities to the editor itself.
*
* <ol>
* <li>The editor should determine its own title.</li>
* <li>The editor should listen to resource deltas and close itself if the
* input is deleted. It may also choose to stay open if the editor has dirty
* state.</li>
* <li>The editor should persist its own state plus editor input.</li>
* </ol>
*/
class EditorManager
{ // implements IExtensionChangeHandler {
friend class EditorReference;
EditorAreaHelper* editorPresentation;
WorkbenchWindow* window;
WorkbenchPage* page;
//std::map<std::string, EditorActionBars::Pointer> actionCache = new HashMap();
static const std::string PIN_EDITOR_KEY; // = "PIN_EDITOR"; //$NON-NLS-1$
//static const std::string PIN_EDITOR = "ovr16/pinned_ovr.gif"; //$NON-NLS-1$
// When the user removes or adds the close editors automatically preference
// the icon should be removed or added accordingly
//IPropertyChangeListener editorPropChangeListnener = null;
// Handler for the pin editor keyboard shortcut
//IHandlerActivation pinEditorHandlerActivation = null;
static const std::string RESOURCES_TO_SAVE_MESSAGE; // = "Select resources to save:";
static const std::string SAVE_RESOURCES_TITLE; // = "Save Resources";
public:
/**
* EditorManager constructor comment.
*/
EditorManager(SmartPointer<WorkbenchWindow> window,
SmartPointer<WorkbenchPage> workbenchPage,
EditorAreaHelper* pres);
protected:
/**
* Check to determine if the editor resources are no longer needed removes
* property change listener for editors removes pin editor keyboard shortcut
* handler disposes cached images and clears the cached images hash table
*/
void CheckDeleteEditorResources();
/**
* Check to determine if the property change listener for editors should be
* created
*/
//void CheckCreateEditorPropListener();
/**
* Check to determine if the handler for the pin editor keyboard shortcut
* should be created.
*/
//void CheckCreatePinEditorShortcutKeyHandler();
/**
* Method to create the editor's pin ImageDescriptor
*
* @return the single image descriptor for the editor's pin icon
*/
// ImageDescriptor GetEditorPinImageDesc() {
// ImageRegistry registry = JFaceResources.getImageRegistry();
// ImageDescriptor pinDesc = registry.getDescriptor(PIN_EDITOR_KEY);
// // Avoid registering twice
// if (pinDesc == null) {
// pinDesc = WorkbenchImages.getWorkbenchImageDescriptor(PIN_EDITOR);
// registry.put(PIN_EDITOR_KEY, pinDesc);
//
// }
// return pinDesc;
// }
private:
/**
* Answer a list of dirty editors.
*/
std::vector<IEditorPart::Pointer> CollectDirtyEditors();
/**
* Returns whether the manager contains an editor.
*/
public:
bool ContainsEditor(IEditorReference::Pointer ref);
/*
* Creates the action bars for an editor. Editors of the same type should
* share a single editor action bar, so this implementation may return an
* existing action bar vector.
*/
private:
//EditorActionBars* CreateEditorActionBars(EditorDescriptor::Pointer desc,
// IEditorSite::Pointer site);
/*
* Creates the action bars for an editor.
*/
private:
//EditorActionBars* CreateEmptyEditorActionBars(IEditorSite::Pointer site);
/*
* Dispose
*/
protected:
//void DisposeEditorActionBars(EditorActionBars* actionBars);
/**
* Returns an open editor matching the given editor input. If none match,
* returns <code>null</code>.
*
* @param input
* the editor input
* @return the matching editor, or <code>null</code> if no match fond
*/
public:
IEditorPart::Pointer FindEditor(IEditorInput::Pointer input);
/**
* Returns an open editor matching the given editor input and/or editor id,
* as specified by matchFlags. If none match, returns <code>null</code>.
*
* @param editorId
* the editor id
* @param input
* the editor input
* @param matchFlags
* flags specifying which aspects to match
* @return the matching editor, or <code>null</code> if no match fond
* @since 3.1
*/
public:
IEditorPart::Pointer FindEditor(const std::string& editorId,
IEditorInput::Pointer input, int matchFlags);
/**
* Returns the open editor references matching the given editor input and/or
* editor id, as specified by matchFlags. If none match, returns an empty
* array.
*
* @param editorId
* the editor id
* @param input
* the editor input
* @param matchFlags
* flags specifying which aspects to match
* @return the matching editor, or <code>null</code> if no match fond
* @since 3.1
*/
public:
std::vector<IEditorReference::Pointer> FindEditors(
IEditorInput::Pointer input, const std::string& editorId, int matchFlags);
/**
* Returns an open editor matching the given editor id and/or editor input.
* Returns <code>null</code> if none match.
*
* @param editorId
* the editor id
* @param input
* the editor input
* @param editorList
* a mutable list containing the references for the editors to
* check (warning: items may be removed)
* @param result
* the list to which matching editor references should be added
* @since 3.1
*/
private:
void FindEditors(std::list<SmartPointer<IEditorReference> >& editorList,
IEditorInput::Pointer input, const std::string& editorId, int matchFlags,
std::vector<IEditorReference::Pointer>& result);
/**
* Answer the number of editors.
*/
public:
std::size_t GetEditorCount();
/*
* Answer the editor registry.
*/
private:
IEditorRegistry* GetEditorRegistry();
/*
* See IWorkbenchPage.
*/
public:
std::vector<IEditorPart::Pointer> GetDirtyEditors();
/*
* See IWorkbenchPage.
*/
public:
std::list<IEditorReference::Pointer> GetEditors();
/*
* See IWorkbenchPage#getFocusEditor
*/
public:
IEditorPart::Pointer GetVisibleEditor();
/**
* Answer true if save is needed in any one of the editors.
*/
public:
bool IsSaveAllNeeded();
/*
* Prompt the user to save the reusable editor. Return false if a new editor
* should be opened.
*/
private:
IEditorReference::Pointer FindReusableEditor(EditorDescriptor::Pointer desc);
/**
* @param editorId
* the editor part id
* @param input
* the input
* @param setVisible
* if this is to be created visible ... not used
* @param editorState
* an {@link IMemento} &lt;editorState&gt; for persistable
* editors. Can be <code>null</code>.
* @return a created editor reference
* @throws PartInitException
*/
public:
IEditorReference::Pointer OpenEditor(const std::string& editorId,
IEditorInput::Pointer input, bool setVisible, IMemento::Pointer editorState);
/*
* Open a new editor
*/
public:
IEditorReference::Pointer OpenEditorFromDescriptor(
EditorDescriptor::Pointer desc, IEditorInput::Pointer input,
IMemento::Pointer editorState);
/**
* Open a specific external editor on an file based on the descriptor.
*/
//private:
// IEditorReference::Pointer OpenExternalEditor(EditorDescriptor::Pointer desc,
// IEditorInput::Pointer input);
/*
* Opens an editor part.
*/
private: void CreateEditorTab(SmartPointer<EditorReference> ref, const std::string& workbookId);
/*
* Create the site and initialize it with its action bars.
*/
protected:
SmartPointer<EditorSite> CreateSite(IEditorReference::Pointer ref,
IEditorPart::Pointer part, EditorDescriptor::Pointer desc,
IEditorInput::Pointer input) const;
/*
* See IWorkbenchPage.
*/
private:
IEditorReference::Pointer ReuseInternalEditor(EditorDescriptor::Pointer desc,
IEditorInput::Pointer input);
protected:
IEditorPart::Pointer CreatePart(EditorDescriptor::Pointer desc) const;
/**
* Open a system external editor on the input path.
*/
//private:
// IEditorReference::Pointer OpenSystemExternalEditor(Poco::Path location);
protected:
//ImageDescriptor FindImage(EditorDescriptor::Pointer desc, Poco::Path path);
/**
* @see org.blueberry.ui.IPersistable
*/
public:
/*IStatus*/bool RestoreState(IMemento::Pointer memento);
/**
* Save all of the editors in the workbench. Return true if successful.
* Return false if the user has canceled the command.
* @param confirm true if the user should be prompted before the save
* @param closing true if the page is being closed
* @param addNonPartSources true if saveables from non-part sources should be saved too.
* @return false if the user canceled or an error occurred while saving
*/
public:
bool SaveAll(bool confirm, bool closing, bool addNonPartSources);
/**
* Saves the given dirty editors and views, optionally prompting the user.
*
* @param dirtyParts
* the dirty views and editors
* @param confirm
* <code>true</code> to prompt whether to save, <code>false</code>
* to save without prompting
* @param closing
* <code>true</code> if the parts are being closed,
* <code>false</code> if just being saved without closing
* @param addNonPartSources true if non-part sources should be saved too
* @param window
* the window to use as the parent for the dialog that prompts to
* save multiple dirty editors and views
* @return <code>true</code> on success, <code>false</code> if the user
* canceled the save or an error occurred while saving
*/
public:
static bool SaveAll(const std::vector<IWorkbenchPart::Pointer>& dirtyParts,
bool confirm, bool closing, bool addNonPartSources, SmartPointer<IWorkbenchWindow>);
/*
* Saves the workbench part.
*/
public:
bool SavePart(ISaveablePart::Pointer saveable, IWorkbenchPart::Pointer part, bool confirm);
/**
* @see IPersistablePart
*/
public:
/*IStatus*/bool SaveState(const IMemento::Pointer memento);
/**
* Shows an editor. If <code>setFocus == true</code> then give it focus,
* too.
*
* @return true if the active editor was changed, false if not.
*/
public:
bool SetVisibleEditor(IEditorReference::Pointer newEd, bool setFocus);
private:
IPathEditorInput::Pointer GetPathEditorInput(IEditorInput::Pointer input);
/*
* Made public for Mylar in 3.3 - see bug 138666. Can be made private once
* we have real API for this.
*/
private:
void RestoreEditorState(IMemento::Pointer editorMem,
std::vector<IEditorReference::Pointer>& visibleEditors,
std::vector<IEditorReference::Pointer>& activeEditor);
// for dynamic UI
protected:
void SaveEditorState(IMemento::Pointer mem, IEditorReference::Pointer ed/*, MultiStatus res*/);
// for dynamic UI
public:
IMemento::Pointer GetMemento(IEditorReference::Pointer e);
IEditorReference::Pointer OpenEmptyTab();
public:
static bool UseIPersistableEditor();
};
}
#endif /*BERRYEDITORMANAGER_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorReference.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorReference.cpp
index 2fcbd14569..1d6ef7d27d 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorReference.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorReference.cpp
@@ -1,574 +1,574 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryEditorReference.h"
#include "tweaklets/berryWorkbenchPageTweaklet.h"
#include "berryEditorManager.h"
#include "berryEditorDescriptor.h"
#include "berryEditorRegistry.h"
#include "berryEditorSite.h"
#include "berryEditorAreaHelper.h"
#include "berryWorkbenchPlugin.h"
#include "berryWorkbenchPage.h"
#include "berryNullEditorInput.h"
#include "berryPartTester.h"
#include "berryImageDescriptor.h"
#include "berryPlatformUI.h"
#include "berryIWorkbenchPartConstants.h"
namespace berry
{
EditorReference::EditorReference(EditorManager* man,
IEditorInput::Pointer input, EditorDescriptor::Pointer desc,
IMemento::Pointer editorState) :
manager(man), expectingInputChange(false),
reportedMalfunctioningEditor(false)
{
this->InitListenersAndHandlers();
restoredInput = input;
this->editorState = editorState;
this->Init(desc->GetId(), "", desc->GetImageDescriptor(),
desc->GetLabel(), "");
}
EditorReference::EditorReference(EditorManager* man, IMemento::Pointer memento) :
manager(man), expectingInputChange(false),
reportedMalfunctioningEditor(false)
{
this->InitListenersAndHandlers();
this->editorMemento = memento;
if (manager->UseIPersistableEditor())
{
//editorState = editorMemento->GetChild(WorkbenchConstants::TAG_EDITOR_STATE);
}
else
{
editorState = 0;
}
// String id = memento.getString(IWorkbenchConstants.TAG_ID);
// String title = memento.getString(IWorkbenchConstants.TAG_TITLE);
// String tooltip = Util.safeString(memento
// .getString(IWorkbenchConstants.TAG_TOOLTIP));
// String partName = memento
// .getString(IWorkbenchConstants.TAG_PART_NAME);
//
// IMemento propBag = memento.getChild(IWorkbenchConstants.TAG_PROPERTIES);
// if (propBag != null)
// {
// IMemento[] props = propBag
// .getChildren(IWorkbenchConstants.TAG_PROPERTY);
// for (int i = 0; i < props.length; i++)
// {
// propertyCache.put(props[i].getID(), props[i].getTextData());
// }
// }
// For compatibility set the part name to the title if not found
// if (partName.empty())
// {
// partName = title;
// }
// Get the editor descriptor.
// EditorDescriptor::Pointer desc;
// if (id != null)
// {
// desc = getDescriptor(id);
// }
// // desc may be null if id is null or desc is not found, but findImage below handles this
// String location = memento.getString(IWorkbenchConstants.TAG_PATH);
// IPath path = location == null ? null : new Path(location);
// ImageDescriptor iDesc = this.manager.findImage(desc, path);
//
// this.name = memento.getString(IWorkbenchConstants.TAG_NAME);
// if (this.name == null)
// {
// this.name = title;
// }
// setPinned("true".equals(memento.getString(IWorkbenchConstants.TAG_PINNED))); //$NON-NLS-1$
//
// IMemento inputMem = memento.getChild(IWorkbenchConstants.TAG_INPUT);
// if (inputMem != null)
// {
// this.factoryId = inputMem
// .getString(IWorkbenchConstants.TAG_FACTORY_ID);
// }
//
// init(id, title, tooltip, iDesc, partName, ""); //$NON-NLS-1$
}
EditorDescriptor::Pointer EditorReference::GetDescriptor()
{
return this->GetDescriptor(this->GetId());
}
EditorDescriptor::Pointer EditorReference::GetDescriptor(const std::string& id)
{
EditorDescriptor::Pointer desc;
IEditorRegistry* reg = WorkbenchPlugin::GetDefault()->GetEditorRegistry();
desc = reg->FindEditor(id).Cast<EditorDescriptor> ();
return desc;
}
void EditorReference::InitListenersAndHandlers()
{
// Create a property change listener to track the "close editors automatically"
// preference and show/remove the pin icon on editors
// Only 1 listener will be created in the EditorManager when necessary
//this->manager->CheckCreateEditorPropListener();
// Create a keyboard shortcut handler for pinning editors
// Only 1 handler will be created in the EditorManager when necessary
//this->manager->CheckCreatePinEditorShortcutKeyHandler();
}
PartPane::Pointer EditorReference::CreatePane()
{
PartPane::Pointer pane(
new PartPane(IWorkbenchPartReference::Pointer(this), this->manager->page));
return pane;
//return Tweaklets::Get(WorkbenchTweaklet::KEY)->CreateEditorPane(this,
// this->manager->page);
}
void EditorReference::PinStatusUpdated()
{
//firePropertyChange(IWorkbenchPart.PROP_TITLE);
}
std::string EditorReference::GetFactoryId()
{
// IEditorPart editor = getEditor(false);
// if (editor != null)
// {
// IPersistableElement persistable = editor.getEditorInput()
// .getPersistable();
// if (persistable != null)
// {
// return persistable.getFactoryId();
// }
// return null;
// }
// return factoryId;
return "";
}
std::string EditorReference::ComputePartName()
{
return WorkbenchPartReference::ComputePartName();
}
std::string EditorReference::GetName()
{
if (part.IsNotNull())
{
return this->GetEditor(false)->GetEditorInput()->GetName();
}
return name;
}
IEditorPart::Pointer EditorReference::GetEditor(bool restore)
{
return this->GetPart(restore).Cast<IEditorPart> ();
}
void EditorReference::SetName(const std::string& name)
{
this->name = name;
}
IMemento::Pointer EditorReference::GetMemento()
{
return editorMemento;
}
IWorkbenchPage::Pointer EditorReference::GetPage() const
{
return IWorkbenchPage::Pointer(this->manager->page);
}
IEditorInput::Pointer EditorReference::GetEditorInput()
{
IEditorPart::Pointer part = this->GetEditor(false);
if (part.IsNotNull())
{
return part->GetEditorInput();
}
return this->GetRestoredInput();
}
IEditorInput::Pointer EditorReference::GetRestoredInput()
{
if (restoredInput.IsNotNull())
{
return restoredInput;
}
// Get the input factory.
// IMemento::Pointer editorMem = this->GetMemento();
// if (editorMem == null)
// {
// throw new PartInitException(NLS.bind(WorkbenchMessages.EditorManager_no_persisted_state, getId(), getName()));
// }
// IMemento inputMem = editorMem
// .getChild(IWorkbenchConstants.TAG_INPUT);
// String factoryID = null;
// if (inputMem != null)
// {
// factoryID = inputMem
// .getString(IWorkbenchConstants.TAG_FACTORY_ID);
// }
// if (factoryID == null)
// {
// throw new PartInitException(NLS.bind(WorkbenchMessages.EditorManager_no_input_factory_ID, getId(), getName()));
// }
// IAdaptable input = null;
// String label = null; // debugging only
// if (UIStats.isDebugging(UIStats.CREATE_PART_INPUT))
// {
// label = getName() != null ? getName() : factoryID;
// }
// try
// {
// UIStats.start(UIStats.CREATE_PART_INPUT, label);
// IElementFactory factory = PlatformUI.getWorkbench()
// .getElementFactory(factoryID);
// if (factory == null)
// {
// throw new PartInitException(NLS.bind(WorkbenchMessages.EditorManager_bad_element_factory, new Object[]
// { factoryID, getId(), getName()}));
// }
//
// // Get the input element.
// input = factory.createElement(inputMem);
// if (input == null)
// {
// throw new PartInitException(NLS.bind(WorkbenchMessages.EditorManager_create_element_returned_null, new Object[]
// { factoryID, getId(), getName()}));
// }
// }finally
// {
// UIStats.end(UIStats.CREATE_PART_INPUT, input, label);
// }
// if (!(input instanceof IEditorInput))
// {
// throw new PartInitException(NLS.bind(WorkbenchMessages.EditorManager_wrong_createElement_result, new Object[]
// { factoryID, getId(), getName()}));
// }
// restoredInput = (IEditorInput) input;
return restoredInput;
}
IWorkbenchPart::Pointer EditorReference::CreatePart()
{
if (EditorRegistry::EMPTY_EDITOR_ID == this->GetId())
{
return this->GetEmptyEditor(this->GetDescriptor());
}
IWorkbenchPart::Pointer result;
// Try to restore the editor -- this does the real work of restoring the editor
//
try
{
result = this->CreatePartHelper().Cast<IWorkbenchPart> ();
} catch (PartInitException e)
{
// If unable to create the part, create an error part instead
// and pass the error to the status handling facility
// IStatus originalStatus = exception.getStatus();
// IStatus logStatus = StatusUtil.newStatus(originalStatus,
// NLS.bind("Unable to create editor ID {0}: {1}", //$NON-NLS-1$
// getId(), originalStatus.getMessage()));
// IStatus displayStatus = StatusUtil.newStatus(originalStatus,
// NLS.bind(WorkbenchMessages.EditorManager_unableToCreateEditor,
// originalStatus.getMessage()));
WorkbenchPlugin::Log("Unable to create editor ID " + this->GetId() + ": "
+ e.displayText());
// Pass the error to the status handling facility
//StatusManager.getManager().handle(logStatus);
EditorDescriptor::Pointer descr = this->GetDescriptor();
std::string label = this->GetId();
if (descr.IsNotNull())
label = descr->GetLabel();
IEditorPart::Pointer part =
Tweaklets::Get(WorkbenchPageTweaklet::KEY)->CreateErrorEditorPart(label,
e.displayText());
if (part.IsNotNull())
{
IEditorInput::Pointer input;
try
{
input = this->GetEditorInput();
} catch (PartInitException e1)
{
input = new NullEditorInput(EditorReference::Pointer(this));
}
PartPane::Pointer pane = this->GetPane();
pane->CreateControl(
manager->page->GetEditorPresentation()->GetLayoutPart()->GetControl());
EditorSite::Pointer site(
new EditorSite(IEditorReference::Pointer(this), part, manager->page, descr));
//site.setActionBars(new EditorActionBars(manager.page, site.getWorkbenchWindow(), getId()));
part->Init(site, input);
try
{
part->CreatePartControl(pane->GetControl());
} catch (...)
{
//content.dispose();
//StatusUtil.handleStatus(e, StatusManager.SHOW
// | StatusManager.LOG);
WorkbenchPlugin::Log("Error creating editor");
return IWorkbenchPart::Pointer(0);
}
result = part.Cast<IWorkbenchPart> ();
}
}
return result;
}
void EditorReference::PropertyChanged(Object::Pointer source, int propId)
{
// Detect badly behaved editors that don't fire PROP_INPUT events
// when they're supposed to. This branch is only needed to handle
// malfunctioning editors.
if (propId == IWorkbenchPartConstants::PROP_INPUT)
{
expectingInputChange = false;
}
WorkbenchPartReference::PropertyChanged(source, propId);
}
bool EditorReference::SetInput(IEditorInput::Pointer input)
{
if (part.IsNotNull())
{
if (part.Cast<IReusableEditor> ().IsNotNull())
{
IReusableEditor::Pointer editor = part.Cast<IReusableEditor> ();
expectingInputChange = true;
editor->SetInput(input);
// If the editor never fired a PROP_INPUT event, log the fact that we've discovered
// a buggy editor and fire the event for free. Firing the event for free isn't required
// and cannot be relied on (it only works if the input change was triggered by this
// method, and there are definitely other cases where events will still be lost),
// but older versions of the workbench did this so we fire it here in the spirit
// of playing nice.
if (expectingInputChange)
{
// Log the fact that this editor is broken
this->ReportMalfunction(
"Editor is not firing a PROP_INPUT event in response to IReusableEditor.setInput(...)"); //$NON-NLS-1$
// Fire the property for free (can't be relied on since there are other ways the input
// can change, but we do it here to be consistent with older versions of the workbench)
FirePropertyChange(IWorkbenchPartConstants::PROP_INPUT);
}
return editor->GetEditorInput() == input;
}
// Can't change the input if the editor already exists and isn't an IReusableEditor
return false;
}
// Changing the input is trivial and always succeeds if the editor doesn't exist yet
if (input != restoredInput)
{
restoredInput = input;
//firePropertyChange(IWorkbenchPartConstants.PROP_INPUT);
}
return true;
}
void EditorReference::ReportMalfunction(const std::string& string)
{
if (!reportedMalfunctioningEditor)
{
reportedMalfunctioningEditor = true;
std::string errorMessage = "Problem detected with part " + this->GetId(); //$NON-NLS-1$
if (part.IsNotNull())
{
errorMessage.append("(class = ").append(part->GetClassName()).append(
")"); //$NON-NLS-1$ //$NON-NLS-2$
}
errorMessage += ": " + string; //$NON-NLS-1$
//StatusManager.getManager().handle(StatusUtil.newStatus(getDescriptor().getPluginId(), errorMessage, null));
BERRY_ERROR << errorMessage << std::endl;
}
}
IEditorPart::Pointer EditorReference::CreatePartHelper()
{
EditorSite::Pointer site;
IEditorPart::Pointer part;
try
{
IEditorInput::Pointer editorInput = this->GetEditorInput();
// Get the editor descriptor.
std::string editorID = this->GetId();
EditorDescriptor::Pointer desc = this->GetDescriptor();
if (desc.IsNull())
{
throw PartInitException("No editor descriptor for id " + editorID);
}
if (desc->IsInternal())
{
// Create an editor instance.
part = manager->CreatePart(desc);
this->CreatePartProperties(part);
}
// else if (desc->GetId() == IEditorRegistry.SYSTEM_INPLACE_EDITOR_ID)
// {
//
// part = ComponentSupport.getSystemInPlaceEditor();
//
// if (part == null)
// {
// throw new PartInitException(WorkbenchMessages.EditorManager_no_in_place_support);
// }
// }
else
{
throw PartInitException("Invalid editor descriptor for id " + editorID);
}
// Create a pane for this part
PartPane::Pointer pane = this->GetPane();
pane->CreateControl(manager->page->GetEditorPresentation()->GetLayoutPart()->GetControl());
// Link everything up to the part reference (the part reference itself should not have
// been modified until this point)
site = manager->CreateSite(IEditorReference::Pointer(this), part, desc, editorInput);
// if there is saved state that's appropriate, pass it on
if (/*part instanceof IPersistableEditor &&*/editorState.IsNotNull())
{
//part->RestoreState(editorState);
}
// Remember the site and the action bars (now that we've created them, we'll need to dispose
// them if an exception occurs)
//actionBars = (EditorActionBars) site.getActionBars();
part->CreatePartControl(pane->GetControl());
// The editor should now be fully created. Exercise its public interface, and sanity-check
// it wherever possible. If it's going to throw exceptions or behave badly, it's much better
// that it does so now while we can still cancel creation of the part.
PartTester::TestEditor(part);
return part;
} catch (std::exception e)
{
throw PartInitException(e.what());
}
}
IEditorPart::Pointer EditorReference::GetEmptyEditor(
EditorDescriptor::Pointer descr)
{
IEditorPart::Pointer part =
Tweaklets::Get(WorkbenchPageTweaklet::KEY)->CreateErrorEditorPart("(Empty)", "");
IEditorInput::Pointer input;
try
{
input = this->GetEditorInput();
} catch (PartInitException e1)
{
input = new NullEditorInput(EditorReference::Pointer(this));
}
PartPane::Pointer pane = this->GetPane();
pane->CreateControl(
manager->page->GetEditorPresentation()->GetLayoutPart()->GetControl());
EditorSite::Pointer site(new EditorSite(IEditorReference::Pointer(this),
part, manager->page, descr));
//site.setActionBars(new EditorActionBars(manager.page, site.getWorkbenchWindow(), getId()));
part->Init(site, input);
try
{
part->CreatePartControl(pane->GetControl());
} catch (std::exception e)
{
//StatusManager.getManager().handle(
// StatusUtil.newStatus(WorkbenchPlugin.PI_WORKBENCH, e));
BERRY_ERROR << e.what() << std::endl;
return IEditorPart::Pointer(0);
}
this->part = part.Cast<IWorkbenchPart> ();
// Add a dispose listener to the part. This dispose listener does nothing but log an exception
// if the part's widgets get disposed unexpectedly. The workbench part reference is the only
// object that should dispose this control, and it will remove the listener before it does so.
this->RefreshFromPart();
//this->ReleaseReferences();
if (this->GetPage().Cast<WorkbenchPage> ()->GetActiveEditorReference()
!= this)
{
//fireInternalPropertyChange(INTERNAL_PROPERTY_OPENED);
}
return part;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorReference.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorReference.h
index 064b417411..331a0e3cfd 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorReference.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorReference.h
@@ -1,242 +1,242 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYEDITORREFERENCE_H_
#define BERRYEDITORREFERENCE_H_
#include "berryWorkbenchPartReference.h"
#include "berryIEditorReference.h"
#include "berryIEditorInput.h"
#include "berryIMemento.h"
#include "berryIWorkbenchPart.h"
#include "berryIEditorPart.h"
namespace berry
{
class EditorManager;
class EditorDescriptor;
class PartPane;
struct IWorkbenchPage;
/**
* \ingroup org_blueberry_ui_internal
*
*/
class EditorReference : public WorkbenchPartReference, public IEditorReference
{
private:
const EditorManager* manager;
private:
IMemento::Pointer editorMemento;
private:
IMemento::Pointer editorState;
/**
* Flag that lets us detect malfunctioning editors that don't fire PROP_INPUT events.
* It is never needed for a correctly-functioning
*/
private:
bool expectingInputChange;
/**
* Flag that determines whether we've already reported that this editor is malfunctioning.
* This prevents us from spamming the event log if we repeatedly detect the same error in
* a particular editor. If we ever detect an editor is violating its public contract in
* a way we can recover from (such as a missing property change event), we report the error
* once and then silently ignore errors from the same editor.
*/
private:
bool reportedMalfunctioningEditor;
/**
* User-readable name of the editor's input
*/
std::string name;
std::string factoryId;
IEditorInput::Pointer restoredInput;
/**
* @param manager
* The editor manager for this reference
* @param input
* our input
* @param desc
* the descriptor from the declaration
* @param editorState
* propogate state from another editor. Can be <code>null</code>.
*/
public:
berryObjectMacro(EditorReference)
EditorReference(EditorManager* manager, IEditorInput::Pointer input,
SmartPointer<EditorDescriptor> desc, IMemento::Pointer editorState = IMemento::Pointer(0));
/**
* Constructs a new editor reference for use by editors being restored from
* a memento.
*/
EditorReference(EditorManager* manager, IMemento::Pointer memento);
public:
SmartPointer<EditorDescriptor> GetDescriptor();
/**
* @since 3.1
*
* @param id the id
* @return the editor descriptor
*/
private:
SmartPointer<EditorDescriptor> GetDescriptor(const std::string& id);
/**
* Initializes the necessary editor listeners and handlers
*/
private:
void InitListenersAndHandlers();
protected:
SmartPointer<PartPane> CreatePane();
/**
* This method is called when there should be a change in the editor pin
* status (added or removed) so that it will ask its presentable part
* to fire a PROP_TITLE event in order for the presentation to request
* the new icon for this editor
*/
public:
void PinStatusUpdated();
public:
std::string GetFactoryId();
protected:
std::string ComputePartName();
public:
std::string GetName();
public:
IEditorPart::Pointer GetEditor(bool restore);
public:
void SetName(const std::string& name);
public:
IMemento::Pointer GetMemento();
public:
SmartPointer<IWorkbenchPage> GetPage() const;
public:
IEditorInput::Pointer GetEditorInput();
private:
IEditorInput::Pointer GetRestoredInput();
/* (non-Javadoc)
* @see org.blueberry.ui.IWorkbenchPartReference#getTitleImage()
* This method will append a pin to the icon of the editor
* if the "automatically close editors" option in the
* preferences is enabled and the editor has been pinned.
*/
//public: ImageDescriptor computeImageDescriptor() {
// ImageDescriptor descriptor = super.computeImageDescriptor();
// if (!isPinned()) {
// return descriptor;
// }
//
// // Check if the pinned preference is set
// IPreferenceStore prefStore = WorkbenchPlugin.getDefault()
// .getPreferenceStore();
// boolean bUsePin = prefStore
// .getBoolean(IPreferenceConstants.REUSE_EDITORS_BOOLEAN)
// || ((TabBehaviour)Tweaklets.get(TabBehaviour.KEY)).alwaysShowPinAction();
//
// if (!bUsePin) {
// return descriptor;
// }
//
// ImageDescriptor pinDesc = this.manager.getEditorPinImageDesc();
// if (pinDesc == null) {
// return descriptor;
// }
//
// return new OverlayIcon(descriptor, pinDesc, new Point(16, 16));
// }
protected:
/**
* Wrapper for restoring the editor. First, this delegates to busyRestoreEditorHelper
* to do the real work of restoring the view. If unable to restore the editor, this
* method tries to substitute an error part and return success.
*
* @return the created part
*/
IWorkbenchPart::Pointer CreatePart();
void PropertyChanged(Object::Pointer source, int propId);
/**
* Attempts to set the input of the editor to the given input. Note that the input
* can't always be changed for an editor. Editors that don't implement IReusableEditor
* can't have their input changed once they've been materialized.
*
* @since 3.1
*
* @param input new input
* @return true iff the input was actually changed
*/
public:
bool SetInput(IEditorInput::Pointer input);
/**
* Reports a recoverable malfunction in the system log. A recoverable malfunction would be
* something like failure to fire an expected property change. Only the first malfunction is
* recorded to avoid spamming the system log with repeated failures in the same editor.
*
* @since 3.1
*
* @param string
*/
private:
void ReportMalfunction(const std::string& string);
private:
IEditorPart::Pointer CreatePartHelper();
/**
* Creates and returns an empty editor (<code>ErrorEditorPart</code>).
*
* @param descr the editor descriptor
* @return the empty editor part or <code>null</code> in case of an exception
*/
public:
IEditorPart::Pointer GetEmptyEditor(SmartPointer<EditorDescriptor> descr);
};
} // namespace berry
#endif /*BERRYEDITORREFERENCE_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorRegistry.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorRegistry.cpp
index ba5c6b52fb..5614dab4ab 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorRegistry.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorRegistry.cpp
@@ -1,1312 +1,1312 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 <berryIExtensionPointService.h>
#include "berryEditorRegistry.h"
#include "berryWorkbenchPlugin.h"
#include "berryEditorRegistryReader.h"
#include "berryWorkbenchRegistryConstants.h"
#include <Poco/String.h>
namespace berry
{
const std::string EditorRegistry::EMPTY_EDITOR_ID =
"org.blueberry.ui.internal.emptyEditorTab"; //$NON-NLS-1$
std::map<std::string, FileEditorMapping::Pointer>
EditorRegistry::EditorMap::defaultMap;
std::map<std::string, FileEditorMapping::Pointer> EditorRegistry::EditorMap::map;
EditorRegistry::RelatedRegistry::RelatedRegistry(EditorRegistry* reg) :
editorRegistry(reg)
{
}
std::list<IEditorDescriptor::Pointer> EditorRegistry::RelatedRegistry::GetRelatedObjects(
const std::string& fileName)
{
IFileEditorMapping::Pointer mapping = editorRegistry->GetMappingFor(fileName);
if (mapping.IsNull())
{
return std::list<IEditorDescriptor::Pointer>();
}
return mapping->GetEditors();
}
EditorRegistry::EditorRegistry() :
relatedRegistry(this)
{
this->InitialIdToEditorMap(mapIDtoEditor);
this->InitializeFromStorage();
//IExtensionTracker tracker = PlatformUI.getWorkbench().getExtensionTracker();
//tracker.registerHandler(this,
// ExtensionTracker.createExtensionPointFilter(getExtensionPointFilter()));
}
void EditorRegistry::AddEditorFromPlugin(EditorDescriptor::Pointer editor,
const std::vector<std::string>& extensions,
const std::vector<std::string>& filenames,
const std::vector<std::string>& /*contentTypeVector*/, bool bDefault)
{
//PlatformUI.getWorkbench().getExtensionTracker().registerObject(editor.getConfigurationElement().getDeclaringExtension(), editor, IExtensionTracker.REF_WEAK);
// record it in our quick reference list
sortedEditorsFromPlugins.push_back(editor);
// add it to the table of mappings
for (std::vector<std::string>::const_iterator itr = extensions.begin(); itr
!= extensions.end(); ++itr)
{
std::string fileExtension = *itr;
if (!fileExtension.empty())
{
FileEditorMapping::Pointer mapping = this->GetMappingFor("*."
+ fileExtension); //$NON-NLS-1$
if (mapping.IsNull())
{ // no mapping for that extension
mapping = new FileEditorMapping(fileExtension);
typeEditorMappings.PutDefault(this->MappingKeyFor(mapping), mapping);
}
mapping->AddEditor(editor);
if (bDefault)
{
mapping->SetDefaultEditor(editor);
}
}
}
// add it to the table of mappings
for (std::vector<std::string>::const_iterator itr = filenames.begin(); itr
!= filenames.end(); ++itr)
{
std::string filename = *itr;
if (!filename.empty())
{
FileEditorMapping::Pointer mapping = this->GetMappingFor(filename);
if (mapping.IsNull())
{ // no mapping for that extension
std::string name;
std::string extension;
std::string::size_type index = filename.find_first_of('.');
if (index == std::string::npos)
{
name = filename;
extension = ""; //$NON-NLS-1$
}
else
{
name = filename.substr(0, index);
extension = filename.substr(index + 1);
}
mapping = new FileEditorMapping(name, extension);
typeEditorMappings.PutDefault(this->MappingKeyFor(mapping), mapping);
}
mapping->AddEditor(editor);
if (bDefault)
{
mapping->SetDefaultEditor(editor);
}
}
}
// for (std::vector<std::string>::const_iterator itr = contentTypeVector.begin();
// itr != contentTypeVector.end(); ++itr)
// {
// std::string contentTypeId = *itr;
// if (!contentTypeId.empty())
// {
// IContentType contentType = Platform.getContentTypeManager().getContentType(contentTypeId);
// if (contentType != null)
// {
// IEditorDescriptor [] editorArray = (IEditorDescriptor[]) contentTypeToEditorMappings.get(contentType);
// if (editorArray == null)
// {
// editorArray = new IEditorDescriptor[]
// { editor};
// contentTypeToEditorMappings.put(contentType, editorArray);
// }
// else
// {
// IEditorDescriptor [] newArray = new IEditorDescriptor[editorArray.length + 1];
// if (bDefault)
// { // default editors go to the front of the line
// newArray[0] = editor;
// System.arraycopy(editorArray, 0, newArray, 1, editorArray.length);
// }
// else
// {
// newArray[editorArray.length] = editor;
// System.arraycopy(editorArray, 0, newArray, 0, editorArray.length);
// }
// contentTypeToEditorMappings.put(contentType, newArray);
// }
// }
// }
// }
// Update editor map.
mapIDtoEditor[editor->GetId()] = editor;
}
void EditorRegistry::AddExternalEditorsToEditorMap()
{
// Add registered editors (may include external editors).
std::vector<FileEditorMapping::Pointer> maps =
typeEditorMappings.AllMappings();
for (unsigned int i = 0; i < maps.size(); ++i)
{
FileEditorMapping::Pointer map = maps[i];
std::list<IEditorDescriptor::Pointer> descArray = map->GetEditors();
for (std::list<IEditorDescriptor::Pointer>::iterator itr =
descArray.begin(); itr != descArray.end(); ++itr)
{
mapIDtoEditor[(*itr)->GetId()] = itr->Cast<EditorDescriptor> ();
}
}
}
IEditorDescriptor::Pointer EditorRegistry::FindEditor(const std::string& id)
{
return mapIDtoEditor[id];
}
IEditorDescriptor::Pointer EditorRegistry::GetDefaultEditor()
{
// the default editor will always be the system external editor
// this should never return null
return this->FindEditor(IEditorRegistry::SYSTEM_EXTERNAL_EDITOR_ID);
}
IEditorDescriptor::Pointer EditorRegistry::GetDefaultEditor(
const std::string& fileName)
{
//return this->GetDefaultEditor(filename, guessAtContentType(filename));
return this->GetEditorForContentType(fileName /*, contentType*/);
}
IEditorDescriptor::Pointer EditorRegistry::GetEditorForContentType(
const std::string& filename
/*IContentType contentType*/)
{
IEditorDescriptor::Pointer desc;
;
std::list<IEditorDescriptor::Pointer> contentTypeResults =
this->FindRelatedObjects(/*contentType,*/filename, relatedRegistry);
if (contentTypeResults.size() > 0)
{
desc = contentTypeResults.front();
}
return desc;
}
std::list<IEditorDescriptor::Pointer> EditorRegistry::FindRelatedObjects(
/*IContentType type,*/const std::string& fileName,
RelatedRegistry& /*registry*/)
{
std::list<IEditorDescriptor::Pointer> allRelated;
std::list<IEditorDescriptor::Pointer> nonDefaultFileEditors;
std::list<IEditorDescriptor::Pointer> related;
if (!fileName.empty())
{
FileEditorMapping::Pointer mapping = this->GetMappingFor(fileName);
if (!mapping.IsNull())
{
// backwards compatibility - add editors flagged as "default"
related = mapping->GetDeclaredDefaultEditors();
for (std::list<IEditorDescriptor::Pointer>::iterator itr =
related.begin(); itr != related.end(); ++itr)
{
// we don't want to return duplicates
if (std::find(allRelated.begin(), allRelated.end(), *itr)
== allRelated.end())
{
allRelated.push_back(*itr);
}
}
// add all filename editors to the nonDefaultList
// we'll later try to add them all after content types are resolved
// duplicates (ie: default editors) will be ignored
std::list<IEditorDescriptor::Pointer> tmpList = mapping->GetEditors();
nonDefaultFileEditors.splice(nonDefaultFileEditors.end(), tmpList);
}
std::string::size_type index = fileName.find_last_of('.');
if (index != std::string::npos)
{
std::string extension = "*" + fileName.substr(index); //$NON-NLS-1$
mapping = this->GetMappingFor(extension);
if (!mapping.IsNull())
{
related = mapping->GetDeclaredDefaultEditors();
for (std::list<IEditorDescriptor::Pointer>::iterator itr =
related.begin(); itr != related.end(); ++itr)
{
// we don't want to return duplicates
if (std::find(allRelated.begin(), allRelated.end(), *itr)
== allRelated.end())
{
allRelated.push_back(*itr);
}
}
std::list<IEditorDescriptor::Pointer> tmpList = mapping->GetEditors();
nonDefaultFileEditors.splice(nonDefaultFileEditors.end(), tmpList);
}
}
}
// if (type != null) {
// // now add any objects directly related to the content type
// related = registry.getRelatedObjects(type);
// for (int i = 0; i < related.length; i++) {
// // we don't want to return duplicates
// if (!allRelated.contains(related[i])) {
// // if it's not filtered, add it to the list
// if (!WorkbenchActivityHelper.filterItem(related[i])) {
// allRelated.add(related[i]);
// }
// }
// }
//
// }
// if (type != null) {
// // now add any indirectly related objects, walking up the content type hierarchy
// while ((type = type.getBaseType()) != null) {
// related = registry.getRelatedObjects(type);
// for (int i = 0; i < related.length; i++) {
// // we don't want to return duplicates
// if (!allRelated.contains(related[i])) {
// // if it's not filtered, add it to the list
// if (!WorkbenchActivityHelper.filterItem(related[i])) {
// allRelated.add(related[i]);
// }
// }
// }
// }
// }
// add all non-default editors to the list
for (std::list<IEditorDescriptor::Pointer>::iterator i =
nonDefaultFileEditors.begin(); i != nonDefaultFileEditors.end(); ++i)
{
IEditorDescriptor::Pointer editor = *i;
if (std::find(allRelated.begin(), allRelated.end(), editor)
== allRelated.end())
{
allRelated.push_back(editor);
}
}
return allRelated;
}
std::list<IEditorDescriptor::Pointer> EditorRegistry::GetEditors(
const std::string& filename)
{
//return getEditors(filename, guessAtContentType(filename));
return this->FindRelatedObjects(/*contentType,*/filename, relatedRegistry);
}
std::vector<IFileEditorMapping::Pointer> EditorRegistry::GetFileEditorMappings()
{
std::vector<FileEditorMapping::Pointer>
array(typeEditorMappings.AllMappings());
std::sort(array.begin(), array.end(), CmpFileEditorMapping());
std::vector<IFileEditorMapping::Pointer> result;
for (std::vector<FileEditorMapping::Pointer>::iterator itr = array.begin(); itr
!= array.end(); ++itr)
{
result.push_back(itr->Cast<IFileEditorMapping> ());
}
return result;
}
FileEditorMapping::Pointer EditorRegistry::GetMappingFor(const std::string& ext)
{
std::string key = this->MappingKeyFor(ext);
return typeEditorMappings.Get(key);
}
std::vector<FileEditorMapping::Pointer> EditorRegistry::GetMappingForFilename(
const std::string& filename)
{
std::vector<FileEditorMapping::Pointer> mapping;
// Lookup on entire filename
mapping[0] = this->GetMappingFor(filename);
// Lookup on filename's extension
std::string::size_type index = filename.find_last_of('.');
if (index != std::string::npos)
{
std::string extension = filename.substr(index);
mapping[1] = this->GetMappingFor("*" + extension); //$NON-NLS-1$
}
return mapping;
}
// std::vector<IEditorDescriptor::Pointer> EditorRegistry::GetSortedEditorsFromOS()
// {
// List externalEditors = new ArrayList();
// Program[] programs = Program.getPrograms();
//
// for (int i = 0; i < programs.length; i++)
// {
// //1FPLRL2: ITPUI:WINNT - NOTEPAD editor cannot be launched
// //Some entries start with %SystemRoot%
// //For such cases just use the file name as they are generally
// //in directories which are on the path
// /*
// * if (fileName.charAt(0) == '%') { fileName = name + ".exe"; }
// */
//
// EditorDescriptor editor = new EditorDescriptor();
// editor.setOpenMode(EditorDescriptor.OPEN_EXTERNAL);
// editor.setProgram(programs[i]);
//
// // determine the program icon this editor would need (do not let it
// // be cached in the workbench registry)
// ImageDescriptor desc = new ExternalProgramImageDescriptor(
// programs[i]);
// editor.setImageDescriptor(desc);
// externalEditors.add(editor);
// }
//
// Object[] tempArray = sortEditors(externalEditors);
// IEditorDescriptor[] array = new IEditorDescriptor[externalEditors
// .size()];
// for (int i = 0; i < tempArray.length; i++)
// {
// array[i] = (IEditorDescriptor) tempArray[i];
// }
// return array;
// }
std::list<IEditorDescriptor::Pointer> EditorRegistry::GetSortedEditorsFromPlugins()
{
std::list<IEditorDescriptor::Pointer> result;
for (std::list<EditorDescriptor::Pointer>::iterator itr =
sortedEditorsFromPlugins.begin(); itr != sortedEditorsFromPlugins.end(); ++itr)
{
result.push_back((*itr).Cast<IEditorDescriptor> ());
}
return result;
}
void EditorRegistry::InitialIdToEditorMap(
std::map<std::string, EditorDescriptor::Pointer>& map)
{
this->AddSystemEditors(map);
}
void EditorRegistry::AddSystemEditors(
std::map<std::string, EditorDescriptor::Pointer>& map)
{
// there will always be a system external editor descriptor
EditorDescriptor::Pointer editor(new EditorDescriptor());
editor->SetID(IEditorRegistry::SYSTEM_EXTERNAL_EDITOR_ID);
editor->SetName("System Editor");
editor->SetOpenMode(EditorDescriptor::OPEN_EXTERNAL);
// @issue we need a real icon for this editor?
map[IEditorRegistry::SYSTEM_EXTERNAL_EDITOR_ID] = editor;
// there may be a system in-place editor if supported by platform
// if (ComponentSupport.inPlaceEditorSupported())
// {
// editor = new EditorDescriptor();
// editor.setID(IEditorRegistry.SYSTEM_INPLACE_EDITOR_ID);
// editor.setName(WorkbenchMessages.SystemInPlaceDescription_name);
// editor.setOpenMode(EditorDescriptor.OPEN_INPLACE);
// // @issue we need a real icon for this editor?
// map.put(IEditorRegistry.SYSTEM_INPLACE_EDITOR_ID, editor);
// }
EditorDescriptor::Pointer emptyEditorDescriptor(new EditorDescriptor());
emptyEditorDescriptor->SetID(EMPTY_EDITOR_ID);
emptyEditorDescriptor->SetName("(Empty)"); //$NON-NLS-1$
//emptyEditorDescriptor.setImageDescriptor(WorkbenchImages
//.getImageDescriptor(IWorkbenchGraphicConstants.IMG_OBJ_ELEMENT));
map[EMPTY_EDITOR_ID] = emptyEditorDescriptor;
}
void EditorRegistry::InitializeFromStorage()
{
//Get editors from the registry
EditorRegistryReader registryReader;
registryReader.AddEditors(this);
this->SortInternalEditors();
this->RebuildInternalEditorMap();
// IPreferenceStore store = PlatformUI.getPreferenceStore();
// String defaultEditors = store
// .getString(IPreferenceConstants.DEFAULT_EDITORS);
// String chachedDefaultEditors = store
// .getString(IPreferenceConstants.DEFAULT_EDITORS_CACHE);
//If defaults has changed load it afterwards so it overrides the users
// associations.
//if (defaultEditors == null
// || defaultEditors.equals(chachedDefaultEditors))
//{
this->SetProductDefaults("");//defaultEditors);
this->LoadAssociations(); //get saved earlier state
// }
// else
// {
// loadAssociations(); //get saved earlier state
// setProductDefaults(defaultEditors);
// store.putValue(IPreferenceConstants.DEFAULT_EDITORS_CACHE,
// defaultEditors);
// }
this->AddExternalEditorsToEditorMap();
}
void EditorRegistry::SetProductDefaults(const std::string& defaultEditors)
{
if (defaultEditors.empty())
{
return;
}
// Poco::StringTokenizer extEditors(defaultEditors,
// IPreferenceConstants::SEPARATOR, Poco::StringTokenizer::TOK_TRIM | Poco::StringTokenizer::TOK_IGNORE_EMPTY);
// while (extEditors.hasMoreTokens())
// {
// String extEditor = extEditors.nextToken().trim();
// int index = extEditor.indexOf(':');
// if (extEditor.length() < 3 || index <= 0 || index
// >= (extEditor.length() - 1))
// {
// //Extension and id must have at least one char.
// WorkbenchPlugin
// .log("Error setting default editor. Could not parse '" + extEditor
// + "'. Default editors should be specified as '*.ext1:editorId1;*.ext2:editorId2'"); //$NON-NLS-1$ //$NON-NLS-2$
// return;
// }
// String ext = extEditor.substring(0, index).trim();
// String editorId = extEditor.substring(index + 1).trim();
// FileEditorMapping mapping = getMappingFor(ext);
// if (mapping == null)
// {
// WorkbenchPlugin
// .log("Error setting default editor. Could not find mapping for '"
// + ext + "'."); //$NON-NLS-1$ //$NON-NLS-2$
// continue;
// }
// EditorDescriptor editor = (EditorDescriptor) findEditor(editorId);
// if (editor == null)
// {
// WorkbenchPlugin
// .log("Error setting default editor. Could not find editor: '"
// + editorId + "'."); //$NON-NLS-1$ //$NON-NLS-2$
// continue;
// }
// mapping.setDefaultEditor(editor);
// }
}
bool EditorRegistry::ReadEditors(
std::map<std::string, EditorDescriptor::Pointer>& /*editorTable*/)
{
//Get the workbench plugin's working directory
Poco::Path workbenchStatePath;
if (!WorkbenchPlugin::GetDefault()->GetDataPath(workbenchStatePath))
{
return false;
}
// IPreferenceStore store = WorkbenchPlugin.getDefault()
// .getPreferenceStore();
// Reader reader = null;
// try
// {
// // Get the editors defined in the preferences store
// String xmlString = store.getString(IPreferenceConstants.EDITORS);
// if (xmlString == null || xmlString.length() == 0)
// {
// FileInputStream stream = new FileInputStream(workbenchStatePath
// .append(IWorkbenchConstants.EDITOR_FILE_NAME)
// .toOSString());
// reader = new BufferedReader(new InputStreamReader(stream,
// "utf-8")); //$NON-NLS-1$
// }
// else
// {
// reader = new StringReader(xmlString);
// }
// XMLMemento memento = XMLMemento.createReadRoot(reader);
// EditorDescriptor editor;
// IMemento[] edMementos = memento
// .getChildren(IWorkbenchConstants.TAG_DESCRIPTOR);
// // Get the editors and validate each one
// for (int i = 0; i < edMementos.length; i++)
// {
// editor = new EditorDescriptor();
// boolean valid = editor.loadValues(edMementos[i]);
// if (!valid)
// {
// continue;
// }
// if (editor.getPluginID() != null)
// {
// //If the editor is from a plugin we use its ID to look it
// // up in the mapping of editors we
// //have obtained from plugins. This allows us to verify that
// // the editor is still valid
// //and allows us to get the editor description from the
// // mapping table which has
// //a valid config element field.
// EditorDescriptor validEditorDescritor = (EditorDescriptor) mapIDtoEditor
// .get(editor.getId());
// if (validEditorDescritor != null)
// {
// editorTable.put(validEditorDescritor.getId(),
// validEditorDescritor);
// }
// }
// else
// { //This is either from a program or a user defined
// // editor
// ImageDescriptor descriptor;
// if (editor.getProgram() == null)
// {
// descriptor = new ProgramImageDescriptor(editor
// .getFileName(), 0);
// }
// else
// {
// descriptor = new ExternalProgramImageDescriptor(editor
// .getProgram());
// }
// editor.setImageDescriptor(descriptor);
// editorTable.put(editor.getId(), editor);
// }
// }
// }
// catch (IOException e)
// {
// try
// {
// if (reader != null)
// {
// reader.close();
// }
// }
// catch (IOException ex)
// {
// e.printStackTrace();
// }
// //Ignore this as the workbench may not yet have saved any state
// return false;
// }
// catch (WorkbenchException e)
// {
// ErrorDialog.openError((Shell) null, WorkbenchMessages.EditorRegistry_errorTitle,
// WorkbenchMessages.EditorRegistry_errorMessage,
// e.getStatus());
// return false;
// }
return true;
}
void EditorRegistry::ReadResources(
std::map<std::string, EditorDescriptor::Pointer>& /*editorTable*/,
std::ostream& /*reader*/)
{
// XMLMemento memento = XMLMemento.createReadRoot(reader);
// String versionString = memento.getString(IWorkbenchConstants.TAG_VERSION);
// boolean versionIs31 = "3.1".equals(versionString); //$NON-NLS-1$
//
// IMemento[] extMementos = memento
// .getChildren(IWorkbenchConstants.TAG_INFO);
// for (int i = 0; i < extMementos.length; i++)
// {
// String name = extMementos[i]
// .getString(IWorkbenchConstants.TAG_NAME);
// if (name == null)
// {
// name = "*"; //$NON-NLS-1$
// }
// String extension = extMementos[i]
// .getString(IWorkbenchConstants.TAG_EXTENSION);
// IMemento[] idMementos = extMementos[i]
// .getChildren(IWorkbenchConstants.TAG_EDITOR);
// String[] editorIDs = new String[idMementos.length];
// for (int j = 0; j < idMementos.length; j++)
// {
// editorIDs[j] = idMementos[j]
// .getString(IWorkbenchConstants.TAG_ID);
// }
// idMementos = extMementos[i]
// .getChildren(IWorkbenchConstants.TAG_DELETED_EDITOR);
// String[] deletedEditorIDs = new String[idMementos.length];
// for (int j = 0; j < idMementos.length; j++)
// {
// deletedEditorIDs[j] = idMementos[j]
// .getString(IWorkbenchConstants.TAG_ID);
// }
// FileEditorMapping mapping = getMappingFor(name + "." + extension); //$NON-NLS-1$
// if (mapping == null)
// {
// mapping = new FileEditorMapping(name, extension);
// }
// List editors = new ArrayList();
// for (int j = 0; j < editorIDs.length; j++)
// {
// if (editorIDs[j] != null)
// {
// EditorDescriptor editor = (EditorDescriptor) editorTable
// .get(editorIDs[j]);
// if (editor != null)
// {
// editors.add(editor);
// }
// }
// }
// List deletedEditors = new ArrayList();
// for (int j = 0; j < deletedEditorIDs.length; j++)
// {
// if (deletedEditorIDs[j] != null)
// {
// EditorDescriptor editor = (EditorDescriptor) editorTable
// .get(deletedEditorIDs[j]);
// if (editor != null)
// {
// deletedEditors.add(editor);
// }
// }
// }
//
// List defaultEditors = new ArrayList();
//
// if (versionIs31)
// { // parse the new format
// idMementos = extMementos[i]
// .getChildren(IWorkbenchConstants.TAG_DEFAULT_EDITOR);
// String[] defaultEditorIds = new String[idMementos.length];
// for (int j = 0; j < idMementos.length; j++)
// {
// defaultEditorIds[j] = idMementos[j]
// .getString(IWorkbenchConstants.TAG_ID);
// }
// for (int j = 0; j < defaultEditorIds.length; j++)
// {
// if (defaultEditorIds[j] != null)
// {
// EditorDescriptor editor = (EditorDescriptor) editorTable
// .get(defaultEditorIds[j]);
// if (editor != null)
// {
// defaultEditors.add(editor);
// }
// }
// }
// }
// else
// { // guess at pre 3.1 format defaults
// if (!editors.isEmpty())
// {
// EditorDescriptor editor = (EditorDescriptor) editors.get(0);
// if (editor != null)
// {
// defaultEditors.add(editor);
// }
// }
// defaultEditors.addAll(Arrays.asList(mapping.getDeclaredDefaultEditors()));
// }
//
// // Add any new editors that have already been read from the registry
// // which were not deleted.
// IEditorDescriptor[] editorsArray = mapping.getEditors();
// for (int j = 0; j < editorsArray.length; j++)
// {
// if (!contains(editors, editorsArray[j])
// && !deletedEditors.contains(editorsArray[j]))
// {
// editors.add(editorsArray[j]);
// }
// }
// // Map the editor(s) to the file type
// mapping.setEditorsList(editors);
// mapping.setDeletedEditorsList(deletedEditors);
// mapping.setDefaultEditors(defaultEditors);
// typeEditorMappings.put(mappingKeyFor(mapping), mapping);
// }
}
bool EditorRegistry::Contains(
const std::vector<IEditorDescriptor::Pointer>& editorsArray,
IEditorDescriptor::Pointer editorDescriptor)
{
IEditorDescriptor::Pointer currentEditorDescriptor;
for (std::vector<IEditorDescriptor::Pointer>::const_iterator i =
editorsArray.begin(); i != editorsArray.end(); ++i)
{
currentEditorDescriptor = *i;
if (currentEditorDescriptor->GetId() == editorDescriptor->GetId())
{
return true;
}
}
return false;
}
bool EditorRegistry::ReadResources(
std::map<std::string, EditorDescriptor::Pointer>& /*editorTable*/)
{
//Get the workbench plugin's working directory
Poco::Path workbenchStatePath;
// XXX: nobody cares about this return value
if (WorkbenchPlugin::GetDefault()->GetDataPath(workbenchStatePath))
{
return false;
}
// IPreferenceStore store = WorkbenchPlugin.getDefault()
// .getPreferenceStore();
// Reader reader = null;
// try
// {
// // Get the resource types
// String xmlString = store.getString(IPreferenceConstants.RESOURCES);
// if (xmlString == null || xmlString.length() == 0)
// {
// FileInputStream stream = new FileInputStream(workbenchStatePath
// .append(IWorkbenchConstants.RESOURCE_TYPE_FILE_NAME)
// .toOSString());
// reader = new BufferedReader(new InputStreamReader(stream,
// "utf-8")); //$NON-NLS-1$
// }
// else
// {
// reader = new StringReader(xmlString);
// }
// // Read the defined resources into the table
// readResources(editorTable, reader);
// }
// catch (IOException e)
// {
// try
// {
// if (reader != null)
// {
// reader.close();
// }
// }
// catch (IOException ex)
// {
// ex.printStackTrace();
// }
// MessageDialog.openError((Shell) null, WorkbenchMessages.EditorRegistry_errorTitle,
// WorkbenchMessages.EditorRegistry_errorMessage);
// return false;
// }
// catch (WorkbenchException e)
// {
// ErrorDialog.openError((Shell) null, WorkbenchMessages.EditorRegistry_errorTitle,
// WorkbenchMessages.EditorRegistry_errorMessage,
// e.getStatus());
// return false;
// }
return true;
}
bool EditorRegistry::LoadAssociations()
{
std::map<std::string, EditorDescriptor::Pointer> editorTable;
if (!this->ReadEditors(editorTable))
{
return false;
}
return this->ReadResources(editorTable);
}
std::string EditorRegistry::MappingKeyFor(const std::string& type)
{
// keep everyting lower case for case-sensitive platforms
return Poco::toLower(type);
}
std::string EditorRegistry::MappingKeyFor(FileEditorMapping::Pointer mapping)
{
return this->MappingKeyFor(mapping->GetName()
+ (mapping->GetExtension().size() == 0 ? "" : "."
+ mapping->GetExtension())); //$NON-NLS-1$ //$NON-NLS-2$
}
void EditorRegistry::RebuildEditorMap()
{
this->RebuildInternalEditorMap();
this->AddExternalEditorsToEditorMap();
}
void EditorRegistry::RebuildInternalEditorMap()
{
EditorDescriptor::Pointer desc;
// Allocate a new map.
mapIDtoEditor.clear();
this->InitialIdToEditorMap(mapIDtoEditor);
// Add plugin editors.
for (std::list<EditorDescriptor::Pointer>::iterator itr =
sortedEditorsFromPlugins.begin(); itr != sortedEditorsFromPlugins.end(); ++itr)
{
desc = *itr;
mapIDtoEditor[desc->GetId()] = desc;
}
}
void EditorRegistry::SaveAssociations()
{
//Save the resource type descriptions
// List editors = new ArrayList();
// IPreferenceStore store = WorkbenchPlugin.getDefault()
// .getPreferenceStore();
//
// XMLMemento memento = XMLMemento
// .createWriteRoot(IWorkbenchConstants.TAG_EDITORS);
// memento.putString(IWorkbenchConstants.TAG_VERSION, "3.1"); //$NON-NLS-1$
// FileEditorMapping maps[] = typeEditorMappings.userMappings();
// for (int mapsIndex = 0; mapsIndex < maps.length; mapsIndex++)
// {
// FileEditorMapping type = maps[mapsIndex];
// IMemento editorMemento = memento
// .createChild(IWorkbenchConstants.TAG_INFO);
// editorMemento.putString(IWorkbenchConstants.TAG_NAME, type
// .getName());
// editorMemento.putString(IWorkbenchConstants.TAG_EXTENSION, type
// .getExtension());
// IEditorDescriptor[] editorArray = type.getEditors();
// for (int i = 0; i < editorArray.length; i++)
// {
// EditorDescriptor editor = (EditorDescriptor) editorArray[i];
// if (!editors.contains(editor))
// {
// editors.add(editor);
// }
// IMemento idMemento = editorMemento
// .createChild(IWorkbenchConstants.TAG_EDITOR);
// idMemento.putString(IWorkbenchConstants.TAG_ID, editorArray[i]
// .getId());
// }
// editorArray = type.getDeletedEditors();
// for (int i = 0; i < editorArray.length; i++)
// {
// EditorDescriptor editor = (EditorDescriptor) editorArray[i];
// if (!editors.contains(editor))
// {
// editors.add(editor);
// }
// IMemento idMemento = editorMemento
// .createChild(IWorkbenchConstants.TAG_DELETED_EDITOR);
// idMemento.putString(IWorkbenchConstants.TAG_ID, editorArray[i]
// .getId());
// }
// editorArray = type.getDeclaredDefaultEditors();
// for (int i = 0; i < editorArray.length; i++)
// {
// EditorDescriptor editor = (EditorDescriptor) editorArray[i];
// if (!editors.contains(editor))
// {
// editors.add(editor);
// }
// IMemento idMemento = editorMemento
// .createChild(IWorkbenchConstants.TAG_DEFAULT_EDITOR);
// idMemento.putString(IWorkbenchConstants.TAG_ID, editorArray[i]
// .getId());
// }
// }
// Writer writer = null;
// try
// {
// writer = new StringWriter();
// memento.save(writer);
// writer.close();
// store.setValue(IPreferenceConstants.RESOURCES, writer.toString());
// }
// catch (IOException e)
// {
// try
// {
// if (writer != null)
// {
// writer.close();
// }
// }
// catch (IOException ex)
// {
// ex.printStackTrace();
// }
// MessageDialog.openError((Shell) null, "Saving Problems", //$NON-NLS-1$
// "Unable to save resource associations."); //$NON-NLS-1$
// return;
// }
//
// memento = XMLMemento.createWriteRoot(IWorkbenchConstants.TAG_EDITORS);
// Iterator itr = editors.iterator();
// while (itr.hasNext())
// {
// EditorDescriptor editor = (EditorDescriptor) itr.next();
// IMemento editorMemento = memento
// .createChild(IWorkbenchConstants.TAG_DESCRIPTOR);
// editor.saveValues(editorMemento);
// }
// writer = null;
// try
// {
// writer = new StringWriter();
// memento.save(writer);
// writer.close();
// store.setValue(IPreferenceConstants.EDITORS, writer.toString());
// }
// catch (IOException e)
// {
// try
// {
// if (writer != null)
// {
// writer.close();
// }
// }
// catch (IOException ex)
// {
// ex.printStackTrace();
// }
// MessageDialog.openError((Shell) null,
// "Error", "Unable to save resource associations."); //$NON-NLS-1$ //$NON-NLS-2$
// return;
// }
}
void EditorRegistry::SetFileEditorMappings(
const std::vector<FileEditorMapping::Pointer>& newResourceTypes)
{
typeEditorMappings.Clear();
for (unsigned int i = 0; i < newResourceTypes.size(); i++)
{
FileEditorMapping::Pointer mapping = newResourceTypes[i];
typeEditorMappings.Put(this->MappingKeyFor(mapping), mapping);
}
//extensionImages = new HashMap();
this->RebuildEditorMap();
//firePropertyChange(PROP_CONTENTS);
}
void EditorRegistry::SetDefaultEditor(const std::string& fileName,
const std::string& editorId)
{
EditorDescriptor::Pointer desc = this->FindEditor(editorId).Cast<
EditorDescriptor> ();
std::vector<FileEditorMapping::Pointer> mapping = this->GetMappingForFilename(
fileName);
if (!mapping[0].IsNull())
{
mapping[0]->SetDefaultEditor(desc);
}
if (!mapping[1].IsNull())
{
mapping[1]->SetDefaultEditor(desc);
}
}
std::vector<IEditorDescriptor::Pointer> EditorRegistry::SortEditors(
const std::vector<IEditorDescriptor::Pointer>& unsortedList)
{
std::vector<IEditorDescriptor::Pointer> result(unsortedList);
std::sort(result.begin(), result.end(), CmpIEditorDescriptor());
return result;
}
void EditorRegistry::SortInternalEditors()
{
sortedEditorsFromPlugins.sort(CmpEditorDescriptor());
}
void EditorRegistry::EditorMap::PutDefault(const std::string& key,
FileEditorMapping::Pointer value)
{
defaultMap[key] = value;
}
void EditorRegistry::EditorMap::Put(const std::string& key,
FileEditorMapping::Pointer value)
{
std::map<std::string, FileEditorMapping::Pointer>::iterator result =
defaultMap.find(key);
if (result != defaultMap.end())
{
map[key] = value;
}
}
FileEditorMapping::Pointer EditorRegistry::EditorMap::Get(
const std::string& key)
{
std::map<std::string, FileEditorMapping::Pointer>::iterator result =
map.find(key);
if (result == map.end())
{
return defaultMap[key];
}
return result->second;
}
void EditorRegistry::EditorMap::Clear()
{
defaultMap.clear();
map.clear();
}
std::vector<FileEditorMapping::Pointer> EditorRegistry::EditorMap::AllMappings()
{
std::set<FileEditorMapping::Pointer, CmpFileEditorMapping> resultSet;
std::map<std::string, FileEditorMapping::Pointer>::iterator iter;
for (iter = defaultMap.begin(); iter != defaultMap.end(); ++iter)
{
resultSet.insert(iter->second);
}
for (iter = map.begin(); iter != map.end(); ++iter)
{
resultSet.insert(iter->second);
}
return std::vector<FileEditorMapping::Pointer>(resultSet.begin(),
resultSet.end());
}
std::vector<FileEditorMapping::Pointer> EditorRegistry::EditorMap::UserMappings()
{
std::vector<FileEditorMapping::Pointer> result;
for (std::map<std::string, FileEditorMapping::Pointer>::iterator iter =
map.begin(); iter != map.end(); ++iter)
{
result.push_back(iter->second);
}
return result;
}
bool EditorRegistry::IsSystemInPlaceEditorAvailable(const std::string& /*filename*/)
{
//return ComponentSupport.inPlaceEditorAvailable(filename);
return false;
}
bool EditorRegistry::IsSystemExternalEditorAvailable(
const std::string& /*filename*/)
{
// std::string::size_type nDot = filename.find_last_of('.');
// if (nDot != std::string::npos)
// {
// std::string strName = filename.substr(nDot);
// return Program.findProgram(strName) != null;
// }
return false;
}
void EditorRegistry::RemoveEditorFromMapping(
std::map<std::string, FileEditorMapping::Pointer>& map,
IEditorDescriptor::Pointer desc)
{
FileEditorMapping::Pointer mapping;
for (std::map<std::string, FileEditorMapping::Pointer>::iterator iter =
map.begin(); iter != map.end(); ++iter)
{
mapping = iter->second;
std::list<IEditorDescriptor::Pointer> editors(mapping->GetEditors());
std::list<IEditorDescriptor::Pointer>::iterator result = std::find(
editors.begin(), editors.end(), desc);
if (result != editors.end())
{
mapping->RemoveEditor(result->Cast<EditorDescriptor> ());
editors.erase(result);
}
if (editors.empty())
{
map.erase(iter->first);
break;
}
}
}
const IExtensionPoint* EditorRegistry::GetExtensionPointFilter()
{
return Platform::GetExtensionPointService()->GetExtensionPoint(
PlatformUI::PLUGIN_ID + WorkbenchRegistryConstants::PL_EDITOR);
}
std::vector<IFileEditorMapping::Pointer> EditorRegistry::GetUnifiedMappings()
{
std::vector<IFileEditorMapping::Pointer>
standardMappings(
dynamic_cast<EditorRegistry*> (PlatformUI::GetWorkbench() ->GetEditorRegistry())->GetFileEditorMappings());
std::vector<IFileEditorMapping::Pointer> allMappings(standardMappings);
// mock-up content type extensions into IFileEditorMappings
// IContentType [] contentTypes = Platform.getContentTypeManager().getAllContentTypes();
// for (int i = 0; i < contentTypes.length; i++)
// {
// IContentType type = contentTypes[i];
// String [] extensions = type.getFileSpecs(IContentType.FILE_EXTENSION_SPEC);
// for (int j = 0; j < extensions.length; j++)
// {
// String extension = extensions[j];
// boolean found = false;
// for (Iterator k = allMappings.iterator(); k.hasNext();)
// {
// IFileEditorMapping mapping = (IFileEditorMapping) k.next();
// if ("*".equals(mapping.getName())
// && extension.equals(mapping.getExtension()))
// { //$NON-NLS-1$
// found = true;
// break;
// }
// }
// if (!found)
// {
// MockMapping mockMapping = new MockMapping(type, "*", extension); //$NON-NLS-1$
// allMappings.add(mockMapping);
// }
// }
//
// String [] filenames = type.getFileSpecs(IContentType.FILE_NAME_SPEC);
// for (int j = 0; j < filenames.length; j++)
// {
// String wholename = filenames[j];
// int idx = wholename.indexOf('.');
// String name = idx == -1 ? wholename : wholename.substring(0, idx);
// String extension = idx == -1 ? "" : wholename.substring(idx + 1); //$NON-NLS-1$
//
// boolean found = false;
// for (Iterator k = allMappings.iterator(); k.hasNext();)
// {
// IFileEditorMapping mapping = (IFileEditorMapping) k.next();
// if (name.equals(mapping.getName())
// && extension.equals(mapping.getExtension()))
// {
// found = true;
// break;
// }
// }
// if (!found)
// {
// MockMapping mockMapping = new MockMapping(type, name, extension);
// allMappings.add(mockMapping);
// }
// }
// }
return allMappings;
}
MockMapping::MockMapping(/*IContentType type,*/const std::string& name,
const std::string& ext) :
extension(ext), filename(name)
{
//this.contentType = type;
}
IEditorDescriptor::Pointer MockMapping::GetDefaultEditor()
{
// std::vector<IEditorDescriptor::Pointer> candidates = PlatformUI::GetWorkbench()->GetEditorRegistry()
// ->GetEditorsForContentType(contentType);
// if (candidates.empty())
// {
// return IEditorDescriptor::Pointer();
// }
// return candidates[0];
return IEditorDescriptor::Pointer();
}
std::list<IEditorDescriptor::Pointer> MockMapping::GetEditors() const
{
// std::list<IEditorDescriptor::Pointer> editorsForContentType = (dynamic_cast<EditorRegistry*>(PlatformUI
// ::GetWorkbench()->GetEditorRegistry())
// ->GetEditorsForContentType(contentType);
// return editorsForContentType;
return std::list<IEditorDescriptor::Pointer>();
}
std::list<IEditorDescriptor::Pointer> MockMapping::GetDeletedEditors() const
{
return std::list<IEditorDescriptor::Pointer>();
}
std::string MockMapping::GetExtension()
{
return extension;
}
std::string MockMapping::GetLabel()
{
return filename + '.' + extension;
}
std::string MockMapping::GetName()
{
return filename;
}
bool MockMapping::operator==(const Object* obj) const
{
if (const MockMapping* other = dynamic_cast<const MockMapping*>(obj))
{
if (this == other)
{
return true;
}
//MockMapping mapping = (MockMapping) obj;
if (!(this->filename == other->filename))
{
return false;
}
if (!(this->extension == other->extension))
{
return false;
}
if (!(this->GetEditors() == other->GetEditors()))
{
return false;
}
return this->GetDeletedEditors() == other->GetDeletedEditors();
}
return false;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorRegistry.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorRegistry.h
index 1f0d107a51..6c4dc67374 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorRegistry.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorRegistry.h
@@ -1,771 +1,771 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYEDITORREGISTRY_H_
#define BERRYEDITORREGISTRY_H_
#include <berryIExtensionPoint.h>
#include "berryIEditorRegistry.h"
#include "berryIFileEditorMapping.h"
#include "berryEditorDescriptor.h"
#include "berryFileEditorMapping.h"
#include <vector>
#include <list>
#include <map>
#include <iostream>
#include <functional>
#include <algorithm>
namespace berry
{
/**
* \ingroup org_blueberry_ui_internal
*
* Provides access to the collection of defined editors for resource types.
*/
class EditorRegistry : public IEditorRegistry
{
class RelatedRegistry
{
public: RelatedRegistry(EditorRegistry* editorRegistry);
/**
* Return the objects related to the type.
*
* @param type
* @return the objects related to the type
*/
// public: std::vector<IEditorDescriptor::Pointer> GetRelatedObjects(IContentType type) {
// IEditorDescriptor[] relatedObjects = (IEditorDescriptor[]) contentTypeToEditorMappings.get(type);
// if (relatedObjects == null) {
// return EMPTY;
// }
// return (IEditorDescriptor[]) WorkbenchActivityHelper.restrictArray(relatedObjects);
// }
/**
* Return the objects related to the filename
* @param fileName
* @return the objects related to the filename
*/
public:
std::list<IEditorDescriptor::Pointer> GetRelatedObjects(
const std::string& fileName);
private: EditorRegistry* editorRegistry;
};
friend class RelatedRegistry;
/**
* Map of FileEditorMapping (extension to FileEditorMapping) Uses two
* java.util.HashMap: one keeps the default which are set by the plugins and
* the other keeps the changes made by the user through the preference page.
*/
class EditorMap
{
static std::map<std::string, FileEditorMapping::Pointer> defaultMap;
static std::map<std::string, FileEditorMapping::Pointer> map;
public: void Clear();
/**
* Put a default mapping into the editor map.
*
* @param key the key to set
* @param value the value to associate
*/
public: static void PutDefault(const std::string& key, FileEditorMapping::Pointer value);
/**
* Put a mapping into the user editor map.
*
* @param key the key to set
* @param value the value to associate
*/
public: void Put(const std::string& key, FileEditorMapping::Pointer value);
/**
* Return the mapping associated to the key. First searches user
* map, and then falls back to the default map if there is no match. May
* return <code>null</code>
*
* @param key
* the key to search for
* @return the mapping associated to the key or <code>null</code>
*/
public: FileEditorMapping::Pointer Get(const std::string& key);
/**
* Return all mappings. This will return default mappings overlayed with
* user mappings.
*
* @return the mappings
*/
public: std::vector<FileEditorMapping::Pointer> AllMappings();
/**
* Return all user mappings.
*
* @return the mappings
*/
public: std::vector<FileEditorMapping::Pointer> UserMappings();
};
struct CmpFileEditorMapping : public std::binary_function<FileEditorMapping::Pointer,
FileEditorMapping::Pointer,
bool>
{
bool operator()(const FileEditorMapping::Pointer& x, const FileEditorMapping::Pointer& y) const
{
return x->GetLabel() < y->GetLabel();
}
};
struct CmpIEditorDescriptor : public std::binary_function<IEditorDescriptor::Pointer,
IEditorDescriptor::Pointer,
bool>
{
bool operator()(const IEditorDescriptor::Pointer& x, const IEditorDescriptor::Pointer& y) const
{
return x->GetLabel() < y->GetLabel();
}
};
struct CmpEditorDescriptor : public std::binary_function<EditorDescriptor::Pointer,
EditorDescriptor::Pointer,
bool>
{
bool operator()(const EditorDescriptor::Pointer& x, const EditorDescriptor::Pointer& y) const
{
return x->GetLabel() < y->GetLabel();
}
};
//private: Map contentTypeToEditorMappings = new HashMap();
/*
* Cached images - these include images from registered editors (via
* plugins) and others hence this table is not one to one with the mappings
* table. It is in fact a superset of the keys one would find in
* typeEditorMappings
*/
//private: Map extensionImages = new HashMap();
/**
* Vector of EditorDescriptor - all the editors loaded from plugin files.
* The list is kept in order to be able to show in the editor selection
* dialog of the resource associations page. This list is sorted based on the
* human readable label of the editor descriptor.
*
* @see #comparer
*/
private:
std::list<EditorDescriptor::Pointer> sortedEditorsFromPlugins;
// Map of EditorDescriptor - map editor id to editor.
private:
std::map<std::string, EditorDescriptor::Pointer> mapIDtoEditor;
// Map of FileEditorMapping (extension to FileEditorMapping)
private:
EditorMap typeEditorMappings;
/*
* Compares the labels from two IEditorDescriptor objects
*/
//private:
// static final Comparator comparer = new Comparator()
// {
// private Collator collator = Collator.getInstance();
//
// public int compare(Object arg0, Object arg1)
// {
// String s1 = ((IEditorDescriptor) arg0).getLabel();
// String s2 = ((IEditorDescriptor) arg1).getLabel();
// return collator.compare(s1, s2);
// }
// };
private: RelatedRegistry relatedRegistry;
public: static const std::string EMPTY_EDITOR_ID; // = "org.blueberry.ui.internal.emptyEditorTab"; //$NON-NLS-1$
/**
* Return an instance of the receiver. Adds listeners into the extension
* registry for dynamic UI purposes.
*/
public: EditorRegistry();
/**
* Add an editor for the given extensions with the specified (possibly null)
* extended type. The editor is being registered from a plugin
*
* @param editor
* The description of the editor (as obtained from the plugin
* file and built by the registry reader)
* @param extensions
* Collection of file extensions the editor applies to
* @param filenames
* Collection of filenames the editor applies to
* @param contentTypeVector
* @param bDefault
* Indicates whether the editor should be made the default editor
* and hence appear first inside a FileEditorMapping
*
* This method is not API and should not be called outside the workbench
* code.
*/
public: void AddEditorFromPlugin(EditorDescriptor::Pointer editor, const std::vector<std::string>& extensions,
const std::vector<std::string>& filenames,
const std::vector<std::string>& contentTypeVector,
bool bDefault);
/**
* Add external editors to the editor mapping.
*/
private: void AddExternalEditorsToEditorMap();
/*
* (non-Javadoc) Method declared on IEditorRegistry.
*/
//public: void AddPropertyListener(IPropertyListener l) {
// addListenerObject(l);
// }
/*
* (non-Javadoc) Method declared on IEditorRegistry.
*/
public: IEditorDescriptor::Pointer FindEditor(const std::string& id);
/**
* Fires a property changed event to all registered listeners.
*
* @param type the type of event
* @see IEditorRegistry#PROP_CONTENTS
*/
// private: void FirePropertyChange(final int type) {
// Object[] array = getListeners();
// for (int nX = 0; nX < array.length; nX++) {
// final IPropertyListener l = (IPropertyListener) array[nX];
// Platform.run(new SafeRunnable() {
// public: void run() {
// l.propertyChanged(EditorRegistry.this, type);
// }
// });
// }
// }
/*
* (non-Javadoc) Method declared on IEditorRegistry.
*
* @deprecated
*/
public: IEditorDescriptor::Pointer GetDefaultEditor();
/*
* (non-Javadoc) Method declared on IEditorRegistry.
*/
public: IEditorDescriptor::Pointer GetDefaultEditor(const std::string& filename);
/**
* Return the (approximated) content type for a file with the given name.
*
* @param filename the filename
* @return the content type or <code>null</code> if it could not be determined
* @since 3.1
*/
// private: IContentType::Pointer GuessAtContentType(const std::string& filename) {
// return Platform.getContentTypeManager().findContentTypeFor(filename);
// }
/**
* Returns the default file image descriptor.
*
* @return the image descriptor
*/
// private: ImageDescriptor GetDefaultImage() {
// // @issue what should be the default image?
// return WorkbenchImages.getImageDescriptor(ISharedImages.IMG_OBJ_FILE);
// }
/*
* (non-Javadoc) Method declared on IEditorRegistry.
*/
public: std::list<IEditorDescriptor::Pointer> GetEditors(const std::string& filename);
/*
* (non-Javadoc) Method declared on IEditorRegistry.
*/
public: std::vector<IFileEditorMapping::Pointer> GetFileEditorMappings();
/*
* (non-Javadoc) Method declared on IEditorRegistry.
*/
// public: ImageDescriptor GetImageDescriptor(String filename) {
// return getImageDescriptor(filename, guessAtContentType(filename));
// }
/**
* Find the file editor mapping for the file extension. Returns
* <code>null</code> if not found.
*
* @param ext
* the file extension
* @return the mapping, or <code>null</code>
*/
private: FileEditorMapping::Pointer GetMappingFor(const std::string& ext);
/**
* Find the file editor mappings for the given filename.
* <p>
* Return an array of two FileEditorMapping items, where the first mapping
* is for the entire filename, and the second mapping is for the filename's
* extension only. These items can be null if no mapping exist on the
* filename and/or filename's extension.</p>
*
* @param filename the filename
* @return the mappings
*/
private: std::vector<FileEditorMapping::Pointer> GetMappingForFilename(const std::string& filename);
/**
* Return the editor descriptors pulled from the OS.
* <p>
* WARNING! The image described by each editor descriptor is *not* known by
* the workbench's graphic registry. Therefore clients must take care to
* ensure that if they access any of the images held by these editors that
* they also dispose them
* </p>
* @return the editor descriptors
*/
//public: std::vector<IEditorDescriptor::Pointer> GetSortedEditorsFromOS();
/**
* Return the editors loaded from plugins.
*
* @return the sorted array of editors declared in plugins
* @see #comparer
*/
public: std::list<IEditorDescriptor::Pointer> GetSortedEditorsFromPlugins();
/**
* Answer an intial id to editor map. This will create a new map and
* populate it with the default system editors.
*
* @param initialSize
* the initial size of the map
* @return the new map
*/
private: void InitialIdToEditorMap(std::map<std::string, EditorDescriptor::Pointer>& map);
/**
* Add the system editors to the provided map. This will always add an
* editor with an id of {@link #SYSTEM_EXTERNAL_EDITOR_ID} and may also add
* an editor with id of {@link #SYSTEM_INPLACE_EDITOR_ID} if the system
* configuration supports it.
*
* @param map the map to augment
*/
private: void AddSystemEditors(std::map<std::string, EditorDescriptor::Pointer>& map);
/**
* Initialize the registry state from plugin declarations and preference
* overrides.
*/
private: void InitializeFromStorage();
/**
* Set the default editors according to the preference store which can be
* overwritten in the file properties.ini. In the form:
* <p>
* <code>ext1:id1;ext2:id2;...</code>
* </p>
*
* @param defaultEditors the default editors to set
*/
private: void SetProductDefaults(const std::string& defaultEditors);
/**
* Read the editors defined in the preferences store.
*
* @param editorTable
* Editor table to store the editor definitions.
* @return true if the table is built succesfully.
*/
private: bool ReadEditors(std::map<std::string, EditorDescriptor::Pointer>& editorTable);
/**
* Read the file types and associate them to their defined editor(s).
*
* @param editorTable
* The editor table containing the defined editors.
* @param reader
* Reader containing the preferences content for the resources.
*
* @throws WorkbenchException
*/
public: void ReadResources(std::map<std::string, EditorDescriptor::Pointer>& editorTable, std::ostream& reader);
/**
* Determine if the editors list contains the editor descriptor.
*
* @param editorsArray
* The list of editors
* @param editorDescriptor
* The editor descriptor
* @return <code>true</code> if the editors list contains the editor descriptor
*/
private: bool Contains(const std::vector<IEditorDescriptor::Pointer>& editorsArray,
IEditorDescriptor::Pointer editorDescriptor);
/**
* Creates the reader for the resources preferences defined in the
* preference store.
*
* @param editorTable
* The editor table containing the defined editors.
* @return true if the resources are read succesfully.
*/
private: bool ReadResources(std::map<std::string, EditorDescriptor::Pointer>& editorTable);
/**
* Load the serialized resource associations Return true if the operation
* was successful, false otherwise
*/
private: bool LoadAssociations();
/**
* Return a friendly version of the given key suitable for use in the editor
* map.
*/
private: std::string MappingKeyFor(const std::string& type);
/**
* Return a key that combines the file's name and extension of the given
* mapping
*
* @param mapping the mapping to generate a key for
*/
private: std::string MappingKeyFor(FileEditorMapping::Pointer mapping);
/**
* Rebuild the editor map
*/
private: void RebuildEditorMap();
/**
* Rebuild the internal editor mapping.
*/
private: void RebuildInternalEditorMap();
/*
* (non-Javadoc) Method declared on IEditorRegistry.
*/
// public: void RemovePropertyListener(IPropertyListener l) {
// removeListenerObject(l);
// }
/**
* Save the registry to the filesystem by serializing the current resource
* associations.
*/
public: void SaveAssociations();
/**
* Set the collection of FileEditorMappings. The given collection is
* converted into the internal hash table for faster lookup Each mapping
* goes from an extension to the collection of editors that work on it. This
* operation will rebuild the internal editor mappings.
*
* @param newResourceTypes
* te new file editor mappings.
*/
public: void SetFileEditorMappings(const std::vector<FileEditorMapping::Pointer>& newResourceTypes);
/*
* (non-Javadoc) Method declared on IEditorRegistry.
*/
public: void SetDefaultEditor(const std::string& fileName, const std::string& editorId);
/**
* Alphabetically sort the internal editors.
*
* @see #comparer
*/
private: std::vector<IEditorDescriptor::Pointer> SortEditors(const std::vector<IEditorDescriptor::Pointer>& unsortedList);
/**
* Alphabetically sort the internal editors.
*
* @see #comparer
*/
private: void SortInternalEditors();
/*
* (non-Javadoc)
*
* @see org.blueberry.ui.IEditorRegistry#isSystemInPlaceEditorAvailable(String)
*/
public: bool IsSystemInPlaceEditorAvailable(const std::string& filename);
/*
* (non-Javadoc)
*
* @see org.blueberry.ui.IEditorRegistry#isSystemExternalEditorAvailable(String)
*/
public: bool IsSystemExternalEditorAvailable(const std::string& filename);
/*
* (non-Javadoc)
*
* @see org.blueberry.ui.IEditorRegistry#getSystemExternalEditorImageDescriptor(java.lang.String)
*/
// public: ImageDescriptor GetSystemExternalEditorImageDescriptor(
// const std::string& filename) {
// Program externalProgram = null;
// int extensionIndex = filename.lastIndexOf('.');
// if (extensionIndex >= 0) {
// externalProgram = Program.findProgram(filename
// .substring(extensionIndex));
// }
// if (externalProgram == null) {
// return null;
// }
//
// return new ExternalProgramImageDescriptor(externalProgram);
// }
/**
* Removes the entry with the value of the editor descriptor from the given
* map. If the descriptor is the last descriptor in a given
* FileEditorMapping then the mapping is removed from the map.
*
* @param map
* the map to search
* @param desc
* the descriptor value to remove
*/
private: void RemoveEditorFromMapping(std::map<std::string, FileEditorMapping::Pointer>& map, IEditorDescriptor::Pointer desc);
private: const IExtensionPoint* GetExtensionPointFilter();
/* (non-Javadoc)
* @see org.blueberry.ui.IEditorRegistry#getDefaultEditor(java.lang.String, org.blueberry.core.runtime.content.IContentType)
*/
// public: IEditorDescriptor::Pointer GetDefaultEditor(const std::string& fileName, IContentType contentType) {
// return getEditorForContentType(fileName, contentType);
// }
/**
* Return the editor for a file with a given content type.
*
* @param filename the file name
* @param contentType the content type
* @return the editor for a file with a given content type
* @since 3.1
*/
private: IEditorDescriptor::Pointer GetEditorForContentType(const std::string& filename
/*IContentType contentType*/);
/* (non-Javadoc)
* @see org.blueberry.ui.IEditorRegistry#getEditors(java.lang.String, org.blueberry.core.runtime.content.IContentType)
*/
// public: std::vector<IEditorDescriptor::Pointer> GetEditors(const std::string& fileName, IContentType contentType) {
// return findRelatedObjects(contentType, fileName, relatedRegistry);
// }
/* (non-Javadoc)
* @see org.blueberry.ui.IEditorRegistry#getImageDescriptor(java.lang.String, org.blueberry.core.runtime.content.IContentType)
*/
// public: ImageDescriptor GetImageDescriptor(const std::string filename, IContentType contentType) {
// if (filename == null) {
// return getDefaultImage();
// }
//
// if (contentType != null) {
// IEditorDescriptor desc = getEditorForContentType(filename, contentType);
// if (desc != null) {
// ImageDescriptor anImage = (ImageDescriptor) extensionImages.get(desc);
// if (anImage != null) {
// return anImage;
// }
// anImage = desc.getImageDescriptor();
// extensionImages.put(desc, anImage);
// return anImage;
// }
// }
// // Lookup in the cache first...
// String key = mappingKeyFor(filename);
// ImageDescriptor anImage = (ImageDescriptor) extensionImages.get(key);
// if (anImage != null) {
// return anImage;
// }
//
// // See if we have a mapping for the filename or extension
// FileEditorMapping[] mapping = getMappingForFilename(filename);
// for (int i = 0; i < 2; i++) {
// if (mapping[i] != null) {
// // Lookup in the cache first...
// String mappingKey = mappingKeyFor(mapping[i]);
// ImageDescriptor mappingImage = (ImageDescriptor) extensionImages
// .get(key);
// if (mappingImage != null) {
// return mappingImage;
// }
// // Create it and cache it
// IEditorDescriptor editor = mapping[i].getDefaultEditor();
// if (editor != null) {
// mappingImage = editor.getImageDescriptor();
// extensionImages.put(mappingKey, mappingImage);
// return mappingImage;
// }
// }
// }
//
// // Nothing - time to look externally for the icon
// anImage = getSystemExternalEditorImageDescriptor(filename);
// if (anImage == null) {
// anImage = getDefaultImage();
// }
// // for dynamic UI - comment out the next line
// //extensionImages.put(key, anImage);
// return anImage;
//
// }
/**
* Find objects related to the content type.
*
* This method is temporary and exists only to back us off of the
* soon-to-be-removed IContentTypeManager.IRelatedRegistry API.
*
* @param type
* @param fileName
* @param registry
* @return the related objects
*/
private: std::list<IEditorDescriptor::Pointer> FindRelatedObjects(/*IContentType type,*/ const std::string& fileName,
RelatedRegistry& registry);
/**
* Return the editors bound to this content type, either directly or indirectly.
*
* @param type the content type to check
* @return the editors
* @since 3.1
*
* TODO: this should be rolled in with the above findRelatedObjects code
*/
// public: std::vector<IEditorDescriptor> GetEditorsForContentType(IContentType type) {
// ArrayList allRelated = new ArrayList();
// if (type == null) {
// return new IEditorDescriptor [0];
// }
//
// Object [] related = relatedRegistry.getRelatedObjects(type);
// for (int i = 0; i < related.length; i++) {
// // we don't want to return duplicates
// if (!allRelated.contains(related[i])) {
// // if it's not filtered, add it to the list
// if (!WorkbenchActivityHelper.filterItem(related[i])) {
// allRelated.add(related[i]);
// }
//
// }
// }
//
// // now add any indirectly related objects, walking up the content type hierarchy
// while ((type = type.getBaseType()) != null) {
// related = relatedRegistry.getRelatedObjects(type);
// for (int i = 0; i < related.length; i++) {
// // we don't want to return duplicates
// if (!allRelated.contains(related[i])) {
// // if it's not filtered, add it to the list
// if (!WorkbenchActivityHelper.filterItem(related[i])) {
// allRelated.add(related[i]);
// }
// }
// }
// }
//
// return (IEditorDescriptor[]) allRelated.toArray(new IEditorDescriptor[allRelated.size()]);
// }
/**
* Get filemappings for all defined filetypes, including those defined by content type.
*
* @return the filetypes
* @since 3.1
*/
public: std::vector<IFileEditorMapping::Pointer> GetUnifiedMappings();
};
class MockMapping : public IFileEditorMapping
{
//private: IContentType contentType;
private:
std::string extension;
private:
std::string filename;
MockMapping(/*IContentType type,*/const std::string& name,
const std::string& ext);
public:
IEditorDescriptor::Pointer GetDefaultEditor();
public:
std::list<IEditorDescriptor::Pointer> GetEditors() const;
public:
std::list<IEditorDescriptor::Pointer> GetDeletedEditors() const;
public:
std::string GetExtension();
// public: ImageDescriptor GetImageDescriptor() {
// IEditorDescriptor editor = getDefaultEditor();
// if (editor == null) {
// return WorkbenchImages
// .getImageDescriptor(ISharedImages.IMG_OBJ_FILE);
// }
//
// return editor.getImageDescriptor();
// }
public:
std::string GetLabel();
public:
std::string GetName();
/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
public:
bool operator==(const Object* obj) const;
};
}
#endif /*BERRYEDITORREGISTRY_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorRegistryReader.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorRegistryReader.cpp
index 3965bfddc6..d8f47888f0 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorRegistryReader.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorRegistryReader.cpp
@@ -1,126 +1,126 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryEditorRegistryReader.h"
#include "berryEditorRegistry.h"
#include "berryEditorDescriptor.h"
#include "berryWorkbenchRegistryConstants.h"
#include "berryPlatformUI.h"
#include <Poco/String.h>
#include <Poco/StringTokenizer.h>
namespace berry
{
void EditorRegistryReader::AddEditors(EditorRegistry* registry)
{
this->editorRegistry = registry;
this->ReadRegistry(PlatformUI::PLUGIN_ID,
WorkbenchRegistryConstants::PL_EDITOR);
}
bool EditorRegistryReader::ReadElement(IConfigurationElement::Pointer element)
{
if (element->GetName() != WorkbenchRegistryConstants::TAG_EDITOR)
{
return false;
}
std::string id;
if (!element->GetAttribute(WorkbenchRegistryConstants::ATT_ID, id))
{
this->LogMissingAttribute(element, WorkbenchRegistryConstants::ATT_ID);
return true;
}
EditorDescriptor::Pointer editor(new EditorDescriptor(id, element));
std::vector<std::string> extensionsVector;
std::vector<std::string> filenamesVector;
std::vector<std::string> contentTypeVector;
bool defaultEditor = false;
std::string value;
// Get editor name (required field).
if (!element->GetAttribute(WorkbenchRegistryConstants::ATT_NAME, value))
{
this->LogMissingAttribute(element, WorkbenchRegistryConstants::ATT_NAME);
return true;
}
// Get target extensions (optional field)
std::string extensionsString;
if (element->GetAttribute(WorkbenchRegistryConstants::ATT_EXTENSIONS,
extensionsString))
{
Poco::StringTokenizer tokenizer(extensionsString, ",",
Poco::StringTokenizer::TOK_IGNORE_EMPTY
| Poco::StringTokenizer::TOK_TRIM);//$NON-NLS-1$
Poco::StringTokenizer::Iterator token = tokenizer.begin();
while (token != tokenizer.end())
{
extensionsVector.push_back(*token);
++token;
}
}
std::string filenamesString;
if (element->GetAttribute(WorkbenchRegistryConstants::ATT_FILENAMES,
filenamesString))
{
Poco::StringTokenizer tokenizer(filenamesString, ",",
Poco::StringTokenizer::TOK_IGNORE_EMPTY
| Poco::StringTokenizer::TOK_TRIM);//$NON-NLS-1$
Poco::StringTokenizer::Iterator token = tokenizer.begin();
while (token != tokenizer.end())
{
filenamesVector.push_back(*token);
++token;
}
}
IConfigurationElement::vector bindings = element->GetChildren(
WorkbenchRegistryConstants::TAG_CONTENT_TYPE_BINDING);
for (unsigned int i = 0; i < bindings.size(); ++i)
{
std::string contentTypeId;
if (!bindings[i]->GetAttribute(
WorkbenchRegistryConstants::ATT_CONTENT_TYPE_ID, contentTypeId))
{
continue;
}
contentTypeVector.push_back(contentTypeId);
}
// Is this the default editor?
element->GetBoolAttribute(WorkbenchRegistryConstants::ATT_DEFAULT, defaultEditor);
// Add the editor to the manager.
editorRegistry->AddEditorFromPlugin(editor, extensionsVector,
filenamesVector, contentTypeVector, defaultEditor);
return true;
}
void EditorRegistryReader::ReadElement(EditorRegistry* editorRegistry,
IConfigurationElement::Pointer element)
{
this->editorRegistry = editorRegistry;
this->ReadElement(element);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorRegistryReader.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorRegistryReader.h
index 29a629b75c..515e3a4759 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorRegistryReader.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorRegistryReader.h
@@ -1,72 +1,72 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYEDITORREGISTRYREADER_H_
#define BERRYEDITORREGISTRYREADER_H_
#include "berryRegistryReader.h"
namespace berry
{
class EditorRegistry;
/**
* \ingroup org_blueberry_ui_internal
*
* This class is used to read resource editor registry descriptors from
* the platform registry.
*/
class EditorRegistryReader : public RegistryReader
{
private:
EditorRegistry* editorRegistry;
protected:
/**
* Implementation of the abstract method that
* processes one configuration element.
*/
bool ReadElement(IConfigurationElement::Pointer element);
public:
/**
* Get the editors that are defined in the registry
* and add them to the ResourceEditorRegistry
*
* Warning:
* The registry must be passed in because this method is called during the
* process of setting up the registry and at this time it has not been
* safely setup with the plugin.
*/
void AddEditors(EditorRegistry* registry);
/**
* @param editorRegistry
* @param element
*/
void ReadElement(EditorRegistry* editorRegistry,
IConfigurationElement::Pointer element);
};
}
#endif /*BERRYEDITORREGISTRYREADER_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorSashContainer.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorSashContainer.cpp
index 7ac853c1ed..e1fd834cad 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorSashContainer.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorSashContainer.cpp
@@ -1,609 +1,609 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryEditorSashContainer.h"
#include "berryPresentationSerializer.h"
#include "berryWorkbenchConstants.h"
#include "berryWorkbenchPlugin.h"
#include "berryLayoutTree.h"
#include "berryWorkbenchWindowConfigurer.h"
#include "berryWorkbenchWindow.h"
#include "berryQtDnDControlWidget.h"
#include "tweaklets/berryGuiWidgetsTweaklet.h"
#include <Poco/HashMap.h>
#include <sstream>
namespace berry
{
const std::string EditorSashContainer::DEFAULT_WORKBOOK_ID =
"DefaultEditorWorkbook";
void EditorSashContainer::AddChild(const RelationshipInfo& info)
{
PartSashContainer::AddChild(info);
this->UpdateStackButtons();
}
void EditorSashContainer::ChildAdded(LayoutPart::Pointer child)
{
PartSashContainer::ChildAdded(child);
if (child.Cast<PartStack> () != 0)
{
editorWorkbooks.push_back(child.Cast<PartStack> ());
}
}
void EditorSashContainer::ChildRemoved(LayoutPart::Pointer child)
{
PartSashContainer::ChildRemoved(child);
if (child.Cast<PartStack> () != 0)
{
editorWorkbooks.remove(child.Cast<PartStack>());
if (activeEditorWorkbook == child)
{
this->SetActiveWorkbook(PartStack::Pointer(0), false);
}
this->UpdateStackButtons();
}
}
PartStack::Pointer EditorSashContainer::CreateDefaultWorkbook()
{
PartStack::Pointer newWorkbook = this->NewEditorWorkbook();
newWorkbook->SetID(DEFAULT_WORKBOOK_ID);
this->Add(newWorkbook);
return newWorkbook;
}
void EditorSashContainer::AddDropSupport()
{
WorkbenchWindowConfigurer::Pointer winConfigurer = page->GetWorkbenchWindow().Cast<WorkbenchWindow>()->GetWindowConfigurer();
QtDnDControlWidget* dropWidget = static_cast<QtDnDControlWidget*>(GetParent());
dropWidget->SetTransferTypes(winConfigurer->GetTransfers());
dropWidget->AddDropListener(winConfigurer->GetDropTargetListener().GetPointer());
}
PartStack::Pointer EditorSashContainer::NewEditorWorkbook()
{
PartStack::Pointer newWorkbook(new PartStack(page, true, PresentationFactoryUtil::ROLE_EDITOR));
std::stringstream buf;
buf << newWorkbook->GetClassName() << newWorkbook.GetPointer();
newWorkbook->SetID(buf.str());
return newWorkbook;
}
void* EditorSashContainer::CreateParent(void* parentWidget)
{
//return Tweaklets::Get(GuiWidgetsTweaklet::KEY)->CreateComposite(parentWidget);
return new QtDnDControlWidget(static_cast<QWidget*>(parentWidget));
}
void EditorSashContainer::DisposeParent()
{
this->parent = 0;
}
bool EditorSashContainer::IsActiveWorkbook(PartStack::Pointer workbook)
{
return activeEditorWorkbook == workbook;
}
PartStack::Pointer EditorSashContainer::CreateStack()
{
return this->NewEditorWorkbook();
}
void EditorSashContainer::SetVisiblePart(
IStackableContainer::Pointer container, PartPane::Pointer visiblePart)
{
PartStack::Pointer stack = container.Cast<PartStack>();
if (stack == 0) return;
stack->GetContainer().Cast<EditorSashContainer>()->SetActiveWorkbook(stack, true);
stack->SetSelection(visiblePart);
}
StackablePart::Pointer EditorSashContainer::GetVisiblePart(
IStackableContainer::Pointer container)
{
PartStack::Pointer refPart = container.Cast<PartStack>();
return refPart->GetSelection();
}
EditorSashContainer::EditorSashContainer(const std::string& editorId,
WorkbenchPage* page, void* parent)
: PartSashContainer(editorId, page, parent)
{
this->CreateDefaultWorkbook();
}
bool EditorSashContainer::AllowsAdd(LayoutPart::Pointer layoutPart)
{
return LayoutPart::AllowsAdd(layoutPart);
}
void EditorSashContainer::AddEditor(PartPane::Pointer pane,
PartStack::Pointer stack)
{
//EditorStack workbook = getActiveWorkbook();
stack->Add(pane);
}
void EditorSashContainer::UpdateStackButtons()
{
// // This is applicable only when the new
// // min/max behaviour is being used
// Perspective persp = getPage().getActivePerspective();
// if (!Perspective.useNewMinMax(persp))
// return;
//
// // Find the upper Right editor stack
// LayoutPart[] stacks = getChildren();
// EditorStack winner = getUpperRightEditorStack(stacks);
//
// // Now hide the buttons for all but the upper right stack
// for (int i = 0; i < stacks.length; i++)
// {
// if (!(stacks[i] instanceof EditorStack)
// )
// continue;
// ((EditorStack) stacks[i]).showMinMax(stacks[i] == winner);
// }
//
// // Force the stack's presentation state to match its perspective
// persp.refreshEditorAreaVisibility();
}
PartStack::Pointer EditorSashContainer::GetUpperRightEditorStack()
{
return this->GetUpperRightEditorStack(this->GetChildren());
}
PartStack::Pointer EditorSashContainer::GetUpperRightEditorStack(
const ILayoutContainer::ChildrenType& stacks)
{
// Find the upper Right editor stack
PartStack::Pointer winner;
Rectangle winnerRect;
for (ILayoutContainer::ChildrenType::const_iterator iter = stacks.begin();
iter != stacks.end(); ++iter)
{
LayoutPart::Pointer part = *iter;
if (part.Cast<PartStack>() == 0)
continue;
PartStack::Pointer stack = part.Cast<PartStack>();
Rectangle bb = stack->GetBounds();
if (iter == stacks.begin() || bb.y < winnerRect.y || (bb.y == winnerRect.y && bb.x
> winnerRect.x))
{
winner = stack;
winnerRect = bb;
}
}
return winner;
}
PartStack::Pointer EditorSashContainer::GetActiveWorkbook()
{
if (activeEditorWorkbook == 0)
{
if (editorWorkbooks.size() < 1)
{
this->SetActiveWorkbook(this->CreateDefaultWorkbook(), false);
}
else
{
this->SetActiveWorkbook(editorWorkbooks.front(), false);
}
}
return activeEditorWorkbook;
}
std::string EditorSashContainer::GetActiveWorkbookID()
{
return this->GetActiveWorkbook()->GetID();
}
std::list<PartStack::Pointer> EditorSashContainer::GetEditorWorkbooks()
{
return editorWorkbooks;
}
std::size_t EditorSashContainer::GetEditorWorkbookCount()
{
return editorWorkbooks.size();
}
void EditorSashContainer::FindSashes(LayoutPart::Pointer pane,
PartPane::Sashes& sashes)
{
//Find the sashes around the current editor and
//then the sashes around the editor area.
PartSashContainer::FindSashes(pane, sashes);
ILayoutContainer::Pointer container = this->GetContainer();
if (container != 0)
{
container->FindSashes(LayoutPart::Pointer(this), sashes);
}
}
void EditorSashContainer::RemoveAllEditors()
{
PartStack::Pointer currentWorkbook = this->GetActiveWorkbook();
// Iterate over a copy so the original can be modified.
std::list<PartStack::Pointer> workbooks(editorWorkbooks);
for (std::list<PartStack::Pointer>::iterator iter = workbooks.begin();
iter != workbooks.end(); ++iter)
{
PartStack::Pointer workbook = *iter;
std::list<StackablePart::Pointer> children = workbook->GetChildren();
for (std::list<StackablePart::Pointer>::iterator childIter = children.begin();
childIter != children.end(); ++childIter)
{
workbook->Remove(*childIter);
}
if (workbook != currentWorkbook)
{
this->Remove(workbook);
workbook->Dispose();
}
}
}
void EditorSashContainer::RemoveEditor(PartPane::Pointer pane)
{
PartStack::Pointer workbook = pane->GetContainer().Cast<PartStack>();
if (workbook == 0)
{
return;
}
workbook->Remove(pane);
// remove the editor workbook if empty
if (workbook->GetItemCount() < 1 /* && editorWorkbooks.size() > 1*/)
{
// // If the user closes the last editor and the editor area
// // is maximized, restore it
// Perspective persp = getPage().getActivePerspective();
// if (Perspective.useNewMinMax(persp))
// {
// if (persp.getPresentation().getMaximizedStack() instanceof EditorStack)
// persp.getPresentation().getMaximizedStack().
// setState(IStackPresentationSite.STATE_RESTORED);
// }
this->Remove(workbook);
workbook->Dispose();
}
}
bool EditorSashContainer::RestoreState(IMemento::Pointer memento)
{
//TODO EditorSashContainer restore state
// MultiStatus
// result =
// new MultiStatus(PlatformUI.PLUGIN_ID, IStatus.OK, WorkbenchMessages.RootLayoutContainer_problemsRestoringPerspective, 0);
bool result = true;
// Remove the default editor workbook that is
// initialy created with the editor area.
// StartupThreading.runWithoutExceptions(new StartupRunnable()
// {
//
// public void runWithException() throws Throwable
// {
PartStack::Pointer defaultWorkbook;
for (ILayoutContainer::ChildrenType::iterator i = children.begin();
i != children.end(); ++i)
{
LayoutPart::Pointer child = *i;
if (child->GetID() == DEFAULT_WORKBOOK_ID)
{
defaultWorkbook = child.Cast<PartStack>();
if (defaultWorkbook->GetItemCount() > 0)
{
defaultWorkbook = 0;
}
}
}
if (defaultWorkbook)
{
Remove(defaultWorkbook);
}
// }}
// );
// Restore the relationship/layout
std::vector<IMemento::Pointer> infos(memento->GetChildren(WorkbenchConstants::TAG_INFO));
Poco::HashMap<std::string, LayoutPart::Pointer> mapIDtoPart(infos.size());
for (std::size_t i = 0; i < infos.size(); i++)
{
// Get the info details.
IMemento::Pointer childMem = infos[i];
std::string partID; childMem->GetString(WorkbenchConstants::TAG_PART, partID);
std::string relativeID; childMem->GetString(WorkbenchConstants::TAG_RELATIVE, relativeID);
int relationship = 0;
int left = 0, right = 0;
if (!relativeID.empty())
{
childMem->GetInteger(WorkbenchConstants::TAG_RELATIONSHIP, relationship);
childMem->GetInteger(WorkbenchConstants::TAG_RATIO_LEFT, left);
childMem->GetInteger(WorkbenchConstants::TAG_RATIO_RIGHT, right);
}
PartStack::Pointer workbook;
// StartupThreading.runWithoutExceptions(new StartupRunnable()
// {
//
// public void runWithException() throws Throwable
// {
// Create the part.
workbook = NewEditorWorkbook();
workbook->SetID(partID);
// 1FUN70C: ITPUI:WIN - Shouldn't set Container when not active
workbook->SetContainer(ILayoutContainer::Pointer(this));
// }}
// );
IMemento::Pointer workbookMemento = childMem->GetChild(
WorkbenchConstants::TAG_FOLDER);
if (workbookMemento)
{
//result.add(workbook[0].restoreState(workbookMemento));
result &= workbook->RestoreState(workbookMemento);
}
const int myLeft = left, myRight = right, myRelationship = relationship;
// StartupThreading.runWithoutExceptions(new StartupRunnable()
// {
//
// public void runWithException() throws Throwable
// {
// Add the part to the layout
if (relativeID.empty())
{
Add(workbook);
}
else
{
LayoutPart::Pointer refPart = mapIDtoPart[relativeID];
if (refPart)
{
Add(workbook, myRelationship, myLeft, myRight, refPart);
}
else
{
WorkbenchPlugin::Log("Unable to find part for ID: " + relativeID);
}
}
// }}
// );
mapIDtoPart[partID] = workbook;
}
return result;
}
bool EditorSashContainer::SaveState(IMemento::Pointer memento)
{
std::vector<RelationshipInfo> relationships(ComputeRelation());
// MultiStatus
// result =
// new MultiStatus(PlatformUI.PLUGIN_ID, IStatus.OK, WorkbenchMessages.RootLayoutContainer_problemsSavingPerspective, 0);
bool result = true;
for (std::size_t i = 0; i < relationships.size(); i++)
{
// Save the relationship info ..
// private LayoutPart part;
// private int relationship;
// private float ratio;
// private LayoutPart relative;
const RelationshipInfo& info = relationships[i];
IMemento::Pointer childMem = memento->CreateChild(
WorkbenchConstants::TAG_INFO);
childMem->PutString(WorkbenchConstants::TAG_PART, info.part->GetID());
PartStack::Pointer stack = info.part.Cast<PartStack>();
if (stack)
{
IMemento::Pointer folderMem = childMem->CreateChild(
WorkbenchConstants::TAG_FOLDER);
//result.add(stack.saveState(folderMem));
result &= stack->SaveState(folderMem);
}
if (info.relative != 0)
{
childMem->PutString(WorkbenchConstants::TAG_RELATIVE, info.relative->GetID());
childMem->PutInteger(WorkbenchConstants::TAG_RELATIONSHIP, info.relationship);
childMem->PutInteger(WorkbenchConstants::TAG_RATIO_LEFT, info.left);
childMem->PutInteger(WorkbenchConstants::TAG_RATIO_RIGHT, info.right);
}
}
return result;
}
void EditorSashContainer::SetActiveWorkbook(PartStack::Pointer newWorkbook,
bool hasFocus)
{
if (newWorkbook != 0)
{
if (std::find(editorWorkbooks.begin(), editorWorkbooks.end(), newWorkbook) == editorWorkbooks.end())
{
return;
}
}
PartStack::Pointer oldWorkbook = activeEditorWorkbook;
activeEditorWorkbook = newWorkbook;
if (oldWorkbook != 0 && oldWorkbook != newWorkbook)
{
oldWorkbook->SetActive(StackPresentation::AS_INACTIVE);
}
if (newWorkbook != 0)
{
if (hasFocus)
{
newWorkbook->SetActive(StackPresentation::AS_ACTIVE_FOCUS);
}
else
{
newWorkbook->SetActive(StackPresentation::AS_ACTIVE_NOFOCUS);
}
}
this->UpdateTabList();
}
void EditorSashContainer::SetActiveWorkbookFromID(const std::string& id)
{
for (std::list<PartStack::Pointer>::iterator iter = editorWorkbooks.begin();
iter != editorWorkbooks.end(); ++iter)
{
PartStack::Pointer workbook = *iter;
if (workbook->GetID() == id)
{
this->SetActiveWorkbook(workbook, false);
}
}
}
PartStack::Pointer EditorSashContainer::GetWorkbookFromID(const std::string& id)
{
for (std::list<PartStack::Pointer>::iterator iter = editorWorkbooks.begin();
iter != editorWorkbooks.end(); ++iter)
{
PartStack::Pointer workbook = *iter;
if (workbook->GetID() == id)
{
return workbook;
}
}
return PartStack::Pointer(0);
}
void EditorSashContainer::UpdateTabList()
{
void* parent = this->GetParent();
if (parent != 0)
{ // parent may be 0 on startup
PartStack::Pointer wb(this->GetActiveWorkbook());
//TODO EditorSashContainer update tab list
// if (wb == 0)
// {
// parent.setTabList(new Control[0]);
// }
// else
// {
// parent.setTabList(wb.getTabList());
// }
}
}
void EditorSashContainer::CreateControl(void* parent)
{
PartSashContainer::CreateControl(parent);
///let the user drop files/editor input on the editor area
this->AddDropSupport();
}
bool EditorSashContainer::IsCompressible()
{
//Added for bug 19524
return true;
}
bool EditorSashContainer::IsStackType(IStackableContainer::Pointer toTest)
{
if (toTest.Cast<PartStack>() == 0)
return false;
return (toTest.Cast<PartStack> ()->GetAppearance()
== PresentationFactoryUtil::ROLE_EDITOR);
}
bool EditorSashContainer::IsPaneType(StackablePart::Pointer toTest)
{
if (toTest.Cast<PartPane>() == 0)
return false;
return (toTest.Cast<PartPane> ()->GetPartReference().Cast<IEditorReference> ()
!= 0);
}
bool EditorSashContainer::RestorePresentationState(IMemento::Pointer /*areaMem*/)
{
std::list<PartStack::Pointer> workbooks = this->GetEditorWorkbooks();
for (std::list<PartStack::Pointer>::iterator iter = workbooks.begin();
iter != workbooks.end(); ++iter)
{
PartStack::Pointer workbook = *iter;
IMemento::Pointer memento = workbook->GetSavedPresentationState();
if (memento == 0)
{
continue;
}
std::list<IPresentablePart::Pointer> listParts = workbook->GetPresentableParts();
std::vector<IPresentablePart::Pointer> parts(listParts.begin(), listParts.end());
PresentationSerializer serializer(parts);
//StartupThreading.runWithoutExceptions(new StartupRunnable()
// {
// public void runWithException() throws Throwable
// {
workbook->GetPresentation()->RestoreState(&serializer, memento);
// }}
// );
}
//return new Status(IStatus.OK, PlatformUI.PLUGIN_ID, 0, "", 0); //$NON-NLS-1$
return true;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorSashContainer.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorSashContainer.h
index fa8b189655..adffa13e59 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorSashContainer.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorSashContainer.h
@@ -1,253 +1,253 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYEDITORSASHCONTAINER_H_
#define BERRYEDITORSASHCONTAINER_H_
#include "berryPartSashContainer.h"
#include "berryPartStack.h"
#include <list>
namespace berry
{
/**
* Represents the area set aside for editor workbooks.
* This container only accepts editor stacks (PartStack) and PartSash
* as layout parts.
*
* Note no views are allowed within this container.
*/
class EditorSashContainer: public PartSashContainer
{
public:
berryObjectMacro(EditorSashContainer);
private:
std::list<PartStack::Pointer> editorWorkbooks;
PartStack::Pointer activeEditorWorkbook;
// DropTarget dropTarget;
void AddDropSupport();
PartStack::Pointer NewEditorWorkbook();
protected:
/* (non-Javadoc)
* @see org.blueberry.ui.internal.PartSashContainer#addChild(org.blueberry.ui.internal.PartSashContainer.RelationshipInfo)
*/
void AddChild(const RelationshipInfo& info);
/**
* Notification that a child layout part has been
* added to the container. Subclasses may override
* this method to perform any container specific
* work.
*/
void ChildAdded(LayoutPart::Pointer child);
/**
* Notification that a child layout part has been
* removed from the container. Subclasses may override
* this method to perform any container specific
* work.
*/
void ChildRemoved(LayoutPart::Pointer child);
PartStack::Pointer CreateDefaultWorkbook();
/**
* Subclasses override this method to specify
* the composite to use to parent all children
* layout parts it contains.
*/
void* CreateParent(void* parentWidget);
/**
* Subclasses override this method to dispose
* of any swt resources created during createParent.
*/
void DisposeParent();
/**
* Return true is the workbook specified
* is the active one.
*/
bool IsActiveWorkbook(PartStack::Pointer workbook);
//TODO DND
// /* package */DropTarget getDropTarget() {
// return dropTarget;
// }
/* (non-Javadoc)
* @see org.blueberry.ui.internal.PartSashContainer#createStack(org.blueberry.ui.internal.LayoutPart)
*/
PartStack::Pointer CreateStack();
/* (non-Javadoc)
* @see org.blueberry.ui.internal.PartSashContainer#setVisiblePart(org.blueberry.ui.internal.ILayoutContainer, org.blueberry.ui.internal.LayoutPart)
*/
void SetVisiblePart(IStackableContainer::Pointer container,
PartPane::Pointer visiblePart);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.PartSashContainer#getVisiblePart(org.blueberry.ui.internal.ILayoutContainer)
*/
StackablePart::Pointer GetVisiblePart(IStackableContainer::Pointer container);
public:
static const std::string DEFAULT_WORKBOOK_ID;
EditorSashContainer(const std::string& editorId, WorkbenchPage* page,
void* parent);
bool AllowsAdd(LayoutPart::Pointer layoutPart);
/**
* Add an editor to the active workbook.
*/
void AddEditor(PartPane::Pointer pane, PartStack::Pointer stack);
/**
* Hides the min/max buttons for all editor stacks
* -except- for the upper/left one.
*/
void UpdateStackButtons();
/**
* @param stacks
* @return the EditorStack in the upper right position
*/
PartStack::Pointer GetUpperRightEditorStack();
/**
* @param stacks
* @return the EditorStack in the upper right position
*/
PartStack::Pointer GetUpperRightEditorStack(
const ILayoutContainer::ChildrenType& stacks);
/**
* Return the editor workbook which is active.
*/
PartStack::Pointer GetActiveWorkbook();
/**
* Return the editor workbook id which is active.
*/
std::string GetActiveWorkbookID();
/**
* Return the all the editor workbooks.
*/
std::list<PartStack::Pointer> GetEditorWorkbooks();
/**
* Return the all the editor workbooks.
*/
std::size_t GetEditorWorkbookCount();
/**
* Find the sashes around the specified part.
*/
void FindSashes(LayoutPart::Pointer pane, PartPane::Sashes& sashes);
/**
* Remove all the editors
*/
void RemoveAllEditors();
/**
* Remove an editor from its' workbook.
*/
void RemoveEditor(PartPane::Pointer pane);
/**
* @see IPersistablePart
*/
bool RestoreState(IMemento::Pointer memento);
/**
* @see IPersistablePart
*/
bool SaveState(IMemento::Pointer memento);
/**
* Set the editor workbook which is active.
*/
void SetActiveWorkbook(PartStack::Pointer newWorkbook, bool hasFocus);
/**
* Set the editor workbook which is active.
*/
void SetActiveWorkbookFromID(const std::string& id);
PartStack::Pointer GetWorkbookFromID(const std::string& id);
/**
* Updates the editor area's tab list to include the active
* editor and its tab.
*/
void UpdateTabList();
/**
* @see org.blueberry.ui.internal.LayoutPart#createControl(org.blueberry.swt.widgets.Composite)
*/
void CreateControl(void* parent);
/**
* @see org.blueberry.ui.internal.LayoutPart#getImportance()
*/
bool IsCompressible();
/* (non-Javadoc)
* @see org.blueberry.ui.internal.PartSashContainer#isStackType(org.blueberry.ui.internal.LayoutPart)
*/
bool IsStackType(IStackableContainer::Pointer toTest);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.PartSashContainer#isPaneType(org.blueberry.ui.internal.LayoutPart)
*/
bool IsPaneType(StackablePart::Pointer toTest);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.PartSashContainer#pickPartToZoom()
*/
// LayoutPart pickPartToZoom() {
// return getActiveWorkbook();
// }
/**
* Restore the presentation state. Loop over the workbooks, create the appropriate serializer and pass to the presentation.
*
* @param areaMem the memento containing presentation
* @return the restoration status
*/
bool RestorePresentationState(IMemento::Pointer areaMem);
};
}
#endif /* BERRYEDITORSASHCONTAINER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorSite.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorSite.cpp
index 83991aa2b9..6753b40d34 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorSite.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorSite.cpp
@@ -1,63 +1,63 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryEditorSite.h"
#include "berryPartPane.h"
#include <cassert>
namespace berry
{
std::string EditorSite::GetInitialScopeId()
{
return "org.blueberry.ui.textEditorScope"; //$NON-NLS-1$
}
EditorSite::EditorSite(IEditorReference::Pointer ref,
IEditorPart::Pointer editor, WorkbenchPage* page,
EditorDescriptor::Pointer d)
: PartSite(ref, editor, page), desc(d)
{
assert(!desc.IsNull());
if (!desc->GetConfigurationElement().IsNull())
{
this->SetConfigurationElement(desc->GetConfigurationElement());
}
else
{
// system external and in-place editors do not have a corresponding configuration element
this->SetId(desc->GetId());
this->SetRegisteredName(desc->GetLabel());
}
// Initialize the services specific to this editor site.
//initializeDefaultServices();
}
IEditorPart::Pointer EditorSite::GetEditorPart()
{
return this->GetPart().Cast<IEditorPart>();
}
EditorDescriptor::Pointer EditorSite::GetEditorDescriptor()
{
return desc;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorSite.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorSite.h
index 697185475b..f1d496f2f9 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorSite.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorSite.h
@@ -1,154 +1,154 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYEDITORSITE_H_
#define BERRYEDITORSITE_H_
#include "berryPartSite.h"
#include "berryEditorDescriptor.h"
#include "berryIEditorPart.h"
#include "berryWorkbenchPage.h"
#include "berryIEditorSite.h"
#include "berryIEditorReference.h"
namespace berry {
/**
* \ingroup org_blueberry_ui_internal
*
* An editor container manages the services for an editor.
*/
class EditorSite : public PartSite, public IEditorSite {
/* package */ //static final int PROP_REUSE_EDITOR = -0x101;
private:
EditorDescriptor::Pointer desc;
//ListenerList propChangeListeners = new ListenerList(1);
// SubActionBars ab = null;
/**
* Initialize the local services.
*/
// void InitializeDefaultServices() {
// // Register an implementation of the service appropriate for the
// // EditorSite.
// final IDragAndDropService editorDTService = new EditorSiteDragAndDropServiceImpl();
// serviceLocator.registerService(IDragAndDropService.class, editorDTService);
// }
protected:
std::string GetInitialScopeId();
public:
berryObjectMacro(EditorSite)
/**
* Constructs an EditorSite for an editor.
*/
EditorSite(IEditorReference::Pointer ref, IEditorPart::Pointer editor,
WorkbenchPage* page, EditorDescriptor::Pointer desc);
// void SetActionBars(SubActionBars bars) {
// super.setActionBars(bars);
//
// if (bars instanceof IActionBars2) {
// ab = new SubActionBars2((IActionBars2)bars, this);
// } else {
// ab = new SubActionBars(bars, this);
// }
// }
// void ActivateActionBars(bool forceVisibility) {
// if (ab != null) {
// ab.activate(forceVisibility);
// }
// super.activateActionBars(forceVisibility);
// }
// void DeactivateActionBars(bool forceHide) {
// if (ab != null) {
// ab.deactivate(forceHide);
// }
// super.deactivateActionBars(forceHide);
// }
/**
* Returns the editor action bar contributor for this editor.
* <p>
* An action contributor is responsable for the creation of actions.
* By design, this contributor is used for one or more editors of the same type.
* Thus, the contributor returned by this method is not owned completely
* by the editor. It is shared.
* </p>
*
* @return the editor action bar contributor
*/
// IEditorActionBarContributor::Pointer GetActionBarContributor() {
// EditorActionBars bars = (EditorActionBars) getActionBars();
// if (bars != null) {
// return bars.getEditorContributor();
// }
//
// return null;
// }
/**
* Returns the extension editor action bar contributor for this editor.
*/
// IEditorActionBarContributor::Pointer GetExtensionActionBarContributor() {
// EditorActionBars bars = (EditorActionBars) getActionBars();
// if (bars != null) {
// return bars.getExtensionContributor();
// }
//
// return null;
// }
/**
* Returns the editor
*/
IEditorPart::Pointer GetEditorPart();
EditorDescriptor::Pointer GetEditorDescriptor();
// void registerContextMenu(final MenuManager menuManager,
// final ISelectionProvider selectionProvider,
// final boolean includeEditorInput) {
// registerContextMenu(getId(), menuManager, selectionProvider,
// includeEditorInput);
// }
//
// void registerContextMenu(final String menuId,
// final MenuManager menuManager,
// final ISelectionProvider selectionProvider,
// final boolean includeEditorInput) {
// if (menuExtenders == null) {
// menuExtenders = new ArrayList(1);
// }
//
// PartSite.registerContextMenu(menuId, menuManager, selectionProvider,
// includeEditorInput, getPart(), menuExtenders);
// }
};
}
#endif /*BERRYEDITORSITE_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryErrorViewPart.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryErrorViewPart.cpp
index c93ba96927..ed274a2691 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryErrorViewPart.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryErrorViewPart.cpp
@@ -1,50 +1,50 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryErrorViewPart.h"
namespace berry
{
ErrorViewPart::ErrorViewPart()
{
}
ErrorViewPart::ErrorViewPart(const std::string& title, const std::string& error) :
title(title), error(error)
{
}
void ErrorViewPart::CreatePartControl(void* parent)
{
if (!error.empty())
{
statusPart = Tweaklets::Get(WorkbenchPageTweaklet::KEY)->CreateStatusPart(
parent, title, error);
}
}
void ErrorViewPart::SetPartName(const std::string& newName)
{
ViewPart::SetPartName(newName);
}
void ErrorViewPart::SetFocus()
{
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryErrorViewPart.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryErrorViewPart.h
index 43d55f17ea..62edf11733 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryErrorViewPart.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryErrorViewPart.h
@@ -1,82 +1,82 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYERRORVIEWPART_H_
#define BERRYERRORVIEWPART_H_
#include "tweaklets/berryWorkbenchPageTweaklet.h"
#include "berryViewPart.h"
namespace berry {
/**
* This part is shown instead the views with errors.
*
* @since 3.3
*/
class ErrorViewPart : public ViewPart {
public:
berryObjectMacro(ErrorViewPart)
/**
* Creates instance of the class
*/
ErrorViewPart();
/**
* Creates instance of the class
*
* @param error the status
*/
ErrorViewPart(const std::string& title, const std::string& error);
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
void CreatePartControl(void* parent);
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.part.ViewPart#setPartName(java.lang.String)
*/
void SetPartName(const std::string& newName);
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.part.WorkbenchPart#setFocus()
*/
void SetFocus();
private:
//IStatus error;
std::string title;
std::string error;
Object::Pointer statusPart;
};
}
#endif /* BERRYERRORVIEWPART_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryFileEditorMapping.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryFileEditorMapping.cpp
index e895a39f99..809d7c3f75 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryFileEditorMapping.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryFileEditorMapping.cpp
@@ -1,190 +1,190 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryFileEditorMapping.h"
namespace berry
{
const std::string FileEditorMapping::STAR = "*"; //$NON-NLS-1$
const std::string FileEditorMapping::DOT = "."; //$NON-NLS-1$
bool FileEditorMapping::CompareList (
const std::list<IEditorDescriptor::Pointer>& l1,
const std::list<IEditorDescriptor::Pointer>& l2) const
{
if (l1.size() != l2.size())
{
return false;
}
std::list<IEditorDescriptor::Pointer>::const_iterator iter1, iter2;
for (iter1 = l1.begin(), iter2 = l2.begin(); iter1 != l1.end() && iter2 != l2.end();
++iter1, ++iter2)
{
if (!(iter1->IsNull() ? iter2->IsNull() : *iter1 == *iter2))
{
return false;
}
}
return true;
}
FileEditorMapping::FileEditorMapping(const std::string& extension, const std::string& name)
{
if (name.size() < 1)
{
this->SetName(STAR);
}
else
{
this->SetName(name);
}
this->SetExtension(extension);
}
void FileEditorMapping::AddEditor(EditorDescriptor::Pointer editor)
{
editors.push_back(editor);
deletedEditors.remove(editor);
}
bool FileEditorMapping::operator==(const Object* obj) const
{
if (const FileEditorMapping* mapping = dynamic_cast<const FileEditorMapping*>(obj))
{
if (this == obj)
{
return true;
}
if (this->name != mapping->GetName())
{
return false;
}
if (this->extension != mapping->GetExtension())
{
return false;
}
if (!this->CompareList(this->editors, mapping->GetEditors()))
{
return false;
}
return this->CompareList(this->deletedEditors, mapping->deletedEditors);
}
return false;
}
IEditorDescriptor::Pointer FileEditorMapping::GetDefaultEditor()
{
if (editors.size() == 0) // || WorkbenchActivityHelper.restrictUseOf(editors.get(0)))
{
return IEditorDescriptor::Pointer(0);
}
return editors.front();
}
std::list<IEditorDescriptor::Pointer> FileEditorMapping::GetEditors() const
{
return editors;
}
std::list<IEditorDescriptor::Pointer> FileEditorMapping::GetDeletedEditors() const
{
return deletedEditors;
}
std::string FileEditorMapping::GetExtension() const
{
return extension;
}
std::string FileEditorMapping::GetLabel() const
{
return name + (extension.empty() ? "" : DOT + extension); //$NON-NLS-1$
}
std::string FileEditorMapping::GetName() const
{
return name;
}
void FileEditorMapping::RemoveEditor(EditorDescriptor::Pointer editor)
{
editors.remove(editor);
deletedEditors.push_back(editor);
declaredDefaultEditors.remove(editor);
}
void FileEditorMapping::SetDefaultEditor(EditorDescriptor::Pointer editor)
{
editors.remove(editor);
editors.push_front(editor);
declaredDefaultEditors.remove(editor);
declaredDefaultEditors.push_front(editor);
}
void FileEditorMapping::SetEditorsList(const std::list<IEditorDescriptor::Pointer>& newEditors)
{
editors = newEditors;
declaredDefaultEditors = newEditors;
}
void FileEditorMapping::SetDeletedEditorsList(const std::list<IEditorDescriptor::Pointer>& newDeletedEditors)
{
deletedEditors = newDeletedEditors;
}
void FileEditorMapping::SetExtension(const std::string& extension)
{
this->extension = extension;
}
void FileEditorMapping::SetName(const std::string& name)
{
this->name = name;
}
std::list<IEditorDescriptor::Pointer> FileEditorMapping::GetDeclaredDefaultEditors()
{
return declaredDefaultEditors;
}
bool FileEditorMapping::IsDeclaredDefaultEditor(IEditorDescriptor::Pointer editor)
{
for (std::list<IEditorDescriptor::Pointer>::iterator iter = declaredDefaultEditors.begin();
iter != declaredDefaultEditors.end(); ++iter)
{
if (*iter == editor) return true;
}
return false;
}
void FileEditorMapping::SetDefaultEditors(const std::list<IEditorDescriptor::Pointer>& defaultEditors)
{
declaredDefaultEditors = defaultEditors;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryFileEditorMapping.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryFileEditorMapping.h
index 2648f8302a..34ecc13aef 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryFileEditorMapping.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryFileEditorMapping.h
@@ -1,227 +1,227 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYFILEEDITORMAPPING_H_
#define BERRYFILEEDITORMAPPING_H_
#include "berryIFileEditorMapping.h"
#include "berryEditorDescriptor.h"
#include <vector>
#include <list>
namespace berry
{
/**
* \ingroup org_blueberry_ui_internal
*
* Implementation of IFileEditorMapping.
*
*/
class FileEditorMapping : public IFileEditorMapping
{
public:
berryObjectMacro(FileEditorMapping)
private:
static const std::string STAR; // = "*"; //$NON-NLS-1$
static const std::string DOT; // = "."; //$NON-NLS-1$
std::string name;
std::string extension;
// Collection of EditorDescriptor, where the first one
// is considered the default one.
std::list<IEditorDescriptor::Pointer> editors;
std::list<IEditorDescriptor::Pointer> deletedEditors;
std::list<IEditorDescriptor::Pointer> declaredDefaultEditors;
/**
* Compare the editor ids from both lists and return true if they
* are equals.
*/
bool CompareList(const std::list<IEditorDescriptor::Pointer>& l1,
const std::list<IEditorDescriptor::Pointer>& l2) const;
public:
/**
* Create an instance of this class.
*
* @param name java.lang.std::string
* @param extension java.lang.std::string
*/
FileEditorMapping(const std::string& extension, const std::string& name = STAR);
/**
* Add the given editor to the list of editors registered.
*
* @param editor the editor to add
*/
void AddEditor(EditorDescriptor::Pointer editor);
/**
* Clone the receiver.
*/
// Object clone() {
// try {
// FileEditorMapping clone = (FileEditorMapping) super.clone();
// clone.editors = (List) ((ArrayList) editors).clone();
// return clone;
// } catch (CloneNotSupportedException e) {
// return null;
// }
// }
/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
bool operator==(const Object* obj) const;
/* (non-Javadoc)
* Method declared on IFileEditorMapping.
*/
IEditorDescriptor::Pointer GetDefaultEditor();
/* (non-Javadoc)
* Method declared on IFileEditorMapping.
*/
std::list<IEditorDescriptor::Pointer> GetEditors() const;
/* (non-Javadoc)
* Method declared on IFileEditorMapping.
*/
std::list<IEditorDescriptor::Pointer> GetDeletedEditors() const;
/* (non-Javadoc)
* Method declared on IFileEditorMapping.
*/
std::string GetExtension() const;
/* (non-Javadoc)
* Method declared on IFileEditorMapping.
*/
// ImageDescriptor getImageDescriptor() {
// IEditorDescriptor editor = getDefaultEditor();
// if (editor == null) {
// return WorkbenchImages
// .getImageDescriptor(ISharedImages.IMG_OBJ_FILE);
// }
// return editor.getImageDescriptor();
// }
/* (non-Javadoc)
* Method declared on IFileEditorMapping.
*/
std::string GetLabel() const;
/* (non-Javadoc)
* Method declared on IFileEditorMapping.
*/
std::string GetName() const;
/**
* Remove the given editor from the set of editors registered.
*
* @param editor the editor to remove
*/
void RemoveEditor(EditorDescriptor::Pointer editor);
/**
* Set the default editor registered for file type
* described by this mapping.
*
* @param editor the editor to be set as default
*/
void SetDefaultEditor(EditorDescriptor::Pointer editor);
/**
* Set the collection of all editors (EditorDescriptor)
* registered for the file type described by this mapping.
* Typically an editor is registered either through a plugin or explicitly by
* the user modifying the associations in the preference pages.
* This modifies the internal list to share the passed list.
* (hence the clear indication of list in the method name)
*
* @param newEditors the new list of associated editors
*/
void SetEditorsList(const std::list<IEditorDescriptor::Pointer>& newEditors);
/**
* Set the collection of all editors (EditorDescriptor)
* formally registered for the file type described by this mapping
* which have been deleted by the user.
* This modifies the internal list to share the passed list.
* (hence the clear indication of list in the method name)
*
* @param newDeletedEditors the new list of associated (but deleted) editors
*/
void SetDeletedEditorsList(
const std::list<IEditorDescriptor::Pointer>& newDeletedEditors);
/**
* Set the file's extension.
*
* @param extension the file extension for this mapping
*/
void SetExtension(const std::string& extension);
/**
* Set the file's name.
*
* @param name the file name for this mapping
*/
void SetName(const std::string& name);
/**
* Get the editors that have been declared as default. This may be via plugin
* declarations or the preference page.
*
* @return the editors the default editors
* @since 3.1
*/
std::list<IEditorDescriptor::Pointer> GetDeclaredDefaultEditors();
/**
* Return whether the editor is declared default.
* If this is EditorDescriptor fails the ExpressionsCheck it will always
* return <code>false</code>, even if it's the original default editor.
*
* @param editor the editor to test
* @return whether the editor is declared default
* @since 3.1
*/
bool IsDeclaredDefaultEditor(IEditorDescriptor::Pointer editor);
/**
* Set the default editors for this mapping.
*
* @param defaultEditors the editors
* @since 3.1
*/
void SetDefaultEditors(
const std::list<IEditorDescriptor::Pointer>& defaultEditors);
};
}
#endif /*BERRYFILEEDITORMAPPING_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryFolderLayout.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryFolderLayout.cpp
index 1b7fad2591..0511d7ac95 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryFolderLayout.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryFolderLayout.cpp
@@ -1,97 +1,97 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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.
StackablePart::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)
{
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,
StackablePart::Pointer newPart)
{
pageLayout->SetRefPart(viewId, newPart);
pageLayout->SetFolderPart(viewId, folder);
// force creation of the view layout rec
pageLayout->GetViewLayoutRec(viewId, true);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryFolderLayout.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryFolderLayout.h
index f30d8fc858..bd2d64ca06 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryFolderLayout.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryFolderLayout.h
@@ -1,96 +1,96 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYFOLDERLAYOUT_H_
#define BERRYFOLDERLAYOUT_H_
#include "berryIFolderLayout.h"
#include "berryPartStack.h"
#include "berryViewFactory.h"
namespace berry {
class PageLayout;
/**
* \ingroup org_blueberry_ui_internal
*
* This layout is used to define the initial set of views and placeholders
* in a folder.
* <p>
* Views are added to the folder by ID. This id is used to identify
* a view descriptor in the view registry, and this descriptor is used to
* instantiate the <code>IViewPart</code>.
* </p>
*/
class FolderLayout : public IFolderLayout {
public: berryObjectMacro(FolderLayout)
private:
PartStack::Pointer folder;
SmartPointer<PageLayout> pageLayout;
ViewFactory* viewFactory;
public:
/**
* Create an instance of a <code>FolderLayout</code> belonging to a
* <code>PageLayout</code>.
*/
FolderLayout(SmartPointer<PageLayout> pageLayout, PartStack::Pointer folder,
ViewFactory* viewFactory);
/* (non-Javadoc)
* @see org.blueberry.ui.IPlaceholderFolderLayout#addPlaceholder(java.lang.String)
*/
void AddPlaceholder(const std::string& viewId);
/* (non-Javadoc)
* @see org.blueberry.ui.IFolderLayout#addView(java.lang.String)
*/
void AddView(const std::string& viewId);
/* (non-Javadoc)
* @see org.blueberry.ui.IPlaceholderFolderLayout#getProperty(java.lang.String)
*/
std::string GetProperty(const std::string& id);
/* (non-Javadoc)
* @see org.blueberry.ui.IPlaceholderFolderLayout#setProperty(java.lang.String, java.lang.String)
*/
void SetProperty(const std::string& id, const std::string& value);
private:
/**
* Inform the page layout of the new part created
* and the folder the part belongs to.
*/
void LinkPartToPageLayout(const std::string& viewId, StackablePart::Pointer newPart);
};
}
#endif /*BERRYFOLDERLAYOUT_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryIDragOverListener.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryIDragOverListener.cpp
index 2df943a0b6..55fdbb2a2a 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryIDragOverListener.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryIDragOverListener.cpp
@@ -1,41 +1,41 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryIDragOverListener.h"
namespace berry {
void
IDragOverListener::Events
::AddListener(IDragOverListener::Pointer l)
{
if (l.IsNull()) return;
drag += DragDelegate(l.GetPointer(), &IDragOverListener::Drag);
}
void
IDragOverListener::Events
::RemoveListener(IDragOverListener::Pointer l)
{
if (l.IsNull()) return;
drag -= DragDelegate(l.GetPointer(), &IDragOverListener::Drag);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryIDragOverListener.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryIDragOverListener.h
index 3087d2157e..e5c04080c1 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryIDragOverListener.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryIDragOverListener.h
@@ -1,67 +1,67 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIDRAGOVERLISTENER_H_
#define BERRYIDRAGOVERLISTENER_H_
#include <berryMacros.h>
#include <berryMessage.h>
#include "berryPoint.h"
#include "berryRectangle.h"
#include "berryIDropTarget.h"
namespace berry {
/**
* Implementers of this interface will receive notifications when objects are dragged over
* a particular control.
*/
struct IDragOverListener : public virtual Object {
berryObjectMacro(IDragOverListener);
struct Events {
typedef Message4<void*, Object::Pointer, const Point&, const Rectangle&, IDropTarget::Pointer> DragEventType;
typedef MessageDelegate4<IDragOverListener, void*, Object::Pointer, const Point&, const Rectangle&, IDropTarget::Pointer> DragDelegate;
DragEventType drag;
void AddListener(IDragOverListener::Pointer listener);
void RemoveListener(IDragOverListener::Pointer listener);
};
/**
* Notifies the receiver that the given object has been dragged over
* the given position. Returns a drop target if the object may be
* dropped in this position. Returns null otherwise.
*
* @param draggedObject object being dragged over this location
* @param position location of the cursor
* @param dragRectangle current drag rectangle (may be an empty rectangle if none)
* @return a valid drop target or null if none
*/
virtual IDropTarget::Pointer Drag(void* currentControl, Object::Pointer draggedObject,
const Point& position, const Rectangle& dragRectangle) = 0;
};
}
#endif /* BERRYIDRAGOVERLISTENER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryIDropTarget.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryIDropTarget.h
index bceaa315bf..84180940f3 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryIDropTarget.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryIDropTarget.h
@@ -1,71 +1,71 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIDROPTARGET_H_
#define BERRYIDROPTARGET_H_
#include <berryMacros.h>
#include "berryRectangle.h"
#include "tweaklets/berryDnDTweaklet.h"
namespace berry {
/**
* This interface is used to drop objects. It knows how to drop a particular object
* in a particular location. IDropTargets are typically created by IDragOverListeners, and
* it is the job of the IDragOverListener to supply the drop target with information about
* the object currently being dragged.
*
* @see IDragOverListener
*/
struct BERRY_UI IDropTarget : public Object {
berryObjectMacro(IDropTarget);
~IDropTarget();
/**
* Drops the object in this position
*/
virtual void Drop() = 0;
/**
* Returns a cursor id describing this drop operation
*
* @return a cursor id describing this drop operation
*/
virtual DnDTweaklet::CursorType GetCursor() = 0;
/**
* Returns a rectangle (screen coordinates) describing the target location
* for this drop operation.
*
* @return a snap rectangle or null if this drop target does not have a specific snap
* location.
*/
virtual Rectangle GetSnapRectangle() = 0;
/**
* This is called whenever a drag operation is cancelled
*/
virtual void DragFinished(bool dropPerformed) = 0;
};
}
#endif /* BERRYIDROPTARGET_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryIEvaluationResultCache.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryIEvaluationResultCache.h
index da1bfac417..13f59b75bb 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryIEvaluationResultCache.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryIEvaluationResultCache.h
@@ -1,100 +1,100 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIEVALUATIONRESULTCACHE_H_
#define BERRYIEVALUATIONRESULTCACHE_H_
#include <berryObject.h>
#include <berryMacros.h>
#include <org_blueberry_ui_Export.h>
namespace berry {
struct IEvaluationContext;
class Expression;
/**
* <p>
* A cache of the result of an expression. This also provides the source
* priority for the expression.
* </p>
* <p>
* This interface is not intended to be implemented or extended by clients.
* </p>
*
* @since 3.2
* @see org.eclipse.ui.ISources
* @see org.eclipse.ui.ISourceProvider
*/
struct BERRY_UI IEvaluationResultCache : public Object {
berryInterfaceMacro(IEvaluationResultCache, berry)
~IEvaluationResultCache();
/**
* Clears the cached computation of the <code>evaluate</code> method, if
* any. This method is only intended for internal use. It provides a
* mechanism by which <code>ISourceProvider</code> events can invalidate
* state on a <code>IEvaluationResultCache</code> instance.
*/
virtual void ClearResult() = 0;
/**
* Returns the expression controlling the activation or visibility of this
* item.
*
* @return The expression associated with this item; may be
* <code>null</code>.
*/
virtual SmartPointer<Expression> GetExpression() = 0;
/**
* Returns the priority that has been given to this expression.
*
* @return The priority.
* @see ISources
*/
virtual int GetSourcePriority() const = 0;
/**
* Evaluates the expression -- given the current state of the workbench.
* This method should cache its computation. The cache will be cleared by a
* call to <code>clearResult</code>.
*
* @param context
* The context in which this state should be evaluated; must not
* be <code>null</code>.
* @return <code>true</code> if the expression currently evaluates to
* <code>true</code>; <code>false</code> otherwise.
*/
virtual bool Evaluate(SmartPointer<IEvaluationContext> context) = 0;
/**
* Forces the cached result to be a particular value. This will <b>not</b>
* notify any users of the cache that it has changed.
*
* @param result
* The cached result to use.
* @since 3.3
*/
virtual void SetResult(bool result) = 0;
};
}
#endif /* BERRYIEVALUATIONRESULTCACHE_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryILayoutContainer.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryILayoutContainer.h
index d6c2f50f17..4f270c567f 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryILayoutContainer.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryILayoutContainer.h
@@ -1,122 +1,122 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYILAYOUTCONTAINER_H_
#define BERRYILAYOUTCONTAINER_H_
#include "berryLayoutPart.h"
#include "berryPartPane.h"
#include <list>
namespace berry {
/**
* \ingroup org_blueberry_ui_internal
*
*/
struct BERRY_UI ILayoutContainer : virtual public Object {
berryObjectMacro(ILayoutContainer);
~ILayoutContainer();
typedef std::list<LayoutPart::Pointer> ChildrenType;
virtual bool AllowsAdd(LayoutPart::Pointer toAdd) = 0;
/**
* Add a child to the container.
*/
virtual void Add(LayoutPart::Pointer newPart) = 0;
/**
* Returns a list of layout children.
*/
virtual ChildrenType GetChildren() = 0;
/**
* Remove a child from the container.
*/
virtual void Remove(LayoutPart::Pointer part) = 0;
/**
* Replace one child with another
*/
virtual void Replace(LayoutPart::Pointer oldPart, LayoutPart::Pointer newPart) = 0;
virtual void FindSashes(LayoutPart::Pointer toFind, PartPane::Sashes& result) = 0;
/**
* When a layout part closes, focus will return to the previously active part.
* This method determines whether the parts in this container should participate
* in this behavior. If this method returns true, its parts may automatically be
* given focus when another part is closed.
*
* @return true iff the parts in this container may be given focus when the active
* part is closed
*/
virtual bool AllowsAutoFocus() = 0;
/**
* Called by child parts to request a zoom in, given an immediate child
*
* @param toZoom
* @since 3.1
*/
//public void childRequestZoomIn(LayoutPart toZoom);
/**
* Called by child parts to request a zoom out
*
* @since 3.1
*/
//public void childRequestZoomOut();
/**
* Returns true iff the given child is obscured due to the fact that the container is zoomed into
* another part.
*
* @param toTest
* @return
* @since 3.1
*/
//public boolean childObscuredByZoom(LayoutPart toTest);
/**
* Returns true iff we are zoomed into the given part, given an immediate child of this container.
*
* @param toTest
* @return
* @since 3.1
*/
//public boolean childIsZoomed(LayoutPart toTest);
/**
* Called when the preferred size of the given child has changed, requiring a
* layout to be triggered.
*
* @param childThatChanged the child that triggered the new layout
*/
virtual void ResizeChild(LayoutPart::Pointer childThatChanged) = 0;
};
}
#endif /*BERRYILAYOUTCONTAINER_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryIServiceLocatorCreator.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryIServiceLocatorCreator.h
index e8279aac20..3803065bc7 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryIServiceLocatorCreator.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryIServiceLocatorCreator.h
@@ -1,89 +1,89 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYISERVICELOCATORCREATOR_H_
#define BERRYISERVICELOCATORCREATOR_H_
#include <berryObject.h>
#include <berryMacros.h>
#include <org_blueberry_ui_Export.h>
namespace berry {
struct IServiceLocator;
struct IServiceFactory;
struct IDisposable;
/**
* When creating components this service can be used to create the appropriate
* service locator for the new component. For use with the component framework.
* <p>
* <b>Note:</b> Must not be implemented or extended by clients.
* <p>
* <p>
* <strong>PROVISIONAL</strong>. This class or interface has been added as part
* of a work in progress. There is a guarantee neither that this API will work
* nor that it will remain the same. Please do not use this API without
* consulting with the Platform/UI team. This might disappear in 3.4 M5.
* </p>
*
*
* @since 3.4
*/
struct BERRY_UI IServiceLocatorCreator : public virtual Object {
berryInterfaceMacro(IServiceLocatorCreator, berry);
~IServiceLocatorCreator();
/**
* Creates a service locator that can be used for hosting a new service
* context. It will have the appropriate child services created as needed,
* and can be used with the Dependency Injection framework to reuse
* components (by simply providing your own implementation for certain
* services).
*
* @param parent
* the parent locator
* @param factory
* a factory that can lazily provide services if requested. This
* may be <code>null</code>
* @param owner
* an object whose {@link IDisposable#dispose()} method will be
* called on the UI thread if the created service locator needs
* to be disposed (typically, because a plug-in contributing
* services to the service locator via an
* {@link AbstractServiceFactory} is no longer available). The
* owner can be any object that implements {@link IDisposable}.
* The recommended implementation of the owner's dispose method
* is to do whatever is necessary to stop using the created
* service locator, and then to call
* {@link IDisposable#dispose()} on the service locator.
* @return the created service locator. The returned service locator will be
* an instance of {@link IDisposable}.
*/
virtual SmartPointer<IServiceLocator> CreateServiceLocator(
const WeakPointer<IServiceLocator> parent,
const SmartPointer<const IServiceFactory> factory,
WeakPointer<IDisposable> owner) = 0;
};
}
#endif /* BERRYISERVICELOCATORCREATOR_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryIStackableContainer.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryIStackableContainer.h
index d1d8606185..08d78f52a8 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryIStackableContainer.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryIStackableContainer.h
@@ -1,127 +1,127 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYISTACKABLECONTAINER_H_
#define BERRYISTACKABLECONTAINER_H_
#include "berryStackablePart.h"
#include "berryPartPane.h"
#include <list>
namespace berry {
/**
* \ingroup org_blueberry_ui_internal
*
*/
struct BERRY_UI IStackableContainer : virtual public Object {
berryObjectMacro(IStackableContainer);
typedef std::list<StackablePart::Pointer> ChildrenType;
~IStackableContainer();
virtual bool AllowsAdd(StackablePart::Pointer toAdd) = 0;
/**
* Add a child to the container.
*/
virtual void Add(StackablePart::Pointer newPart) = 0;
/**
* Returnd the id for this stackable container
*/
virtual std::string GetID() const = 0;
/**
* Returns a list of layout children.
*/
virtual ChildrenType GetChildren() const = 0;
/**
* Remove a child from the container.
*/
virtual void Remove(StackablePart::Pointer part) = 0;
/**
* Replace one child with another
*/
virtual void Replace(StackablePart::Pointer oldPart, StackablePart::Pointer newPart) = 0;
virtual void FindSashes(PartPane::Sashes& result) = 0;
/**
* When a layout part closes, focus will return to the previously active part.
* This method determines whether the parts in this container should participate
* in this behavior. If this method returns true, its parts may automatically be
* given focus when another part is closed.
*
* @return true iff the parts in this container may be given focus when the active
* part is closed
*/
virtual bool AllowsAutoFocus() = 0;
/**
* Called by child parts to request a zoom in, given an immediate child
*
* @param toZoom
* @since 3.1
*/
//public void childRequestZoomIn(LayoutPart toZoom);
/**
* Called by child parts to request a zoom out
*
* @since 3.1
*/
//public void childRequestZoomOut();
/**
* Returns true iff the given child is obscured due to the fact that the container is zoomed into
* another part.
*
* @param toTest
* @return
* @since 3.1
*/
//public boolean childObscuredByZoom(LayoutPart toTest);
/**
* Returns true iff we are zoomed into the given part, given an immediate child of this container.
*
* @param toTest
* @return
* @since 3.1
*/
//public boolean childIsZoomed(LayoutPart toTest);
/**
* Called when the preferred size of the given child has changed, requiring a
* layout to be triggered.
*
* @param childThatChanged the child that triggered the new layout
*/
virtual void ResizeChild(StackablePart::Pointer childThatChanged) = 0;
};
}
#endif /* BERRYISTACKABLECONTAINER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryIStickyViewManager.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryIStickyViewManager.h
index 707794f13e..abc1762cb0 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryIStickyViewManager.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryIStickyViewManager.h
@@ -1,54 +1,54 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYISTICKYVIEWMANAGER_H_
#define BERRYISTICKYVIEWMANAGER_H_
#include <berryObject.h>
#include <berryMacros.h>
#include <berryIMemento.h>
#include <set>
namespace berry {
class Perspective;
struct BERRY_UI IStickyViewManager : public Object {
berryInterfaceMacro(IStickyViewManager, berry)
~IStickyViewManager();
virtual void Remove(const std::string& perspectiveId) = 0;
virtual void Add(const std::string& perspectiveId, const std::set<std::string>& stickyViewSet) = 0;
virtual void Clear() = 0;
virtual void Update(SmartPointer<Perspective> oldPersp, SmartPointer<Perspective> newPersp) = 0;
virtual void Save(IMemento::Pointer memento) = 0;
virtual void Restore(IMemento::Pointer memento) = 0;
};
}
#endif /* BERRYISTICKYVIEWMANAGER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryIWorkbenchLocationService.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryIWorkbenchLocationService.h
index 03604392eb..5e3c4fad39 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryIWorkbenchLocationService.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryIWorkbenchLocationService.h
@@ -1,85 +1,85 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIWORKBENCHLOCATIONSERVICE_H_
#define BERRYIWORKBENCHLOCATIONSERVICE_H_
#include <berryObject.h>
#include <berryMacros.h>
#include <org_blueberry_ui_Export.h>
namespace berry {
struct IWorkbench;
struct IWorkbenchWindow;
struct IWorkbenchPartSite;
struct IPageSite;
/**
* Query where you are in the workbench hierarchy.
*
* @since 3.4
*/
struct BERRY_UI IWorkbenchLocationService : public Object {
berryInterfaceMacro(IWorkbenchLocationService, berry)
~IWorkbenchLocationService();
/**
* Get the service scope.
*
* @return the service scope. May return <code>null</code>.
* @see IServiceScopes#PARTSITE_SCOPE
*/
virtual std::string GetServiceScope() const = 0;
/**
* A more numeric representation of the service level.
*
* @return the level - 0==workbench, 1==workbench window, etc
*/
virtual int GetServiceLevel() const = 0;
/**
* @return the workbench. May return <code>null</code>.
*/
virtual IWorkbench* GetWorkbench() const = 0;
/**
* @return the workbench window in this service locator hierarchy. May
* return <code>null</code>.
*/
virtual SmartPointer<IWorkbenchWindow> GetWorkbenchWindow() const = 0;
/**
* @return the part site in this service locator hierarchy. May return
* <code>null</code>.
*/
virtual SmartPointer<IWorkbenchPartSite> GetPartSite() const = 0;
/**
* @return the inner page site for a page based view in this service locator
* hierarchy. May return <code>null</code>.
* @see PageBookView
*/
virtual SmartPointer<IPageSite> GetPageSite() const = 0;
};
}
#endif /* BERRYIWORKBENCHLOCATIONSERVICE_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryLayoutHelper.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryLayoutHelper.cpp
index 43a3800ed2..84b0a408c2 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryLayoutHelper.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryLayoutHelper.cpp
@@ -1,158 +1,158 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryLayoutHelper.h"
#include "berryPageLayout.h"
#include "berryWorkbenchPartReference.h"
namespace berry
{
LayoutHelper::LayoutHelper()
{
}
void LayoutHelper::AddViewActivator(PageLayout::Pointer /*pageLayout*/,
const std::string& /*viewId*/)
{
// TODO View Activator
// if (viewId == null)
// {
// return;
// }
//
// ViewFactory viewFactory = pageLayout.getViewFactory();
//
// final IWorkbenchPage partPage = viewFactory.getWorkbenchPage();
// if (partPage == null)
// {
// return;
// }
//
// final IPerspectiveDescriptor partPerspective = pageLayout
// .getDescriptor();
//
// IWorkbenchActivitySupport support =
// PlatformUI.getWorkbench() .getActivitySupport();
//
// IViewDescriptor descriptor = viewFactory.getViewRegistry().find(viewId);
// if (!(descriptor instanceof IPluginContribution)
// )
// {
// return;
// }
//
// IIdentifier identifier = support.getActivityManager().getIdentifier(
// WorkbenchActivityHelper .createUnifiedId(
// (IPluginContribution) descriptor));
//
// identifier.addIdentifierListener(new IIdentifierListener()
// {
//
// /* (non-Javadoc)
// * @see org.blueberry.ui.activities.IIdentifierListener#identifierChanged(org.blueberry.ui.activities.IdentifierEvent)
// */
// public void identifierChanged(IdentifierEvent identifierEvent)
// {
// if (identifierEvent.hasEnabledChanged())
// {
// IIdentifier thisIdentifier = identifierEvent
// .getIdentifier();
// if (thisIdentifier.isEnabled())
// {
// // show view
// thisIdentifier.removeIdentifierListener(this);
// IWorkbenchPage activePage = partPage
// .getWorkbenchWindow().getActivePage();
// if (partPage == activePage
// && partPerspective == activePage
// .getPerspective())
// {
// // show immediately.
// try
// {
// partPage.showView(viewId);
// }
// catch (PartInitException e)
// {
// WorkbenchPlugin.log(getClass(), "identifierChanged", e); //$NON-NLS-1$
// }
// }
// else
// { // show when the perspective becomes active
// partPage.getWorkbenchWindow()
// .addPerspectiveListener(
// new IPerspectiveListener()
// {
//
// /* (non-Javadoc)
// * @see org.blueberry.ui.IPerspectiveListener#perspectiveActivated(org.blueberry.ui.IWorkbenchPage, org.blueberry.ui.IPerspectiveDescriptor)
// */
// public void perspectiveActivated(
// IWorkbenchPage page,
// IPerspectiveDescriptor newPerspective)
// {
// if (partPerspective == newPerspective)
// {
// partPage
// .getWorkbenchWindow()
// .removePerspectiveListener(
// this);
// try
// {
// page
// .showView(viewId);
// }
// catch (PartInitException e)
// {
// WorkbenchPlugin.log(getClass(), "perspectiveActivated", e); //$NON-NLS-1$
// }
// }
// }
//
// /* (non-Javadoc)
// * @see org.blueberry.ui.IPerspectiveListener#perspectiveChanged(org.blueberry.ui.IWorkbenchPage, org.blueberry.ui.IPerspectiveDescriptor, java.lang.String)
// */
// public void perspectiveChanged(
// IWorkbenchPage page,
// IPerspectiveDescriptor perspective,
// String changeId)
// {
// // no-op
// }
// });
// }
// }
// }
// }
// }
// );
}
PartPane::Pointer LayoutHelper::CreateView(ViewFactory* factory,
const std::string& viewId)
{
WorkbenchPartReference::Pointer ref = factory->CreateView(
ViewFactory::ExtractPrimaryId(viewId), ViewFactory::ExtractSecondaryId(
viewId)).Cast<WorkbenchPartReference>();
PartPane::Pointer newPart = ref->GetPane();
return newPart;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryLayoutHelper.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryLayoutHelper.h
index 856567b8c3..9fd99a2817 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryLayoutHelper.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryLayoutHelper.h
@@ -1,80 +1,80 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYLAYOUTHELPER_H_
#define BERRYLAYOUTHELPER_H_
#include "berryViewFactory.h"
#include "berryPartPane.h"
namespace berry {
class PageLayout;
/**
* Helper methods that the internal layout classes (<code>PageLayout</code> and
* <code>FolderLayout</code>) utilize for activities support and view creation.
*
* @since 3.0
*/
class LayoutHelper {
private:
/**
* Not intended to be instantiated.
*/
LayoutHelper();
public:
/**
* Creates a series of listeners that will activate the provided view on the
* provided page layout when <code>IIdentifier</code> enablement changes. The
* rules for this activation are as follows: <p>
* <ul>
* <li> if the identifier becomes enabled and the perspective of the page
* layout is the currently active perspective in its window, then activate
* the views immediately.
* <li> if the identifier becomes enabled and the perspective of the page
* layout is not the currently active perspecitve in its window, then add an
* <code>IPerspectiveListener</code> to the window and activate the views
* when the perspective becomes active.
*
* @param pageLayout <code>PageLayout</code>.
* @param viewId the view id to activate upon <code>IIdentifier</code> enablement.
*/
static void AddViewActivator(SmartPointer<PageLayout> pageLayout,
const std::string& viewId);
/**
* Create the view. If it's already been been created in the provided
* factory, return the shared instance.
*
* @param factory the <code>ViewFactory</code> to use.
* @param viewID the view id to use.
* @return the new <code>ViewPane</code>.
* @throws PartInitException thrown if there is a problem creating the view.
*/
static PartPane::Pointer CreateView(ViewFactory* factory, const std::string& viewId);
};
}
#endif /* BERRYLAYOUTHELPER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryLayoutPart.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryLayoutPart.cpp
index 34867f094f..f0b6116ff8 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryLayoutPart.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryLayoutPart.cpp
@@ -1,337 +1,337 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryLayoutPart.h"
#include "berryILayoutContainer.h"
#include "berryDetachedWindow.h"
#include "tweaklets/berryGuiWidgetsTweaklet.h"
#include "berryIWorkbenchWindow.h"
#include "berryConstants.h"
namespace berry
{
const std::string LayoutPart::PROP_VISIBILITY = "PROP_VISIBILITY"; //$NON-NLS-1$
LayoutPart::LayoutPart(const std::string& id_) :
id(id_), deferCount(0)
{
}
LayoutPart::~LayoutPart()
{
}
bool LayoutPart::AllowsAutoFocus()
{
if (container != 0)
{
return container->AllowsAutoFocus();
}
return true;
}
void LayoutPart::Dispose()
{
}
Rectangle LayoutPart::GetBounds()
{
if (this->GetControl() == 0)
return Rectangle();
return Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetBounds(this->GetControl());
}
ILayoutContainer::Pointer LayoutPart::GetContainer()
{
return container;
}
std::string LayoutPart::GetID() const
{
return id;
}
bool LayoutPart::IsCompressible()
{
return false;
}
Point LayoutPart::GetSize()
{
Rectangle r = this->GetBounds();
Point ptSize(r.width, r.height);
return ptSize;
}
int LayoutPart::GetSizeFlags(bool /*horizontal*/)
{
return Constants::MIN;
}
int LayoutPart::ComputePreferredSize(bool /*width*/, int /*availableParallel*/,
int /*availablePerpendicular*/, int preferredParallel)
{
return preferredParallel;
}
IDropTarget::Pointer LayoutPart::GetDropTarget(Object::Pointer /*draggedObject*/, const Point& /*displayCoordinates*/)
{
return IDropTarget::Pointer(0);
}
bool LayoutPart::IsDocked()
{
Shell::Pointer s = this->GetShell();
if (s == 0) {
return false;
}
return s->GetData().Cast<IWorkbenchWindow>() != 0;
}
Shell::Pointer LayoutPart::GetShell()
{
void* ctrl = this->GetControl();
if (ctrl)
{
return Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetShell(ctrl);
}
return Shell::Pointer(0);
}
IWorkbenchWindow::Pointer LayoutPart::GetWorkbenchWindow()
{
Shell::Pointer s = this->GetShell();
if (s == 0)
{
return IWorkbenchWindow::Pointer(0);
}
Object::Pointer data = s->GetData();
if (data.Cast<IWorkbenchWindow>() != 0)
{
return data.Cast<IWorkbenchWindow>();
}
else if (data.Cast<DetachedWindow>() != 0)
{
return data.Cast<DetachedWindow>()->GetWorkbenchPage()->GetWorkbenchWindow();
}
return IWorkbenchWindow::Pointer(0);
}
void LayoutPart::MoveAbove(void* /*refControl*/)
{
}
void LayoutPart::Reparent(void* newParent)
{
void* control = this->GetControl();
GuiWidgetsTweaklet* guiTweaklet = Tweaklets::Get(GuiWidgetsTweaklet::KEY);
if ((control == 0) || (guiTweaklet->GetParent(control) == newParent))
{
return;
}
if (guiTweaklet->IsReparentable(control))
{
// make control small in case it is not resized with other controls
//control.setBounds(0, 0, 0, 0);
// By setting the control to disabled before moving it,
// we ensure that the focus goes away from the control and its children
// and moves somewhere else
bool enabled = guiTweaklet->GetEnabled(control);
guiTweaklet->SetEnabled(control, false);
guiTweaklet->SetParent(control, newParent);
guiTweaklet->SetEnabled(control, enabled);
guiTweaklet->MoveAbove(control, 0);
}
}
bool LayoutPart::GetVisible()
{
void* ctrl = this->GetControl();
if (ctrl)
{
return Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetVisible(ctrl);
}
return false;
}
bool LayoutPart::IsVisible()
{
void* ctrl = this->GetControl();
if (ctrl)
{
return Tweaklets::Get(GuiWidgetsTweaklet::KEY)->IsVisible(ctrl);
}
return false;
}
void LayoutPart::SetVisible(bool makeVisible)
{
void* ctrl = this->GetControl();
if (ctrl != 0)
{
if (makeVisible == Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetVisible(ctrl))
{
return;
}
// if (!makeVisible && this->IsFocusAncestor(ctrl))
// {
// // Workaround for Bug 60970 [EditorMgmt] setActive() called on an editor when it does not have focus.
// // Force focus on the shell so that when ctrl is hidden,
// // SWT does not try to send focus elsewhere, which may cause
// // some other part to be activated, which affects the part
// // activation order and can cause flicker.
// ctrl.getShell().forceFocus();
// }
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->SetVisible(ctrl, makeVisible);
}
}
bool LayoutPart::IsFocusAncestor(void* /*ctrl*/)
{
// Control f = ctrl.getDisplay().getFocusControl();
// while (f != null && f != ctrl)
// {
// f = f.getParent();
// }
// return f == ctrl;
return false;
}
void LayoutPart::SetBounds(const Rectangle& r)
{
void* ctrl = this->GetControl();
if (ctrl)
{
return Tweaklets::Get(GuiWidgetsTweaklet::KEY)->SetBounds(ctrl, r);
}
}
void LayoutPart::SetContainer(ILayoutContainer::Pointer container)
{
this->container = container;
//TODO Zoom
// if (container != 0)
// {
// setZoomed(container.childIsZoomed(this));
// }
}
void LayoutPart::SetID(const std::string& str)
{
id = str;
}
LayoutPart::Pointer LayoutPart::GetPart()
{
return LayoutPart::Pointer(this);
}
void LayoutPart::DeferUpdates(bool shouldDefer)
{
if (shouldDefer)
{
if (deferCount == 0)
{
this->StartDeferringEvents();
}
deferCount++;
}
else
{
if (deferCount> 0)
{
deferCount--;
if (deferCount == 0)
{
this->HandleDeferredEvents();
}
}
}
}
void LayoutPart::StartDeferringEvents()
{
}
void LayoutPart::HandleDeferredEvents()
{
}
bool LayoutPart::IsDeferred()
{
return deferCount> 0;
}
void LayoutPart::DescribeLayout(std::string& /*buf*/) const
{
}
std::string LayoutPart::GetPlaceHolderId()
{
return this->GetID();
}
void LayoutPart::ResizeChild(LayoutPart::Pointer /*childThatChanged*/)
{
}
void LayoutPart::FlushLayout()
{
ILayoutContainer::Pointer container = this->GetContainer();
if (container != 0)
{
container->ResizeChild(LayoutPart::Pointer(this));
}
}
bool LayoutPart::AllowsAdd(LayoutPart::Pointer /*toAdd*/)
{
return false;
}
std::string LayoutPart::ToString()
{
return "";
}
void LayoutPart::TestInvariants()
{
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryLayoutPart.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryLayoutPart.h
index 5e29b7fc5b..6ba840a7be 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryLayoutPart.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryLayoutPart.h
@@ -1,297 +1,297 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYLAYOUTPART_H_
#define BERRYLAYOUTPART_H_
#include <berryMacros.h>
#include "berryIDropTarget.h"
#include "berryISizeProvider.h"
#include "berryRectangle.h"
#include "berryPoint.h"
#include "berryShell.h"
namespace berry {
struct ILayoutContainer;
struct IWorkbenchWindow;
/**
* \ingroup org_blueberry_ui_internal
*
* A presentation part is used to build the presentation for the
* workbench. Common subclasses are pane and folder.
*/
class LayoutPart : virtual public Object { //, public ISizeProvider {
public:
berryObjectMacro(LayoutPart);
protected: SmartPointer<ILayoutContainer> container;
protected: std::string id;
public: static const std::string PROP_VISIBILITY;// = "PROP_VISIBILITY"; //$NON-NLS-1$
/**
* Number of times deferUpdates(true) has been called without a corresponding
* deferUpdates(false)
*/
private: int deferCount;
/**
* PresentationPart constructor comment.
*/
public: LayoutPart(const std::string& id);
public: virtual ~LayoutPart();
/**
* When a layout part closes, focus will return to a previously active part.
* This method determines whether this part should be considered for activation
* when another part closes. If a group of parts are all closing at the same time,
* they will all return false from this method while closing to ensure that the
* parent does not activate a part that is in the process of closing. Parts will
* also return false from this method if they are minimized, closed fast views,
* obscured by zoom, etc.
*
* @return true iff the parts in this container may be given focus when the active
* part is closed
*/
public: virtual bool AllowsAutoFocus();
/**
* Creates the GUI control
*/
public: virtual void CreateControl(void* parent) = 0;
/**
* Disposes the GUI control
*
* This can be used to execute cleanup code or notify listeners
* when a LayoutPart is no longer used, but is still referenced
* by a SmartPointer (instead of putting the code in the LayoutPart
* destructor).
*/
public: virtual void Dispose();
/**
* Gets the presentation bounds.
*/
public: Rectangle GetBounds();
/**
* Gets the parent for this part.
* <p>
* In general, this is non-null if the object has been added to a container and the
* container's widgetry exists. The exception to this rule is PartPlaceholders
* created when restoring a ViewStack using restoreState, which point to the
* ViewStack even if its widgetry doesn't exist yet. Returns null in the remaining
* cases.
* </p>
* <p>
* TODO: change the semantics of this method to always point to the parent container,
* regardless of whether its widgetry exists. Locate and refactor code that is currently
* depending on the special cases.
* </p>
*/
public: virtual SmartPointer<ILayoutContainer> GetContainer();
/**
* Get the part control. This method may return null.
*/
public: virtual void* GetControl() = 0;
/**
* Gets the ID for this part.
*/
public: virtual std::string GetID() const;
public: virtual bool IsCompressible();
/**
* Gets the presentation size.
*/
public: virtual Point GetSize();
/**
* @see org.blueberry.ui.presentations.StackPresentation#getSizeFlags(boolean)
*
* @since 3.1
*/
public: virtual int GetSizeFlags(bool horizontal);
/**
* @see org.blueberry.ui.presentations.StackPresentation#computePreferredSize(boolean, int, int, int)
*
* @since 3.1
*/
public: virtual int ComputePreferredSize(bool width, int availableParallel, int availablePerpendicular, int preferredParallel);
public: virtual IDropTarget::Pointer GetDropTarget(Object::Pointer draggedObject, const Point& displayCoordinates);
public: bool IsDocked();
public: virtual Shell::Pointer GetShell();
/**
* Returns the workbench window window for a part.
*
* @return the workbench window, or <code>null</code> if there's no window
* associated with this part.
*/
public: virtual SmartPointer<IWorkbenchWindow> GetWorkbenchWindow();
/**
* Move the control over another one.
*/
public: virtual void MoveAbove(void* refControl);
/**
* Reparent a part.
*/
public: virtual void Reparent(void* newParent);
/**
* Returns true if this part was set visible. This returns whatever was last passed into
* setVisible, but does not necessarily indicate that the part can be seen (ie: one of its
* ancestors may be invisible)
*/
public: virtual bool GetVisible();
/**
* Returns true if this part can be seen. Returns false if the part or any of its ancestors
* are invisible.
*/
public: virtual bool IsVisible();
/**
* Shows the receiver if <code>visible</code> is true otherwise hide it.
*/
public: virtual void SetVisible(bool makeVisible);
/**
* Returns <code>true</code> if the given control or any of its descendents has focus.
*/
private: virtual bool IsFocusAncestor(void* ctrl);
/**
* Sets the presentation bounds.
*/
public: virtual void SetBounds(const Rectangle& r);
/**
* Sets the parent for this part.
*/
public: virtual void SetContainer(SmartPointer<ILayoutContainer> container);
/**
* Sets the part ID.
*/
public: virtual void SetID(const std::string& str);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.IWorkbenchDragDropPart#getPart()
*/
public: virtual LayoutPart::Pointer GetPart();
/**
* deferUpdates(true) disables widget updates until a corresponding call to
* deferUpdates(false). Exactly what gets deferred is the decision
* of each LayoutPart, however the part may only defer operations in a manner
* that does not affect the final result.
* That is, the state of the receiver after the final call to deferUpdates(false)
* must be exactly the same as it would have been if nothing had been deferred.
*
* @param shouldDefer true iff events should be deferred
*/
public: void DeferUpdates(bool shouldDefer);
/**
* This is called when deferUpdates(true) causes UI events for this
* part to be deferred. Subclasses can overload to initialize any data
* structures that they will use to collect deferred events.
*/
protected: virtual void StartDeferringEvents();
/**
* Immediately processes all UI events which were deferred due to a call to
* deferUpdates(true). This is called when the last call is made to
* deferUpdates(false). Subclasses should overload this method if they
* defer some or all UI processing during deferUpdates.
*/
protected: virtual void HandleDeferredEvents();
/**
* Subclasses can call this method to determine whether UI updates should
* be deferred. Returns true iff there have been any calls to deferUpdates(true)
* without a corresponding call to deferUpdates(false). Any operation which is
* deferred based on the result of this method should be performed later within
* handleDeferredEvents().
*
* @return true iff updates should be deferred.
*/
protected: bool IsDeferred();
/**
* Writes a description of the layout to the given string buffer.
* This is used for drag-drop test suites to determine if two layouts are the
* same. Like a hash code, the description should compare as equal iff the
* layouts are the same. However, it should be user-readable in order to
* help debug failed tests. Although these are english readable strings,
* they do not need to be translated.
*
* @param buf
*/
public: virtual void DescribeLayout(std::string& buf) const;
/**
* Returns an id representing this part, suitable for use in a placeholder.
*
* @since 3.0
*/
public: virtual std::string GetPlaceHolderId();
public: virtual void ResizeChild(LayoutPart::Pointer childThatChanged);
public: void FlushLayout();
/**
* Returns true iff the given part can be added to this ILayoutContainer
* @param toAdd
* @return
* @since 3.1
*/
public: virtual bool AllowsAdd(LayoutPart::Pointer toAdd);
/**
* Tests the integrity of this object. Throws an exception if the object's state
* is not internally consistent. For use in test suites.
*/
public: virtual void TestInvariants();
public: virtual std::string ToString();
};
}
#endif /*BERRYLAYOUTPART_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryLayoutPartSash.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryLayoutPartSash.cpp
index 607b62c3fe..7e1b753326 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryLayoutPartSash.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryLayoutPartSash.cpp
@@ -1,305 +1,305 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryLayoutPartSash.h"
#include "berryLayoutTree.h"
#include "berryLayoutTreeNode.h"
#include "berryWorkbenchPlugin.h"
#include "berryConstants.h"
#include "tweaklets/berryGuiWidgetsTweaklet.h"
namespace berry
{
LayoutPartSash::SelectionListener::SelectionListener(LayoutPartSash* lp)
: layoutPartSash(lp)
{
}
void LayoutPartSash::SelectionListener::WidgetSelected(GuiTk::SelectionEvent::Pointer e)
{
layoutPartSash->CheckDragLimit(e);
if (e->detail != Constants::DRAG)
{
layoutPartSash->WidgetSelected(e->x, e->y, e->width,
e->height);
}
}
LayoutPartSash::LayoutPartSash(PartSashContainer* rootContainer, int style)
: LayoutPart(""), sash(0), enabled(false), rootContainer(rootContainer),
style(style), left(300), right(300), presFactory(0), isVisible(false)
{
selectionListener = new SelectionListener(this);
}
LayoutPartSash::~LayoutPartSash()
{
this->Dispose();
}
void LayoutPartSash::CheckDragLimit(GuiTk::SelectionEvent::Pointer event)
{
LayoutTree::Pointer root = rootContainer->GetLayoutTree();
LayoutTreeNode::Pointer node = root->FindSash(LayoutPartSash::Pointer(this));
Rectangle nodeBounds = node->GetBounds();
Rectangle eventRect(event->x, event->y, event->width, event->height);
bool vertical = (style == Constants::VERTICAL);
// If a horizontal sash, flip the coordinate system so that we
// can handle horizontal and vertical sashes without special cases
if (!vertical)
{
nodeBounds.FlipXY();
eventRect.FlipXY();
}
int eventX = eventRect.x;
int left = std::max<int>(0, eventX - nodeBounds.x);
left = std::min<int>(left, nodeBounds.width - this->GetSashSize());
int right = nodeBounds.width - left - this->GetSashSize();
LayoutTreeNode::ChildSizes sizes = node->ComputeChildSizes(nodeBounds.width, nodeBounds.height, left, right, nodeBounds.width);
eventRect.x = nodeBounds.x + sizes.left;
// If it's a horizontal sash, restore eventRect to its original coordinate system
if (!vertical)
{
eventRect.FlipXY();
}
event->x = eventRect.x;
event->y = eventRect.y;
}
void LayoutPartSash::CreateControl(void* /*parent*/)
{
// Defer creation of the control until it becomes visible
if (isVisible)
{
this->DoCreateControl();
}
}
void LayoutPartSash::DoCreateControl()
{
if (sash == 0)
{
// ask the presentation factory to create the sash
IPresentationFactory* factory = WorkbenchPlugin::GetDefault()->GetPresentationFactory();
int sashStyle = IPresentationFactory::SASHTYPE_NORMAL | style;
sash = factory->CreateSash(this->rootContainer->GetParent(), sashStyle);
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->AddSelectionListener(sash, selectionListener);
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->SetEnabled(sash, enabled);
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->SetBounds(sash, bounds);
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->SetVisible(sash, isVisible);
}
}
void LayoutPartSash::SetBounds(const Rectangle& r)
{
LayoutPart::SetBounds(r);
bounds = r;
}
void LayoutPartSash::SetVisible(bool visible)
{
if (visible == isVisible)
{
return;
}
if (visible)
{
this->DoCreateControl();
}
else
{
this->Dispose();
}
LayoutPart::SetVisible(visible);
isVisible = visible;
}
bool LayoutPartSash::IsVisible()
{
return isVisible;
}
void LayoutPartSash::Dispose()
{
if (sash != 0)
{
bounds = Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetBounds(sash);
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->Dispose(sash);
}
sash = 0;
}
Rectangle LayoutPartSash::GetBounds()
{
if (sash == 0)
{
return bounds;
}
return Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetBounds(sash);
}
void* LayoutPartSash::GetControl()
{
return sash;
}
std::string LayoutPartSash::GetID()
{
return "";
}
LayoutPartSash::Pointer LayoutPartSash::GetPostLimit()
{
return postLimit;
}
LayoutPartSash::Pointer LayoutPartSash::GetPreLimit()
{
return preLimit;
}
int LayoutPartSash::GetLeft()
{
return left;
}
int LayoutPartSash::GetRight()
{
return right;
}
bool LayoutPartSash::IsHorizontal()
{
return ((style & Constants::HORIZONTAL) == Constants::HORIZONTAL);
}
bool LayoutPartSash::IsVertical()
{
return ((style & Constants::VERTICAL) == Constants::VERTICAL);
}
void LayoutPartSash::SetPostLimit(LayoutPartSash::Pointer newPostLimit)
{
postLimit = newPostLimit;
}
void LayoutPartSash::SetPreLimit(LayoutPartSash::Pointer newPreLimit)
{
preLimit = newPreLimit;
}
void LayoutPartSash::SetRatio(float newRatio)
{
int total = left + right;
int newLeft = (int) (total * newRatio);
this->SetSizes(newLeft, total - newLeft);
}
void LayoutPartSash::SetSizes(int left, int right)
{
if (left < 0 || right < 0)
{
return;
}
if (left == this->left && right == this->right)
{
return;
}
this->left = left;
this->right = right;
this->FlushCache();
}
void LayoutPartSash::FlushCache()
{
LayoutTree::Pointer root = rootContainer->GetLayoutTree();
if (root != 0)
{
LayoutTreeNode::Pointer node = root->FindSash(LayoutPartSash::Pointer(this));
if (node != 0)
{
node->FlushCache();
}
}
}
void LayoutPartSash::WidgetSelected(int x, int y, int /*width*/, int /*height*/)
{
if (!enabled)
{
return;
}
LayoutTree::Pointer root = rootContainer->GetLayoutTree();
LayoutTreeNode::Pointer node = root->FindSash(LayoutPartSash::Pointer(this));
Rectangle nodeBounds = node->GetBounds();
//Recompute ratio
x -= nodeBounds.x;
y -= nodeBounds.y;
if (style == Constants::VERTICAL)
{
this->SetSizes(x, nodeBounds.width - x - this->GetSashSize());
}
else
{
this->SetSizes(y, nodeBounds.height - y - this->GetSashSize());
}
node->SetBounds(nodeBounds);
}
void LayoutPartSash::SetEnabled(bool resizable)
{
this->enabled = resizable;
if (sash != 0)
{
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->SetEnabled(sash, enabled);
}
}
int LayoutPartSash::GetSashSize() const
{
IPresentationFactory* factory = WorkbenchPlugin::GetDefault()->GetPresentationFactory();
int sashStyle = IPresentationFactory::SASHTYPE_NORMAL | style;
int size = factory->GetSashSize(sashStyle);
return size;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryLayoutPartSash.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryLayoutPartSash.h
index e82f525094..8cda99094d 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryLayoutPartSash.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryLayoutPartSash.h
@@ -1,182 +1,182 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYLAYOUTPARTSASH_H_
#define BERRYLAYOUTPARTSASH_H_
#include "berryLayoutPart.h"
#include "berryPartSashContainer.h"
#include "guitk/berryGuiTkISelectionListener.h"
#include "presentations/berryIPresentationFactory.h"
namespace berry
{
class LayoutPartSash: public LayoutPart
{
friend class WorkbenchPage;
friend class PartSashContainer;
friend class LayoutTreeNode;
public:
berryObjectMacro(LayoutPartSash);
LayoutPartSash(PartSashContainer* rootContainer, int style);
~LayoutPartSash();
private:
void* sash;
bool enabled;
PartSashContainer* rootContainer;
int style;
LayoutPartSash::Pointer preLimit;
LayoutPartSash::Pointer postLimit;
int left;
int right;
Rectangle bounds;
IPresentationFactory* presFactory;
/**
* Stores whether or not the sash is visible. (This is expected to have a meaningful
* value even if the underlying control doesn't exist).
*/
bool isVisible;
struct SelectionListener : public GuiTk::ISelectionListener
{
SelectionListener(LayoutPartSash* layoutPartSash);
void WidgetSelected(GuiTk::SelectionEvent::Pointer e);
private: LayoutPartSash* layoutPartSash;
};
GuiTk::ISelectionListener::Pointer selectionListener;
// checkDragLimit contains changes by cagatayk@acm.org
void CheckDragLimit(GuiTk::SelectionEvent::Pointer event);
/**
* Creates the control. As an optimization, creation of the control is deferred if
* the control is invisible.
*/
public:
void CreateControl(void* parent);
/**
* Creates the underlying SWT control.
*
* @since 3.1
*/
private:
void DoCreateControl();
public:
void SetBounds(const Rectangle& r);
/**
* Makes the sash visible or invisible. Note: as an optimization, the actual widget is destroyed when the
* sash is invisible.
*/
public:
void SetVisible(bool visible);
public:
bool IsVisible();
/**
* See LayoutPart#dispose
*/
public:
void Dispose();
/**
* Gets the presentation bounds.
*/
public:
Rectangle GetBounds();
/**
* Returns the part control.
*/
public:
void* GetControl();
/**
*
*/
public:
std::string GetID();
protected:
LayoutPartSash::Pointer GetPostLimit();
LayoutPartSash::Pointer GetPreLimit();
int GetLeft();
int GetRight();
bool IsHorizontal();
bool IsVertical();
void SetPostLimit(LayoutPartSash::Pointer newPostLimit);
void SetPreLimit(LayoutPartSash::Pointer newPreLimit);
void SetRatio(float newRatio);
void SetSizes(int left, int right);
private:
void FlushCache();
private:
void WidgetSelected(int x, int y, int width, int height);
/**
* @param resizable
* @since 3.1
*/
public:
void SetEnabled(bool resizable);
protected:
/* package */int GetSashSize() const;
};
}
#endif /* BERRYLAYOUTPARTSASH_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryLayoutTree.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryLayoutTree.cpp
index 9faf8a77f0..884f982829 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryLayoutTree.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryLayoutTree.cpp
@@ -1,481 +1,481 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryLayoutTree.h"
#include "berryLayoutTreeNode.h"
#include "berryLayoutPartSash.h"
#include "berryContainerPlaceholder.h"
#include "berryConstants.h"
namespace berry
{
int LayoutTree::minCacheHits = 0;
int LayoutTree::minCacheMisses = 0;
int LayoutTree::maxCacheHits = 0;
int LayoutTree::maxCacheMisses = 0;
LayoutTree::LayoutTree(LayoutPart::Pointer part)
: parent(0),
cachedMinimumWidthHint(Constants::DEFAULT),
cachedMinimumWidth(Constants::DEFAULT),
cachedMinimumHeightHint(Constants::DEFAULT),
cachedMinimumHeight(Constants::DEFAULT),
cachedMaximumWidthHint(Constants::DEFAULT),
cachedMaximumWidth(Constants::DEFAULT),
cachedMaximumHeightHint(Constants::DEFAULT),
cachedMaximumHeight(Constants::DEFAULT),
forceLayout(true),
sizeFlagsDirty(true),
widthSizeFlags(0),
heightSizeFlags(0)
{
this->part = part;
}
LayoutPart::Pointer LayoutTree::ComputeRelation(
std::list<PartSashContainer::RelationshipInfo>& /*relations*/)
{
return part;
}
LayoutPart::Pointer LayoutTree::FindPart(const Point& /*toFind*/)
{
return part;
}
void LayoutTree::DisposeSashes()
{
}
LayoutTree::Pointer LayoutTree::Find(LayoutPart::Pointer child)
{
if (part != child)
{
return LayoutTree::Pointer(0);
}
return LayoutTree::Pointer(this);
}
void LayoutTree::FindSashes(PartPane::Sashes sashes)
{
if (this->GetParent() == 0)
{
return;
}
this->GetParent()->FindSashes(LayoutTree::Pointer(this), sashes);
}
LayoutPart::Pointer LayoutTree::FindBottomRight()
{
return part;
}
LayoutTreeNode::Pointer LayoutTree::FindSash(LayoutPartSash::Pointer /*sash*/)
{
return LayoutTreeNode::Pointer(0);
}
Rectangle LayoutTree::GetBounds()
{
return currentBounds;
}
int LayoutTree::Subtract(int a, int b)
{
poco_assert(b >= 0 && b < INF);
return Add(a, -b);
}
int LayoutTree::Add(int a, int b)
{
if (a == INF || b == INF)
{
return INF;
}
return a + b;
}
void LayoutTree::AssertValidSize(int toCheck)
{
poco_assert(toCheck >= 0 && (toCheck == INF || toCheck < INF / 2));
}
int LayoutTree::ComputePreferredSize(bool width, int availableParallel,
int availablePerpendicular, int preferredParallel)
{
this->AssertValidSize(availableParallel);
this->AssertValidSize(availablePerpendicular);
this->AssertValidSize(preferredParallel);
if (!this->IsVisible())
{
return 0;
}
if (availableParallel == 0)
{
return 0;
}
if (preferredParallel == 0)
{
return std::min<int>(availableParallel, this->ComputeMinimumSize(width,
availablePerpendicular));
}
else if (preferredParallel == INF && availableParallel == INF)
{
return this->ComputeMaximumSize(width, availablePerpendicular);
}
// Optimization: if this subtree doesn't have any size preferences beyond its minimum and maximum
// size, simply return the preferred size
if (!this->HasSizeFlag(width, Constants::FILL))
{
return preferredParallel;
}
int result = this->DoComputePreferredSize(width, availableParallel,
availablePerpendicular, preferredParallel);
return result;
}
int LayoutTree::DoGetSizeFlags(bool width)
{
return part->GetSizeFlags(width);
}
int LayoutTree::DoComputePreferredSize(bool width, int availableParallel,
int availablePerpendicular, int preferredParallel)
{
int result = std::min<int>(availableParallel, part->ComputePreferredSize(width,
availableParallel, availablePerpendicular, preferredParallel));
this->AssertValidSize(result);
return result;
}
int LayoutTree::ComputeMinimumSize(bool width, int availablePerpendicular)
{
this->AssertValidSize(availablePerpendicular);
// Optimization: if this subtree has no minimum size, then always return 0 as its
// minimum size.
if (!this->HasSizeFlag(width, Constants::MIN))
{
return 0;
}
// If this subtree doesn't contain any wrapping controls (ie: they don't care
// about their perpendicular size) then force the perpendicular
// size to be INF. This ensures that we will get a cache hit
// every time for non-wrapping controls.
if (!this->HasSizeFlag(width, Constants::WRAP))
{
availablePerpendicular = INF;
}
if (width)
{
// Check if we have a cached width measurement (we can only return a cached
// value if we computed it for the same height)
if (cachedMinimumWidthHint == availablePerpendicular)
{
minCacheHits++;
return cachedMinimumWidth;
}
// Recompute the minimum width and store it in the cache
minCacheMisses++;
int result = this->DoComputeMinimumSize(width, availablePerpendicular);
cachedMinimumWidth = result;
cachedMinimumWidthHint = availablePerpendicular;
return result;
}
else
{
// Check if we have a cached height measurement (we can only return a cached
// value if we computed it for the same width)
if (cachedMinimumHeightHint == availablePerpendicular)
{
minCacheHits++;
return cachedMinimumHeight;
}
// Recompute the minimum width and store it in the cache
minCacheMisses++;
int result = this->DoComputeMinimumSize(width, availablePerpendicular);
cachedMinimumHeight = result;
cachedMinimumHeightHint = availablePerpendicular;
return result;
}
}
void LayoutTree::PrintCacheStatistics()
{
BERRY_INFO << "minimize cache " << minCacheHits << " / " << (minCacheHits
+ minCacheMisses) << " hits " <<
(minCacheHits * 100 / (minCacheHits + minCacheMisses)) << "%\n";
BERRY_INFO << "maximize cache " << maxCacheHits << " / " << (maxCacheHits
+ maxCacheMisses) << " hits" <<
(maxCacheHits * 100 / (maxCacheHits + maxCacheMisses)) << "%\n";
}
int LayoutTree::DoComputeMinimumSize(bool width, int availablePerpendicular)
{
int result = this->DoComputePreferredSize(width, INF, availablePerpendicular,
0);
this->AssertValidSize(result);
return result;
}
int LayoutTree::ComputeMaximumSize(bool width, int availablePerpendicular)
{
this->AssertValidSize(availablePerpendicular);
// Optimization: if this subtree has no maximum size, then always return INF as its
// maximum size.
if (!this->HasSizeFlag(width, Constants::MAX))
{
return INF;
}
// If this subtree doesn't contain any wrapping controls (ie: they don't care
// about their perpendicular size) then force the perpendicular
// size to be INF. This ensures that we will get a cache hit
// every time.
if (!this->HasSizeFlag(width, Constants::WRAP))
{
availablePerpendicular = INF;
}
if (width)
{
// Check if we have a cached width measurement (we can only return a cached
// value if we computed it for the same height)
if (cachedMaximumWidthHint == availablePerpendicular)
{
maxCacheHits++;
return cachedMaximumWidth;
}
maxCacheMisses++;
// Recompute the maximum width and store it in the cache
int result = this->DoComputeMaximumSize(width, availablePerpendicular);
cachedMaximumWidth = result;
cachedMaximumWidthHint = availablePerpendicular;
return result;
}
else
{
// Check if we have a cached height measurement
if (cachedMaximumHeightHint == availablePerpendicular)
{
maxCacheHits++;
return cachedMaximumHeight;
}
maxCacheMisses++;
// Recompute the maximum height and store it in the cache
int result = this->DoComputeMaximumSize(width, availablePerpendicular);
cachedMaximumHeight = result;
cachedMaximumHeightHint = availablePerpendicular;
return result;
}
}
int LayoutTree::DoComputeMaximumSize(bool width, int availablePerpendicular)
{
return this->DoComputePreferredSize(width, INF, availablePerpendicular,
INF);
}
void LayoutTree::FlushNode()
{
// Clear cached sizes
cachedMinimumWidthHint = Constants::DEFAULT;
cachedMinimumWidth = Constants::DEFAULT;
cachedMinimumHeightHint = Constants::DEFAULT;
cachedMinimumHeight = Constants::DEFAULT;
cachedMaximumWidthHint = Constants::DEFAULT;
cachedMaximumWidth = Constants::DEFAULT;
cachedMaximumHeightHint = Constants::DEFAULT;
cachedMaximumHeight = Constants::DEFAULT;
// Flags may have changed. Ensure that they are recomputed the next time around
sizeFlagsDirty = true;
// The next setBounds call should trigger a layout even if set to the same bounds since
// one of the children has changed.
forceLayout = true;
}
void LayoutTree::FlushChildren()
{
this->FlushNode();
}
void LayoutTree::FlushCache()
{
this->FlushNode();
if (parent != 0)
{
parent->FlushCache();
}
}
int LayoutTree::GetSizeFlags(bool width)
{
if (sizeFlagsDirty)
{
widthSizeFlags = this->DoGetSizeFlags(true);
heightSizeFlags = this->DoGetSizeFlags(false);
sizeFlagsDirty = false;
}
return width ? widthSizeFlags : heightSizeFlags;
}
LayoutTreeNode* LayoutTree::GetParent() const
{
return parent;
}
LayoutTree::Pointer LayoutTree::Insert(LayoutPart::Pointer child, bool left,
LayoutPartSash::Pointer sash, LayoutPart::Pointer relative)
{
LayoutTree::Pointer relativeChild = this->Find(relative);
LayoutTreeNode::Pointer node(new LayoutTreeNode(sash));
if (relativeChild == 0)
{
//Did not find the relative part. Insert beside the root.
node->SetChild(left, child);
node->SetChild(!left, LayoutTree::Pointer(this));
return node;
}
else
{
LayoutTreeNode* oldParent = relativeChild->GetParent();
node->SetChild(left, child);
node->SetChild(!left, relativeChild);
if (oldParent == 0)
{
//It was the root. Return a new root.
return node;
}
oldParent->ReplaceChild(relativeChild, node);
return LayoutTree::Pointer(this);
}
}
bool LayoutTree::IsCompressible()
{
//Added for bug 19524
return part->IsCompressible();
}
bool LayoutTree::IsVisible()
{
return part.Cast<ContainerPlaceholder>().IsNull();
}
void LayoutTree::RecomputeRatio()
{
}
LayoutTree::Pointer LayoutTree::Remove(LayoutPart::Pointer child)
{
LayoutTree::Pointer tree = this->Find(child);
if (tree == 0)
{
return LayoutTree::Pointer(this);
}
LayoutTreeNode::Pointer oldParent(tree->GetParent());
if (oldParent == 0)
{
//It was the root and the only child of this tree
return LayoutTree::Pointer(0);
}
if (oldParent->GetParent() == 0)
{
return oldParent->Remove(tree);
}
oldParent->Remove(tree);
return LayoutTree::Pointer(this);
}
void LayoutTree::SetBounds(const Rectangle& bounds)
{
if (!(bounds == currentBounds) || forceLayout)
{
currentBounds = bounds;
this->DoSetBounds(currentBounds);
forceLayout = false;
}
}
void LayoutTree::DoSetBounds(const Rectangle& bounds)
{
part->SetBounds(bounds);
}
void LayoutTree::SetParent(LayoutTreeNode* parent)
{
this->parent = parent;
}
void LayoutTree::SetPart(LayoutPart::Pointer part)
{
this->part = part;
this->FlushCache();
}
std::string LayoutTree::ToString()
{
return "(" + part->ToString() + ")";//$NON-NLS-2$//$NON-NLS-1$
}
void LayoutTree::CreateControl(void* /*parent*/)
{
}
void LayoutTree::DescribeLayout(std::string& buf) const
{
part->DescribeLayout(buf);
}
bool LayoutTree::HasSizeFlag(bool width, int flag)
{
return (this->GetSizeFlags(width) & flag) != 0;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryLayoutTree.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryLayoutTree.h
index 3d9b87c5cd..c7a97cbe43 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryLayoutTree.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryLayoutTree.h
@@ -1,373 +1,373 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYLAYOUTTREE_H_
#define BERRYLAYOUTTREE_H_
#include "berryISizeProvider.h"
#include "berryRectangle.h"
#include "berryPoint.h"
#include "berryPartSashContainer.h"
#include <list>
namespace berry
{
class LayoutTreeNode;
class LayoutPartSash;
/**
* \ingroup org_blueberry_ui_internal
*
* Implementation of a tree where the node is allways a sash
* and it allways has two chidren. If a children is removed
* the sash, ie the node, is removed as well and its other children
* placed on its parent.
*/
class LayoutTree : public Object, public ISizeProvider
{ //implements ISizeProvider {
public:
berryObjectMacro(LayoutTree);
/* The parent of this tree or null if it is the root */
LayoutTreeNode* parent;
/* Any LayoutPart if this is a leaf or a LayoutSashPart if it is a node */
LayoutPart::Pointer part;
private:
// Cached information
int cachedMinimumWidthHint;
int cachedMinimumWidth;
int cachedMinimumHeightHint;
int cachedMinimumHeight;
int cachedMaximumWidthHint;
int cachedMaximumWidth;
int cachedMaximumHeightHint;
int cachedMaximumHeight;
bool forceLayout;
Rectangle currentBounds;
// Cached size flags
bool sizeFlagsDirty;
int widthSizeFlags;
int heightSizeFlags;
public:
// Cache statistics. For use in benchmarks and test suites only!
static int minCacheHits;
static int minCacheMisses;
static int maxCacheHits;
static int maxCacheMisses;
/**
* Initialize this tree with its part.
*/
LayoutTree(LayoutPart::Pointer part);
/**
* Add the relation ship between the children in the list
* and returns the left children.
*/
virtual LayoutPart::Pointer ComputeRelation(
std::list<PartSashContainer::RelationshipInfo>& relations);
/**
* Locates the part that intersects the given point
*
* @param toFind
* @return
*/
virtual LayoutPart::Pointer FindPart(const Point& toFind);
/**
* Dispose all Sashs in this tree
*/
virtual void DisposeSashes();
/**
* Find a LayoutPart in the tree and return its sub-tree. Returns
* null if the child is not found.
*/
virtual SmartPointer<LayoutTree> Find(LayoutPart::Pointer child);
/**
* Find the Left,Right,Top and Bottom
* sashes around this tree and set them
* in <code>sashes</code>
*/
virtual void FindSashes(PartPane::Sashes sashes);
/**
* Find the part that is in the bottom right position.
*/
virtual LayoutPart::Pointer FindBottomRight();
/**
* Find a sash in the tree and return its sub-tree. Returns
* null if the sash is not found.
*/
virtual SmartPointer<LayoutTreeNode> FindSash(SmartPointer<LayoutPartSash> sash);
/**
* Return the bounds of this tree which is the rectangle that
* contains all Controls in this tree.
*/
Rectangle GetBounds();
/**
* Subtracts two integers. If a is INF, this is treated as
* positive infinity.
*
* @param a a positive integer or INF indicating positive infinity
* @param b a positive integer (may not be INF)
* @return a - b, or INF if a == INF
* @since 3.1
*/
static int Subtract(int a, int b);
/**
* Adds two positive integers. Treates INF as positive infinity.
*
* @param a a positive integer
* @param b a positive integer
* @return a + b, or INF if a or b are positive infinity
* @since 3.1
*/
static int Add(int a, int b);
/**
* Asserts that toCheck is a positive integer less than INF / 2 or equal
* to INF. Many of the methods of this class use positive integers as sizes,
* with INF indicating positive infinity. This picks up accidental addition or
* subtraction from infinity.
*
* @param toCheck integer to validate
* @since 3.1
*/
static void AssertValidSize(int toCheck);
/**
* Computes the preferred size for this object. The interpretation of the result depends on the flags returned
* by getSizeFlags(). If the caller is looking for a maximum or minimum size, this delegates to computeMinimumSize
* or computeMaximumSize in order to benefit from caching optimizations. Otherwise, it delegates to
* doComputePreferredSize. Subclasses should overload one of doComputeMinimumSize, doComputeMaximumSize, or
* doComputePreferredSize to specialize the return value.
*
* @see LayoutPart#computePreferredSize(boolean, int, int, int)
*/
int ComputePreferredSize(bool width, int availableParallel,
int availablePerpendicular, int preferredParallel);
protected:
/**
* Returns the size flags for this tree.
*
* @see org.blueberry.ui.presentations.StackPresentation#getSizeFlags(boolean)
*
* @param b indicates whether the caller wants the flags for computing widths (=true) or heights (=false)
* @return a bitwise combiniation of flags with the same meaning as StackPresentation.getSizeFlags(boolean)
*/
virtual int DoGetSizeFlags(bool width);
/**
* Subclasses should overload this method instead of computePreferredSize(boolean, int, int, int)
*
* @see org.blueberry.ui.presentations.StackPresentation#computePreferredSize(boolean, int, int, int)
*
* @since 3.1
*/
virtual int DoComputePreferredSize(bool width, int availableParallel,
int availablePerpendicular, int preferredParallel);
public:
/**
* Returns the minimum size for this subtree. Equivalent to calling
* computePreferredSize(width, INF, availablePerpendicular, 0).
* Returns a cached value if possible or defers to doComputeMinimumSize otherwise.
* Subclasses should overload doComputeMinimumSize if they want to specialize the
* return value.
*
* @param width true iff computing the minimum width, false iff computing the minimum height
* @param availablePerpendicular available space (pixels) perpendicular to the dimension
* being computed. This is a height when computing a width, or a width when computing a height.
*
* @see LayoutPart#computePreferredSize(boolean, int, int, int)
*/
int ComputeMinimumSize(bool width, int availablePerpendicular);
/**
* For use in benchmarks and test suites only. Displays cache utilization statistics for all
* LayoutTree instances.
*
* @since 3.1
*/
static void PrintCacheStatistics();
virtual int DoComputeMinimumSize(bool width, int availablePerpendicular);
int ComputeMaximumSize(bool width, int availablePerpendicular);
protected:
virtual int DoComputeMaximumSize(bool width, int availablePerpendicular);
public:
/**
* Called to flush any cached information in this tree and its parents.
*/
virtual void FlushNode();
/**
* Flushes all cached information about this node and all of its children.
* This should be called if something may have caused all children to become
* out of synch with their cached information (for example, if a lot of changes
* may have happened without calling flushCache after each change)
*
* @since 3.1
*/
virtual void FlushChildren();
/**
* Flushes all cached information about this node and all of its ancestors.
* This should be called when a single child changes.
*
* @since 3.1
*/
void FlushCache();
int GetSizeFlags(bool width);
/**
* Returns the parent of this tree or null if it is the root.
*/
virtual LayoutTreeNode* GetParent() const;
/**
* Inserts a new child on the tree. The child will be placed beside
* the <code>relative</code> child. Returns the new root of the tree.
*/
virtual SmartPointer<LayoutTree> Insert(LayoutPart::Pointer child, bool left,
SmartPointer<LayoutPartSash> sash, SmartPointer<LayoutPart> relative);
/**
* Returns true if this tree can be compressed and expanded.
* @return true if springy
*/
virtual bool IsCompressible();
/**
* Returns true if this tree has visible parts otherwise returns false.
*/
virtual bool IsVisible();
/**
* Recompute the ratios in this tree.
*/
virtual void RecomputeRatio();
/**
* Find a child in the tree and remove it and its parent.
* The other child of its parent is placed on the parent's parent.
* Returns the new root of the tree.
*/
virtual SmartPointer<LayoutTree> Remove(LayoutPart::Pointer child);
/**
* Sets the bounds of this node. If the bounds have changed or any children have
* changed then the children will be recursively layed out. This implementation
* filters out redundant calls and delegates to doSetBounds to layout the children.
* Subclasses should overload doSetBounds to lay out their children.
*
* @param bounds new bounds of the tree
*/
void SetBounds(const Rectangle& bounds);
protected:
/**
* Resize the parts on this tree to fit in <code>bounds</code>.
*/
virtual void DoSetBounds(const Rectangle& bounds);
public:
/**
* Set the parent of this tree.
*/
virtual void SetParent(LayoutTreeNode* parent);
/**
* Set the part of this leaf
*/
virtual void SetPart(LayoutPart::Pointer part);
/**
* Returns a string representation of this object.
*/
virtual std::string ToString();
/**
* Creates SWT controls owned by the LayoutTree (ie: the sashes). Does not affect the
* LayoutParts that are being arranged by the LayoutTree.
*
* @param parent
* @since 3.1
*/
virtual void CreateControl(void* parent);
/**
* Writes a description of the layout to the given string buffer.
* This is used for drag-drop test suites to determine if two layouts are the
* same. Like a hash code, the description should compare as equal iff the
* layouts are the same. However, it should be user-readable in order to
* help debug failed tests. Although these are english readable strings,
* they should not be translated or equality tests will fail.
* <p>
* This is only intended for use by test suites.
* </p>
*
* @param buf
*/
virtual void DescribeLayout(std::string& buf) const;
/**
* This is a shorthand method that checks if the tree contains the
* given size flag. For example, hasSizeFlag(false, SWT.MIN) returns
* true iff the receiver enforces a minimum height, or
* hasSizeFlag(true, SWT.WRAP) returns true iff the receiver needs to
* know its height when computing its preferred width.
*
* @param vertical
* @return
* @since 3.1
*/
bool HasSizeFlag(bool width, int flag);
};
}
#endif /*BERRYLAYOUTTREE_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryLayoutTreeNode.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryLayoutTreeNode.cpp
index 29838a59b3..d6eb7447cf 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryLayoutTreeNode.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryLayoutTreeNode.cpp
@@ -1,717 +1,717 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryLayoutTreeNode.h"
#include "berryConstants.h"
#include "berryIPageLayout.h"
#include <sstream>
namespace berry
{
LayoutTreeNode::ChildSizes::ChildSizes (int l, int r, bool resize)
{
left = l;
right = r;
resizable = resize;
}
LayoutTreeNode::LayoutTreeNode(LayoutPartSash::Pointer sash)
: LayoutTree(sash)
{
children[0] = 0;
children[1] = 0;
}
LayoutTreeNode::~LayoutTreeNode()
{
}
void LayoutTreeNode::FlushChildren()
{
LayoutTree::FlushChildren();
children[0]->FlushChildren();
children[1]->FlushChildren();
}
LayoutPart::Pointer LayoutTreeNode::FindPart(const Point& toFind)
{
if (!children[0]->IsVisible())
{
if (!children[1]->IsVisible())
{
return LayoutPart::Pointer(0);
}
return children[1]->FindPart(toFind);
}
else
{
if (!children[1]->IsVisible())
{
return children[0]->FindPart(toFind);
}
}
LayoutPartSash::Pointer sash = this->GetSash();
Rectangle bounds = sash->GetBounds();
if (sash->IsVertical())
{
if (toFind.x < bounds.x + (bounds.width / 2))
{
return children[0]->FindPart(toFind);
}
return children[1]->FindPart(toFind);
}
else
{
if (toFind.y < bounds.y + (bounds.height / 2))
{
return children[0]->FindPart(toFind);
}
return children[1]->FindPart(toFind);
}
}
LayoutPart::Pointer LayoutTreeNode::ComputeRelation(
std::list<PartSashContainer::RelationshipInfo>& relations)
{
PartSashContainer::RelationshipInfo r =
PartSashContainer::RelationshipInfo();
r.relative = children[0]->ComputeRelation(relations);
r.part = children[1]->ComputeRelation(relations);
r.left = this->GetSash()->GetLeft();
r.right = this->GetSash()->GetRight();
r.relationship = this->GetSash()->IsVertical() ? IPageLayout::RIGHT : IPageLayout::BOTTOM;
relations.push_front(r);
return r.relative;
}
void LayoutTreeNode::DisposeSashes()
{
children[0]->DisposeSashes();
children[1]->DisposeSashes();
this->GetSash()->Dispose();
}
LayoutTree::Pointer LayoutTreeNode::Find(LayoutPart::Pointer child)
{
LayoutTree::Pointer node = children[0]->Find(child);
if (node != 0)
{
return node;
}
node = children[1]->Find(child);
return node;
}
LayoutPart::Pointer LayoutTreeNode::FindBottomRight()
{
if (children[1]->IsVisible())
{
return children[1]->FindBottomRight();
}
return children[0]->FindBottomRight();
}
LayoutTreeNode* LayoutTreeNode::FindCommonParent(LayoutPart::Pointer child1,
LayoutPart::Pointer child2, bool foundChild1,
bool foundChild2)
{
if (!foundChild1)
{
foundChild1 = this->Find(child1) != 0;
}
if (!foundChild2)
{
foundChild2 = this->Find(child2) != 0;
}
if (foundChild1 && foundChild2)
{
return this;
}
if (parent == 0)
{
return 0;
}
return parent
->FindCommonParent(child1, child2, foundChild1, foundChild2);
}
LayoutTreeNode::Pointer LayoutTreeNode::FindSash(LayoutPartSash::Pointer sash)
{
if (this->GetSash() == sash)
{
return LayoutTreeNode::Pointer(this);
}
LayoutTreeNode::Pointer node = children[0]->FindSash(sash);
if (node != 0)
{
return node;
}
node = children[1]->FindSash(sash);
if (node != 0)
{
return node;
}
return LayoutTreeNode::Pointer(0);
}
void LayoutTreeNode::FindSashes(LayoutTree::Pointer child, PartPane::Sashes sashes)
{
void* sash = this->GetSash()->GetControl();
bool leftOrTop = children[0] == child;
if (sash != 0)
{
LayoutPartSash::Pointer partSash = this->GetSash();
//If the child is in the left, the sash
//is in the rigth and so on.
if (leftOrTop)
{
if (partSash->IsVertical())
{
if (sashes.right == 0)
{
sashes.right = sash;
}
}
else
{
if (sashes.bottom == 0)
{
sashes.bottom = sash;
}
}
}
else
{
if (partSash->IsVertical())
{
if (sashes.left == 0)
{
sashes.left = sash;
}
}
else
{
if (sashes.top == 0)
{
sashes.top = sash;
}
}
}
}
if (this->GetParent() != 0)
{
this->GetParent()->FindSashes(LayoutTree::Pointer(this), sashes);
}
}
LayoutPartSash::Pointer LayoutTreeNode::GetSash() const
{
return part.Cast<LayoutPartSash>();
}
int LayoutTreeNode::GetSashSize() const
{
return this->GetSash()->GetSashSize();
}
bool LayoutTreeNode::IsVisible()
{
return children[0]->IsVisible() || children[1]->IsVisible();
}
LayoutTree::Pointer LayoutTreeNode::Remove(LayoutTree::Pointer child)
{
this->GetSash()->Dispose();
if (parent == 0)
{
//This is the root. Return the other child to be the new root.
if (children[0] == child)
{
children[1]->SetParent(0);
return children[1];
}
children[0]->SetParent(0);
return children[0];
}
LayoutTreeNode::Pointer oldParent(parent);
if (children[0] == child)
{
oldParent->ReplaceChild(LayoutTree::Pointer(this), children[1]);
}
else
{
oldParent->ReplaceChild(LayoutTree::Pointer(this), children[0]);
}
return oldParent;
}
void LayoutTreeNode::ReplaceChild(LayoutTree::Pointer oldChild, LayoutTree::Pointer newChild)
{
if (children[0] == oldChild)
{
children[0] = newChild;
}
else if (children[1] == oldChild)
{
children[1] = newChild;
}
newChild->SetParent(this);
if (!children[0]->IsVisible() || !children[0]->IsVisible())
{
this->GetSash()->Dispose();
}
this->FlushCache();
}
bool LayoutTreeNode::SameDirection(bool isVertical, LayoutTreeNode::Pointer subTree)
{
bool treeVertical = this->GetSash()->IsVertical();
if (treeVertical != isVertical)
{
return false;
}
while (subTree != 0)
{
if (this == subTree.GetPointer())
{
return true;
}
if (subTree->children[0]->IsVisible() && subTree->children[1]->IsVisible())
{
if (subTree->GetSash()->IsVertical() != isVertical)
{
return false;
}
}
subTree = subTree->GetParent();
}
return true;
}
int LayoutTreeNode::DoComputePreferredSize(bool width, int availableParallel,
int availablePerpendicular, int preferredParallel)
{
this->AssertValidSize(availablePerpendicular);
this->AssertValidSize(availableParallel);
this->AssertValidSize(preferredParallel);
// If one child is invisible, defer to the other child
if (!children[0]->IsVisible())
{
return children[1]->ComputePreferredSize(width, availableParallel,
availablePerpendicular, preferredParallel);
}
if (!children[1]->IsVisible())
{
return children[0]->ComputePreferredSize(width, availableParallel,
availablePerpendicular, preferredParallel);
}
if (availableParallel == 0)
{
return 0;
}
// If computing the dimension perpendicular to our sash
if (width == this->GetSash()->IsVertical())
{
// Compute the child sizes
ChildSizes sizes = this->ComputeChildSizes(availableParallel,
availablePerpendicular,
GetSash()->GetLeft(), GetSash()->GetRight(), preferredParallel);
// Return the sum of the child sizes plus the sash size
return this->Add(sizes.left, this->Add(sizes.right, this->GetSashSize()));
}
else
{
// Computing the dimension parallel to the sash. We will compute and return the preferred size
// of whichever child is closest to the ideal size.
// First compute the dimension of the child sizes perpendicular to the sash
ChildSizes sizes = this->ComputeChildSizes(availablePerpendicular, availableParallel,
GetSash()->GetLeft(), GetSash()->GetRight(), availablePerpendicular);
// Use this information to compute the dimension of the child sizes parallel to the sash.
// Return the preferred size of whichever child is largest
int leftSize = children[0]->ComputePreferredSize(width, availableParallel,
sizes.left, preferredParallel);
// Compute the preferred size of the right child
int rightSize = children[1]->ComputePreferredSize(width, availableParallel,
sizes.right, preferredParallel);
// Return leftSize or rightSize: whichever one is largest
int result = rightSize;
if (leftSize > rightSize)
{
result = leftSize;
}
this->AssertValidSize(result);
return result;
}
}
LayoutTreeNode::ChildSizes LayoutTreeNode::ComputeChildSizes(int width, int height, int left,
int right, int preferredWidth)
{
poco_assert(children[0]->IsVisible());
poco_assert(children[1]->IsVisible());
this->AssertValidSize(width);
this->AssertValidSize(height);
this->AssertValidSize(preferredWidth);
poco_assert(left >= 0);
poco_assert(right >= 0);
poco_assert(preferredWidth >= 0);
poco_assert(preferredWidth <= width);
bool vertical = this->GetSash()->IsVertical();
if (width <= this->GetSashSize())
{
return ChildSizes(0,0, false);
}
if (width == INF)
{
if (preferredWidth == INF)
{
return ChildSizes(children[0]->ComputeMaximumSize(vertical, height),
children[1]->ComputeMaximumSize(vertical, height), false);
}
if (preferredWidth == 0)
{
return ChildSizes(children[0]->ComputeMinimumSize(vertical, height),
children[1]->ComputeMinimumSize(vertical, height), false);
}
}
int total = left + right;
// Use all-or-none weighting
double wLeft = left, wRight = right;
switch (this->GetCompressionBias())
{
case -1:
wLeft = 0.0;
break;
case 1:
wRight = 0.0;
break;
default:
break;
}
double wTotal = wLeft + wRight;
// Subtract the SASH_WIDTH from preferredWidth and width. From here on, we'll deal with the
// width available to the controls and neglect the space used by the sash.
preferredWidth = std::max<int>(0, this->Subtract(preferredWidth, this->GetSashSize()));
width = std::max<int>(0, this->Subtract(width, this->GetSashSize()));
int redistribute = this->Subtract(preferredWidth, total);
// Compute the minimum and maximum sizes for each child
int leftMinimum = children[0]->ComputeMinimumSize(vertical, height);
int rightMinimum = children[1]->ComputeMinimumSize(vertical, height);
int leftMaximum = children[0]->ComputeMaximumSize(vertical, height);
int rightMaximum = children[1]->ComputeMaximumSize(vertical, height);
int idealLeft = 0;
int idealRight = 0;
if (PartSashContainer::leftToRight)
{
// Keep track of the available space for each child, given the minimum size of the other child
int leftAvailable = std::min<int>(leftMaximum, std::max<int>(0, this->Subtract(width,
rightMinimum)));
int rightAvailable = std::min<int>(rightMaximum, std::max<int>(0, this->Subtract(width,
leftMinimum)));
// Figure out the ideal size of the left child
idealLeft = std::max<int>(leftMinimum, std::min<int>(preferredWidth, left
+ (int)(redistribute * wLeft / wTotal)));
// If the right child can't use all its available space, let the left child fill it in
idealLeft = std::max<int>(idealLeft, preferredWidth - rightAvailable);
// Ensure the left child doesn't get larger than its available space
idealLeft = std::min<int>(idealLeft, leftAvailable);
// Check if the left child would prefer to be a different size
idealLeft = children[0]->ComputePreferredSize(vertical, leftAvailable, height,
idealLeft);
// Ensure that the left child is larger than its minimum size
idealLeft = std::max<int>(idealLeft, leftMinimum);
idealLeft = std::min<int>(idealLeft, leftAvailable);
// Compute the right child width
idealRight = std::max<int>(rightMinimum, preferredWidth - idealLeft);
rightAvailable = std::max<int>(0, std::min<int>(rightAvailable, this->Subtract(width,
idealLeft)));
idealRight = std::min<int>(idealRight, rightAvailable);
idealRight = children[1]->ComputePreferredSize(vertical, rightAvailable,
height, idealRight);
idealRight = std::max<int>(idealRight, rightMinimum);
}
else
{
// Keep track of the available space for each child, given the minimum size of the other child
int rightAvailable = std::min<int>(rightMaximum, std::max<int>(0, this->Subtract(width,
leftMinimum)));
int leftAvailable = std::min<int>(leftMaximum, std::max<int>(0, this->Subtract(width,
rightMinimum)));
// Figure out the ideal size of the right child
idealRight = std::max<int>(rightMinimum, std::min<int>(preferredWidth, right
+ (int)(redistribute * wRight / wTotal)));
// If the left child can't use all its available space, let the right child fill it in
idealRight = std::max<int>(idealRight, preferredWidth - leftAvailable);
// Ensure the right child doesn't get larger than its available space
idealRight = std::min<int>(idealRight, rightAvailable);
// Check if the right child would prefer to be a different size
idealRight = children[1]->ComputePreferredSize(vertical, rightAvailable, height,
idealRight);
// Ensure that the right child is larger than its minimum size
idealRight = std::max<int>(idealRight, rightMinimum);
idealRight = std::min<int>(idealRight, rightAvailable);
// Compute the left child width
idealLeft = std::max<int>(leftMinimum, preferredWidth - idealRight);
leftAvailable = std::max<int>(0, std::min<int>(leftAvailable, this->Subtract(width,
idealRight)));
idealLeft = std::min<int>(idealLeft, leftAvailable);
idealLeft = children[0]->ComputePreferredSize(vertical, leftAvailable,
height, idealLeft);
idealLeft = std::max<int>(idealLeft, leftMinimum);
}
return ChildSizes(idealLeft, idealRight, leftMaximum> leftMinimum
&& rightMaximum> rightMinimum
&& leftMinimum + rightMinimum < width);
}
int LayoutTreeNode::DoGetSizeFlags(bool width)
{
if (!children[0]->IsVisible())
{
return children[1]->GetSizeFlags(width);
}
if (!children[1]->IsVisible())
{
return children[0]->GetSizeFlags(width);
}
int leftFlags = children[0]->GetSizeFlags(width);
int rightFlags = children[1]->GetSizeFlags(width);
return ((leftFlags | rightFlags) & ~Constants::MAX) | (leftFlags & rightFlags
& Constants::MAX);
}
void LayoutTreeNode::DoSetBounds(const Rectangle& b)
{
if (!children[0]->IsVisible())
{
children[1]->SetBounds(b);
this->GetSash()->SetVisible(false);
return;
}
if (!children[1]->IsVisible())
{
children[0]->SetBounds(b);
this->GetSash()->SetVisible(false);
return;
}
Rectangle bounds = b;
bool vertical = this->GetSash()->IsVertical();
// If this is a horizontal sash, flip coordinate systems so
// that we can eliminate special cases
if (!vertical)
{
bounds.FlipXY();
}
ChildSizes childSizes = this->ComputeChildSizes(bounds.width, bounds.height,
this->GetSash()->GetLeft(), this->GetSash()->GetRight(), bounds.width);
this->GetSash()->SetVisible(true);
this->GetSash()->SetEnabled(childSizes.resizable);
Rectangle leftBounds = Rectangle(bounds.x, bounds.y, childSizes.left, bounds.height);
Rectangle sashBounds = Rectangle(leftBounds.x + leftBounds.width, bounds.y, this->GetSashSize(), bounds.height);
Rectangle
rightBounds =
Rectangle(sashBounds.x + sashBounds.width, bounds.y, childSizes.right, bounds.height);
if (!vertical)
{
leftBounds.FlipXY();
sashBounds.FlipXY();
rightBounds.FlipXY();
}
this->GetSash()->SetBounds(sashBounds);
children[0]->SetBounds(leftBounds);
children[1]->SetBounds(rightBounds);
}
void LayoutTreeNode::CreateControl(void* parent)
{
children[0]->CreateControl(parent);
children[1]->CreateControl(parent);
this->GetSash()->CreateControl(parent);
LayoutTree::CreateControl(parent);
}
bool LayoutTreeNode::IsCompressible()
{
return children[0]->IsCompressible() || children[1]->IsCompressible();
}
int LayoutTreeNode::GetCompressionBias()
{
bool left = children[0]->IsCompressible();
bool right = children[1]->IsCompressible();
if (left == right)
{
return 0;
}
if (right)
{
return -1;
}
return 1;
}
bool LayoutTreeNode::IsLeftChild(LayoutTree::ConstPointer toTest)
{
return children[0] == toTest;
}
LayoutTree::Pointer LayoutTreeNode::GetChild(bool left)
{
int index = left ? 0 : 1;
return (children[index]);
}
void LayoutTreeNode::SetChild(bool left, LayoutPart::Pointer part)
{
LayoutTree::Pointer child(new LayoutTree(part));
this->SetChild(left, child);
this->FlushCache();
}
void LayoutTreeNode::SetChild(bool left, LayoutTree::Pointer child)
{
int index = left ? 0 : 1;
children[index] = child;
child->SetParent(this);
this->FlushCache();
}
std::string LayoutTreeNode::ToString()
{
std::stringstream s;
s << "<null>\n";
if (part->GetControl() != 0)
{
s << "<@" << part->GetControl() << ">\n";//$NON-NLS-2$//$NON-NLS-1$
}
std::stringstream result;
result << "["; //$NON-NLS-1$
if (children[0]->GetParent() != this)
{
result << result.str() << "{" << children[0] << "}" << s.str();//$NON-NLS-2$//$NON-NLS-1$
}
else
{
result << result.str() << children[0] << s.str();
}
if (children[1]->GetParent() != this)
{
result << result.str() << "{" << children[1] << "}]";//$NON-NLS-2$//$NON-NLS-1$
}
else
{
result << result.str() << children[1] << "]";//$NON-NLS-1$
}
return result.str();
}
//void LayoutTreeNode::UpdateSashes(void* parent) {
// if (parent == 0)
// return;
// children[0]->UpdateSashes(parent);
// children[1]->UpdateSashes(parent);
// if (children[0]->IsVisible() && children[1]->IsVisible())
// this->GetSash()->CreateControl(parent);
// else
// this->GetSash()->Dispose();
// }
void LayoutTreeNode::DescribeLayout(std::string& buf) const
{
if (!(children[0]->IsVisible()))
{
if (!children[1]->IsVisible())
{
return;
}
children[1]->DescribeLayout(buf);
return;
}
if (!children[1]->IsVisible())
{
children[0]->DescribeLayout(buf);
return;
}
buf.append("("); //$NON-NLS-1$
children[0]->DescribeLayout(buf);
buf.append(this->GetSash()->IsVertical() ? "|" : "-"); //$NON-NLS-1$ //$NON-NLS-2$
children[1]->DescribeLayout(buf);
buf.append(")"); //$NON-NLS-1$
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryLayoutTreeNode.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryLayoutTreeNode.h
index 6c9cbdb7dc..a083faf856 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryLayoutTreeNode.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryLayoutTreeNode.h
@@ -1,222 +1,222 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYLAYOUTTREENODE_H_
#define BERRYLAYOUTTREENODE_H_
#include "berryLayoutTree.h"
#include "berryLayoutPartSash.h"
namespace berry {
/**
* \ingroup org_blueberry_ui_internal
*
* Implementation of a tree node. The node represents a
* sash and it allways has two children.
*/
class LayoutTreeNode : public LayoutTree {
public:
berryObjectMacro(LayoutTreeNode);
struct ChildSizes {
int left;
int right;
bool resizable;
ChildSizes (int l, int r, bool resize);
};
/* The node children witch may be another node or a leaf */
private: LayoutTree::Pointer children[2];
/**
* Initialize this tree with its sash.
*/
public: LayoutTreeNode(LayoutPartSash::Pointer sash);
public: ~LayoutTreeNode();
/* (non-Javadoc)
* @see org.blueberry.ui.internal.LayoutTree#flushChildren()
*/
public: void FlushChildren();
/**
* Traverses the tree to find the part that intersects the given point
*
* @param toFind
* @return the part that intersects the given point
*/
public: LayoutPart::Pointer FindPart(const Point& toFind);
/**
* Add the relation ship between the children in the list
* and returns the left children.
*/
public: LayoutPart::Pointer ComputeRelation(std::list<PartSashContainer::RelationshipInfo>& relations);
/**
* Dispose all Sashs in this tree
*/
public: void DisposeSashes();
/**
* Find a LayoutPart in the tree and return its sub-tree. Returns
* null if the child is not found.
*/
public: SmartPointer<LayoutTree> Find(LayoutPart::Pointer child);
/**
* Find the part that is in the bottom right position.
*/
public: LayoutPart::Pointer FindBottomRight();
/**
* Go up in the tree finding a parent that is common of both children.
* Return the subtree.
*/
LayoutTreeNode* FindCommonParent(LayoutPart::Pointer child1, LayoutPart::Pointer child2,
bool foundChild1 = false, bool foundChild2 = false);
/**
* Find a sash in the tree and return its sub-tree. Returns
* null if the sash is not found.
*/
public: SmartPointer<LayoutTreeNode> FindSash(LayoutPartSash::Pointer sash);
/**
* Sets the elements in the array of sashes with the
* Left,Rigth,Top and Botton sashes. The elements
* may be null depending whether there is a shash
* beside the <code>part</code>
*/
void FindSashes(SmartPointer<LayoutTree> child, PartPane::Sashes sashes);
/**
* Returns the sash of this node.
*/
public: LayoutPartSash::Pointer GetSash() const;
private: int GetSashSize() const;
/**
* Returns true if this tree has visible parts otherwise returns false.
*/
public: bool IsVisible();
/**
* Remove the child and this node from the tree
*/
SmartPointer<LayoutTree> Remove(SmartPointer<LayoutTree> child);
/**
* Replace a child with a new child and sets the new child's parent.
*/
void ReplaceChild(SmartPointer<LayoutTree> oldChild, SmartPointer<LayoutTree> newChild);
/**
* Go up from the subtree and return true if all the sash are
* in the direction specified by <code>isVertical</code>
*/
public: bool SameDirection(bool isVertical, SmartPointer<LayoutTreeNode> subTree);
public: int DoComputePreferredSize(bool width, int availableParallel, int availablePerpendicular, int preferredParallel);
/**
* Computes the pixel sizes of this node's children, given the available
* space for this node. Note that "width" and "height" actually refer
* to the distance perpendicular and parallel to the sash respectively.
* That is, their meaning is reversed when computing a horizontal sash.
*
* @param width the pixel width of a vertical node, or the pixel height
* of a horizontal node (INF if unbounded)
* @param height the pixel height of a vertical node, or the pixel width
* of a horizontal node (INF if unbounded)
* @return a struct describing the pixel sizes of the left and right children
* (this is a width for horizontal nodes and a height for vertical nodes)
*/
ChildSizes ComputeChildSizes(int width, int height, int left, int right, int preferredWidth);
protected: int DoGetSizeFlags(bool width);
/**
* Resize the parts on this tree to fit in <code>bounds</code>.
*/
public: void DoSetBounds(const Rectangle& bounds);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.LayoutTree#createControl(org.blueberry.swt.widgets.Composite)
*/
public: void CreateControl(void* parent);
//Added by hudsonr@us.ibm.com - bug 19524
public: bool IsCompressible();
/**
* Returns 0 if there is no bias. Returns -1 if the first child should be of
* fixed size, and the second child should be compressed. Returns 1 if the
* second child should be of fixed size.
* @return the bias
*/
public: int GetCompressionBias();
bool IsLeftChild(SmartPointer<const LayoutTree> toTest);
SmartPointer<LayoutTree> GetChild(bool left);
/**
* Sets a child in this node
*/
void SetChild(bool left, LayoutPart::Pointer part);
/**
* Sets a child in this node
*/
void SetChild(bool left, SmartPointer<LayoutTree> child);
/**
* Returns a string representation of this object.
*/
public: std::string ToString();
/**
* Create the sashes if the children are visible
* and dispose it if they are not.
*/
//public: void UpdateSashes(void* parent);
/**
* Writes a description of the layout to the given string buffer.
* This is used for drag-drop test suites to determine if two layouts are the
* same. Like a hash code, the description should compare as equal iff the
* layouts are the same. However, it should be user-readable in order to
* help debug failed tests. Although these are english readable strings,
* they should not be translated or equality tests will fail.
*
* @param buf
*/
public: void DescribeLayout(std::string& buf) const;
};
}
#endif /*BERRYLAYOUTTREENODE_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryNullEditorInput.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryNullEditorInput.cpp
index fb8f53000b..ba8f17f672 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryNullEditorInput.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryNullEditorInput.cpp
@@ -1,61 +1,61 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryNullEditorInput.h"
#include "berryPartPane.h"
namespace berry
{
NullEditorInput::NullEditorInput()
{
}
NullEditorInput::NullEditorInput(EditorReference::Pointer editorReference)
{
//poco_assert(editorReference.IsNotNull());
this->editorReference = editorReference;
}
bool NullEditorInput::Exists() const
{
return false;
}
std::string NullEditorInput::GetName() const
{
if (editorReference.IsNotNull())
return editorReference->GetName();
return ""; //$NON-NLS-1$
}
std::string NullEditorInput::GetToolTipText() const
{
if (editorReference.IsNotNull())
return editorReference->GetTitleToolTip();
return ""; //$NON-NLS-1$
}
bool NullEditorInput::operator==(const Object* o) const
{
const NullEditorInput* input = dynamic_cast<const NullEditorInput*>(o);
if (input == 0) return false;
return true;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryNullEditorInput.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryNullEditorInput.h
index b5fb50994e..48ee6729f6 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryNullEditorInput.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryNullEditorInput.h
@@ -1,76 +1,76 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYNULLEDITORINPUT_H_
#define BERRYNULLEDITORINPUT_H_
#include "berryIEditorInput.h"
#include "berryEditorReference.h"
namespace berry {
/**
* \ingroup org_blueberry_ui_internal
*
*/
class NullEditorInput : public IEditorInput {
private: EditorReference::Pointer editorReference;
public:
berryObjectMacro(NullEditorInput)
NullEditorInput();
/**
* Creates a <code>NullEditorInput</code> for the
* given editor reference.
*
* @param editorReference the editor reference
* @since 3.4
*/
NullEditorInput(EditorReference::Pointer editorReference);
/* (non-Javadoc)
* @see org.blueberry.ui.IEditorInput#exists()
*/
bool Exists() const;
/* (non-Javadoc)
* @see org.blueberry.ui.IEditorInput#getImageDescriptor()
*/
// ImageDescriptor getImageDescriptor() {
// return ImageDescriptor.getMissingImageDescriptor();
// }
/* (non-Javadoc)
* @see org.blueberry.ui.IEditorInput#getName()
*/
std::string GetName() const;
/* (non-Javadoc)
* @see org.blueberry.ui.IEditorInput#getToolTipText()
*/
std::string GetToolTipText() const;
bool operator==(const Object* o) const;
};
}
#endif /*BERRYNULLEDITORINPUT_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPageLayout.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPageLayout.cpp
index e6a28c817e..61c087d3c4 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPageLayout.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPageLayout.cpp
@@ -1,689 +1,689 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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.
// StackablePart::Pointer newPart = this->CreateView(ID_EDITOR_AREA);
// if (newPart == 0)
// {
// // this should never happen as long as newID is the editor ID.
// return;
// }
//
// this->SetFolderPart(ID_EDITOR_AREA, editorFolder.Cast<ILayoutContainer>());
// Add it to the layout.
rootLayoutContainer->Add(editorFolder);
}
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::AddStack(IStackableContainer::Pointer newPart,
const std::string& partId, int relationship, float ratio,
const std::string& refId)
{
//this->SetRefPart(partId, newPart);
this->SetFolderPart(partId, newPart);
// If the referenced part is inside a folder,
// then use the folder as the reference part.
IStackableContainer::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.Cast<LayoutPart>(), this->GetPartSashConst(relationship), ratio,
refPart.Cast<LayoutPart>());
}
else if (refId == ID_EDITOR_AREA)
{
ratio = this->NormalizeRatio(ratio);
rootLayoutContainer->Add(newPart.Cast<LayoutPart>(), this->GetPartSashConst(relationship), ratio,
this->editorFolder.Cast<LayoutPart>());
}
else
{
WorkbenchPlugin::Log("Reference part does not exist yet: " + refId);
rootLayoutContainer->Add(newPart.Cast<LayoutPart>());
}
}
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 a folder.
ContainerPlaceholder::Pointer folder(new ContainerPlaceholder(viewId));
folder->SetContainer(rootLayoutContainer);
folder->SetRealContainer(PartStack::Pointer(new PartStack(rootLayoutContainer->page)));
//folder->SetId(folderId);
// Create the placeholder.
PartPlaceholder::Pointer newPart(new PartPlaceholder(viewId));
folder->Add(newPart);
this->AddStack(folder, 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())
{
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)
{
if (this->CheckPartInLayout(viewId))
{
return;
}
try
{
// Create the part.
StackablePart::Pointer newPart = this->CreateView(viewId);
if (newPart == 0)
{
this->AddPlaceholder(viewId, relationship, ratio, refId);
//TODO ViewActivator for IIdentifier
//LayoutHelper::AddViewActivator(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->AddStack(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))
{
IStackableContainer::Pointer folder = this->GetFolderPart(folderId);
return mapFolderToFolderLayout[folder].Cast<IFolderLayout>();
}
// Create the folder.
PartStack::Pointer folder(new PartStack(rootLayoutContainer->page));
folder->SetID(folderId);
this->AddStack(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<ContainerPlaceholder>();
return mapFolderToFolderLayout[folder];
}
// Create the folder.
ContainerPlaceholder::Pointer folder(new ContainerPlaceholder(""));
folder->SetContainer(rootLayoutContainer);
folder->SetRealContainer(IStackableContainer::Pointer(new PartStack(rootLayoutContainer->page)));
folder->SetID(folderId);
this->AddStack(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;
}
StackablePart::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;
}
IStackableContainer::Pointer PageLayout::GetFolderPart(const std::string& viewId)
{
return mapIDtoFolder[viewId];
}
int PageLayout::GetPartSashConst(int nRelationship)
{
return nRelationship;
}
std::vector<std::string> PageLayout::GetPerspectiveShortcuts()
{
return perspectiveShortcuts;
}
StackablePart::Pointer PageLayout::GetRefPart(const std::string& partID)
{
return mapIDtoPart[partID];
}
PartSashContainer::Pointer PageLayout::GetRootLayoutContainer()
{
return rootLayoutContainer;
}
std::vector<std::string> PageLayout::GetShowInPartIds()
{
return showInPartIds;
}
std::vector<std::string> 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)
{
IStackableContainer::Pointer tabFolder = container->GetRealContainer();
mapIDtoFolder[viewId] = tabFolder;
}
void PageLayout::SetFolderPart(const std::string& viewId,
PartStack::Pointer folder)
{
mapIDtoFolder[viewId] = folder.Cast<IStackableContainer>();
}
void PageLayout::SetFolderPart(const std::string& viewId,
IStackableContainer::Pointer folder)
{
mapIDtoFolder[viewId] = folder;
}
void PageLayout::SetRefPart(const std::string& partID, StackablePart::Pointer part)
{
mapIDtoPart[partID] = part;
}
void PageLayout::StackPart(StackablePart::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<PartStack>();
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.
// StackablePart::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));
StackablePart::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
{
StackablePart::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(IStackableContainer::Pointer(new PartStack(rootLayoutContainer->page, true,
appearance, 0)));
folder->SetID(stackId);
this->AddStack(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<std::string, ViewLayoutRec::Pointer> PageLayout::GetIDtoViewLayoutRecMap()
{
return mapIDtoViewLayoutRec;
}
void PageLayout::RemovePlaceholder(const std::string& id)
{
StackablePart::Pointer part = this->GetRefPart(id);
if (part->IsPlaceHolder())
{
IStackableContainer::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);
IStackableContainer::Pointer folder = mapIDtoFolder[viewId];
IPlaceholderFolderLayout::Pointer layout;
if (mapFolderToFolderLayout[folder] == 0)
{
layout = new FolderLayout(PageLayout::Pointer(this), folder.Cast<PartStack>(), viewFactory);
mapFolderToFolderLayout[folder] = layout;
}
else
{
layout = mapFolderToFolderLayout[folder];
}
return layout;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPageLayout.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPageLayout.h
index c4eb39f576..8a62c39cec 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPageLayout.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPageLayout.h
@@ -1,586 +1,586 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYPAGELAYOUT_H_
#define BERRYPAGELAYOUT_H_
#include "berryIPageLayout.h"
#include "berryViewLayoutRec.h"
#include "berryContainerPlaceholder.h"
#include "berryViewSashContainer.h"
#include "berryPartStack.h"
namespace berry
{
/**
* \ingroup org_blueberry_ui_internal
*
* This factory is used to define the initial layout of a part sash container.
* <p>
* Design notes: The design of <code>IPageLayout</code> is a reflection of
* three requirements:
* <ol>
* <li>A mechanism is required to define the initial layout for a page. </li>
* <li>The views and editors within a page will be persisted between
* sessions.</li>
* <li>The view and editor lifecycle for (1) and (2) should be identical.</li>
* </ol>
* </p>
* <p>
* In reflection of these requirements, the following strategy has been
* implemented for layout definition.
* <ol>
* <li>A view extension is added to the workbench registry for the view.
* This extension defines the extension id and extension class. </li>
* <li>A view is added to a page by invoking one of the add methods
* in <code>IPageLayout</code>. The type of view is passed as an
* extension id, rather than a handle. The page layout will map
* the extension id to a view class, create an instance of the class,
* and then add the view to the page.</li>
* </ol>
* </p>
*/
class PageLayout : public IPageLayout
{
public:
berryObjectMacro(PageLayout);
private:
//ArrayList actionSets = new ArrayList(3);
IPerspectiveDescriptor::Pointer descriptor;
LayoutPart::Pointer editorFolder;
bool editorVisible;
bool fixed;
typedef std::map<std::string, IStackableContainer::Pointer> IDToFolderMap;
IDToFolderMap mapIDtoFolder;
typedef std::map<std::string, StackablePart::Pointer> IDToPartMap;
IDToPartMap mapIDtoPart;
typedef std::map<std::string, ViewLayoutRec::Pointer> IDToViewLayoutRecMap;
IDToViewLayoutRecMap mapIDtoViewLayoutRec;
typedef std::map<IStackableContainer::Pointer, IPlaceholderFolderLayout::Pointer> FolderToFolderLayoutMap;
FolderToFolderLayoutMap mapFolderToFolderLayout;
std::vector<std::string> perspectiveShortcuts;
ViewSashContainer::Pointer rootLayoutContainer;
std::vector<std::string> showInPartIds;
std::vector<std::string> showViewShortcuts;
ViewFactory* viewFactory;
/**
* Constructs a new PageLayout for other purposes.
*/
public:
PageLayout();
/**
* Constructs a new PageLayout for the normal case of creating a new
* perspective.
*/
public:
PageLayout(ViewSashContainer::Pointer container, ViewFactory* viewFactory,
LayoutPart::Pointer editorFolder,
IPerspectiveDescriptor::Pointer descriptor);
/**
* Adds the editor to a layout.
*/
private:
void AddEditorArea();
/**
* Adds an action set to the page.
*
* @param actionSetID Identifies the action set extension to use. It must
* exist within the workbench registry.
*/
// public: void addActionSet(String actionSetID) {
// if (!actionSets.contains(actionSetID)) {
// actionSets.add(actionSetID);
// }
// }
/* (non-Javadoc)
* @see org.blueberry.ui.IPageLayout#addFastView(java.lang.String)
*/
// public: void addFastView(String id) {
// addFastView(id, INVALID_RATIO);
// }
/* (non-Javadoc)
* @see org.blueberry.ui.IPageLayout#addFastView(java.lang.String, float)
*/
// public: void addFastView(String id, float ratio) {
// if (checkPartInLayout(id)) {
// return;
// }
// if (id != null) {
// try {
// IViewDescriptor viewDescriptor = viewFactory.getViewRegistry()
// .find(ViewFactory.extractPrimaryId(id));
// if (!WorkbenchActivityHelper.filterItem(viewDescriptor)) {
// IViewReference ref = viewFactory.createView(ViewFactory
// .extractPrimaryId(id), ViewFactory
// .extractSecondaryId(id));
// fastViews.add(ref);
//
// // force creation of the view layout rec
// ViewLayoutRec rec = getViewLayoutRec(id, true);
//
// // remember the ratio, if valid
// if (ratio >= IPageLayout.RATIO_MIN
// && ratio <= IPageLayout.RATIO_MAX) {
// rec.fastViewWidthRatio = ratio;
// }
// }
// } catch (PartInitException e) {
// WorkbenchPlugin.log(getClass(), "addFastView", e); //$NON-NLS-1$
// }
// }
// }
/**
* Check to see if the partId represents a fast view's id.
*
* @param partId
* The part's id.
* @return true if the partId is a fast view id.
*/
// private: boolean isFastViewId(String partId) {
// for (int i = 0; i < fastViews.size(); i++) {
// IViewReference ref = (IViewReference) fastViews.get(i);
// String secondaryId = ref.getSecondaryId();
// String refId = (secondaryId == null ? ref.getId() : ref.getId()
// + ":" + secondaryId); //$NON-NLS-1$
// if (refId.equals(partId)) {
// return true;
// }
// }
// return false;
// }
/**
* Returns the view layout record for the given view id, or null if not
* found. If create is true, the record is created if it doesn't already
* exist.
*
* @since 3.0
*/
public:
ViewLayoutRec::Pointer GetViewLayoutRec(const std::string& id, bool create);
/**
* Adds a creation wizard to the File New menu.
* The id must name a new wizard extension contributed to the
* workbench's extension point (named <code>"org.blueberry.ui.newWizards"</code>).
*
* @param id the wizard id
*/
// public: void addNewWizardShortcut(String id) {
// if (!newWizardShortcuts.contains(id)) {
// newWizardShortcuts.add(id);
// }
// }
/**
* Add the layout part to the page's layout
*/
private:
void AddStack(IStackableContainer::Pointer newPart, const std::string& partId,
int relationship, float ratio, const std::string& refId);
/**
* Adds a perspective shortcut to the Perspective menu.
* The id must name a perspective extension contributed to the
* workbench's extension point (named <code>"org.blueberry.ui.perspectives"</code>).
*
* @param id the perspective id
*/
public:
void AddPerspectiveShortcut(const std::string& id);
/* (non-Javadoc)
* @see org.blueberry.ui.IPageLayout#addPlaceholder(java.lang.String, int, float, java.lang.String)
*/
public:
void AddPlaceholder(const std::string& viewId, int relationship, float ratio,
const std::string& refId);
/**
* Checks whether the given id is a valid placeholder id.
* A placeholder id may be simple or compound, and can optionally contain a wildcard.
*
* @param id the placeholder id
* @return <code>true</code> if the given id is a valid placeholder id, <code>false</code> otherwise
*/
bool CheckValidPlaceholderId(const std::string& id);
/* (non-Javadoc)
* @see org.blueberry.ui.IPageLayout#addShowInPart(java.lang.String)
*/
public:
void AddShowInPart(const std::string& id);
/**
* Adds a view to the Show View menu. The id must name a view extension
* contributed to the workbench's extension point (named <code>"org.blueberry.ui.views"</code>).
*
* @param id the view id
*/
public:
void AddShowViewShortcut(const std::string& id);
/* (non-Javadoc)
* @see org.blueberry.ui.IPageLayout#addView(java.lang.String, int, float, java.lang.String)
*/
public:
void AddView(const std::string& viewId, int relationship, float ratio,
const std::string& refId);
/**
* Convenience method to allow setting the initial minimized
* state if a new stack is created. Used by the 'perspectiveExtension'
* reader.
*
* @since 3.3
*/
public:
void AddView(const std::string& viewId, int relationship, float ratio,
const std::string& refId, bool minimized);
/* (non-Javadoc)
* @see org.blueberry.ui.IPageLayout#addView(java.lang.String, int, float, java.lang.String)
*/
private:
void
AddView(const std::string& viewId, int relationship, float ratio,
const std::string& refId, bool minimized, bool standalone,
bool showTitle);
// public: List getMinimizedStacks() {
// return minimizedStacks;
// }
/**
* Verify that the part is already present in the layout
* and cannot be added again. Log a warning message.
*/
public:
bool CheckPartInLayout(const std::string& partId);
/* (non-Javadoc)
* @see org.blueberry.ui.IPageLayout#createFolder(java.lang.String, int, float, java.lang.String)
*/
public:
IFolderLayout::Pointer CreateFolder(const std::string& folderId,
int relationship, float ratio, const std::string& refId);
/* (non-Javadoc)
* @see org.blueberry.ui.IPageLayout#createPlaceholderFolder(java.lang.String, int, float, java.lang.String)
*/
public:
IPlaceholderFolderLayout::Pointer CreatePlaceholderFolder(
const std::string& folderId, int relationship, float ratio,
const std::string& refId);
/**
* Create a new <code>LayoutPart</code>.
*
* @param partID the id of the part to create.
* @return the <code>LayoutPart</code>, or <code>null</code> if it should not be
* created because of activity filtering.
* @throws PartInitException thrown if there is a problem creating the part.
*/
private:
StackablePart::Pointer CreateView(const std::string& partID);
/**
* @return the action set list for the page. This is <code>List</code> of
* <code>String</code>s.
*/
// public: ArrayList getActionSets() {
// return actionSets;
// }
/* (non-Javadoc)
* @see org.blueberry.ui.IPageLayout#getDescriptor()
*/
public:
IPerspectiveDescriptor::Pointer GetDescriptor();
/**
* @return an identifier for the editor area. The editor area is
* automatically added to each layout before any other part. It should be
* used as a reference part for other views.
*/
public:
std::string GetEditorArea();
/* (non-Javadoc)
* @see org.blueberry.ui.IPageLayout#getEditorReuseThreshold()
*/
// public: int getEditorReuseThreshold() {
// return -1;
// }
/**
* @return <code>ArrayList</code>
*/
// public: ArrayList getFastViews() {
// return fastViews;
// }
/**
* @return the folder part containing the given view ID or <code>null</code>
* if none (i.e. part of the page layout instead of a folder layout).
*/
private:
IStackableContainer::Pointer GetFolderPart(const std::string& viewId);
/**
* @return the new wizard shortcuts associated with the page. This is a <code>List</code> of
* <code>String</code>s.
*/
// public: ArrayList getNewWizardShortcuts() {
// return newWizardShortcuts;
// }
/**
* @return the part sash container const for a layout value.
*/
private:
int GetPartSashConst(int nRelationship);
/**
* @return the perspective shortcuts associated with the page. This is a <code>List</code> of
* <code>String</code>s.
*/
public:
std::vector<std::string> GetPerspectiveShortcuts();
/**
* @return the part for a given ID.
*/
/*package*/
StackablePart::Pointer GetRefPart(const std::string& partID);
/**
* @return the top level layout container.
*/
public:
PartSashContainer::Pointer GetRootLayoutContainer();
/**
* @return the ids of the parts to list in the Show In... prompter. This is
* a <code>List</code> of <code>String</code>s.
*/
public:
std::vector<std::string> GetShowInPartIds();
/**
* @return the show view shortcuts associated with the page. This is a <code>List</code> of
* <code>String</code>s.
*/
public:
std::vector<std::string> GetShowViewShortcuts();
/**
* @return the <code>ViewFactory</code> for this <code>PageLayout</code>.
* @since 3.0
*/
/* package */
ViewFactory* GetViewFactory();
/* (non-Javadoc)
* @see org.blueberry.ui.IPageLayout#isEditorAreaVisible()
*/
public:
bool IsEditorAreaVisible();
/**
* Trim the ratio so that direct manipulation of parts is easy.
*
* @param in the initial ratio.
* @return the normalized ratio.
*/
private:
float NormalizeRatio(float in);
/**
* Prefill the layout with required parts.
*/
private:
void Prefill();
/* (non-Javadoc)
* @see org.blueberry.ui.IPageLayout#setEditorAreaVisible(boolean)
*/
public:
void SetEditorAreaVisible(bool showEditorArea);
/* (non-Javadoc)
* @see org.blueberry.ui.IPageLayout#setEditorReuseThreshold(int)
*/
// public: void setEditorReuseThreshold(int openEditors) {
// //no-op
// }
/* (non-Javadoc)
* @see org.blueberry.ui.IPageLayout#setFixed(boolean)
*/
public:
void SetFixed(bool fixed);
/* (non-Javadoc)
* @see org.blueberry.ui.IPageLayout#getFixed()
*/
public:
bool IsFixed();
/**
* Map the folder part containing the given view ID.
*
* @param viewId the part ID.
* @param container the <code>ContainerPlaceholder</code>.
*/
/*package*/
void SetFolderPart(const std::string& viewId,
ContainerPlaceholder::Pointer container);
/**
* Map the folder part containing the given view ID.
*
* @param viewId the part ID.
* @param folder the <code>ViewStack</code>.
*/
/*package*/
void SetFolderPart(const std::string& viewId, PartStack::Pointer folder);
void SetFolderPart(const std::string& viewId, IStackableContainer::Pointer folder);
/**
* Map an ID to a part.
*
* @param partId the part ID.
* @param part the <code>LayoutPart</code>.
*/
/*package*/
void SetRefPart(const std::string& partID, StackablePart::Pointer part);
/**
* Stack a part on top of another.
*
* @param newPart the new part.
* @param viewId the view ID.
* @param refId the reference ID.
*/
private:
void StackPart(StackablePart::Pointer newPart, const std::string& viewId,
const std::string& refId);
/**
* Stack a placeholder on top of another.
*
* @param viewId the view ID.
* @param refId the reference ID.
*/
public:
void StackPlaceholder(const std::string& viewId, const std::string& refId);
// stackView(String, String) modified by dan_rubel@instantiations.com
/**
* Stack one view on top of another.
*
* @param viewId the view ID.
* @param refId the reference ID.
*/
public:
void StackView(const std::string& viewId, const std::string& refId);
/**
* Converts common position constants into layout position constants.
*
* @param one of Constants::TOP, Constants::BOTTOM, Constants::LEFT, or Constants::RIGHT
* @return one of IPageLayout::TOP, IPageLayout::BOTTOM, IPageLayout::LEFT, IPageLayout::RIGHT, or -1 indicating an
* invalid input
*
* @since 3.0
*/
public: static int ConstantToLayoutPosition(int constant);
/* (non-Javadoc)
* @see org.blueberry.ui.IPageLayout#addStandaloneView(java.lang.String, boolean, int, float, java.lang.String)
* @since 3.0
*/
public:
void AddStandaloneView(const std::string& viewId, bool showTitle,
int relationship, float ratio, const std::string& refId);
/* (non-Javadoc)
* @see org.blueberry.ui.IPageLayout#addStandaloneViewPlaceholder(java.lang.String, int, float, java.lang.String, boolean)
*/
public:
void AddStandaloneViewPlaceholder(const std::string& viewId,
int relationship, float ratio, const std::string& refId, bool showTitle);
/*
* (non-Javadoc)
*
* @see org.blueberry.ui.IPageLayout#getViewLayout(java.lang.String)
* @since 3.0
*/
public:
IViewLayout::Pointer GetViewLayout(const std::string& viewId);
/**
* @since 3.0
*/
public:
std::map<std::string, ViewLayoutRec::Pointer> GetIDtoViewLayoutRecMap();
/**
* Removes any existing placeholder with the given id.
*
* @param id the id for the placeholder
* @since 3.1
*/
public:
void RemovePlaceholder(const std::string& id);
/* (non-Javadoc)
* @see org.blueberry.ui.IPageLayout#getFolderForView(java.lang.String)
*/
public:
IPlaceholderFolderLayout::Pointer GetFolderForView(const std::string& viewId);
};
}
#endif /*BERRYPAGELAYOUT_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPagePartSelectionTracker.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPagePartSelectionTracker.cpp
index 89fc96c7d2..321183d136 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPagePartSelectionTracker.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPagePartSelectionTracker.cpp
@@ -1,275 +1,275 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryPagePartSelectionTracker.h"
#include "berryIPostSelectionProvider.h"
namespace berry
{
class SelTrackerPartListener: public IPartListener
{
public:
SelTrackerPartListener(PagePartSelectionTracker* tracker)
: tracker(tracker)
{}
Events::Types GetPartEventTypes() const
{
return Events::CLOSED | Events::OPENED;
}
void PartClosed(IWorkbenchPartReference::Pointer partRef)
{
if (tracker->GetPartId(partRef->GetPart(false))
== tracker->AbstractPartSelectionTracker::GetPartId())
{
tracker->SetPart(IWorkbenchPart::Pointer(0), true);
}
}
void PartOpened(IWorkbenchPartReference::Pointer partRef)
{
if (tracker->GetPartId(partRef->GetPart(false))
== tracker->AbstractPartSelectionTracker::GetPartId())
{
tracker->SetPart(partRef->GetPart(false), true);
}
}
private:
PagePartSelectionTracker* tracker;
};
class SelTrackerPerspectiveListener: public IPerspectiveListener
{
public:
SelTrackerPerspectiveListener(PagePartSelectionTracker* tracker)
: tracker(tracker)
{}
IPerspectiveListener::Events::Types GetPerspectiveEventTypes() const
{
return IPerspectiveListener::Events::PART_CHANGED;
}
void PerspectiveChanged(IWorkbenchPage::Pointer,
IPerspectiveDescriptor::Pointer,
IWorkbenchPartReference::Pointer partRef, const std::string& changeId)
{
if (!partRef)
return;
IWorkbenchPart::Pointer part = partRef->GetPart(false);
if (!part)
return;
if (IWorkbenchPage::CHANGE_VIEW_SHOW == changeId)
{
if (tracker->GetPart()) // quick check first, plus avoids double setting
return;
if (tracker->GetPartId(part) == tracker->AbstractPartSelectionTracker::GetPartId())
tracker->SetPart(part, true);
}
}
private:
PagePartSelectionTracker* tracker;
};
class SelTrackerSelectionChangedListener: public ISelectionChangedListener
{
public:
SelTrackerSelectionChangedListener(PagePartSelectionTracker* tracker)
: tracker(tracker)
{}
void SelectionChanged(SelectionChangedEvent::Pointer event)
{
tracker->FireSelection(tracker->GetPart(), event->GetSelection());
}
private:
PagePartSelectionTracker* tracker;
};
PagePartSelectionTracker::PostSelectionListener::PostSelectionListener(
PagePartSelectionTracker* tracker) :
m_Tracker(tracker)
{
}
void PagePartSelectionTracker::PostSelectionListener::SelectionChanged(
SelectionChangedEvent::Pointer event)
{
m_Tracker->FirePostSelection(m_Tracker->GetPart(), event->GetSelection());
}
PagePartSelectionTracker::PagePartSelectionTracker(
IWorkbenchPage* page, const std::string& partId) :
AbstractPartSelectionTracker(partId)
{
postSelectionListener = new PostSelectionListener(this);
perspListener = new SelTrackerPerspectiveListener(this);
selChangedListener = new SelTrackerSelectionChangedListener(this);
partListener = new SelTrackerPartListener(this);
this->SetPage(page);
page->AddPartListener(partListener);
page->GetWorkbenchWindow()->AddPerspectiveListener(
perspListener);
std::string secondaryId;
std::string primaryId = partId;
std::string::size_type indexOfColon;
if ((indexOfColon = partId.find_first_of(':')) != std::string::npos)
{
secondaryId = partId.substr(indexOfColon + 1);
primaryId = partId.substr(0, indexOfColon);
}
IViewReference::Pointer part =
page->FindViewReference(primaryId, secondaryId);
if (part.IsNotNull() && part->GetView(false).IsNotNull())
{
this->SetPart(part->GetView(false), false);
}
}
ISelection::ConstPointer PagePartSelectionTracker::GetSelection()
{
IWorkbenchPart::Pointer part = this->GetPart();
if (part.IsNotNull())
{
ISelectionProvider::Pointer sp = part->GetSite()->GetSelectionProvider();
if (sp.IsNotNull())
{
return sp->GetSelection();
}
}
return ISelection::Pointer(0);
}
PagePartSelectionTracker::~PagePartSelectionTracker()
{
IWorkbenchPage::Pointer page = GetPage();
page->GetWorkbenchWindow()->RemovePerspectiveListener(
perspListener);
page->RemovePartListener(partListener);
this->SetPart(IWorkbenchPart::Pointer(0), false);
this->SetPage(0);
}
IWorkbenchPart::Pointer PagePartSelectionTracker::GetPart()
{
return fPart;
}
IWorkbenchPage::Pointer PagePartSelectionTracker::GetPage()
{
return IWorkbenchPage::Pointer(fPage);
}
ISelectionProvider::Pointer PagePartSelectionTracker::GetSelectionProvider()
{
IWorkbenchPart::Pointer part = this->GetPart();
if (part.IsNotNull())
{
return part->GetSite()->GetSelectionProvider();
}
return ISelectionProvider::Pointer(0);
}
std::string PagePartSelectionTracker::GetPartId(IWorkbenchPart::Pointer part)
{
std::string id = part->GetSite()->GetId();
if (part.Cast<IViewPart> ().IsNotNull())
{
std::string secondaryId =
part.Cast<IViewPart> ()->GetViewSite() ->GetSecondaryId();
if (secondaryId != "")
{
id = id + ':' + secondaryId;
}
}
return id;
}
void PagePartSelectionTracker::SetPage(IWorkbenchPage* page)
{
fPage = page;
}
void PagePartSelectionTracker::SetPart(IWorkbenchPart::Pointer part,
bool notify)
{
if (fPart.IsNotNull())
{
// remove myself as a listener from the existing part
ISelectionProvider::Pointer sp = fPart->GetSite()->GetSelectionProvider();
if (sp.IsNotNull())
{
sp->RemoveSelectionChangedListener(selChangedListener);
if (sp.Cast<IPostSelectionProvider> ().IsNotNull())
{
sp.Cast<IPostSelectionProvider> () ->RemovePostSelectionChangedListener(
postSelectionListener);
}
else
{
sp->RemoveSelectionChangedListener(postSelectionListener);
}
}
}
fPart = part;
ISelection::ConstPointer sel;
if (part.IsNotNull())
{
ISelectionProvider::Pointer sp = part->GetSite()->GetSelectionProvider();
if (sp.IsNotNull())
{
sp->AddSelectionChangedListener(selChangedListener);
if (sp.Cast<IPostSelectionProvider> ().IsNotNull())
{
sp.Cast<IPostSelectionProvider> () ->AddPostSelectionChangedListener(
postSelectionListener);
}
else
{
sp->AddSelectionChangedListener(postSelectionListener);
}
if (notify)
{
// get the selection to send below
sel = sp->GetSelection();
}
}
}
if (notify)
{
this->FireSelection(part, sel);
this->FirePostSelection(part, sel);
}
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPagePartSelectionTracker.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPagePartSelectionTracker.h
index 2388e982f4..97d3d04f7f 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPagePartSelectionTracker.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPagePartSelectionTracker.h
@@ -1,143 +1,143 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYPAGEPARTSELECTIONTRACKER_H_
#define BERRYPAGEPARTSELECTIONTRACKER_H_
#include "berryIPartListener.h"
#include "berryISelectionChangedListener.h"
#include "berryISelectionService.h"
#include "berryISelectionProvider.h"
#include "berrySelectionChangedEvent.h"
#include "berryIWorkbenchPage.h"
#include "berryAbstractPartSelectionTracker.h"
namespace berry
{
/**
* \ingroup org_blueberry_ui_internal
*
* Provides per-part selection tracking for the selection service.
*/
class PagePartSelectionTracker : public AbstractPartSelectionTracker
{
public:
berryObjectMacro(PagePartSelectionTracker);
private:
/**
* The workbench page for which this is tracking selection.
*/
IWorkbenchPage* fPage;
/**
* The part in this tracker's page, or <code>null</code> if one is not open.
*/
IWorkbenchPart::Pointer fPart;
struct PostSelectionListener : public ISelectionChangedListener
{
PostSelectionListener(PagePartSelectionTracker* tracker);
void SelectionChanged(SelectionChangedEvent::Pointer event);
PagePartSelectionTracker* m_Tracker;
};
friend struct PostSelectionListener;
friend class SelTrackerPartListener;
friend class SelTrackerPerspectiveListener;
friend class SelTrackerSelectionChangedListener;
ISelectionChangedListener::Pointer postSelectionListener;
IPerspectiveListener::Pointer perspListener;
ISelectionChangedListener::Pointer selChangedListener;
IPartListener::Pointer partListener;
public:
/**
* Constructs a part selection tracker for the part with the given id.
*
* @param id part identifier
*/
PagePartSelectionTracker(IWorkbenchPage* page,
const std::string& partId);
/**
* Returns the selection from the part being tracked,
* or <code>null</code> if the part is closed or has no selection.
*/
ISelection::ConstPointer GetSelection();
/**
* Disposes this selection tracker. This removes all listeners currently registered.
*/
~PagePartSelectionTracker();
protected:
/**
* Returns the part this is tracking,
* or <code>null</code> if it is not open
*
* @return part., or <code>null</code>
*/
IWorkbenchPart::Pointer GetPart();
/**
* Returns the page this selection provider works for
*
* @return workbench page
*/
IWorkbenchPage::Pointer GetPage();
ISelectionProvider::Pointer GetSelectionProvider();
private:
/**
* Returns the id for the given part, taking into account
* multi-view instances which may have a secondary id.
*
*/
std::string GetPartId(IWorkbenchPart::Pointer part);
/**
* Sets the page this selection provider works for
*
* @param page workbench page
*/
void SetPage(IWorkbenchPage* page);
/**
* Sets the part for this selection tracker.
*
* @param part the part
* @param notify whether to send notification that the selection has changed.
*/
void SetPart(IWorkbenchPart::Pointer part, bool notify);
};
}
#endif /*BERRYPAGEPARTSELECTIONTRACKER_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPageSelectionService.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPageSelectionService.cpp
index 92626c7522..a8dd92db1c 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPageSelectionService.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPageSelectionService.cpp
@@ -1,47 +1,47 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryPageSelectionService.h"
#include "berryPagePartSelectionTracker.h"
#include "berryIWorkbenchPage.h"
namespace berry
{
void PageSelectionService::SetPage(IWorkbenchPage* page)
{
this->page = page;
}
PageSelectionService::PageSelectionService(IWorkbenchPage* page)
{
SetPage(page);
}
IWorkbenchPage* PageSelectionService::GetPage() const
{
return page;
}
AbstractPartSelectionTracker::Pointer PageSelectionService::CreatePartTracker(
const std::string& partId) const
{
AbstractPartSelectionTracker::Pointer tracker(new PagePartSelectionTracker(GetPage(), partId));
return tracker;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPageSelectionService.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPageSelectionService.h
index 1bcbde7eb7..202f94d3f1 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPageSelectionService.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPageSelectionService.h
@@ -1,64 +1,64 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYPAGESELECTIONSERVICE_H_
#define BERRYPAGESELECTIONSERVICE_H_
#include "berryAbstractSelectionService.h"
namespace berry {
struct IWorkbenchPage;
/**
* The selection service for a page.
*/
class PageSelectionService : public AbstractSelectionService
{
private:
IWorkbenchPage* page;
/**
* Sets the page.
*/
void SetPage(IWorkbenchPage* page);
public:
/**
* Creates a new selection service for a specific workbench page.
*/
PageSelectionService(IWorkbenchPage* page);
protected:
/**
* Returns the page.
*/
IWorkbenchPage* GetPage() const;
/*
* @see AbstractSelectionService#CreatePartTracker(const std::string&)
*/
AbstractPartSelectionTracker::Pointer CreatePartTracker(const std::string& partId) const;
};
}
#endif /* BERRYPAGESELECTIONSERVICE_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartPane.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartPane.cpp
index 025b37aae7..cea52b7fba 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartPane.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartPane.cpp
@@ -1,466 +1,466 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryPartPane.h"
#include "tweaklets/berryGuiWidgetsTweaklet.h"
#include "tweaklets/berryWorkbenchPageTweaklet.h"
#include "berryWorkbenchPage.h"
#include "berryPartStack.h"
#include "berryEditorAreaHelper.h"
#include "berryPerspective.h"
#include "berryPartStack.h"
#include "berryDragUtil.h"
namespace berry
{
PartPane::Sashes::Sashes() :
left(0), right(0), top(0), bottom(0)
{
}
PartPane::PartPane(IWorkbenchPartReference::Pointer partReference,
WorkbenchPage* workbenchPage)
: StackablePart(partReference->GetId()),
control(0), inLayout(true), busy(false), hasFocus(false)
{
//super(partReference.getId());
this->partReference = partReference;
this->page = workbenchPage;
}
void PartPane::CreateControl(void* parent) {
if (this->GetControl() != 0)
{
return;
}
partReference.Lock()->AddPropertyListener(IPropertyChangeListener::Pointer(this));
// Create view form.
control = Tweaklets::Get(WorkbenchPageTweaklet::KEY)->CreatePaneControl(parent);
// the part should never be visible by default. It will be made visible
// by activation. This allows us to have views appear in tabs without
// becoming active by default.
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->SetVisible(control, false);
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->MoveAbove(control, 0);
// Create a title bar.
//this->CreateTitleBar();
// When the pane or any child gains focus, notify the workbench.
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->AddControlListener(control, GuiTk::IControlListener::Pointer(this));
//control.addTraverseListener(traverseListener);
}
bool PartPane::IsPlaceHolder()
{
return false;
}
PartPane::~PartPane()
{
// super.dispose();
//
this->Register();
if (control != 0)
{
BERRY_DEBUG << "Deleting PartPane control";
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->RemoveControlListener(control, GuiTk::IControlListener::Pointer(this));
// control.removeTraverseListener(traverseListener);
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->Dispose(control);
control = 0;
}
// if ((paneMenuManager != null))
// {
// paneMenuManager.dispose();
// paneMenuManager = null;
// }
//
if (!partReference.Expired())
{
partReference.Lock()->RemovePropertyListener(IPropertyChangeListener::Pointer(this));
}
// partReference.removePartPropertyListener(this);
this->UnRegister(false);
}
void PartPane::DoHide()
{
if (partReference.Lock().Cast<IViewReference>() != 0)
{
this->GetPage()->HideView(partReference.Lock().Cast<IViewReference>());
}
else if (partReference.Lock().Cast<IEditorReference>() != 0)
{
this->GetPage()->CloseEditor(partReference.Lock().Cast<IEditorReference>(), true);
}
}
Rectangle PartPane::GetParentBounds()
{
void* ctrl = this->GetControl();
if (this->GetContainer() != 0 && this->GetContainer().Cast<LayoutPart>() != 0) {
LayoutPart::Pointer part = this->GetContainer().Cast<LayoutPart>();
if (part->GetControl() != 0) {
ctrl = part->GetControl();
}
}
return DragUtil::GetDisplayBounds(ctrl);
}
void* PartPane::GetControl()
{
return control;
}
IWorkbenchPartReference::Pointer PartPane::GetPartReference() const
{
return partReference.Lock();
}
void PartPane::ControlActivated(GuiTk::ControlEvent::Pointer /*e*/)
{
if (inLayout)
{
this->RequestActivation();
}
}
GuiTk::IControlListener::Events::Types PartPane::GetEventTypes() const
{
return GuiTk::IControlListener::Events::ACTIVATED;
}
void PartPane::MoveAbove(void* refControl)
{
if (this->GetControl() != 0)
{
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->MoveAbove(this->GetControl(), refControl);
}
}
void PartPane::RequestActivation()
{
IWorkbenchPart::Pointer part = partReference.Lock()->GetPart(true);
this->page->RequestActivation(part);
}
//PartStack::Pointer PartPane::GetStack()
//{
// return partStack;
//}
PartPane::Sashes PartPane::FindSashes()
{
Sashes result;
IStackableContainer::Pointer container = this->GetContainer();
if (container == 0) {
return result;
}
container->FindSashes(result);
return result;
}
WorkbenchPage::Pointer PartPane::GetPage()
{
return WorkbenchPage::Pointer(page);
}
void PartPane::SetContainer(IStackableContainer::Pointer container)
{
if (hasFocus)
{
IStackableContainer::Pointer oldContainer = this->GetContainer();
if (PartStack::Pointer oldStack = oldContainer.Cast<PartStack>())
{
oldStack->SetActive(StackPresentation::AS_INACTIVE);
}
if (PartStack::Pointer newContainer = container.Cast<PartStack>())
{
newContainer->SetActive(StackPresentation::AS_ACTIVE_FOCUS);
}
}
void* containerControl = container == 0 ? 0 : container.Cast<LayoutPart>()->GetControl();
if (containerControl != 0)
{
void* control = this->GetControl();
void* newParent = Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetParent(containerControl);
if (control != 0 && newParent != Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetParent(control))
{
this->Reparent(newParent);
}
}
StackablePart::SetContainer(container);
}
void PartPane::Reparent(void* newParent)
{
void* control = this->GetControl();
GuiWidgetsTweaklet* guiTweaklet = Tweaklets::Get(GuiWidgetsTweaklet::KEY);
if ((control == 0) || (guiTweaklet->GetParent(control) == newParent))
{
return;
}
if (guiTweaklet->IsReparentable(control))
{
// make control small in case it is not resized with other controls
//control.setBounds(0, 0, 0, 0);
// By setting the control to disabled before moving it,
// we ensure that the focus goes away from the control and its children
// and moves somewhere else
bool enabled = guiTweaklet->GetEnabled(control);
guiTweaklet->SetEnabled(control, false);
guiTweaklet->SetParent(control, newParent);
guiTweaklet->SetEnabled(control, enabled);
guiTweaklet->MoveAbove(control, 0);
}
}
void PartPane::ShowFocus(bool inFocus)
{
if (partReference.Lock().Cast<IViewReference>() != 0)
{
hasFocus = inFocus;
}
if (PartStack::Pointer stack = this->GetContainer().Cast<PartStack>())
{
if (partReference.Lock().Cast<IViewReference>() != 0)
{
stack->SetActive(inFocus ? StackPresentation::AS_ACTIVE_FOCUS
: StackPresentation::AS_INACTIVE);
}
else if (partReference.Lock().Cast<IEditorReference>() != 0)
{
if (inFocus)
{
page->GetEditorPresentation()->SetActiveWorkbook(stack, true);
}
else
{
stack->SetActive(page->GetEditorPresentation()->GetActiveWorkbook() == stack ?
StackPresentation::AS_ACTIVE_NOFOCUS : StackPresentation::AS_INACTIVE);
}
}
}
}
PartStack::Pointer PartPane::GetStack()
{
IStackableContainer::Pointer container = this->GetContainer();
return container.Cast<PartStack>();
}
void PartPane::SetVisible(bool makeVisible)
{
// Avoid redundant visibility changes
if (makeVisible == this->GetVisible())
{
return;
}
if (makeVisible)
{
partReference.Lock()->GetPart(true);
}
if (this->GetControl() != 0)
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->SetVisible(this->GetControl(), makeVisible);
partReference.Lock().Cast<WorkbenchPartReference>()->FireVisibilityChange();
}
bool PartPane::GetVisible()
{
if (this->GetControl() != 0)
return Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetVisible(this->GetControl());
return false;
}
void PartPane::SetFocus()
{
this->RequestActivation();
IWorkbenchPart::Pointer part = partReference.Lock()->GetPart(true);
if (part.IsNotNull())
{
// Control control = getControl();
// if (!SwtUtil.isFocusAncestor(control))
// {
// First try to call part.setFocus
part->SetFocus();
//}
}
}
void PartPane::SetWorkbenchPage(WorkbenchPage::Pointer workbenchPage)
{
this->page = workbenchPage.GetPointer();
}
void PartPane::DoDock()
{
// do nothing
}
void PartPane::SetBusy(bool isBusy)
{
if (isBusy != busy)
{
busy = isBusy;
//firePropertyChange(IPresentablePart.PROP_BUSY);
}
}
void PartPane::ShowHighlight()
{
//No nothing by default
}
void* PartPane::GetToolBar()
{
return 0;
}
bool PartPane::HasViewMenu()
{
return false;
}
bool PartPane::IsBusy()
{
return busy;
}
void PartPane::DescribeLayout(std::string& buf) const
{
IWorkbenchPartReference::Pointer part = this->GetPartReference();
if (part.IsNotNull())
{
buf.append(part->GetPartName());
return;
}
}
bool PartPane::IsCloseable()
{
if (partReference.Lock().Cast<IViewReference>() != 0)
{
Perspective::Pointer perspective = page->GetActivePerspective();
if (perspective == 0) {
// Shouldn't happen -- can't have a ViewStack without a
// perspective
return true;
}
return perspective->IsCloseable(partReference.Lock().Cast<IViewReference>());
}
return true;
}
void PartPane::SetInLayout(bool inLayout)
{
this->inLayout = inLayout;
}
bool PartPane::GetInLayout()
{
return inLayout;
}
bool PartPane::AllowsAutoFocus()
{
if (!inLayout)
{
return false;
}
//return super.allowsAutoFocus();
return true;
}
void PartPane::RemoveContributions()
{
}
void PartPane::AddPropertyListener(IPropertyChangeListener::Pointer listener)
{
propertyChangeEvents.AddListener(listener);
}
void PartPane::RemovePropertyListener(IPropertyChangeListener::Pointer listener)
{
propertyChangeEvents.RemoveListener(listener);
}
void PartPane::FirePropertyChange(PropertyChangeEvent::Pointer event)
{
propertyChangeEvents.propertyChange(event);
}
void PartPane::PropertyChange(PropertyChangeEvent::Pointer event)
{
this->FirePropertyChange(event);
}
int PartPane::ComputePreferredSize(bool width, int availableParallel,
int availablePerpendicular, int preferredParallel)
{
return partReference.Lock().Cast<WorkbenchPartReference>()->ComputePreferredSize(width,
availableParallel, availablePerpendicular, preferredParallel);
}
int PartPane::GetSizeFlags(bool horizontal)
{
return partReference.Lock().Cast<WorkbenchPartReference>()->GetSizeFlags(horizontal);
}
void PartPane::ShellActivated()
{
}
void PartPane::ShellDeactivated()
{
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartPane.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartPane.h
index 73e06d73b2..e0a0c5b30b 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartPane.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartPane.h
@@ -1,436 +1,436 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYPARTPANE_H_
#define BERRYPARTPANE_H_
#include "berryWorkbenchPartReference.h"
#include "berryStackablePart.h"
#include "berryRectangle.h"
#include "berryIPropertyChangeListener.h"
#include "guitk/berryGuiTkIControlListener.h"
namespace berry {
class WorkbenchPage;
class PartStack;
struct IStackableContainer;
/**
* Provides the common behavior for both views
* and editor panes.
*
*/
class PartPane : public StackablePart,
public IPropertyChangeListener,
public GuiTk::IControlListener
{
public:
berryObjectMacro(PartPane);
friend class PartSashContainer;
friend class EditorSashContainer;
friend class WorkbenchPage;
friend struct IStackableContainer;
friend struct ILayoutContainer;
friend class PartStack;
friend class ContainerPlaceholder;
friend class LayoutTree;
friend class LayoutTreeNode;
friend class DetachedPlaceHolder;
friend class PerspectiveHelper;
// private: MenuManager paneMenuManager;
// private: ListenerList listeners = new ListenerList();
// private: ListenerList partListeners = new ListenerList();
private: IPropertyChangeListener::Events propertyChangeEvents;
protected: IWorkbenchPartReference::WeakPtr partReference;
protected: WorkbenchPage* page;
protected: void* control;
private: bool inLayout;
// private: TraverseListener traverseListener = new TraverseListener() {
// /* (non-Javadoc)
// * @see org.blueberry.swt.events.TraverseListener#keyTraversed(org.blueberry.swt.events.TraverseEvent)
// */
// public: void keyTraversed(TraverseEvent e) {
// // Hack: Currently, SWT sets focus whenever we call Control.traverse. This doesn't
// // cause too much of a problem for ctrl-pgup and ctrl-pgdn, but it is seriously unexpected
// // for other traversal events. When (and if) it becomes possible to call traverse() without
// // forcing a focus change, this if statement should be removed and ALL events should be
// // forwarded to the container.
// if (e.detail == SWT.TRAVERSE_PAGE_NEXT
// || e.detail == SWT.TRAVERSE_PAGE_PREVIOUS) {
// ILayoutContainer container = getContainer();
// if (container != null && container instanceof LayoutPart) {
// LayoutPart parent = (LayoutPart) container;
// Control parentControl = parent.getControl();
// if (parentControl != null && !parentControl.isDisposed()) {
// e.doit = parentControl.traverse(e.detail);
// if (e.doit) {
// e.detail = SWT.TRAVERSE_NONE;
// }
// }
// }
// }
// }
//
// };
private: bool busy;
private: bool hasFocus;
//private: SmartPointer<PartStack> partStack;
protected:
/*static*/ class Sashes {
public:
Sashes();
/*Sash*/ void* left;
/*Sash*/ void* right;
/*Sash*/ void* top;
/*Sash*/ void* bottom;
};
/**
* Construct a pane for a part.
*/
public: PartPane(IWorkbenchPartReference::Pointer partReference,
WorkbenchPage* workbenchPage);
// public: void addSizeMenuItem(Menu menu, int index) {
// //Add size menu
// MenuItem item = new MenuItem(menu, SWT.CASCADE, index);
// item.setText(WorkbenchMessages.PartPane_size);
// Menu sizeMenu = new Menu(menu);
// item.setMenu(sizeMenu);
// addSizeItems(sizeMenu);
// }
/**
*
* Creates the GUI-dependent container control
* for the part widgets. This is passed to
* IWorkbenchPart::CreatePartControl(void*)
*/
public: virtual void CreateControl(void* parent);
//public: virtual void SetControlEnabled(bool enabled) = 0;
/**
* Create a title bar for the pane if required.
*/
// protected: virtual void CreateTitleBar() = 0;
public: bool IsPlaceHolder();
/**
* @private:
*/
public: virtual ~PartPane();
/**
* User has requested to close the pane.
* Take appropriate action depending on type.
*/
public: void DoHide();
protected: Rectangle GetParentBounds();
/**
* Get the control.
*/
public: void* GetControl();
/**
* Answer the part child.
*/
public: IWorkbenchPartReference::Pointer GetPartReference() const;
/**
* @see GuiTk::IControlListener
*/
public: void ControlActivated(GuiTk::ControlEvent::Pointer e);
/**
* @see GuiTk::IControlListener
*/
public: GuiTk::IControlListener::Events::Types GetEventTypes() const;
/**
* Move the control over another one.
*/
public: void MoveAbove(void* refControl);
/**
* Notify the workbook page that the part pane has
* been activated by the user.
*/
public: void RequestActivation();
/**
* Shows the receiver if <code>visible</code> is true otherwise hide it.
*/
public: void SetVisible(bool makeVisible);
public: virtual bool GetVisible();
/**
* Sets focus to this part.
*/
public: void SetFocus();
/**
* Sets the workbench page of the view.
*/
public: void SetWorkbenchPage(SmartPointer<WorkbenchPage> workbenchPage);
public: void Reparent(void* newParent);
/**
* Indicate focus in part.
*/
public: void ShowFocus(bool inFocus);
/**
* @see IPartDropTarget::targetPartFor
*/
// public: LayoutPart targetPartFor(LayoutPart dragSource) {
// return this;
// }
/**
* Returns the PartStack that contains this PartPane, or null if none.
*
* @return
*/
public: SmartPointer<PartStack> GetStack();
public: void SetContainer(SmartPointer<IStackableContainer> stack);
/**
* Show a title label menu for this pane.
*/
// public: void ShowPaneMenu() {
// PartStack folder = getStack();
//
// if (folder != null) {
// folder.showPaneMenu();
// }
// }
/**
* Show the context menu for this part.
*/
// public: void showSystemMenu() {
// PartStack folder = getStack();
//
// if (folder != null) {
// folder.showSystemMenu();
// }
// }
/**
* Finds and return the sashes around this part.
*/
protected: Sashes FindSashes();
/**
* Enable the user to resize this part using
* the keyboard to move the specified sash
*/
// protected: void moveSash(final Sash sash) {
// moveSash(sash, this);
// }
// public: static void moveSash(final Sash sash,
// final LayoutPart toGetFocusWhenDone) {
// final KeyListener listener = new KeyAdapter() {
// public: void keyPressed(KeyEvent e) {
// if (e.character == SWT.ESC || e.character == '\r') {
// if (toGetFocusWhenDone != null) {
// toGetFocusWhenDone.setFocus();
// }
// }
// }
// };
// sash.addFocusListener(new FocusAdapter() {
// public: void focusGained(FocusEvent e) {
// sash.setBackground(sash.getDisplay().getSystemColor(
// SWT.COLOR_LIST_SELECTION));
// sash.addKeyListener(listener);
// }
//
// public: void focusLost(FocusEvent e) {
// sash.setBackground(null);
// sash.removeKeyListener(listener);
// }
// });
// sash.setFocus();
//
// }
/**
* Add a menu item to the Size Menu
*/
// protected: void addSizeItem(Menu sizeMenu, String labelMessage,
// final Sash sash) {
// MenuItem item = new MenuItem(sizeMenu, SWT.NONE);
// item.setText(labelMessage);
// item.addSelectionListener(new SelectionAdapter() {
// public: void widgetSelected(SelectionEvent e) {
// moveSash(sash);
// }
// });
// item.setEnabled(!isZoomed() && sash != null);
// }
/**
* Returns the workbench page of this pane.
*/
public: SmartPointer<WorkbenchPage> GetPage();
/**
* Add the Left,Right,Up,Botton menu items to the Size menu.
*/
// protected: void addSizeItems(Menu sizeMenu) {
// Sashes sashes = findSashes();
// addSizeItem(sizeMenu,
// WorkbenchMessages.PartPane_sizeLeft, sashes.left);
// addSizeItem(sizeMenu,
// WorkbenchMessages.PartPane_sizeRight, sashes.right);
// addSizeItem(sizeMenu,
// WorkbenchMessages.PartPane_sizeTop, sashes.top);
// addSizeItem(sizeMenu, WorkbenchMessages.PartPane_sizeBottom, sashes.bottom);
// }
/**
* Pin this part.
*/
protected: virtual void DoDock();
/**
* Set the busy state of the pane.
*/
public: virtual void SetBusy(bool isBusy);
/**
* Show a highlight for the receiver if it is
* not currently the part in the front of its
* presentation.
*
*/
public: virtual void ShowHighlight();
/**
* @return
*/
public: virtual void* GetToolBar();
/**
* @return
*/
public: bool HasViewMenu();
/**
* @param location
*/
// public: void ShowViewMenu(Point location) {
//
// }
public: bool IsBusy();
/**
* Writes a description of the layout to the given string buffer.
* This is used for drag-drop test suites to determine if two layouts are the
* same. Like a hash code, the description should compare as equal iff the
* layouts are the same. However, it should be user-readable in order to
* help debug failed tests. Although these are english readable strings,
* they do not need to be translated.
*
* @param buf
*/
public: void DescribeLayout(std::string& buf) const;
/**
* @return
* @since 3.1
*/
public: bool IsCloseable();
public: void SetInLayout(bool inLayout);
public: bool GetInLayout();
public: bool AllowsAutoFocus();
/**
* Clears all contribution items from the contribution managers (this is done separately
* from dispose() since it is done after the part is disposed). This is a bit of a hack.
* Really, the contribution managers should be part of the site, not the PartPane. If these
* were moved elsewhere, then disposal of the PartPane would be atomic and this method could
* be removed.
*/
public: virtual void RemoveContributions();
public: void AddPropertyListener(IPropertyChangeListener::Pointer listener);
public: void RemovePropertyListener(IPropertyChangeListener::Pointer listener);
public: void FirePropertyChange(PropertyChangeEvent::Pointer event);
/* (non-Javadoc)
* @see IPropertyChangeListener#PropertyChange(PropertyChangeEvent::Pointer)
*/
public: void PropertyChange(PropertyChangeEvent::Pointer event);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.LayoutPart#computePreferredSize(boolean, int, int, int)
*/
public: int ComputePreferredSize(bool width, int availableParallel,
int availablePerpendicular, int preferredParallel);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.LayoutPart#getSizeFlags(boolean)
*/
public: int GetSizeFlags(bool horizontal);
/**
* Informs the pane that it's window shell has
* been activated.
*/
public: virtual void ShellActivated();
/**
* Informs the pane that it's window shell has
* been deactivated.
*/
public: virtual void ShellDeactivated();
};
}
#endif /*BERRYPARTPANE_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartPlaceholder.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartPlaceholder.cpp
index 9f957a7913..7232eef7b9 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartPlaceholder.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartPlaceholder.cpp
@@ -1,52 +1,52 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryPartPlaceholder.h"
#include "berryPartStack.h"
namespace berry
{
const std::string PartPlaceholder::WILD_CARD = "*"; //$NON-NLS-1$
PartPlaceholder::PartPlaceholder(const std::string& id) :
StackablePart(id)
{
}
void PartPlaceholder::CreateControl(void* /*parent*/)
{
// do nothing
}
void* PartPlaceholder::GetControl()
{
return 0;
}
bool PartPlaceholder::HasWildCard()
{
return this->GetId().find_first_of(WILD_CARD) != std::string::npos;
}
bool PartPlaceholder::IsPlaceHolder() const
{
return true;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartPlaceholder.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartPlaceholder.h
index 11f4e93472..ce57dd9abc 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartPlaceholder.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartPlaceholder.h
@@ -1,66 +1,66 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYPARTPLACEHOLDER_H_
#define BERRYPARTPLACEHOLDER_H_
#include "berryStackablePart.h"
namespace berry {
/**
* \ingroup org_blueberry_ui_internal
*
* A PlaceHolder is a non-visible stand-in for a layout part.
*/
class PartPlaceholder : public StackablePart {
public:
berryObjectMacro(PartPlaceholder);
/**
* Placeholder ids may contain wildcards. This is the wildcard string.
*
* @since 3.0
*/
static const std::string WILD_CARD; // = "*"; //$NON-NLS-1$
PartPlaceholder(const std::string& id);
/**
* Creates the SWT control
*/
void CreateControl(void* parent);
/**
* Get the part control. This method may return null.
*/
void* GetControl();
/**
* Returns whether this placeholder has a wildcard.
*
* @since 3.0
*/
bool HasWildCard();
bool IsPlaceHolder() const;
};
}
#endif /*BERRYPARTPLACEHOLDER_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartSashContainer.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartSashContainer.cpp
index cde07253af..355af00612 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartSashContainer.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartSashContainer.cpp
@@ -1,1282 +1,1282 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryPartSashContainer.h"
#include "berryLayoutTree.h"
#include "berryLayoutTreeNode.h"
#include "berryPartStack.h"
#include "berryPageLayout.h"
#include "berryPerspective.h"
#include "berryPerspectiveHelper.h"
#include "berryDragUtil.h"
#include "berryWorkbenchPlugin.h"
#include "berryWorkbenchPreferenceConstants.h"
#include "berryGeometry.h"
#include "berryPartPane.h"
#include "tweaklets/berryGuiWidgetsTweaklet.h"
#include "berryConstants.h"
namespace berry
{
bool PartSashContainer::leftToRight = true;
PartSashContainer::ControlListener::ControlListener(
PartSashContainer* container) :
partSashContainer(container)
{
}
GuiTk::IControlListener::Events::Types PartSashContainer::ControlListener::GetEventTypes() const
{
return Events::RESIZED;
}
void PartSashContainer::ControlListener::ControlResized(
GuiTk::ControlEvent::Pointer /*e*/)
{
partSashContainer->ResizeSashes();
}
PartSashContainer::SashContainerDropTarget::SashContainerDropTarget(
PartSashContainer* partSashContainer, Object::Pointer sourcePart, int side,
int cursor, Object::Pointer targetPart) :
partSashContainer(partSashContainer)
{
this->SetTarget(sourcePart, side, cursor, targetPart);
}
void PartSashContainer::SashContainerDropTarget::SetTarget(
Object::Pointer sourcePart, int side, int cursor,
Object::Pointer targetPart)
{
this->side = side;
this->targetPart = targetPart;
this->sourcePart = sourcePart;
this->cursor = cursor;
}
void PartSashContainer::SashContainerDropTarget::Drop()
{
if (side != Constants::NONE)
{
StackablePart::Pointer visiblePart = sourcePart.Cast<StackablePart> ();
if (sourcePart.Cast<IStackableContainer> () != 0)
{
visiblePart = partSashContainer->GetVisiblePart(sourcePart.Cast<
IStackableContainer> ());
}
partSashContainer->DropObject(
partSashContainer->GetVisibleParts(sourcePart), visiblePart,
targetPart, side);
}
}
void PartSashContainer::DropObject(const std::vector<PartPane::Pointer>& toDrop,
StackablePart::Pointer visiblePart, Object::Pointer targetPart, int side)
{
//getControl().setRedraw(false);
// Targetpart is null if there isn't a part under the cursor (all the parts are
// hidden or the container is empty). In this case, the actual side doesn't really
// since we'll be the only visible container and will fill the entire space. However,
// we can't leave it as Constants::CENTER since we can't stack if we don't have something
// to stack on. In this case, we pick Constants::BOTTOM -- this will insert the new pane
// below any currently-hidden parts.
if (targetPart == 0 && side == Constants::CENTER)
{
side = Constants::BOTTOM;
}
PartStack::Pointer targetStack = targetPart.Cast<PartStack> ();
if (targetStack == 0 && targetPart.Cast<PartPane>() != 0)
{
targetStack = targetPart.Cast<PartPane> ()->GetStack();
}
LayoutPart::Pointer targetLayoutPart = targetStack;
// if targetLayoutPart == 0 then we normally got a EditorSashContainer
if (targetLayoutPart == 0)
targetLayoutPart = targetPart.Cast<LayoutPart>();
if (side == Constants::CENTER)
{
if (this->IsStackType(targetStack))
{
for (unsigned int idx = 0; idx < toDrop.size(); idx++)
{
StackablePart::Pointer next = toDrop[idx];
this->Stack(next, targetStack);
}
}
}
else
{
PartStack::Pointer newPart = this->CreateStack();
// if the toDrop array has 1 item propagate the stack
// appearance
if (toDrop.size() == 1 && toDrop[0]->GetStack() != 0)
{
toDrop[0]->GetStack()->CopyAppearanceProperties(newPart);
}
for (unsigned int idx = 0; idx < toDrop.size(); idx++)
{
StackablePart::Pointer next = toDrop[idx];
this->Stack(next, newPart);
}
this->AddEnhanced(newPart, side, this->GetDockingRatio(newPart, targetStack),
targetLayoutPart);
}
if (visiblePart != 0)
{
this->SetVisiblePart(visiblePart->GetContainer(),
visiblePart.Cast<PartPane> ());
}
//getControl().setRedraw(true);
if (visiblePart != 0)
{
visiblePart->SetFocus();
}
}
DnDTweaklet::CursorType PartSashContainer::SashContainerDropTarget::GetCursor()
{
return DnDTweaklet::PositionToCursorType(cursor);
}
Rectangle PartSashContainer::SashContainerDropTarget::GetSnapRectangle()
{
Rectangle targetBounds;
if (targetPart.Cast<LayoutPart> () != 0)
{
targetBounds = DragUtil::GetDisplayBounds(
targetPart.Cast<LayoutPart> ()->GetControl());
}
else if (targetPart.Cast<StackablePart> () != 0)
{
targetBounds = DragUtil::GetDisplayBounds(
targetPart.Cast<StackablePart> ()->GetControl());
}
else
{
targetBounds = DragUtil::GetDisplayBounds(partSashContainer->GetParent());
}
if (side == Constants::CENTER || side == Constants::NONE)
{
return targetBounds;
}
int distance = Geometry::GetDimension(targetBounds, !Geometry::IsHorizontal(
side));
IStackableContainer::Pointer stack = targetPart.Cast<IStackableContainer> ();
if (stack == 0 && targetPart.Cast<StackablePart> () != 0)
{
stack = targetPart.Cast<StackablePart> ()->GetContainer();
}
return Geometry::GetExtrudedEdge(targetBounds, (int) (distance
* partSashContainer->GetDockingRatio(sourcePart, stack)), side);
}
PartSashContainer::PartSashContainer(const std::string& id,
WorkbenchPage* _page, void* _parentWidget) :
LayoutPart(id), parentWidget(_parentWidget), parent(0), page(_page), active(
false), layoutDirty(false)
{
resizeListener = new ControlListener(this);
std::string layout = WorkbenchPlugin::GetDefault()->GetPreferencesService()->
GetSystemPreferences()->Get(WorkbenchPreferenceConstants::PREFERRED_SASH_LAYOUT,
WorkbenchPreferenceConstants::LEFT);
if (layout == WorkbenchPreferenceConstants::RIGHT)
{
leftToRight = false;
}
}
std::vector<PartPane::Pointer> PartSashContainer::GetVisibleParts(
Object::Pointer pane)
{
std::vector<PartPane::Pointer> parts;
if (pane.Cast<PartPane> ().IsNotNull())
{
parts.push_back(pane.Cast<PartPane> ());
}
else if (pane.Cast<PartStack> ().IsNotNull())
{
PartStack::Pointer stack = pane.Cast<PartStack> ();
std::list<StackablePart::Pointer> children = stack->GetChildren();
for (std::list<StackablePart::Pointer>::iterator iter = children.begin(); iter
!= children.end(); ++iter)
{
if (iter->Cast<PartPane> () != 0)
{
parts.push_back(iter->Cast<PartPane> ());
}
}
}
return parts;
}
PartSashContainer::~PartSashContainer()
{
}
void PartSashContainer::FindSashes(LayoutPart::Pointer pane,
PartPane::Sashes& sashes)
{
if (root == 0)
{
return;
}
LayoutTree::Pointer part = root->Find(pane);
if (part == 0)
{
return;
}
part->FindSashes(sashes);
}
void PartSashContainer::Add(LayoutPart::Pointer child)
{
if (child.IsNull())
{
return;
}
this->AddEnhanced(child, Constants::RIGHT, 0.5f, this->FindBottomRight());
}
void PartSashContainer::AddPart(StackablePart::Pointer child)
{
if (child.IsNull())
{
return;
}
PartStack::Pointer newFolder = this->CreateStack();
newFolder->Add(child);
this->AddEnhanced(newFolder, Constants::RIGHT, 0.5f, this->FindBottomRight());
}
void PartSashContainer::AddEnhanced(LayoutPart::Pointer child,
int directionConstant, float ratioForNewPart, LayoutPart::Pointer relative)
{
int relativePosition =
PageLayout::ConstantToLayoutPosition(directionConstant);
float ratioForUpperLeftPart;
if (relativePosition == IPageLayout::RIGHT || relativePosition
== IPageLayout::BOTTOM)
{
ratioForUpperLeftPart = 1.0f - ratioForNewPart;
}
else
{
ratioForUpperLeftPart = ratioForNewPart;
}
this->Add(child, relativePosition, ratioForUpperLeftPart, relative);
}
void PartSashContainer::Add(LayoutPart::Pointer child, int relationship,
float ratio, LayoutPart::Pointer relative)
{
bool isHorizontal = (relationship == IPageLayout::LEFT || relationship
== IPageLayout::RIGHT);
LayoutTree::Pointer node;
if (root != 0 && relative != 0)
{
node = root->Find(relative);
}
Rectangle bounds;
if (this->GetParent() == 0)
{
void* control = this->GetPage()->GetClientComposite();
if (control != 0)
{
bounds = Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetBounds(control);
}
else
{
bounds = Rectangle(0, 0, 800, 600);
}
bounds.x = 0;
bounds.y = 0;
}
else
{
bounds = this->GetBounds();
}
int totalSize = this->MeasureTree(bounds, node, isHorizontal);
int left = (int) (totalSize * ratio);
int right = totalSize - left;
this->Add(child, relationship, left, right, relative);
}
int PartSashContainer::MeasureTree(const Rectangle& outerBounds,
LayoutTree::ConstPointer toMeasure, bool horizontal)
{
if (toMeasure == 0)
{
return outerBounds.GetDimension(horizontal);
}
LayoutTreeNode* parent = toMeasure->GetParent();
if (parent == 0)
{
return outerBounds.GetDimension(horizontal);
}
if (parent->GetSash()->IsHorizontal() == horizontal)
{
return MeasureTree(outerBounds, LayoutTree::ConstPointer(parent), horizontal);
}
bool isLeft = parent->IsLeftChild(toMeasure);
LayoutTree::Pointer otherChild = parent->GetChild(!isLeft);
if (otherChild->IsVisible())
{
int left = parent->GetSash()->GetLeft();
int right = parent->GetSash()->GetRight();
int childSize = isLeft ? left : right;
int bias = parent->GetCompressionBias();
// Normalize bias: 1 = we're fixed, -1 = other child is fixed
if (isLeft)
{
bias = -bias;
}
if (bias == 1)
{
// If we're fixed, return the fixed size
return childSize;
}
else if (bias == -1)
{
// If the other child is fixed, return the size of the parent minus the fixed size of the
// other child
return MeasureTree(outerBounds, LayoutTree::ConstPointer(parent), horizontal) - (left + right
- childSize);
}
// Else return the size of the parent, scaled appropriately
return MeasureTree(outerBounds, LayoutTree::ConstPointer(parent), horizontal) * childSize / (left
+ right);
}
return MeasureTree(outerBounds, LayoutTree::ConstPointer(parent), horizontal);
}
void PartSashContainer::AddChild(const RelationshipInfo& info)
{
LayoutPart::Pointer child = info.part;
children.push_back(child);
if (root == 0)
{
root = new LayoutTree(child);
}
else
{
//Add the part to the tree.
int vertical = (info.relationship == IPageLayout::LEFT || info.relationship
== IPageLayout::RIGHT) ? Constants::VERTICAL : Constants::HORIZONTAL;
bool left = info.relationship == IPageLayout::LEFT || info.relationship
== IPageLayout::TOP;
LayoutPartSash::Pointer sash(new LayoutPartSash(this, vertical));
sash->SetSizes(info.left, info.right);
if ((parent != 0) && child.Cast<PartPlaceholder> ().IsNull())
{
sash->CreateControl(parent);
}
LayoutTree::Pointer newroot =
root->Insert(child, left, sash, info.relative);
root = newroot;
}
this->ChildAdded(child);
if (active)
{
child->CreateControl(parent);
child->SetVisible(true);
child->SetContainer(ILayoutContainer::Pointer(this));
this->ResizeChild(child);
}
}
void PartSashContainer::AddChildForPlaceholder(LayoutPart::Pointer child,
LayoutPart::Pointer placeholder)
{
RelationshipInfo newRelationshipInfo;
newRelationshipInfo.part = child;
if (root != 0)
{
newRelationshipInfo.relationship = IPageLayout::RIGHT;
newRelationshipInfo.relative = root->FindBottomRight();
newRelationshipInfo.left = 200;
newRelationshipInfo.right = 200;
}
// find the relationship info for the placeholder
std::vector<RelationshipInfo> relationships = this->ComputeRelation();
for (unsigned int i = 0; i < relationships.size(); i++)
{
RelationshipInfo info = relationships[i];
if (info.part == placeholder)
{
newRelationshipInfo.left = info.left;
newRelationshipInfo.right = info.right;
newRelationshipInfo.relationship = info.relationship;
newRelationshipInfo.relative = info.relative;
}
}
this->AddChild(newRelationshipInfo);
this->FlushLayout();
}
bool PartSashContainer::AllowsBorder()
{
return true;
}
void PartSashContainer::ChildAdded(LayoutPart::Pointer child)
{
if (this->IsDeferred())
{
child->DeferUpdates(true);
}
}
void PartSashContainer::ChildRemoved(LayoutPart::Pointer child)
{
if (this->IsDeferred())
{
child->DeferUpdates(false);
}
}
std::vector<PartSashContainer::RelationshipInfo> PartSashContainer::ComputeRelation()
{
LayoutTree::Pointer treeRoot = root;
std::list<RelationshipInfo> list;
if (treeRoot == 0)
{
return std::vector<RelationshipInfo>();
}
RelationshipInfo r;
r.part = treeRoot->ComputeRelation(list);
list.push_front(r);
std::vector<RelationshipInfo> result(list.begin(), list.end());
return result;
}
void PartSashContainer::SetActive(bool isActive)
{
if (isActive == active)
{
return;
}
active = isActive;
ILayoutContainer::ChildrenType children = this->children;
for (ILayoutContainer::ChildrenType::iterator childIter = children.begin(); childIter
!= children.end(); ++childIter)
{
if (childIter->Cast<PartStack> ().IsNotNull())
{
PartStack::Pointer stack = childIter->Cast<PartStack> ();
stack->SetActive(isActive);
}
}
if (isActive)
{
this->CreateControl(parentWidget);
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->AddControlListener(parent,
resizeListener);
DragUtil::AddDragTarget(parent, IDragOverListener::Pointer(this));
DragUtil::AddDragTarget(Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetShell(parent)->GetControl(), IDragOverListener::Pointer(this));
ILayoutContainer::ChildrenType children = this->children;
for (ILayoutContainer::ChildrenType::iterator childIter = children.begin(); childIter
!= children.end(); ++childIter)
{
LayoutPart::Pointer child = *childIter;
child->SetContainer(ILayoutContainer::Pointer(this));
child->SetVisible(true); //zoomedPart == null || child == zoomedPart);
if (child.Cast<PartStack> ().IsNull())
{
if (root != 0)
{
LayoutTree::Pointer node = root->Find(child);
if (node != 0)
{
node->FlushCache();
}
}
}
}
if (root != 0)
{
//root.flushChildren();
//if (!isZoomed())
{
root->CreateControl(parent);
}
}
this->ResizeSashes();
}
else
{
DragUtil::RemoveDragTarget(parent, IDragOverListener::Pointer(this));
DragUtil::RemoveDragTarget(Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetShell(parent)->GetControl(), IDragOverListener::Pointer(this));
// remove all Listeners
if (resizeListener != 0 && parent != 0)
{
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->RemoveControlListener(parent,
resizeListener);
}
for (ILayoutContainer::ChildrenType::iterator iter = children.begin(); iter
!= children.end(); ++iter)
{
LayoutPart::Pointer child = *iter;
child->SetContainer(ILayoutContainer::Pointer(0));
if (child.Cast<PartStack> ().IsNotNull())
{
child->SetVisible(false);
}
}
this->DisposeSashes();
//dispose();
}
}
void PartSashContainer::CreateControl(void* parentWidget)
{
if (this->parent != 0)
{
return;
}
parent = this->CreateParent(parentWidget);
ILayoutContainer::ChildrenType children = this->children;
for (ILayoutContainer::ChildrenType::iterator childIter = children.begin(); childIter
!= children.end(); ++childIter)
{
(*childIter)->CreateControl(parent);
}
}
void PartSashContainer::Dispose()
{
if (parent == 0)
{
return;
}
for (ILayoutContainer::ChildrenType::iterator iter = children.begin();
iter != children.end(); ++iter)
{
// In PartSashContainer dispose really means deactivate, so we
// only dispose PartTabFolders.
if (iter->Cast<PartStack>() != 0)
{
(*iter)->Dispose();
}
}
this->DisposeParent();
this->parent = 0;
}
void PartSashContainer::DisposeSashes()
{
if (root != 0)
{
root->DisposeSashes();
}
}
void PartSashContainer::SetVisible(bool makeVisible)
{
if (makeVisible == this->GetVisible())
{
return;
}
//if (!SwtUtil.isDisposed(this.parent))
//{
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->SetEnabled(this->parent, makeVisible);
//}
LayoutPart::SetVisible(makeVisible);
ILayoutContainer::ChildrenType children = this->children;
for (ILayoutContainer::ChildrenType::iterator childIter = children.begin(); childIter
!= children.end(); ++childIter)
{
(*childIter)->SetVisible(makeVisible); // && (zoomedPart == null || child == zoomedPart));
}
}
LayoutPart::Pointer PartSashContainer::FindBottomRight()
{
if (root == 0)
{
return LayoutPart::Pointer(0);
}
return root->FindBottomRight();
}
Rectangle PartSashContainer::GetBounds()
{
return Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetBounds(this->parent);
}
ILayoutContainer::ChildrenType PartSashContainer::GetChildren()
{
return children;
}
void* PartSashContainer::GetControl()
{
return this->parent;
}
LayoutTree::Pointer PartSashContainer::GetLayoutTree()
{
return root;
}
WorkbenchPage::Pointer PartSashContainer::GetPage()
{
return WorkbenchPage::Pointer(page);
}
void* PartSashContainer::GetParent()
{
return parent;
}
bool PartSashContainer::IsChild(LayoutPart::Pointer part)
{
return std::find(children.begin(), children.end(), part) != children.end();
}
void PartSashContainer::ResizeChild(LayoutPart::Pointer childThatChanged)
{
if (root != 0)
{
LayoutTree::Pointer tree = root->Find(childThatChanged);
if (tree != 0)
{
tree->FlushCache();
}
}
this->FlushLayout();
}
void PartSashContainer::Remove(LayoutPart::Pointer child)
{
// if (child == getZoomedPart())
// {
// childRequestZoomOut();
// }
if (!this->IsChild(child))
{
return;
}
children.remove(child);
if (root != 0)
{
root = root->Remove(child);
}
this->ChildRemoved(child);
if (active)
{
child->SetVisible(false);
child->SetContainer(ILayoutContainer::Pointer(0));
this->FlushLayout();
}
}
void PartSashContainer::FlushLayout()
{
layoutDirty = true;
LayoutPart::FlushLayout();
if (layoutDirty)
{
this->ResizeSashes();
}
}
void PartSashContainer::Replace(LayoutPart::Pointer oldChild,
LayoutPart::Pointer newChild)
{
if (!this->IsChild(oldChild))
{
return;
}
// if (oldChild == getZoomedPart())
// {
// if (newChild.Cast<PartPlaceholder> ().IsNotNull())
// {
// childRequestZoomOut();
// }
// else
// {
// zoomedPart.setZoomed(false);
// zoomedPart = newChild;
// zoomedPart.setZoomed(true);
// }
// }
children.erase(std::find(children.begin(), children.end(), oldChild));
children.push_back(newChild);
this->ChildAdded(newChild);
if (root != 0)
{
LayoutTree::Pointer leaf;
leaf = root->Find(oldChild);
if (leaf != 0)
{
leaf->SetPart(newChild);
}
}
this->ChildRemoved(oldChild);
if (active)
{
oldChild->SetVisible(false);
oldChild->SetContainer(ILayoutContainer::Pointer(0));
newChild->CreateControl(parent);
newChild->SetContainer(ILayoutContainer::Pointer(this));
newChild->SetVisible(true); //zoomedPart == null || zoomedPart == newChild);
this->ResizeChild(newChild);
}
}
void PartSashContainer::ResizeSashes()
{
layoutDirty = false;
if (!active)
{
return;
}
// if (isZoomed())
// {
// getZoomedPart().setBounds(parent.getClientArea());
// }
// else
{
if (root != 0)
{
root->SetBounds(Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetClientArea(
parent));
}
}
}
int PartSashContainer::ComputePreferredSize(bool width, int availableParallel,
int availablePerpendicular, int preferredParallel)
{
// if (isZoomed())
// {
// return getZoomedPart().computePreferredSize(width, availableParallel,
// availablePerpendicular, preferredParallel);
// }
if (root != 0)
{
return root->ComputePreferredSize(width, availableParallel,
availablePerpendicular, preferredParallel);
}
return preferredParallel;
}
int PartSashContainer::GetSizeFlags(bool width)
{
// if (isZoomed())
// {
// return getZoomedPart().getSizeFlags(width);
// }
if (root != 0)
{
return root->GetSizeFlags(width);
}
return 0;
}
void PartSashContainer::SetBounds(const Rectangle& r)
{
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->SetBounds(this->parent, r);
}
IDropTarget::Pointer PartSashContainer::Drag(void* /*currentControl*/,
Object::Pointer draggedObject, const Point& position,
const Rectangle& /*dragRectangle*/)
{
if (!(draggedObject.Cast<PartStack> () != 0
|| draggedObject.Cast<PartPane> () != 0))
{
return IDropTarget::Pointer(0);
}
PartPane::Pointer sourcePart = draggedObject.Cast<PartPane> ();
PartStack::Pointer sourceContainer = draggedObject.Cast<PartStack> ();
if (sourceContainer == 0)
{
sourceContainer = sourcePart->GetStack();
}
if (!this->IsStackType(sourceContainer) && !this->IsPaneType(sourcePart))
{
return IDropTarget::Pointer(0);
}
IWorkbenchWindow::Pointer window = sourcePart ? sourcePart->GetWorkbenchWindow() : sourceContainer->GetWorkbenchWindow();
bool differentWindows = window
!= this->GetWorkbenchWindow();
bool editorDropOK = ((sourceContainer->GetAppearance()
== PresentationFactoryUtil::ROLE_EDITOR)
&& window->GetWorkbench()
== this->GetWorkbenchWindow()->GetWorkbench());
if (differentWindows && !editorDropOK)
{
return IDropTarget::Pointer(0);
}
Rectangle containerBounds = DragUtil::GetDisplayBounds(parent);
LayoutPart::Pointer targetPart;
// If this container has no visible children
if (this->GetVisibleChildrenCount(ILayoutContainer::Pointer(this)) == 0)
{
return this->CreateDropTarget(draggedObject, Constants::CENTER,
Constants::CENTER, Object::Pointer(0));
}
if (containerBounds.Contains(position))
{
if (root != 0)
{
targetPart = root->FindPart(
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->ToControl(parent, position));
}
if (targetPart != 0)
{
void* targetControl = targetPart->GetControl();
Rectangle targetBounds = DragUtil::GetDisplayBounds(targetControl);
int side = Geometry::GetClosestSide(targetBounds, position);
int distance =
Geometry::GetDistanceFromEdge(targetBounds, position, side);
// is the source coming from a standalone part
bool standalone = (this->IsStackType(sourceContainer)
&& sourceContainer->IsStandalone()) || (this->IsPaneType(sourcePart)
&& sourcePart->GetStack()->IsStandalone());
// Only allow dropping onto an existing stack from different windows
if (differentWindows && targetPart.Cast<PartStack> () != 0
&& targetPart.Cast<PartStack> ()->GetAppearance()
== PresentationFactoryUtil::ROLE_EDITOR)
{
IDropTarget::Pointer target = targetPart->GetDropTarget(draggedObject,
position);
return target;
}
// Reserve the 5 pixels around the edge of the part for the drop-on-edge cursor
if (distance >= 5 && !standalone)
{
// Otherwise, ask the part if it has any special meaning for this drop location
IDropTarget::Pointer target = targetPart->GetDropTarget(draggedObject,
position);
if (target != 0)
{
return target;
}
}
if (distance > 30 && this->IsStackType(targetPart.Cast<PartStack> ())
&& !standalone)
{
PartStack::Pointer targetContainer = targetPart.Cast<PartStack> ();
if (targetContainer->AllowsAdd(sourcePart))
{
side = Constants::CENTER;
}
}
// If the part doesn't want to override this drop location then drop on the edge
// A "pointless drop" would be one that will put the dragged object back where it started.
// Note that it should be perfectly valid to drag an object back to where it came from -- however,
// the drop should be ignored.
bool pointlessDrop = false; // = isZoomed();
if (!sourcePart && sourceContainer == targetPart)
{
pointlessDrop = true;
}
if ((sourceContainer != 0) && (sourceContainer == targetPart)
&& this->GetVisibleChildrenCount(sourceContainer.Cast<IStackableContainer>()) <= 1)
{
pointlessDrop = true;
}
if (side == Constants::CENTER && sourceContainer == targetPart)
{
pointlessDrop = true;
}
int cursor = side;
if (pointlessDrop)
{
side = Constants::NONE;
cursor = Constants::CENTER;
}
if (sourcePart)
return this->CreateDropTarget(sourcePart, side, cursor, targetPart);
else
return this->CreateDropTarget(sourceContainer, side, cursor, targetPart);
}
}
else
{
// We only allow dropping into a stack, not creating one
if (differentWindows)
return IDropTarget::Pointer(0);
int side = Geometry::GetClosestSide(containerBounds, position);
bool pointlessDrop = false; // = isZoomed();
if (/*(this->IsStackType(sourceContainer) && sourceContainer == this)
||*/ (this->IsPaneType(sourcePart) && this->GetVisibleChildrenCount(
sourceContainer.Cast<IStackableContainer>()) <= 1) && sourceContainer->GetContainer() == this)
{
if (root == 0 || this->GetVisibleChildrenCount(ILayoutContainer::Pointer(this)) <= 1)
{
pointlessDrop = true;
}
}
int cursor = Geometry::GetOppositeSide(side);
if (pointlessDrop)
{
side = Constants::NONE;
}
if (sourcePart)
return this->CreateDropTarget(sourcePart, side, cursor, Object::Pointer(0));
else
return this->CreateDropTarget(sourceContainer, side, cursor, Object::Pointer(0));
}
return IDropTarget::Pointer(0);
}
PartSashContainer::SashContainerDropTarget::Pointer
PartSashContainer::CreateDropTarget(
Object::Pointer sourcePart, int side, int cursor,
Object::Pointer targetPart)
{
if (dropTarget == 0)
{
dropTarget
= new SashContainerDropTarget(this, sourcePart, side, cursor, targetPart);
}
else
{
dropTarget->SetTarget(sourcePart, side, cursor, targetPart);
}
return dropTarget;
}
void PartSashContainer::Stack(StackablePart::Pointer newPart,
IStackableContainer::Pointer container)
{
//this->GetControl().setRedraw(false);
// Only deref the part if it is being referenced in -this- perspective
Perspective::Pointer persp = page->GetActivePerspective();
PerspectiveHelper* pres = (persp != 0) ? persp->GetPresentation() : 0;
if (pres != 0 && container.Cast<PartStack>()->GetAppearance() != PresentationFactoryUtil::ROLE_EDITOR)
{
IWorkbenchPartReference::Pointer newPartRef =
newPart.Cast<PartPane> ()->GetPartReference();
IViewReference::Pointer vRef = newPartRef.Cast<IViewReference> ();
if (vRef != 0)
{
StackablePart::Pointer fpp = pres->FindPart(vRef->GetId(),
vRef->GetSecondaryId());
if (fpp != 0)
{
// Remove the part from old container.
this->DerefPart(newPart);
}
}
}
else
{
// Remove the part from old container.
this->DerefPart(newPart);
}
// Reparent part and add it to the workbook
newPart->Reparent(this->GetParent());
container->Add(newPart);
//getControl().setRedraw(true);
}
void PartSashContainer::DerefPart(StackablePart::Pointer sourcePart)
{
IStackableContainer::Pointer container = sourcePart->GetContainer();
if (container != 0)
{
container->Remove(sourcePart);
if (this->IsStackType(container) && container.Cast<LayoutPart> () != 0)
{
if (container->GetChildren().size() == 0)
{
LayoutPart::Pointer stack = container.Cast<LayoutPart> ();
this->Remove(stack);
stack->Dispose();
}
}
}
}
std::size_t PartSashContainer::GetVisibleChildrenCount(
IStackableContainer::Pointer container)
{
// Treat null as an empty container
if (container == 0)
{
return 0;
}
IStackableContainer::ChildrenType children = container->GetChildren();
std::size_t count = 0;
for (IStackableContainer::ChildrenType::iterator iter = children.begin(); iter
!= children.end(); ++iter)
{
if (!(*iter)->IsPlaceHolder())
{
count++;
}
}
return count;
}
std::size_t PartSashContainer::GetVisibleChildrenCount(
ILayoutContainer::Pointer container)
{
// Treat null as an empty container
if (container == 0)
{
return 0;
}
return container->GetChildren().size();
}
float PartSashContainer::GetDockingRatio(Object::Pointer /*dragged*/,
IStackableContainer::Pointer /*target*/)
{
return 0.5f;
}
void PartSashContainer::DescribeLayout(std::string& buf) const
{
if (root == 0)
{
return;
}
// if (isZoomed())
// {
// buf.append("zoomed "); //$NON-NLS-1$
// root.describeLayout(buf);
// }
// else
{
buf.append("layout "); //$NON-NLS-1$
root->DescribeLayout(buf);
}
}
void PartSashContainer::Add(LayoutPart::Pointer child, int relationship,
int left, int right, LayoutPart::Pointer relative)
{
if (child == 0)
{
return;
}
if (relative != 0 && !this->IsChild(relative))
{
return;
}
if (relationship < IPageLayout::LEFT || relationship > IPageLayout::BOTTOM)
{
relationship = IPageLayout::LEFT;
}
// store info about relative positions
RelationshipInfo info;
info.part = child;
info.relationship = relationship;
info.left = left;
info.right = right;
info.relative = relative;
this->AddChild(info);
}
bool PartSashContainer::AllowsAutoFocus()
{
return true;
}
void PartSashContainer::StartDeferringEvents()
{
LayoutPart::StartDeferringEvents();
ILayoutContainer::ChildrenType deferredChildren = children;
for (ILayoutContainer::ChildrenType::iterator iter = deferredChildren.begin(); iter
!= deferredChildren.end(); ++iter)
{
(*iter)->DeferUpdates(true);
}
}
void PartSashContainer::HandleDeferredEvents()
{
LayoutPart::HandleDeferredEvents();
ILayoutContainer::ChildrenType deferredChildren = children;
for (ILayoutContainer::ChildrenType::iterator iter = deferredChildren.begin(); iter
!= deferredChildren.end(); ++iter)
{
(*iter)->DeferUpdates(false);
}
}
void PartSashContainer::TestInvariants()
{
LayoutPart::TestInvariants();
// If we have a parent container, ensure that we are displaying the zoomed appearance iff
// our parent is zoomed in on us
// if (this->GetContainer() != 0)
// {
// Assert.isTrue((getZoomedPart() != null) == (getContainer().childIsZoomed(
// this)));
// }
ILayoutContainer::ChildrenType childArray = this->GetChildren();
for (ILayoutContainer::ChildrenType::iterator iter = childArray.begin(); iter
!= childArray.end(); ++iter)
{
(*iter)->TestInvariants();
}
// If we're zoomed, ensure that we're actually zoomed into one of our children
// if (isZoomed())
// {
// Assert.isTrue(children.contains(zoomedPart));
// }
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartSashContainer.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartSashContainer.h
index ba96787938..f3ce56c941 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartSashContainer.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartSashContainer.h
@@ -1,703 +1,703 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYPARTSASHCONTAINER_H_
#define BERRYPARTSASHCONTAINER_H_
#include "berryLayoutPart.h"
#include "berryILayoutContainer.h"
#include "berryIStackableContainer.h"
#include "berryIDragOverListener.h"
#include "berryAbstractDropTarget.h"
#include "tweaklets/berryDnDTweaklet.h"
#include "berryRectangle.h"
#include "guitk/berryGuiTkIControlListener.h"
namespace berry
{
class WorkbenchPage;
class PartPane;
class LayoutTree;
class PartStack;
/**
* \ingroup org_blueberry_ui_internal
*
* Abstract container that groups various layout
* parts (possibly other containers) together as
* a unit. Manages the placement and size of these
* layout parts based on the location of sashes within
* the container.
*
* GUI specializations must override the following methods
* (read their documentation for implementation details):
*
* <ul>
* <li>PartSashContainer
*/
class PartSashContainer: public LayoutPart, public ILayoutContainer, public IDragOverListener {
public:
berryObjectMacro(PartSashContainer);
friend class LayoutTree;
friend class LayoutTreeNode;
friend class PageLayout;
private:
void* parentWidget;
//LayoutPart::Pointer zoomedPart;
/* Indicates if the children of a sash container should be aligned from left to right
* or the other way around. This is important if one child does
* not occupy all of the available space. Then the empty space
* is either on the left, or on the right side.
*/
bool static leftToRight;
protected:
struct ControlListener : public GuiTk::IControlListener
{
ControlListener(PartSashContainer* partSashContainer);
Events::Types GetEventTypes() const;
void ControlResized(GuiTk::ControlEvent::Pointer e);
private: PartSashContainer* partSashContainer;
};
void* parent;
GuiTk::IControlListener::Pointer resizeListener;
SmartPointer<LayoutTree> root;
WorkbenchPage* page;
bool active;
bool layoutDirty;
/* Array of LayoutPart */
ILayoutContainer::ChildrenType children;
protected:
struct RelationshipInfo
{
LayoutPart::Pointer part;
LayoutPart::Pointer relative;
int relationship;
/**
* Preferred size for the left child (this would be the size, in pixels of the child
* at the time the sash was last moved)
*/
int left;
/**
* Preferred size for the right child (this would be the size, in pixels of the child
* at the time the sash was last moved)
*/
int right;
};
private:
class SashContainerDropTarget : public AbstractDropTarget {
private:
int side;
int cursor;
// This is a IStackablePart or IStackableContainer
Object::Pointer targetPart;
// This is a IStackablePart or IStackableContainer
Object::Pointer sourcePart;
PartSashContainer* partSashContainer;
public:
berryObjectMacro(SashContainerDropTarget);
SashContainerDropTarget(PartSashContainer* partSashContainer, Object::Pointer sourcePart,
int side, int cursor, Object::Pointer targetPart);
void SetTarget(Object::Pointer sourcePart, int side, int cursor, Object::Pointer targetPart);
void Drop();
DnDTweaklet::CursorType GetCursor();
Rectangle GetSnapRectangle();
};
SashContainerDropTarget::Pointer dropTarget;
public:
/**
* Constructs a PartSashContainer with the given id under the given page
* and parentWidget.
*
* GUI specializations must hook
*/
PartSashContainer(const std::string& id, WorkbenchPage* page,
void* parentWidget);
~PartSashContainer();
/* (non-Javadoc)
* @see org.blueberry.ui.internal.ILayoutContainer#obscuredByZoom(org.blueberry.ui.internal.LayoutPart)
*/
// public: bool childObscuredByZoom(LayoutPart toTest) {
// LayoutPart zoomPart = getZoomedPart();
//
// if (zoomPart != null && toTest != zoomPart) {
// return true;
// }
// return isObscuredByZoom();
// }
/**
* Given an object associated with a drag (a PartPane or PartStack), this returns
* the actual PartPanes being dragged.
*
* @param pane
* @return
*/
private:
std::vector<SmartPointer<PartPane> > GetVisibleParts(Object::Pointer pane);
/**
* Find the sashs around the specified part.
*/
public:
void FindSashes(LayoutPart::Pointer pane, PartPane::Sashes& sashes);
public:
/**
* Add a part.
*/
virtual void Add(LayoutPart::Pointer child);
virtual void AddPart(StackablePart::Pointer child);
/**
* Add a part relative to another. For compatibility only. New code should use
* addEnhanced, above.
*
* @param child the new part to add
* @param relationship one of PageLayout.TOP, PageLayout.BOTTOM, PageLayout.LEFT, or PageLayout.RIGHT
* @param ratio a value between 0.0 and 1.0, indicating how much space will be allocated to the UPPER-LEFT pane
* @param relative part where the new part will be attached
*/
virtual void Add(LayoutPart::Pointer child, int relationship, float ratio,
LayoutPart::Pointer relative);
protected:
virtual void DropObject(const std::vector<PartPane::Pointer>& toDrop,
StackablePart::Pointer visiblePart,
Object::Pointer targetPart, int side);
/**
* Add a new part relative to another. This should be used in place of <code>add</code>.
* It differs as follows:
* <ul>
* <li>relationships are specified using SWT direction constants</li>
* <li>the ratio applies to the newly added child -- not the upper-left child</li>
* </ul>
*
* @param child new part to add to the layout
* @param swtDirectionConstant one of SWT.TOP, SWT.BOTTOM, SWT.LEFT, or SWT.RIGHT
* @param ratioForNewPart a value between 0.0 and 1.0 specifying how much space will be allocated for the newly added part
* @param relative existing part indicating where the new child should be attached
* @since 3.0
*/
protected:
virtual void AddEnhanced(LayoutPart::Pointer child, int swtDirectionConstant,
float ratioForNewPart, LayoutPart::Pointer relative);
protected:
static int MeasureTree(const Rectangle& outerBounds,
SmartPointer<const LayoutTree> toMeasure, bool horizontal);
protected:
virtual void AddChild(const RelationshipInfo& info);
/**
* Adds the child using ratio and position attributes
* from the specified placeholder without replacing
* the placeholder
*
* FIXME: I believe there is a bug in computeRelation()
* when a part is positioned relative to the editorarea.
* We end up with a null relative and 0.0 for a ratio.
*/
protected:
virtual void AddChildForPlaceholder(LayoutPart::Pointer child,
LayoutPart::Pointer placeholder);
/**
* See ILayoutContainer#allowBorder
*/
public:
virtual bool AllowsBorder();
/**
* Notification that a child layout part has been
* added to the container. Subclasses may override
* this method to perform any container specific
* work.
*/
protected:
virtual void ChildAdded(LayoutPart::Pointer child);
/**
* Notification that a child layout part has been
* removed from the container. Subclasses may override
* this method to perform any container specific
* work.
*/
protected:
virtual void ChildRemoved(LayoutPart::Pointer child);
/**
* Returns an array with all the relation ship between the
* parts.
*/
public:
virtual std::vector<RelationshipInfo> ComputeRelation();
public:
virtual void SetActive(bool isActive);
/**
* @see LayoutPart#getControl
*/
public:
void CreateControl(void* parentWidget);
/**
* Subclasses override this method to specify
* the composite to use to parent all children
* layout parts it contains.
*/
protected:
virtual void* CreateParent(void* parentWidget) = 0;
/**
* @see LayoutPart#dispose
*/
public:
virtual void Dispose();
/**
* Subclasses override this method to dispose
* of any swt resources created during createParent.
*/
protected:
virtual void DisposeParent() = 0;
/**
* Dispose all sashs used in this perspective.
*/
public:
virtual void DisposeSashes();
/* (non-Javadoc)
* @see org.blueberry.ui.internal.LayoutPart#setVisible(boolean)
*/
public:
void SetVisible(bool makeVisible);
/**
* Return the most bottom right part or null if none.
*/
public:
virtual LayoutPart::Pointer FindBottomRight();
/**
* @see LayoutPart#getBounds
*/
public:
Rectangle GetBounds();
/**
* @see ILayoutContainer#getChildren
*/
public:
ChildrenType GetChildren();
/**
* @see LayoutPart#getControl
*/
public:
void* GetControl();
public:
virtual SmartPointer<LayoutTree> GetLayoutTree();
/**
* For themes.
*
* @return the current WorkbenchPage.
*/
public:
virtual SmartPointer<WorkbenchPage> GetPage();
/**
* Returns the composite used to parent all the
* layout parts contained within.
*/
public:
virtual void* GetParent();
protected:
virtual bool IsChild(LayoutPart::Pointer part);
/**
* Returns whether this container is zoomed.
*/
// public: bool IsZoomed() {
// return (zoomedPart != null);
// }
/* (non-Javadoc)
* @see org.blueberry.ui.internal.LayoutPart#forceLayout(org.blueberry.ui.internal.LayoutPart)
*/
public:
void ResizeChild(LayoutPart::Pointer childThatChanged);
/**
* Remove a part.
*/
public:
void Remove(LayoutPart::Pointer child);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.LayoutPart#forceLayout()
*/
public:
void FlushLayout();
/**
* Replace one part with another.
*/
public:
void Replace(LayoutPart::Pointer oldChild, LayoutPart::Pointer newChild);
private:
void ResizeSashes();
/**
* Returns the maximum size that can be utilized by this part if the given width and
* height are available. Parts can overload this if they have a quantized set of preferred
* sizes.
*
* @param width available horizontal space (pixels)
* @return returns a new point where point.x is <= availableWidth and point.y is <= availableHeight
*/
public:
virtual int ComputePreferredSize(bool width, int availableParallel,
int availablePerpendicular, int preferredParallel);
public:
int GetSizeFlags(bool width);
/**
* @see LayoutPart#setBounds
*/
public:
void SetBounds(const Rectangle& r);
/**
* Zoom in on a particular layout part.
*
* The implementation of zoom is quite simple. When zoom occurs we create
* a zoom root which only contains the zoom part. We store the old
* root in unzoomRoot and then active the zoom root. When unzoom occurs
* we restore the unzoomRoot and dispose the zoom root.
*
* Note: Method assumes we are active.
*/
// private: void zoomIn(LayoutPart part) {
// // Sanity check.
// if (isZoomed()) {
// return;
// }
//
// // Hide the sashes
// root.disposeSashes();
//
// // Make all parts invisible except for the zoomed part
// LayoutPart[] children = getChildren();
// for (int i = 0; i < children.length; i++) {
// LayoutPart child = children[i];
// child.setVisible(child == part);
// }
//
// zoomedPart = part;
//
// // Notify the part that it has been zoomed
// part.setZoomed(true);
//
// // Remember that we need to trigger a layout
// layoutDirty = true;
// }
/**
* Returns the currently zoomed part or null if none
*
* @return the currently zoomed part or null if none
* @since 3.1
*/
// public: LayoutPart getZoomedPart() {
// return zoomedPart;
// }
// public: void childRequestZoomIn(LayoutPart toZoom) {
// if (!SwtUtil.isDisposed(this.parent)) {
// this.parent.setRedraw(false);
// }
// try {
// zoomIn(toZoom);
//
// requestZoomIn();
//
// if (layoutDirty) {
// resizeSashes();
// }
// } finally {
// if (!SwtUtil.isDisposed(this.parent)) {
// this.parent.setRedraw(true);
// }
// }
// }
// public: void childRequestZoomOut() {
// if (!SwtUtil.isDisposed(this.parent)) {
// this.parent.setRedraw(false);
// }
// try {
// zoomOut();
//
// requestZoomOut();
//
// if (layoutDirty) {
// resizeSashes();
// }
// } finally {
// if (!SwtUtil.isDisposed(this.parent)) {
// this.parent.setRedraw(true);
// }
// }
// }
/* (non-Javadoc)
* @see org.blueberry.ui.internal.LayoutPart#setZoomed(boolean)
*/
// public: void setZoomed(boolean isZoomed) {
// if (!isZoomed) {
// zoomOut();
// } else {
// if (!isZoomed()) {
// LayoutPart toZoom = pickPartToZoom();
//
// if (toZoom != null) {
// zoomIn(toZoom);
// }
// }
// }
// super.setZoomed(isZoomed);
// }
// public: LayoutPart pickPartToZoom() {
// return findBottomRight();
// }
/**
* Zoom out.
*
* See zoomIn for implementation details.
*
* Note: Method assumes we are active.
*/
// private: void zoomOut() {
// // Sanity check.
// if (!isZoomed()) {
// return;
// }
//
// LayoutPart zoomedPart = this.zoomedPart;
// this.zoomedPart = null;
// // Inform the part that it is no longer zoomed
// zoomedPart.setZoomed(false);
//
// // Make all children visible
// LayoutPart[] children = getChildren();
// for (int i = 0; i < children.length; i++) {
// LayoutPart child = children[i];
//
// child.setVisible(true);
// }
//
// // Recreate the sashes
// root.createControl(getParent());
//
// // Ensure that the part being un-zoomed will have its size refreshed.
// LayoutTree node = root.find(zoomedPart);
// node.flushCache();
//
// layoutDirty = true;
// }
/* (non-Javadoc)
* @see org.blueberry.ui.internal.dnd.IDragOverListener#drag(org.blueberry.swt.widgets.Control, java.lang.Object, org.blueberry.swt.graphics.Point, org.blueberry.swt.graphics.Rectangle)
*/
public:
IDropTarget::Pointer Drag(void* currentControl, Object::Pointer draggedObject,
const Point& position, const Rectangle& dragRectangle);
/**
* @param sourcePart
* @param targetPart
* @param side
* @param cursor
* @return
* @since 3.1
*/
private:
SashContainerDropTarget::Pointer CreateDropTarget(Object::Pointer sourcePart, int side, int cursor, Object::Pointer targetPart);
/**
* Returns true iff this PartSashContainer allows its parts to be stacked onto the given
* container.
*
* @param container
* @return
*/
public:
virtual bool IsStackType(IStackableContainer::Pointer toTest) = 0;
public:
virtual bool IsPaneType(StackablePart::Pointer toTest) = 0;
protected:
virtual SmartPointer<PartStack> CreateStack() = 0;
public:
virtual void Stack(StackablePart::Pointer newPart, SmartPointer<IStackableContainer> container);
/**
* @param container
* @param visiblePart
*/
protected:
virtual void SetVisiblePart(IStackableContainer::Pointer container,
SmartPointer<PartPane> visiblePart) = 0;
/**
* @param container
* @return
*/
protected:
virtual StackablePart::Pointer GetVisiblePart(
IStackableContainer::Pointer container) = 0;
/**
* @param sourcePart
*/
protected:
virtual void DerefPart(StackablePart::Pointer sourcePart);
protected:
virtual std::size_t GetVisibleChildrenCount(IStackableContainer::Pointer container);
virtual std::size_t GetVisibleChildrenCount(ILayoutContainer::Pointer container);
protected:
virtual float
GetDockingRatio(Object::Pointer dragged, IStackableContainer::Pointer target);
/**
* Writes a description of the layout to the given string buffer.
* This is used for drag-drop test suites to determine if two layouts are the
* same. Like a hash code, the description should compare as equal iff the
* layouts are the same. However, it should be user-readable in order to
* help debug failed tests. Although these are english readable strings,
* they should not be translated or equality tests will fail.
*
* @param buf
*/
public:
void DescribeLayout(std::string& buf) const;
/**
* Adds a new child to the container relative to some part
*
* @param child
* @param relationship
* @param left preferred pixel size of the left/top child
* @param right preferred pixel size of the right/bottom child
* @param relative relative part
*/
protected:
virtual void Add(LayoutPart::Pointer child, int relationship, int left, int right,
LayoutPart::Pointer relative);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.ILayoutContainer#isZoomed(org.blueberry.ui.internal.LayoutPart)
*/
// public: bool childIsZoomed(LayoutPart toTest) {
// return toTest == getZoomedPart();
// }
/* (non-Javadoc)
* @see org.blueberry.ui.internal.ILayoutContainer#allowsAutoFocus()
*/
public:
bool AllowsAutoFocus();
/* (non-Javadoc)
* @see org.blueberry.ui.internal.LayoutPart#startDeferringEvents()
*/
protected:
void StartDeferringEvents();
/* (non-Javadoc)
* @see org.blueberry.ui.internal.LayoutPart#handleDeferredEvents()
*/
protected:
void HandleDeferredEvents();
/* (non-Javadoc)
* @see org.blueberry.ui.internal.LayoutPart#testInvariants()
*/
public:
void TestInvariants();
};
}
#endif /*BERRYPARTSASHCONTAINER_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartSite.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartSite.cpp
index 0f854b0c1b..94737b4230 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartSite.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartSite.cpp
@@ -1,360 +1,360 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryPartSite.h"
#include "berryIWorkbenchPart.h"
#include "berryIWorkbenchPage.h"
#include "berryIWorkbenchWindow.h"
#include "berryPartPane.h"
#include "services/berryIServiceFactory.h"
#include "berryIServiceLocatorCreator.h"
#include "berryWorkbenchPartReference.h"
namespace berry
{
//void
//PartSite::RegisterContextMenu(const std::string& menuId,
// const MenuManager menuManager,
// const ISelectionProvider selectionProvider,
// bool includeEditorInput, IWorkbenchPart::ConstPointer part,
// const Collection menuExtenders) {
// /*
// * Check to see if the same menu manager and selection provider have
// * already been used. If they have, then we can just add another menu
// * identifier to the existing PopupMenuExtender.
// */
// final Iterator extenderItr = menuExtenders.iterator();
// boolean foundMatch = false;
// while (extenderItr.hasNext()) {
// final PopupMenuExtender existingExtender = (PopupMenuExtender) extenderItr
// .next();
// if (existingExtender.matches(menuManager, selectionProvider, part)) {
// existingExtender.addMenuId(menuId);
// foundMatch = true;
// break;
// }
// }
//
// if (!foundMatch) {
// menuExtenders.add(new PopupMenuExtender(menuId, menuManager,
// selectionProvider, part, includeEditorInput));
// }
// }
PartSite::PartSite(IWorkbenchPartReference::Pointer ref,
IWorkbenchPart::Pointer _part, IWorkbenchPage* _page) :
partReference(ref), part(_part), page(_page),
serviceLocatorOwner(new ServiceLocatorOwner(this))
{
extensionID = "org.blueberry.ui.UnknownID"; //$NON-NLS-1$
extensionName = "Unknown Name"; //$NON-NLS-1$
// Initialize the service locator.
IServiceLocator::Pointer parentServiceLocator(page->GetWorkbenchWindow());
IServiceLocatorCreator::Pointer slc(parentServiceLocator
->GetService(IServiceLocatorCreator::GetManifestName()).Cast<IServiceLocatorCreator>());
this->serviceLocator = slc->CreateServiceLocator(IServiceLocator::WeakPtr(parentServiceLocator),
IServiceFactory::Pointer(0), IDisposable::WeakPtr(serviceLocatorOwner)).Cast<ServiceLocator>();
//initializeDefaultServices();
}
PartSite::~PartSite()
{
}
PartSite::ServiceLocatorOwner::ServiceLocatorOwner(PartSite* s)
: site(s)
{
}
void PartSite::ServiceLocatorOwner::Dispose()
{
void* control = site->GetPane()->GetControl();
if (control != 0) {
site->GetPane()->DoHide();
}
}
void PartSite::InitializeDefaultServices()
{
// serviceLocator.registerService(IWorkbenchPartSite.class, this);
// final Expression defaultExpression = new ActivePartExpression(part);
//
// final IContextService parentContextService = (IContextService) serviceLocator
// .getService(IContextService.class);
// final IContextService contextService = new SlaveContextService(
// parentContextService, defaultExpression);
// serviceLocator.registerService(IContextService.class, contextService);
//
// final ICommandService parentCommandService = (ICommandService) serviceLocator
// .getService(ICommandService.class);
// final ICommandService commandService = new SlaveCommandService(
// parentCommandService, IServiceScopes.PARTSITE_SCOPE,
// this);
// serviceLocator.registerService(ICommandService.class, commandService);
}
//IActionBars
//PartSite::GetActionBars() {
// return actionBars;
// }
std::string PartSite::GetId()
{
return extensionID;
}
IWorkbenchPage::Pointer PartSite::GetPage()
{
return IWorkbenchPage::Pointer(page);
}
PartPane::Pointer PartSite::GetPane()
{
return partReference.Lock().Cast<WorkbenchPartReference>()->GetPane();
}
IWorkbenchPart::Pointer PartSite::GetPart()
{
return IWorkbenchPart::Pointer(part);
}
IWorkbenchPartReference::Pointer PartSite::GetPartReference()
{
return partReference.Lock();
}
std::string PartSite::GetPluginId()
{
return pluginID;
}
std::string PartSite::GetRegisteredName()
{
return extensionName;
}
ISelectionProvider::Pointer
PartSite::GetSelectionProvider()
{
return selectionProvider;
}
Shell::Pointer PartSite::GetShell()
{
PartPane::Pointer pane = GetPane();
if (!pane) return GetWorkbenchWindow()->GetShell();
return pane->GetShell();
}
IWorkbenchWindow::Pointer PartSite::GetWorkbenchWindow()
{
return page->GetWorkbenchWindow();
}
// void
// PartSite::RegisterContextMenu(const std::string& menuID,
// MenuManager menuMgr,
// ISelectionProvider selProvider) {
// if (menuExtenders == null) {
// menuExtenders = new ArrayList(1);
// }
//
// registerContextMenu(menuID, menuMgr, selProvider, true, getPart(),
// menuExtenders);
// }
//void
//PartSite::RegisterContextMenu(MenuManager menuMgr,
// ISelectionProvider selProvider) {
// registerContextMenu(getId(), menuMgr, selProvider);
// }
//void
//PartSite::GetContextMenuIds(std::vector<std::string>& menuIds) {
// if (menuExtenders == null) {
// return new String[0];
// }
// ArrayList menuIds = new ArrayList(menuExtenders.size());
// for (Iterator iter = menuExtenders.iterator(); iter.hasNext();) {
// final PopupMenuExtender extender = (PopupMenuExtender) iter.next();
// menuIds.addAll(extender.getMenuIds());
// }
// return (String[]) menuIds.toArray(new String[menuIds.size()]);
// }
//void
//PartSite::SetActionBars(SubActionBars bars) {
// actionBars = bars;
// }
void PartSite::SetConfigurationElement(
IConfigurationElement::Pointer configElement)
{
// Get extension ID.
configElement->GetAttribute("id", extensionID); //$NON-NLS-1$
// Get plugin ID.
pluginID = configElement->GetContributor();
// Get extension name.
std::string name;
configElement->GetAttribute("name", name); //$NON-NLS-1$
if (name != "")
{
extensionName = name;
}
}
void PartSite::SetPluginId(const std::string& pluginId)
{
this->pluginID = pluginId;
}
void PartSite::SetId(const std::string& id)
{
extensionID = id;
}
void PartSite::SetPart(IWorkbenchPart::Pointer newPart)
{
part = newPart;
}
void PartSite::SetRegisteredName(const std::string& name)
{
extensionName = name;
}
void PartSite::SetSelectionProvider(ISelectionProvider::Pointer provider)
{
selectionProvider = provider;
}
/*
* @see IWorkbenchPartSite#getKeyBindingService()
*
* TODO deprecated: use IHandlerService instead
*/
//IKeyBindingService
//PartSite::GetKeyBindingService() {
// if (keyBindingService == null) {
// keyBindingService = new KeyBindingService(this);
//
// // TODO why is this here? and it should be using HandlerSubmissions
// // directly..
// if (this instanceof EditorSite) {
// EditorActionBuilder.ExternalContributor contributor = (EditorActionBuilder.ExternalContributor) ((EditorSite) this)
// .getExtensionActionBarContributor();
//
// if (contributor != null) {
// ActionDescriptor[] actionDescriptors = contributor
// .getExtendedActions();
//
// if (actionDescriptors != null) {
// for (int i = 0; i < actionDescriptors.length; i++) {
// ActionDescriptor actionDescriptor = actionDescriptors[i];
//
// if (actionDescriptor != null) {
// IAction action = actionDescriptors[i]
// .getAction();
//
// if (action != null
// && action.getActionDefinitionId() != null) {
// keyBindingService.registerAction(action);
// }
// }
// }
// }
// }
// }
// }
//
// return keyBindingService;
// }
std::string PartSite::GetInitialScopeId()
{
return "";
}
void* PartSite::GetAdapterImpl(const std::type_info& /*adapter*/) const
{
// if (IWorkbenchSiteProgressService.class == adapter) {
// return getSiteProgressService();
// }
//
// if (IWorkbenchPartTestable.class == adapter) {
// return new WorkbenchPartTestable(this);
// }
//
// return Platform.getAdapterManager().getAdapter(this, adapter);
return 0;
}
//void
//PartSite::ActivateActionBars(bool forceVisibility) {
// if (actionBars != null) {
// actionBars.activate(forceVisibility);
// }
// }
//void
//PartSite::DeactivateActionBars(bool forceHide) {
// if (actionBars != null) {
// actionBars.deactivate(forceHide);
// }
// }
//WorkbenchSiteProgressService
//PartSite::GetSiteProgressService() {
// if (progressService == null) {
// progressService = new WorkbenchSiteProgressService(this);
// }
// return progressService;
// }
Object::Pointer
PartSite::GetService(const std::string& api) {
return serviceLocator->GetService(api);
}
bool
PartSite::HasService(const std::string& api) const {
return serviceLocator->HasService(api);
}
std::string PartSite::ToString()
{
std::string buffer = "PartSite(id=" + this->GetId() + ",pluginId="
+ this->GetPluginId() + ",registeredName=" + this->GetRegisteredName()
+ ")";
return buffer;
}
} // namespace berry
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartSite.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartSite.h
index d236a169f8..b14c6f1476 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartSite.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartSite.h
@@ -1,310 +1,310 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYPARTSITE_H_
#define BERRYPARTSITE_H_
#include <berryIConfigurationElement.h>
#include "berryServiceLocator.h"
#include "berryIWorkbenchPartSite.h"
#include "berryIWorkbenchPartReference.h"
#include "berryISelectionProvider.h"
namespace berry {
struct IWorkbenchPart;
struct IWorkbenchPage;
struct IWorkbenchWindow;
class PartPane;
class Shell;
/**
* \ingroup org_blueberry_ui_internal
*
* <code>PartSite</code> is the general implementation for an
* <code>IWorkbenchPartSite</code>. A site maintains the context for a part,
* including the part, its pane, active contributions, selection provider, etc.
* Together, these components make up the complete behavior for a part as if it
* was implemented by one person.
*
* The <code>PartSite</code> lifecycle is as follows ..
*
* <ol>
* <li>a site is constructed </li>
* <li>a part is constructed and stored in the part </li>
* <li>the site calls part.init() </li>
* <li>a pane is constructed and stored in the site </li>
* <li>the action bars for a part are constructed and stored in the site </li>
* <li>the pane is added to a presentation </li>
* <li>the SWT widgets for the pane and part are created </li>
* <li>the site is activated, causing the actions to become visible </li>
* </ol>
*/
class PartSite : public virtual IWorkbenchPartSite {
public:
berryObjectMacro(PartSite);
/**
* This is a helper method for the register context menu functionality. It
* is provided so that different implementations of the
* <code>IWorkbenchPartSite</code> interface don't have to worry about how
* context menus should work.
*
* @param menuId
* the menu id
* @param menuManager
* the menu manager
* @param selectionProvider
* the selection provider
* @param includeEditorInput
* whether editor inputs should be included in the structured
* selection when calculating contributions
* @param part
* the part for this site
* @param menuExtenders
* the collection of menu extenders for this site
* @see IWorkbenchPartSite#registerContextMenu(MenuManager,
* ISelectionProvider)
*/
//public: static void RegisterContextMenu(const std::string& menuId,
// const MenuManager menuManager,
// const ISelectionProvider selectionProvider,
// bool includeEditorInput, IWorkbenchPart::ConstPointer part,
// const Collection menuExtenders);
private:
IWorkbenchPartReference::WeakPtr partReference;
WeakPointer<IWorkbenchPart> part;
IWorkbenchPage* page;
std::string extensionID;
std::string pluginID;
std::string extensionName;
ISelectionProvider::Pointer selectionProvider;
//SubActionBars actionBars;
//KeyBindingService keyBindingService;
//ArrayList menuExtenders;
//WorkbenchSiteProgressService progressService;
struct ServiceLocatorOwner : public IDisposable
{
ServiceLocatorOwner(PartSite* site);
PartSite* site;
void Dispose();
};
ServiceLocatorOwner::Pointer serviceLocatorOwner;
protected:
ServiceLocator::Pointer serviceLocator;
/**
* Build the part site.
*
* @param ref
* the part reference
* @param part
* the part
* @param page
* the page it belongs to
*/
public: PartSite(IWorkbenchPartReference::Pointer ref, SmartPointer<IWorkbenchPart> part,
IWorkbenchPage* page);
/**
* Initialize the local services.
*/
private: void InitializeDefaultServices();
/**
* Dispose the contributions.
*/
public: ~PartSite();
/**
* Returns the action bars for the part. If this part is a view then it has
* exclusive use of the action bars. If this part is an editor then the
* action bars are shared among this editor and other editors of the same
* type.
*/
//public: virtual IActionBars GetActionBars();
/**
* Returns the part registry extension ID.
*
* @return the registry extension ID
*/
public: virtual std::string GetId();
/**
* Returns the page containing this workbench site's part.
*
* @return the page containing this part
*/
public: virtual SmartPointer<IWorkbenchPage> GetPage();
/**
* Gets the part pane.
*/
public: SmartPointer<PartPane> GetPane();
/**
* Returns the part.
*/
public: virtual SmartPointer<IWorkbenchPart> GetPart();
/**
* Returns the part reference.
*/
public: virtual IWorkbenchPartReference::Pointer GetPartReference();
/**
* Returns the part registry plugin ID. It cannot be <code>null</code>.
*
* @return the registry plugin ID
*/
public: virtual std::string GetPluginId();
/**
* Returns the registered name for this part.
*/
public: virtual std::string GetRegisteredName();
/**
* Returns the selection provider for a part.
*/
public: virtual ISelectionProvider::Pointer GetSelectionProvider();
/**
* Returns the shell containing this part.
*
* @return the shell containing this part
*/
public: SmartPointer<Shell> GetShell();
/**
* Returns the workbench window containing this part.
*
* @return the workbench window containing this part
*/
public: virtual SmartPointer<IWorkbenchWindow> GetWorkbenchWindow();
/**
* Register a popup menu for extension.
*/
//public: virtual void RegisterContextMenu(const std::string& menuID,
// MenuManager menuMgr,
// ISelectionProvider selProvider);
/**
* Register a popup menu with the default id for extension.
*/
//public: virtual void RegisterContextMenu(MenuManager menuMgr,
// ISelectionProvider selProvider);
// getContextMenuIds() added by Dan Rubel (dan_rubel@instantiations.com)
/**
* Get the registered popup menu identifiers
*/
//public: virtual void GetContextMenuIds(std::vector<std::string>& menuIds);
/**
* Sets the action bars for the part.
*/
//public: virtual void SetActionBars(SubActionBars bars);
/**
* Sets the configuration element for a part.
*/
public: virtual void SetConfigurationElement(IConfigurationElement::Pointer configElement);
protected: virtual void SetPluginId(const std::string& pluginId);
/**
* Sets the part registry extension ID.
*
* @param id
* the registry extension ID
*/
protected: virtual void SetId(const std::string& id);
/**
* Sets the part.
*/
public: virtual void SetPart(SmartPointer<IWorkbenchPart> newPart);
/**
* Sets the registered name for this part.
*
* @param name
* the registered name
*/
protected: virtual void SetRegisteredName(const std::string& name);
/**
* Set the selection provider for a part.
*/
public: virtual void SetSelectionProvider(ISelectionProvider::Pointer provider);
/*
* @see IWorkbenchPartSite#getKeyBindingService()
*
* TODO deprecated: use IHandlerService instead
*/
//public: virtual IKeyBindingService GetKeyBindingService();
protected: virtual std::string GetInitialScopeId();
/**
* Get an adapter for this type.
*
* @param adapter
* @return
*/
protected: void* GetAdapterImpl(const std::type_info& adapter) const;
//public: virtual void ActivateActionBars(bool forceVisibility);
//public: virtual void DeactivateActionBars(bool forceHide);
/**
* Get a progress service for the receiver.
*
* @return WorkbenchSiteProgressService
*/
//public: virtual WorkbenchSiteProgressService GetSiteProgressService();
public: Object::Pointer GetService(const std::string& api);
public: bool HasService(const std::string& api) const;
/**
* Prints out the identifier, the plug-in identifier and the registered
* name. This is for debugging purposes only.
*
* @since 3.2
*/
public: virtual std::string ToString();
};
} // namespace berry
#endif /*BERRYPARTSITE_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartStack.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartStack.cpp
index 8fe1ff91ad..79682ce230 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartStack.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartStack.cpp
@@ -1,1607 +1,1607 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryPartStack.h"
#include "berryPerspective.h"
#include "berryPresentationFactoryUtil.h"
#include "berryWorkbenchPlugin.h"
#include "berryPresentationSerializer.h"
#include "berryDragUtil.h"
#include "berryEditorAreaHelper.h"
#include "berryPerspectiveHelper.h"
#include "berryWorkbenchConstants.h"
#include "berryXMLMemento.h"
#include "berryIWorkbenchPartConstants.h"
#include "berryGeometry.h"
#include "tweaklets/berryGuiWidgetsTweaklet.h"
#include <berryObjects.h>
#include <Poco/HashSet.h>
namespace berry
{
const int PartStack::PROP_SELECTION = 0x42;
PartStack::PartStackDropResult::Pointer PartStack::dropResult(
new PartStack::PartStackDropResult());
void PartStack::PartStackDropResult::SetTarget(PartStack::Pointer stack,
PartPane::Pointer pane, StackDropResult::Pointer result)
{
this->pane = pane;
this->dropResult = result;
this->stack = stack;
}
void PartStack::PartStackDropResult::Drop()
{
// If we're dragging a pane over itself do nothing
//if (dropResult.getInsertionPoint() == pane.getPresentablePart()) { return; };
Object::Pointer cookie;
if (dropResult != 0)
{
cookie = dropResult->GetCookie();
}
PartPane::Pointer pane(this->pane);
PartStack::Pointer stack(this->stack);
// Handle cross window drops by opening a new editor
if (pane->GetPartReference().Cast<IEditorReference> () != 0)
{
IEditorReference::Pointer editorRef = pane->GetPartReference().Cast<
IEditorReference> ();
if (pane->GetWorkbenchWindow() != stack->GetWorkbenchWindow())
{
try
{
IEditorInput::Pointer input = editorRef->GetEditorInput();
// Close the old editor and capture the actual closed state incase of a 'cancel'
bool editorClosed = pane->GetPage()->CloseEditor(editorRef, true);
// Only open open the new editor if the old one closed
if (editorClosed)
stack->GetPage()->OpenEditor(input, editorRef->GetId());
return;
} catch (PartInitException& e)
{
//e.printStackTrace();
BERRY_ERROR << e.displayText();
}
}
}
if (pane->GetContainer() != stack)
{
// Moving from another stack
stack->DerefPart(pane);
pane->Reparent(stack->GetParent());
stack->Add(pane, cookie);
stack->SetSelection(pane);
pane->SetFocus();
}
else if (cookie != 0)
{
// Rearranging within this stack
stack->GetPresentation()->MovePart(stack->GetPresentablePart(pane), cookie);
}
}
DnDTweaklet::CursorType PartStack::PartStackDropResult::GetCursor()
{
return DnDTweaklet::CURSOR_CENTER;
}
Rectangle PartStack::PartStackDropResult::GetSnapRectangle()
{
if (dropResult == 0)
{
return DragUtil::GetDisplayBounds(stack.Lock()->GetControl());
}
return dropResult->GetSnapRectangle();
}
PartStack::MyStackPresentationSite::MyStackPresentationSite(PartStack* stack) :
partStack(stack)
{
}
void PartStack::MyStackPresentationSite::Close(IPresentablePart::Pointer part)
{
partStack->Close(part);
}
void PartStack::MyStackPresentationSite::Close(const std::vector<
IPresentablePart::Pointer>& parts)
{
partStack->Close(parts);
}
void PartStack::MyStackPresentationSite::DragStart(
IPresentablePart::Pointer beingDragged, Point& initialLocation,
bool keyboard)
{
partStack->DragStart(beingDragged, initialLocation, keyboard);
}
void PartStack::MyStackPresentationSite::DragStart(Point& initialLocation,
bool keyboard)
{
partStack->DragStart(IPresentablePart::Pointer(0), initialLocation, keyboard);
}
bool PartStack::MyStackPresentationSite::IsPartMoveable(
IPresentablePart::Pointer part)
{
return partStack->IsMoveable(part);
}
void PartStack::MyStackPresentationSite::SelectPart(
IPresentablePart::Pointer toSelect)
{
partStack->PresentationSelectionChanged(toSelect);
}
bool PartStack::MyStackPresentationSite::SupportsState(int state)
{
return partStack->SupportsState(state);
}
void PartStack::MyStackPresentationSite::SetState(int newState)
{
partStack->SetState(newState);
}
IPresentablePart::Pointer PartStack::MyStackPresentationSite::GetSelectedPart()
{
return partStack->GetSelectedPart();
}
// void AddSystemActions(IMenuManager menuManager) {
// PartStack.this.addSystemActions(menuManager);
// }
bool PartStack::MyStackPresentationSite::IsStackMoveable()
{
return partStack->CanMoveFolder();
}
void PartStack::MyStackPresentationSite::FlushLayout()
{
partStack->FlushLayout();
}
PartStack::PresentableVector PartStack::MyStackPresentationSite::GetPartList()
{
return partStack->GetPresentableParts();
}
std::string PartStack::MyStackPresentationSite::GetProperty(
const std::string& id)
{
return partStack->GetProperty(id);
}
PartStack::PartStack(WorkbenchPage* p, bool allowsStateChanges,
int appear, IPresentationFactory* fac) :
LayoutPart("PartStack"), page(p), isActive(true), allowStateChanges(
allowsStateChanges), appearance(appear), ignoreSelectionChanges(false),
factory(fac)
{
std::stringstream buf;
buf << "PartStack@" << this;
this->SetID(buf.str());
presentationSite = new MyStackPresentationSite(this);
}
bool PartStack::IsMoveable(IPresentablePart::Pointer part)
{
PartPane::Pointer pane = this->GetPaneFor(part);
Perspective::Pointer perspective = this->GetPage()->GetActivePerspective();
if (perspective == 0)
{
// Shouldn't happen -- can't have a ViewStack without a
// perspective
return true;
}
IWorkbenchPartReference::Pointer partRef = pane->GetPartReference();
if (partRef.Cast<IViewReference> () != 0)
return perspective->IsMoveable(partRef.Cast<IViewReference> ());
return true;
}
bool PartStack::SupportsState(int /*newState*/)
{
if (page->IsFixedLayout())
{
return false;
}
return allowStateChanges;
}
bool PartStack::CanMoveFolder()
{
if (appearance == PresentationFactoryUtil::ROLE_EDITOR)
return true;
Perspective::Pointer perspective = this->GetPage()->GetActivePerspective();
if (perspective == 0)
{
// Shouldn't happen -- can't have a ViewStack without a
// perspective
return false;
}
// We need to search if one of the presentations is not moveable
// if that's the case the whole folder should not be moveable
IStackPresentationSite::Pointer presenationSite;
if ((presenationSite = this->GetPresentationSite()) != 0)
{
std::list<IPresentablePart::Pointer> parts = presenationSite->GetPartList();
for (std::list<IPresentablePart::Pointer>::iterator iter = parts.begin(); iter
!= parts.end(); ++iter)
{
if (!presenationSite->IsPartMoveable(*iter))
{
return false;
}
}
}
return !perspective->IsFixedLayout();
}
void PartStack::DerefPart(StackablePart::Pointer toDeref)
{
if (appearance == PresentationFactoryUtil::ROLE_EDITOR)
EditorAreaHelper::DerefPart(toDeref);
else
this->GetPage()->GetActivePerspective()->GetPresentation()->DerefPart(
toDeref);
}
bool PartStack::AllowsDrop(PartPane::Pointer part)
{
PartStack::Pointer stack = part->GetContainer().Cast<PartStack> ();
if (stack != 0)
{
if (stack->appearance == this->appearance)
return true;
}
return false;
}
void PartStack::AddListener(IPropertyChangeListener::Pointer listener)
{
propEvents.AddListener(listener);
}
void PartStack::RemoveListener(IPropertyChangeListener::Pointer listener)
{
propEvents.RemoveListener(listener);
}
int PartStack::GetAppearance() const
{
return appearance;
}
std::string PartStack::GetID() const
{
return LayoutPart::GetID();
}
bool PartStack::IsStandalone()
{
return (appearance == PresentationFactoryUtil::ROLE_STANDALONE || appearance
== PresentationFactoryUtil::ROLE_STANDALONE_NOTITLE);
}
IPresentablePart::Pointer PartStack::GetSelectedPart()
{
return presentationCurrent.Cast<IPresentablePart> ();
}
IStackPresentationSite::Pointer PartStack::GetPresentationSite()
{
return presentationSite;
}
void PartStack::TestInvariants()
{
void* focusControl =
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetFocusControl();
bool currentFound = false;
ChildVector children = this->GetChildren();
for (ChildVector::iterator iter = children.begin(); iter != children.end(); ++iter)
{
StackablePart::Pointer child = *iter;
// No 0 children allowed
poco_assert(child != 0)
; // "0 children are not allowed in PartStack"
// Ensure that all the PartPanes have an associated presentable part
IPresentablePart::Pointer part = this->GetPresentablePart(child);
if (!child->IsPlaceHolder())
{
poco_assert(part != 0); // "All PartPanes must have a non-0 IPresentablePart"
}
// Ensure that the child's backpointer points to this stack
IStackableContainer::Pointer childContainer = child->GetContainer();
// Disable tests for placeholders -- PartPlaceholder backpointers don't
// obey the usual rules -- they sometimes point to a container placeholder
// for this stack instead of the real stack.
if (!child->IsPlaceHolder())
{
// If the widgetry exists, the child's backpointer must point to us
poco_assert(childContainer.GetPointer() == this); // "PartStack has a child that thinks it has a different parent"
// If this child has focus, then ensure that it is selected and that we have
// the active appearance.
if (focusControl && Tweaklets::Get(GuiWidgetsTweaklet::KEY)->IsChild(child->GetControl(), focusControl))
{
poco_assert(child == current); // "The part with focus is not the selected part"
// focus check commented out since it fails when focus workaround in LayoutPart.setVisible is not present
// Assert.isTrue(getActive() == StackPresentation.AS_ACTIVE_FOCUS);
}
}
// Ensure that "current" points to a valid child
if (child == current)
{
currentFound = true;
}
// Test the child's internal state
child->TestInvariants();
}
// If we have at least one child, ensure that the "current" pointer points to one of them
if (this->GetPresentableParts().size()> 0)
{
poco_assert(currentFound);
StackPresentation::Pointer presentation = this->GetPresentation();
// If the presentation controls have focus, ensure that we have the active appearance
if (focusControl && Tweaklets::Get(GuiWidgetsTweaklet::KEY)->IsChild(presentation->GetControl(), focusControl))
{
poco_assert(this->GetActive() == StackPresentation::AS_ACTIVE_FOCUS);
// "The presentation has focus but does not have the active appearance"
}
}
// Check to that we're displaying the zoomed icon iff we're actually maximized
//poco_assert((this->GetState() == IStackPresentationSite::STATE_MAXIMIZED)
// == (this->GetContainer() != 0 && this->GetContainer()->ChildIsZoomed(this)));
}
void PartStack::DescribeLayout(std::string& buf) const
{
int activeState = this->GetActive();
if (activeState == StackPresentation::AS_ACTIVE_FOCUS)
{
buf.append("active "); //$NON-NLS-1$
}
else if (activeState == StackPresentation::AS_ACTIVE_NOFOCUS)
{
buf.append("active_nofocus "); //$NON-NLS-1$
}
buf.append("("); //$NON-NLS-1$
ChildVector children = this->GetChildren();
int visibleChildren = 0;
for (ChildVector::iterator iter = children.begin(); iter != children.end(); ++iter)
{
StackablePart::Pointer next = *iter;
if (!next->IsPlaceHolder())
{
if (iter != children.begin())
{
buf.append(", "); //$NON-NLS-1$
}
if (next == requestedCurrent)
{
buf.append("*"); //$NON-NLS-1$
}
next->DescribeLayout(buf);
visibleChildren++;
}
}
buf.append(")"); //$NON-NLS-1$
}
void PartStack::Add(StackablePart::Pointer child)
{
this->Add(child, Object::Pointer(0));
}
void PartStack::Add(StackablePart::Pointer newChild, Object::Pointer cookie)
{
children.push_back(newChild);
// Fix for bug 78470:
if(newChild->GetContainer().Cast<ContainerPlaceholder>() == 0)
{
newChild->SetContainer(IStackableContainer::Pointer(this));
}
this->ShowPart(newChild, cookie);
}
bool PartStack::AllowsAdd(StackablePart::Pointer /*toAdd*/)
{
return !this->IsStandalone();
}
bool PartStack::AllowsAutoFocus()
{
if (presentationSite->GetState() == IStackPresentationSite::STATE_MINIMIZED)
{
return false;
}
return LayoutPart::AllowsAutoFocus();
}
void PartStack::Close(const std::vector<IPresentablePart::Pointer>& parts)
{
for (unsigned int idx = 0; idx < parts.size(); idx++)
{
IPresentablePart::Pointer part = parts[idx];
this->Close(part);
}
}
void PartStack::Close(IPresentablePart::Pointer part)
{
if (!presentationSite->IsCloseable(part))
{
return;
}
PartPane::Pointer pane = this->GetPaneFor(part);
if (pane != 0)
{
pane->DoHide();
}
}
IPresentationFactory* PartStack::GetFactory()
{
if (factory != 0)
{
return factory;
}
return WorkbenchPlugin::GetDefault()->GetPresentationFactory();
}
void PartStack::CreateControl(void* parent)
{
if (this->GetPresentation() != 0)
{
return;
}
IPresentationFactory* factory = this->GetFactory();
PresentableVector partList = this->GetPresentableParts();
std::vector<IPresentablePart::Pointer> partVec(partList.begin(), partList.end());
PresentationSerializer serializer(partVec);
StackPresentation::Pointer presentation = PresentationFactoryUtil
::CreatePresentation(factory, appearance, parent,
presentationSite, &serializer, savedPresentationState);
this->CreateControl(parent, presentation);
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->MoveBelow(this->GetControl(), 0);
}
IDropTarget::Pointer PartStack::GetDropTarget(Object::Pointer draggedObject, const Point& position)
{
if (draggedObject.Cast<PartPane>() == 0)
{
return IDropTarget::Pointer(0);
}
PartPane::Pointer pane = draggedObject.Cast<PartPane>();
if (this->IsStandalone()
|| !this->AllowsDrop(pane))
{
return IDropTarget::Pointer(0);
}
// Don't allow views to be dragged between windows
bool differentWindows = pane->GetWorkbenchWindow() != this->GetWorkbenchWindow();
bool editorDropOK = ((pane->GetPartReference().Cast<IEditorReference>() != 0) &&
pane->GetWorkbenchWindow()->GetWorkbench() ==
this->GetWorkbenchWindow()->GetWorkbench());
if (differentWindows && !editorDropOK)
{
return IDropTarget::Pointer(0);
}
StackDropResult::Pointer dropResult = this->GetPresentation()->DragOver(
this->GetControl(), position);
if (dropResult == 0)
{
return IDropTarget::Pointer(0);
}
return this->CreateDropTarget(pane, dropResult);
}
void PartStack::SetBounds(const Rectangle& r)
{
if (this->GetPresentation() != 0)
{
this->GetPresentation()->SetBounds(r);
}
}
IDropTarget::Pointer PartStack::CreateDropTarget(PartPane::Pointer pane, StackDropResult::Pointer result)
{
dropResult->SetTarget(PartStack::Pointer(this), pane, result);
return dropResult;
}
void PartStack::SetActive(bool isActive)
{
this->isActive = isActive;
// Add all visible children to the presentation
for(ChildVector::iterator iter = children.begin(); iter != children.end(); ++iter)
{
(*iter)->SetContainer(isActive ? IStackableContainer::Pointer(this) : IStackableContainer::Pointer(0));
}
for (PresentableVector::iterator iter = presentableParts.begin();
iter != presentableParts.end(); ++iter)
{
PresentablePart::Pointer next = iter->Cast<PresentablePart>();
next->EnableInputs(isActive);
next->EnableOutputs(isActive);
}
}
void PartStack::CreateControl(void* /*parent*/, StackPresentation::Pointer presentation)
{
poco_assert(this->GetPresentation() == 0);
if (presentationSite->GetPresentation() != 0)
{
return;
}
presentationSite->SetPresentation(presentation);
// Add all visible children to the presentation
// Use a copy of the current set of children to avoid a ConcurrentModificationException
// if a part is added to the same stack while iterating over the children (bug 78470)
ChildVector childParts(children);
for (ChildVector::iterator iter = childParts.begin(); iter != childParts.end(); ++iter)
{
this->ShowPart(*iter, Object::Pointer(0));
}
if (savedPresentationState != 0)
{
PresentableVector partList = this->GetPresentableParts();
std::vector<IPresentablePart::Pointer> partVec(partList.begin(), partList.end());
PresentationSerializer serializer(partVec);
presentation->RestoreState(&serializer, savedPresentationState);
}
//void* ctrl = this->GetPresentation()->GetControl();
//TODO control setData ?
//ctrl.setData(this);
// We should not have a placeholder selected once we've created the widgetry
if (requestedCurrent != 0 && requestedCurrent->IsPlaceHolder())
{
requestedCurrent = 0;
this->UpdateContainerVisibleTab();
}
this->RefreshPresentationSelection();
}
void PartStack::SavePresentationState()
{
if (this->GetPresentation() == 0)
{
return;
}
{// Save the presentation's state before disposing it
XMLMemento::Pointer memento = XMLMemento
::CreateWriteRoot(WorkbenchConstants::TAG_PRESENTATION);
memento->PutString(WorkbenchConstants::TAG_ID, this->GetFactory()->GetId());
std::list<IPresentablePart::Pointer> parts(this->GetPresentableParts());
PresentationSerializer serializer(std::vector<IPresentablePart::Pointer>(parts.begin(), parts.end()));
this->GetPresentation()->SaveState(&serializer, memento);
// Store the memento in savedPresentationState
savedPresentationState = memento;
}
}
PartStack::~PartStack()
{
//BERRY_INFO << "DELETING PARTSTACK";
}
void PartStack::Dispose()
{
if (this->GetPresentation() == 0)
{
return;
}
this->SavePresentationState();
// for (PresentableVector::iterator iter = presentableParts.begin();
// iter != presentableParts.end(); ++iter)
// {
// iter->Cast<PresentablePart>()->Dispose();
// }
presentableParts.clear();
presentationCurrent = 0;
current = 0;
this->FireInternalPropertyChange(PROP_SELECTION);
}
void PartStack::FindSashes(PartPane::Sashes& sashes)
{
ILayoutContainer::Pointer container = this->GetContainer();
if (container != 0)
{
container->FindSashes(LayoutPart::Pointer(this), sashes);
}
}
Rectangle PartStack::GetBounds()
{
if (this->GetPresentation() == 0)
{
return Rectangle(0, 0, 0, 0);
}
return Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetBounds(this->GetPresentation()->GetControl());
}
std::list<StackablePart::Pointer> PartStack::GetChildren() const
{
return children;
}
void* PartStack::GetControl()
{
StackPresentation::Pointer presentation = this->GetPresentation();
if (presentation == 0)
{
return 0;
}
return presentation->GetControl();
}
/**
* Answer the number of children.
*/
PartStack::ChildVector::size_type PartStack::GetItemCount()
{
if (this->GetPresentation() == 0)
{
return children.size();
}
return this->GetPresentableParts().size();
}
PartPane::Pointer PartStack::GetPaneFor(IPresentablePart::Pointer part)
{
if (part == 0 || part.Cast<PresentablePart>() == 0)
{
return PartPane::Pointer(0);
}
return part.Cast<PresentablePart>()->GetPane();
}
void* PartStack::GetParent()
{
return Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetParent(this->GetControl());
}
PartStack::PresentableVector PartStack::GetPresentableParts()
{
return presentableParts;
}
PresentablePart::Pointer PartStack::GetPresentablePart(StackablePart::Pointer pane)
{
for (PresentableVector::iterator iter = presentableParts.begin(); iter != presentableParts.end(); ++iter)
{
PresentablePart::Pointer part = iter->Cast<PresentablePart>();
if (part->GetPane() == pane)
{
return part;
}
}
return PresentablePart::Pointer(0);
}
StackPresentation::Pointer PartStack::GetPresentation()
{
return presentationSite->GetPresentation();
}
StackablePart::Pointer PartStack::GetSelection()
{
return current;
}
void PartStack::PresentationSelectionChanged(IPresentablePart::Pointer newSelection)
{
// Ignore selection changes that occur as a result of removing a part
if (ignoreSelectionChanges)
{
return;
}
PartPane::Pointer newPart = this->GetPaneFor(newSelection);
// This method should only be called on objects that are already in the layout
poco_assert(newPart != 0);
if (newPart == requestedCurrent)
{
return;
}
this->SetSelection(newPart);
if (newPart != 0)
{
newPart->SetFocus();
}
}
void PartStack::Remove(StackablePart::Pointer child)
{
IPresentablePart::Pointer presentablePart = this->GetPresentablePart(child);
// Need to remove it from the list of children before notifying the presentation
// since it may setVisible(false) on the part, leading to a partHidden notification,
// during which findView must not find the view being removed. See bug 60039.
children.remove(child);
StackPresentation::Pointer presentation = this->GetPresentation();
if (presentablePart != 0 && presentation != 0)
{
ignoreSelectionChanges = true;
presentableParts.remove(presentablePart);
presentation->RemovePart(presentablePart);
presentablePart = 0;
ignoreSelectionChanges = false;
}
if (this->GetPresentation() != 0)
{
child->SetContainer(IStackableContainer::Pointer(0));
}
if (child == requestedCurrent)
{
this->UpdateContainerVisibleTab();
}
}
void PartStack::Reparent(void* newParent)
{
void* control = this->GetControl();
GuiWidgetsTweaklet* tweaklet = Tweaklets::Get(GuiWidgetsTweaklet::KEY);
if ((control == 0) || (tweaklet->GetParent(control) == newParent)
|| !tweaklet->IsReparentable(control))
{
return;
}
LayoutPart::Reparent(newParent);
for(ChildVector::iterator iter = children.begin();
iter != children.end(); ++iter)
{
(*iter)->Reparent(newParent);
}
}
void PartStack::Replace(StackablePart::Pointer oldChild, StackablePart::Pointer newChild)
{
ChildVector::iterator loc = std::find(children.begin(), children.end(), oldChild);
int idx = 0;
int numPlaceholders = 0;
//subtract the number of placeholders still existing in the list
//before this one - they wont have parts.
for (ChildVector::iterator iter = children.begin(); iter != loc; ++iter, ++idx)
{
if ((*iter)->IsPlaceHolder())
{
numPlaceholders++;
}
}
ObjectInt::Pointer cookie(new ObjectInt(idx - numPlaceholders));
children.insert(loc, newChild);
this->ShowPart(newChild, cookie);
if (oldChild == requestedCurrent && newChild.Cast<PartPane>() != 0)
{
this->SetSelection(newChild.Cast<PartPane>());
}
this->Remove(oldChild);
}
int PartStack::ComputePreferredSize(bool width, int availableParallel,
int availablePerpendicular, int preferredParallel)
{
return this->GetPresentation()->ComputePreferredSize(width, availableParallel,
availablePerpendicular, preferredParallel);
}
int PartStack::GetSizeFlags(bool horizontal)
{
StackPresentation::Pointer presentation = this->GetPresentation();
if (presentation != 0)
{
return presentation->GetSizeFlags(horizontal);
}
return 0;
}
bool PartStack::RestoreState(IMemento::Pointer memento)
{
// Read the active tab.
std::string activeTabID; memento->GetString(WorkbenchConstants::TAG_ACTIVE_PAGE_ID, activeTabID);
// Read the page elements.
std::vector<IMemento::Pointer> children = memento->GetChildren(WorkbenchConstants::TAG_PAGE);
// Loop through the page elements.
for (std::size_t i = 0; i < children.size(); i++)
{
// Get the info details.
IMemento::Pointer childMem = children[i];
std::string partID; childMem->GetString(WorkbenchConstants::TAG_CONTENT, partID);
// Create the part.
StackablePart::Pointer part(new PartPlaceholder(partID));
part->SetContainer(IStackableContainer::Pointer(this));
this->Add(part);
//1FUN70C: ITPUI:WIN - Shouldn't set Container when not active
//part.setContainer(this);
if (partID == activeTabID)
{
this->SetSelection(part);
// Mark this as the active part.
//current = part;
}
}
//IPreferenceStore preferenceStore = PrefUtil.getAPIPreferenceStore();
//boolean useNewMinMax = preferenceStore.getBoolean(IWorkbenchPreferenceConstants.ENABLE_NEW_MIN_MAX);
int expanded;
if (memento->GetInteger(WorkbenchConstants::TAG_EXPANDED, expanded))
{
//StartupThreading.runWithoutExceptions(new StartupRunnable()
// {
// void runWithException() throws Throwable
// {
SetState(expanded != IStackPresentationSite::STATE_MINIMIZED ? IStackPresentationSite::STATE_RESTORED
: IStackPresentationSite::STATE_MINIMIZED);
// }
// });
}
else
{
SetState(IStackPresentationSite::STATE_RESTORED);
}
int appearance;
if (memento->GetInteger(WorkbenchConstants::TAG_APPEARANCE, appearance))
{
this->appearance = appearance;
}
// Determine if the presentation has saved any info here
savedPresentationState = 0;
std::vector<IMemento::Pointer> presentationMementos(memento
->GetChildren(WorkbenchConstants::TAG_PRESENTATION));
for (std::size_t idx = 0; idx < presentationMementos.size(); idx++)
{
IMemento::Pointer child = presentationMementos[idx];
std::string id; child->GetString(WorkbenchConstants::TAG_ID, id);
if (id == GetFactory()->GetId())
{
savedPresentationState = child;
break;
}
}
IMemento::Pointer propertiesState = memento->GetChild(WorkbenchConstants::TAG_PROPERTIES);
if (propertiesState)
{
std::vector<IMemento::Pointer> props(propertiesState->GetChildren(WorkbenchConstants::TAG_PROPERTY));
for (std::size_t i = 0; i < props.size(); i++)
{
std::string id = props[i]->GetID();
properties.insert(std::make_pair(id, props[i]->GetTextData()));
}
}
//return new Status(IStatus.OK, PlatformUI.PLUGIN_ID, 0, "", 0); //$NON-NLS-1$
return true;
}
void PartStack::SetVisible(bool makeVisible)
{
void* ctrl = this->GetControl();
bool useShortcut = makeVisible || !isActive;
if (ctrl != 0 && useShortcut)
{
if (makeVisible == Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetVisible(ctrl))
{
return;
}
}
if (makeVisible)
{
for (PresentableVector::iterator iter = presentableParts.begin();
iter != presentableParts.end(); ++iter)
{
PresentablePart::Pointer next = iter->Cast<PresentablePart>();
next->EnableInputs(isActive);
next->EnableOutputs(isActive);
}
}
LayoutPart::SetVisible(makeVisible);
StackPresentation::Pointer presentation = this->GetPresentation();
if (presentation != 0)
{
presentation->SetVisible(makeVisible);
}
if (!makeVisible)
{
for (PresentableVector::iterator iter = presentableParts.begin();
iter != presentableParts.end(); ++iter)
{
PresentablePart::Pointer next = iter->Cast<PresentablePart>();
next->EnableInputs(false);
}
}
}
bool PartStack::SaveState(IMemento::Pointer memento)
{
if (GetAppearance() != PresentationFactoryUtil::ROLE_EDITOR)
{
// Save the active tab.
if (requestedCurrent)
{
memento->PutString(WorkbenchConstants::TAG_ACTIVE_PAGE_ID, requestedCurrent
->GetCompoundId());
}
// Write out the presentable parts (in order)
Poco::HashSet<std::string> cachedIds;
PartStack::PresentableVector pparts(GetPresentableParts());
for (PartStack::PresentableVector::iterator ppIter = pparts.begin();
ppIter != pparts.end(); ++ppIter)
{
PresentablePart::Pointer presPart = ppIter->Cast<PresentablePart>();
IMemento::Pointer childMem = memento->CreateChild(WorkbenchConstants::TAG_PAGE);
PartPane::Pointer part = presPart->GetPane();
std::string tabText = part->GetPartReference()->GetPartName();
childMem->PutString(WorkbenchConstants::TAG_LABEL, tabText);
childMem->PutString(WorkbenchConstants::TAG_CONTENT, presPart->GetPane()->GetPlaceHolderId());
// Cache the id so we don't write it out later
cachedIds.insert(presPart->GetPane()->GetPlaceHolderId());
}
for (ChildVector::iterator iter = children.begin();
iter != children.end(); ++iter)
{
StackablePart::Pointer next = *iter;
PartPane::Pointer part;
if (part = next.Cast<PartPane>())
{
// Have we already written it out?
if (cachedIds.find(part->GetPlaceHolderId()) != cachedIds.end())
continue;
}
IMemento::Pointer childMem = memento
->CreateChild(WorkbenchConstants::TAG_PAGE);
std::string tabText = "LabelNotFound";
if (part)
{
tabText = part->GetPartReference()->GetPartName();
}
childMem->PutString(WorkbenchConstants::TAG_LABEL, tabText);
childMem->PutString(WorkbenchConstants::TAG_CONTENT, next->GetId());
}
}
// IPreferenceStore preferenceStore = PrefUtil.getAPIPreferenceStore();
// boolean useNewMinMax = preferenceStore.getBoolean(IWorkbenchPreferenceConstants.ENABLE_NEW_MIN_MAX);
// if (useNewMinMax)
// {
memento->PutInteger(WorkbenchConstants::TAG_EXPANDED, presentationSite->GetState());
// }
// else
// {
// memento
// .putInteger(
// IWorkbenchConstants.TAG_EXPANDED,
// (presentationSite.getState() == IStackPresentationSite.STATE_MINIMIZED) ? IStackPresentationSite.STATE_MINIMIZED
// : IStackPresentationSite.STATE_RESTORED);
// }
memento->PutInteger(WorkbenchConstants::TAG_APPEARANCE, appearance);
this->SavePresentationState();
if (savedPresentationState)
{
IMemento::Pointer presentationState = memento
->CreateChild(WorkbenchConstants::TAG_PRESENTATION);
presentationState->PutMemento(savedPresentationState);
}
if (!properties.empty())
{
IMemento::Pointer propertiesState = memento->CreateChild(WorkbenchConstants::TAG_PROPERTIES);
for (std::map<std::string, std::string>::iterator iterator = properties.begin();
iterator != properties.end(); ++iterator)
{
if (iterator->second.empty()) continue;
IMemento::Pointer prop = propertiesState->CreateChild(WorkbenchConstants::TAG_PROPERTY, iterator->first);
prop->PutTextData(iterator->second);
}
}
//return new Status(IStatus.OK, PlatformUI.PLUGIN_ID, 0, "", 0);
return true;
}
WorkbenchPage::Pointer PartStack::GetPage()
{
// WorkbenchWindow::Pointer window = this->GetWorkbenchWindow().Cast<WorkbenchWindow>();
//
// if (window == 0)
// {
// return 0;
// }
//
// return window->GetActivePage().Cast<WorkbenchPage>();
return WorkbenchPage::Pointer(page);
}
void PartStack::SetActive(int activeState)
{
// if (activeState == StackPresentation::AS_ACTIVE_FOCUS && isMinimized)
// {
// setMinimized(false);
// }
presentationSite->SetActive(activeState);
}
int PartStack::GetActive() const
{
return presentationSite->GetActive();
}
void PartStack::SetSelection(StackablePart::Pointer part)
{
if (part == requestedCurrent)
{
return;
}
requestedCurrent = part;
this->RefreshPresentationSelection();
}
void PartStack::UpdateActions(PresentablePart::Pointer /*current*/)
{
}
void PartStack::HandleDeferredEvents()
{
LayoutPart::HandleDeferredEvents();
this->RefreshPresentationSelection();
}
void PartStack::RefreshPresentationSelection()
{
// If deferring UI updates, exit.
if (this->IsDeferred())
{
return;
}
// If the presentation is already displaying the desired part, then there's nothing
// to do.
if (current == requestedCurrent)
{
return;
}
StackPresentation::Pointer presentation = this->GetPresentation();
if (presentation != 0)
{
presentationCurrent = this->GetPresentablePart(requestedCurrent);
// this->UupdateActions(presentationCurrent);
if (presentationCurrent != 0 && presentation != 0)
{
requestedCurrent->CreateControl(this->GetParent());
GuiWidgetsTweaklet* tweaklet = Tweaklets::Get(GuiWidgetsTweaklet::KEY);
if (tweaklet->GetParent(requestedCurrent->GetControl()) !=
tweaklet->GetParent(this->GetControl()))
{
requestedCurrent->Reparent(tweaklet->GetParent(this->GetControl()));
}
presentation->SelectPart(presentationCurrent);
}
// Update the return value of getVisiblePart
current = requestedCurrent;
this->FireInternalPropertyChange(PROP_SELECTION);
}
}
int PartStack::GetState()
{
return presentationSite->GetState();
}
void PartStack::SetState(const int newState)
{
int oldState = presentationSite->GetState();
if (!this->SupportsState(newState) || newState == oldState)
{
return;
}
// WorkbenchWindow::Pointer wbw = this->GetPage()->GetWorkbenchWindow().Cast<WorkbenchWindow>();
// if (wbw == 0 || wbw->GetShell() == 0 || wbw->GetActivePage() == 0)
// return;
//
// WorkbenchPage::Pointer page = wbw->GetActivePage();
//
// bool useNewMinMax = Perspective::UseNewMinMax(page->GetActivePerspective());
//
// // we have to fiddle with the zoom behavior to satisfy Intro req's
// // by usning the old zoom behavior for its stack
// if (newState == IStackPresentationSite::STATE_MAXIMIZED)
// useNewMinMax = useNewMinMax; // && !this->IsIntroInStack();
// else if (newState == IStackPresentationSite::STATE_RESTORED)
// {
// PartStack::Pointer maxStack = page->GetActivePerspective()->GetPresentation()->GetMaximizedStack();
// useNewMinMax = useNewMinMax && maxStack == this;
// }
//
// if (useNewMinMax)
// {
// //StartupThreading.runWithoutExceptions(new StartupRunnable()
// // {
// // void runWithException() throws Throwable
// // {
// wbw->GetPageComposite()->SetRedraw(false);
// try
// {
// if (newState == IStackPresentationSite::STATE_MAXIMIZED)
// {
// smartZoom();
// }
// else if (oldState == IStackPresentationSite::STATE_MAXIMIZED)
// {
// smartUnzoom();
// }
//
// if (newState == IStackPresentationSite::STATE_MINIMIZED)
// {
// setMinimized(true);
// }
//
// wbw.getPageComposite().setRedraw(true);
//
// // Force a redraw (fixes Mac refresh)
// wbw.getShell().redraw();
//
// }
// catch (...)
// {
// wbw.getPageComposite().setRedraw(true);
//
// // Force a redraw (fixes Mac refresh)
// wbw.getShell().redraw();
// }
//
// this->SetPresentationState(newState);
// // }
// // });
// }
// else
// {
//// bool minimized = (newState == IStackPresentationSite::STATE_MINIMIZED);
//// this->SetMinimized(minimized);
////
//// if (newState == IStackPresentationSite::STATE_MAXIMIZED)
//// {
//// requestZoomIn();
//// }
//// else if (oldState == IStackPresentationSite::STATE_MAXIMIZED)
//// {
//// requestZoomOut();
////
//// if (newState == IStackPresentationSite::STATE_MINIMIZED)
//// setMinimized(true);
//// }
// }
}
void PartStack::ShowPart(StackablePart::Pointer part, Object::Pointer cookie)
{
if (this->GetPresentation() == 0)
{
return;
}
if (part->IsPlaceHolder())
{
part->SetContainer(IStackableContainer::Pointer(this));
return;
}
if (part.Cast<PartPane>() == 0)
{
WorkbenchPlugin::Log("Incorrect part " + part->GetId() + "contained in a part stack");
return;
}
PartPane::Pointer pane = part.Cast<PartPane>();
PresentablePart::Pointer presentablePart(new PresentablePart(pane, Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetParent(this->GetControl())));
presentableParts.push_back(presentablePart);
if (isActive)
{
part->SetContainer(IStackableContainer::Pointer(this));
// The active part should always be enabled
if (part->GetControl() != 0)
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->SetEnabled(part->GetControl(), true);
}
presentationSite->GetPresentation()->AddPart(presentablePart, cookie);
if (requestedCurrent == 0)
{
this->SetSelection(pane);
}
// if (childObscuredByZoom(part))
// {
// presentablePart.enableInputs(false);
// }
}
void PartStack::UpdateContainerVisibleTab()
{
ChildVector parts = this->GetChildren();
if (parts.size() < 1)
{
this->SetSelection(StackablePart::Pointer(0));
return;
}
PartPane::Pointer selPart;
int topIndex = 0;
WorkbenchPage::Pointer page = this->GetPage();
if (page != 0)
{
std::vector<IWorkbenchPartReference::Pointer> sortedParts = page->GetSortedParts();
for (ChildVector::iterator partIter = parts.begin();
partIter != parts.end(); ++partIter)
{
if (partIter->Cast<PartPane>() != 0)
{
IWorkbenchPartReference::Pointer part = partIter->Cast<PartPane>()
->GetPartReference();
int index = static_cast<int>(std::find(sortedParts.begin(), sortedParts.end(), part) - sortedParts.begin());
if (index >= topIndex)
{
topIndex = index;
selPart = partIter->Cast<PartPane>();
}
}
}
}
if (selPart == 0)
{
PresentableVector presentableParts = this->GetPresentableParts();
if (presentableParts.size() != 0)
{
IPresentablePart::Pointer part = presentableParts.front();
selPart = this->GetPaneFor(part);
}
}
this->SetSelection(selPart);
}
void PartStack::ShowSystemMenu()
{
//this->GetPresentation()->ShowSystemMenu();
}
void PartStack::ShowPaneMenu()
{
//this->GetPresentation()->ShowPaneMenu();
}
void PartStack::ShowPartList()
{
this->GetPresentation()->ShowPartList();
}
std::vector<void*> PartStack::GetTabList(StackablePart::Pointer part)
{
if (part != 0)
{
IPresentablePart::Pointer presentablePart = this->GetPresentablePart(part);
StackPresentation::Pointer presentation = this->GetPresentation();
if (presentablePart != 0 && presentation != 0)
{
return presentation->GetTabList(presentablePart);
}
}
return std::vector<void*>();
}
void PartStack::DragStart(IPresentablePart::Pointer beingDragged, Point& initialLocation,
bool keyboard)
{
if (beingDragged == 0)
{
this->PaneDragStart(PartPane::Pointer(0), initialLocation, keyboard);
}
else
{
if (presentationSite->IsPartMoveable(beingDragged))
{
PartPane::Pointer pane = this->GetPaneFor(beingDragged);
if (pane != 0)
{
this->PaneDragStart(pane, initialLocation, keyboard);
}
}
}
}
void PartStack::PaneDragStart(PartPane::Pointer pane, Point& initialLocation,
bool keyboard)
{
if (pane == 0)
{
if (this->CanMoveFolder())
{
if (presentationSite->GetState() == IStackPresentationSite::STATE_MAXIMIZED)
{
// Calculate where the initial location was BEFORE the 'restore'...as a percentage
Rectangle bounds = Geometry::ToDisplay(this->GetParent(),
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetBounds(this->GetPresentation()->GetControl()));
float xpct = (initialLocation.x - bounds.x) / (float)(bounds.width);
float ypct = (initialLocation.y - bounds.y) / (float)(bounds.height);
// Only restore if we're dragging views/view stacks
if (this->GetAppearance() != PresentationFactoryUtil::ROLE_EDITOR)
this->SetState(IStackPresentationSite::STATE_RESTORED);
// Now, adjust the initial location to be within the bounds of the restored rect
bounds = Geometry::ToDisplay(this->GetParent(),
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetBounds(this->GetPresentation()->GetControl()));
initialLocation.x = (int) (bounds.x + (xpct * bounds.width));
initialLocation.y = (int) (bounds.y + (ypct * bounds.height));
}
DragUtil::PerformDrag(Object::Pointer(this), Geometry::ToDisplay(this->GetParent(),
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetBounds(this->GetPresentation()->GetControl())),
initialLocation, !keyboard);
}
}
else
{
if (presentationSite->GetState() == IStackPresentationSite::STATE_MAXIMIZED)
{
// Calculate where the initial location was BEFORE the 'restore'...as a percentage
Rectangle bounds = Geometry::ToDisplay(this->GetParent(),
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetBounds(this->GetPresentation()->GetControl()));
float xpct = (initialLocation.x - bounds.x) / (float)(bounds.width);
float ypct = (initialLocation.y - bounds.y) / (float)(bounds.height);
// Only restore if we're dragging views/view stacks
if (this->GetAppearance() != PresentationFactoryUtil::ROLE_EDITOR)
this->SetState(IStackPresentationSite::STATE_RESTORED);
// Now, adjust the initial location to be within the bounds of the restored rect
// See bug 100908
bounds = Geometry::ToDisplay(this->GetParent(),
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetBounds(this->GetPresentation()->GetControl()));
initialLocation.x = (int) (bounds.x + (xpct * bounds.width));
initialLocation.y = (int) (bounds.y + (ypct * bounds.height));
}
DragUtil::PerformDrag(pane, Geometry::ToDisplay(this->GetParent(),
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetBounds(this->GetPresentation()->GetControl())),
initialLocation, !keyboard);
}
}
IMemento::Pointer PartStack::GetSavedPresentationState()
{
return savedPresentationState;
}
void PartStack::FireInternalPropertyChange(int id)
{
ObjectInt::Pointer val(new ObjectInt(id));
Object::Pointer source(this);
PropertyChangeEvent::Pointer event(new PropertyChangeEvent(source,
IWorkbenchPartConstants::INTEGER_PROPERTY, val, val));
propEvents.propertyChange(event);
}
std::string PartStack::GetProperty(const std::string& id)
{
return properties[id];
}
void PartStack::SetProperty(const std::string& id, const std::string& value)
{
if (value == "")
{
properties.erase(id);
}
else
{
properties.insert(std::make_pair(id, value));
}
}
void PartStack::CopyAppearanceProperties(PartStack::Pointer copyTo)
{
copyTo->appearance = this->appearance;
if (!properties.empty())
{
for (std::map<std::string, std::string>::iterator iter = properties.begin();
iter != properties.end(); ++iter)
{
copyTo->SetProperty(iter->first, iter->second);
}
}
}
void PartStack::ResizeChild(StackablePart::Pointer /*childThatChanged*/)
{
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartStack.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartStack.h
index e115040a96..5683ffbc8b 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartStack.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartStack.h
@@ -1,762 +1,762 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYPARTSTACK_H_
#define BERRYPARTSTACK_H_
#include "berryLayoutPart.h"
#include "berryIStackableContainer.h"
#include "berryWorkbenchPage.h"
#include "berryPresentablePart.h"
#include "berryPartPlaceholder.h"
#include "berryDefaultStackPresentationSite.h"
#include "berryPresentationFactoryUtil.h"
#include "berryAbstractDropTarget.h"
#include "berryPartPane.h"
#include "berryIMemento.h"
#include "presentations/berryIPresentationFactory.h"
#include <vector>
#include <list>
#include <map>
namespace berry {
/**
* \ingroup org_blueberry_ui_internal
*
* Implements the common behavior for stacks of Panes (ie: EditorStack and ViewStack)
* This layout container has PartPanes as children and belongs to a PartSashContainer.
*
* @since 3.0
*/
class PartStack : public LayoutPart, public IStackableContainer {
friend class EditorSashContainer;
friend class PartSashContainer;
friend class DetachedWindow;
public: berryObjectMacro(PartStack);
public: static const int PROP_SELECTION; // = 0x42;
private: typedef std::list<StackablePart::Pointer> ChildVector;
private: ChildVector children;
private: WorkbenchPage* page;
private: bool isActive;
private: bool allowStateChanges;
private: typedef std::list<IPresentablePart::Pointer> PresentableVector;
private: PresentableVector presentableParts;
private: std::map<std::string, std::string> properties;
protected: int appearance;
/**
* Stores the last value passed to setSelection. If UI updates are being deferred,
* this may be significantly different from the other current pointers. Once UI updates
* are re-enabled, the stack will update the presentation selection to match the requested
* current pointer.
*/
private: StackablePart::Pointer requestedCurrent;
/**
* Stores the current part for the stack. Whenever the outside world asks a PartStack
* for the current part, this is what gets returned. This pointer is only updated after
* the presentation selection has been restored and the stack has finished updating its
* internal state. If the stack is still in the process of updating the presentation,
* it will still point to the previous part until the presentation is up-to-date.
*/
private: StackablePart::Pointer current;
/**
* Stores the presentable part sent to the presentation. Whenever the presentation
* asks for the current part, this is what gets returned. This is updated before sending
* the part to the presentation, and it is not updated while UI updates are disabled.
* When UI updates are enabled, the stack first makes presentationCurrent match
* requestedCurrent. Once the presentation is displaying the correct part, the "current"
* pointer on PartStack is updated.
*/
private: PresentablePart::Pointer presentationCurrent;
private: bool ignoreSelectionChanges;
protected: IMemento::Pointer savedPresentationState;
protected:
class MyStackPresentationSite : public DefaultStackPresentationSite {
private:
PartStack* partStack;
public:
MyStackPresentationSite(PartStack* stack);
void Close(IPresentablePart::Pointer part);
void Close(const std::vector<IPresentablePart::Pointer>& parts);
void DragStart(IPresentablePart::Pointer beingDragged,
Point& initialLocation, bool keyboard);
void DragStart(Point& initialLocation, bool keyboard);
bool IsPartMoveable(IPresentablePart::Pointer part);
void SelectPart(IPresentablePart::Pointer toSelect);
bool SupportsState(int state);
void SetState(int newState);
IPresentablePart::Pointer GetSelectedPart();
// void AddSystemActions(IMenuManager menuManager) {
// PartStack.this.addSystemActions(menuManager);
// }
bool IsStackMoveable();
void FlushLayout();
PresentableVector GetPartList();
std::string GetProperty(const std::string& id);
};
DefaultStackPresentationSite::Pointer presentationSite;
private:
class PartStackDropResult : public AbstractDropTarget {
private:
PartPane::WeakPtr pane;
// Result of the presentation's dragOver method or null if we are stacking over the
// client area of the pane.
StackDropResult::Pointer dropResult;
PartStack::WeakPtr stack;
public:
berryObjectMacro(PartStackDropResult);
/**
* Resets the target of this drop result (allows the same drop result object to be
* reused)
*
* @param stack
* @param pane
* @param result result of the presentation's dragOver method, or null if we are
* simply stacking anywhere.
* @since 3.1
*/
void SetTarget(PartStack::Pointer stack, PartPane::Pointer pane, StackDropResult::Pointer result);
void Drop();
DnDTweaklet::CursorType GetCursor();
Rectangle GetSnapRectangle();
};
private: static PartStackDropResult::Pointer dropResult;
// protected: bool isMinimized;
private: IPropertyChangeListener::Events propEvents;
/**
* Custom presentation factory to use for this stack, or null to
* use the default
*/
private: IPresentationFactory* factory;
// private: boolean smartZoomed = false;
// private: boolean doingUnzoom = false;
protected: virtual bool IsMoveable(IPresentablePart::Pointer part);
// protected: abstract void addSystemActions(IMenuManager menuManager);
protected: virtual bool SupportsState(int newState);
protected: virtual bool CanMoveFolder();
protected: virtual void DerefPart(StackablePart::Pointer toDeref);
protected: virtual bool AllowsDrop(PartPane::Pointer part);
// protected: static void appendToGroupIfPossible(IMenuManager m,
// String groupId, ContributionItem item) {
// try {
// m.appendToGroup(groupId, item);
// } catch (IllegalArgumentException e) {
// m.add(item);
// }
// }
/**
* Creates a new part stack that uses the given custom presentation factory
* @param appearance
* @param factory custom factory to use (or null to use the default)
*/
public: PartStack(WorkbenchPage* page,
bool allowsStateChanges = true,
int appearance = PresentationFactoryUtil::ROLE_VIEW,
IPresentationFactory* factory = 0);
/**
* Adds a property listener to this stack. The listener will receive a PROP_SELECTION
* event whenever the result of getSelection changes
*
* @param listener
*/
public: void AddListener(IPropertyChangeListener::Pointer listener);
public: void RemoveListener(IPropertyChangeListener::Pointer listener);
public: int GetAppearance() const;
public: std::string GetID() const;
protected: bool IsStandalone();
/**
* Returns the currently selected IPresentablePart, or null if none
*
* @return
*/
protected: IPresentablePart::Pointer GetSelectedPart();
protected: IStackPresentationSite::Pointer GetPresentationSite();
/**
* Tests the integrity of this object. Throws an exception if the object's state
* is invalid. For use in test suites.
*/
public: void TestInvariants();
/* (non-Javadoc)
* @see org.blueberry.ui.internal.LayoutPart#describeLayout(java.lang.StringBuffer)
*/
public: void DescribeLayout(std::string& buf) const;
/**
* See IVisualContainer#add
*/
public: void Add(StackablePart::Pointer child);
/**
* Add a part at a particular position
*/
protected: void Add(StackablePart::Pointer newChild, Object::Pointer cookie);
public: bool AllowsAdd(StackablePart::Pointer toAdd);
/*
* (non-Javadoc)
*
* @see org.blueberry.ui.internal.ILayoutContainer#allowsAutoFocus()
*/
public: bool AllowsAutoFocus();
/**
* @param parts
*/
protected: void Close(const std::vector<IPresentablePart::Pointer>& parts);
/**
* @param part
*/
protected: void Close(IPresentablePart::Pointer part);
protected: IPresentationFactory* GetFactory();
public: void CreateControl(void* parent);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.LayoutPart#getDropTarget(java.lang.Object, org.blueberry.swt.graphics.Point)
*/
public: IDropTarget::Pointer GetDropTarget(Object::Pointer draggedObject, const Point& position);
public: void SetActive(bool isActive);
public: IDropTarget::Pointer CreateDropTarget(PartPane::Pointer pane, StackDropResult::Pointer result);
/**
* Saves the current state of the presentation to savedPresentationState, if the
* presentation exists.
*/
protected: void SavePresentationState();
public: ~PartStack();
/**
* See LayoutPart#Dispose
*/
public: void Dispose();
public: void FindSashes(PartPane::Sashes& sashes);
/**
* Gets the presentation bounds.
*/
public: Rectangle GetBounds();
/**
* See IVisualContainer#getChildren
*/
public: ChildVector GetChildren() const;
public: void* GetControl();
/**
* Answer the number of children.
*/
public: ChildVector::size_type GetItemCount();
/**
* Returns the LayoutPart for the given IPresentablePart, or null if the given
* IPresentablePart is not in this stack. Returns null if given a null argument.
*
* @param part to locate or null
* @return
*/
protected: PartPane::Pointer GetPaneFor(IPresentablePart::Pointer part);
/**
* Get the parent control.
*/
public: void* GetParent();
/**
* Returns a list of IPresentablePart
*
* @return
*/
public: PresentableVector GetPresentableParts();
private: PresentablePart::Pointer GetPresentablePart(StackablePart::Pointer pane);
protected: StackPresentation::Pointer GetPresentation();
/**
* Returns the visible child.
* @return the currently visible part, or null if none
*/
public: StackablePart::Pointer GetSelection();
private: void PresentationSelectionChanged(IPresentablePart::Pointer newSelection);
/**
* See IVisualContainer#remove
*/
public: void Remove(StackablePart::Pointer child);
/**
* Reparent a part. Also reparent visible children...
*/
public: void Reparent(void* newParent);
/**
* See IVisualContainer#replace
*/
public: void Replace(StackablePart::Pointer oldChild, StackablePart::Pointer newChild);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.LayoutPart#computePreferredSize(boolean, int, int, int)
*/
public: int ComputePreferredSize(bool width, int availableParallel,
int availablePerpendicular, int preferredParallel);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.LayoutPart#getSizeFlags(boolean)
*/
public: int GetSizeFlags(bool horizontal);
/**
* @see IPersistable
*/
public: bool RestoreState(IMemento::Pointer memento);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.LayoutPart#setVisible(boolean)
*/
public: void SetVisible(bool makeVisible);
/**
* @see IPersistable
*/
public: bool SaveState(IMemento::Pointer memento);
protected: WorkbenchPage::Pointer GetPage();
/**
* Set the active appearence on the tab folder.
*
* @param active
*/
public: void SetActive(int activeState);
public: int GetActive() const;
public: void CreateControl(void* parent, StackPresentation::Pointer presentation);
/**
* Sets the presentation bounds.
*/
public: void SetBounds(const Rectangle& r);
public: void SetSelection(StackablePart::Pointer part);
/**
* Updates the enablement state of actions
*/
protected: virtual void UpdateActions(PresentablePart::Pointer current);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.LayoutPart#handleDeferredEvents()
*/
protected: void HandleDeferredEvents();
private: void RefreshPresentationSelection();
public: int GetState();
/**
* Sets the minimized state for this stack. The part may call this method to
* minimize or restore itself. The minimized state only affects the view
* when unzoomed in the 3.0 presentation (in 3.3 it's handled by the
* ViewStack directly and works as expected).
*/
// public: void setMinimized(boolean minimized) {
// if (minimized != isMinimized) {
// isMinimized = minimized;
//
// refreshPresentationState();
// }
// }
/* (non-Javadoc)
* @see org.blueberry.ui.internal.ILayoutContainer#obscuredByZoom(org.blueberry.ui.internal.LayoutPart)
*/
// public: boolean childObscuredByZoom(LayoutPart toTest) {
// return isObscuredByZoom();
// }
/* (non-Javadoc)
* @see org.blueberry.ui.internal.LayoutPart#requestZoom(org.blueberry.ui.internal.LayoutPart)
*/
// public: void childRequestZoomIn(LayoutPart toZoom) {
// super.childRequestZoomIn(toZoom);
//
// requestZoomIn();
// }
/* (non-Javadoc)
* @see org.blueberry.ui.internal.LayoutPart#requestZoomOut()
*/
// public: void childRequestZoomOut() {
// super.childRequestZoomOut();
//
// requestZoomOut();
// }
/* (non-Javadoc)
* @see org.blueberry.ui.internal.ILayoutContainer#isZoomed(org.blueberry.ui.internal.LayoutPart)
*/
// public: boolean childIsZoomed(LayoutPart toTest) {
// return isZoomed();
// }
/**
* This is a hack that allows us to preserve the old
* min/max behavior for the stack containing the IntroPart.
* This is required to have the initial Intro (Welcome)
* pane to show correctly but will induce strange
* effects should a user re-locate the part to
* stacks other that its initial one...
*
* @return true if the stack contains the intro
* as a ViewPane (not if it's only a placeholder)
*/
// private: boolean isIntroInStack() {
// LayoutPart[] kids = getChildren();
// for (int i = 0; i < kids.length; i++) {
// if (kids[i] instanceof ViewPane) {
// ViewPane vp = (ViewPane) kids[i];
// if (vp.getID().equals(IIntroConstants.INTRO_VIEW_ID))
// return true;
// }
// }
// return false;
// }
// private: void smartZoom() {
// WorkbenchWindow wbw = (WorkbenchWindow) getPage().getWorkbenchWindow();
// if (wbw == null || wbw.getShell() == null)
// return;
//
// Perspective perspective = getPage().getActivePerspective();
// FastViewManager fvm = perspective.getFastViewManager();
//
// fvm.deferUpdates(true);
//
// // Cache the layout bounds
// perspective.getPresentation().updateBoundsMap();
//
// LayoutPart[] children = perspective.getPresentation().getLayout().getChildren();
// for (int i = 0; i < children.length; i++) {
// if (children[i] != this) {
// if (children[i] instanceof ViewStack) {
// ((ViewStack) children[i]).setMinimized(true);
// ViewStackTrimToolBar vstb = fvm
// .getViewStackTrimToolbar(children[i]
// .getID());
// vstb.setRestoreOnUnzoom(true);
// }
// else if (children[i] instanceof EditorSashContainer && !(this instanceof EditorStack)) {
// perspective.setEditorAreaState(IStackPresentationSite.STATE_MINIMIZED);
// perspective.setEditorAreaRestoreOnUnzoom(true);
// }
// }
// }
//
// // If the editor area has changed state tell the perspective
// if (this instanceof EditorStack)
// perspective.setEditorAreaState(IStackPresentationSite.STATE_MAXIMIZED);
//
// // Clear the boundsMap
// perspective.getPresentation().resetBoundsMap();
//
// // We're done batching...
// fvm.deferUpdates(false);
//
// perspective.getPresentation().setMaximizedStack(this);
// smartZoomed = true;
// }
// protected: void smartUnzoom() {
// // Prevent recursion through 'setMinimized'
// if (doingUnzoom)
// return;
// doingUnzoom = true;
//
// WorkbenchWindow wbw = (WorkbenchWindow) getPage().getWorkbenchWindow();
// if (wbw == null || wbw.getShell() == null)
// return;
//
// ITrimManager tbm = wbw.getTrimManager();
// Perspective perspective = getPage().getActivePerspective();
// FastViewManager fvm = perspective.getFastViewManager();
//
// ILayoutContainer root = getContainer();
//
// // We go up one more level when maximizing an editor stack
// // so that we 'zoom' the editor area
// boolean restoringEditorArea = false;
// if (root instanceof EditorSashContainer) {
// root = ((EditorSashContainer) root).getContainer();
// restoringEditorArea = true;
// }
//
// // This is a compound operation
// fvm.deferUpdates(true);
//
// LayoutPart[] children = root.getChildren();
// for (int i = 0; i < children.length; i++) {
// if (children[i] != this) {
// IWindowTrim trim = tbm.getTrim(children[i].getID());
// if (trim == null)
// continue;
//
// if (trim instanceof ViewStackTrimToolBar) {
// ViewStackTrimToolBar vstb = (ViewStackTrimToolBar) trim;
// if (vstb.restoreOnUnzoom()
// && children[i] instanceof ContainerPlaceholder) {
// // In the current presentation its a
// // container placeholder
// ViewStack realStack = (ViewStack) ((ContainerPlaceholder) children[i])
// .getRealContainer();
// realStack.setMinimized(false);
//
// vstb.setRestoreOnUnzoom(false);
// }
// } else if (trim instanceof EditorAreaTrimToolBar) {
// if (perspective.getEditorAreaRestoreOnUnzoom())
// perspective.setEditorAreaState(IStackPresentationSite.STATE_RESTORED);
// }
// }
// }
//
// // If the editor area has changed state tell the perspective
// if (restoringEditorArea)
// perspective.setEditorAreaState(IStackPresentationSite.STATE_RESTORED);
//
// perspective.getPresentation().setMaximizedStack(null);
//
// fvm.deferUpdates(false);
// smartZoomed = false;
//
// doingUnzoom = false;
// }
protected: void SetState(const int newState);
/**
* Called by the workbench page to notify this part that it has been zoomed or unzoomed.
* The PartStack should not call this method itself -- it must request zoom changes by
* talking to the WorkbenchPage.
*/
// public: void setZoomed(boolean isZoomed) {
//
// super.setZoomed(isZoomed);
//
// LayoutPart[] children = getChildren();
//
// for (int i = 0; i < children.length; i++) {
// LayoutPart next = children[i];
//
// next.setZoomed(isZoomed);
// }
//
// refreshPresentationState();
// }
// public: boolean isZoomed() {
// ILayoutContainer container = getContainer();
//
// if (container != null) {
// return container.childIsZoomed(this);
// }
//
// return false;
// }
// protected: void refreshPresentationState() {
// if (isZoomed() || smartZoomed) {
// presentationSite.setPresentationState(IStackPresentationSite.STATE_MAXIMIZED);
// } else {
//
// boolean wasMinimized = (presentationSite.getState() == IStackPresentationSite.STATE_MINIMIZED);
//
// if (isMinimized) {
// presentationSite.setPresentationState(IStackPresentationSite.STATE_MINIMIZED);
// } else {
// presentationSite.setPresentationState(IStackPresentationSite.STATE_RESTORED);
// }
//
// if (isMinimized != wasMinimized) {
// flushLayout();
//
// if (isMinimized) {
// WorkbenchPage page = getPage();
//
// if (page != null) {
// page.refreshActiveView();
// }
// }
// }
// }
// }
/**
* Makes the given part visible in the presentation.
* @param part the part to add to the stack
* @param cookie other information
*/
private: void ShowPart(StackablePart::Pointer part, Object::Pointer cookie);
/**
* Update the container to show the correct visible tab based on the
* activation list.
*/
private: void UpdateContainerVisibleTab();
/**
*
*/
public: void ShowSystemMenu();
public: void ShowPaneMenu();
public: void ShowPartList();
public: std::vector<void*> GetTabList(StackablePart::Pointer part);
/**
*
* @param beingDragged
* @param initialLocation
* @param keyboard
*/
private: void DragStart(IPresentablePart::Pointer beingDragged, Point& initialLocation,
bool keyboard);
public: void PaneDragStart(PartPane::Pointer pane, Point& initialLocation,
bool keyboard);
/**
* @return Returns the savedPresentationState.
*/
public: IMemento::Pointer GetSavedPresentationState();
private: void FireInternalPropertyChange(int id);
// TrimStack Support
/**
* Explicitly sets the presentation state. This is used by the
* new min/max code to force the CTabFolder to show the proper
* state without going through the 'setState' code (which causes
* nasty side-effects.
* @param newState The state to set the presentation to
*/
// public: void setPresentationState(int newState) {
// presentationSite.setPresentationState(newState);
// }
//
// Support for passing perspective layout properties to the presentation
public: std::string GetProperty(const std::string& id);
public: void SetProperty(const std::string& id, const std::string& value);
/**
* Copies all appearance related data from this stack to the given stack.
*/
public: void CopyAppearanceProperties(PartStack::Pointer copyTo);
public: void ResizeChild(StackablePart::Pointer childThatChanged);
};
}
#endif /*BERRYPARTSTACK_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartTester.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartTester.cpp
index eb8c09a0d8..41c62b5915 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartTester.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartTester.cpp
@@ -1,110 +1,110 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryPartTester.h"
#include <Poco/Exception.h>
#include <berryObjectString.h>
#include "berryIEditorSite.h"
#include "berryIViewSite.h"
namespace berry
{
void PartTester::TestEditor(IEditorPart::Pointer part)
{
TestWorkbenchPart(part);
if (!(part->GetSite() == part->GetEditorSite().GetPointer()))
throw Poco::AssertionViolationException("The part's editor site must be the same as the part's site"); //$NON-NLS-1$
IEditorInput::Pointer input = part->GetEditorInput();
if (input.IsNull())
throw Poco::AssertionViolationException("The editor input must be non-null"); //$NON-NLS-1$
TestEditorInput(input);
part->IsDirty();
part->IsSaveAsAllowed();
part->IsSaveOnCloseNeeded();
}
void PartTester::TestEditorInput(IEditorInput::Pointer /*input*/)
{
//input.getAdapter(Object.class);
// Don't test input.getImageDescriptor() -- the workbench never uses that
// method and most editor inputs would fail the test. It should really be
// deprecated.
// Persistable element may be null
// IPersistableElement persistableElement = input.getPersistable();
// if (persistableElement != null) {
// Assert
// .isNotNull(persistableElement.getFactoryId(),
// "The persistable element for the editor input must have a non-null factory id"); //$NON-NLS-1$
// }
}
void PartTester::TestWorkbenchPart(IWorkbenchPart::Pointer part)
{
// IPropertyListener testListener = new IPropertyListener() {
// public void propertyChanged(Object source, int propId) {
//
// }
// };
// Test addPropertyListener
//part.addPropertyListener(testListener);
// Test removePropertyListener
//part.removePropertyListener(testListener);
// Test equals
if (part != part)
throw Poco::AssertionViolationException("A part must be equal to itself"); //$NON-NLS-1$
Object::Pointer obj(new ObjectString("jo"));
if (part == obj)
throw Poco::AssertionViolationException("A part must have a meaningful operator== method"); //$NON-NLS-1$
// Test getAdapter
//Object partAdapter = part.getAdapter(part.getClass());
//Assert.isTrue(partAdapter == null || partAdapter == part,
//"A part must adapter to itself or return null"); //$NON-NLS-1$
// Test getTitleImage
//Assert.isNotNull(part.getTitleImage(),
// "A part's title image must be non-null"); //$NON-NLS-1$
// Compute hashCode
//part.hashCode();
}
void PartTester::TestView(IViewPart::Pointer part)
{
if (!(part->GetSite() == part->GetViewSite().GetPointer()))
throw Poco::AssertionViolationException(
"A part's site must be the same as a part's view site"); //$NON-NLS-1$
TestWorkbenchPart(part);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartTester.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartTester.h
index 0f852b215c..4686420f16 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartTester.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartTester.h
@@ -1,73 +1,73 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYPARTTESTER_H_
#define BERRYPARTTESTER_H_
#include "berryIEditorPart.h"
#include "berryIEditorInput.h"
#include "berryIViewPart.h"
namespace berry {
/**
* \ingroup org_blueberry_ui_internal
*
*/
class PartTester {
private:
PartTester() { }
/**
* Sanity-check the public interface of the editor. This is called on every editor after it
* is fully initiallized, but before it is actually connected to the editor reference or the
* layout. Calls as much of the editor's public interface as possible to test for exceptions,
* and tests the return values for glaring faults. This does not need to be an exhaustive conformance
* test, as it is called every time an editor is opened and it needs to be efficient.
* The part should be unmodified when the method exits.
*
* @param part
*/
public: static void TestEditor(IEditorPart::Pointer part);
public: static void TestEditorInput(IEditorInput::Pointer input);
/**
* Sanity-checks a workbench part. Excercises the public interface and tests for any
* obviously bogus return values. The part should be unmodified when the method exits.
*
* @param part
* @throws Exception
*/
private: static void TestWorkbenchPart(IWorkbenchPart::Pointer part);
/**
* Sanity-check the public interface of a view. This is called on every view after it
* is fully initiallized, but before it is actually connected to the part reference or the
* layout. Calls as much of the part's public interface as possible without modifying the part
* to test for exceptions and check the return values for glaring faults. This does not need
* to be an exhaustive conformance test, as it is called every time an editor is opened and
* it needs to be efficient.
*
* @param part
*/
public: static void TestView(IViewPart::Pointer part);
};
}
#endif /*BERRYPARTTESTER_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspective.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspective.cpp
index 846f5bf082..ee7d5a7f32 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspective.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspective.cpp
@@ -1,1764 +1,1764 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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<IWorkbenchPart>() == ref->GetPart(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<IViewReference::Pointer> refs(this->GetViewReferences());
for (std::vector<IViewReference::Pointer>::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<IMemento::Pointer> 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<IViewReference::Pointer> 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<WorkbenchPartReference>()->GetPane();
}
std::vector<std::string> Perspective::GetPerspectiveShortcuts()
{
return perspectiveShortcuts;
}
PerspectiveHelper* Perspective::GetPresentation() const
{
return presentation;
}
std::vector<std::string> Perspective::GetShowViewShortcuts()
{
return showViewShortcuts;
}
ViewFactory* Perspective::GetViewFactory()
{
return viewFactory;
}
std::vector<IViewReference::Pointer> Perspective::GetViewReferences()
{
// Get normal views.
if (presentation == 0)
{
return std::vector<IViewReference::Pointer>();
}
std::vector<PartPane::Pointer> panes;
presentation->CollectViewPanes(panes);
std::vector<IViewReference::Pointer> 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<PartPane::Pointer>::iterator iter = panes.begin();
iter != panes.end(); ++iter)
{
PartPane::Pointer pane = *iter;
result.push_back(pane->GetPartReference().Cast<IViewReference>());
}
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<EditorStack>() != 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 ContainerPlaceholder(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<PerspectiveRegistry*>(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<PerspectiveRegistry*>(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<IStickyViewDescriptor::Pointer> 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<std::string, ViewLayoutRec::Pointer> 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();
// 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<ViewStack>() != 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<PerspectiveDescriptor>();
if (desc)
{
descriptor = desc;
}
this->memento = memento;
// Add the visible views.
std::vector<IMemento::Pointer> 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<IMemento::Pointer>& 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<IMemento::Pointer> 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<WorkbenchPartReference>();
// 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<IViewPart>();
if (view)
{
ViewSite::Pointer site = view->GetSite().Cast<ViewSite>();
pres->ReplacePlaceholderWithPart(site->GetPane().Cast<StackablePart>());
}
}
else
{
pres->ReplacePlaceholderWithPart(ref->GetPane().Cast<StackablePart>());
}
}
// // Load the fast views
// if (fastViewManager != 0)
// fastViewManager.restoreState(memento, result);
// Load the view layout recs
std::vector<IMemento::Pointer> 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<IMemento::Pointer> 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<std::string> Perspective::GetShowInIdsFromRegistry()
{
PerspectiveExtensionReader reader;
std::vector<std::string> 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<PerspectiveDescriptor>();
// //get the layout from the registry
// PerspectiveRegistry* perspRegistry = dynamic_cast<PerspectiveRegistry*>(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<std::string>::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<std::string>::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<PartPane::Pointer> viewPanes;
presentation->CollectViewPanes(viewPanes);
// Save the views.
for (std::vector<PartPane::Pointer>::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<IViewReference>()));
}
}
// // save all fastview state
// if (fastViewManager != 0)
// fastViewManager.saveState(memento);
// Save the view layout recs.
for (std::map<std::string, ViewLayoutRec::Pointer>::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<std::string>& list)
{
perspectiveShortcuts = list;
}
void Perspective::SetShowInPartIds(const std::vector<std::string>& list)
{
showInPartIds = list;
}
void Perspective::SetShowViewActionIds(const std::vector<std::string>& 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<EditorSashContainer>()->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<IViewPart>();
if (part == 0)
{
throw PartInitException("Could not create view: " + ref->GetId());
}
PartSite::Pointer site = part->GetSite().Cast<PartSite>();
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<ContainerPlaceholder>() != 0)
// id = ((ContainerPlaceholder)container).getID();
// else if (container.Cast<ViewStack>() != 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<ContainerPlaceholder>() != 0)
// {
// ContainerPlaceholder cph = (ContainerPlaceholder) blPart;
// if (cph.getRealContainer().Cast<ViewStack>() != 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<ViewStack>() != 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<IViewReference::Pointer> 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<WorkbenchWindow>();
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;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspective.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspective.h
index 3156923d12..1dc1a29f44 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspective.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspective.h
@@ -1,628 +1,628 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 <berryMacros.h>
#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 <map>
#include <vector>
#include <string>
namespace berry {
class ViewFactory;
class PerspectiveHelper;
/**
* \ingroup org_blueberry_ui_internal
*
*/
class Perspective : public Object {
public:
berryObjectMacro(Perspective);
friend class WorkbenchPage;
private:
ViewFactory* viewFactory;
std::map<std::string, ViewLayoutRec::Pointer> mapIDtoViewLayoutRec;
static const std::string VERSION_STRING; // = "0.016";//$NON-NLS-1$
/**
* Reference to the part that was previously active
* when this perspective was deactivated.
*/
IWorkbenchPartReference::Pointer oldPartRef;
protected:
PerspectiveDescriptor::Pointer descriptor;
WorkbenchPage* page;
// Editor Area management
LayoutPart::Pointer editorArea;
ContainerPlaceholder::Pointer editorHolder;
bool editorHidden;
int editorAreaState;
//ArrayList alwaysOnActionSets;
//ArrayList alwaysOffActionSets;
std::vector<std::string> showViewShortcuts;
std::vector<std::string> perspectiveShortcuts;
bool fixed;
std::vector<std::string> showInPartIds;
//HashMap showInTimes;
IMemento::Pointer memento;
PerspectiveHelper* presentation;
bool shouldHideEditorsOnActivate;
PageLayout::Pointer layout;
/**
* ViewManager constructor comment.
*/
public: Perspective(PerspectiveDescriptor::Pointer desc, WorkbenchPage::Pointer page);
/**
* ViewManager constructor comment.
*/
protected: Perspective(WorkbenchPage::Pointer page);
protected: void Init(WorkbenchPage::Pointer page);
/**
* Moves a part forward in the Z order of a perspective so it is visible.
*
* @param part the part to bring to move forward
* @return true if the part was brought to top, false if not.
*/
public: bool BringToTop(IViewReference::Pointer ref);
/**
* Returns whether a view exists within the perspective.
*/
public: bool ContainsView(IViewPart::Pointer view);
/**
* Create the initial list of action sets.
*/
// protected: void CreateInitialActionSets(List outputList, List stringList) {
// ActionSetRegistry reg = WorkbenchPlugin.getDefault()
// .getActionSetRegistry();
// Iterator iter = stringList.iterator();
// while (iter.hasNext()) {
// String id = (String) iter.next();
// IActionSetDescriptor desc = reg.findActionSet(id);
// if (desc != null) {
// outputList.add(desc);
// } else {
// WorkbenchPlugin.log("Unable to find Action Set: " + id);//$NON-NLS-1$
// }
// }
// }
/**
* Create a presentation for a perspective.
*/
private: void CreatePresentation(PerspectiveDescriptor::Pointer persp);
/**
* Dispose the perspective and all views contained within.
*/
public: ~Perspective();
private: void DisposeViewRefs();
/**
* Finds the view with the given ID that is open in this page, or <code>null</code>
* if not found.
*
* @param viewId the view ID
*/
public: IViewReference::Pointer FindView(const std::string& viewId);
/**
* Finds the view with the given id and secondary id that is open in this page,
* or <code>null</code> if not found.
*
* @param viewId the view ID
* @param secondaryId the secondary ID
*/
public: IViewReference::Pointer FindView(const std::string& id, const std::string& secondaryId);
/**
* Returns the window's client composite widget
* which views and editor area will be parented.
*/
public: void* GetClientComposite();
/**
* Returns the perspective.
*/
public: IPerspectiveDescriptor::Pointer GetDesc();
/**
* Returns the pane for a view reference.
*/
protected: PartPane::Pointer GetPane(IViewReference::Pointer ref);
/**
* Returns the perspective shortcuts associated with this perspective.
*
* @return an array of perspective identifiers
*/
public: std::vector<std::string> GetPerspectiveShortcuts();
/**
* Returns the presentation.
*/
public: PerspectiveHelper* GetPresentation() const;
/**
* Returns the show view shortcuts associated with this perspective.
*
* @return an array of view identifiers
*/
public: std::vector<std::string> GetShowViewShortcuts();
/**
* Returns the view factory.
*/
public: ViewFactory* GetViewFactory();
/**
* See IWorkbenchPage.
*/
public: std::vector<IViewReference::Pointer> GetViewReferences();
/**
* Hide the editor area if visible
*/
protected: void HideEditorArea();
/**
* Hide the editor area if visible
*/
protected: void HideEditorAreaLocal();
public: bool HideView(IViewReference::Pointer ref);
/*
* Return whether the editor area is visible or not.
*/
protected: bool IsEditorAreaVisible();
/**
* Returns the view layout rec for the given view reference,
* or null if not found. If create is true, it creates the record
* if not already created.
*/
public: ViewLayoutRec::Pointer GetViewLayoutRec(IViewReference::Pointer ref, bool create);
/**
* Returns the view layout record for the given view id
* or null if not found. If create is true, it creates the record
* if not already created.
*/
private: ViewLayoutRec::Pointer GetViewLayoutRec(const std::string& viewId, bool create);
/**
* Returns true if a layout or perspective is fixed.
*/
public: bool IsFixedLayout();
/**
* Returns true if a view is standalone.
*
* @since 3.0
*/
public: bool IsStandaloneView(IViewReference::Pointer ref);
/**
* Returns whether the title for a view should
* be shown. This applies only to standalone views.
*
* @since 3.0
*/
public: bool GetShowTitleView(IViewReference::Pointer ref);
/**
* Creates a new presentation from a persistence file.
* Note: This method should not modify the current state of the perspective.
*/
private: void LoadCustomPersp(PerspectiveDescriptor::Pointer persp);
private: void UnableToOpenPerspective(PerspectiveDescriptor::Pointer persp,
const std::string& status);
/**
* Create a presentation for a perspective.
* Note: This method should not modify the current state of the perspective.
*/
protected: void LoadPredefinedPersp(PerspectiveDescriptor::Pointer persp);
// private: void RemoveAlwaysOn(IActionSetDescriptor::Pointer descriptor) {
// if (descriptor == null) {
// return;
// }
// if (!alwaysOnActionSets.contains(descriptor)) {
// return;
// }
//
// alwaysOnActionSets.remove(descriptor);
// if (page != null) {
// page.perspectiveActionSetChanged(this, descriptor, ActionSetManager.CHANGE_HIDE);
// }
// }
// protected: void AddAlwaysOff(IActionSetDescriptor descriptor) {
// if (descriptor == null) {
// return;
// }
// if (alwaysOffActionSets.contains(descriptor)) {
// return;
// }
// alwaysOffActionSets.add(descriptor);
// if (page != null) {
// page.perspectiveActionSetChanged(this, descriptor, ActionSetManager.CHANGE_MASK);
// }
// removeAlwaysOn(descriptor);
// }
// protected: void AddAlwaysOn(IActionSetDescriptor descriptor) {
// if (descriptor == null) {
// return;
// }
// if (alwaysOnActionSets.contains(descriptor)) {
// return;
// }
// alwaysOnActionSets.add(descriptor);
// if (page != null) {
// page.perspectiveActionSetChanged(this, descriptor, ActionSetManager.CHANGE_SHOW);
// }
// removeAlwaysOff(descriptor);
// }
// private: void RemoveAlwaysOff(IActionSetDescriptor descriptor) {
// if (descriptor == null) {
// return;
// }
// if (!alwaysOffActionSets.contains(descriptor)) {
// return;
// }
// alwaysOffActionSets.remove(descriptor);
// if (page != null) {
// page.perspectiveActionSetChanged(this, descriptor, ActionSetManager.CHANGE_UNMASK);
// }
// }
/**
* activate.
*/
protected: void OnActivate();
/**
* deactivate.
*/
protected: void OnDeactivate();
/**
* Notifies that a part has been activated.
*/
public: void PartActivated(IWorkbenchPart::Pointer activePart);
/**
* The user successfully performed a Show In... action on the specified part.
* Update the history.
*/
public: void PerformedShowIn(const std::string& partId);
/**
* Fills a presentation with layout data.
* Note: This method should not modify the current state of the perspective.
*/
public: bool RestoreState(IMemento::Pointer memento);
bool CreateReferences(const std::vector<IMemento::Pointer>& views);
/**
* Fills a presentation with layout data.
* Note: This method should not modify the current state of the perspective.
*/
public: bool RestoreState();
/**
* Returns the ActionSets read from perspectiveExtensions in the registry.
*/
// protected: ArrayList GetPerspectiveExtensionActionSets() {
// PerspectiveExtensionReader reader = new PerspectiveExtensionReader();
// reader
// .setIncludeOnlyTags(new String[] { IWorkbenchRegistryConstants.TAG_ACTION_SET });
// PageLayout layout = new PageLayout();
// reader.extendLayout(null, descriptor.getOriginalId(), layout);
// return layout.getActionSets();
// }
/**
* Returns the Show In... part ids read from the registry.
*/
protected: std::vector<std::string> GetShowInIdsFromRegistry();
/**
* Save the layout.
*/
public: void SaveDesc();
/**
* Save the layout.
*/
public: void SaveDescAs(IPerspectiveDescriptor::Pointer desc);
/**
* Save the layout.
*/
public: bool SaveState(IMemento::Pointer memento);
/**
* Save the layout.
*/
private: bool SaveState(IMemento::Pointer memento, PerspectiveDescriptor::Pointer p,
bool saveInnerViewState);
// public: void turnOnActionSets(IActionSetDescriptor[] newArray) {
// for (int i = 0; i < newArray.length; i++) {
// IActionSetDescriptor descriptor = newArray[i];
//
// addAlwaysOn(descriptor);
// }
// }
// public: void turnOffActionSets(IActionSetDescriptor[] toDisable) {
// for (int i = 0; i < toDisable.length; i++) {
// IActionSetDescriptor descriptor = toDisable[i];
//
// turnOffActionSet(descriptor);
// }
// }
// public: void turnOffActionSet(IActionSetDescriptor toDisable) {
// addAlwaysOff(toDisable);
// }
/**
* Sets the perspective actions for this page.
* This is List of Strings.
*/
public: void SetPerspectiveActionIds(const std::vector<std::string>& list);
/**
* Sets the ids of the parts to list in the Show In... prompter.
* This is a List of Strings.
*/
public: void SetShowInPartIds(const std::vector<std::string>& list);
/**
* Sets the ids of the views to list in the Show View shortcuts.
* This is a List of Strings.
*/
public: void SetShowViewActionIds(const std::vector<std::string>& list);
/**
* Show the editor area if not visible
*/
protected: void ShowEditorArea();
/**
* Show the editor area if not visible
*/
protected: void ShowEditorAreaLocal();
public: void SetEditorAreaState(int newState);
public: int GetEditorAreaState();
/**
*
*/
public: void RefreshEditorAreaVisibility();
/**
* Resolves a view's id into its reference, creating the
* view if necessary.
*
* @param viewId The primary id of the view (must not be
* <code>null</code>
* @param secondaryId The secondary id of a multiple-instance view
* (may be <code>null</code>).
*
* @return The reference to the specified view. This may be null if the
* view fails to create (i.e. thrown a PartInitException)
*/
public: IViewReference::Pointer GetViewReference(const std::string& viewId, const std::string& secondaryId);
/**
* Shows the view with the given id and secondary id.
*/
public: IViewPart::Pointer ShowView(const std::string& viewId, const std::string& secondaryId);
/**
* Returns the old part reference.
* Returns null if there was no previously active part.
*
* @return the old part reference or <code>null</code>
*/
public: IWorkbenchPartReference::Pointer GetOldPartRef();
/**
* Sets the old part reference.
*
* @param oldPartRef The old part reference to set, or <code>null</code>
*/
public: void SetOldPartRef(IWorkbenchPartReference::Pointer oldPartRef);
// //for dynamic UI
// protected: void AddActionSet(IActionSetDescriptor newDesc) {
// IContextService service = (IContextService)page.getWorkbenchWindow().getService(IContextService.class);
// try {
// service.activateContext(ContextAuthority.DEFER_EVENTS);
// for (int i = 0; i < alwaysOnActionSets.size(); i++) {
// IActionSetDescriptor desc = (IActionSetDescriptor) alwaysOnActionSets
// .get(i);
// if (desc.getId().equals(newDesc.getId())) {
// removeAlwaysOn(desc);
// removeAlwaysOff(desc);
// break;
// }
// }
// addAlwaysOn(newDesc);
// } finally {
// service.activateContext(ContextAuthority.SEND_EVENTS);
// }
// }
// // for dynamic UI
// /* package */void removeActionSet(String id) {
// IContextService service = (IContextService)page.getWorkbenchWindow().getService(IContextService.class);
// try {
// service.activateContext(ContextAuthority.DEFER_EVENTS);
// for (int i = 0; i < alwaysOnActionSets.size(); i++) {
// IActionSetDescriptor desc = (IActionSetDescriptor) alwaysOnActionSets
// .get(i);
// if (desc.getId().equals(id)) {
// removeAlwaysOn(desc);
// break;
// }
// }
//
// for (int i = 0; i < alwaysOffActionSets.size(); i++) {
// IActionSetDescriptor desc = (IActionSetDescriptor) alwaysOffActionSets
// .get(i);
// if (desc.getId().equals(id)) {
// removeAlwaysOff(desc);
// break;
// }
// }
// } finally {
// service.activateContext(ContextAuthority.SEND_EVENTS);
// }
// }
// void removeActionSet(IActionSetDescriptor toRemove) {
// removeAlwaysOn(toRemove);
// removeAlwaysOff(toRemove);
// }
/**
* Returns whether the given view is closeable in this perspective.
*
* @since 3.0
*/
public: bool IsCloseable(IViewReference::Pointer reference);
/**
* Returns whether the given view is moveable in this perspective.
*
* @since 3.0
*/
public: bool IsMoveable(IViewReference::Pointer reference);
/**
* Writes a description of the layout to the given string buffer.
* This is used for drag-drop test suites to determine if two layouts are the
* same. Like a hash code, the description should compare as equal iff the
* layouts are the same. However, it should be user-readable in order to
* help debug failed tests. Although these are english readable strings,
* they should not be translated or equality tests will fail.
* <p>
* This is only intended for use by test suites.
* </p>
*
* @param buf
*/
public: void DescribeLayout(std::string& buf) const;
/**
* Sanity-checks the LayoutParts in this perspective. Throws an Assertation exception
* if an object's internal state is invalid.
*/
public: void TestInvariants();
// public: IActionSetDescriptor[] getAlwaysOnActionSets() {
// return (IActionSetDescriptor[]) alwaysOnActionSets.toArray(new IActionSetDescriptor[alwaysOnActionSets.size()]);
// }
// public: IActionSetDescriptor[] getAlwaysOffActionSets() {
// return (IActionSetDescriptor[]) alwaysOffActionSets.toArray(new IActionSetDescriptor[alwaysOffActionSets.size()]);
// }
/**
* Used to restrict the use of the new min/max behavior to envoronments
* in which it has a chance of working...
*
* @param activePerspective We pass this in as an arg so others won't have
* to check it for 'null' (which is one of the failure cases)
*
*/
public: static bool UseNewMinMax(Perspective::Pointer activePerspective);
};
}
#endif /*BERRYPERSPECTIVE_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveDescriptor.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveDescriptor.cpp
index bfcd2a13d5..aebd143d29 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveDescriptor.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveDescriptor.cpp
@@ -1,306 +1,306 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryPerspectiveDescriptor.h"
#include "berryWorkbenchRegistryConstants.h"
#include "berryWorkbenchPlugin.h"
#include "berryWorkbenchConstants.h"
#include "berryPerspectiveRegistry.h"
namespace berry
{
PerspectiveDescriptor::PerspectiveDescriptor(const std::string& id,
const std::string& label, PerspectiveDescriptor::Pointer originalDescriptor)
: singleton(false), fixed(false)
{
this->id = id;
this->label = label;
if (originalDescriptor != 0)
{
this->originalId = originalDescriptor->GetOriginalId();
this->imageDescriptor = originalDescriptor->imageDescriptor;
// This perspective is based on a perspective in some bundle -- if
// that
// bundle goes away then I think it makes sense to treat this
// perspective
// the same as any other -- so store it with the original
// descriptor's
// bundle's list.
//
// It might also make sense the other way...removing the following
// line
// will allow the perspective to stay around when the originating
// bundle
// is unloaded.
//
// This might also have an impact on upgrade cases -- should we
// really be
// destroying all user customized perspectives when the older
// version is
// removed?
//
// I'm leaving this here for now since its a good example, but
// wouldn't be
// surprised if we ultimately decide on the opposite.
//
// The reason this line is important is that this is the value used
// to
// put the object into the UI level registry. When that bundle goes
// away,
// the registry will remove the entire list of objects. So if this
// desc
// has been put into that list -- it will go away.
this->pluginId = originalDescriptor->GetPluginId();
}
}
PerspectiveDescriptor::PerspectiveDescriptor(const std::string& id,
IConfigurationElement::Pointer configElement)
: singleton(false), fixed(false)
{
this->configElement = configElement;
this->id = id;
// Sanity check.
if ((this->GetId() == "") || (this->GetLabel() == "")
|| (this->GetFactoryClassName() == ""))
{
throw CoreException("Invalid extension (missing label, id or class name): "
+ this->GetId());
}
}
IPerspectiveFactory::Pointer PerspectiveDescriptor::CreateFactory()
{
// if there is an originalId, then use that descriptor instead
if (originalId != "")
{
// Get the original descriptor to create the factory. If the
// original is gone then nothing can be done.
IPerspectiveDescriptor::Pointer
target =
dynamic_cast<PerspectiveRegistry*> (WorkbenchPlugin::GetDefault()->GetPerspectiveRegistry()) ->FindPerspectiveWithId(
originalId);
return target == 0 ? IPerspectiveFactory::Pointer(0) : target.Cast<
PerspectiveDescriptor> ()->CreateFactory();
}
// otherwise try to create the executable extension
if (configElement != 0)
{
try
{
IPerspectiveFactory::Pointer factory(
configElement ->CreateExecutableExtension<IPerspectiveFactory> (
WorkbenchRegistryConstants::ATT_CLASS));
if (factory.IsNull())
{
// support legacy BlueBerry extensions
factory = configElement ->CreateExecutableExtension<IPerspectiveFactory> (
WorkbenchRegistryConstants::ATT_CLASS, IPerspectiveFactory::GetManifestName());
}
return factory;
} catch (CoreException& /*e*/)
{
// do nothing
}
}
return IPerspectiveFactory::Pointer(0);
}
void PerspectiveDescriptor::DeleteCustomDefinition()
{
dynamic_cast<PerspectiveRegistry*> (WorkbenchPlugin::GetDefault() ->GetPerspectiveRegistry())->DeleteCustomDefinition(
PerspectiveDescriptor::Pointer(this));
}
std::string PerspectiveDescriptor::GetDescription() const
{
return configElement == 0 ? description : RegistryReader::GetDescription(
configElement);
}
bool PerspectiveDescriptor::GetFixed() const
{
if (configElement == 0)
return fixed;
bool val = false;
configElement->GetBoolAttribute(WorkbenchRegistryConstants::ATT_FIXED, val);
return val;
}
std::string PerspectiveDescriptor::GetId() const
{
return id;
}
std::string PerspectiveDescriptor::GetPluginId() const
{
return configElement == 0 ? pluginId : configElement->GetContributor();
}
ImageDescriptor::Pointer PerspectiveDescriptor::GetImageDescriptor() const
{
if (imageDescriptor)
return imageDescriptor;
if (configElement)
{
std::string icon;
configElement->GetAttribute(WorkbenchRegistryConstants::ATT_ICON, icon);
if (!icon.empty())
{
imageDescriptor = AbstractUICTKPlugin::ImageDescriptorFromPlugin(
configElement->GetContributor(), icon);
}
}
if (!imageDescriptor)
{
imageDescriptor = ImageDescriptor::GetMissingImageDescriptor();
}
return imageDescriptor;
}
std::string PerspectiveDescriptor::GetLabel() const
{
if (configElement == 0)
return label;
std::string val;
configElement->GetAttribute(WorkbenchRegistryConstants::ATT_NAME, val);
return val;
}
std::string PerspectiveDescriptor::GetOriginalId() const
{
if (originalId == "")
{
return this->GetId();
}
return originalId;
}
bool PerspectiveDescriptor::HasCustomDefinition() const
{
return dynamic_cast<PerspectiveRegistry*> (WorkbenchPlugin::GetDefault()->GetPerspectiveRegistry())->HasCustomDefinition(
PerspectiveDescriptor::ConstPointer(this));
}
bool PerspectiveDescriptor::HasDefaultFlag() const
{
if (configElement == 0)
{
return false;
}
bool val = false;
configElement->GetBoolAttribute(WorkbenchRegistryConstants::ATT_DEFAULT, val);
return val;
}
bool PerspectiveDescriptor::IsPredefined() const
{
return this->GetFactoryClassName() != "" && configElement != 0;
}
bool PerspectiveDescriptor::IsSingleton() const
{
if (configElement == 0)
return singleton;
bool val = false;
configElement->GetBoolAttribute(WorkbenchRegistryConstants::ATT_SINGLETON,
val);
return val;
}
bool PerspectiveDescriptor::RestoreState(IMemento::Pointer memento)
{
IMemento::Pointer childMem(memento->GetChild(
WorkbenchConstants::TAG_DESCRIPTOR));
if (childMem)
{
childMem->GetString(WorkbenchConstants::TAG_ID, id);
childMem->GetString(WorkbenchConstants::TAG_DESCRIPTOR, originalId);
childMem->GetString(WorkbenchConstants::TAG_LABEL, label);
childMem->GetString(WorkbenchConstants::TAG_CLASS, className);
int singletonVal;
singleton = childMem->GetInteger(WorkbenchConstants::TAG_SINGLETON,
singletonVal);
// Find a descriptor in the registry.
IPerspectiveDescriptor::Pointer
descriptor =
WorkbenchPlugin::GetDefault() ->GetPerspectiveRegistry()->FindPerspectiveWithId(
this->GetOriginalId());
if (descriptor)
{
// Copy the state from the registred descriptor.
imageDescriptor = descriptor->GetImageDescriptor();
}
}
//return new Status(IStatus.OK, PlatformUI.PLUGIN_ID, 0, "", null); //$NON-NLS-1$
return true;
}
void PerspectiveDescriptor::RevertToPredefined()
{
if (this->IsPredefined())
{
this->DeleteCustomDefinition();
}
}
bool PerspectiveDescriptor::SaveState(IMemento::Pointer memento)
{
IMemento::Pointer childMem(memento->CreateChild(
WorkbenchConstants::TAG_DESCRIPTOR));
childMem->PutString(WorkbenchConstants::TAG_ID, GetId());
if (!originalId.empty())
{
childMem->PutString(WorkbenchConstants::TAG_DESCRIPTOR, originalId);
}
childMem->PutString(WorkbenchConstants::TAG_LABEL, GetLabel());
childMem->PutString(WorkbenchConstants::TAG_CLASS, GetFactoryClassName());
if (singleton)
{
childMem->PutInteger(WorkbenchConstants::TAG_SINGLETON, 1);
}
//return new Status(IStatus.OK, PlatformUI.PLUGIN_ID, 0, "", null);
return true;
}
IConfigurationElement::Pointer PerspectiveDescriptor::GetConfigElement() const
{
return configElement;
}
std::string PerspectiveDescriptor::GetFactoryClassName() const
{
return configElement == 0 ? className : RegistryReader::GetClassValue(
configElement, WorkbenchRegistryConstants::ATT_CLASS);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveDescriptor.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveDescriptor.h
index 824c9f617b..bb64f78c51 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveDescriptor.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveDescriptor.h
@@ -1,233 +1,233 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYPERSPECTIVEDESCRIPTOR_H_
#define BERRYPERSPECTIVEDESCRIPTOR_H_
#include <berryIConfigurationElement.h>
#include "berryIPerspectiveDescriptor.h"
#include "berryIPerspectiveFactory.h"
#include "berryIMemento.h"
#include <string>
namespace berry {
/**
* \ingroup org_blueberry_ui_internal
*
* PerspectiveDescriptor.
* <p>
* A PerspectiveDesciptor has 3 states:
* </p>
* <ol>
* <li>It <code>isPredefined()</code>, in which case it was defined from an
* extension point.</li>
* <li>It <code>isPredefined()</code> and <code>hasCustomFile</code>, in
* which case the user has customized a predefined perspective.</li>
* <li>It <code>hasCustomFile</code>, in which case the user created a new
* perspective.</li>
* </ol>
*
*/
class PerspectiveDescriptor : public IPerspectiveDescriptor {
public:
berryObjectMacro(PerspectiveDescriptor)
private:
std::string id;
std::string pluginId;
std::string originalId;
std::string label;
std::string className;
std::string description;
bool singleton;
bool fixed;
mutable ImageDescriptor::Pointer imageDescriptor;
IConfigurationElement::Pointer configElement;
/**
* Create a new empty descriptor.
*
* @param id
* the id of the new descriptor
* @param label
* the label of the new descriptor
* @param originalDescriptor
* the descriptor that this descriptor is based on
*/
public: PerspectiveDescriptor(const std::string& id, const std::string& label,
PerspectiveDescriptor::Pointer originalDescriptor);
/**
* Create a descriptor from a config element.
*
* @param id
* the id of the element to create
* @param configElement
* the element to base this perspective on
* @throws CoreException
* thrown if there are any missing attributes
*/
public: PerspectiveDescriptor(const std::string& id, IConfigurationElement::Pointer configElement);
/**
* Creates a factory for a predefined perspective. If the perspective is not
* predefined return <code>null</code>.
*
* @return the IPerspectiveFactory or <code>null</code>
* @throws CoreException
* if the object could not be instantiated.
*/
public: IPerspectiveFactory::Pointer CreateFactory();
/**
* Deletes the custom definition for a perspective..
*/
public: void DeleteCustomDefinition();
/*
* (non-Javadoc)
*
* @see org.blueberry.ui.IPerspectiveDescriptor#getDescription()
*/
public: std::string GetDescription() const;
/**
* Returns whether or not this perspective is fixed.
*
* @return whether or not this perspective is fixed
*/
public: bool GetFixed() const;
/*
* (non-Javadoc)
*
* @see org.blueberry.ui.IPerspectiveDescriptor#getId()
*/
public: std::string GetId() const;
public: std::string GetPluginId() const;
/*
* (non-Javadoc)
*
* @see org.blueberry.ui.IPerspectiveDescriptor#getImageDescriptor()
*/
public: ImageDescriptor::Pointer GetImageDescriptor() const;
/*
* (non-Javadoc)
*
* @see org.blueberry.ui.IPerspectiveDescriptor#getLabel()
*/
public: std::string GetLabel() const;
/**
* Return the original id of this descriptor.
*
* @return the original id of this descriptor
*/
public: std::string GetOriginalId() const;
/**
* Returns <code>true</code> if this perspective has a custom definition.
*
* @return whether this perspective has a custom definition
*/
public: bool HasCustomDefinition() const;
/**
* Returns <code>true</code> if this perspective wants to be default.
*
* @return whether this perspective wants to be default
*/
public: bool HasDefaultFlag() const;
/**
* Returns <code>true</code> if this perspective is predefined by an
* extension.
*
* @return boolean whether this perspective is predefined by an extension
*/
public: bool IsPredefined() const;
/**
* Returns <code>true</code> if this perspective is a singleton.
*
* @return whether this perspective is a singleton
*/
public: bool IsSingleton() const;
/**
* Restore the state of a perspective from a memento.
*
* @param memento
* the memento to restore from
* @return the <code>IStatus</code> of the operation
* @see org.blueberry.ui.IPersistableElement
*/
public: bool RestoreState(IMemento::Pointer memento);
/**
* Revert to the predefined extension template. Does nothing if this
* descriptor is user defined.
*/
public: void RevertToPredefined();
/**
* Save the state of a perspective to a memento.
*
* @param memento
* the memento to restore from
* @return the <code>IStatus</code> of the operation
* @see org.blueberry.ui.IPersistableElement
*/
public: bool SaveState(IMemento::Pointer memento);
/**
* Return the configuration element used to create this perspective, if one
* was used.
*
* @return the configuration element used to create this perspective
* @since 3.0
*/
public: IConfigurationElement::Pointer GetConfigElement() const;
/**
* Returns the factory class name for this descriptor.
*
* @return the factory class name for this descriptor
* @since 3.1
*/
public: std::string GetFactoryClassName() const;
};
}
#endif /*BERRYPERSPECTIVEDESCRIPTOR_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveExtensionReader.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveExtensionReader.cpp
index 25306232a0..cdd91b288f 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveExtensionReader.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveExtensionReader.cpp
@@ -1,389 +1,389 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryPerspectiveExtensionReader.h"
#include "berryWorkbenchPlugin.h"
#include "berryWorkbenchRegistryConstants.h"
#include <Poco/NumberParser.h>
namespace berry
{
const std::string PerspectiveExtensionReader::VAL_LEFT = "left";//$NON-NLS-1$
const std::string PerspectiveExtensionReader::VAL_RIGHT = "right";//$NON-NLS-1$
const std::string PerspectiveExtensionReader::VAL_TOP = "top";//$NON-NLS-1$
const std::string PerspectiveExtensionReader::VAL_BOTTOM = "bottom";//$NON-NLS-1$
const std::string PerspectiveExtensionReader::VAL_STACK = "stack";//$NON-NLS-1$
const std::string PerspectiveExtensionReader::VAL_FAST = "fast";//$NON-NLS-1$
const std::string PerspectiveExtensionReader::VAL_TRUE = "true";//$NON-NLS-1$
//const std::string PerspectiveExtensionReader::VAL_FALSE = "false";//$NON-NLS-1$
bool PerspectiveExtensionReader::IncludeTag(const std::string& tag)
{
return includeOnlyTags.empty() ||
std::find(includeOnlyTags.begin(), includeOnlyTags.end(), tag) != includeOnlyTags.end();
}
bool PerspectiveExtensionReader::ProcessActionSet(
IConfigurationElement::Pointer element)
{
std::string id;
if (element->GetAttribute(WorkbenchRegistryConstants::ATT_ID, id))
{
//TODO PerspectiveExtensionReader action set
//pageLayout->AddActionSet(id);
}
return true;
}
bool PerspectiveExtensionReader::ProcessExtension(
IConfigurationElement::Pointer element)
{
IConfigurationElement::vector children = element->GetChildren();
for (unsigned int nX = 0; nX < children.size(); nX++)
{
IConfigurationElement::Pointer child = children[nX];
std::string type = child->GetName();
if (this->IncludeTag(type))
{
bool result = false;
if (type == WorkbenchRegistryConstants::TAG_ACTION_SET)
{
result = this->ProcessActionSet(child);
}
else if (type == WorkbenchRegistryConstants::TAG_VIEW)
{
result = this->ProcessView(child);
}
else if (type == WorkbenchRegistryConstants::TAG_VIEW_SHORTCUT)
{
result = this->ProcessViewShortcut(child);
}
// else if (type == IorkbenchRegistryConstants::TAG_NEW_WIZARD_SHORTCUT)
// {
// result = processWizardShortcut(child);
// }
else if (type == WorkbenchRegistryConstants::TAG_PERSP_SHORTCUT)
{
result = this->ProcessPerspectiveShortcut(child);
}
else if (type == WorkbenchRegistryConstants::TAG_SHOW_IN_PART)
{
result = this->ProcessShowInPart(child);
}
if (!result)
{
WorkbenchPlugin::Log("Unable to process element: " + //$NON-NLS-1$
type + " in perspective extension: " + //$NON-NLS-1$
element->GetDeclaringExtension()->GetUniqueIdentifier());
}
}
}
return true;
}
bool PerspectiveExtensionReader::ProcessPerspectiveShortcut(
IConfigurationElement::Pointer element)
{
std::string id;
if (element->GetAttribute(WorkbenchRegistryConstants::ATT_ID, id))
{
pageLayout->AddPerspectiveShortcut(id);
}
return true;
}
bool PerspectiveExtensionReader::ProcessShowInPart(
IConfigurationElement::Pointer element)
{
std::string id;
if (element->GetAttribute(WorkbenchRegistryConstants::ATT_ID, id))
{
pageLayout->AddShowInPart(id);
}
return true;
}
bool PerspectiveExtensionReader::ProcessView(
IConfigurationElement::Pointer element)
{
// Get id, relative, and relationship.
std::string id;
if (!element->GetAttribute(WorkbenchRegistryConstants::ATT_ID, id))
{
this->LogMissingAttribute(element, WorkbenchRegistryConstants::ATT_ID);
return false;
}
std::string relative;
bool hasRelative = element->GetAttribute(WorkbenchRegistryConstants::ATT_RELATIVE, relative);
std::string relationship;
if (!element->GetAttribute(WorkbenchRegistryConstants::ATT_RELATIONSHIP, relationship))
{
this->LogMissingAttribute(element, WorkbenchRegistryConstants::ATT_RELATIONSHIP);
return false;
}
if (VAL_FAST != relationship && !hasRelative)
{
this->LogError(element, "Attribute '" + WorkbenchRegistryConstants::ATT_RELATIVE
+ "' not defined. This attribute is required when "
+ WorkbenchRegistryConstants::ATT_RELATIONSHIP + "=\"" + relationship
+ "\"."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
return false;
}
// Get relationship details.
bool stack = false;
bool fast = false;
int intRelation = 0;
if (relationship == VAL_LEFT)
{
intRelation = IPageLayout::LEFT;
}
else if (relationship == VAL_RIGHT)
{
intRelation = IPageLayout::RIGHT;
}
else if (relationship == VAL_TOP)
{
intRelation = IPageLayout::TOP;
}
else if (relationship == VAL_BOTTOM)
{
intRelation = IPageLayout::BOTTOM;
}
else if (relationship == VAL_STACK)
{
stack = true;
}
else if (relationship == VAL_FAST)
{
fast = true;
}
else
{
return false;
}
float ratio = 0.5f;
std::string ratioString;
if (element->GetAttribute(WorkbenchRegistryConstants::ATT_RATIO, ratioString))
{
try
{
ratio = (float)Poco::NumberParser::parseFloat(ratioString);
} catch (Poco::SyntaxException& /*e*/)
{
return false;
}
// If the ratio is outside the allowable range, mark it as invalid.
if (ratio < IPageLayout::RATIO_MIN || ratio > IPageLayout::RATIO_MAX)
{
ratio = IPageLayout::INVALID_RATIO;
}
}
else
{
// The ratio has not been specified.
ratio = IPageLayout::NULL_RATIO;
}
std::string strVisible;
element->GetAttribute(WorkbenchRegistryConstants::ATT_VISIBLE, strVisible);
bool visible = (VAL_TRUE == strVisible);
std::string closeable;
bool hasCloseable = element->GetAttribute(
WorkbenchRegistryConstants::ATT_CLOSEABLE, closeable);
std::string moveable;
bool hasMoveable = element->GetAttribute(
WorkbenchRegistryConstants::ATT_MOVEABLE, moveable);
std::string standalone;
element->GetAttribute(
WorkbenchRegistryConstants::ATT_STANDALONE, standalone);
std::string showTitle;
element->GetAttribute(
WorkbenchRegistryConstants::ATT_SHOW_TITLE, showTitle);
// Default to 'false'
std::string minVal;
bool minimized = false;
if (element->GetAttribute(WorkbenchRegistryConstants::ATT_MINIMIZED, minVal))
minimized = VAL_TRUE == minVal;
if (visible)
{
// If adding a view (not just a placeholder), remove any existing placeholder.
// See bug 85948 [Perspectives] Adding register & expressions view by default to debug perspective fails
pageLayout->RemovePlaceholder(id);
}
// If stack ..
if (stack)
{
if (visible)
{
pageLayout->StackView(id, relative);
}
else
{
pageLayout->StackPlaceholder(id, relative);
}
}
// // If the view is a fast view...
// else if (fast)
// {
// if (ratio == IPageLayout::NULL_RATIO)
// {
// // The ratio has not been specified.
// pageLayout->AddFastView(id);
// }
// else
// {
// pageLayout->AddFastView(id, ratio);
// }
// }
else
{
// The view is a regular view.
// If the ratio is not specified or is invalid, use the default ratio.
if (ratio == IPageLayout::NULL_RATIO || ratio == IPageLayout::INVALID_RATIO)
{
ratio = IPageLayout::DEFAULT_VIEW_RATIO;
}
if (visible)
{
if (VAL_TRUE == standalone)
{
pageLayout->AddStandaloneView(id, VAL_TRUE == showTitle,
intRelation, ratio, relative);
}
else
{
pageLayout->AddView(id, intRelation, ratio, relative, minimized);
}
}
else
{
// Fix for 99155, CGross (schtoo@schtoo.com)
// Adding standalone placeholder for standalone views
if (VAL_TRUE == standalone)
{
pageLayout->AddStandaloneViewPlaceholder(id, intRelation, ratio,
relative, VAL_TRUE == showTitle);
}
else
{
pageLayout->AddPlaceholder(id, intRelation, ratio, relative);
}
}
}
IViewLayout::Pointer viewLayout = pageLayout->GetViewLayout(id);
// may be null if it's been filtered by activity
if (viewLayout != 0)
{
if (hasCloseable)
{
viewLayout->SetCloseable(VAL_TRUE == closeable);
}
if (hasMoveable)
{
viewLayout->SetMoveable(VAL_TRUE == moveable);
}
}
return true;
}
bool PerspectiveExtensionReader::ProcessViewShortcut(
IConfigurationElement::Pointer element)
{
std::string id;
if (element->GetAttribute(WorkbenchRegistryConstants::ATT_ID, id))
{
pageLayout->AddShowViewShortcut(id);
}
return true;
}
//bool PerspectiveExtensionReader::ProcessWizardShortcut(
// IConfigurationElement::Pointer element)
//{
// std::string id = element.getAttribute(IWorkbenchRegistryConstants.ATT_ID);
// if (id != null)
// {
// pageLayout.addNewWizardShortcut(id);
// }
// return true;
//}
bool PerspectiveExtensionReader::ReadElement(
IConfigurationElement::Pointer element)
{
std::string type = element->GetName();
if (type == WorkbenchRegistryConstants::TAG_PERSPECTIVE_EXTENSION)
{
std::string id;
element->GetAttribute(WorkbenchRegistryConstants::ATT_TARGET_ID, id);
if (targetID == id || "*" == id)
{ //$NON-NLS-1$
// if (tracker != null)
// {
// tracker.registerObject(element.getDeclaringExtension(),
// new DirtyPerspectiveMarker(id), IExtensionTracker.REF_STRONG);
// }
return this->ProcessExtension(element);
}
return true;
}
return false;
}
PerspectiveExtensionReader::PerspectiveExtensionReader()
{
// do nothing
}
void PerspectiveExtensionReader::ExtendLayout(const std::string& id,
PageLayout::Pointer out)
{
//tracker = extensionTracker;
targetID = id;
pageLayout = out;
this->ReadRegistry(PlatformUI::PLUGIN_ID,
WorkbenchRegistryConstants::PL_PERSPECTIVE_EXTENSIONS);
}
void PerspectiveExtensionReader::SetIncludeOnlyTags(
const std::vector<std::string>& tags)
{
includeOnlyTags = tags;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveExtensionReader.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveExtensionReader.h
index 67ea5a8f97..562240fdb1 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveExtensionReader.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveExtensionReader.h
@@ -1,136 +1,136 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYPERSPECTIVEEXTENSIONREADER_H_
#define BERRYPERSPECTIVEEXTENSIONREADER_H_
#include "berryRegistryReader.h"
#include "berryPageLayout.h"
namespace berry
{
/**
* A strategy to read perspective extension from the registry.
* A pespective extension is one of a view, viewAction, perspAction,
* newWizardAction, or actionSet.
*/
class PerspectiveExtensionReader: public RegistryReader
{
private:
std::string targetID;
PageLayout::Pointer pageLayout;
std::vector<std::string> includeOnlyTags;
static const std::string VAL_LEFT; // = "left";//$NON-NLS-1$
static const std::string VAL_RIGHT; // = "right";//$NON-NLS-1$
static const std::string VAL_TOP; // = "top";//$NON-NLS-1$
static const std::string VAL_BOTTOM; // = "bottom";//$NON-NLS-1$
static const std::string VAL_STACK; // = "stack";//$NON-NLS-1$
static const std::string VAL_FAST; // = "fast";//$NON-NLS-1$
static const std::string VAL_TRUE; // = "true";//$NON-NLS-1$
// VAL_FALSE added by dan_rubel@instantiations.com
// TODO: this logic is backwards... we should be checking for true, but
// technically this is API now...
//static const std::string VAL_FALSE; // = "false";//$NON-NLS-1$
// IExtensionTracker tracker;
/**
* Returns whether the given tag should be included.
*/
bool IncludeTag(const std::string& tag);
/**
* Process an action set.
*/
bool ProcessActionSet(IConfigurationElement::Pointer element);
/**
* Process an extension.
* Assumption: Extension is for current perspective.
*/
bool ProcessExtension(IConfigurationElement::Pointer element);
/**
* Process a perspective shortcut
*/
bool ProcessPerspectiveShortcut(IConfigurationElement::Pointer element);
/**
* Process a show in element.
*/
bool ProcessShowInPart(IConfigurationElement::Pointer element);
// processView(IConfigurationElement) modified by dan_rubel@instantiations.com
/**
* Process a view
*/
bool ProcessView(IConfigurationElement::Pointer element);
/**
* Process a view shortcut
*/
bool ProcessViewShortcut(IConfigurationElement::Pointer element);
/**
* Process a wizard shortcut
*/
//bool ProcessWizardShortcut(IConfigurationElement::Pointer element);
protected:
bool ReadElement(IConfigurationElement::Pointer element);
public:
/**
* PerspectiveExtensionReader constructor..
*/
PerspectiveExtensionReader();
/**
* Read the view extensions within a registry.
*
* @param extensionTracker the tracker
* @param id the id
* @param out the layout
*/
void ExtendLayout(const std::string& id,
PageLayout::Pointer out);
/**
* Sets the tags to include. All others are ignored.
*
* @param tags the tags to include
*/
void SetIncludeOnlyTags(const std::vector<std::string>& tags);
};
}
#endif /* BERRYPERSPECTIVEEXTENSIONREADER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveHelper.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveHelper.cpp
index 5d4980130b..8b27ed2eb1 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveHelper.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveHelper.cpp
@@ -1,1673 +1,1673 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryPerspectiveHelper.h"
#include "berryLayoutTree.h"
#include "berryEditorSashContainer.h"
#include "berryDragUtil.h"
#include "berryPresentationFactoryUtil.h"
#include "berryWorkbenchConstants.h"
#include <berryDebugUtil.h>
#include <Poco/RegularExpression.h>
namespace berry
{
const int PerspectiveHelper::MIN_DETACH_WIDTH = 150;
const int PerspectiveHelper::MIN_DETACH_HEIGHT = 250;
PerspectiveHelper::DragOverListener::DragOverListener(PerspectiveHelper* perspHelper) :
perspHelper(perspHelper)
{
}
IDropTarget::Pointer PerspectiveHelper::DragOverListener::Drag(
void* /*currentControl*/, Object::Pointer draggedObject, const Point& /*position*/,
const Rectangle& dragRectangle)
{
if (draggedObject.Cast<PartPane>() != 0)
{
PartPane::Pointer part = draggedObject.Cast<PartPane>();
if (part->GetContainer().Cast<PartStack>()->GetAppearance() == PresentationFactoryUtil::ROLE_EDITOR)
return IDropTarget::Pointer(0);
// Views that haven't been shown yet have no 'control' which causes
// 'GetWorkbenchWindow' to return 'null' so check explicitly
if (part->GetPage() != perspHelper->page)
return IDropTarget::Pointer(0);
else if (part->GetWorkbenchWindow() != perspHelper->page->GetWorkbenchWindow())
return IDropTarget::Pointer(0);
if (perspHelper->dropTarget == 0)
perspHelper->dropTarget = new ActualDropTarget(perspHelper, part, dragRectangle);
else
perspHelper->dropTarget->SetTarget(part, dragRectangle);
}
else if (draggedObject.Cast<PartStack>() != 0)
{
PartStack::Pointer stack = draggedObject.Cast<PartStack>();
if (stack->GetAppearance() == PresentationFactoryUtil::ROLE_EDITOR)
return IDropTarget::Pointer(0);
if (stack->GetWorkbenchWindow() != perspHelper->page->GetWorkbenchWindow())
return IDropTarget::Pointer(0);
if (perspHelper->dropTarget == 0)
perspHelper->dropTarget = new ActualDropTarget(perspHelper, stack, dragRectangle);
else
perspHelper->dropTarget->SetTarget(stack, dragRectangle);
}
return perspHelper->dropTarget;
}
void PerspectiveHelper::ActualDropTarget::SetTarget(PartPane::Pointer part,
const Rectangle& dragRectangle)
{
this->stack = 0;
this->part = part;
this->dragRectangle = dragRectangle;
}
void PerspectiveHelper::ActualDropTarget::SetTarget(PartStack::Pointer stack,
const Rectangle& dragRectangle)
{
this->stack = stack;
this->part = 0;
this->dragRectangle = dragRectangle;
}
PerspectiveHelper::ActualDropTarget::ActualDropTarget(PerspectiveHelper* perspHelper, PartPane::Pointer part,
const Rectangle& dragRectangle)
: AbstractDropTarget(), perspHelper(perspHelper)
{
this->SetTarget(part, dragRectangle);
}
PerspectiveHelper::ActualDropTarget::ActualDropTarget(PerspectiveHelper* perspHelper, PartStack::Pointer stack,
const Rectangle& dragRectangle)
: AbstractDropTarget(), perspHelper(perspHelper)
{
this->SetTarget(stack, dragRectangle);
}
void PerspectiveHelper::ActualDropTarget::Drop()
{
if (part != 0)
{
Shell::Pointer shell = part->GetShell();
if (shell->GetData().Cast<DetachedWindow> () != 0)
{
// if only one view in tab folder then do a window move
IStackableContainer::Pointer container = part->GetContainer();
if (container.Cast<PartStack> () != 0)
{
if (container.Cast<PartStack>()->GetItemCount() == 1)
{
shell->SetLocation(dragRectangle.x, dragRectangle.y);
return;
}
}
}
// // If layout is modified always zoom out.
// if (isZoomed())
// {
// zoomOut();
// }
// do a normal part detach
perspHelper->DetachPart(part, dragRectangle.x, dragRectangle.y);
}
else if (stack != 0)
{
Shell::Pointer shell = stack->GetShell();
if (shell->GetData().Cast<DetachedWindow> () != 0)
{
// only one tab folder in a detach window, so do window
// move
shell->SetLocation(dragRectangle.x, dragRectangle.y);
return;
}
// // If layout is modified always zoom out.
// if (isZoomed())
// {
// zoomOut();
// }
// do a normal part detach
perspHelper->Detach(stack, dragRectangle.x, dragRectangle.y);
}
}
DnDTweaklet::CursorType PerspectiveHelper::ActualDropTarget::GetCursor()
{
return DnDTweaklet::CURSOR_OFFSCREEN;
}
PerspectiveHelper::MatchingPart::MatchingPart(const std::string& pid,
const std::string& sid, StackablePart::Pointer part)
{
this->pid = pid;
this->sid = sid;
this->part = part;
this->len = pid.size() + sid.size();
this->hasWildcard = (pid.find_first_of(PartPlaceholder::WILD_CARD)
!= std::string::npos) || (sid.find_first_of(PartPlaceholder::WILD_CARD)
!= std::string::npos);
}
bool PerspectiveHelper::CompareMatchingParts::operator()(const MatchingPart& m1, const MatchingPart& m2) const
{
// specific ids always outweigh ids with wildcards
if (m1.hasWildcard && !m2.hasWildcard)
{
return true;
}
if (!m1.hasWildcard && m2.hasWildcard)
{
return false;
}
// if both are specific or both have wildcards, simply compare based on length
return m1.len > m2.len;
}
PerspectiveHelper::PerspectiveHelper(WorkbenchPage* workbenchPage,
ViewSashContainer::Pointer mainLayout, Perspective::Pointer persp)
: page(workbenchPage), perspective(persp),
mainLayout(mainLayout),
detachable(false), active(false)
{
// Views can be detached if the feature is enabled (true by default,
// use the plug-in customization file to disable), and if the platform
// supports detaching.
this->dragTarget = new DragOverListener(this);
//TODO preference store
// IPreferenceStore store = PlatformUI.getPreferenceStore();
// this.detachable = store.getBoolean(
// IWorkbenchPreferenceConstants.ENABLE_DETACHED_VIEWS);
this->detachable = true;
if (this->detachable)
{
// Check if some arbitrary Composite supports reparenting. If it
// doesn't, views cannot be detached.
void* client = workbenchPage->GetClientComposite();
if (client == 0)
{
// The workbench page is not initialized. I don't think this can happen,
// but if it does, silently set detachable to false.
this->detachable = false;
}
else
{
this->detachable = Tweaklets::Get(GuiWidgetsTweaklet::KEY)->IsReparentable(client);
}
}
}
void PerspectiveHelper::Activate(void* parent)
{
if (active)
{
return;
}
parentWidget = parent;
// Activate main layout
// make sure all the views have been properly parented
std::vector<PartPane::Pointer> children;
this->CollectViewPanes(children, mainLayout->GetChildren());
for (std::vector<PartPane::Pointer>::iterator iter = children.begin();
iter != children.end(); ++iter)
{
PartPane::Pointer part = *iter;
part->Reparent(parent);
}
mainLayout->CreateControl(parent);
mainLayout->SetActive(true);
// Open the detached windows.
for (DetachedWindowsType::iterator iter = detachedWindowList.begin();
iter != detachedWindowList.end(); ++iter)
{
(*iter)->Open();
}
this->EnableAllDrag();
// // Ensure that the maximized stack's presentation state is correct
// if (maximizedStackId != 0)
// {
// LayoutPart part = this->FindPart(maximizedStackId);
// if (part.Cast<PartStack>() != 0)
// {
// maximizedStack = (PartStack) part;
// maximizedStackId = 0;
// }
// }
//
// // NOTE: we only handle ViewStacks here; Editor Stacks are handled by the
// // perspective
// if (maximizedStack instanceof ViewStack)
// {
// maximizedStack.setPresentationState(IStackPresentationSite.STATE_MAXIMIZED);
// }
active = true;
}
void PerspectiveHelper::AddPart(StackablePart::Pointer part)
{
// Look for a placeholder.
PartPlaceholder::Pointer placeholder;
StackablePart::Pointer testPart;
std::string primaryId = part->GetId();
std::string secondaryId;
IViewReference::Pointer ref;
if (part.Cast<PartPane> () != 0)
{
PartPane::Pointer pane = part.Cast<PartPane> ();
ref = pane->GetPartReference().Cast<IViewReference> ();
if (ref != 0)
secondaryId = ref->GetSecondaryId();
}
if (secondaryId != "")
{
testPart = this->FindPart(primaryId, secondaryId);
}
else
{
testPart = this->FindPart(primaryId);
}
// validate the testPart
if (testPart != 0 && testPart.Cast<PartPlaceholder>() != 0)
{
placeholder = testPart.Cast<PartPlaceholder> ();
}
// If there is no placeholder do a simple add. Otherwise, replace the
// placeholder if its not a pattern matching placholder
if (placeholder == 0)
{
part->Reparent(mainLayout->GetParent());
LayoutPart::Pointer relative = mainLayout->FindBottomRight();
if (relative != 0 && relative.Cast<IStackableContainer>() != 0)
{
IStackableContainer::Pointer stack =
relative.Cast<IStackableContainer> ();
if (stack->AllowsAdd(part))
{
mainLayout->Stack(part, stack);
}
else
{
mainLayout->AddPart(part);
}
}
else
{
mainLayout->AddPart(part);
}
}
else
{
IStackableContainer::Pointer container = placeholder->GetContainer();
if (container != 0)
{
if (container.Cast<DetachedPlaceHolder> () != 0)
{
//Create a detached window add the part on it.
DetachedPlaceHolder::Pointer holder = container.Cast<DetachedPlaceHolder>();
detachedPlaceHolderList.remove(holder);
container->Remove(testPart);
DetachedWindow::Pointer window(new DetachedWindow(page));
detachedWindowList.push_back(window);
window->Create();
part->CreateControl(window->GetShell()->GetControl());
// Open window.
window->GetShell()->SetBounds(holder->GetBounds());
window->Open();
// add part to detached window.
PartPane::Pointer pane = part.Cast<PartPane>();
window->Add(pane);
std::list<StackablePart::Pointer> otherChildren = holder->GetChildren();
for (std::list<StackablePart::Pointer>::iterator iter = otherChildren.begin();
iter != otherChildren.end(); ++iter)
{
part->GetContainer()->Add(*iter);
}
}
else
{
// show parent if necessary
if (container.Cast<ContainerPlaceholder> () != 0)
{
ContainerPlaceholder::Pointer containerPlaceholder =
container.Cast<ContainerPlaceholder>();
ILayoutContainer::Pointer parentContainer =
containerPlaceholder->GetContainer();
container = containerPlaceholder->GetRealContainer();
if (container.Cast<LayoutPart> () != 0)
{
parentContainer->Replace(containerPlaceholder,
container.Cast<LayoutPart>());
}
containerPlaceholder->SetRealContainer(IStackableContainer::Pointer(0));
}
// reparent part.
//if (!(container instanceof ViewStack))
// {
// We don't need to reparent children of PartTabFolders since they will automatically
// reparent their children when they become visible. This if statement used to be
// part of an else branch. Investigate if it is still necessary.
// part.reparent(mainLayout.getParent());
// }
// see if we should replace the placeholder
if (placeholder->HasWildCard())
{
// if (container instanceof PartSashContainer)
// {
// ((PartSashContainer) container) .addChildForPlaceholder(part,
// placeholder);
// }
// else
// {
container->Add(part);
// }
}
else
{
container->Replace(placeholder, part);
}
}
}
}
}
void PerspectiveHelper::AttachPart(IViewReference::Pointer ref)
{
PartPane::Pointer pane = ref.Cast<WorkbenchPartReference>()->GetPane();
// Restore any maximized part before re-attaching.
// Note that 'getMaximizedStack != 0' implies 'useNewMinMax'
// if (getMaximizedStack() != 0)
// {
// getMaximizedStack().setState(IStackPresentationSite.STATE_RESTORED);
// }
this->DerefPart(pane);
this->AddPart(pane);
this->BringPartToTop(pane);
pane->SetFocus();
}
bool PerspectiveHelper::CanDetach()
{
return detachable;
}
bool PerspectiveHelper::BringPartToTop(StackablePart::Pointer part)
{
IStackableContainer::Pointer container = part->GetContainer();
if (container != 0 && container.Cast<PartStack> () != 0)
{
PartStack::Pointer folder = container.Cast<PartStack> ();
if (folder->GetSelection() != part)
{
folder->SetSelection(part);
return true;
}
}
return false;
}
bool PerspectiveHelper::IsPartVisible(IWorkbenchPartReference::Pointer partRef)
{
StackablePart::Pointer foundPart;
if (partRef.Cast<IViewReference> () != 0)
{
foundPart = this->FindPart(partRef->GetId(),
partRef.Cast<IViewReference>()->GetSecondaryId());
}
else
{
foundPart = this->FindPart(partRef->GetId());
}
if (foundPart == 0)
{
return false;
}
if (foundPart.Cast<PartPlaceholder> () != 0)
{
return false;
}
IStackableContainer::Pointer container = foundPart->GetContainer();
if (container.Cast<ContainerPlaceholder> () != 0)
{
return false;
}
if (container.Cast<PartStack> () != 0)
{
PartStack::Pointer folder = container.Cast<PartStack>();
StackablePart::Pointer visiblePart = folder->GetSelection();
if (visiblePart == 0)
{
return false;
}
return partRef == visiblePart.Cast<PartPane>()->GetPartReference();
}
return true;
}
bool PerspectiveHelper::WillPartBeVisible(const std::string& partId)
{
return this->WillPartBeVisible(partId, 0);
}
bool PerspectiveHelper::WillPartBeVisible(const std::string& partId,
const std::string& secondaryId)
{
StackablePart::Pointer part = this->FindPart(partId, secondaryId);
if (part == 0)
{
return false;
}
IStackableContainer::Pointer container = part->GetContainer();
if (container != 0 && container.Cast<ContainerPlaceholder> () != 0)
{
container
= container.Cast<ContainerPlaceholder>()->GetRealContainer();
}
if (container != 0 && container.Cast<PartStack> () != 0)
{
PartStack::Pointer folder = container.Cast<PartStack>();
if (folder->GetSelection() == 0)
{
return false;
}
return part->GetCompoundId() == folder->GetSelection().Cast<PartPane>()->GetCompoundId();
}
return true;
}
std::vector<PartPlaceholder::Pointer> PerspectiveHelper::CollectPlaceholders()
{
// Scan the main window.
std::vector<PartPlaceholder::Pointer> results = this->CollectPlaceholders(
mainLayout->GetChildren());
// Scan each detached window.
if (detachable)
{
for (DetachedWindowsType::iterator winIter = detachedWindowList.begin();
winIter != detachedWindowList.end(); ++winIter)
{
DetachedWindow::Pointer win = *winIter;
std::list<StackablePart::Pointer> moreResults = win->GetChildren();
if (moreResults.size()> 0)
{
for (std::list<StackablePart::Pointer>::iterator iter = moreResults.begin();
iter != moreResults.end(); ++iter)
{
if (iter->Cast<PartPlaceholder>() != 0)
results.push_back(iter->Cast<PartPlaceholder>());
}
}
}
}
return results;
}
std::vector<PartPlaceholder::Pointer> PerspectiveHelper::CollectPlaceholders(
const std::list<LayoutPart::Pointer>& parts)
{
std::vector<PartPlaceholder::Pointer> result;
for (std::list<LayoutPart::Pointer>::const_iterator iter = parts.begin();
iter != parts.end(); ++iter)
{
LayoutPart::Pointer part = *iter;
if (part.Cast<ILayoutContainer> () != 0)
{
// iterate through sub containers to find sub-parts
std::vector<PartPlaceholder::Pointer> newParts = this->CollectPlaceholders(
part.Cast<ILayoutContainer>()->GetChildren());
result.insert(result.end(), newParts.begin(), newParts.end());
}
else if (part.Cast<IStackableContainer> () != 0)
{
std::list<StackablePart::Pointer> children = part.Cast<IStackableContainer>()->GetChildren();
for (std::list<StackablePart::Pointer>::iterator partIter = children.begin();
partIter != children.end(); ++partIter)
{
if (partIter->Cast<PartPlaceholder>() != 0)
result.push_back(partIter->Cast<PartPlaceholder>());
}
}
}
return result;
}
std::vector<ContainerPlaceholder::Pointer> PerspectiveHelper::CollectContainerPlaceholders()
{
// Scan the main window.
std::vector<ContainerPlaceholder::Pointer> results(this->CollectContainerPlaceholders(
mainLayout->GetChildren()));
// // Scan each detached window.
// if (detachable)
// {
// for (DetachedWindowsType::iterator winIter = detachedWindowList.begin();
// winIter != detachedWindowList.end(); ++winIter)
// {
// DetachedWindow::Pointer win = *winIter;
// std::list<StackablePart::Pointer> moreResults = win->GetChildren();
// if (moreResults.size()> 0)
// {
// for (std::list<StackablePart::Pointer>::iterator iter = moreResults.begin();
// iter != moreResults.end(); ++iter)
// {
// if (iter->Cast<PartPlaceholder>() != 0)
// results.push_back(iter->Cast<PartPlaceholder>());
// }
// }
// }
// }
return results;
}
std::vector<ContainerPlaceholder::Pointer> PerspectiveHelper::CollectContainerPlaceholders(
const std::list<LayoutPart::Pointer>& parts)
{
std::vector<ContainerPlaceholder::Pointer> result;
for (std::list<LayoutPart::Pointer>::const_iterator iter = parts.begin();
iter != parts.end(); ++iter)
{
LayoutPart::Pointer part = *iter;
if (part.Cast<ILayoutContainer> () != 0)
{
// iterate through sub containers to find sub-parts
std::vector<ContainerPlaceholder::Pointer> newParts = this->CollectContainerPlaceholders(
part.Cast<ILayoutContainer>()->GetChildren());
result.insert(result.end(), newParts.begin(), newParts.end());
}
else if (part.Cast<ContainerPlaceholder> () != 0)
{
result.push_back(part.Cast<ContainerPlaceholder>());
}
}
return result;
}
void PerspectiveHelper::CollectViewPanes(std::vector<PartPane::Pointer>& result)
{
// Scan the main window.
this->CollectViewPanes(result, mainLayout->GetChildren());
// Scan each detached window.
if (detachable)
{
for (DetachedWindowsType::iterator winIter = detachedWindowList.begin();
winIter != detachedWindowList.end(); ++winIter)
{
DetachedWindow::Pointer win = *winIter;
std::list<StackablePart::Pointer> moreResults = win->GetChildren();
for (std::list<StackablePart::Pointer>::iterator iter = moreResults.begin();
iter != moreResults.end(); ++iter)
{
if (iter->Cast<PartPane>() != 0)
result.push_back(iter->Cast<PartPane>());
}
}
}
}
void PerspectiveHelper::CollectViewPanes(std::vector<PartPane::Pointer>& result,
const std::list<LayoutPart::Pointer>& parts)
{
for (std::list<LayoutPart::Pointer>::const_iterator iter = parts.begin();
iter != parts.end(); ++iter)
{
LayoutPart::Pointer part = *iter;
if (part.Cast<PartStack> () != 0 && part.Cast<PartStack>()->GetAppearance() != PresentationFactoryUtil::ROLE_EDITOR)
{
std::list<StackablePart::Pointer> children = part.Cast<IStackableContainer>()->GetChildren();
for (std::list<StackablePart::Pointer>::iterator partIter = children.begin();
partIter != children.end(); ++partIter)
{
if (partIter->Cast<PartPane>() != 0)
result.push_back(partIter->Cast<PartPane>());
}
}
else if (part.Cast<ILayoutContainer> () != 0)
{
this->CollectViewPanes(result, part.Cast<ILayoutContainer>()->GetChildren());
}
}
}
void PerspectiveHelper::Deactivate()
{
if (!active)
{
return;
}
this->DisableAllDrag();
// Reparent all views to the main window
void* parent = mainLayout->GetParent();
std::vector<PartPane::Pointer> children;
this->CollectViewPanes(children, mainLayout->GetChildren());
for (DetachedWindowsType::iterator winIter = detachedWindowList.begin();
winIter != detachedWindowList.end(); ++winIter)
{
DetachedWindow::Pointer window = *winIter;
std::list<StackablePart::Pointer> moreResults = window->GetChildren();
for (std::list<StackablePart::Pointer>::iterator iter = moreResults.begin();
iter != moreResults.end(); ++iter)
{
if (iter->Cast<PartPane>() != 0)
children.push_back(iter->Cast<PartPane>());
}
}
// *** Do we even need to do this if detached windows not supported?
for (std::vector<PartPane::Pointer>::iterator itr = children.begin();
itr != children.end(); ++itr)
{
PartPane::Pointer part = *itr;
part->Reparent(parent);
}
// Dispose main layout.
mainLayout->SetActive(false);
// Dispose the detached windows
for (DetachedWindowsType::iterator iter = detachedWindowList.begin();
iter != detachedWindowList.end(); ++iter)
{
(*iter)->Close();
}
active = false;
}
PerspectiveHelper::~PerspectiveHelper()
{
mainLayout->Dispose();
mainLayout->DisposeSashes();
}
void PerspectiveHelper::DescribeLayout(std::string& buf) const
{
if (detachable)
{
if (detachedWindowList.size() != 0)
{
buf.append("detachedWindows ("); //$NON-NLS-1$
for (DetachedWindowsType::const_iterator winIter = detachedWindowList.begin();
winIter != detachedWindowList.end(); ++winIter)
{
DetachedWindow::ConstPointer window = *winIter;
std::list<StackablePart::Pointer> children = window->GetChildren();
unsigned int j = 0;
if (children.size() != 0)
{
buf.append("dWindow ("); //$NON-NLS-1$
for (std::list<StackablePart::Pointer>::iterator partIter = children.begin();
partIter != children.end(); ++partIter, ++j)
{
if (partIter->Cast<PartPlaceholder>() != 0)
buf.append(partIter->Cast<PartPlaceholder>()->GetPlaceHolderId());
else if (partIter->Cast<PartPane>() != 0)
buf.append(
partIter->Cast<PartPane>()->GetPartReference()->GetPartName());
if (j < (children.size() - 1))
{
buf.append(", "); //$NON-NLS-1$
}
}
buf.append(")"); //$NON-NLS-1$
}
}
buf.append("), "); //$NON-NLS-1$
}
}
this->GetLayout()->DescribeLayout(buf);
}
void PerspectiveHelper::DerefPart(StackablePart::Pointer part)
{
// if (part.Cast<PartPane> () != 0)
// {
// IViewReference::Pointer ref = ((ViewPane) part).getViewReference();
// if (perspective.isFastView(ref))
// {
// // Special check: if it's a fast view then it's actual ViewStack
// // may only contain placeholders and the stack is represented in
// // the presentation by a container placeholder...make sure the
// // PartPlaceHolder for 'ref' is removed from the ViewStack
// String id = perspective.getFastViewManager().getIdForRef(ref);
// LayoutPart parentPart = findPart(id, 0);
// if (parentPart.Cast<ContainerPlaceholder> () != 0)
// {
// ViewStack vs =
// (ViewStack) ((ContainerPlaceholder) parentPart).getRealContainer();
// std::vector<LayoutPart::Pointer> kids = vs.getChildren();
// for (int i = 0; i < kids.length; i++)
// {
// if (kids[i].Cast<PartPlaceholder> () != 0)
// {
// if (ref.getId().equals(kids[i].id))
// vs.remove(kids[i]);
// }
// }
// }
// perspective.getFastViewManager().removeViewReference(ref, true, true);
// }
// }
// Get vital part stats before reparenting.
IStackableContainer::Pointer oldContainer = part->GetContainer();
bool wasDocked = part->IsDocked();
Shell::Pointer oldShell = part->GetShell();
// Reparent the part back to the main window
part->Reparent(mainLayout->GetParent());
// Update container.
if (oldContainer == 0)
{
return;
}
oldContainer->Remove(part);
IStackableContainer::ChildrenType children = oldContainer->GetChildren();
if (wasDocked)
{
bool hasChildren = (children.size()> 0);
if (hasChildren)
{
// make sure one is at least visible
int childVisible = 0;
for (IStackableContainer::ChildrenType::iterator iter = children.begin();
iter != children.end(); ++iter)
{
if ((*iter)->GetControl() != 0)
{
childVisible++;
}
}
// none visible, then reprarent and remove container
if (oldContainer.Cast<PartStack> () != 0)
{
PartStack::Pointer folder = oldContainer.Cast<PartStack>();
// Is the part in the trim?
bool inTrim = false;
// // Safety check...there may be no FastViewManager
// if (perspective.getFastViewManager() != 0)
// inTrim
// = perspective.getFastViewManager().getFastViews(folder.getID()).size()
// > 0;
if (childVisible == 0 && !inTrim)
{
ILayoutContainer::Pointer parentContainer = folder->GetContainer();
hasChildren = folder->GetChildren().size()> 0;
// We maintain the stack as a place-holder if it has children
// (which at this point would represent view place-holders)
if (hasChildren)
{
folder->Dispose();
// replace the real container with a ContainerPlaceholder
ContainerPlaceholder::Pointer placeholder(
new ContainerPlaceholder(folder->GetID()));
placeholder->SetRealContainer(folder);
parentContainer->Replace(folder, placeholder);
}
}
else if (childVisible == 1)
{
LayoutTree::Pointer layout = mainLayout->GetLayoutTree();
layout = layout->Find(folder);
layout->SetBounds(layout->GetBounds());
}
}
}
if (!hasChildren)
{
// There are no more children in this container, so get rid of
// it
if (oldContainer.Cast<LayoutPart> () != 0)
{
//BERRY_INFO << "No children left, removing container\n";
LayoutPart::Pointer parent = oldContainer.Cast<LayoutPart>();
ILayoutContainer::Pointer parentContainer = parent->GetContainer();
if (parentContainer != 0)
{
parentContainer->Remove(parent);
parent->Print(std::cout);
parent->Dispose();
}
}
}
}
else if (!wasDocked)
{
if (children.empty())
{
// There are no more children in this container, so get rid of
// it
// Turn on redraw again just in case it was off.
//oldShell.setRedraw(true);
DetachedWindow::Pointer w = oldShell->GetData().Cast<DetachedWindow>();
oldShell->Close();
detachedWindowList.remove(w);
}
else
{
// There are children. If none are visible hide detached
// window.
bool allInvisible = true;
for (IStackableContainer::ChildrenType::iterator iter = children.begin();
iter != children.end(); ++iter)
{
if (iter->Cast<PartPlaceholder> () == 0)
{
allInvisible = false;
break;
}
}
if (allInvisible)
{
DetachedPlaceHolder::Pointer placeholder(new DetachedPlaceHolder("",
oldShell->GetBounds()));
for (IStackableContainer::ChildrenType::iterator iter = children.begin();
iter != children.end(); ++iter)
{
oldContainer->Remove(*iter);
(*iter)->SetContainer(placeholder);
placeholder->Add(*iter);
}
detachedPlaceHolderList.push_back(placeholder);
DetachedWindow::Pointer w = oldShell->GetData().Cast<DetachedWindow>();
oldShell->Close();
detachedWindowList.remove(w);
}
}
}
}
void PerspectiveHelper::Detach(LayoutPart::Pointer part, int x, int y)
{
// Detaching is disabled on some platforms ..
if (!detachable)
{
return;
}
// Calculate detached window size.
Point size = part->GetSize();
if (size.x == 0 || size.y == 0)
{
ILayoutContainer::Pointer container = part->GetContainer();
if (container.Cast<LayoutPart> () != 0)
{
size = container.Cast<LayoutPart>()->GetSize();
}
}
int width = std::max<int>(size.x, MIN_DETACH_WIDTH);
int height = std::max<int>(size.y, MIN_DETACH_HEIGHT);
// Create detached window.
DetachedWindow::Pointer window(new DetachedWindow(page));
detachedWindowList.push_back(window);
// Open window.
window->Create();
window->GetShell()->SetBounds(x, y, width, height);
window->Open();
if (part.Cast<PartStack> () != 0)
{
//window.getShell().setRedraw(false);
//parentWidget.setRedraw(false);
PartStack::Pointer stack = part.Cast<PartStack>();
StackablePart::Pointer visiblePart = stack->GetSelection();
IStackableContainer::ChildrenType children = stack->GetChildren();
for (IStackableContainer::ChildrenType::iterator iter = children.begin();
iter != children.end(); ++iter)
{
if (!(*iter)->IsPlaceHolder())
{
// remove the part from its current container
this->DerefPart(*iter);
// add part to detached window.
window->Add(*iter);
}
}
if (visiblePart != 0)
{
this->BringPartToTop(visiblePart);
visiblePart->SetFocus();
}
//window.getShell().setRedraw(true);
//parentWidget.setRedraw(true);
}
}
void PerspectiveHelper::DetachPart(StackablePart::Pointer part, int x, int y)
{
// Detaching is disabled on some platforms ..
if (!detachable)
{
return;
}
// Calculate detached window size.
Point size = part->GetSize();
if (size.x == 0 || size.y == 0)
{
IStackableContainer::Pointer container = part->GetContainer();
if (container.Cast<LayoutPart> () != 0)
{
size = container.Cast<LayoutPart>()->GetSize();
}
}
int width = std::max<int>(size.x, MIN_DETACH_WIDTH);
int height = std::max<int>(size.y, MIN_DETACH_HEIGHT);
// Create detached window.
DetachedWindow::Pointer window(new DetachedWindow(page));
detachedWindowList.push_back(window);
// Open window.
window->Create();
window->GetShell()->SetBounds(x, y, width, height);
window->Open();
// remove the part from its current container
this->DerefPart(part);
// add part to detached window.
window->Add(part);
part->SetFocus();
}
void PerspectiveHelper::DetachPart(IViewReference::Pointer ref)
{
PartPane::Pointer pane = ref.Cast<WorkbenchPartReference>()->GetPane();
if (this->CanDetach() && pane != 0)
{
// if (getMaximizedStack() != 0)
// getMaximizedStack().setState(IStackPresentationSite.STATE_RESTORED);
Rectangle bounds = pane->GetParentBounds();
this->DetachPart(pane, bounds.x, bounds.y);
}
}
void PerspectiveHelper::AddDetachedPart(StackablePart::Pointer part)
{
// Calculate detached window size.
Rectangle bounds = Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetShell(parentWidget)->GetBounds();
bounds.x = bounds.x + (bounds.width - 300) / 2;
bounds.y = bounds.y + (bounds.height - 300) / 2;
this->AddDetachedPart(part, bounds);
}
void PerspectiveHelper::AddDetachedPart(StackablePart::Pointer part,
const Rectangle& bounds)
{
// Detaching is disabled on some platforms ..
if (!detachable)
{
this->AddPart(part);
return;
}
// Create detached window.
DetachedWindow::Pointer window(new DetachedWindow(page));
detachedWindowList.push_back(window);
window->Create();
// add part to detached window.
part->CreateControl(window->GetShell()->GetControl());
window->Add(part);
// Open window.
window->GetShell()->SetBounds(bounds.x, bounds.y, bounds.width, bounds.height);
window->Open();
part->SetFocus();
}
void PerspectiveHelper::DisableAllDrag()
{
DragUtil::RemoveDragTarget(0, dragTarget);
}
void PerspectiveHelper::EnableAllDrag()
{
DragUtil::AddDragTarget(0, dragTarget);
}
StackablePart::Pointer PerspectiveHelper::FindPart(const std::string& id)
{
return this->FindPart(id, "");
}
StackablePart::Pointer PerspectiveHelper::FindPart(const std::string& primaryId,
const std::string& secondaryId)
{
//BERRY_INFO << "Looking for part: " << primaryId << ":" << secondaryId << std::endl;
// check main window.
std::vector<MatchingPart> matchingParts;
StackablePart::Pointer part = (secondaryId != "") ? this->FindPart(primaryId, secondaryId,
mainLayout->GetChildren(), matchingParts) : this->FindPart(primaryId,
mainLayout->GetChildren(), matchingParts);
if (part != 0)
{
return part;
}
// check each detached windows.
for (DetachedWindowsType::iterator iter = detachedWindowList.begin();
iter != detachedWindowList.end(); ++iter)
{
DetachedWindow::Pointer window = *iter;
part = (secondaryId != "") ? this->FindPart(primaryId, secondaryId,
window->GetChildren(), matchingParts) : this->FindPart(primaryId,
window->GetChildren(), matchingParts);
if (part != 0)
{
return part;
}
}
for (DetachedPlaceHoldersType::iterator iter = detachedPlaceHolderList.begin();
iter != detachedPlaceHolderList.end(); ++iter)
{
DetachedPlaceHolder::Pointer holder = *iter;
part = (secondaryId != "") ? this->FindPart(primaryId, secondaryId,
holder->GetChildren(), matchingParts) : this->FindPart(primaryId,
holder->GetChildren(), matchingParts);
if (part != 0)
{
return part;
}
}
//BERRY_INFO << "Looking through the matched parts (count: " << matchingParts.size() << ")\n";
// sort the matching parts
if (matchingParts.size()> 0)
{
std::partial_sort(matchingParts.begin(), (matchingParts.begin()), matchingParts.end(), CompareMatchingParts());
const MatchingPart& mostSignificantPart = matchingParts.front();
return mostSignificantPart.part;
}
// Not found.
return StackablePart::Pointer(0);
}
StackablePart::Pointer PerspectiveHelper::FindPart(const std::string& id,
const std::list<LayoutPart::Pointer>& parts,
std::vector<MatchingPart>& matchingParts)
{
//BERRY_INFO << "Looking for part " << id << " in a list of layout parts with size " << parts.size() << std::endl;
for (std::list<LayoutPart::Pointer>::const_iterator iter = parts.begin();
iter != parts.end(); ++iter)
{
LayoutPart::Pointer part = *iter;
if (part.Cast<ILayoutContainer> () != 0)
{
StackablePart::Pointer result = this->FindPart(id, part.Cast<ILayoutContainer>()->GetChildren(),
matchingParts);
if (result != 0) return result;
}
else if (part.Cast<IStackableContainer>() != 0)
{
StackablePart::Pointer result = this->FindPart(id, part.Cast<IStackableContainer>()->GetChildren(),
matchingParts);
if (result != 0) return result;
}
}
//BERRY_INFO << "Returning 0\n";
return StackablePart::Pointer(0);
}
LayoutPart::Pointer PerspectiveHelper::FindLayoutPart(const std::string& id,
const std::list<LayoutPart::Pointer>& parts,
std::vector<MatchingPart>& matchingParts)
{
for (std::list<LayoutPart::Pointer>::const_iterator iter = parts.begin();
iter != parts.end(); ++iter)
{
LayoutPart::Pointer part = *iter;
// check for part equality, parts with secondary ids fail
if (part->GetID() == id)
{
return part;
}
else if (part.Cast<EditorSashContainer>() != 0)
{
// Skip.
}
else if (part.Cast<ILayoutContainer> () != 0)
{
part = this->FindLayoutPart(id, part.Cast<ILayoutContainer>()->GetChildren(),
matchingParts);
return part;
}
}
return LayoutPart::Pointer(0);
}
StackablePart::Pointer PerspectiveHelper::FindPart(const std::string& id,
const std::list<StackablePart::Pointer>& parts,
std::vector<MatchingPart>& matchingParts)
{
//BERRY_INFO << "Looking for part " << id << " in a list of stackable parts with size " << parts.size() << std::endl;
for (std::list<StackablePart::Pointer>::const_iterator iter = parts.begin();
iter != parts.end(); ++iter)
{
StackablePart::Pointer part = *iter;
// check for part equality, parts with secondary ids fail
if (part->GetId() == id)
{
if (part.Cast<PartPane> () != 0)
{
PartPane::Pointer pane = part.Cast<PartPane>();
IViewReference::Pointer ref = pane->GetPartReference().Cast<IViewReference>();
if (ref->GetSecondaryId() != "")
{
continue;
}
}
return part;
}
// check pattern matching placeholders
else if (part.Cast<PartPlaceholder>() != 0
&& part.Cast<PartPlaceholder>()->HasWildCard())
{
Poco::RegularExpression re(id, Poco::RegularExpression::RE_CASELESS);
if (re.match(part->GetId()))
{
matchingParts.push_back(MatchingPart(part->GetId(), "", part));
}
// StringMatcher sm = new StringMatcher(part.getID(), true, false);
// if (sm.match(id))
// {
// matchingParts .add(new MatchingPart(part.getID(), 0, part));
// }
}
}
//BERRY_INFO << "Returning 0\n";
return StackablePart::Pointer(0);
}
StackablePart::Pointer PerspectiveHelper::FindPart(const std::string& primaryId,
const std::string& secondaryId,
const std::list<LayoutPart::Pointer>& parts,
std::vector<MatchingPart>& matchingParts)
{
for (std::list<LayoutPart::Pointer>::const_iterator iter = parts.begin();
iter != parts.end(); ++iter)
{
LayoutPart::Pointer part = *iter;
// check containers first
if (part.Cast<EditorSashContainer>() != 0)
{
// skip
}
else if (part.Cast<ILayoutContainer> () != 0)
{
StackablePart::Pointer testPart = this->FindPart(primaryId, secondaryId,
part.Cast<ILayoutContainer>()->GetChildren(), matchingParts);
if (testPart != 0)
{
return testPart;
}
}
}
return StackablePart::Pointer(0);
}
StackablePart::Pointer PerspectiveHelper::FindPart(const std::string& primaryId,
const std::string& secondaryId,
const std::list<StackablePart::Pointer>& parts,
std::vector<MatchingPart>& matchingParts)
{
for (std::list<StackablePart::Pointer>::const_iterator iter = parts.begin();
iter != parts.end(); ++iter)
{
StackablePart::Pointer part = *iter;
// check for view part equality
if (part.Cast<PartPane> () != 0)
{
PartPane::Pointer pane = part.Cast<PartPane>();
IViewReference::Pointer ref = pane->GetPartReference().Cast<IViewReference>();
if (ref->GetId() == primaryId && ref->GetSecondaryId() == secondaryId)
{
return part;
}
}
// check placeholders
else if (part.Cast<PartPlaceholder> () != 0)
{
std::string id = part->GetId();
// optimization: don't bother parsing id if it has no separator -- it can't match
std::string phSecondaryId = ViewFactory::ExtractSecondaryId(id);
if (phSecondaryId == "")
{
// but still need to check for wildcard case
if (id == PartPlaceholder::WILD_CARD)
{
matchingParts.push_back(MatchingPart(id, "", part));
}
continue;
}
std::string phPrimaryId = ViewFactory::ExtractPrimaryId(id);
// perfect matching pair
if (phPrimaryId == primaryId && phSecondaryId == secondaryId)
{
return part;
}
// check for partial matching pair
Poco::RegularExpression pre(phPrimaryId, Poco::RegularExpression::RE_CASELESS);
if (pre.match(primaryId))
{
Poco::RegularExpression sre(phSecondaryId, Poco::RegularExpression::RE_CASELESS);
if (sre.match(secondaryId))
{
matchingParts.push_back(MatchingPart(phPrimaryId, phSecondaryId, part));
}
}
}
}
return StackablePart::Pointer(0);
}
bool PerspectiveHelper::HasPlaceholder(const std::string& id)
{
return this->HasPlaceholder(id, 0);
}
bool PerspectiveHelper::HasPlaceholder(const std::string& primaryId,
const std::string& secondaryId)
{
StackablePart::Pointer testPart;
if (secondaryId == "")
{
testPart = this->FindPart(primaryId);
}
else
{
testPart = this->FindPart(primaryId, secondaryId);
}
return (testPart != 0 && testPart.Cast<PartPlaceholder> () != 0);
}
PartSashContainer::Pointer PerspectiveHelper::GetLayout() const
{
return mainLayout;
}
bool PerspectiveHelper::IsActive()
{
return active;
}
float PerspectiveHelper::GetDockingRatio(StackablePart::Pointer source,
LayoutPart::Pointer target)
{
if ((source.Cast<PartPane> () != 0 || source.Cast<PartStack> () != 0)
&& target.Cast<EditorSashContainer> () != 0)
{
return 0.25f;
}
return 0.5f;
}
void PerspectiveHelper::RemovePart(StackablePart::Pointer part)
{
// Reparent the part back to the main window
void* parent = mainLayout->GetParent();
part->Reparent(parent);
// Replace part with a placeholder
IStackableContainer::Pointer container = part->GetContainer();
if (container != 0)
{
std::string placeHolderId = part->GetPlaceHolderId();
container->Replace(part, StackablePart::Pointer(new PartPlaceholder(placeHolderId)));
// // If the parent is root we're done. Do not try to replace
// // it with placeholder.
// if (container == mainLayout)
// {
// return;
// }
// If the parent is empty replace it with a placeholder.
std::list<StackablePart::Pointer> children = container->GetChildren();
bool allInvisible = true;
for (std::list<StackablePart::Pointer>::iterator childIter = children.begin();
childIter != children.end(); ++childIter)
{
if (childIter->Cast<PartPlaceholder> () == 0)
{
allInvisible = false;
break;
}
}
if (allInvisible && (container.Cast<LayoutPart> () != 0))
{
// what type of window are we in?
LayoutPart::Pointer cPart = container.Cast<LayoutPart>();
//Window oldWindow = cPart.getWindow();
bool wasDocked = cPart->IsDocked();
Shell::Pointer oldShell = cPart->GetShell();
if (wasDocked)
{
// PR 1GDFVBY: ViewStack not disposed when page
// closed.
if (container.Cast<PartStack> () != 0)
{
container.Cast<PartStack>()->Dispose();
}
// replace the real container with a
// ContainerPlaceholder
ILayoutContainer::Pointer parentContainer = cPart->GetContainer();
ContainerPlaceholder::Pointer placeholder(
new ContainerPlaceholder(cPart->GetID()));
placeholder->SetRealContainer(container);
parentContainer->Replace(cPart, placeholder);
}
else
{
DetachedPlaceHolder::Pointer placeholder(
new DetachedPlaceHolder("", oldShell->GetBounds())); //$NON-NLS-1$
for (std::list<StackablePart::Pointer>::iterator childIter2 = children.begin();
childIter2 != children.end(); ++childIter2)
{
(*childIter2)->GetContainer()->Remove(*childIter2);
(*childIter2)->SetContainer(placeholder);
placeholder->Add(*childIter2);
}
detachedPlaceHolderList.push_back(placeholder);
DetachedWindow::Pointer w = oldShell->GetData().Cast<DetachedWindow>();
oldShell->Close();
detachedWindowList.remove(w);
}
}
}
}
void PerspectiveHelper::ReplacePlaceholderWithPart(StackablePart::Pointer part)
{
// Look for a PartPlaceholder that will tell us how to position this
// object
std::vector<PartPlaceholder::Pointer> placeholders = this->CollectPlaceholders();
for (unsigned int i = 0; i < placeholders.size(); i++)
{
if (placeholders[i]->GetCompoundId() == part->GetCompoundId())
{
// found a matching placeholder which we can replace with the
// new View
IStackableContainer::Pointer container = placeholders[i]->GetContainer();
if (container != 0)
{
if (container.Cast<ContainerPlaceholder> () != 0)
{
// One of the children is now visible so replace the
// ContainerPlaceholder with the real container
ContainerPlaceholder::Pointer containerPlaceholder =
container.Cast<ContainerPlaceholder>();
ILayoutContainer::Pointer parentContainer =
containerPlaceholder->GetContainer();
container
= containerPlaceholder->GetRealContainer();
if (container.Cast<LayoutPart> () != 0)
{
parentContainer->Replace(containerPlaceholder,
container.Cast<LayoutPart>());
}
containerPlaceholder->SetRealContainer(IStackableContainer::Pointer(0));
}
container->Replace(placeholders[i], part);
return;
}
}
}
}
void PerspectiveHelper::ReplacePlaceholderWithPart(LayoutPart::Pointer part)
{
// Look for a ContainerPlaceholder that will tell us how to position this
// object
std::vector<ContainerPlaceholder::Pointer> placeholders(this->CollectContainerPlaceholders());
for (std::size_t i = 0; i < placeholders.size(); i++)
{
if (placeholders[i]->GetID() == part->GetID())
{
// found a matching placeholder which we can replace with the
// new container
ILayoutContainer::Pointer container = placeholders[i]->GetContainer();
if (container != 0)
{
// if (container.Cast<ContainerPlaceholder> () != 0)
// {
// // One of the children is now visible so replace the
// // ContainerPlaceholder with the real container
// ContainerPlaceholder::Pointer containerPlaceholder =
// container.Cast<ContainerPlaceholder>();
// ILayoutContainer::Pointer parentContainer =
// containerPlaceholder->GetContainer();
// container
// = containerPlaceholder->GetRealContainer();
// if (container.Cast<LayoutPart> () != 0)
// {
// parentContainer->Replace(containerPlaceholder,
// container.Cast<LayoutPart>());
// }
// containerPlaceholder->SetRealContainer(IStackableContainer::Pointer(0));
// }
container->Replace(placeholders[i], part);
return;
}
}
}
}
bool PerspectiveHelper::RestoreState(IMemento::Pointer memento)
{
// Restore main window.
IMemento::Pointer childMem = memento->GetChild(WorkbenchConstants::TAG_MAIN_WINDOW);
//IStatus r = mainLayout->RestoreState(childMem);
bool r = mainLayout->RestoreState(childMem);
// Restore each floating window.
if (detachable)
{
std::vector<IMemento::Pointer> detachedWindows(memento->GetChildren(
WorkbenchConstants::TAG_DETACHED_WINDOW));
for (std::vector<IMemento::Pointer>::iterator iter = detachedWindows.begin();
iter != detachedWindows.end(); ++iter)
{
DetachedWindow::Pointer win(new DetachedWindow(page));
detachedWindowList.push_back(win);
win->RestoreState(*iter);
}
std::vector<IMemento::Pointer> childrenMem(memento->GetChildren(
WorkbenchConstants::TAG_HIDDEN_WINDOW));
for (std::vector<IMemento::Pointer>::iterator iter = childrenMem.begin();
iter != childrenMem.end(); ++iter)
{
DetachedPlaceHolder::Pointer holder(
new DetachedPlaceHolder("", Rectangle(0, 0, 0, 0)));
holder->RestoreState(*iter);
detachedPlaceHolderList.push_back(holder);
}
}
// Get the cached id of the currently maximized stack
//maximizedStackId = childMem.getString(IWorkbenchConstants.TAG_MAXIMIZED);
return r;
}
bool PerspectiveHelper::SaveState(IMemento::Pointer memento)
{
// Persist main window.
IMemento::Pointer childMem = memento->CreateChild(WorkbenchConstants::TAG_MAIN_WINDOW);
//IStatus r = mainLayout->SaveState(childMem);
bool r = mainLayout->SaveState(childMem);
if (detachable)
{
// Persist each detached window.
for (DetachedWindowsType::iterator iter = detachedWindowList.begin();
iter != detachedWindowList.end(); ++iter)
{
childMem = memento->CreateChild(WorkbenchConstants::TAG_DETACHED_WINDOW);
(*iter)->SaveState(childMem);
}
for (DetachedPlaceHoldersType::iterator iter = detachedPlaceHolderList.begin();
iter != detachedPlaceHolderList.end(); ++iter)
{
childMem = memento->CreateChild(WorkbenchConstants::TAG_HIDDEN_WINDOW);
(*iter)->SaveState(childMem);
}
}
// Write out the id of the maximized (View) stack (if any)
// NOTE: we only write this out if it's a ViewStack since the
// Editor Area is handled by the perspective
// if (maximizedStack.Cast<PartStack> () != 0)
// {
// childMem.putString(IWorkbenchConstants.TAG_MAXIMIZED,
// maximizedStack.getID());
// }
// else if (maximizedStackId != 0)
// {
// // Maintain the cache if the perspective has never been activated
// childMem.putString(IWorkbenchConstants.TAG_MAXIMIZED, maximizedStackId);
// }
return r;
}
void PerspectiveHelper::UpdateBoundsMap()
{
boundsMap.clear();
// Walk the layout gathering the current bounds of each stack
// and the editor area
std::list<LayoutPart::Pointer> kids = mainLayout->GetChildren();
for (std::list<LayoutPart::Pointer>::iterator iter = kids.begin();
iter != kids.end(); ++iter)
{
if (iter->Cast<PartStack> () != 0)
{
PartStack::Pointer vs = iter->Cast<PartStack>();
boundsMap.insert(std::make_pair(vs->GetID(), vs->GetBounds()));
}
else if (iter->Cast<EditorSashContainer> () != 0)
{
EditorSashContainer::Pointer esc = iter->Cast<EditorSashContainer>();
boundsMap.insert(std::make_pair(esc->GetID(), esc->GetBounds()));
}
}
}
void PerspectiveHelper::ResetBoundsMap()
{
boundsMap.clear();
}
Rectangle PerspectiveHelper::GetCachedBoundsFor(const std::string& id)
{
return boundsMap[id];
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveHelper.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveHelper.h
index d81f32d6a0..b2c872d5d8 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveHelper.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveHelper.h
@@ -1,594 +1,594 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYPERSPECTIVEHELPER_H_
#define BERRYPERSPECTIVEHELPER_H_
#include "berryWorkbenchPage.h"
#include "berryPartPlaceholder.h"
#include "berryPerspective.h"
#include "berryViewSashContainer.h"
#include "berryPartPlaceholder.h"
#include "berryDetachedWindow.h"
#include "berryDetachedPlaceHolder.h"
#include "berryIDragOverListener.h"
#include "berryAbstractDropTarget.h"
#include "berryPartPane.h"
namespace berry
{
class WorkbenchPage;
/**
* A perspective presentation is a collection of parts with a layout. Each part
* is parented to a main window, so you can create more than one presentation
* on a set of parts and change the layout just by activating / deactivating a
* presentation.
*
* In addition, the user can change the position of any part by mouse
* manipulation (drag & drop). If a part is removed, we leave a placeholder
* behind to indicate where it goes should the part be added back.
*/
class PerspectiveHelper
{
friend class PartStack;
friend class ViewSashContainer;
private:
WorkbenchPage* page;
protected:
Perspective::Pointer perspective;
protected:
void* parentWidget;
private:
ViewSashContainer::Pointer mainLayout;
//private: PartStack maximizedStack;
/**
* If there is a ViewStack maximized on shutdown the id is
* cached and restored into this field on 'restoreState'.
* This is then used to bash the ViewStack's presentation state
* into the correct value on activation (the startup life-cycle
* is such that we have to use this 'latch' because the window
* state isn't valid until the activate happens.
*/
//private: String maximizedStackId;
private:
typedef std::list<DetachedWindow::Pointer> DetachedWindowsType;
DetachedWindowsType detachedWindowList;
private:
typedef std::list<DetachedPlaceHolder::Pointer> DetachedPlaceHoldersType;
DetachedPlaceHoldersType detachedPlaceHolderList;
/**
* Maps a stack's id to its current bounds
* this is used to capture the current bounds of all
* stacks -before- starting a maximize (since the
* iterative 'minimize' calls cause the intial stack's
* bounds to change.
*/
private:
std::map<std::string, Rectangle> boundsMap;
private:
bool detachable;
protected:
bool active;
// key is the LayoutPart object, value is the PartDragDrop object
//private: IPartDropListener partDropListener;
private:
static const int MIN_DETACH_WIDTH;
private:
static const int MIN_DETACH_HEIGHT;
struct DragOverListener: public IDragOverListener
{
DragOverListener(PerspectiveHelper* perspHelper);
IDropTarget::Pointer Drag(void* currentControl,
Object::Pointer draggedObject, const Point& position,
const Rectangle& dragRectangle);
private:
PerspectiveHelper* perspHelper;
};
IDragOverListener::Pointer dragTarget;
struct ActualDropTarget: public AbstractDropTarget
{
berryObjectMacro(ActualDropTarget)
/**
* @param part
* @param dragRectangle
* @since 3.1
*/
void SetTarget(PartPane::Pointer part, const Rectangle& dragRectangle);
/**
* @param part
* @param dragRectangle
* @since 3.1
*/
void SetTarget(PartStack::Pointer part, const Rectangle& dragRectangle);
ActualDropTarget(PerspectiveHelper* perspHelper, PartPane::Pointer part, const Rectangle& dragRectangle);
ActualDropTarget(PerspectiveHelper* perspHelper, PartStack::Pointer part, const Rectangle& dragRectangle);
void Drop();
DnDTweaklet::CursorType GetCursor();
private:
PartPane::Pointer part;
PartStack::Pointer stack;
Rectangle dragRectangle;
PerspectiveHelper* perspHelper;
};
ActualDropTarget::Pointer dropTarget;
private:
struct MatchingPart
{
std::string pid;
std::string sid;
StackablePart::Pointer part;
bool hasWildcard;
std::string::size_type len;
MatchingPart(const std::string& pid, const std::string& sid,
StackablePart::Pointer part);
};
struct CompareMatchingParts: public std::binary_function<MatchingPart, MatchingPart, bool>
{
bool operator()(const MatchingPart& m1, const MatchingPart& m2) const;
};
/**
* Constructs a new object.
*/
public:
PerspectiveHelper(WorkbenchPage* workbenchPage,
ViewSashContainer::Pointer mainLayout, Perspective::Pointer perspective);
/**
* Show the presentation.
*/
public:
void Activate(void* parent);
/**
* Adds a part to the presentation. If a placeholder exists for the part
* then swap the part in. Otherwise, add the part in the bottom right
* corner of the presentation.
*/
public:
void AddPart(StackablePart::Pointer part);
/**
* Attaches a part that was previously detached to the mainLayout.
*
* @param ref
*/
public:
void AttachPart(IViewReference::Pointer ref);
/**
* Return whether detachable parts can be supported.
*/
public:
bool CanDetach();
/**
* Bring a part forward so it is visible.
*
* @return true if the part was brought to top, false if not.
*/
public:
bool BringPartToTop(StackablePart::Pointer part);
/**
* Returns true if the given part is visible.
* A part is visible if it's top-level (not in a tab folder) or if it is the top one
* in a tab folder.
*/
public:
bool IsPartVisible(IWorkbenchPartReference::Pointer partRef);
/**
* Returns true is not in a tab folder or if it is the top one in a tab
* folder.
*/
public:
bool WillPartBeVisible(const std::string& partId);
public:
bool WillPartBeVisible(const std::string& partId,
const std::string& secondaryId);
/**
* Answer a list of the PartPlaceholder objects.
*/
private:
std::vector<PartPlaceholder::Pointer> CollectPlaceholders();
private:
std::vector<ContainerPlaceholder::Pointer> CollectContainerPlaceholders();
/**
* Answer a list of the PartPlaceholder objects.
*/
private:
std::vector<PartPlaceholder::Pointer> CollectPlaceholders(
const std::list<LayoutPart::Pointer>& parts);
private:
std::vector<ContainerPlaceholder::Pointer> CollectContainerPlaceholders(
const std::list<LayoutPart::Pointer>& parts);
/**
* Answer a list of the view panes.
*/
public:
void CollectViewPanes(std::vector<PartPane::Pointer>& result);
/**
* Answer a list of the view panes.
*/
private:
void CollectViewPanes(std::vector<PartPane::Pointer>& result,
const std::list<LayoutPart::Pointer>& parts);
/**
* Hide the presentation.
*/
public:
void Deactivate();
public:
~PerspectiveHelper();
/**
* Writes a description of the layout to the given string buffer.
* This is used for drag-drop test suites to determine if two layouts are the
* same. Like a hash code, the description should compare as equal iff the
* layouts are the same. However, it should be user-readable in order to
* help debug failed tests. Although these are english readable strings,
* they should not be translated or equality tests will fail.
* <p>
* This is only intended for use by test suites.
* </p>
*
* @param buf
*/
public:
void DescribeLayout(std::string& buf) const;
/**
* Deref a given part. Deconstruct its container as required. Do not remove
* drag listeners.
*/
protected:
/* package */void DerefPart(StackablePart::Pointer part);
/**
* Create a detached window containing a part.
*/
private:
void DetachPart(StackablePart::Pointer source, int x, int y);
private:
void Detach(LayoutPart::Pointer source, int x, int y);
/**
* Detached a part from the mainLayout. Presently this does not use placeholders
* since the current implementation is not robust enough to remember a view's position
* in more than one root container. For now the view is simply derefed and will dock
* in the default position when attachPart is called.
*
* By default parts detached this way are set to float on top of the workbench
* without docking. It is assumed that people that want to drag a part back onto
* the WorkbenchWindow will detach it via drag and drop.
*
* @param ref
*/
public:
void DetachPart(IViewReference::Pointer ref);
/**
* Create a detached window containing a part.
*/
public:
void AddDetachedPart(StackablePart::Pointer part);
public:
void AddDetachedPart(StackablePart::Pointer part, const Rectangle& bounds);
/**
* disableDragging.
*/
private:
void DisableAllDrag();
/**
* enableDragging.
*/
private:
void EnableAllDrag();
/**
* Find the first part with a given ID in the presentation.
* Wild cards now supported.
*/
private:
StackablePart::Pointer FindPart(const std::string& id);
/**
* Find the first part that matches the specified
* primary and secondary id pair. Wild cards
* are supported.
*/
public:
StackablePart::Pointer FindPart(const std::string& primaryId,
const std::string& secondaryId);
/**
* Find the first part with a given ID in the presentation.
*/
private:
StackablePart::Pointer FindPart(const std::string& id,
const std::list<LayoutPart::Pointer>& parts,
std::vector<MatchingPart>& matchingParts);
LayoutPart::Pointer FindLayoutPart(const std::string& id,
const std::list<LayoutPart::Pointer>& parts,
std::vector<MatchingPart>& matchingParts);
StackablePart::Pointer FindPart(const std::string& id,
const std::list<StackablePart::Pointer>& parts,
std::vector<MatchingPart>& matchingParts);
/**
* Find the first part that matches the specified
* primary and secondary id pair. Wild cards
* are supported.
*/
private:
StackablePart::Pointer FindPart(const std::string& primaryId,
const std::string& secondaryId,
const std::list<LayoutPart::Pointer>& parts,
std::vector<MatchingPart>& matchingParts);
StackablePart::Pointer FindPart(const std::string& primaryId,
const std::string& secondaryId,
const std::list<StackablePart::Pointer>& parts,
std::vector<MatchingPart>& matchingParts);
/**
* Returns true if a placeholder exists for a given ID.
*/
public:
bool HasPlaceholder(const std::string& id);
/**
* Returns true if a placeholder exists for a given ID.
* @since 3.0
*/
public:
bool HasPlaceholder(const std::string& primaryId,
const std::string& secondaryId);
/**
* Returns the layout container.
*/
public:
PartSashContainer::Pointer GetLayout() const;
/**
* Gets the active state.
*/
public:
bool IsActive();
/**
* Returns whether the presentation is zoomed.
*
* <strong>NOTE:</strong> As of 3.3 this method should always return 'false'
* when using the new min/max behavior. It is only used for
* legacy 'zoom' handling.
*/
// public: bool IsZoomed() {
// return mainLayout.getZoomedPart() != null;
// }
/**
* @return The currently maxmized stack (if any)
*/
// public: PartStack::Pointer GetMaximizedStack() {
// return maximizedStack;
// }
/**
* Sets the currently maximized stack. Used for query
* and 'unZoom' purposes in the 3.3 presentation.
*
* @param stack The newly maximized stack
*/
// public: void SetMaximizedStack(PartStack::Pointer stack) {
// if (stack == maximizedStack)
// return;
//
// maximizedStack = stack;
// }
/**
* Returns the ratio that should be used when docking the given source
* part onto the given target
*
* @param source newly added part
* @param target existing part being dragged over
* @return the final size of the source part (wrt the current size of target)
* after it is docked
*/
public:
static float GetDockingRatio(StackablePart::Pointer source,
LayoutPart::Pointer target);
/**
* Returns whether changes to a part will affect zoom. There are a few
* conditions for this .. - we are zoomed. - the part is contained in the
* main window. - the part is not the zoom part - the part is not a fast
* view - the part and the zoom part are not in the same editor workbook
* - the part and the zoom part are not in the same view stack.
*/
// public: bool PartChangeAffectsZoom(LayoutPart::Pointer pane) {
// return pane.isObscuredByZoom();
// }
/**
* Remove all references to a part.
*/
public:
void RemovePart(StackablePart::Pointer part);
/**
* Add a part to the presentation.
*
* Note: unlike all other LayoutParts, PartPlaceholders will still point to
* their parent container even when it is inactive. This method relies on this
* fact to locate the parent.
*/
public:
void ReplacePlaceholderWithPart(StackablePart::Pointer part);
void ReplacePlaceholderWithPart(LayoutPart::Pointer container);
/**
* @see org.blueberry.ui.IPersistable
*/
public:
bool RestoreState(IMemento::Pointer memento);
/**
* @see org.blueberry.ui.IPersistable
*/
public:
bool SaveState(IMemento::Pointer memento);
/**
* Zoom in on a particular layout part.
*/
// public: void zoomIn(IWorkbenchPartReference ref) {
// PartPane pane = ((WorkbenchPartReference) ref).getPane();
//
//
// parentWidget.setRedraw(false);
// try {
// pane.requestZoomIn();
// } finally {
// parentWidget.setRedraw(true);
// }
// }
/**
* Zoom out.
*/
// public: void zoomOut() {
// // New 3.3 behavior
// if (Perspective.useNewMinMax(perspective)) {
// if (maximizedStack != null)
// maximizedStack.setState(IStackPresentationSite.STATE_RESTORED);
// return;
// }
//
// LayoutPart zoomPart = mainLayout.getZoomedPart();
// if (zoomPart != null) {
// zoomPart.requestZoomOut();
// }
// }
/**
* Forces the perspective to have no zoomed or minimized parts.
* This is used when switching to the 3.3 presentation...
*/
// public: void forceNoZoom() {
// // Ensure that nobody's zoomed
// zoomOut();
//
// // Now, walk the layout ensuring that nothing is minimized
// LayoutPart[] kids = mainLayout.getChildren();
// for (int i = 0; i < kids.length; i++) {
// if (kids[i] instanceof ViewStack) {
// ((ViewStack)kids[i]).setMinimized(false);
// }
// else if (kids[i] instanceof EditorSashContainer) {
// LayoutPart[] editorStacks = ((EditorSashContainer)kids[i]).getChildren();
// for (int j = 0; j < editorStacks.length; j++) {
// if (editorStacks[j] instanceof EditorStack) {
// ((EditorStack)editorStacks[j]).setMinimized(false);
// }
// }
// }
// }
// }
/**
* Captures the current bounds of all ViewStacks and the editor
* area and puts them into an ID -> Rectangle map. This info is
* used to cache the bounds so that we can correctly place minimized
* stacks during a 'maximized' operation (where the iterative min's
* affect the current layout while being performed.
*/
public:
void UpdateBoundsMap();
/**
* Resets the bounds map so that it won't interfere with normal minimize
* operations
*/
public:
void ResetBoundsMap();
public:
Rectangle GetCachedBoundsFor(const std::string& id);
};
}
#endif /* BERRYPERSPECTIVEHELPER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveRegistry.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveRegistry.cpp
index 90608716f6..f4e03a431f 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveRegistry.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveRegistry.cpp
@@ -1,593 +1,593 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryPerspectiveRegistry.h"
#include "berryWorkbench.h"
#include "berryWorkbenchPlugin.h"
#include "berryPerspectiveRegistryReader.h"
#include <Poco/String.h>
namespace berry
{
const std::string PerspectiveRegistry::EXT = "_persp.xml";
const std::string PerspectiveRegistry::ID_DEF_PERSP = "PerspectiveRegistry.DEFAULT_PERSP";
const std::string PerspectiveRegistry::PERSP = "_persp";
const char PerspectiveRegistry::SPACE_DELIMITER = ' ';
PerspectiveRegistry::PerspectiveRegistry()
{
//IExtensionTracker tracker = PlatformUI.getWorkbench() .getExtensionTracker();
//tracker.registerHandler(this, null);
//this->InitializePreferenceChangeListener();
//WorkbenchPlugin::GetDefault()->GetPreferenceStore()->AddPropertyChangeListener(
// preferenceListener);
}
void PerspectiveRegistry::AddPerspective(PerspectiveDescriptor::Pointer desc)
{
if (desc == 0)
{
return;
}
this->Add(desc);
}
PerspectiveDescriptor::Pointer PerspectiveRegistry::CreatePerspective(const std::string& label,
PerspectiveDescriptor::Pointer originalDescriptor)
{
// Sanity check to avoid invalid or duplicate labels.
if (!this->ValidateLabel(label))
{
return PerspectiveDescriptor::Pointer(0);
}
if (this->FindPerspectiveWithLabel(label) != 0)
{
return PerspectiveDescriptor::Pointer(0);
}
// Calculate ID.
std::string id(label);
std::replace(id.begin(), id.end(), ' ', '_');
Poco::trimInPlace(id);
// Create descriptor.
PerspectiveDescriptor::Pointer desc(
new PerspectiveDescriptor(id, label, originalDescriptor));
this->Add(desc);
return desc;
}
void PerspectiveRegistry::RevertPerspectives(
const std::list<PerspectiveDescriptor::Pointer>& perspToRevert)
{
// indicate that the user is removing these perspectives
for (std::list<PerspectiveDescriptor::Pointer>::const_iterator iter = perspToRevert.begin();
iter != perspToRevert.end(); ++iter)
{
PerspectiveDescriptor::Pointer desc = *iter;
perspToRemove.push_back(desc->GetId());
desc->RevertToPredefined();
}
}
void PerspectiveRegistry::DeletePerspectives(
const std::list<PerspectiveDescriptor::Pointer>& perspToDelete)
{
for (std::list<PerspectiveDescriptor::Pointer>::const_iterator iter = perspToDelete.begin();
iter != perspToDelete.end(); ++iter)
{
this->DeletePerspective(*iter);
}
}
void PerspectiveRegistry::DeletePerspective(IPerspectiveDescriptor::Pointer in)
{
PerspectiveDescriptor::Pointer desc = in.Cast<PerspectiveDescriptor>();
// Don't delete predefined perspectives
if (!desc->IsPredefined())
{
perspToRemove.push_back(desc->GetId());
perspectives.remove(desc);
desc->DeleteCustomDefinition();
this->VerifyDefaultPerspective();
}
}
IPerspectiveDescriptor::Pointer PerspectiveRegistry::FindPerspectiveWithId(const std::string& id)
{
for (std::list<PerspectiveDescriptor::Pointer>::iterator iter = perspectives.begin();
iter != perspectives.end(); ++iter)
{
PerspectiveDescriptor::Pointer desc = *iter;
if (desc->GetId() == id)
{
// if (WorkbenchActivityHelper.restrictUseOf(desc))
// {
// return null;
// }
return desc;
}
}
return IPerspectiveDescriptor::Pointer(0);
}
IPerspectiveDescriptor::Pointer PerspectiveRegistry::FindPerspectiveWithLabel(
const std::string& label)
{
for (std::list<PerspectiveDescriptor::Pointer>::iterator iter = perspectives.begin();
iter != perspectives.end(); ++iter)
{
PerspectiveDescriptor::Pointer desc = *iter;
if (desc->GetLabel() == label)
{
// if (WorkbenchActivityHelper.restrictUseOf(desc))
// {
// return 0;
// }
return desc;
}
}
return IPerspectiveDescriptor::Pointer(0);
}
std::string PerspectiveRegistry::GetDefaultPerspective()
{
return defaultPerspID;
}
std::vector<IPerspectiveDescriptor::Pointer> PerspectiveRegistry::GetPerspectives()
{
// Collection descs = WorkbenchActivityHelper.restrictCollection(perspectives,
// new ArrayList());
// return (IPerspectiveDescriptor[]) descs.toArray(
// new IPerspectiveDescriptor[descs.size()]);
std::vector<IPerspectiveDescriptor::Pointer> result;
for (std::list<PerspectiveDescriptor::Pointer>::iterator iter = perspectives.begin();
iter != perspectives.end(); ++iter)
{
result.push_back(iter->Cast<IPerspectiveDescriptor>());
}
return result;
}
void PerspectiveRegistry::Load()
{
// Load the registries.
this->LoadPredefined();
this->LoadCustom();
// Get default perspective.
// Get it from the R1.0 dialog settings first. Fixes bug 17039
// IDialogSettings dialogSettings =
// WorkbenchPlugin.getDefault() .getDialogSettings();
// std::string str = dialogSettings.get(ID_DEF_PERSP);
// if (str != null && str.length() > 0)
// {
// this->SetDefaultPerspective(str);
// dialogSettings.put(ID_DEF_PERSP, ""); //$NON-NLS-1$
// }
this->VerifyDefaultPerspective();
}
//void PerspectiveRegistry::SaveCustomPersp(PerspectiveDescriptor::Pointer desc,
// XMLMemento::Pointer memento)
//{
//
// IPreferenceStore store = WorkbenchPlugin.getDefault() .getPreferenceStore();
//
// // Save it to the preference store.
// Writer writer = new StringWriter();
//
// memento.save(writer);
// writer.close();
// store.setValue(desc.getId() + PERSP, writer.toString());
//
//}
IMemento::Pointer PerspectiveRegistry::GetCustomPersp(const std::string& /*id*/)
{
//TODO CustomPersp
// Reader reader = null;
//
// IPreferenceStore store = WorkbenchPlugin.getDefault() .getPreferenceStore();
// std::string xmlString = store.getString(id + PERSP);
// if (xmlString != null && xmlString.length() != 0)
// { // defined in store
// reader = new StringReader(xmlString);
// }
// XMLMemento memento = XMLMemento.createReadRoot(reader);
// reader.close();
// return memento;
return IMemento::Pointer(0);
}
void PerspectiveRegistry::SetDefaultPerspective(const std::string& id)
{
IPerspectiveDescriptor::Pointer desc = this->FindPerspectiveWithId(id);
if (desc != 0)
{
defaultPerspID = id;
//TODO Preferences
// PrefUtil.getAPIPreferenceStore().setValue(
// IWorkbenchPreferenceConstants.DEFAULT_PERSPECTIVE_ID, id);
}
}
bool PerspectiveRegistry::ValidateLabel(const std::string& label)
{
return !Poco::trim(label).empty();
}
IPerspectiveDescriptor::Pointer PerspectiveRegistry::ClonePerspective(const std::string& id,
const std::string& label,
IPerspectiveDescriptor::Pointer originalDescriptor)
{
// Check for invalid labels
if (label == "" || Poco::trim(label).empty())
{
throw Poco::InvalidArgumentException();
}
// Check for duplicates
IPerspectiveDescriptor::Pointer desc = this->FindPerspectiveWithId(id);
if (desc != 0)
{
throw Poco::InvalidArgumentException();
}
// Create descriptor.
desc
= new PerspectiveDescriptor(id, label, originalDescriptor.Cast<PerspectiveDescriptor>());
this->Add(desc.Cast<PerspectiveDescriptor>());
return desc;
}
void PerspectiveRegistry::RevertPerspective(IPerspectiveDescriptor::Pointer perspToRevert)
{
PerspectiveDescriptor::Pointer desc = perspToRevert.Cast<PerspectiveDescriptor>();
perspToRemove.push_back(desc->GetId());
desc->RevertToPredefined();
}
PerspectiveRegistry::~PerspectiveRegistry()
{
// PlatformUI.getWorkbench().getExtensionTracker().unregisterHandler(this);
// WorkbenchPlugin.getDefault().getPreferenceStore() .removePropertyChangeListener(
// preferenceListener);
}
void PerspectiveRegistry::DeleteCustomDefinition(PerspectiveDescriptor::Pointer /*desc*/)
{
//TODO Preferences
// remove the entry from the preference store.
//IPreferenceStore store = WorkbenchPlugin.getDefault() .getPreferenceStore();
/*
* To delete the perspective definition from the preference store, use
* the setToDefault method. Since no default is defined, this will
* remove the entry
*/
//store.setToDefault(desc.getId() + PERSP);
}
bool PerspectiveRegistry::HasCustomDefinition(PerspectiveDescriptor::ConstPointer /*desc*/) const
{
//TODO Preferences
//IPreferenceStore store = WorkbenchPlugin::GetDefault()->GetPreferenceStore();
//return store.contains(desc.getId() + PERSP);
return false;
}
void PerspectiveRegistry::InitializePreferenceChangeListener()
{
// preferenceListener = new IPropertyChangeListener()
// {
// public void propertyChange(PropertyChangeEvent event)
// {
// /*
// * To ensure the that no custom perspective definitions are
// * deleted when preferences are imported, merge old and new
// * values
// */
// if (event.getProperty().endsWith(PERSP))
// {
// /* A Perspective is being changed, merge */
// mergePerspectives(event);
// }
// else if (event.getProperty().equals(
// IPreferenceConstants.PERSPECTIVES))
// {
// /* The list of perpsectives is being changed, merge */
// updatePreferenceList((IPreferenceStore) event.getSource());
// }
// }
//
// void MergePerspectives(PropertyChangeEvent::Pointer event)
// {
// IPreferenceStore store = (IPreferenceStore) event.getSource();
// if (event.getNewValue() == null
// || event.getNewValue().equals(""))
// { //$NON-NLS-1$
// /*
// * Perpsective is being removed; if the user has deleted or
// * reverted a custom perspective, let the change pass
// * through. Otherwise, restore the custom perspective entry
// */
//
// // Find the matching descriptor in the registry
// IPerspectiveDescriptor[] perspectiveList = getPerspectives();
// for (int i = 0; i < perspectiveList.length; i++)
// {
// std::string id = perspectiveList[i].getId();
// if (event.getProperty().equals(id + PERSP))
// { // found
// // descriptor
// // see if the perspective has been flagged for
// // reverting or deleting
// if (!perspToRemove.contains(id))
// { // restore
// store.setValue(id + PERSP, (std::string) event
// .getOldValue());
// }
// else
// { // remove element from the list
// perspToRemove.remove(id);
// }
// }
// }
// }
// else if ((event.getOldValue() == null || event.getOldValue()
// .equals("")))
// { //$NON-NLS-1$
//
// /*
// * New perspective is being added, update the
// * perspectiveRegistry to contain the new custom perspective
// */
//
// std::string id = event.getProperty().substring(0,
// event.getProperty().lastIndexOf(PERSP));
// if (findPerspectiveWithId(id) == null)
// {
// // perspective does not already exist in registry, add
// // it
// PerspectiveDescriptor desc = new PerspectiveDescriptor(
// null, null, null);
// StringReader reader = new StringReader((std::string) event
// .getNewValue());
// try
// {
// XMLMemento memento = XMLMemento
// .createReadRoot(reader);
// desc.restoreState(memento);
// addPerspective(desc);
// }
// catch (WorkbenchException e)
// {
// unableToLoadPerspective(e.getStatus());
// }
// }
// }
// /* If necessary, add to the list of perspectives */
// updatePreferenceList(store);
// }
//
// void UpdatePreferenceList(IPreferenceStore store)
// {
// IPerspectiveDescriptor[] perspectiveList = getPerspectives();
// StringBuffer perspBuffer = new StringBuffer();
// for (int i = 0; i < perspectiveList.length; i++)
// {
// PerspectiveDescriptor desc = (PerspectiveDescriptor) perspectiveList[i];
// if (hasCustomDefinition(desc))
// {
// perspBuffer.append(desc.getId())
// .append(SPACE_DELIMITER);
// }
// }
// std::string newList = perspBuffer.toString().trim();
// store.setValue(IPreferenceConstants.PERSPECTIVES, newList);
// }
// };
}
void PerspectiveRegistry::Add(PerspectiveDescriptor::Pointer desc)
{
perspectives.push_back(desc);
// IConfigurationElement::Pointer element = desc->GetConfigElement();
// if (element != 0)
// {
// PlatformUI::GetWorkbench().getExtensionTracker().registerObject(
// element.getDeclaringExtension(), desc, IExtensionTracker.REF_WEAK);
// }
}
void PerspectiveRegistry::InternalDeletePerspective(PerspectiveDescriptor::Pointer desc)
{
perspToRemove.push_back(desc->GetId());
perspectives.remove(desc);
desc->DeleteCustomDefinition();
this->VerifyDefaultPerspective();
}
void PerspectiveRegistry::LoadCustom()
{
// Reader reader = null;
//
// /* Get the entries from the Preference store */
// IPreferenceStore store = WorkbenchPlugin.getDefault() .getPreferenceStore();
//
// /* Get the space-delimited list of custom perspective ids */
// std::string customPerspectives = store .getString(
// IPreferenceConstants.PERSPECTIVES);
// std::string[] perspectivesList = StringConverter.asArray(customPerspectives);
//
// for (int i = 0; i < perspectivesList.length; i++)
// {
// try
// {
// std::string xmlString = store.getString(perspectivesList[i] + PERSP);
// if (xmlString != null && xmlString.length() != 0)
// {
// reader = new StringReader(xmlString);
// }
//
// // Restore the layout state.
// XMLMemento memento = XMLMemento.createReadRoot(reader);
// PerspectiveDescriptor newPersp =
// new PerspectiveDescriptor(null, null, null);
// newPersp.restoreState(memento);
// std::string id = newPersp.getId();
// IPerspectiveDescriptor oldPersp = findPerspectiveWithId(id);
// if (oldPersp == null)
// {
// add(newPersp);
// }
// reader.close();
// } catch (IOException e)
// {
// unableToLoadPerspective(null);
// } catch (WorkbenchException e)
// {
// unableToLoadPerspective(e.getStatus());
// }
// }
//
// // Get the entries from files, if any
// // if -data @noDefault specified the state location may not be
// // initialized
// IPath path = WorkbenchPlugin.getDefault().getDataLocation();
// if (path == null)
// {
// return;
// }
//
// File folder = path.toFile();
//
// if (folder.isDirectory())
// {
// File[] fileList = folder.listFiles();
// int nSize = fileList.length;
// for (int nX = 0; nX < nSize; nX++)
// {
// File file = fileList[nX];
// if (file.getName().endsWith(EXT))
// {
// // get the memento
// InputStream stream = null;
// try
// {
// stream = new FileInputStream(file);
// reader = new BufferedReader(new InputStreamReader(stream, "utf-8")); //$NON-NLS-1$
//
// // Restore the layout state.
// XMLMemento memento = XMLMemento.createReadRoot(reader);
// PerspectiveDescriptor newPersp =
// new PerspectiveDescriptor(null, null, null);
// newPersp.restoreState(memento);
// IPerspectiveDescriptor oldPersp = findPerspectiveWithId(
// newPersp .getId());
// if (oldPersp == null)
// {
// add(newPersp);
// }
//
// // save to the preference store
// saveCustomPersp(newPersp, memento);
//
// // delete the file
// file.delete();
//
// reader.close();
// stream.close();
// } catch (IOException e)
// {
// unableToLoadPerspective(null);
// } catch (WorkbenchException e)
// {
// unableToLoadPerspective(e.getStatus());
// }
// }
// }
// }
}
void PerspectiveRegistry::UnableToLoadPerspective(const std::string& status)
{
std::string msg = "Unable to load perspective";
if (status == "")
{
WorkbenchPlugin::Log(msg);
//IStatus errStatus =
// new Status(IStatus.ERR, WorkbenchPlugin.PI_WORKBENCH, msg);
//StatusManager.getManager().handle(errStatus, StatusManager.SHOW);
}
else
{
WorkbenchPlugin::Log(status + ": " + msg);
//IStatus errStatus = StatusUtil.newStatus(status, msg);
//StatusManager.getManager().handle(errStatus, StatusManager.SHOW);
}
}
void PerspectiveRegistry::LoadPredefined()
{
PerspectiveRegistryReader reader;
reader.ReadPerspectives(this);
}
void PerspectiveRegistry::VerifyDefaultPerspective()
{
// Step 1: Try current defPerspId value.
IPerspectiveDescriptor::Pointer desc;
if (defaultPerspID != "")
{
desc = this->FindPerspectiveWithId(defaultPerspID);
}
if (desc != 0)
{
return;
}
// Step 2. Read default value.
//TODO Preferences
// std::string str = PrefUtil.getAPIPreferenceStore().getString(
// IWorkbenchPreferenceConstants.DEFAULT_PERSPECTIVE_ID);
// if (str != null && str.length() > 0)
// {
// desc = this->FindPerspectiveWithId(str);
// }
// if (desc != 0)
// {
// defaultPerspID = str;
// return;
// }
// Step 3. Use application-specific default
defaultPerspID = Workbench::GetInstance()->GetDefaultPerspectiveId();
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveRegistry.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveRegistry.h
index 9fbe82c76f..3fd10db103 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveRegistry.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveRegistry.h
@@ -1,309 +1,309 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYPERSPECTIVEREGISTRY_H_
#define BERRYPERSPECTIVEREGISTRY_H_
#include "berryIPerspectiveRegistry.h"
#include "berryPerspectiveDescriptor.h"
#include <list>
namespace berry {
/**
* Perspective registry.
*/
class PerspectiveRegistry : public IPerspectiveRegistry {
// IExtensionChangeHandler {
friend class PerspectiveDescriptor;
private:
std::string defaultPerspID;
static const std::string EXT; // = "_persp.xml";
static const std::string ID_DEF_PERSP; // = "PerspectiveRegistry.DEFAULT_PERSP";
static const std::string PERSP; // = "_persp";
static const char SPACE_DELIMITER; // = ' ';
std::list<PerspectiveDescriptor::Pointer> perspectives;
// keep track of the perspectives the user has selected to remove or revert
std::list<std::string> perspToRemove;
//IPropertyChangeListener::Pointer preferenceListener;
public:
/**
* Construct a new registry.
*/
PerspectiveRegistry();
/**
* Adds a perspective. This is typically used by the reader.
*
* @param desc
*/
void AddPerspective(PerspectiveDescriptor::Pointer desc);
/**
* Create a new perspective.
*
* @param label
* the name of the new descriptor
* @param originalDescriptor
* the descriptor on which to base the new descriptor
* @return a new perspective descriptor or <code>null</code> if the
* creation failed.
*/
PerspectiveDescriptor::Pointer CreatePerspective(const std::string& label,
PerspectiveDescriptor::Pointer originalDescriptor);
/**
* Reverts a list of perspectives back to the plugin definition
*
* @param perspToRevert
*/
void RevertPerspectives(const std::list<PerspectiveDescriptor::Pointer>& perspToRevert);
/**
* Deletes a list of perspectives
*
* @param perspToDelete
*/
void DeletePerspectives(const std::list<PerspectiveDescriptor::Pointer>& perspToDelete);
/**
* Delete a perspective. Has no effect if the perspective is defined in an
* extension.
*
* @param in
*/
void DeletePerspective(IPerspectiveDescriptor::Pointer in);
/*
* (non-Javadoc)
*
* @see org.blueberry.ui.IPerspectiveRegistry#findPerspectiveWithId(java.lang.std::string)
*/
IPerspectiveDescriptor::Pointer FindPerspectiveWithId(const std::string& id);
/*
* (non-Javadoc)
*
* @see org.blueberry.ui.IPerspectiveRegistry#findPerspectiveWithLabel(java.lang.std::string)
*/
IPerspectiveDescriptor::Pointer FindPerspectiveWithLabel(const std::string& label);
/**
* @see IPerspectiveRegistry#getDefaultPerspective()
*/
std::string GetDefaultPerspective();
/*
* (non-Javadoc)
*
* @see org.blueberry.ui.IPerspectiveRegistry#getPerspectives()
*/
std::vector<IPerspectiveDescriptor::Pointer> GetPerspectives();
/**
* Loads the registry.
*/
void Load();
/**
* Saves a custom perspective definition to the preference store.
*
* @param desc
* the perspective
* @param memento
* the memento to save to
* @throws IOException
*/
// void SaveCustomPersp(PerspectiveDescriptor::Pointer desc, XMLMemento::Pointer memento);
/**
* Gets the Custom perspective definition from the preference store.
*
* @param id
* the id of the perspective to find
* @return IMemento a memento containing the perspective description
*
* @throws WorkbenchException
* @throws IOException
*/
IMemento::Pointer GetCustomPersp(const std::string& id);
/**
* @see IPerspectiveRegistry#setDefaultPerspective(std::string)
*/
void SetDefaultPerspective(const std::string& id);
/**
* Return <code>true</code> if a label is valid. This checks only the
* given label in isolation. It does not check whether the given label is
* used by any existing perspectives.
*
* @param label
* the label to test
* @return whether the label is valid
*/
bool ValidateLabel(const std::string& label);
/*
* (non-Javadoc)
*
* @see org.blueberry.ui.IPerspectiveRegistry#clonePerspective(java.lang.std::string,
* java.lang.std::string, org.blueberry.ui.IPerspectiveDescriptor)
*/
IPerspectiveDescriptor::Pointer ClonePerspective(const std::string& id, const std::string& label,
IPerspectiveDescriptor::Pointer originalDescriptor);
/*
* (non-Javadoc)
*
* @see org.blueberry.ui.IPerspectiveRegistry#revertPerspective(org.blueberry.ui.IPerspectiveDescriptor)
*/
void RevertPerspective(IPerspectiveDescriptor::Pointer perspToRevert);
/**
* Dispose the receiver.
*/
~PerspectiveRegistry();
/*
* (non-Javadoc)
*
* @see org.blueberry.core.runtime.dynamicHelpers.IExtensionChangeHandler#removeExtension(org.blueberry.core.runtime.IExtension,
* java.lang.Object[])
*/
// void removeExtension(IExtension source, Object[] objects) {
// for (int i = 0; i < objects.length; i++) {
// if (objects[i] instanceof PerspectiveDescriptor) {
// // close the perspective in all windows
// IWorkbenchWindow[] windows = PlatformUI.getWorkbench()
// .getWorkbenchWindows();
// PerspectiveDescriptor desc = (PerspectiveDescriptor) objects[i];
// for (int w = 0; w < windows.length; ++w) {
// IWorkbenchWindow window = windows[w];
// IWorkbenchPage[] pages = window.getPages();
// for (int p = 0; p < pages.length; ++p) {
// WorkbenchPage page = (WorkbenchPage) pages[p];
// ClosePerspectiveHandler.closePerspective(page, page
// .findPerspective(desc));
// }
// }
//
// // ((Workbench)PlatformUI.getWorkbench()).getPerspectiveHistory().removeItem(desc);
//
// internalDeletePerspective(desc);
// }
//
// }
// }
/*
* (non-Javadoc)
*
* @see org.blueberry.core.runtime.dynamicHelpers.IExtensionChangeHandler#addExtension(org.blueberry.core.runtime.dynamicHelpers.IExtensionTracker,
* org.blueberry.core.runtime.IExtension)
*/
// void addExtension(IExtensionTracker tracker,
// IExtension addedExtension) {
// IConfigurationElement[] addedElements = addedExtension
// .getConfigurationElements();
// for (int i = 0; i < addedElements.length; i++) {
// PerspectiveRegistryReader reader = new PerspectiveRegistryReader(
// this);
// reader.readElement(addedElements[i]);
// }
// }
protected:
/**
* Removes the custom definition of a perspective from the preference store
*
* @param desc
*/
/* package */
void DeleteCustomDefinition(PerspectiveDescriptor::Pointer desc);
/**
* Method hasCustomDefinition.
*
* @param desc
*/
/* package */
bool HasCustomDefinition(PerspectiveDescriptor::ConstPointer desc) const;
private:
/**
* Initialize the preference change listener.
*/
void InitializePreferenceChangeListener();
/**
* @param desc
*/
void Add(PerspectiveDescriptor::Pointer desc);
/**
* Delete a perspective. This will remove perspectives defined in
* extensions.
*
* @param desc
* the perspective to delete
* @since 3.1
*/
void InternalDeletePerspective(PerspectiveDescriptor::Pointer desc);
/**
* Read children from the file system.
*/
void LoadCustom();
/**
* @param status
*/
void UnableToLoadPerspective(const std::string& status);
/**
* Read children from the plugin registry.
*/
void LoadPredefined();
/**
* Verifies the id of the default perspective. If the default perspective is
* invalid use the workbench default.
*/
void VerifyDefaultPerspective();
};
}
#endif /* BERRYPERSPECTIVEREGISTRY_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveRegistryReader.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveRegistryReader.cpp
index 85399ee0f9..49d8e0ef2c 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveRegistryReader.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveRegistryReader.cpp
@@ -1,62 +1,62 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryPerspectiveRegistryReader.h"
#include "berryPerspectiveRegistry.h"
#include "berryWorkbenchPlugin.h"
#include "berryPlatformUI.h"
#include "berryWorkbenchRegistryConstants.h"
namespace berry
{
PerspectiveRegistryReader::PerspectiveRegistryReader()
{
}
void PerspectiveRegistryReader::ReadPerspectives(PerspectiveRegistry* out)
{
registry = out;
this->ReadRegistry(PlatformUI::PLUGIN_ID,
WorkbenchRegistryConstants::PL_PERSPECTIVES);
}
bool PerspectiveRegistryReader::ReadElement(IConfigurationElement::Pointer element)
{
if (element->GetName() == WorkbenchRegistryConstants::TAG_PERSPECTIVE)
{
try
{
std::string id;
element->GetAttribute(WorkbenchRegistryConstants::ATT_ID, id);
PerspectiveDescriptor::Pointer desc(
new PerspectiveDescriptor(id, element));
registry->AddPerspective(desc);
}
catch (CoreException e)
{
// log an error since its not safe to open a dialog here
WorkbenchPlugin::Log("Unable to create layout descriptor.", e);//$NON-NLS-1$
}
return true;
}
return false;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveRegistryReader.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveRegistryReader.h
index 85593bdea9..fed0c1e637 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveRegistryReader.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveRegistryReader.h
@@ -1,64 +1,64 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYPERSPECTIVEREGISTRYREADER_H_
#define BERRYPERSPECTIVEREGISTRYREADER_H_
#include "berryRegistryReader.h"
#include <berryIConfigurationElement.h>
namespace berry {
class PerspectiveRegistry;
/**
* A strategy to read perspective extensions from the registry.
*/
class PerspectiveRegistryReader : public RegistryReader {
private:
PerspectiveRegistry* registry;
public:
/**
* RegistryViewReader constructor comment.
*/
PerspectiveRegistryReader();
/**
* Read the view extensions within a registry.
*
* @param out the perspective registry to use
*/
void ReadPerspectives(PerspectiveRegistry* out);
protected:
/**
* readElement method comment.
*/
// for dynamic UI - change access from protected to public
bool ReadElement(IConfigurationElement::Pointer element);
};
}
#endif /* BERRYPERSPECTIVEREGISTRYREADER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPlaceholderFolderLayout.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPlaceholderFolderLayout.cpp
index 62cea2d1b1..1aa329dd65 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPlaceholderFolderLayout.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPlaceholderFolderLayout.cpp
@@ -1,78 +1,78 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryPlaceholderFolderLayout.h"
namespace berry
{
PlaceholderFolderLayout::PlaceholderFolderLayout(
PageLayout::Pointer pageLayout, ContainerPlaceholder::Pointer folder)
{
this->placeholder = folder;
this->pageLayout = pageLayout;
}
void PlaceholderFolderLayout::AddPlaceholder(const std::string& viewId)
{
if (!pageLayout->CheckValidPlaceholderId(viewId))
{
return;
}
// Create the placeholder.
StackablePart::Pointer newPart(new PartPlaceholder(viewId));
this->LinkPartToPageLayout(viewId, newPart);
// Add it to the placeholder layout.
placeholder->Add(newPart);
}
std::string PlaceholderFolderLayout::GetProperty(const std::string& id)
{
IStackableContainer::Pointer folder = placeholder->GetRealContainer();
if (folder.Cast<PartStack>() != 0)
{
return folder.Cast<PartStack>()->GetProperty(id);
}
//throw not supported?
return "";
}
void PlaceholderFolderLayout::SetProperty(const std::string& id,
const std::string& value)
{
IStackableContainer::Pointer folder = placeholder->GetRealContainer();
if (folder.Cast<PartStack>() != 0)
{
folder.Cast<PartStack>()->SetProperty(id, value);
}
//throw not supported?
}
void PlaceholderFolderLayout::LinkPartToPageLayout(const std::string& viewId,
StackablePart::Pointer newPart)
{
pageLayout->SetRefPart(viewId, newPart);
// force creation of the view layout rec
pageLayout->GetViewLayoutRec(viewId, true);
pageLayout->SetFolderPart(viewId, placeholder);
newPart->SetContainer(placeholder);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPlaceholderFolderLayout.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPlaceholderFolderLayout.h
index 0b31a8b03f..a588a8e07a 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPlaceholderFolderLayout.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPlaceholderFolderLayout.h
@@ -1,84 +1,84 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYPLACEHOLDERFOLDERLAYOUT_H_
#define BERRYPLACEHOLDERFOLDERLAYOUT_H_
#include "berryIPlaceholderFolderLayout.h"
#include "berryStackablePart.h"
#include "berryPageLayout.h"
namespace berry
{
/**
* \ingroup org_blueberry_ui_internal
*
* This layout is used to define the initial set of placeholders
* in a placeholder.
* <p>
* Views are added to the placeholder by ID. This id is used to identify
* a view descriptor in the view registry, and this descriptor is used to
* instantiate the IViewPart.
* </p>
*/
class PlaceholderFolderLayout : public IPlaceholderFolderLayout
{
public:
berryObjectMacro(PlaceholderFolderLayout)
private:
PageLayout::Pointer pageLayout;
ContainerPlaceholder::Pointer placeholder;
public:
PlaceholderFolderLayout(PageLayout::Pointer pageLayout,
ContainerPlaceholder::Pointer folder);
/**
* @see IPlaceholderFolderLayout
*/
void AddPlaceholder(const std::string& viewId);
/* (non-Javadoc)
* @see org.blueberry.ui.IPlaceholderFolderLayout#getProperty(java.lang.String)
*/
std::string GetProperty(const std::string& id);
/* (non-Javadoc)
* @see org.blueberry.ui.IPlaceholderFolderLayout#setProperty(java.lang.String, java.lang.String)
*/
void SetProperty(const std::string& id, const std::string& value);
private:
/**
* Inform the page layout of the new part created
* and the placeholder the part belongs to.
*/
void LinkPartToPageLayout(const std::string& viewId,
StackablePart::Pointer newPart);
};
}
#endif /*BERRYPLACEHOLDERFOLDERLAYOUT_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPreferenceConstants.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPreferenceConstants.cpp
index 015e88aaf3..3d58630e46 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPreferenceConstants.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPreferenceConstants.cpp
@@ -1,64 +1,64 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryPreferenceConstants.h"
namespace berry
{
const std::string PreferenceConstants::OPEN_ON_SINGLE_CLICK = "OPEN_ON_SINGLE_CLICK";
const std::string PreferenceConstants::SELECT_ON_HOVER = "SELECT_ON_HOVER";
const std::string PreferenceConstants::OPEN_AFTER_DELAY = "OPEN_AFTER_DELAY";
const std::string PreferenceConstants::COLOR_ICONS = "COLOR_ICONS";
const std::string PreferenceConstants::EDITORS = "editors";
const std::string PreferenceConstants::RESOURCES = "resourcetypes";
const std::string PreferenceConstants::PERSPECTIVES = "perspectives";
const std::string PreferenceConstants::REUSE_EDITORS = "REUSE_OPEN_EDITORS";
const std::string PreferenceConstants::REUSE_DIRTY_EDITORS = "REUSE_DIRTY_EDITORS";
const std::string PreferenceConstants::REUSE_EDITORS_BOOLEAN = "REUSE_OPEN_EDITORS_BOOLEAN";
const std::string PreferenceConstants::RECENT_FILES = "RECENT_FILES";
const std::string PreferenceConstants::OPEN_VIEW_MODE = "OPEN_VIEW_MODE";
const int PreferenceConstants::OVM_EMBED = 0;
const int PreferenceConstants::OVM_FAST = 1;
const int PreferenceConstants::OVM_FLOAT = 2;
const std::string PreferenceConstants::OPEN_PERSP_MODE = "OPEN_PERSPECTIVE_MODE";
const int PreferenceConstants::OPM_ACTIVE_PAGE = 0;
const int PreferenceConstants::OPM_NEW_WINDOW = 2;
const std::string PreferenceConstants::ENABLED_DECORATORS = "ENABLED_DECORATORS";
const std::string PreferenceConstants::STICKY_CYCLE = "STICKY_CYCLE";
const std::string PreferenceConstants::PLUGINS_NOT_ACTIVATED_ON_STARTUP = "PLUGINS_NOT_ACTIVATED_ON_STARTUP";
const char PreferenceConstants::SEPARATOR = ';';
const std::string PreferenceConstants::DEFAULT_EDITORS = "defaultEditors";
const std::string PreferenceConstants::DEFAULT_EDITORS_CACHE = "defaultEditorsCache";
const std::string PreferenceConstants::EDITOR_TAB_WIDTH = "EDITOR_TAB_WIDTH";
const std::string PreferenceConstants::EDITORLIST_PULLDOWN_ACTIVE = "EDITORLIST_PULLDOWN_ACTIVE";
const std::string PreferenceConstants::EDITORLIST_SELECTION_SCOPE = "EDITORLIST_SELECTION_SCOPE";
const int PreferenceConstants::EDITORLIST_SET_WINDOW_SCOPE = 0;
const int PreferenceConstants::EDITORLIST_SET_PAGE_SCOPE = 1;
const int PreferenceConstants::EDITORLIST_SET_TAB_GROUP_SCOPE = 2;
const std::string PreferenceConstants::EDITORLIST_SORT_CRITERIA = "EDITORLIST_SORT_CRITERIA";
const int PreferenceConstants::EDITORLIST_NAME_SORT = 0;
const int PreferenceConstants::EDITORLIST_MRU_SORT = 1;
const std::string PreferenceConstants::EDITORLIST_DISPLAY_FULL_NAME = "EDITORLIST_DISPLAY_FULL_NAME";
const std::string PreferenceConstants::OVERRIDE_PRESENTATION = "overridepresentation"; //$
const std::string PreferenceConstants::KEYS_PREFERENCE_SELECTED_TAB = "KEYS_PREFERENCE_SELECTED_TAB";
const std::string PreferenceConstants::MULTI_KEY_ASSIST = "MULTI_KEY_ASSIST";
const std::string PreferenceConstants::MULTI_KEY_ASSIST_TIME = "MULTI_KEY_ASSIST_TIME";
const std::string PreferenceConstants::USE_IPERSISTABLE_EDITORS = "USE_IPERSISTABLE_EDITORS";
const std::string PreferenceConstants::RUN_IN_BACKGROUND = "RUN_IN_BACKGROUND";
const std::string PreferenceConstants::SHOULD_PROMPT_FOR_ENABLEMENT = "shouldPromptForEnablement";
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPreferenceConstants.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPreferenceConstants.h
index ef3b750dd1..f7071a7b69 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPreferenceConstants.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPreferenceConstants.h
@@ -1,221 +1,221 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYPREFERENCECONSTANTS_H_
#define BERRYPREFERENCECONSTANTS_H_
#include <string>
namespace berry {
/**
* The PreferenceConstants are the internal constants used by the Workbench.
*/
struct PreferenceConstants {
public:
//Boolean: true; // = single click opens editor; false; // = double click opens it.
static const std::string OPEN_ON_SINGLE_CLICK; // = "OPEN_ON_SINGLE_CLICK";
//Boolean: true; // = select on hover;
static const std::string SELECT_ON_HOVER; // = "SELECT_ON_HOVER";
//Boolean: true; // = open after delay
static const std::string OPEN_AFTER_DELAY; // = "OPEN_AFTER_DELAY";
//Do we show color icons in toolbars?
static const std::string COLOR_ICONS; // = "COLOR_ICONS";
//mappings for type/extension to an editor
const static std::string EDITORS; // = "editors";
const static std::string RESOURCES; // = "resourcetypes";
//saving perspective layouts
const static std::string PERSPECTIVES; // = "perspectives";
// (int) If > 0, an editor will be reused once 'N' editors are opened.
static const std::string REUSE_EDITORS; // = "REUSE_OPEN_EDITORS";
//Boolean: true; // = replace dirty editor if no other editors to reuse
// (prompt for save);
// false; // = open a new editor if no other editors to resuse
static const std::string REUSE_DIRTY_EDITORS; // = "REUSE_DIRTY_EDITORS";
//On/Off option for the two preceding options.
static const std::string REUSE_EDITORS_BOOLEAN; // = "REUSE_OPEN_EDITORS_BOOLEAN";
// (int) N recently viewed files will be listed in the File->Open Recent
// menu.
static const std::string RECENT_FILES; // = "RECENT_FILES";
// (integer) Mode for opening a view.
static const std::string OPEN_VIEW_MODE; // = "OPEN_VIEW_MODE";
static const int OVM_EMBED; // = 0;
static const int OVM_FAST; // = 1;
static const int OVM_FLOAT; // = 2;
// (int) Mode for opening a new perspective
static const std::string OPEN_PERSP_MODE; // = "OPEN_PERSPECTIVE_MODE";
static const int OPM_ACTIVE_PAGE; // = 0;
// static const int OPM_NEW_PAGE; // = 1;
static const int OPM_NEW_WINDOW; // = 2;
//Identifier for enabled decorators
static const std::string ENABLED_DECORATORS; // = "ENABLED_DECORATORS";
//Boolean: true; // = keep cycle part dialog open when keys released
static const std::string STICKY_CYCLE; // = "STICKY_CYCLE";
//List of plugins but that extends "startup" extension point but are
// overriden by the user.
//std::string of plugin unique ids separated by ";"
static const std::string PLUGINS_NOT_ACTIVATED_ON_STARTUP; // = "PLUGINS_NOT_ACTIVATED_ON_STARTUP";
//Separator for PLUGINS_NOT_ACTIVATED_ON_STARTUP
static const char SEPARATOR; // = ';';
//Preference key for default editors
const static std::string DEFAULT_EDITORS; // = "defaultEditors";
//Preference key for default editors
const static std::string DEFAULT_EDITORS_CACHE; // = "defaultEditorsCache";
//Tab width; // = tab height * scalar value
const static std::string EDITOR_TAB_WIDTH; // = "EDITOR_TAB_WIDTH";
//Boolean: true; // = show Editors drop down button on CTabFolder
static const std::string EDITORLIST_PULLDOWN_ACTIVE; // = "EDITORLIST_PULLDOWN_ACTIVE";
// Selection scope for EditorList
static const std::string EDITORLIST_SELECTION_SCOPE; // = "EDITORLIST_SELECTION_SCOPE";
static const int EDITORLIST_SET_WINDOW_SCOPE; // = 0;
static const int EDITORLIST_SET_PAGE_SCOPE; // = 1;
static const int EDITORLIST_SET_TAB_GROUP_SCOPE; // = 2;
// Sort criteria for EditorList
static const std::string EDITORLIST_SORT_CRITERIA; // = "EDITORLIST_SORT_CRITERIA";
static const int EDITORLIST_NAME_SORT; // = 0;
static const int EDITORLIST_MRU_SORT; // = 1;
/**
* Boolean; true; // = EditorList displays full path
*/
static const std::string EDITORLIST_DISPLAY_FULL_NAME; // = "EDITORLIST_DISPLAY_FULL_NAME";
/**
* Workbench preference id for determining whether the user has chosen to
* override some of the settings in the current presentation.
* <p>
* The default value for this preference is: <code>false</code> (prompt)
* </p>
*
* @since 3.2
*/
static const std::string OVERRIDE_PRESENTATION; // = "overridepresentation"; //$
/**
* <p>
* The key for the preference indicating which tab is selected in the keys
* preference page when last okay was pressed. This value should never
* really be directly edited by a user.
* </p>
* <p>
* This preference is an <code>int</code> value. The default value is
* <code>0</code>.
* </p>
*
* @since 3.1
*/
static const std::string KEYS_PREFERENCE_SELECTED_TAB; // = "KEYS_PREFERENCE_SELECTED_TAB";
/**
* <p>
* The key for the preference indicating whether multi-stroke key sequences
* should provide assistance to the user. This means that if the user pauses
* after pressing the first key, a window will open showing the possible
* completions.
* </p>
* <p>
* This preference is a <code>boolean</code> value. The default value is
* <code>false</code>.
* </p>
*
* @since 3.0
*/
static const std::string MULTI_KEY_ASSIST; // = "MULTI_KEY_ASSIST";
/**
* <p>
* The key for the preference indicating how long the assist window should
* wait before opening. This is a value in milliseconds -- from the time the
* first key in a multi-key is received by the system, to the time the
* assist window should appear.
* </p>
* <p>
* This preference is an <code>int</code> value. The default value is
* <code>1000</code>.
* </p>
*
* @since 3.0
*/
static const std::string MULTI_KEY_ASSIST_TIME; // = "MULTI_KEY_ASSIST_TIME";
/**
* Workbench preference to use the new IPersistableEditor interface
* throughout the workbench new editor/open editor calls.
*
* @since 3.3
*/
static const std::string USE_IPERSISTABLE_EDITORS; // = "USE_IPERSISTABLE_EDITORS";
/**
* Preference to show user jobs in a dialog.
*/
static const std::string RUN_IN_BACKGROUND; // = "RUN_IN_BACKGROUND";
/**
* Workbench preference id for determining whether the user will be prompted
* for activity enablement. If this is false then activities are enabled
* automatically. If it is true, then the user is only prompted for
* activities that they have not already declared a disinterest in via the
* prompt dialog.
* <p>
* The default value for this preference is: <code>true</code> (prompt)
* </p>
*
* @since 3.0
*/
static const std::string SHOULD_PROMPT_FOR_ENABLEMENT; // = "shouldPromptForEnablement";
};
}
#endif /* BERRYPREFERENCECONSTANTS_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPresentablePart.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPresentablePart.cpp
index af82411f57..642c8bcafe 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPresentablePart.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPresentablePart.cpp
@@ -1,317 +1,317 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryPresentablePart.h"
#include "berryIWorkbenchPartConstants.h"
#include "berryPartPane.h"
#include "berryWorkbenchPage.h"
#include <berryObjects.h>
namespace berry
{
PresentablePart::
PropertyListenerProxy::PropertyListenerProxy(PresentablePart* p)
: part(p)
{
}
void
PresentablePart::
PropertyListenerProxy::PropertyChange(PropertyChangeEvent::Pointer e)
{
if (e->GetProperty() == IWorkbenchPartConstants::INTEGER_PROPERTY)
{
// these are "part" events
PropertyChangeEvent::Pointer event(new PropertyChangeEvent(Object::Pointer(part), e->GetProperty(),
e->GetOldValue(), e->GetNewValue()));
part->FirePropertyChange(event);
}
else
{
part->FirePropertyChange(e);
}
}
IPropertyChangeListener::Pointer PresentablePart::GetPropertyListenerProxy()
{
if (lazyPropertyListenerProxy == 0)
{
lazyPropertyListenerProxy = new PropertyListenerProxy(this);
}
return lazyPropertyListenerProxy;
}
WorkbenchPartReference::Pointer PresentablePart::GetPartReference() const
{
return part->GetPartReference().Cast<WorkbenchPartReference>();
}
void PresentablePart::FirePropertyChange(PropertyChangeEvent::Pointer event)
{
partPropertyChangeEvents.propertyChange(event);
}
void PresentablePart::FirePropertyChange(int propId)
{
ObjectInt::Pointer val(new ObjectInt(propId));
Object::Pointer source(this);
PropertyChangeEvent::Pointer event(new PropertyChangeEvent(source, IWorkbenchPartConstants::INTEGER_PROPERTY, val, val));
this->FirePropertyChange(event);
}
PresentablePart::PresentablePart(PartPane::Pointer part, void* /*parent*/)
{
enableInputs = true;
enableOutputs = true;
isVisible = false;
isDirty = false;
isBusy = false;
hasViewMenu = false;
this->part = part;
this->GetPane()->AddPropertyListener(this->GetPropertyListenerProxy());
}
PartPane::Pointer PresentablePart::GetPane() const
{
return part;
}
PresentablePart::~PresentablePart()
{
// Ensure that the property listener is detached (necessary to prevent leaks)
this->GetPane()->RemovePropertyListener(this->GetPropertyListenerProxy());
}
void PresentablePart::AddPropertyListener(IPropertyChangeListener::Pointer listener)
{
partPropertyChangeEvents.AddListener(listener);
}
void PresentablePart::RemovePropertyListener(
IPropertyChangeListener::Pointer listener)
{
partPropertyChangeEvents.RemoveListener(listener);
}
void PresentablePart::SetBounds(const Rectangle& bounds)
{
savedBounds = bounds;
if (enableInputs && part != 0)
{
part->SetBounds(bounds);
}
}
void PresentablePart::SetVisible(bool isVisible)
{
this->isVisible = isVisible;
if (enableInputs)
{
part->SetVisible(isVisible);
}
}
void PresentablePart::SetFocus()
{
if (part != 0)
{
if (part->GetPage()->GetActivePart()
== part->GetPartReference()->GetPart(false))
{
part->SetFocus();
}
else
{
part->RequestActivation();
}
}
}
std::string PresentablePart::GetName() const
{
if (enableOutputs)
{
return this->GetPartReference()->GetPartName();
}
return name;
}
std::string PresentablePart::GetTitle() const
{
return this->GetPartReference()->GetPartName();
}
std::string PresentablePart::GetTitleStatus() const
{
if (enableOutputs)
{
return this->GetPartReference()->GetContentDescription();
}
return titleStatus;
}
void* PresentablePart::GetTitleImage()
{
if (enableOutputs)
{
return this->GetPartReference()->GetTitleImage();
}
// return PlatformUI.getWorkbench().getSharedImages().getImage(
// ISharedImages.IMG_DEF_VIEW);
return 0;
}
std::string PresentablePart::GetTitleToolTip() const
{
return this->GetPartReference()->GetTitleToolTip();
}
bool PresentablePart::IsDirty() const
{
if (enableOutputs)
{
return this->GetPartReference()->IsDirty();
}
return isDirty;
}
bool PresentablePart::IsBusy() const
{
if (enableOutputs)
{
return part->IsBusy();
}
return isBusy;
}
void* PresentablePart::GetToolBar()
{
if (enableOutputs)
{
return this->GetPane()->GetToolBar();
}
return 0;
}
bool PresentablePart::IsCloseable() const
{
return part->IsCloseable();
}
void* PresentablePart::GetControl()
{
return part->GetControl();
}
void PresentablePart::EnableOutputs(bool isActive)
{
if (isActive == this->enableOutputs)
{
return;
}
this->enableOutputs = isActive;
if (isActive)
{
if (isBusy != this->GetPane()->IsBusy())
{
this->FirePropertyChange(PROP_BUSY);
}
if (isDirty != this->IsDirty())
{
this->FirePropertyChange(PROP_DIRTY);
}
if (name != this->GetName())
{
this->FirePropertyChange(PROP_PART_NAME);
}
if (titleStatus != this->GetTitleStatus())
{
this->FirePropertyChange(PROP_CONTENT_DESCRIPTION);
}
if (hasViewMenu != this->GetPane()->HasViewMenu())
{
this->FirePropertyChange(PROP_PANE_MENU);
}
// Always assume that the toolbar and title has changed (keeping track of this for real
// would be too expensive)
this->FirePropertyChange(PROP_TOOLBAR);
this->FirePropertyChange(PROP_TITLE);
this->GetPane()->AddPropertyListener(this->GetPropertyListenerProxy());
}
else
{
this->GetPane()->RemovePropertyListener(this->GetPropertyListenerProxy());
WorkbenchPartReference::Pointer ref = this->GetPartReference();
isBusy = this->GetPane()->IsBusy();
isDirty = ref->IsDirty();
name = ref->GetPartName();
titleStatus = ref->GetContentDescription();
hasViewMenu = this->GetPane()->HasViewMenu();
this->FirePropertyChange(PROP_TITLE);
this->FirePropertyChange(PROP_TOOLBAR);
}
}
void PresentablePart::EnableInputs(bool isActive)
{
if (isActive == this->enableInputs)
{
return;
}
this->enableInputs = isActive;
if (isActive)
{
if (isActive && part != 0)
{
part->SetBounds(savedBounds);
}
part->SetVisible(isVisible);
}
}
std::string PresentablePart::GetPartProperty(const std::string& key) const
{
return this->GetPartReference()->GetPartProperty(key);
}
int PresentablePart::ComputePreferredSize(bool width, int availableParallel,
int availablePerpendicular, int preferredResult)
{
return this->GetPane()->ComputePreferredSize(width, availableParallel,
availablePerpendicular, preferredResult);
}
int PresentablePart::GetSizeFlags(bool width)
{
return this->GetPane()->GetSizeFlags(width);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPresentablePart.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPresentablePart.h
index 244d217e9c..5dca32abc0 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPresentablePart.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPresentablePart.h
@@ -1,265 +1,265 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYPRESENTABLEPART_H_
#define BERRYPRESENTABLEPART_H_
#include "presentations/berryIPresentablePart.h"
#include "berryWorkbenchPartReference.h"
namespace berry
{
class PartPane;
/**
* This is a lightweight adapter that allows PartPanes to be used by a StackPresentation. All methods
* either redirect directly to PartPane or do trivial type conversions. All listeners registered by
* the presentation are kept here rather than registering them directly on the PartPane. This allows
* us to remove all listeners registered by a presentation that has been disposed, offering some
* protection against memory leaks.
*/
class PresentablePart: public IPresentablePart
{
public:
berryObjectMacro(PresentablePart);
private:
SmartPointer<PartPane> part;
/**
* Local listener list -- we use this rather than registering listeners directly on the part
* in order to protect against memory leaks in badly behaved presentations.
*/
//List listeners = new ArrayList();
// Lazily initialized. Use getPropertyListenerProxy() to access.
IPropertyChangeListener::Pointer lazyPropertyListenerProxy;
//ListenerList partPropertyChangeListeners = new ListenerList();
IPropertyChangeListener::Events partPropertyChangeEvents;
//IPropertyChangeListener::Pointer lazyPartPropertyChangeListener;
// Lazily initialized. Use getMenu() to access
//IPartMenu viewMenu;
// True iff the "set" methods on this object are talking to the real part (disabled
// if the part is currently being managed by another presentation stack)
bool enableInputs;
// True iff the "get" methods are returning up-to-date info from the real part (disabled
// for efficiency if the presentation is invisible)
bool enableOutputs;
Rectangle savedBounds;
bool isVisible;
// Saved state (only used when the part is inactive)
std::string name;
std::string titleStatus;
bool isDirty;
bool isBusy;
bool hasViewMenu;
struct PropertyListenerProxy: public IPropertyChangeListener
{
PropertyListenerProxy(PresentablePart* part);
void PropertyChange(PropertyChangeEvent::Pointer e);
private:
PresentablePart* part;
};
friend struct PropertyListenerProxy;
IPropertyChangeListener::Pointer GetPropertyListenerProxy();
WorkbenchPartReference::Pointer GetPartReference() const;
protected:
void FirePropertyChange(int propId);
void FirePropertyChange(PropertyChangeEvent::Pointer event);
public:
/**
* Constructor
*
* @param part
*/
PresentablePart(SmartPointer<PartPane> part, void* parent);
SmartPointer<PartPane> GetPane() const;
/**
* Detach this PresentablePart from the real part. No further methods should
* be invoked on this object.
*/
~PresentablePart();
// void firePropertyChange(int propertyId) {
// for (int i = 0; i < listeners.size(); i++) {
// ((IPropertyListener) listeners.get(i)).propertyChanged(this, propertyId);
// }
// }
void AddPropertyListener(IPropertyChangeListener::Pointer listener);
void RemovePropertyListener(IPropertyChangeListener::Pointer listener);
// void addPartPropertyListener(IPropertyChangeListener listener) {
// partPropertyChangeListeners.add(listener);
// }
//
// void removePartPropertyListener(IPropertyChangeListener listener) {
// partPropertyChangeListeners.remove(listener);
// }
/* (non-Javadoc)
* @see org.blueberry.ui.presentations.IPresentablePart#setBounds(org.blueberry.swt.graphics.Rectangle)
*/
void SetBounds(const Rectangle& bounds);
/* (non-Javadoc)
* @see org.blueberry.ui.presentations.IPresentablePart#setVisible(boolean)
*/
void SetVisible(bool isVisible);
/* (non-Javadoc)
* @see org.blueberry.ui.presentations.IPresentablePart#setFocus()
*/
void SetFocus();
/* (non-Javadoc)
* @see org.blueberry.ui.presentations.IPresentablePart#getName()
*/
std::string GetName() const;
/* (non-Javadoc)
* @see org.blueberry.ui.presentations.IPresentablePart#getTitle()
*/
std::string GetTitle() const;
/* (non-Javadoc)
* @see org.blueberry.ui.presentations.IPresentablePart#getTitleStatus()
*/
std::string GetTitleStatus() const;
/*
* (non-Javadoc)
*
* @see org.blueberry.ui.presentations.IPresentablePart#getTitleImage()
*/
void* GetTitleImage();
/*
* (non-Javadoc)
*
* @see org.blueberry.ui.presentations.IPresentablePart#getTitleToolTip()
*/
std::string GetTitleToolTip() const;
/* (non-Javadoc)
* @see org.blueberry.ui.presentations.IPresentablePart#isDirty()
*/
bool IsDirty() const;
/*
* (non-Javadoc)
*
* @see org.blueberry.ui.presentations.IPresentablePart#isBusy()
*/
bool IsBusy() const;
/*
* (non-Javadoc)
*
* @see org.blueberry.ui.presentations.IPresentablePart#getToolBar()
*/
void* GetToolBar();
/*
* (non-Javadoc)
*
* @see org.blueberry.ui.presentations.IPresentablePart#getMenu()
*/
// IPartMenu getMenu() {
// boolean hasMenu;
//
// if (enableOutputs) {
// hasMenu = part.hasViewMenu();
// } else {
// hasMenu = this.hasViewMenu;
// }
//
// if (!hasMenu) {
// return null;
// }
//
// if (viewMenu == null) {
// viewMenu = new IPartMenu() {
// public void showMenu(Point location) {
// part.showViewMenu(location);
// }
// };
// }
//
// return viewMenu;
// }
/* (non-Javadoc)
* @see org.blueberry.ui.presentations.IPresentablePart#isCloseable()
*/
bool IsCloseable() const;
/* (non-Javadoc)
* @see org.blueberry.ui.presentations.IPresentablePart#getControl()
*/
void* GetControl();
void EnableOutputs(bool isActive);
void EnableInputs(bool isActive);
/* (non-Javadoc)
* @see org.blueberry.ui.presentations.IPresentablePart#getPartProperty(java.lang.String)
*/
std::string GetPartProperty(const std::string& key) const;
/* (non-Javadoc)
* @see org.blueberry.ui.ISizeProvider#computePreferredSize(boolean, int, int, int)
*/
int ComputePreferredSize(bool width, int availableParallel,
int availablePerpendicular, int preferredResult);
/* (non-Javadoc)
* @see org.blueberry.ui.ISizeProvider#getSizeFlags(boolean)
*/
int GetSizeFlags(bool width);
};
}
#endif /* BERRYPRESENTABLEPART_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPresentationFactoryUtil.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPresentationFactoryUtil.cpp
index 55647385dc..99f4e74aed 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPresentationFactoryUtil.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPresentationFactoryUtil.cpp
@@ -1,69 +1,69 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryPresentationFactoryUtil.h"
namespace berry
{
const int PresentationFactoryUtil::ROLE_EDITOR = 0x01;
const int PresentationFactoryUtil::ROLE_VIEW = 0x02;
const int PresentationFactoryUtil::ROLE_STANDALONE = 0x03;
const int PresentationFactoryUtil::ROLE_STANDALONE_NOTITLE = 0x04;
StackPresentation::Pointer PresentationFactoryUtil::CreatePresentation(
IPresentationFactory* factory, int role, void* parent,
IStackPresentationSite::Pointer site, IPresentationSerializer* serializer,
IMemento::Pointer memento)
{
StackPresentation::Pointer presentation;
switch (role)
{
case ROLE_EDITOR:
presentation = factory->CreateEditorPresentation(parent, site);
break;
case ROLE_STANDALONE:
presentation
= factory->CreateStandaloneViewPresentation(parent, site, true);
break;
case ROLE_STANDALONE_NOTITLE:
presentation = factory->CreateStandaloneViewPresentation(parent, site,
false);
break;
default:
presentation = factory->CreateViewPresentation(parent, site);
}
//don't initialize editors at creation time - it will not contain any parts
if (role != ROLE_EDITOR && memento != 0 && serializer != 0)
{
presentation->RestoreState(serializer, memento);
}
return presentation;
}
PresentationFactoryUtil::PresentationFactoryUtil()
{
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPresentationFactoryUtil.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPresentationFactoryUtil.h
index 0734b9420e..e242305fae 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPresentationFactoryUtil.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPresentationFactoryUtil.h
@@ -1,53 +1,53 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYPRESENTATIONFACTORYUTIL_H_
#define BERRYPRESENTATIONFACTORYUTIL_H_
#include "presentations/berryIPresentationFactory.h"
#include "presentations/berryIStackPresentationSite.h"
#include "presentations/berryIPresentationSerializer.h"
namespace berry
{
class PresentationFactoryUtil
{
public:
static const int ROLE_EDITOR; // = 0x01;
static const int ROLE_VIEW; // = 0x02;
static const int ROLE_STANDALONE; // = 0x03;
static const int ROLE_STANDALONE_NOTITLE; // = 0x04;
static StackPresentation::Pointer CreatePresentation(
IPresentationFactory* factory, int role, void* parent,
IStackPresentationSite::Pointer site,
IPresentationSerializer* serializer, IMemento::Pointer memento);
private:
PresentationFactoryUtil();
};
}
#endif /* BERRYPRESENTATIONFACTORYUTIL_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPresentationSerializer.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPresentationSerializer.cpp
index 8962147c41..0ba5ab05de 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPresentationSerializer.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPresentationSerializer.cpp
@@ -1,61 +1,61 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryPresentationSerializer.h"
#include <Poco/NumberParser.h>
#include <algorithm>
#include <sstream>
namespace berry
{
PresentationSerializer::PresentationSerializer(
const std::vector<IPresentablePart::Pointer>& presentableParts) :
parts(presentableParts)
{
}
std::string PresentationSerializer::GetId(IPresentablePart::Pointer part)
{
std::size_t index = std::find(parts.begin(), parts.end(), part) - parts.begin();
std::stringstream ssId;
ssId << index;
return ssId.str();
}
IPresentablePart::Pointer PresentationSerializer::GetPart(const std::string& id)
{
try
{
unsigned int index = Poco::NumberParser::parseUnsigned(id);
IPresentablePart::Pointer result;
if (index < parts.size())
result = parts[index];
return result;
} catch (Poco::SyntaxException& /*e*/)
{
}
return IPresentablePart::Pointer(0);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPresentationSerializer.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPresentationSerializer.h
index 04f6f1169d..7bfdb59916 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPresentationSerializer.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPresentationSerializer.h
@@ -1,57 +1,57 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYPRESENTATIONSERIALIZER_H_
#define BERRYPRESENTATIONSERIALIZER_H_
#include "presentations/berryIPresentationSerializer.h"
#include "presentations/berryIPresentablePart.h"
#include <vector>
namespace berry
{
/**
* This class is used to map IPresentableParts onto string IDs
*/
class PresentationSerializer: public IPresentationSerializer
{
private:
std::vector<IPresentablePart::Pointer> parts;
public:
PresentationSerializer(
const std::vector<IPresentablePart::Pointer>& presentableParts);
/* (non-Javadoc)
* @see org.blueberry.ui.presentations.IPresentationSerializer#getId(org.blueberry.ui.presentations.IPresentablePart)
*/
std::string GetId(IPresentablePart::Pointer part);
/* (non-Javadoc)
* @see org.blueberry.ui.presentations.IPresentationSerializer#getPart(java.lang.String)
*/
IPresentablePart::Pointer GetPart(const std::string& id);
};
}
#endif /* BERRYPRESENTATIONSERIALIZER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryQtControlWidget.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryQtControlWidget.cpp
index 387e24d153..8e60efb8e4 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryQtControlWidget.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryQtControlWidget.cpp
@@ -1,161 +1,161 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryLog.h"
#include "berryQtControlWidget.h"
#include <berryShell.h>
#include <QMoveEvent>
#include <QResizeEvent>
#include <algorithm>
namespace berry {
QtControlWidget::QtControlWidget(QWidget* parent, Shell* shell, Qt::WindowFlags f)
: QFrame(parent, f)
{
controller = new QtWidgetController(shell);
this->setFrameStyle(QFrame::NoFrame);
// TODO WeakPointer: QVariant should hold a weak pointer
QVariant variant(QVariant::UserType);
variant.setValue(controller);
this->setProperty(QtWidgetController::PROPERTY_ID, variant);
}
QtControlWidget::~QtControlWidget()
{
GuiTk::ControlEvent::Pointer controlEvent(new GuiTk::ControlEvent(static_cast<QWidget*>(this)));
controller->controlEvents.destroyedEvent(controlEvent);
}
void QtControlWidget::changeEvent(QEvent* event)
{
typedef IShellListener::Events::ShellEventType::ListenerList ListenerList;
switch (event->type())
{
case QEvent::WindowActivate:
{
ShellEvent::Pointer shellEvent(new ShellEvent(Shell::Pointer(controller->shell)));
ListenerList activatedListeners(controller->shellEvents.shellActivated.GetListeners());
for (ListenerList::iterator listener = activatedListeners.begin();
listener != activatedListeners.end(); ++listener)
{
(*listener)->Execute(shellEvent);
if (!shellEvent->doit) {
event->accept();
return;
}
}
}
break;
case QEvent::WindowDeactivate:
{
ShellEvent::Pointer shellEvent(new ShellEvent(Shell::Pointer(controller->shell)));
ListenerList deactivatedListeners(controller->shellEvents.shellDeactivated.GetListeners());
for (ListenerList::iterator listener = deactivatedListeners.begin();
listener != deactivatedListeners.end(); ++listener)
{
(*listener)->Execute(shellEvent);
if (!shellEvent->doit) {
event->accept();
return;
}
}
}
break;
case QEvent::WindowStateChange:
{
ShellEvent::Pointer shellEvent(new ShellEvent(Shell::Pointer(controller->shell)));
QWindowStateChangeEvent* stateEvent = dynamic_cast<QWindowStateChangeEvent*>(event);
Qt::WindowStates oldState = stateEvent->oldState();
if (this->isMinimized() && !(oldState & Qt::WindowMinimized))
{
ListenerList iconifiedListeners(controller->shellEvents.shellIconified.GetListeners());
for (ListenerList::iterator listener = iconifiedListeners.begin();
listener != iconifiedListeners.end(); ++listener)
{
(*listener)->Execute(shellEvent);
if (!shellEvent->doit) {
event->accept();
return;
}
}
}
else if (oldState & Qt::WindowMinimized && !this->isMinimized())
{
ListenerList deiconifiedListeners(controller->shellEvents.shellDeiconified.GetListeners());
for (ListenerList::iterator listener = deiconifiedListeners.begin();
listener != deiconifiedListeners.end(); ++listener)
{
(*listener)->Execute(shellEvent);
if (!shellEvent->doit) return;
}
}
}
break;
default:
break;
}
QFrame::changeEvent(event);
}
void QtControlWidget::closeEvent(QCloseEvent* event)
{
typedef IShellListener::Events::ShellEventType::ListenerList ListenerList;
ShellEvent::Pointer shellEvent(new ShellEvent(Shell::Pointer(controller->shell)));
ListenerList closedListeners(controller->shellEvents.shellClosed.GetListeners());
for (ListenerList::iterator listener = closedListeners.begin();
listener != closedListeners.end(); ++listener)
{
(*listener)->Execute(shellEvent);
if (!shellEvent->doit) {
//event->accept();
return;
}
}
event->accept();
}
void QtControlWidget::moveEvent(QMoveEvent* event)
{
GuiTk::ControlEvent::Pointer controlEvent(new GuiTk::ControlEvent(static_cast<QWidget*>(this), event->pos().x(), event->pos().y()));
controller->controlEvents.movedEvent(controlEvent);
}
void QtControlWidget::resizeEvent(QResizeEvent* event)
{
GuiTk::ControlEvent::Pointer controlEvent(new GuiTk::ControlEvent(static_cast<QWidget*>(this), 0, 0, event->size().width(), event->size().height()));
controller->controlEvents.resizedEvent(controlEvent);
}
void QtControlWidget::FireActivateEvent()
{
GuiTk::ControlEvent::Pointer controlEvent(new GuiTk::ControlEvent(static_cast<QWidget*>(this)));
controller->controlEvents.activatedEvent(controlEvent);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryQtControlWidget.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryQtControlWidget.h
index 3fc4fa98ae..a987af0821 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryQtControlWidget.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryQtControlWidget.h
@@ -1,58 +1,58 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYQTCONTROLWIDGET_H_
#define BERRYQTCONTROLWIDGET_H_
#include <QFrame>
#include "berryQtWidgetController.h"
#include <org_blueberry_ui_Export.h>
namespace berry {
class BERRY_UI QtControlWidget : public QFrame
{
public:
QtControlWidget(QWidget* parent, Shell* shell, Qt::WindowFlags f = 0);
~QtControlWidget();
void FireActivateEvent();
protected:
// used for shell listeners
void changeEvent(QEvent* event);
void closeEvent(QCloseEvent* closeEvent);
// used for control listeners
void moveEvent(QMoveEvent* event);
void resizeEvent(QResizeEvent* event);
private:
QtWidgetController::Pointer controller;
};
}
#endif /* BERRYQTCONTROLWIDGET_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryQtDnDControlWidget.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryQtDnDControlWidget.cpp
index d45d8a5072..0f1b65a984 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryQtDnDControlWidget.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryQtDnDControlWidget.cpp
@@ -1,84 +1,84 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryShell.h"
#include "berryQtDnDControlWidget.h"
#include <QDragEnterEvent>
#include <QDragMoveEvent>
#include <QDragLeaveEvent>
#include <QDropEvent>
namespace berry {
QtDnDControlWidget::QtDnDControlWidget(QWidget* parent)
: QtControlWidget(parent, 0)
{
}
void QtDnDControlWidget::SetTransferTypes(const QStringList& types)
{
transferTypes = types;
if (types.isEmpty())
{
this->setAcceptDrops(false);
}
else
{
this->setAcceptDrops(true);
}
}
void QtDnDControlWidget::AddDropListener(IDropTargetListener* listener)
{
dndEvents.AddListener(listener);
}
void QtDnDControlWidget::RemoveDropListener(IDropTargetListener* listener)
{
dndEvents.RemoveListener(listener);
}
void QtDnDControlWidget::dragEnterEvent(QDragEnterEvent* event)
{
foreach (QString type, transferTypes)
{
if (event->mimeData()->hasFormat(type))
{
event->acceptProposedAction();
dndEvents.dragEnter(event);
break;
}
}
}
void QtDnDControlWidget::dragMoveEvent(QDragMoveEvent* event)
{
dndEvents.dragMove(event);
}
void QtDnDControlWidget::dragLeaveEvent(QDragLeaveEvent* event)
{
dndEvents.dragLeave(event);
}
void QtDnDControlWidget::dropEvent(QDropEvent* event)
{
dndEvents.drop(event);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryQtDnDControlWidget.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryQtDnDControlWidget.h
index b4b865adb9..763f5a80a8 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryQtDnDControlWidget.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryQtDnDControlWidget.h
@@ -1,54 +1,54 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYQTDNDCONTROLWIDGET_H
#define BERRYQTDNDCONTROLWIDGET_H
#include "berryQtControlWidget.h"
#include "berryIDropTargetListener.h"
#include <QMimeData>
namespace berry {
class QtDnDControlWidget : public QtControlWidget
{
public:
QtDnDControlWidget(QWidget *parent = 0);
void SetTransferTypes(const QStringList& types);
void AddDropListener(IDropTargetListener* listener);
void RemoveDropListener(IDropTargetListener* listener);
protected:
void dragEnterEvent(QDragEnterEvent* event);
void dragMoveEvent(QDragMoveEvent* event);
void dragLeaveEvent(QDragLeaveEvent* event);
void dropEvent(QDropEvent* event);
private:
IDropTargetListener::Events dndEvents;
QStringList transferTypes;
};
}
#endif // BERRYQTDNDCONTROLWIDGET_H
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryQtWidgetController.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryQtWidgetController.cpp
index a05e7b4d98..2aa360ff04 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryQtWidgetController.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryQtWidgetController.cpp
@@ -1,76 +1,76 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryQtWidgetController.h"
#include <berryShell.h>
namespace berry {
const char QtWidgetController::PROPERTY_ID[] = "QtWidgetController_property";
QtWidgetController::QtWidgetController(Shell* shell)
: shell(shell)
{
if (shell)
{
// Normally, a Shell outlives a QtWidgetController, but
// in QtWorkbenchWindow::~QtWorkbenchWindow the main widget is
// deleted via widget->deleteLater() and hence an instance of this
// class could still be alive when the Shell is deleted
shell->AddDestroyListener(MessageDelegate<QtWidgetController>(this, &QtWidgetController::ShellDestroyed));
}
}
QtWidgetController::~QtWidgetController()
{
if (shell)
{
shell->RemoveDestroyListener(MessageDelegate<QtWidgetController>(this, &QtWidgetController::ShellDestroyed));
}
}
Shell::Pointer QtWidgetController::GetShell()
{
return Shell::Pointer(shell);
}
void QtWidgetController::ShellDestroyed()
{
shell = 0;
}
void QtWidgetController::AddControlListener(GuiTk::IControlListener::Pointer listener)
{
controlEvents.AddListener(listener);
}
void QtWidgetController::RemoveControlListener(GuiTk::IControlListener::Pointer listener)
{
controlEvents.RemoveListener(listener);
}
void QtWidgetController::AddShellListener(IShellListener::Pointer listener)
{
shellEvents.AddListener(listener);
}
void QtWidgetController::RemoveShellListener(IShellListener::Pointer listener)
{
shellEvents.RemoveListener(listener);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryQtWidgetController.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryQtWidgetController.h
index a5cec42bc1..d271943143 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryQtWidgetController.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryQtWidgetController.h
@@ -1,72 +1,72 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIQTCONTROLWIDGET_H_
#define BERRYIQTCONTROLWIDGET_H_
#include <berryGuiTkIControlListener.h>
#include <berryIShellListener.h>
#include <QMetaType>
#include <org_blueberry_ui_Export.h>
namespace berry {
class Shell;
class BERRY_UI QtWidgetController : public Object
{
public:
berryObjectMacro(QtWidgetController)
static const char PROPERTY_ID[];
QtWidgetController(Shell* shell);
~QtWidgetController();
void AddControlListener(GuiTk::IControlListener::Pointer listener);
void RemoveControlListener(GuiTk::IControlListener::Pointer listener);
void AddShellListener(IShellListener::Pointer listener);
void RemoveShellListener(IShellListener::Pointer listener);
SmartPointer<Shell> GetShell();
protected:
friend class QtControlWidget;
friend class QtMainWindowControl;
GuiTk::IControlListener::Events controlEvents;
IShellListener::Events shellEvents;
void ShellDestroyed();
Shell* shell;
};
}
//TODO WeakPointer: register a weak pointer as metatype
Q_DECLARE_METATYPE(berry::QtWidgetController::Pointer)
#endif /* BERRYIQTCONTROLWIDGET_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryReferenceCounter.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryReferenceCounter.h
index 7c3a9a0cb7..f7610ed2f9 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryReferenceCounter.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryReferenceCounter.h
@@ -1,225 +1,225 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYREFERENCECOUNTER_H_
#define BERRYREFERENCECOUNTER_H_
#include <map>
#include <vector>
namespace berry
{
/**
* \ingroup org_blueberry_ui_internal
*
* A ReferenceCounter is used to reference counting objects.
* Each object is identified by a unique ID. Together they form
* an ID - value pair. An object is added to the counter by calling
* #put(id, object). From this point on additional refs can be made
* by calling #addRef(id) or #removeRef(id).
*/
template<class I, class V> class ReferenceCounter
{
/**
* Capture the information about an object.
*/
public:
class RefRec
{
public:
RefRec() :
m_RefCount(0)
{
}
RefRec(I id, V value) : m_Id(id), m_Value(value), m_RefCount(0)
{
AddRef();
}
I GetId()
{
return m_Id;
}
V GetValue()
{
return m_Value;
}
int AddRef()
{
++m_RefCount;
return m_RefCount;
}
int RemoveRef()
{
--m_RefCount;
return m_RefCount;
}
int GetRef()
{
return m_RefCount;
}
bool IsNotReferenced()
{
return (m_RefCount <= 0);
}
I m_Id;
V m_Value;
private:
int m_RefCount;
};
private:
std::map<I, RefRec> mapIdToRec;
public:
/**
* Creates a new counter.
*/
ReferenceCounter()
{
}
/**
* Adds one reference to an object in the counter.
*
* @param id is a unique ID for the object.
* @return the new ref count
*/
int AddRef(I id)
{
typename std::map<I, RefRec>::iterator rec = mapIdToRec.find(id);
if (rec == mapIdToRec.end())
{
return 0;
}
return rec->second.AddRef();
}
/**
* Returns the object defined by an ID. If the ID is not
* found <code>null</code> is returned.
*
* @return the object or <code>null</code>
*/
V Get(I id)
{
typename std::map<I, RefRec>::iterator rec = mapIdToRec.find(id);
if (rec == mapIdToRec.end())
{
return V();
}
return rec->second.GetValue();
}
/**
* Returns a complete list of the keys in the counter.
*
* @return a Set containing the ID for each.
*/
std::vector<I> KeyVector()
{
std::vector<I> keys;
for (typename std::map<I, RefRec>::iterator iter = mapIdToRec.begin(); iter
!= mapIdToRec.end(); ++iter)
{
keys.push_back(iter->first);
}
return keys;
}
/**
* Adds an object to the counter for counting and gives
* it an initial ref count of 1.
*
* @param id is a unique ID for the object.
* @param value is the object itself.
*/
void Put(I id, V value)
{
RefRec rec(id, value);
mapIdToRec[id] = rec;
}
/**
* @param id is a unique ID for the object.
* @return the current ref count
*/
int GetRef(I id)
{
RefRec rec = mapIdToRec[id];
return rec.GetRef();
}
/**
* Removes one reference from an object in the counter.
* If the ref count drops to 0 the object is removed from
* the counter completely.
*
* @param id is a unique ID for the object.
* @return the new ref count
*/
int RemoveRef(I id)
{
RefRec rec = mapIdToRec[id];
if (rec.GetRef() == 0)
{
return 0;
}
int newCount = rec.RemoveRef();
if (newCount <= 0)
{
mapIdToRec.erase(id);
}
return newCount;
}
/**
* Returns a complete list of the values in the counter.
*
* @return a Collection containing the values.
*/
std::vector<V> Values()
{
std::vector<V> values;
for (typename std::map<I, RefRec>::iterator iter = mapIdToRec.begin(); iter
!= mapIdToRec.end(); ++iter)
{
values.push_back(iter->second.GetValue());
}
return values;
}
};
}
#endif /*BERRYREFERENCECOUNTER_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryRegistryReader.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryRegistryReader.cpp
index c9b46b10c8..20dc993af2 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryRegistryReader.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryRegistryReader.cpp
@@ -1,151 +1,151 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 <berryIExtensionPointService.h>
#include "berryRegistryReader.h"
#include "berryWorkbenchPlugin.h"
#include "berryWorkbenchRegistryConstants.h"
#include "berryImageDescriptor.h"
namespace berry
{
RegistryReader::RegistryReader()
{
}
RegistryReader::~RegistryReader()
{
}
void RegistryReader::LogError(IConfigurationElement::Pointer element,
const std::string& text)
{
const IExtension* extension = element->GetDeclaringExtension();
std::string buf = "Plugin " + extension->GetNamespace() + ", extension "
+ extension->GetExtensionPointIdentifier();
// look for an ID if available - this should help debugging
std::string id;
if (element->GetAttribute("id", id))
{
buf.append(", id ");
buf.append(id);
}
buf.append(": " + text);
WorkbenchPlugin::Log(buf);
}
void RegistryReader::LogMissingAttribute(
IConfigurationElement::Pointer element, const std::string& attributeName)
{
RegistryReader::LogError(element, "Required attribute '" + attributeName + "' not defined");//$NON-NLS-2$//$NON-NLS-1$
}
void RegistryReader::LogMissingElement(
IConfigurationElement::Pointer element, const std::string& elementName)
{
RegistryReader::LogError(element, "Required sub element '" + elementName + "' not defined");//$NON-NLS-2$//$NON-NLS-1$
}
void RegistryReader::LogUnknownElement(
IConfigurationElement::Pointer element)
{
RegistryReader::LogError(element, "Unknown extension tag found: " + element->GetName());//$NON-NLS-1$
}
const std::vector<const IExtension*> RegistryReader::OrderExtensions(
const std::vector<const IExtension*>& extensions)
{
// By default, the order is based on plugin id sorted
// in ascending order. The order for a plugin providing
// more than one extension for an extension point is
// dependent in the order listed in the XML file.
std::vector<const IExtension*> sortedExtension(extensions);
std::stable_sort(sortedExtension.begin(), sortedExtension.end());
return sortedExtension;
}
void RegistryReader::ReadElementChildren(
IConfigurationElement::Pointer element)
{
this->ReadElements(element->GetChildren());
}
void RegistryReader::ReadElements(
const std::vector<IConfigurationElement::Pointer>& elements)
{
for (unsigned int i = 0; i < elements.size(); i++)
{
if (!this->ReadElement(elements[i]))
{
RegistryReader::LogUnknownElement(elements[i]);
}
}
}
void RegistryReader::ReadExtension(const IExtension* extension)
{
this->ReadElements(extension->GetConfigurationElements());
}
void RegistryReader::ReadRegistry(
const std::string& pluginId, const std::string& extensionPoint)
{
const IExtensionPoint* point = Platform::GetExtensionPointService()->GetExtensionPoint(pluginId + "." + extensionPoint);
if (point == 0)
{
return;
}
std::vector<const IExtension*> extensions(point->GetExtensions());
extensions = this->OrderExtensions(extensions);
for (unsigned int i = 0; i < extensions.size(); i++)
{
this->ReadExtension(extensions[i]);
}
}
std::string RegistryReader::GetDescription(IConfigurationElement::Pointer configElement)
{
IConfigurationElement::vector children(configElement->GetChildren(WorkbenchRegistryConstants::TAG_DESCRIPTION));
if (children.size() >= 1)
{
return children[0]->GetValue();
}
return "";//$NON-NLS-1$
}
std::string RegistryReader::GetClassValue(
IConfigurationElement::Pointer configElement,
const std::string& classAttributeName)
{
std::string className;
if (configElement->GetAttribute(classAttributeName, className))
{
return className;
}
IConfigurationElement::vector candidateChildren(configElement->GetChildren(classAttributeName));
if (candidateChildren.size() == 0)
{
return "";
}
candidateChildren[0]->GetAttribute(WorkbenchRegistryConstants::ATT_CLASS, className);
return className;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryRegistryReader.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryRegistryReader.h
index d11c361e21..f380ce618b 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryRegistryReader.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryRegistryReader.h
@@ -1,163 +1,163 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYREGISTRYREADER_H_
#define BERRYREGISTRYREADER_H_
#include "service/berryIConfigurationElement.h"
#include "service/berryIExtension.h"
namespace berry {
/**
* \ingroup org_blueberry_ui_internal
*
* Template implementation of a registry reader that creates objects
* representing registry contents. Typically, an extension
* contains one element, but this reader handles multiple
* elements per extension.
*
* To start reading the extensions from the registry for an
* extension point, call the method <code>readRegistry</code>.
*
* To read children of an IConfigurationElement, call the
* method <code>readElementChildren</code> from your implementation
* of the method <code>readElement</code>, as it will not be
* done by default.
*/
class RegistryReader {
// for dynamic UI - remove this cache to avoid inconsistency
//protected static Hashtable extensionPoints = new Hashtable();
/**
* The constructor.
*/
protected:
RegistryReader();
virtual ~RegistryReader();
/**
* Logs the error in the workbench log using the provided
* text and the information in the configuration element.
*/
static void LogError(IConfigurationElement::Pointer element, const std::string& text);
/**
* Logs a very common registry error when a required attribute is missing.
*/
static void LogMissingAttribute(IConfigurationElement::Pointer element,
const std::string& attributeName);
/**
* Logs a very common registry error when a required child is missing.
*/
static void LogMissingElement(IConfigurationElement::Pointer element,
const std::string& elementName);
/**
* Logs a registry error when the configuration element is unknown.
*/
static void LogUnknownElement(IConfigurationElement::Pointer element);
public:
/**
* Apply a reproducable order to the list of extensions
* provided, such that the order will not change as
* extensions are added or removed.
* @param extensions the extensions to order
* @return ordered extensions
*/
static const std::vector<const IExtension*> OrderExtensions(const std::vector<const IExtension*>& extensions);
protected:
/**
* Implement this method to read element's attributes.
* If children should also be read, then implementor
* is responsible for calling <code>readElementChildren</code>.
* Implementor is also responsible for logging missing
* attributes.
*
* @return true if element was recognized, false if not.
*/
virtual bool ReadElement(IConfigurationElement::Pointer element) = 0;
/**
* Read the element's children. This is called by
* the subclass' readElement method when it wants
* to read the children of the element.
*/
virtual void ReadElementChildren(IConfigurationElement::Pointer element);
/**
* Read each element one at a time by calling the
* subclass implementation of <code>readElement</code>.
*
* Logs an error if the element was not recognized.
*/
virtual void ReadElements(const std::vector<IConfigurationElement::Pointer>& elements);
/**
* Read one extension by looping through its
* configuration elements.
*/
virtual void ReadExtension(const IExtension* extension);
public:
/**
* Start the registry reading process using the
* supplied plugin ID and extension point.
*
* @param registry the registry to read from
* @param pluginId the plugin id of the extenion point
* @param extensionPoint the extension point id
*/
virtual void ReadRegistry(const std::string& pluginId,
const std::string& extensionPoint);
/**
* Utility for extracting the description child of an element.
*
* @param configElement the element
* @return the description
* @since 3.1
*/
static std::string GetDescription(IConfigurationElement::Pointer configElement);
/**
* Utility for extracting the value of a class attribute or a nested class
* element that follows the pattern set forth by
* {@link org.blueberry.core.runtime.IExecutableExtension}.
*
* @param configElement
* the element
* @param classAttributeName
* the name of the class attribute to check
* @return the value of the attribute or nested class element
* @since 3.1
*/
static std::string GetClassValue(IConfigurationElement::Pointer configElement, const std::string& classAttributeName);
};
}
#endif /*BERRYREGISTRYREADER_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berrySaveablesList.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berrySaveablesList.cpp
index 8bc3b974df..643451ac79 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berrySaveablesList.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berrySaveablesList.cpp
@@ -1,637 +1,637 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berrySaveablesList.h"
#include "berryWorkbenchPlugin.h"
#include "berryDefaultSaveable.h"
#include "berryImageDescriptor.h"
#include "berryWorkbenchPart.h"
namespace berry
{
bool SaveablesList::AddModel(Object::Pointer source, Saveable::Pointer model)
{
if (model == 0)
{
this->LogWarning("Ignored attempt to add invalid saveable", source, model); //$NON-NLS-1$
return false;
}
bool result = false;
Saveable::Set& modelsForSource = modelMap[source.GetPointer()];
if (modelsForSource.find(model) == modelsForSource.end())
{
modelsForSource.insert(model);
result = this->IncrementRefCount(modelRefCounts, model);
}
else
{
this->LogWarning("Ignored attempt to add saveable that was already registered",
source, model); //$NON-NLS-1$
}
return result;
}
bool SaveablesList::IncrementRefCount(
std::map<Saveable::Pointer, int>& referenceMap, Saveable::Pointer key)
{
bool result = false;
int& refCount = referenceMap[key];
if (refCount == 0)
{
result = true;
}
refCount++;
return result;
}
bool SaveablesList::DecrementRefCount(
std::map<Saveable::Pointer, int>& referenceMap, Saveable::Pointer key)
{
bool result = false;
int& refCount = referenceMap[key];
poco_assert(refCount != 0);
if (refCount == 1)
{
referenceMap.erase(key);
result = true;
}
else
{
--refCount;
}
return result;
}
bool SaveablesList::RemoveModel(Object::Pointer source, Saveable::Pointer model)
{
bool result = false;
std::map<Object*, Saveable::Set>::iterator it = modelMap.find(source.GetPointer());
if (it == modelMap.end())
{
this->LogWarning(
"Ignored attempt to remove a saveable when no saveables were known",
source, model); //$NON-NLS-1$
}
else
{
Saveable::Set& modelsForSource = it->second;
if (modelsForSource.erase(model) != 0)
{
result = this->DecrementRefCount(modelRefCounts, model);
if (modelsForSource.empty())
{
modelMap.erase(source.GetPointer());
}
}
else
{
this->LogWarning(
"Ignored attempt to remove a saveable that was not registered",
source, model); //$NON-NLS-1$
}
}
return result;
}
void SaveablesList::LogWarning(const std::string& message,
Object::Pointer source, Saveable::Pointer model)
{
// create a new exception
std::string text = message + "; " + "unknown saveable: " + model->GetName()
+ " from part: " + source->GetClassName();
// record the current stack trace to help with debugging
//assertionFailedException.fillInStackTrace();
WorkbenchPlugin::Log(text);
}
void SaveablesList::UpdateNonPartSource(ISaveablesSource::Pointer source)
{
std::vector<Saveable::Pointer> saveables = source->GetSaveables();
if (saveables.empty())
{
nonPartSources.erase(source);
}
else
{
nonPartSources.insert(source);
}
}
void SaveablesList::RemoveModels(Object::Pointer source,
const std::vector<Saveable::Pointer>& modelArray)
{
std::vector<Saveable::Pointer> removed;
for (unsigned int i = 0; i < modelArray.size(); i++)
{
Saveable::Pointer model = modelArray[i];
if (this->RemoveModel(source, model))
{
removed.push_back(model);
}
}
if (removed.size() > 0)
{
Object::Pointer source(this);
SaveablesLifecycleEvent::Pointer event(new SaveablesLifecycleEvent(source,
SaveablesLifecycleEvent::POST_OPEN, removed, false));
this->FireModelLifecycleEvent(event);
}
}
void SaveablesList::AddModels(Object::Pointer source,
const std::vector<Saveable::Pointer>& modelArray)
{
std::vector<Saveable::Pointer> added;
for (unsigned int i = 0; i < modelArray.size(); i++)
{
Saveable::Pointer model = modelArray[i];
if (this->AddModel(source, model))
{
added.push_back(model);
}
}
if (added.size() > 0)
{
Object::Pointer source(this);
SaveablesLifecycleEvent::Pointer event(new SaveablesLifecycleEvent(source,
SaveablesLifecycleEvent::POST_OPEN, added, false));
this->FireModelLifecycleEvent(event);
}
}
void SaveablesList::FireModelLifecycleEvent(
SaveablesLifecycleEvent::Pointer event)
{
events.lifecycleChange(event);
}
bool SaveablesList::PromptForSavingIfNecessary(
IWorkbenchWindow::Pointer /*window*/, const Saveable::Set& /*modelsClosing*/,
const std::map<Saveable::Pointer, int>& /*modelsDecrementing*/, bool /*canCancel*/)
{
// List modelsToOptionallySave = new ArrayList();
// for (Iterator it = modelsDecrementing.keySet().iterator(); it.hasNext();)
// {
// Saveable modelDecrementing = (Saveable) it.next();
// if (modelDecrementing.isDirty() && !modelsClosing.contains(
// modelDecrementing))
// {
// modelsToOptionallySave.add(modelDecrementing);
// }
// }
//
// boolean shouldCancel =
// modelsToOptionallySave.isEmpty() ? false : promptForSaving(
// modelsToOptionallySave, window, window, canCancel, true);
//
// if (shouldCancel)
// {
// return true;
// }
//
// List modelsToSave = new ArrayList();
// for (Iterator it = modelsClosing.iterator(); it.hasNext();)
// {
// Saveable modelClosing = (Saveable) it.next();
// if (modelClosing.isDirty())
// {
// modelsToSave.add(modelClosing);
// }
// }
// return modelsToSave.isEmpty() ? false : promptForSaving(modelsToSave, window,
// window, canCancel, false);
return false;
}
void SaveablesList::FillModelsClosing(Saveable::Set& modelsClosing,
const std::map<Saveable::Pointer, int>& modelsDecrementing)
{
for (std::map<Saveable::Pointer, int>::const_iterator it = modelsDecrementing.begin();
it != modelsDecrementing.end(); ++it)
{
Saveable::Pointer model = it->first;
if (it->second == modelRefCounts[model])
{
modelsClosing.insert(model);
}
}
}
std::vector<Saveable::Pointer> SaveablesList::GetSaveables(
IWorkbenchPart::Pointer part)
{
if (part.Cast<ISaveablesSource> () != 0)
{
ISaveablesSource::Pointer source = part.Cast<ISaveablesSource>();
return source->GetSaveables();
}
else if (part.Cast<ISaveablePart> () != 0)
{
std::vector<Saveable::Pointer> result;
Saveable::Pointer defaultSaveable(new DefaultSaveable(part));
result.push_back(defaultSaveable);
return result;
}
else
{
return std::vector<Saveable::Pointer>();
}
}
Saveable::Set SaveablesList::GetOpenModels()
{
Saveable::Set allDistinctModels;
for (std::map<Object*, Saveable::Set>::iterator it = modelMap.begin();
it != modelMap.end(); ++it)
allDistinctModels.insert(it->second.begin(), it->second.end());
return allDistinctModels;
}
void SaveablesList::HandleLifecycleEvent(SaveablesLifecycleEvent::Pointer event)
{
if (event->GetSource().Cast<IWorkbenchPart> () == 0)
{
// just update the set of non-part sources. No prompting necessary.
// See bug 139004.
this->UpdateNonPartSource(event->GetSource().Cast<ISaveablesSource>());
return;
}
std::vector<Saveable::Pointer> modelArray = event->GetSaveables();
int eventType = event->GetEventType();
if (eventType == SaveablesLifecycleEvent::POST_OPEN)
{
this->AddModels(event->GetSource(), modelArray);
}
else if (eventType == SaveablesLifecycleEvent::PRE_CLOSE)
{
std::vector<Saveable::Pointer> models = event->GetSaveables();
std::map<Saveable::Pointer, int> modelsDecrementing;
Saveable::Set modelsClosing;
for (unsigned int i = 0; i < models.size(); i++)
{
this->IncrementRefCount(modelsDecrementing, models[i]);
}
this->FillModelsClosing(modelsClosing, modelsDecrementing);
bool canceled = this->PromptForSavingIfNecessary(
PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow(), modelsClosing,
modelsDecrementing, !event->IsForce());
if (canceled)
{
event->SetVeto(true);
}
}
else if (eventType == SaveablesLifecycleEvent::POST_CLOSE)
{
this->RemoveModels(event->GetSource(), modelArray);
}
else if (eventType == SaveablesLifecycleEvent::DIRTY_CHANGED)
{
Object::Pointer source(this);
SaveablesLifecycleEvent::Pointer event(
new SaveablesLifecycleEvent(source, event->GetEventType(), event->GetSaveables(), false));
this->FireModelLifecycleEvent(event);
}
}
void SaveablesList::AddModelLifecycleListener(
ISaveablesLifecycleListener::Pointer listener)
{
events.AddListener(listener);
}
void SaveablesList::RemoveModelLifecycleListener(
ISaveablesLifecycleListener::Pointer listener)
{
events.RemoveListener(listener);
}
SaveablesList::PostCloseInfo::Pointer SaveablesList::PreCloseParts(
const std::list<IWorkbenchPart::Pointer>& partsToClose, bool save,
IWorkbenchWindow::Pointer window)
{
// reference count (how many occurrences of a model will go away?)
PostCloseInfo::Pointer postCloseInfo(new PostCloseInfo());
for (std::list<IWorkbenchPart::Pointer>::const_iterator it = partsToClose.begin();
it != partsToClose.end(); ++it)
{
WorkbenchPart::Pointer part = it->Cast<WorkbenchPart>();
postCloseInfo->partsClosing.push_back(part);
if (part.Cast<ISaveablePart> () != 0)
{
ISaveablePart::Pointer saveablePart = part.Cast<ISaveablePart>();
if (save && !saveablePart->IsSaveOnCloseNeeded())
{
// pretend for now that this part is not closing
continue;
}
}
// if (save && part.Cast<ISaveablePart2> () != 0)
// {
// ISaveablePart2 saveablePart2 = (ISaveablePart2) part;
// // TODO show saveablePart2 before prompting, see
// // EditorManager.saveAll
// int response = SaveableHelper.savePart(saveablePart2, window, true);
// if (response == ISaveablePart2.CANCEL)
// {
// // user canceled
// return 0;
// }
// else if (response != ISaveablePart2.DEFAULT)
// {
// // only include this part in the following logic if it returned
// // DEFAULT
// continue;
// }
// }
std::vector<Saveable::Pointer> modelsFromSource = this->GetSaveables(part);
for (unsigned int i = 0; i < modelsFromSource.size(); i++)
{
this->IncrementRefCount(postCloseInfo->modelsDecrementing, modelsFromSource[i]);
}
}
this->FillModelsClosing(postCloseInfo->modelsClosing,
postCloseInfo->modelsDecrementing);
if (save)
{
bool canceled = this->PromptForSavingIfNecessary(window,
postCloseInfo->modelsClosing, postCloseInfo->modelsDecrementing, true);
if (canceled)
{
return PostCloseInfo::Pointer(0);
}
}
return postCloseInfo;
}
bool SaveablesList::PromptForSaving(
const std::list<Saveable::Pointer>& /*modelsToSave*/,
/*final IShellProvider shellProvider, IRunnableContext runnableContext,*/
bool /*canCancel*/, bool /*stillOpenElsewhere*/)
{
// // Save parts, exit the method if cancel is pressed.
// if (modelsToSave.size() > 0) {
// boolean canceled = SaveableHelper.waitForBackgroundSaveJobs(modelsToSave);
// if (canceled) {
// return true;
// }
//
// IPreferenceStore apiPreferenceStore = PrefUtil.getAPIPreferenceStore();
// boolean dontPrompt = stillOpenElsewhere && !apiPreferenceStore.getBoolean(IWorkbenchPreferenceConstants.PROMPT_WHEN_SAVEABLE_STILL_OPEN);
//
// if (dontPrompt) {
// modelsToSave.clear();
// return false;
// } else if (modelsToSave.size() == 1) {
// Saveable model = (Saveable) modelsToSave.get(0);
// // Show a dialog.
// std::vector<std::string> buttons;
// if(canCancel) {
// buttons.push_back(IDialogConstants.YES_LABEL);
// buttons.push_back(IDialogConstants.NO_LABEL);
// buttons.push_back(IDialogConstants.CANCEL_LABEL);
// } else {
// buttons.push_back(IDialogConstants.YES_LABEL);
// buttons.push_back(IDialogConstants.NO_LABEL);
// }
//
// // don't save if we don't prompt
// int choice = ISaveablePart2.NO;
//
// MessageDialog dialog;
// if (stillOpenElsewhere) {
// String message = NLS
// .bind(
// WorkbenchMessages.EditorManager_saveChangesOptionallyQuestion,
// model.getName());
// MessageDialogWithToggle dialogWithToggle = new MessageDialogWithToggle(shellProvider.getShell(),
// WorkbenchMessages.Save_Resource, 0, message,
// MessageDialog.QUESTION, buttons, 0, WorkbenchMessages.EditorManager_closeWithoutPromptingOption, false) {
// protected int getShellStyle() {
// return (canCancel ? SWT.CLOSE : SWT.NONE)
// | SWT.TITLE | SWT.BORDER
// | SWT.APPLICATION_MODAL
// | getDefaultOrientation();
// }
// };
// dialog = dialogWithToggle;
// } else {
// String message = NLS
// .bind(
// WorkbenchMessages.EditorManager_saveChangesQuestion,
// model.getName());
// dialog = new MessageDialog(shellProvider.getShell(),
// WorkbenchMessages.Save_Resource, 0, message,
// MessageDialog.QUESTION, buttons, 0) {
// protected int getShellStyle() {
// return (canCancel ? SWT.CLOSE : SWT.NONE)
// | SWT.TITLE | SWT.BORDER
// | SWT.APPLICATION_MODAL
// | getDefaultOrientation();
// }
// };
// }
//
// choice = SaveableHelper.testGetAutomatedResponse();
// if (SaveableHelper.testGetAutomatedResponse() == SaveableHelper.USER_RESPONSE) {
// choice = dialog.open();
//
// if(stillOpenElsewhere) {
// // map value of choice back to ISaveablePart2 values
// switch (choice) {
// case IDialogConstants.YES_ID:
// choice = ISaveablePart2.YES;
// break;
// case IDialogConstants.NO_ID:
// choice = ISaveablePart2.NO;
// break;
// case IDialogConstants.CANCEL_ID:
// choice = ISaveablePart2.CANCEL;
// break;
// default:
// break;
// }
// MessageDialogWithToggle dialogWithToggle = (MessageDialogWithToggle) dialog;
// if (choice != ISaveablePart2.CANCEL && dialogWithToggle.getToggleState()) {
// apiPreferenceStore.setValue(IWorkbenchPreferenceConstants.PROMPT_WHEN_SAVEABLE_STILL_OPEN, false);
// }
// }
// }
//
// // Branch on the user choice.
// // The choice id is based on the order of button labels
// // above.
// switch (choice) {
// case ISaveablePart2.YES: // yes
// break;
// case ISaveablePart2.NO: // no
// modelsToSave.clear();
// break;
// default:
// case ISaveablePart2.CANCEL: // cancel
// return true;
// }
// } else {
// MyListSelectionDialog dlg = new MyListSelectionDialog(
// shellProvider.getShell(),
// modelsToSave,
// new ArrayContentProvider(),
// new WorkbenchPartLabelProvider(),
// stillOpenElsewhere ? WorkbenchMessages.EditorManager_saveResourcesOptionallyMessage
// : WorkbenchMessages.EditorManager_saveResourcesMessage,
// canCancel, stillOpenElsewhere);
// dlg.setInitialSelections(modelsToSave.toArray());
// dlg.setTitle(EditorManager.SAVE_RESOURCES_TITLE);
//
// // this "if" statement aids in testing.
// if (SaveableHelper.testGetAutomatedResponse() == SaveableHelper.USER_RESPONSE) {
// int result = dlg.open();
// // Just return 0 to prevent the operation continuing
// if (result == IDialogConstants.CANCEL_ID)
// return true;
//
// if (dlg.getDontPromptSelection()) {
// apiPreferenceStore.setValue(IWorkbenchPreferenceConstants.PROMPT_WHEN_SAVEABLE_STILL_OPEN, false);
// }
//
// modelsToSave = Arrays.asList(dlg.getResult());
// }
// }
// }
// // Create save block.
// return saveModels(modelsToSave, shellProvider, runnableContext);
return true;
}
bool SaveablesList::SaveModels(const std::list<Saveable::Pointer>& /*finalModels*/
/*final IShellProvider shellProvider, IRunnableContext runnableContext*/)
{
// IRunnableWithProgress progressOp = new IRunnableWithProgress() {
// public void run(IProgressMonitor monitor) {
// IProgressMonitor monitorWrap = new EventLoopProgressMonitor(
// monitor);
// monitorWrap.beginTask("", finalModels.size()); //$NON-NLS-1$
// for (Iterator i = finalModels.iterator(); i.hasNext();) {
// Saveable model = (Saveable) i.next();
// // handle case where this model got saved as a result of
// // saving another
// if (!model.isDirty()) {
// monitor.worked(1);
// continue;
// }
// SaveableHelper.doSaveModel(model, new SubProgressMonitor(monitorWrap, 1), shellProvider, true);
// if (monitorWrap.isCanceled())
// break;
// }
// monitorWrap.done();
// }
// };
//
// // Do the save.
// return !SaveableHelper.runProgressMonitorOperation(
// WorkbenchMessages.Save_All, progressOp, runnableContext,
// shellProvider);
return true;
}
void SaveablesList::PostClose(PostCloseInfo::Pointer postCloseInfo)
{
std::vector<Saveable::Pointer> removed;
for (std::list<WorkbenchPart::Pointer>::const_iterator it = postCloseInfo->partsClosing.begin();
it != postCloseInfo->partsClosing.end(); ++it)
{
IWorkbenchPart::Pointer part = *it;
std::map<Object*, Saveable::Set>::iterator it2 = modelMap.find(part.GetPointer());
if (it2 != modelMap.end()) {
// make a copy to avoid a ConcurrentModificationException - we
// will remove from the original set as we iterate
Saveable::Set saveables(it2->second);
for (Saveable::Set::const_iterator it3 = saveables.begin();
it3 != saveables.end(); ++it3)
{
if (RemoveModel(part, *it3)) {
removed.push_back(*it3);
}
}
}
}
if (!removed.empty()) {
Object::Pointer source(this);
SaveablesLifecycleEvent::Pointer event(new SaveablesLifecycleEvent(source,
SaveablesLifecycleEvent::POST_CLOSE, removed, false));
this->FireModelLifecycleEvent(event);
}
}
void SaveablesList::PostOpen(IWorkbenchPart::Pointer part)
{
this->AddModels(part, this->GetSaveables(part));
}
void SaveablesList::DirtyChanged(IWorkbenchPart::Pointer part)
{
std::vector<Saveable::Pointer> saveables = this->GetSaveables(part);
if (saveables.size() > 0) {
Object::Pointer source(this);
SaveablesLifecycleEvent::Pointer event(new SaveablesLifecycleEvent(source,
SaveablesLifecycleEvent::DIRTY_CHANGED, saveables, false));
this->FireModelLifecycleEvent(event);
}
}
std::vector<Object::Pointer> SaveablesList::TestGetSourcesForModel(
Saveable::Pointer /*model*/)
{
std::vector<Object::Pointer> result;
// for (Iterator it = modelMap.entrySet().iterator(); it.hasNext();) {
// Map.Entry entry = (Map.Entry) it.next();
// Set values = (Set) entry.getValue();
// if (values.contains(model)) {
// result.add(entry.getKey());
// }
// }
return result;
}
std::vector<ISaveablesSource::Pointer> SaveablesList::GetNonPartSources()
{
std::vector<ISaveablesSource::Pointer> result(nonPartSources.begin(),
nonPartSources.end());
return result;
}
std::vector<IWorkbenchPart::Pointer> SaveablesList::GetPartsForSaveable(
Saveable::Pointer model)
{
std::vector<IWorkbenchPart::Pointer> result;
for (std::map<Object*, Saveable::Set>::iterator it = modelMap.begin(); it
!= modelMap.end(); ++it)
{
Saveable::Set& values = it->second;
IWorkbenchPart::Pointer part(dynamic_cast<IWorkbenchPart*>(it->first));
if (values.find(model) != values.end() && part)
{
result.push_back(part);
}
}
return result;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berrySaveablesList.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berrySaveablesList.h
index d1161b7d55..17a44a2634 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berrySaveablesList.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berrySaveablesList.h
@@ -1,362 +1,362 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYSAVEABLESLIST_H_
#define BERRYSAVEABLESLIST_H_
#include "berryISaveablesLifecycleListener.h"
#include "berryISaveablesSource.h"
#include "berryIWorkbenchWindow.h"
#include "berryIWorkbenchPart.h"
#include "berryWorkbenchPart.h"
#include <map>
#include <set>
#include <list>
#include <vector>
namespace berry
{
/**
* The model manager maintains a list of open saveable models.
*
* @see Saveable
* @see ISaveablesSource
*
* @since 3.2
*/
class SaveablesList: public ISaveablesLifecycleListener
{
public:
berryObjectMacro(SaveablesList);
private:
ISaveablesLifecycleListener::Events events;
// event source (mostly ISaveablesSource) -> Set of Saveable
std::map<Object*, Saveable::Set> modelMap;
// reference counting map, Saveable -> Integer
std::map<Saveable::Pointer, int> modelRefCounts;
std::set<ISaveablesSource::Pointer> nonPartSources;
// returns true if this model has not yet been in getModels()
bool AddModel(Object::Pointer source, Saveable::Pointer model);
/**
* returns true if the given key was added for the first time
*
* @param referenceMap
* @param key
* @return true if the ref count of the given key is now 1
*/
bool IncrementRefCount(std::map<Saveable::Pointer, int>& referenceMap,
Saveable::Pointer key);
/**
* returns true if the given key has been removed
*
* @param referenceMap
* @param key
* @return true if the ref count of the given key was 1
*/
bool DecrementRefCount(std::map<Saveable::Pointer, int>& referenceMap,
Saveable::Pointer key);
// returns true if this model was removed from getModels();
bool RemoveModel(Object::Pointer source, Saveable::Pointer model);
void LogWarning(const std::string& message, Object::Pointer source,
Saveable::Pointer model);
/**
* Updates the set of non-part saveables sources.
* @param source
*/
void UpdateNonPartSource(ISaveablesSource::Pointer source);
/**
* @param source
* @param modelArray
*/
void RemoveModels(Object::Pointer source,
const std::vector<Saveable::Pointer>& modelArray);
/**
* @param source
* @param modelArray
*/
void AddModels(Object::Pointer source,
const std::vector<Saveable::Pointer>& modelArray);
/**
* @param event
*/
void FireModelLifecycleEvent(SaveablesLifecycleEvent::Pointer event);
/**
* @param window
* @param modelsClosing
* @param canCancel
* @return true if the user canceled
*/
bool
PromptForSavingIfNecessary(IWorkbenchWindow::Pointer window,
const Saveable::Set& modelsClosing,
const std::map<Saveable::Pointer, int>& modelsDecrementing,
bool canCancel);
/**
* @param modelsClosing
* @param modelsDecrementing
*/
void FillModelsClosing(Saveable::Set& modelsClosing,
const std::map<Saveable::Pointer, int>& modelsDecrementing);
/**
* Returns the saveable models provided by the given part. If the part does
* not provide any models, a default model is returned representing the
* part.
*
* @param part
* the workbench part
* @return the saveable models
*/
std::vector<Saveable::Pointer> GetSaveables(IWorkbenchPart::Pointer part);
//TODO SaveablesList ListSelectionDialog
// class MyListSelectionDialog extends
// ListSelectionDialog {
// private final boolean canCancel;
// private Button checkbox;
// private boolean dontPromptSelection;
// private boolean stillOpenElsewhere;
//
// private MyListSelectionDialog(Shell shell, Object input,
// IStructuredContentProvider contentprovider,
// ILabelProvider labelProvider, String message, boolean canCancel, boolean stillOpenElsewhere) {
// super(shell, input, contentprovider, labelProvider, message);
// this.canCancel = canCancel;
// this.stillOpenElsewhere = stillOpenElsewhere;
// if (!canCancel) {
// int shellStyle = getShellStyle();
// shellStyle &= ~SWT.CLOSE;
// setShellStyle(shellStyle);
// }
// }
//
// /**
// * @return
// */
// public boolean getDontPromptSelection() {
// return dontPromptSelection;
// }
//
// protected void createButtonsForButtonBar(Composite parent) {
// createButton(parent, IDialogConstants.OK_ID,
// IDialogConstants.OK_LABEL, true);
// if (canCancel) {
// createButton(parent, IDialogConstants.CANCEL_ID,
// IDialogConstants.CANCEL_LABEL, false);
// }
// }
//
// protected Control createDialogArea(Composite parent) {
// Composite dialogAreaComposite = (Composite) super.createDialogArea(parent);
//
// if (stillOpenElsewhere) {
// Composite checkboxComposite = new Composite(dialogAreaComposite, SWT.NONE);
// checkboxComposite.setLayout(new GridLayout(2, false));
//
// checkbox = new Button(checkboxComposite, SWT.CHECK);
// checkbox.addSelectionListener(new SelectionAdapter() {
// public void widgetSelected(SelectionEvent e) {
// dontPromptSelection = checkbox.getSelection();
// }
// });
// GridData gd = new GridData();
// gd.horizontalAlignment = SWT.BEGINNING;
// checkbox.setLayoutData(gd);
//
// Label label = new Label(checkboxComposite, SWT.NONE);
// label.setText(WorkbenchMessages.EditorManager_closeWithoutPromptingOption);
// gd = new GridData();
// gd.grabExcessHorizontalSpace = true;
// gd.horizontalAlignment = SWT.BEGINNING;
// }
//
// return dialogAreaComposite;
// }
// }
public:
struct PostCloseInfo : public Object
{
berryObjectMacro(PostCloseInfo);
std::list<SmartPointer<WorkbenchPart> > partsClosing;
std::map<Saveable::Pointer, int> modelsDecrementing;
Saveable::Set modelsClosing;
private:
PostCloseInfo() {}
friend class SaveablesList;
};
/**
* Returns the list of open models managed by this model manager.
*
* @return a list of models
*/
Saveable::Set GetOpenModels();
/**
* This implementation of handleModelLifecycleEvent must be called by
* implementers of ISaveablesSource whenever the list of models of the model
* source changes, or when the dirty state of models changes. The
* ISaveablesSource instance must be passed as the source of the event
* object.
* <p>
* This method may also be called by objects that hold on to models but are
* not workbench parts. In this case, the event source must be set to an
* object that is not an instanceof IWorkbenchPart.
* </p>
* <p>
* Corresponding open and close events must originate from the same
* (identical) event source.
* </p>
* <p>
* This method must be called on the UI thread.
* </p>
*/
void HandleLifecycleEvent(SaveablesLifecycleEvent::Pointer event);
/**
* Adds the given listener to the list of listeners. Has no effect if the
* same (identical) listener has already been added. The listener will be
* notified about changes to the models managed by this model manager. Event
* types include: <br>
* POST_OPEN when models were added to the list of models <br>
* POST_CLOSE when models were removed from the list of models <br>
* DIRTY_CHANGED when the dirty state of models changed
* <p>
* Listeners should ignore all other event types, including PRE_CLOSE. There
* is no guarantee that listeners are notified before models are closed.
*
* @param listener
*/
void AddModelLifecycleListener(ISaveablesLifecycleListener::Pointer listener);
/**
* Removes the given listener from the list of listeners. Has no effect if
* the given listener is not contained in the list.
*
* @param listener
*/
void RemoveModelLifecycleListener(
ISaveablesLifecycleListener::Pointer listener);
/**
* @param partsToClose
* @param save
* @param window
* @return the post close info to be passed to postClose
*/
PostCloseInfo::Pointer PreCloseParts(
const std::list<SmartPointer<IWorkbenchPart> >& partsToClose, bool save,
IWorkbenchWindow::Pointer window);
/**
* Prompt the user to save the given saveables.
* @param modelsToSave the saveables to be saved
* @param shellProvider the provider used to obtain a shell in prompting is
* required. Clients can use a workbench window for this.
* @param runnableContext a runnable context that will be used to provide a
* progress monitor while the save is taking place. Clients can
* use a workbench window for this.
* @param canCancel whether the operation can be canceled
* @param stillOpenElsewhere whether the models are referenced by open parts
* @return true if the user canceled
*/
bool PromptForSaving(const std::list<Saveable::Pointer>& modelsToSave,
/*final IShellProvider shellProvider, IRunnableContext runnableContext,*/
bool canCancel, bool stillOpenElsewhere);
/**
* Save the given models.
* @param finalModels the list of models to be saved
* @param shellProvider the provider used to obtain a shell in prompting is
* required. Clients can use a workbench window for this.
* @param runnableContext a runnable context that will be used to provide a
* progress monitor while the save is taking place. Clients can
* use a workbench window for this.
* @return <code>true</code> if the operation was canceled
*/
bool SaveModels(const std::list<Saveable::Pointer>& finalModels
/*final IShellProvider shellProvider, IRunnableContext runnableContext*/);
/**
* @param postCloseInfoObject
*/
void PostClose(PostCloseInfo::Pointer postCloseInfoObject);
/**
* @param actualPart
*/
void PostOpen(IWorkbenchPart::Pointer part);
/**
* @param actualPart
*/
void DirtyChanged(IWorkbenchPart::Pointer part);
/**
* For testing purposes. Not to be called by clients.
*
* @param model
* @return
*/
std::vector<Object::Pointer> TestGetSourcesForModel(Saveable::Pointer model);
/**
* @return a list of ISaveablesSource objects registered with this saveables
* list which are not workbench parts.
*/
std::vector<ISaveablesSource::Pointer> GetNonPartSources();
/**
* @param model
*/
std::vector<IWorkbenchPart::Pointer> GetPartsForSaveable(
Saveable::Pointer model);
};
}
#endif /* BERRYSAVEABLESLIST_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryServiceLocator.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryServiceLocator.cpp
index 0077400b85..85424bb2db 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryServiceLocator.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryServiceLocator.cpp
@@ -1,233 +1,233 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryServiceLocator.h"
#include "berryWorkbenchServiceRegistry.h"
#include "services/berryIServiceFactory.h"
#include "services/berryINestable.h"
#include <Poco/Exception.h>
namespace berry
{
ServiceLocator::ParentLocator::ParentLocator(const IServiceLocator::WeakPtr parent,
const std::string& serviceInterface) :
locator(parent), key(serviceInterface)
{
}
Object::Pointer ServiceLocator::ParentLocator::GetService(
const std::string& api)
{
if (key == api)
{
try {
return locator.Lock()->GetService(key);
}
catch (const BadWeakPointerException& /*e*/)
{
}
}
return Object::Pointer(0);
}
bool ServiceLocator::ParentLocator::HasService(const std::string& api) const
{
if (key == api)
{
return true;
}
return false;
}
ServiceLocator::ServiceLocator() :
activated(false), disposed(false)
{
}
ServiceLocator::ServiceLocator(const IServiceLocator::WeakPtr _parent,
const IServiceFactory::ConstPointer _factory, IDisposable::WeakPtr _owner) :
activated(false), factory(_factory), parent(_parent),
disposed(false), owner(_owner)
{
}
void ServiceLocator::Activate()
{
activated = true;
for (KeyToServiceMapType::iterator serviceItr = services.begin(); serviceItr
!= services.end(); ++serviceItr)
{
Object::Pointer service = serviceItr->second;
if (INestable::Pointer nestableService = service.Cast<INestable>())
{
nestableService->Activate();
}
}
}
void ServiceLocator::Deactivate()
{
activated = false;
for (KeyToServiceMapType::iterator serviceItr = services.begin(); serviceItr
!= services.end(); ++serviceItr)
{
Object::Pointer service = serviceItr->second;
if (INestable::Pointer nestableService = service.Cast<INestable>())
{
nestableService->Deactivate();
}
}
}
void ServiceLocator::Dispose()
{
for (KeyToServiceMapType::iterator serviceItr = services.begin(); serviceItr
!= services.end(); ++serviceItr)
{
Object::Pointer object = serviceItr->second;
if (IDisposable::Pointer service = object.Cast<IDisposable>())
{
service->Dispose();
}
}
services.clear();
parent.Reset();
disposed = true;
}
Object::Pointer ServiceLocator::GetService(const std::string& key)
{
if (disposed)
{
return Object::Pointer(0);
}
KeyToServiceMapType::const_iterator iter = services.find(key);
Object::Pointer service;
if (iter != services.end())
{
service = iter->second;
}
else
{
// if we don't have a service in our cache then:
// 1. check our local factory
// 2. go to the registry
// or 3. use the parent service
IServiceLocator::Pointer factoryParent(WorkbenchServiceRegistry::GLOBAL_PARENT);
if (!parent.Expired())
{
factoryParent = new ParentLocator(parent, key);
}
if (factory)
{
service = factory->Create(key, factoryParent, IServiceLocator::Pointer(this));
}
if (!service)
{
service = WorkbenchServiceRegistry::GetRegistry()->GetService(key,
factoryParent, ServiceLocator::Pointer(this));
}
if (!service)
{
service = factoryParent->GetService(key);
}
else
{
this->RegisterService(key, service);
}
}
return service;
}
bool ServiceLocator::HasService(const std::string& key) const
{
if (disposed)
{
return false;
}
if (services.find(key) != services.end())
{
return true;
}
return false;
}
void ServiceLocator::RegisterService(const std::string& api,
Object::Pointer service) const
{
if (api.empty())
{
throw Poco::InvalidArgumentException("The service key cannot be empty"); //$NON-NLS-1$
}
// if (!api.isInstance(service))
// {
// throw new IllegalArgumentException("The service does not implement the given interface"); //$NON-NLS-1$
// }
if (services.find(api) != services.end())
{
Object::Pointer currentService = services[api];
services.erase(api);
if (IDisposable::Pointer disposable = currentService.Cast<IDisposable>())
{
disposable->Dispose();
}
}
if (service)
{
services.insert(std::make_pair(api, service));
if (INestable::Pointer nestable = service.Cast<INestable>())
{
if (activated)
{
nestable->Activate();
}
}
}
}
bool ServiceLocator::IsDisposed() const
{
return disposed;
}
void ServiceLocator::UnregisterServices(const std::vector<std::string>& /*serviceNames*/)
{
IDisposable::Pointer d(owner);
if (d)
{
d->Dispose();
}
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryServiceLocator.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryServiceLocator.h
index ddf585ef5b..ad22b3cf55 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryServiceLocator.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryServiceLocator.h
@@ -1,151 +1,151 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYSERVICELOCATOR_H_
#define BERRYSERVICELOCATOR_H_
#include "services/berryIServiceLocator.h"
#include "services/berryINestable.h"
#include "services/berryIDisposable.h"
#include <map>
#include <vector>
#include <string>
#include <typeinfo>
namespace berry
{
struct IServiceFactory;
class ServiceLocator: public IDisposable,
public INestable,
public IServiceLocator
{
private:
bool activated;
class ParentLocator: public IServiceLocator
{
const IServiceLocator::WeakPtr locator;
const std::string& key;
public:
ParentLocator(const IServiceLocator::WeakPtr parent,
const std::string& serviceInterface);
/*
* (non-Javadoc)
*
* @see org.blueberry.ui.services.IServiceLocator#getService(java.lang.Class)
*/
Object::Pointer GetService(const std::string& api);
/*
* (non-Javadoc)
*
* @see org.blueberry.ui.services.IServiceLocator#hasService(java.lang.Class)
*/
bool HasService(const std::string& api) const;
};
const SmartPointer<const IServiceFactory> factory;
/**
* The parent for this service locator. If a service can't be found in this
* locator, then the parent is asked. This value may be <code>null</code>
* if there is no parent.
*/
IServiceLocator::WeakPtr parent;
/**
* The map of services This value is <code>null</code> until a service is
* registered.
*/
typedef std::map<const std::string, Object::Pointer> KeyToServiceMapType;
mutable KeyToServiceMapType services;
bool disposed;
IDisposable::WeakPtr owner;
public:
berryObjectMacro(ServiceLocator)
/**
* Constructs a service locator with no parent.
*/
ServiceLocator();
/**
* Constructs a service locator with the given parent.
*
* @param parent
* The parent for this service locator; this value may be
* <code>null</code>.
* @param factory
* a local factory that can provide services at this level
* @param owner
*/
ServiceLocator(const IServiceLocator::WeakPtr parent, const SmartPointer<const IServiceFactory> factory,
IDisposable::WeakPtr owner);
void Activate();
void Deactivate();
void Dispose();
Object::Pointer GetService(const std::string& key);
bool HasService(const std::string& key) const;
/**
* Registers a service with this locator. If there is an existing service
* matching the same <code>api</code> and it implements
* {@link IDisposable}, it will be disposed.
*
* @param api
* This is the interface that the service implements. Must not be
* <code>null</code>.
* @param service
* The service to register. This must be some implementation of
* <code>api</code>. This value must not be <code>null</code>.
*/
void RegisterService(const std::string& api, Object::Pointer service) const;
/**
* @return
*/
bool IsDisposed() const;
/**
* Some services that were contributed to this locator are no longer available
* (because the plug-in containing the AbstractServiceFactory is no longer
* available). Notify the owner of the locator about this.
*/
void UnregisterServices(const std::vector<std::string>& serviceNames);
};
}
#endif // BERRYSERVICELOCATOR_H_
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryServiceLocatorCreator.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryServiceLocatorCreator.cpp
index b1a07d3126..9ad0723978 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryServiceLocatorCreator.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryServiceLocatorCreator.cpp
@@ -1,36 +1,36 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryServiceLocatorCreator.h"
#include "berryServiceLocator.h"
#include "services/berryIServiceFactory.h"
#include "services/berryIDisposable.h"
namespace berry {
SmartPointer<IServiceLocator>
ServiceLocatorCreator::CreateServiceLocator(
const WeakPointer<IServiceLocator> parent,
const SmartPointer<const IServiceFactory> factory,
WeakPointer<IDisposable> owner)
{
IServiceLocator::WeakPtr weakParent(parent);
IServiceLocator::Pointer locator(new ServiceLocator(weakParent, factory, owner));
return locator;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryServiceLocatorCreator.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryServiceLocatorCreator.h
index 49a033feef..ac7c8bfd7d 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryServiceLocatorCreator.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryServiceLocatorCreator.h
@@ -1,45 +1,45 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYSERVICELOCATORCREATOR_H_
#define BERRYSERVICELOCATORCREATOR_H_
#include "berryIServiceLocatorCreator.h"
namespace berry {
/**
* A simple service locator creator.
*
* @since 3.4
*/
class ServiceLocatorCreator : public IServiceLocatorCreator
{
public:
berryObjectMacro(ServiceLocatorCreator)
SmartPointer<IServiceLocator> CreateServiceLocator(
const WeakPointer<IServiceLocator> parent,
const SmartPointer<const IServiceFactory> factory,
WeakPointer<IDisposable> owner);
};
}
#endif /* BERRYSERVICELOCATORCREATOR_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryShellPool.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryShellPool.cpp
index 9cc8217536..f29cc9079d 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryShellPool.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryShellPool.cpp
@@ -1,83 +1,83 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryShellPool.h"
#include "tweaklets/berryGuiWidgetsTweaklet.h"
namespace berry
{
const std::string ShellPool::CLOSE_LISTENER = "close listener"; //$NON-NLS-1$
void ShellPool::ShellClosed(ShellEvent::Pointer e)
{
if (e->doit)
{
Shell::Pointer s = e->GetSource();
IShellListener::Pointer l =
s->GetData(CLOSE_LISTENER).Cast<IShellListener> ();
if (l != 0)
{
s->SetData(Object::Pointer(0), CLOSE_LISTENER);
l->ShellClosed(e);
// The shell can 'cancel' the close by setting
// the 'doit' to false...if so, do nothing
if (e->doit)
{
availableShells.push_back(s);
s->SetVisible(false);
}
else
{
// Restore the listener
s->SetData(l, CLOSE_LISTENER);
}
}
}
e->doit = false;
}
ShellPool::ShellPool(Shell::Pointer parentShell, int childFlags) :
flags(childFlags), parentShell(parentShell)
{
}
Shell::Pointer ShellPool::AllocateShell(IShellListener::Pointer closeListener)
{
Shell::Pointer result;
if (!availableShells.empty())
{
result = availableShells.front();
availableShells.pop_front();
}
else
{
result = Tweaklets::Get(GuiWidgetsTweaklet::KEY)->CreateShell(parentShell.Lock(),
flags);
result->AddShellListener(IShellListener::Pointer(this));
//result.addDisposeListener(disposeListener);
}
result->SetData(closeListener, CLOSE_LISTENER);
return result;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryShellPool.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryShellPool.h
index 34e9ca349c..3099cbfab9 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryShellPool.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryShellPool.h
@@ -1,87 +1,87 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYSHELLPOOL_H_
#define BERRYSHELLPOOL_H_
#include "berryShell.h"
#include <list>
namespace berry
{
/**
* Manages a pool of shells. This can be used instead of creating and destroying
* shells. By reusing shells, they will never be disposed until the pool goes away.
* This is useful in situations where client code may have cached pointers to the
* shells to use as a parent for dialogs. It also works around bug 86226 (SWT menus
* cannot be reparented).
*
* @since 3.1
*/
class ShellPool: public IShellListener
{
int flags;
/**
* Parent shell (or null if none)
*
* The parentShell is owned by the WorkbenchWindow, which also owns a ShellPool instance
*/
Shell::WeakPtr parentShell;
std::list<Shell::Pointer> availableShells;
static const std::string CLOSE_LISTENER; // = "close listener";
// DisposeListener disposeListener = new DisposeListener() {
// public void widgetDisposed(DisposeEvent e) {
// WorkbenchPlugin.log(new RuntimeException("Widget disposed too early!")); //$NON-NLS-1$
// }
// };
friend class WorkbenchWindow;
public:
berryObjectMacro(ShellPool);
void ShellClosed(ShellEvent::Pointer e);
/**
* Creates a shell pool that allocates shells that are children of the
* given parent and are created with the given flags.
*
* @param parentShell parent shell (may be null, indicating that this pool creates
* top-level shells)
* @param childFlags flags for all child shells
*/
ShellPool(Shell::Pointer parentShell, int childFlags);
/**
* Returns a new shell. The shell must not be disposed directly, but it may be closed.
* Once the shell is closed, it will be returned to the shell pool. Note: callers must
* remove all listeners from the shell before closing it.
*/
Shell::Pointer AllocateShell(IShellListener::Pointer closeListener);
};
}
#endif /* BERRYSHELLPOOL_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berrySourcePriorityNameMapping.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berrySourcePriorityNameMapping.cpp
index 372ee7734b..c970e0ccba 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berrySourcePriorityNameMapping.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berrySourcePriorityNameMapping.cpp
@@ -1,138 +1,138 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berrySourcePriorityNameMapping.h"
#include <Poco/Exception.h>
namespace berry
{
std::map<std::string,int> SourcePriorityNameMapping::sourcePrioritiesByName;
SourcePriorityNameMapping::SourcePriorityNameMapping()
{
// This class should not be instantiated.
}
const std::string SourcePriorityNameMapping::LEGACY_LEGACY_NAME()
{
static const std::string val = "LEGACY";
return val;
}
int SourcePriorityNameMapping::NO_SOURCE_PRIORITY()
{
static int val = 0;
return val;
}
SourcePriorityNameMapping::Initializer::Initializer()
{
SourcePriorityNameMapping::AddMapping(ISources::ACTIVE_ACTION_SETS_NAME(),
ISources::ACTIVE_ACTION_SETS());
SourcePriorityNameMapping::AddMapping(ISources::ACTIVE_CONTEXT_NAME(), ISources::ACTIVE_CONTEXT());
SourcePriorityNameMapping::AddMapping(ISources::ACTIVE_CURRENT_SELECTION_NAME(),
ISources::ACTIVE_CURRENT_SELECTION());
SourcePriorityNameMapping::AddMapping(ISources::ACTIVE_EDITOR_NAME(), ISources::ACTIVE_EDITOR());
SourcePriorityNameMapping::AddMapping(ISources::ACTIVE_EDITOR_ID_NAME(), ISources::ACTIVE_EDITOR_ID());
SourcePriorityNameMapping::AddMapping(ISources::ACTIVE_MENU_NAME(), ISources::ACTIVE_MENU());
SourcePriorityNameMapping::AddMapping(ISources::ACTIVE_MENU_SELECTION_NAME(), ISources::ACTIVE_MENU());
SourcePriorityNameMapping::AddMapping(ISources::ACTIVE_MENU_EDITOR_INPUT_NAME(),
ISources::ACTIVE_MENU());
SourcePriorityNameMapping::AddMapping(ISources::ACTIVE_FOCUS_CONTROL_ID_NAME(),
ISources::ACTIVE_MENU());
SourcePriorityNameMapping::AddMapping(ISources::ACTIVE_FOCUS_CONTROL_NAME(), ISources::ACTIVE_MENU());
SourcePriorityNameMapping::AddMapping(ISources::ACTIVE_PART_NAME(), ISources::ACTIVE_PART());
SourcePriorityNameMapping::AddMapping(ISources::ACTIVE_PART_ID_NAME(), ISources::ACTIVE_PART_ID());
SourcePriorityNameMapping::AddMapping(ISources::ACTIVE_SHELL_NAME(), ISources::ACTIVE_SHELL());
SourcePriorityNameMapping::AddMapping(ISources::ACTIVE_SITE_NAME(), ISources::ACTIVE_SITE());
SourcePriorityNameMapping::AddMapping(ISources::ACTIVE_WORKBENCH_WINDOW_NAME(),
ISources::ACTIVE_WORKBENCH_WINDOW());
SourcePriorityNameMapping::AddMapping(ISources::ACTIVE_WORKBENCH_WINDOW_SHELL_NAME(),
ISources::ACTIVE_WORKBENCH_WINDOW_SHELL());
SourcePriorityNameMapping::AddMapping(
ISources::ACTIVE_WORKBENCH_WINDOW_IS_COOLBAR_VISIBLE_NAME(),
ISources::ACTIVE_WORKBENCH_WINDOW_SUBORDINATE());
SourcePriorityNameMapping::AddMapping(
ISources::ACTIVE_WORKBENCH_WINDOW_ACTIVE_PERSPECTIVE_NAME(),
ISources::ACTIVE_WORKBENCH_WINDOW_SUBORDINATE());
SourcePriorityNameMapping::AddMapping(
ISources::ACTIVE_WORKBENCH_WINDOW_IS_PERSPECTIVEBAR_VISIBLE_NAME(),
ISources::ACTIVE_WORKBENCH_WINDOW_SUBORDINATE());
SourcePriorityNameMapping::AddMapping(LEGACY_LEGACY_NAME(), LEGACY_LEGACY());
SourcePriorityNameMapping::AddMapping("workbench", ISources::WORKBENCH());
}
SourcePriorityNameMapping::Initializer SourcePriorityNameMapping::initializer;
void SourcePriorityNameMapping::AddMapping(const std::string& sourceName,
int sourcePriority)
{
if (sourceName == "")
{
throw Poco::InvalidArgumentException("The source name cannot be empty."); //$NON-NLS-1$
}
if (sourcePrioritiesByName.find(sourceName) == sourcePrioritiesByName.end())
{
sourcePrioritiesByName.insert(std::make_pair(sourceName, sourcePriority));
}
}
int SourcePriorityNameMapping::ComputeSourcePriority(
Expression::ConstPointer expression)
{
int sourcePriority = ISources::WORKBENCH();
if (expression == 0)
{
return sourcePriority;
}
const ExpressionInfo* info = expression->ComputeExpressionInfo();
// Add the default variable, if any.
if (info->HasDefaultVariableAccess())
{
sourcePriority |= ISources::ACTIVE_CURRENT_SELECTION();
}
// Add all of the reference variables.
std::set<std::string> sourceNames = info->GetAccessedVariableNames();
for (std::set<std::string>::iterator iter = sourceNames.begin();
iter != sourceNames.end(); ++iter)
{
sourcePriority |= GetMapping(*iter);
}
return sourcePriority;
}
int SourcePriorityNameMapping::GetMapping(const std::string& sourceName)
{
std::map<std::string, int>::iterator mapping = sourcePrioritiesByName.find(
sourceName);
if (mapping != sourcePrioritiesByName.end())
{
return mapping->second;
}
return NO_SOURCE_PRIORITY();
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berrySourcePriorityNameMapping.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berrySourcePriorityNameMapping.h
index cfdb3af8d8..03353fe3e3 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berrySourcePriorityNameMapping.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berrySourcePriorityNameMapping.h
@@ -1,146 +1,146 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYSOURCEPRIORITYNAMEMAPPING_H_
#define BERRYSOURCEPRIORITYNAMEMAPPING_H_
#include "berryISources.h"
#include <berryExpression.h>
#include <map>
#include <string>
namespace berry {
/**
* <p>
* A static class linking the names of variables in an IEvaluationContext to the
* priority they should be given when doing conflict resolution.
* </p>
* <p>
* In the future, it will possible to define a new variable (i.e., piece of
* application state) that you want to use inside of the
* <code>org.blueberry.ui.contexts</code>, <code>org.blueberry.ui.handlers</code>
* or <code>org.blueberry.ui.menus</code> extension points. As it stands right
* now, it is not possible to run code soon enough for the
* <code>IHandlerService</code>, <code>IMenuService</code> or
* <code>IContextService</code> to become aware of the new variables. This
* will likely be fixed with a new extension point.
* </p>
* <p>
* TODO Move to "org.blueberry.ui" and resolve the above issue.
* </p>
*
* @since 3.2
* @see org.blueberry.ui.ISources
* @see org.blueberry.ui.contexts.IContextService
* @see org.blueberry.ui.handlers.IHandlerService
* @see org.blueberry.ui.menus.IMenuService
*/
class SourcePriorityNameMapping : public ISources {
private:
/**
* The map of source priorities indexed by name. This value is never
* <code>null</code>.
*/
static std::map<std::string,int> sourcePrioritiesByName;
/**
* This class should not be instantiated.
*/
SourcePriorityNameMapping();
public:
/**
* The variable name to use when boosting priority on an activation.
*/
static const std::string LEGACY_LEGACY_NAME(); // = "LEGACY"; //$NON-NLS-1$
/**
* The value returned if there is source priority for the given name
*
* @see SourcePriorityNameMapping#getMapping(String)
*/
static int NO_SOURCE_PRIORITY(); // = 0;
private:
struct Initializer {
Initializer();
};
static Initializer initializer;
public:
/**
* Adds a mapping between a source name and a source priority. This method
* also cleans up any existing mappings using the same name or priority.
* There is a one-to-one relationship between name and priority.
*
* @param sourceName
* The name of the variable as it would appear in an XML
* expression; must not be <code>null</code>.
* @param sourcePriority
* The priority of the source with respect to other sources. A
* higher value means that expressions including this priority
* will win ties more often. It is recommended that this value is
* simply a single bit shifted to a particular place.
* @see ISources
*/
static void AddMapping(const std::string& sourceName,
int sourcePriority);
/**
* Computes the source priority for the given expression. The source
* priority is a bit mask of all of the variables references by the
* expression. The default variable is considered to be
* {@link ISources#ACTIVE_CURRENT_SELECTION}. The source priority is used
* to minimize recomputations of the expression, and it can also be used for
* conflict resolution.
*
* @param expression
* The expression for which the source priority should be
* computed; may be <code>null</code>.
* @return The bit mask of all the sources required for this expression;
* <code>0</code> if none.
*/
static int ComputeSourcePriority(Expression::ConstPointer expression);
/**
* Gets the priority for the source with the given name.
*
* @param sourceName
* The name of the variable as it would appear in an XML
* expression; should not be <code>null</code>.
* @return The source priority that matches, if any;
* <code>NO_SOURCE_PRIORITY</code> if none is found.
*/
static int GetMapping(const std::string& sourceName);
};
}
#endif /* BERRYSOURCEPRIORITYNAMEMAPPING_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryStackablePart.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryStackablePart.cpp
index 2d28bd0c7a..8c5d6ee118 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryStackablePart.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryStackablePart.cpp
@@ -1,171 +1,171 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryStackablePart.h"
#include "berryIStackableContainer.h"
#include "berryDetachedWindow.h"
#include "berryIWorkbenchWindow.h"
#include "tweaklets/berryGuiWidgetsTweaklet.h"
#include "berryImageDescriptor.h"
namespace berry
{
StackablePart::StackablePart(std::string id_)
: id(id_)
{
}
IStackableContainer::Pointer StackablePart::GetContainer() const
{
return container;
}
void StackablePart::SetContainer(IStackableContainer::Pointer container)
{
this->container = container;
}
void StackablePart::Reparent(void* newParent)
{
void* control = this->GetControl();
GuiWidgetsTweaklet* guiTweaklet = Tweaklets::Get(GuiWidgetsTweaklet::KEY);
if ((control == 0) || (guiTweaklet->GetParent(control) == newParent))
{
return;
}
if (guiTweaklet->IsReparentable(control))
{
// make control small in case it is not resized with other controls
//control.setBounds(0, 0, 0, 0);
// By setting the control to disabled before moving it,
// we ensure that the focus goes away from the control and its children
// and moves somewhere else
bool enabled = guiTweaklet->GetEnabled(control);
guiTweaklet->SetEnabled(control, false);
guiTweaklet->SetParent(control, newParent);
guiTweaklet->SetEnabled(control, enabled);
guiTweaklet->MoveAbove(control, 0);
}
}
void StackablePart::DescribeLayout(std::string& /*description*/) const
{
}
std::string StackablePart::GetPlaceHolderId() const
{
return this->GetId();
}
std::string StackablePart::GetId() const
{
return id;
}
void StackablePart::SetId(const std::string& id)
{
this->id = id;
}
void StackablePart::SetFocus()
{
}
void StackablePart::SetBounds(const Rectangle& r)
{
void* ctrl = this->GetControl();
if (ctrl)
{
return Tweaklets::Get(GuiWidgetsTweaklet::KEY)->SetBounds(ctrl, r);
}
}
Rectangle StackablePart::GetBounds()
{
return Rectangle();
}
Point StackablePart::GetSize()
{
Rectangle r = this->GetBounds();
Point ptSize(r.width, r.height);
return ptSize;
}
bool StackablePart::IsDocked()
{
Shell::Pointer s = this->GetShell();
if (s == 0)
{
return false;
}
return s->GetData().Cast<IWorkbenchWindow>() != 0;
}
Shell::Pointer StackablePart::GetShell()
{
void* ctrl = this->GetControl();
if (ctrl)
{
return Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetShell(ctrl);
}
return Shell::Pointer(0);
}
IWorkbenchWindow::Pointer StackablePart::GetWorkbenchWindow()
{
Shell::Pointer s = this->GetShell();
if (s == 0)
{
return IWorkbenchWindow::Pointer(0);
}
Object::Pointer data = s->GetData();
if (data.Cast<IWorkbenchWindow>() != 0)
{
return data.Cast<IWorkbenchWindow>();
}
else if (data.Cast<DetachedWindow>() != 0)
{
return data.Cast<DetachedWindow>()->GetWorkbenchPage()->GetWorkbenchWindow();
}
return IWorkbenchWindow::Pointer(0);
}
std::string StackablePart::GetCompoundId()
{
return this->GetId();
}
bool StackablePart::IsPlaceHolder() const
{
return false;
}
void StackablePart::TestInvariants()
{
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryStackablePart.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryStackablePart.h
index 4f19f3f77e..91d5750f0e 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryStackablePart.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryStackablePart.h
@@ -1,97 +1,97 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYSTACKABLEPART_H_
#define BERRYSTACKABLEPART_H_
#include <berryMacros.h>
#include "berryShell.h"
#include "berryPoint.h"
#include "berryRectangle.h"
#include <string>
namespace berry {
struct IStackableContainer;
struct IWorkbenchWindow;
class StackablePart : public virtual Object
{
public:
berryObjectMacro(StackablePart);
StackablePart(std::string id);
virtual void CreateControl(void* parent) = 0;
virtual void* GetControl() = 0;
virtual SmartPointer<IStackableContainer> GetContainer() const;
virtual void SetContainer(SmartPointer<IStackableContainer> container);
virtual void Reparent(void* newParent);
virtual void DescribeLayout(std::string& description) const;
virtual std::string GetPlaceHolderId() const;
virtual std::string GetId() const;
virtual void SetId(const std::string& id);
/**
* Sets focus to this part.
*/
virtual void SetFocus();
virtual void SetBounds(const Rectangle& bounds);
virtual Rectangle GetBounds();
virtual Point GetSize();
virtual bool IsDocked();
virtual Shell::Pointer GetShell();
SmartPointer<IWorkbenchWindow> GetWorkbenchWindow();
/**
* Returns the compound ID for this part.
* The compound ID is of the form: primaryId [':' + secondaryId]
*
* @return the compound ID for this part.
*/
virtual std::string GetCompoundId();
virtual bool IsPlaceHolder() const;
virtual void TestInvariants();
private:
std::string id;
SmartPointer<IStackableContainer> container;
};
}
#endif /* BERRYSTACKABLEPART_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryStickyViewDescriptor.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryStickyViewDescriptor.cpp
index 1eba1e080d..d3a03d71d0 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryStickyViewDescriptor.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryStickyViewDescriptor.cpp
@@ -1,107 +1,107 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryStickyViewDescriptor.h"
#include "berryWorkbenchRegistryConstants.h"
#include <berryIPageLayout.h>
#include <Poco/String.h>
namespace berry
{
const std::string StickyViewDescriptor::STICKY_FOLDER_RIGHT =
"stickyFolderRight";
const std::string StickyViewDescriptor::STICKY_FOLDER_LEFT = "stickyFolderLeft";
const std::string StickyViewDescriptor::STICKY_FOLDER_TOP = "stickyFolderTop";
const std::string StickyViewDescriptor::STICKY_FOLDER_BOTTOM =
"stickyFolderBottom";
StickyViewDescriptor::StickyViewDescriptor(
IConfigurationElement::Pointer element) throw (CoreException)
{
this->configurationElement = element;
configurationElement->GetAttribute(WorkbenchRegistryConstants::ATT_ID, id);
if (id.empty())
{
//TODO IStatus
// throw new CoreException(new Status(IStatus.ERROR, element .getNamespace(),
// 0, "Invalid extension (missing id) ", null));//$NON-NLS-1$
throw CoreException(element->GetContributor() + ": Invalid extension (missing id)");
}
}
IConfigurationElement::Pointer StickyViewDescriptor::GetConfigurationElement() const
{
return configurationElement;
}
int StickyViewDescriptor::GetLocation() const
{
int direction = IPageLayout::RIGHT;
std::string location;
configurationElement->GetAttribute(
WorkbenchRegistryConstants::ATT_LOCATION, location);
if (!location.empty())
{
if (Poco::icompare(location, "left") == 0)
{
direction = IPageLayout::LEFT;
}
else if (Poco::icompare(location, "top") == 0)
{
direction = IPageLayout::TOP;
}
else if (Poco::icompare(location, "bottom") == 0)
{
direction = IPageLayout::BOTTOM;
//no else for right - it is the default value;
}
}
return direction;
}
std::string StickyViewDescriptor::GetId() const
{
return id;
}
bool StickyViewDescriptor::IsCloseable() const
{
bool closeable = true;
std::string closeableString;
configurationElement->GetAttribute(
WorkbenchRegistryConstants::ATT_CLOSEABLE, closeableString);
closeable = closeableString != "false";
return closeable;
}
bool StickyViewDescriptor::IsMoveable() const
{
bool moveable = true;
std::string moveableString;
configurationElement->GetAttribute(
WorkbenchRegistryConstants::ATT_MOVEABLE, moveableString);
moveable = moveableString != "false";
return moveable;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryStickyViewDescriptor.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryStickyViewDescriptor.h
index 6a16269917..e3f366be1a 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryStickyViewDescriptor.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryStickyViewDescriptor.h
@@ -1,97 +1,97 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYSTICKYVIEWDESCRIPTOR_H_
#define BERRYSTICKYVIEWDESCRIPTOR_H_
#include "berryIStickyViewDescriptor.h"
#include <berryIConfigurationElement.h>
namespace berry
{
class StickyViewDescriptor: public IStickyViewDescriptor
{
private:
IConfigurationElement::Pointer configurationElement;
std::string id;
public:
berryObjectMacro(StickyViewDescriptor)
/**
* Folder constant for right sticky views.
*/
static const std::string STICKY_FOLDER_RIGHT; // = "stickyFolderRight"; //$NON-NLS-1$
/**
* Folder constant for left sticky views.
*/
static const std::string STICKY_FOLDER_LEFT; // = "stickyFolderLeft"; //$NON-NLS-1$
/**
* Folder constant for top sticky views.
*/
static const std::string STICKY_FOLDER_TOP; // = "stickyFolderTop"; //$NON-NLS-1$
/**
* Folder constant for bottom sticky views.
*/
static const std::string STICKY_FOLDER_BOTTOM; // = "stickyFolderBottom"; //$NON-NLS-1$
/**
* @param element
* @throws CoreException
*/
StickyViewDescriptor(IConfigurationElement::Pointer element)
throw (CoreException);
/**
* Return the configuration element.
*
* @return the configuration element
*/
IConfigurationElement::Pointer GetConfigurationElement() const;
/*
* @see IStickyViewDescriptor#GetLocation()
*/
int GetLocation() const;
/*
* @see IStickyViewDescriptor#GetId()
*/
std::string GetId() const;
/*
* @see IStickyViewDescriptor#IsFixed()
*/
bool IsCloseable() const;
/*
* @see IStickyViewDescriptor#IsMoveable()
*/
bool IsMoveable() const;
};
}
#endif /* BERRYSTICKYVIEWDESCRIPTOR_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryStickyViewManager.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryStickyViewManager.cpp
index e14b50c197..b7757c9da7 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryStickyViewManager.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryStickyViewManager.cpp
@@ -1,110 +1,110 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryStickyViewManager.h"
#include "berryPerspective.h"
#include "berryWorkbenchPlugin.h"
#include <berryIStickyViewDescriptor.h>
#include <berryIWorkbenchPage.h>
namespace berry
{
StickyViewManager::StickyViewManager(IWorkbenchPage* page) :
page(page)
{
}
IStickyViewManager::Pointer StickyViewManager::GetInstance(IWorkbenchPage* page)
{
IStickyViewManager::Pointer stickyViewMan;
// IPreferenceStore preferenceStore = PrefUtil.getAPIPreferenceStore();
// boolean enable32Behavior = preferenceStore
// .getBoolean(IWorkbenchPreferenceConstants.ENABLE_32_STICKY_CLOSE_BEHAVIOR);
// if (enable32Behavior)
// stickyViewMan = new StickyViewManager32(page);
// else
stickyViewMan = IStickyViewManager::Pointer(new StickyViewManager(page));
return stickyViewMan;
}
void StickyViewManager::Add(const std::string& /*perspectiveId*/, const std::set<std::string>& /*stickyViewSet*/)
{
// do nothing
}
void StickyViewManager::Clear()
{
// do nothing
}
void StickyViewManager::Remove(const std::string& /*perspectiveId*/)
{
// do nothing
}
void StickyViewManager::Restore(IMemento::Pointer /*memento*/)
{
// do nothing
}
void StickyViewManager::Save(IMemento::Pointer /*memento*/)
{
// do nothing
}
void StickyViewManager::Update(Perspective::Pointer oldPersp,
Perspective::Pointer newPersp)
{
if (oldPersp == 0 || newPersp == 0)
{
return;
}
IViewRegistry* viewReg = WorkbenchPlugin::GetDefault()->GetViewRegistry();
std::vector<IStickyViewDescriptor::Pointer> stickyDescs(
viewReg->GetStickyViews());
for (std::size_t i = 0; i < stickyDescs.size(); i++)
{
const std::string viewId = stickyDescs[i]->GetId();
try
{
// show a sticky view if it was in the last perspective and
// hasn't already been activated in this one
if (oldPersp->FindView(viewId))
{
page->ShowView(viewId, "", IWorkbenchPage::VIEW_CREATE);
}
// remove a view if it's sticky and its not visible in the old
// perspective
else if (newPersp->FindView(viewId) && oldPersp->FindView(viewId) == 0)
{
page->HideView(newPersp->FindView(viewId));
}
} catch (PartInitException& e)
{
//TODO IStatus
// WorkbenchPlugin::Log(
// "Could not open view :" + viewId, new Status(IStatus.ERROR, WorkbenchPlugin.PI_WORKBENCH, IStatus.ERROR, "Could not open view :" + viewId, e)); //$NON-NLS-1$ //$NON-NLS-2$
WorkbenchPlugin::Log("Could not open view: " + viewId, e);
}
}
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryStickyViewManager.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryStickyViewManager.h
index 789924fc51..a96d3a5398 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryStickyViewManager.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryStickyViewManager.h
@@ -1,87 +1,87 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYSTICKYVIEWMANAGER_H_
#define BERRYSTICKYVIEWMANAGER_H_
#include "berryIStickyViewManager.h"
namespace berry {
struct IWorkbenchPage;
class StickyViewManager : public IStickyViewManager {
private:
IWorkbenchPage* page;
public:
StickyViewManager(IWorkbenchPage* page);
static IStickyViewManager::Pointer GetInstance(IWorkbenchPage* page);
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.internal.IStickyViewManager#add(java.lang.String,
* java.util.Set)
*/
void Add(const std::string& perspectiveId, const std::set<std::string>& stickyViewSet);
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.internal.IStickyViewManager#clear()
*/
void Clear();
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.internal.IStickyViewManager#remove(java.lang.String)
*/
void Remove(const std::string& perspectiveId);
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.internal.IStickyViewManager#restore(org.eclipse.ui.IMemento)
*/
void Restore(IMemento::Pointer memento);
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.internal.IStickyViewManager#save(org.eclipse.ui.IMemento)
*/
void Save(IMemento::Pointer memento);
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.internal.IStickyViewManager#update(org.eclipse.ui.internal.Perspective,
* org.eclipse.ui.internal.Perspective)
*/
void Update(SmartPointer<Perspective> oldPersp, SmartPointer<Perspective> newPersp);
};
}
#endif /* BERRYSTICKYVIEWMANAGER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryTestDropLocation.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryTestDropLocation.h
index de88de0d2d..813fbf9a2e 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryTestDropLocation.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryTestDropLocation.h
@@ -1,58 +1,58 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYTESTDROPLOCATION_H_
#define BERRYTESTDROPLOCATION_H_
#include <berryObject.h>
#include "berryPoint.h"
#include "berryShell.h"
#include <vector>
namespace berry {
/**
* This is an interface intended for use in test suites. Objects can implement
* this interface to force any dragged object to be dropped at a particular
* location.
*
* @since 3.0
*/
struct TestDropLocation : public Object {
berryObjectMacro(TestDropLocation);
/**
* Location where the object should be dropped, in display coordinates
*
* @return a location in display coordinates
*/
virtual Point GetLocation() = 0;
/**
* The drop code will pretend that only the given shells are open,
* and that they have the specified Z-order.
*
* @return the shells to check for drop targets, from bottom to top.
*/
virtual std::vector<Shell::Pointer> GetShells() = 0;
};
}
#endif /* BERRYTESTDROPLOCATION_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryTweaklets.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryTweaklets.cpp
index 1b307f39e7..c2f47b89c9 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryTweaklets.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryTweaklets.cpp
@@ -1,61 +1,61 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryTweaklets.h"
namespace berry
{
QHash<TweakKey_base, QObject*> Tweaklets::defaults;
QHash<TweakKey_base, QObject*> Tweaklets::tweaklets;
TweakKey_base::TweakKey_base(const QString& _tweakClass) :
tweakClass(_tweakClass)
{ }
bool TweakKey_base::operator==(const TweakKey_base& obj) const
{
if (this == &obj)
return true;
return tweakClass == obj.tweakClass;
}
bool TweakKey_base::operator<(const TweakKey_base& obj) const
{
return tweakClass < obj.tweakClass;
}
void Tweaklets::SetDefault(const TweakKey_base& definition,
QObject* implementation)
{
defaults.insert(definition, implementation);
}
void Tweaklets::Clear()
{
// BERRY_DEBUG << "Clearing tweaklets";
tweaklets.clear();
defaults.clear();
}
}
uint qHash(const berry::TweakKey_base& key)
{
return qHash(key.tweakClass);
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryTweaklets.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryTweaklets.h
index 12c6434ff7..1e1d4c1157 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryTweaklets.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryTweaklets.h
@@ -1,156 +1,156 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYTWEAKLETS_H_
#define BERRYTWEAKLETS_H_
#include <org_blueberry_ui_Export.h>
#include <QString>
namespace berry {
struct BERRY_UI TweakKey_base
{
QString tweakClass;
/**
* @param tweakClass
*/
TweakKey_base(const QString& _tweakClass);
bool operator==(const TweakKey_base& obj) const;
bool operator<(const TweakKey_base& obj) const;
};
}
BERRY_UI uint qHash(const berry::TweakKey_base& key);
#include <berryIConfigurationElement.h>
#include <berryIExtensionPointService.h>
#include <berryPlatform.h>
namespace berry {
class BERRY_UI Tweaklets
{
public:
template<typename I>
struct TweakKey: public TweakKey_base
{
TweakKey() :
TweakKey_base("")
{
tweakClass = QString(qobject_interface_iid<I*>());
}
TweakKey(const QString& _tweakClass) :
TweakKey_base(_tweakClass)
{
}
};
static void SetDefault(const TweakKey_base& definition,
QObject* implementation);
static void Clear();
template<typename I>
static I* Get(const TweakKey<I>& definition)
{
TweakletMap::const_iterator iter = tweaklets.find(definition);
QObject* result;
if (iter == tweaklets.end())
{
result = CreateTweaklet(definition);
if (result == 0)
{
result = GetDefault(definition);
}
Q_ASSERT(result != 0);
tweaklets.insert(definition, result);
return qobject_cast<I*>(result);
}
return qobject_cast<I*>(iter.value());
}
private:
typedef QHash<TweakKey_base, QObject*> TweakletMap;
static TweakletMap defaults;
static TweakletMap tweaklets;
/**
* @param definition
* @return
*/
template<typename I>
static QObject* GetDefault(const TweakKey<I>& definition)
{
TweakletMap::const_iterator iter = defaults.find(definition);
if (iter == defaults.end())
return 0;
return iter.value();
}
/**
* @param definition
* @return
*/
template<typename I>
static QObject* CreateTweaklet(const TweakKey<I>& definition)
{
std::vector<IConfigurationElement::Pointer> elements =
Platform::GetExtensionPointService()
->GetConfigurationElementsFor("org.blueberry.ui.tweaklets"); //$NON-NLS-1$
for (unsigned int i = 0; i < elements.size(); i++)
{
std::string attr;
if (elements[i]->GetAttribute("definition", attr) &&
definition.tweakClass == QString::fromStdString(attr))
{
try
{
QObject* tweaklet = elements[i]->CreateExecutableExtension<QObject>("implementation");
tweaklets.insert(definition, tweaklet);
return tweaklet;
}
catch (CoreException e)
{
//StatusManager.getManager().handle(
// StatusUtil.newStatus(IStatus.ERR,
BERRY_ERROR << "Error with extension " << elements[i] << e.what();
// StatusManager.LOG);
}
}
}
return 0;
}
};
}
#endif /* BERRYTWEAKLETS_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryUtil.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryUtil.h
index 959e2bb8ce..e9058d9945 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryUtil.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryUtil.h
@@ -1,88 +1,88 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYUTIL_H_
#define BERRYUTIL_H_
namespace berry
{
class Util
{
public:
/**
* If it is possible to adapt the given object to the given type, this
* returns the adapter. Performs the following checks:
*
* <ol>
* <li>Returns <code>sourceObject</code> if it is an instance of the
* adapter type.</li>
* <li>If sourceObject implements IAdaptable, it is queried for adapters.</li>
* <li>If sourceObject is not an instance of PlatformObject (which would have
* already done so), the adapter manager is queried for adapters</li>
* </ol>
*
* Otherwise returns null.
*
* @param sourceObject
* object to adapt, or null
* @param adapterType
* type to adapt to
* @return a representation of sourceObject that is assignable to the
* adapter type, or null if no such representation exists
*/
template<class A>
static A* GetAdapter(Object::Pointer sourceObject)
{
if (sourceObject == 0)
{
return 0;
}
if (A* adapter = dynamic_cast<A*>(sourceObject.GetPointer()))
{
return adapter;
}
if (/*IAdaptable* adaptable =*/ dynamic_cast<IAdaptable*>(sourceObject.GetPointer()))
{
// TODO IAdaptable
// IAdaptable adaptable = (IAdaptable) sourceObject;
//
// Object result = adaptable.getAdapter(adapterType);
// if (result != null) {
// // Sanity-check
// Assert.isTrue(adapterType.isInstance(result));
// return result;
// }
return 0;
}
// if (!(sourceObject instanceof PlatformObject)) {
// Object result = Platform.getAdapterManager().getAdapter(sourceObject, adapterType);
// if (result != null) {
// return result;
// }
// }
return 0;
}
};
}
#endif /* BERRYUTIL_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewDescriptor.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewDescriptor.cpp
index 34abb7b249..827edcc6c7 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewDescriptor.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewDescriptor.cpp
@@ -1,213 +1,213 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryViewDescriptor.h"
#include "service/berryIConfigurationElement.h"
#include "berryPlatformException.h"
#include "berryRegistryReader.h"
#include "berryWorkbenchRegistryConstants.h"
#include "berryImageDescriptor.h"
#include "berryAbstractUIPlugin.h"
#include "berryAbstractUICTKPlugin.h"
#include "berryImageDescriptor.h"
#include "handlers/berryIHandlerActivation.h"
#include <Poco/String.h>
#include <Poco/StringTokenizer.h>
namespace berry
{
ViewDescriptor::ViewDescriptor(IConfigurationElement::Pointer e) :
configElement(e)
{
this->LoadFromExtension();
}
IViewPart::Pointer ViewDescriptor::CreateView()
{
IViewPart::Pointer part(configElement->CreateExecutableExtension<IViewPart> (
WorkbenchRegistryConstants::ATT_CLASS));
if (part.IsNull())
{
// support legacy BlueBerry extensions
part = configElement->CreateExecutableExtension<IViewPart> (
WorkbenchRegistryConstants::ATT_CLASS, IViewPart::GetManifestName());
}
return part;
}
const std::vector<std::string>& ViewDescriptor::GetCategoryPath() const
{
return categoryPath;
}
IConfigurationElement::Pointer ViewDescriptor::GetConfigurationElement() const
{
return configElement;
}
std::string ViewDescriptor::GetDescription() const
{
return RegistryReader::GetDescription(configElement);
}
std::string ViewDescriptor::GetId() const
{
return id;
}
bool ViewDescriptor::operator==(const Object* o) const
{
if (const IViewDescriptor* other = dynamic_cast<const IViewDescriptor*>(o))
return this->GetId() == other->GetId();
return false;
}
ImageDescriptor::Pointer ViewDescriptor::GetImageDescriptor() const
{
if (imageDescriptor)
{
return imageDescriptor;
}
std::string iconName;
configElement->GetAttribute(WorkbenchRegistryConstants::ATT_ICON, iconName);
// If the icon attribute was omitted, use the default one
if (iconName.empty())
{
//TODO default image descriptor
//return PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_DEF_VIEW);
return ImageDescriptor::GetMissingImageDescriptor();
}
const IExtension* extension(configElement->GetDeclaringExtension());
const std::string extendingPluginId(extension->GetNamespace());
imageDescriptor = AbstractUICTKPlugin::ImageDescriptorFromPlugin(
extendingPluginId, iconName);
if (!imageDescriptor)
{
// Try legacy BlueBerry method
imageDescriptor = AbstractUIPlugin::ImageDescriptorFromPlugin(
extendingPluginId, iconName);
}
// If the icon attribute was invalid, use the error icon
if (!imageDescriptor)
{
imageDescriptor = ImageDescriptor::GetMissingImageDescriptor();
}
return imageDescriptor;
}
std::string ViewDescriptor::GetLabel() const
{
std::string label;
configElement->GetAttribute(WorkbenchRegistryConstants::ATT_NAME, label);
return label;
}
std::string ViewDescriptor::GetAccelerator() const
{
std::string accel;
configElement->GetAttribute(WorkbenchRegistryConstants::ATT_ACCELERATOR, accel);
return accel;
}
bool ViewDescriptor::GetAllowMultiple() const
{
bool allow = false;
configElement->GetBoolAttribute(WorkbenchRegistryConstants::ATT_ALLOW_MULTIPLE, allow);
return allow;
}
bool ViewDescriptor::IsRestorable() const {
std::string string;
if (configElement->GetAttribute(WorkbenchRegistryConstants::ATT_RESTORABLE, string))
{
return Poco::icompare(string, "true") == 0;
}
else {
return true;
}
}
Poco::Any ViewDescriptor::GetAdapter(const std::string& adapter)
{
if (adapter == IConfigurationElement::GetStaticClassName())
{
return Poco::Any(GetConfigurationElement());
}
return Poco::Any();
}
void
ViewDescriptor::ActivateHandler()
{
//TODO ViewDescriptor handler activation
// if (!handlerActivation)
// {
// IHandler::Pointer handler(new ShowViewHandler(this->GetId()));
// IHandlerService::Pointer handlerService(
// PlatformUI::GetWorkbench()->GetService(IHandlerService::GetManifestName()).Cast<IHandlerService>());
// handlerActivation = handlerService
// ->ActivateHandler(this->GetId(), handler);
// }
}
void
ViewDescriptor::DeactivateHandler()
{
//TODO ViewDescriptor handler deactivation
// if (handlerActivation)
// {
// IHandlerService::Pointer handlerService(
// PlatformUI::GetWorkbench()->GetService(IHandlerService::GetManifestName()).Cast<IHandlerService>());
// handlerService->DeactivateHandler(handlerActivation);
// handlerActivation = 0;
// }
}
void ViewDescriptor::LoadFromExtension()
{
configElement->GetAttribute(WorkbenchRegistryConstants::ATT_ID, id);
// Sanity check.
std::string name;
if ((configElement->GetAttribute(WorkbenchRegistryConstants::ATT_NAME, name) == false)
|| (RegistryReader::GetClassValue(configElement,
WorkbenchRegistryConstants::ATT_CLASS) == ""))
{
throw CoreException(
"Invalid extension (missing label or class name)", id);
}
std::string category;
if (configElement->GetAttribute(WorkbenchRegistryConstants::TAG_CATEGORY, category))
{
Poco::StringTokenizer stok(category, "/", Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM);
// Parse the path tokens and store them
for (Poco::StringTokenizer::Iterator iter = stok.begin(); iter != stok.end(); ++iter)
{
categoryPath.push_back(*iter);
}
}
}
} // namespace berry
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewDescriptor.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewDescriptor.h
index 783ba425e1..16d8c2a3a5 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewDescriptor.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewDescriptor.h
@@ -1,152 +1,152 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYVIEWDESCRIPTOR_H_
#define BERRYVIEWDESCRIPTOR_H_
#include "berryIViewPart.h"
#include "berryIViewDescriptor.h"
#include "service/berryIConfigurationElement.h"
#include <string>
#include <vector>
namespace berry
{
struct IHandlerActivation;
/**
* \ingroup org_blueberry_ui_internal
*
*/
class ViewDescriptor : public IViewDescriptor
{
private:
std::string id;
mutable SmartPointer<ImageDescriptor> imageDescriptor;
IConfigurationElement::Pointer configElement;
std::vector<std::string> categoryPath;
/**
* The activation token returned when activating the show view handler with
* the workbench.
*/
SmartPointer<IHandlerActivation> handlerActivation;
public:
berryObjectMacro(ViewDescriptor)
/**
* Create a new <code>ViewDescriptor</code> for an extension.
*
* @param e the configuration element
* @throws CoreException thrown if there are errors in the configuration
*/
ViewDescriptor(IConfigurationElement::Pointer e);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.registry.IViewDescriptor#createView()
*/
IViewPart::Pointer CreateView();
/* (non-Javadoc)
* @see org.blueberry.ui.internal.registry.IViewDescriptor#getCategoryPath()
*/
const std::vector<std::string>& GetCategoryPath() const;
/**
* Return the configuration element for this descriptor.
*
* @return the configuration element
*/
IConfigurationElement::Pointer GetConfigurationElement() const;
/* (non-Javadoc)
* @see org.blueberry.ui.internal.registry.IViewDescriptor#getDescription()
*/
std::string GetDescription() const;
/* (non-Javadoc)
* @see org.blueberry.ui.IWorkbenchPartDescriptor#getId()
*/
std::string GetId() const;
/* (non-Javadoc)
* @see org.blueberry.ui.IWorkbenchPartDescriptor#getImageDescriptor()
*/
SmartPointer<ImageDescriptor> GetImageDescriptor() const;
/* (non-Javadoc)
* @see org.blueberry.ui.IWorkbenchPartDescriptor#getLabel()
*/
std::string GetLabel() const;
/**
* Return the accelerator attribute.
*
* @return the accelerator attribute
*/
std::string GetAccelerator() const;
/* (non-Javadoc)
* @see org.blueberry.ui.internal.registry.IViewDescriptor#getAllowMultiple()
*/
bool GetAllowMultiple() const;
/* (non-Javadoc)
* @see org.eclipse.ui.views.IViewDescriptor#getRestorable()
*/
bool IsRestorable() const;
bool operator==(const Object*) const;
/**
* Activates a show view handler for this descriptor. This handler can later
* be deactivated by calling {@link ViewDescriptor#deactivateHandler()}.
* This method will only activate the handler if it is not currently active.
*
*/
void ActivateHandler();
/**
* Deactivates the show view handler for this descriptor. This handler was
* previously activated by calling {@link ViewDescriptor#activateHandler()}.
* This method will only deactivative the handler if it is currently active.
*
*/
void DeactivateHandler();
protected:
/* (non-Javadoc)
* @see IAdaptable#GetAdapterImpl(const std::type_info&)
*/
Poco::Any GetAdapter(const std::string& adapter);
private:
/**
* load a view descriptor from the registry.
*/
void LoadFromExtension();
};
}
#endif /*BERRYVIEWDESCRIPTOR_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewFactory.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewFactory.cpp
index 5c06bc7c9b..e33822879e 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewFactory.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewFactory.cpp
@@ -1,324 +1,324 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryViewFactory.h"
#include "berryUIException.h"
#include "berryIViewRegistry.h"
#include "berryImageDescriptor.h"
#include "berryViewReference.h"
#include "berryViewDescriptor.h"
#include "berryWorkbenchPage.h"
#include "berryWorkbenchConstants.h"
#include "util/berrySafeRunnable.h"
#include <berrySafeRunner.h>
namespace berry
{
const std::string ViewFactory::ID_SEP = ":"; //$NON-NLS-1$
std::string ViewFactory::GetKey(const std::string& id,
const std::string& secondaryId)
{
return secondaryId.empty() ? id : id + ID_SEP + secondaryId;
}
std::string ViewFactory::GetKey(IViewReference::Pointer viewRef)
{
return GetKey(viewRef->GetId(), viewRef->GetSecondaryId());
}
std::string ViewFactory::ExtractPrimaryId(const std::string& compoundId)
{
std::string::size_type i = compoundId.find_last_of(ID_SEP);
if (i == std::string::npos)
{
return compoundId;
}
return compoundId.substr(0, i);
}
std::string ViewFactory::ExtractSecondaryId(const std::string& compoundId)
{
std::string::size_type i = compoundId.find_last_of(ID_SEP);
if (i == std::string::npos)
{
return "";
}
return compoundId.substr(i + 1);
}
bool ViewFactory::HasWildcard(const std::string& viewId)
{
return viewId.find_first_of('*') != std::string::npos;
}
ViewFactory::ViewFactory(WorkbenchPage* p, IViewRegistry* reg) :
page(p), viewReg(reg)
{
//page.getExtensionTracker().registerHandler(this, null);
}
IViewReference::Pointer ViewFactory::CreateView(const std::string& id,
const std::string& secondaryId)
{
IViewDescriptor::Pointer desc = viewReg->Find(id);
// ensure that the view id is valid
if (desc.IsNull())
{
throw PartInitException("Could not create view", id);
}
// ensure that multiple instances are allowed if a secondary id is given
if (secondaryId != "")
{
if (!desc->GetAllowMultiple())
{
throw PartInitException("View does not allow multiple instances", id);
}
}
std::string key = this->GetKey(id, secondaryId);
IViewReference::Pointer ref = counter.Get(key);
if (ref.IsNull())
{
IMemento::Pointer memento = mementoTable[key];
ref = new ViewReference(this, id, secondaryId, memento);
mementoTable.erase(key);
counter.Put(key, ref);
this->GetWorkbenchPage()->PartAdded(ref.Cast<ViewReference> ());
}
else
{
counter.AddRef(key);
}
return ref;
}
std::vector<IViewReference::Pointer> ViewFactory::GetViewReferences()
{
std::vector<IViewReference::Pointer> values(counter.Values());
return values;
}
IViewReference::Pointer ViewFactory::GetView(const std::string& id)
{
return this->GetView(id, "");
}
IViewReference::Pointer ViewFactory::GetView(const std::string& id,
const std::string& secondaryId)
{
std::string key = this->GetKey(id, secondaryId);
return counter.Get(key);
}
const IViewRegistry* ViewFactory::GetViewRegistry() const
{
return viewReg;
}
std::vector<IViewReference::Pointer> ViewFactory::GetViews()
{
std::vector<IViewReference::Pointer> values(counter.Values());
return values;
}
WorkbenchPage* ViewFactory::GetWorkbenchPage() const
{
return page;
}
int ViewFactory::GetReferenceCount(IViewReference::Pointer viewRef)
{
std::string key = this->GetKey(viewRef);
IViewReference::Pointer ref = counter.Get(key);
return ref.IsNull() ? 0 : counter.GetRef(key);
}
void ViewFactory::ReleaseView(IViewReference::Pointer viewRef)
{
std::string key = this->GetKey(viewRef);
IViewReference::Pointer ref = counter.Get(key);
if (ref.IsNull())
{
return;
}
int count = counter.RemoveRef(key);
if (count <= 0)
{
this->GetWorkbenchPage()->PartRemoved(ref.Cast<ViewReference> ());
}
}
bool ViewFactory::RestoreState(IMemento::Pointer memento)
{
std::vector<IMemento::Pointer> mem(memento->GetChildren(
WorkbenchConstants::TAG_VIEW));
for (std::size_t i = 0; i < mem.size(); i++)
{
//for dynamic UI - add the next line to replace subsequent code that is commented out
RestoreViewState(mem[i]);
}
// return new Status(IStatus.OK, PlatformUI.PLUGIN_ID, 0, "", null); //$NON-NLS-1$
return true;
}
bool ViewFactory::SaveState(IMemento::Pointer memento)
{
// final MultiStatus result = new MultiStatus(PlatformUI.PLUGIN_ID,
// IStatus.OK, WorkbenchMessages.ViewFactory_problemsSavingViews, null);
bool result = true;
std::vector<IViewReference::Pointer> refs(GetViews());
for (std::size_t i = 0; i < refs.size(); i++)
{
IViewDescriptor::Pointer desc = viewReg->Find(refs[i]->GetId());
if (desc->IsRestorable())
{
//for dynamic UI - add the following line to replace subsequent code which is commented out
SaveViewState(memento, refs[i], result);
}
}
return result;
}
struct SaveViewRunnable: public SafeRunnable
{
SaveViewRunnable(IViewPart::Pointer view, IMemento::Pointer viewMemento,
bool& result) :
view(view), viewMemento(viewMemento), result(result)
{
}
void Run()
{
const std::map<std::string, std::string>& properties =
view->GetPartProperties();
if (!properties.empty())
{
IMemento::Pointer propBag = viewMemento ->CreateChild(
WorkbenchConstants::TAG_PROPERTIES);
for (std::map<std::string, std::string>::const_iterator i =
properties.begin(); i != properties.end(); ++i)
{
IMemento::Pointer p = propBag->CreateChild(
WorkbenchConstants::TAG_PROPERTY, i->first);
p->PutTextData(i->second);
}
}
view->SaveState(viewMemento ->CreateChild(
WorkbenchConstants::TAG_VIEW_STATE));
}
void HandleException(const std::exception& /*e*/)
{
// result
// .add(new Status(
// IStatus.ERR,
// PlatformUI.PLUGIN_ID,
// 0,
// NLS.bind(WorkbenchMessages.ViewFactory_couldNotSave, viewRef.getTitle() ),
// e));
result = false;
}
private:
IViewPart::Pointer view;
IMemento::Pointer viewMemento;
bool& result;
};
// for dynamic UI
IMemento::Pointer ViewFactory::SaveViewState(IMemento::Pointer memento,
IViewReference::Pointer ref, bool& res)
{
//final MultiStatus result = res;
bool& result = res;
IMemento::Pointer viewMemento = memento->CreateChild(
WorkbenchConstants::TAG_VIEW);
viewMemento->PutString(WorkbenchConstants::TAG_ID, ViewFactory::GetKey(ref));
if (ViewReference::Pointer viewRef = ref.Cast<ViewReference>())
{
viewMemento->PutString(WorkbenchConstants::TAG_PART_NAME,
viewRef->GetPartName());
}
const IViewReference::Pointer viewRef = ref;
const IViewPart::Pointer view = ref->GetPart(false).Cast<IViewPart> ();
if (view)
{
ISafeRunnable::Pointer runnable(new SaveViewRunnable(view, viewMemento,
result));
SafeRunner::Run(runnable);
}
else
{
IMemento::Pointer mem;
IMemento::Pointer props;
// if we've created the reference once, any previous workbench
// state memento is there. After once, there is no previous
// session state, so it should be null.
if (ref.Cast<ViewReference> ())
{
mem = ref.Cast<ViewReference> ()->GetMemento();
if (mem)
{
props = mem->GetChild(WorkbenchConstants::TAG_PROPERTIES);
mem = mem->GetChild(WorkbenchConstants::TAG_VIEW_STATE);
}
}
if (props)
{
viewMemento->CreateChild(WorkbenchConstants::TAG_PROPERTIES) ->PutMemento(
props);
}
if (mem)
{
IMemento::Pointer child = viewMemento ->CreateChild(
WorkbenchConstants::TAG_VIEW_STATE);
child->PutMemento(mem);
}
}
return viewMemento;
}
// for dynamic UI
void ViewFactory::RestoreViewState(IMemento::Pointer memento)
{
std::string compoundId;
memento->GetString(WorkbenchConstants::TAG_ID, compoundId);
mementoTable.insert(std::make_pair(compoundId, memento));
}
IMemento::Pointer ViewFactory::GetViewState(const std::string& key)
{
IMemento::Pointer memento = mementoTable[key];
if (!memento)
return IMemento::Pointer(0);
return memento->GetChild(WorkbenchConstants::TAG_VIEW_STATE);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewFactory.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewFactory.h
index 5aeaea359b..fc8e7bd013 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewFactory.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewFactory.h
@@ -1,194 +1,194 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYVIEWFACTORY_H_
#define BERRYVIEWFACTORY_H_
#include <berrySmartPointer.h>
#include "berryIMemento.h"
#include "berryIViewReference.h"
#include "berryReferenceCounter.h"
#include <map>
#include <vector>
namespace berry {
class WorkbenchPage;
struct IViewRegistry;
/**
* \ingroup org_blueberry_ui_internal
*
* The ViewFactory is used to control the creation and disposal of views.
* It implements a reference counting strategy so that one view can be shared
* by more than one client.
*/
class ViewFactory { // implements IExtensionChangeHandler {
private:
std::map<std::string, IMemento::Pointer> mementoTable;
ReferenceCounter<std::string, IViewReference::Pointer> counter;
WorkbenchPage* page;
IViewRegistry* viewReg;
public:
/**
* Separates a view's primary id from its secondary id in view key strings.
*/
static const std::string ID_SEP; // = ":"; //$NON-NLS-1$
/**
* Returns a string representing a view with the given id and (optional) secondary id,
* suitable for use as a key in a map.
*
* @param id primary id of the view
* @param secondaryId secondary id of the view or <code>null</code>
* @return the key
*/
static std::string GetKey(const std::string& id, const std::string& secondaryId);
/**
* Returns a string representing the given view reference, suitable for use as a key in a map.
*
* @param viewRef the view reference
* @return the key
*/
static std::string GetKey(IViewReference::Pointer viewRef);
/**
* Extracts ths primary id portion of a compound id.
* @param compoundId a compound id of the form: primaryId [':' secondaryId]
* @return the primary id
*/
static std::string ExtractPrimaryId(const std::string& compoundId);
/**
* Extracts ths secondary id portion of a compound id.
* @param compoundId a compound id of the form: primaryId [':' secondaryId]
* @return the secondary id, or <code>null</code> if none
*/
static std::string ExtractSecondaryId(const std::string& compoundId);
/**
* Returns whether the given view id contains a wildcard. Wildcards cannot
* be used in regular view ids, only placeholders.
*
* @param viewId the view id
* @return <code>true</code> if the given view id contains a wildcard,
* <code>false</code> otherwise
*
* @since 3.1
*/
static bool HasWildcard(const std::string& viewId);
/**
* Constructs a new view factory.
*/
ViewFactory(WorkbenchPage* page, IViewRegistry* reg);
/**
* Creates an instance of a view defined by id and secondary id.
*
* This factory implements reference counting. The first call to this
* method will return a new view. Subsequent calls will return the
* first view with an additional reference count. The view is
* disposed when releaseView is called an equal number of times
* to createView.
*/
IViewReference::Pointer CreateView(const std::string& id, const std::string& secondaryId = "");
/**
* Returns the set of views being managed by this factory
*
* @return the set of views being managed by this factory
*/
std::vector<IViewReference::Pointer> GetViewReferences();
/**
* Returns the view with the given id, or <code>null</code> if not found.
*/
IViewReference::Pointer GetView(const std::string& id);
/**
* Returns the view with the given id and secondary id, or <code>null</code> if not found.
*/
IViewReference::Pointer GetView(const std::string& id, const std::string& secondaryId);
/**
* @return the <code>IViewRegistry</code> used by this factory.
* @since 3.0
*/
const IViewRegistry* GetViewRegistry() const;
/**
* Returns a list of views which are open.
*/
std::vector<IViewReference::Pointer> GetViews();
/**
* @return the <code>WorkbenchPage</code> used by this factory.
* @since 3.0
*/
WorkbenchPage* GetWorkbenchPage() const;
int GetReferenceCount(IViewReference::Pointer viewRef);
/**
* Releases an instance of a view.
*
* This factory does reference counting. For more info see
* getView.
*/
void ReleaseView(IViewReference::Pointer viewRef);
/**
* Restore view states.
*
* @param memento the <code>IMemento</code> to restore from.
* @return <code>IStatus</code>
*/
/*IStatus*/bool RestoreState(IMemento::Pointer memento);
/**
* Save view states.
*
* @param memento the <code>IMemento</code> to save to.
* @return <code>IStatus</code>
*/
/*IStatus*/bool SaveState(IMemento::Pointer memento);
// for dynamic UI
IMemento::Pointer SaveViewState(IMemento::Pointer memento, IViewReference::Pointer ref, bool& res);
// for dynamic UI
void RestoreViewState(IMemento::Pointer memento);
IMemento::Pointer GetViewState(const std::string& key);
};
}
#endif /*BERRYVIEWFACTORY_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewLayout.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewLayout.cpp
index cbcd680670..e1a6de9794 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewLayout.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewLayout.cpp
@@ -1,61 +1,61 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryViewLayout.h"
#include "berryImageDescriptor.h"
namespace berry
{
ViewLayout::ViewLayout(PageLayout::Pointer pageLayout, ViewLayoutRec::Pointer r) :
rec(r)
{
poco_assert(pageLayout != 0);
poco_assert(rec != 0);
}
bool ViewLayout::GetShowTitle()
{
return rec->showTitle;
}
bool ViewLayout::IsCloseable()
{
return rec->isCloseable;
}
bool ViewLayout::IsMoveable()
{
return rec->isMoveable;
}
bool ViewLayout::IsStandalone()
{
return rec->isStandalone;
}
void ViewLayout::SetCloseable(bool closeable)
{
rec->isCloseable = closeable;
}
void ViewLayout::SetMoveable(bool moveable)
{
rec->isMoveable = moveable;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewLayout.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewLayout.h
index f49edb2300..5519fd71fb 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewLayout.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewLayout.h
@@ -1,79 +1,79 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYVIEWLAYOUT_H_
#define BERRYVIEWLAYOUT_H_
#include "berryPageLayout.h"
#include "berryViewLayoutRec.h"
namespace berry
{
/**
* \ingroup org_blueberry_ui_internal
*
* Implementation of IViewLayout.
* This is an API facade on the internal ViewLayoutRec.
*
* @since 3.0
*/
class ViewLayout: public IViewLayout
{
private:
ViewLayoutRec::Pointer rec;
public:
ViewLayout(PageLayout::Pointer pageLayout, ViewLayoutRec::Pointer rec);
/* (non-Javadoc)
* @see org.blueberry.ui.IViewLayout#getShowTitle()
*/
bool GetShowTitle();
/* (non-Javadoc)
* @see org.blueberry.ui.IViewLayout#isCloseable()
*/
bool IsCloseable();
/* (non-Javadoc)
* @see org.blueberry.ui.IViewLayout#isMoveable()
*/
bool IsMoveable();
/* (non-Javadoc)
* @see org.blueberry.ui.IViewLayout#isStandalone()
*/
bool IsStandalone();
/* (non-Javadoc)
* @see org.blueberry.ui.IViewLayout#setCloseable(boolean)
*/
void SetCloseable(bool closeable);
/* (non-Javadoc)
* @see org.blueberry.ui.IViewLayout#setMoveable(boolean)
*/
void SetMoveable(bool moveable);
};
}
#endif /*BERRYVIEWLAYOUT_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewLayoutRec.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewLayoutRec.h
index b34f9a473c..64b68d5056 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewLayoutRec.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewLayoutRec.h
@@ -1,54 +1,54 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYVIEWLAYOUTREC_H_
#define BERRYVIEWLAYOUTREC_H_
#include <berryMacros.h>
namespace berry {
/**
* \ingroup org_blueberry_ui_internal
*
* Encapsulates the perspective layout information for a view.
*
* @since 3.0
*/
struct ViewLayoutRec : public Object {
berryObjectMacro(ViewLayoutRec)
bool isCloseable;
bool isMoveable;
bool isStandalone;
bool showTitle;
ViewLayoutRec() : isCloseable(true), isMoveable(true),
isStandalone(false), showTitle(true) {}
ViewLayoutRec(const ViewLayoutRec& rec)
: Object(), isCloseable(rec.isCloseable), isMoveable(rec.isMoveable),
isStandalone(rec.isStandalone), showTitle(rec.showTitle)
{ }
};
}
#endif /*BERRYVIEWLAYOUTREC_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewReference.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewReference.cpp
index 131886b558..fd113a0fd4 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewReference.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewReference.cpp
@@ -1,438 +1,438 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryViewReference.h"
#include <berryIConfigurationElement.h>
#include "berryUIException.h"
#include "tweaklets/berryWorkbenchPageTweaklet.h"
#include "berryPlatformUI.h"
#include "berryImageDescriptor.h"
#include "berryWorkbenchPage.h"
#include "berryWorkbenchConstants.h"
#include "berryViewDescriptor.h"
#include "berryViewFactory.h"
#include "berryViewRegistry.h"
#include "berryViewSite.h"
#include "berryPartTester.h"
#include "berryWorkbenchPlugin.h"
#include "berryErrorViewPart.h"
namespace berry
{
ViewReference::ViewReference(ViewFactory* fac, const std::string& id,
const std::string& secId, IMemento::Pointer m) :
factory(fac), secondaryId(secId), memento(m)
{
ViewDescriptor::Pointer desc =
this->factory->GetViewRegistry()->Find(id).Cast<ViewDescriptor> ();
ImageDescriptor::Pointer iDesc;
std::string title;
if (!desc.IsNull())
{
iDesc = desc->GetImageDescriptor();
title = desc->GetLabel();
}
std::string name;
if (!memento.IsNull())
{
// name = memento.getString(IWorkbenchConstants.TAG_PART_NAME);
// IMemento propBag = memento.getChild(IWorkbenchConstants.TAG_PROPERTIES);
// if (propBag != null) {
// IMemento[] props = propBag
// .getChildren(IWorkbenchConstants.TAG_PROPERTY);
// for (int i = 0; i < props.length; i++) {
// propertyCache.put(props[i].getID(), props[i].getTextData());
// }
// }
}
if (name.empty())
{
name = title;
}
this->Init(id, "", iDesc, name, ""); //$NON-NLS-1$//$NON-NLS-2$
}
void ViewReference::DoDisposePart()
{
IViewPart::Pointer view = part.Cast<IViewPart> ();
//WorkbenchPartReference::DoDisposePart();
if (!view.IsNull())
{
// Free action bars, pane, etc.
//PartSite site = (PartSite) view.getSite();
//ViewActionBars actionBars = (ViewActionBars) site.getActionBars();
//
// 3.3 start
//
//IMenuService menuService = (IMenuService) site
// .getService(IMenuService.class);
//menuService.releaseContributions((ContributionManager) site.getActionBars()
// .getMenuManager());
//menuService.releaseContributions((ContributionManager) site.getActionBars()
// .getToolBarManager());
// 3.3 end
//actionBars.dispose();
// and now dispose the delegates since the
// PluginActionContributionItem
// can no longer do that
// if (actionBuilder != null) {
// actionBuilder.dispose();
// actionBuilder = null;
// }
// Free the site.
//site.dispose();
}
}
IWorkbenchPage::Pointer ViewReference::GetPage() const
{
return IWorkbenchPage::Pointer(this->factory->GetWorkbenchPage());
}
std::string ViewReference::GetRegisteredName()
{
if (!part.IsNull() && !part->GetSite().IsNull())
{
return part->GetSite()->GetRegisteredName();
}
const IViewRegistry* reg = this->factory->GetViewRegistry();
IViewDescriptor::Pointer desc = reg->Find(this->GetId());
if (!desc.IsNull())
{
return desc->GetLabel();
}
return this->GetPartName();
}
std::string ViewReference::GetSecondaryId()
{
return secondaryId;
}
IViewPart::Pointer ViewReference::GetView(bool restore)
{
return this->GetPart(restore).Cast<IViewPart> ();
}
IWorkbenchPart::Pointer ViewReference::CreatePart()
{
// Check the status of this part
IWorkbenchPart::Pointer result;
PartInitException exception;
bool error = false;
// Try to restore the view -- this does the real work of restoring the
// view
//
try
{
result = this->CreatePartHelper();
} catch (PartInitException e)
{
exception = e;
error = true;
}
// If unable to create the part, create an error part instead
// and pass the error to the status handling facility
if (error)
{
// IStatus partStatus = exception.getStatus();
// IStatus displayStatus = StatusUtil.newStatus(partStatus,
// NLS.bind(WorkbenchMessages.ViewFactory_initException, partStatus.getMessage()));
// IStatus logStatus = StatusUtil
// .newStatus(
// partStatus,
// NLS
// .bind(
// "Unable to create view ID {0}: {1}", getId(), partStatus.getMessage())); //$NON-NLS-1$
// Pass the error to the status handling facility
// StatusManager.getManager().handle(logStatus);
std::string errorTitle = "Unable to create view ID " + this->GetId();
WorkbenchPlugin::Log(errorTitle + ": " + exception.displayText());
IViewDescriptor::Pointer desc = factory->GetViewRegistry()->Find(
this->GetId());
std::string label = this->GetId();
if (!desc.IsNull())
{
label = desc->GetLabel();
}
std::string errorMsg = exception.displayText();
errorMsg
+= "<ul><li>Check your shared library for unresolved symbols</li>"
"<li>Check your class attribute in your plugin.xml file</li>"
"<li>Check your manifest.cpp file</li></ul>"
"</br>For a comprehensive check-list, see <a href=\"http://www.mitk.org/wiki/How_to_fix_your_plug-in_DLL\">http://www.mitk.org/wiki/How_to_fix_your_plug-in_DLL</a>";
ErrorViewPart::Pointer part(new ErrorViewPart(errorTitle, errorMsg));
//PartPane pane = getPane();
IViewReference::Pointer viewRef(this);
ViewSite::Pointer site(new ViewSite(viewRef, part,
factory->GetWorkbenchPage(), GetId(), PlatformUI::PLUGIN_ID, label));
//site.setActionBars(new ViewActionBars(factory.page.getActionBars(),
// site, (ViewPane) pane));
try
{
part->Init(site);
} catch (PartInitException e)
{
BERRY_ERROR << e.displayText();
//StatusUtil.handleStatus(e, StatusManager.SHOW
// | StatusManager.LOG);
return IWorkbenchPart::Pointer(0);
}
part->SetPartName(label);
void* parent = pane->GetControl();
try
{
part->CreatePartControl(parent);
} catch (std::exception e)
{
BERRY_ERROR << "Error creating view: " << e.what() << std::endl;
// StatusUtil.handleStatus(e, StatusManager.SHOW
// | StatusManager.LOG);
return IWorkbenchPart::Pointer(0);
}
result = part.Cast<IWorkbenchPart> ();
}
return result;
}
PartPane::Pointer ViewReference::CreatePane()
{
IWorkbenchPartReference::Pointer partRef(this);
PartPane::Pointer pane(new PartPane(partRef,
this->factory->GetWorkbenchPage()));
return pane;
//return Tweaklets::Get(WorkbenchTweaklet::KEY)->CreateViewPane(this, this->factory->GetWorkbenchPage());
}
IWorkbenchPart::Pointer ViewReference::CreatePartHelper()
{
IWorkbenchPart::Pointer result;
IMemento::Pointer stateMem;
if (!memento.IsNull())
{
stateMem = memento->GetChild(WorkbenchConstants::TAG_VIEW_STATE);
}
IViewDescriptor::Pointer desc = factory->GetViewRegistry()->Find(GetId());
if (desc.IsNull())
{
throw PartInitException("Could not create view", this->GetId());
}
// Create the part pane
PartPane::Pointer pane = this->GetPane();
// Create the pane's top-level control
pane->CreateControl(factory->GetWorkbenchPage()->GetClientComposite());
std::string label = desc->GetLabel(); // debugging only
// Things that will need to be disposed if an exception occurs (they are
// listed here
// in the order they should be disposed)
//Composite content = null;
IViewPart::Pointer initializedView;
ViewSite::Pointer site;
//ViewActionBars actionBars = null;
// End of things that need to be explicitly disposed from the try block
try
{
IViewPart::Pointer view;
view = desc->CreateView();
this->CreatePartProperties(view);
// Create site
IViewReference::Pointer viewRef(this);
site = new ViewSite(viewRef, view, factory->GetWorkbenchPage(), desc);
//actionBars = new ViewActionBars(factory.page.getActionBars(), site,
// (ViewPane) pane);
//site.setActionBars(actionBars);
view->Init(site, stateMem);
// Once we've called init, we MUST dispose the view. Remember
// the fact that
// we've initialized the view in case an exception is thrown.
initializedView = view;
if (view->GetSite() != site)
{
throw PartInitException("View initialization failed. Site is incorrect.");
}
// Create the top-level composite
{
void* parent = pane->GetControl();
view->CreatePartControl(parent);
}
// Install the part's tools and menu
{
//
// 3.3 start
//
// IMenuService menuService = (IMenuService) site
// .getService(IMenuService.class);
// menuService.populateContributionManager(
// (ContributionManager) site.getActionBars()
// .getMenuManager(), "menu:" //$NON-NLS-1$
// + site.getId());
// menuService
// .populateContributionManager((ContributionManager) site
// .getActionBars().getToolBarManager(),
// "toolbar:" + site.getId()); //$NON-NLS-1$
// 3.3 end
// actionBuilder = new ViewActionBuilder();
// actionBuilder.readActionExtensions(view);
// ActionDescriptor[] actionDescriptors = actionBuilder
// .getExtendedActions();
// IKeyBindingService keyBindingService = view.getSite()
// .getKeyBindingService();
//
// if (actionDescriptors != null) {
// for (int i = 0; i < actionDescriptors.length; i++) {
// ActionDescriptor actionDescriptor = actionDescriptors[i];
//
// if (actionDescriptor != null) {
// IAction action = actionDescriptors[i].getAction();
//
// if (action != null
// && action.getActionDefinitionId() != null) {
// keyBindingService.registerAction(action);
// }
// }
// }
// }
//
// site.getActionBars().updateActionBars();
}
// The part should now be fully created. Exercise its public
// interface, and sanity-check
// it wherever possible. If it's going to throw exceptions or behave
// badly, it's much better
// that it does so now while we can still cancel creation of the
// part.
PartTester::TestView(view);
result = view.Cast<IWorkbenchPart> ();
// IConfigurationElement::Pointer element = desc->GetConfigurationElement();
// if (!element.IsNull()) {
// factory.page.getExtensionTracker().registerObject(
// element.getDeclaringExtension(), view,
// IExtensionTracker.REF_WEAK);
// }
} catch (const Poco::Exception& e)
{
// if ((e instanceof Error) && !(e instanceof LinkageError)) {
// throw (Error) e;
// }
// An exception occurred. First deallocate anything we've allocated
// in the try block (see the top
// of the try block for a list of objects that need to be explicitly
// disposed)
// if (content != null) {
// try {
// content.dispose();
// } catch (RuntimeException re) {
// StatusManager.getManager().handle(
// StatusUtil.newStatus(WorkbenchPlugin.PI_WORKBENCH,
// re));
// }
// }
//
// if (initializedView != null) {
// try {
// initializedView.dispose();
// } catch (RuntimeException re) {
// StatusManager.getManager().handle(
// StatusUtil.newStatus(WorkbenchPlugin.PI_WORKBENCH,
// re));
// }
// }
//
// if (site != null) {
// try {
// site.dispose();
// } catch (RuntimeException re) {
// StatusManager.getManager().handle(
// StatusUtil.newStatus(WorkbenchPlugin.PI_WORKBENCH,
// re));
// }
// }
//
// if (actionBars != null) {
// try {
// actionBars.dispose();
// } catch (RuntimeException re) {
// StatusManager.getManager().handle(
// StatusUtil.newStatus(WorkbenchPlugin.PI_WORKBENCH,
// re));
// }
// }
throw PartInitException(e.message(), e, e.code());
}
catch (const std::exception& e)
{
throw PartInitException(e.what());
}
return result;
}
IMemento::Pointer ViewReference::GetMemento()
{
return memento;
}
} // namespace berry
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewReference.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewReference.h
index 9a85c745e4..5c692b0ce4 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewReference.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewReference.h
@@ -1,112 +1,112 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYVIEWREFERENCE_H_
#define BERRYVIEWREFERENCE_H_
#include "berryIMemento.h"
#include "berryWorkbenchPartReference.h"
#include "berryIViewReference.h"
#include "berryPartPane.h"
namespace berry {
class ViewFactory;
struct IWorkbenchPage;
/**
* \ingroup org_blueberry_ui_internal
*
*/
class ViewReference : public WorkbenchPartReference, public IViewReference {
public: berryObjectMacro(ViewReference);
private: const ViewFactory* factory;
public: std::string secondaryId;
private: IMemento::Pointer memento;
//private: ViewActionBuilder actionBuilder;
public: ViewReference(ViewFactory* factory, const std::string& id,
const std::string& secondaryId, IMemento::Pointer memento);
/*
* (non-Javadoc)
*
* @see org.blueberry.ui.internal.WorkbenchPartReference#dispose()
*/
protected: virtual void DoDisposePart();
/*
* (non-Javadoc)
*
* @see org.blueberry.ui.IWorkbenchPartReference#getPage()
*/
public: virtual SmartPointer<IWorkbenchPage> GetPage() const;
/*
* (non-Javadoc)
*
* @see org.blueberry.ui.internal.WorkbenchPartReference#getRegisteredName()
*/
public: virtual std::string GetRegisteredName();
/*
* (non-Javadoc)
*
* @see org.blueberry.ui.IViewReference
*/
public: virtual std::string GetSecondaryId();
/*
* (non-Javadoc)
*
* @see org.blueberry.ui.IViewReference#getView(boolean)
*/
public: virtual IViewPart::Pointer GetView(bool restore);
/**
* Wrapper for restoring the view. First, this delegates to
* busyRestoreViewHelper to do the real work of restoring the view. If
* unable to restore the view, this method tries to substitute an error part
* and return success.
*
* @return the created part
*/
protected: IWorkbenchPart::Pointer CreatePart();
protected: PartPane::Pointer CreatePane();
private: IWorkbenchPart::Pointer CreatePartHelper();
/**
* The memento is that last view state saved by the workbench.
*
* @return the last state that was saved by the workbench. It can return
* <code>null</code>.
* @since 3.1.1
*/
public: virtual IMemento::Pointer GetMemento();
};
} // namespace berry
#endif /*BERRYVIEWREFERENCE_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewRegistry.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewRegistry.cpp
index c4fb2db027..f6246917de 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewRegistry.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewRegistry.cpp
@@ -1,281 +1,281 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 <berryIExtensionPointService.h>
#include "berryViewRegistry.h"
#include "berryPlatformUI.h"
#include "berryImageDescriptor.h"
#include "berryWorkbenchPlugin.h"
#include "berryWorkbenchRegistryConstants.h"
#include "berryPlatform.h"
namespace berry
{
ViewRegistry::ViewCategoryProxy::ViewCategoryProxy(
IViewDescriptorCategoryPtr rawCategory) :
rawCategory(rawCategory)
{
}
const std::vector<IViewDescriptor::Pointer>& ViewRegistry::ViewCategoryProxy::GetViews() const
{
return rawCategory->GetElements();
}
const std::string& ViewRegistry::ViewCategoryProxy::GetId() const
{
return rawCategory->GetId();
}
std::vector<std::string> ViewRegistry::ViewCategoryProxy::GetPath() const
{
std::vector<std::string> path;
std::string rawParentPath = rawCategory->GetRawParentPath();
// nested categories are not supported yet
// assume an empty raw parent path
path.push_back(rawParentPath);
return path;
}
std::string ViewRegistry::ViewCategoryProxy::GetLabel() const
{
return rawCategory->GetLabel();
}
bool ViewRegistry::ViewCategoryProxy::operator==(const Object* o) const
{
if (const IViewCategory* other = dynamic_cast<const IViewCategory*>(o))
return this->GetId() == other->GetId();
return false;
}
int ViewRegistry::ViewCategoryProxy::HashCode()
{
//return GetId().hashCode();
return 0;
}
std::string ViewRegistry::EXTENSIONPOINT_UNIQUE_ID = "org.blueberry.ui.views";
// PlatformUI::PLUGIN_ID + "." + WorkbenchRegistryConstants::PL_VIEWS;
Category<IViewDescriptor::Pointer>::Pointer ViewRegistry::InternalFindCategory(const std::string& id)
{
for (std::vector<IViewDescriptorCategoryPtr>::iterator itr = categories.begin();
itr != categories.end(); ++itr)
{
if (id == (*itr)->GetRootPath())
{
return *itr;
}
}
return IViewDescriptorCategoryPtr(0);
}
const IExtensionPoint* ViewRegistry::GetExtensionPointFilter()
{
return Platform::GetExtensionPointService()->GetExtensionPoint(EXTENSIONPOINT_UNIQUE_ID);
}
const std::string ViewRegistry::TAG_DESCRIPTION = "description";
ViewRegistry::ViewRegistry() :
dirtyViewCategoryMappings(true)
{
miscCategory = new IViewDescriptorCategory();
this->Add(miscCategory);
//PlatformUI.getWorkbench().getExtensionTracker().registerHandler(this,
// ExtensionTracker.createExtensionPointFilter(getExtensionPointFilter()));
reader.ReadViews(this);
}
void ViewRegistry::Add(IViewDescriptorCategoryPtr desc)
{
/* fix for 1877 */
if (this->InternalFindCategory(desc->GetId()).IsNull())
{
dirtyViewCategoryMappings = true;
// Mark categories list as dirty
categories.push_back(desc);
// IConfigurationElement::Pointer element(
// dynamic_cast<IConfigurationElement*>(
// desc->GetAdapter(typeid(IConfigurationElement))
// ));
// if (element.IsNull())
// {
// return;
// }
// PlatformUI::GetWorkbench()->GetExtensionTracker()
// .registerObject(element->GetDeclaringExtension(), desc,
// IExtensionTracker::REF_WEAK);
}
}
void ViewRegistry::Add(ViewDescriptor::Pointer desc)
{
for (std::vector<IViewDescriptor::Pointer>::const_iterator itr = views.begin();
itr != views.end(); ++itr)
{
if (desc.GetPointer() == itr->GetPointer()) return;
}
views.push_back(desc);
dirtyViewCategoryMappings = true;
//desc.activateHandler();
}
void ViewRegistry::Add(StickyViewDescriptor::Pointer desc)
{
if (std::find(sticky.begin(), sticky.end(), desc) == sticky.end())
{
sticky.push_back(desc);
// PlatformUI::GetWorkbench()->GetExtensionTracker()
// .registerObject(desc.getConfigurationElement().getDeclaringExtension(),
// desc, IExtensionTracker.REF_WEAK);
}
}
IViewDescriptor::Pointer ViewRegistry::Find(const std::string& id) const
{
for (std::vector<IViewDescriptor::Pointer>::const_iterator itr = views.begin();
itr != views.end(); ++itr)
{
if (id == (*itr)->GetId())
{
return *itr;
}
}
return IViewDescriptor::Pointer(0);
}
IViewCategory::Pointer ViewRegistry::FindCategory(const std::string& id)
{
this->MapViewsToCategories();
IViewDescriptorCategoryPtr category(this->InternalFindCategory(id));
if (category.IsNull())
{
return IViewCategory::Pointer(0);
}
IViewCategory::Pointer cat(new ViewCategoryProxy(category));
return cat;
}
std::vector<IViewCategory::Pointer> ViewRegistry::GetCategories()
{
this->MapViewsToCategories();
std::vector<IViewCategory::Pointer> retArray;
for (std::vector<IViewDescriptorCategoryPtr>::iterator itr = categories.begin();
itr != categories.end(); ++itr)
{
retArray.push_back(IViewCategory::Pointer(new ViewCategoryProxy(*itr)));
}
return retArray;
}
std::vector<IStickyViewDescriptor::Pointer> ViewRegistry::GetStickyViews() const
{
return sticky;
}
Category<IViewDescriptor::Pointer>::Pointer ViewRegistry::GetMiscCategory() const
{
return miscCategory;
}
const std::vector<IViewDescriptor::Pointer>& ViewRegistry::GetViews() const
{
return views;
}
void ViewRegistry::MapViewsToCategories()
{
if (dirtyViewCategoryMappings)
{
dirtyViewCategoryMappings = false;
// clear all category mappings
for (std::vector<IViewDescriptorCategoryPtr>::iterator i = categories.begin();
i != categories.end(); ++i)
{
(*i)->Clear(); // this is bad
}
miscCategory->Clear();
for (std::vector<IViewDescriptor::Pointer>::iterator i = views.begin();
i != views.end(); ++i)
{
IViewDescriptor::Pointer desc(*i);
IViewDescriptorCategoryPtr cat(0);
const std::vector<std::string>& catPath = desc->GetCategoryPath();
if (catPath.size() > 0)
{
cat = this->InternalFindCategory(catPath[0]);
}
if (cat.IsNotNull())
{
if (!cat->HasElement(desc))
{
cat->AddElement(desc);
}
}
else
{
if (catPath.size() > 0)
{
// If we get here, this view specified a category which
// does not exist. Add this view to the 'Other' category
// but give out a message (to the log only) indicating
// this has been done.
std::string fmt(Poco::Logger::format(
"Category $0 not found for view $1. This view added to ''$2'' category.",
catPath[0], desc->GetId(), miscCategory->GetLabel()));
WorkbenchPlugin::Log(fmt);
}
miscCategory->AddElement(desc);
}
}
}
}
//void ViewRegistry::AddExtension(IExtensionTracker tracker,
// IExtension addedExtension)
//{
// IConfigurationElement[] addedElements = addedExtension.getConfigurationElements();
// for (int i = 0; i < addedElements.length; i++)
// {
// IConfigurationElement element = addedElements[i];
// if (element.getName().equals(IWorkbenchRegistryConstants.TAG_VIEW))
// {
// reader.readView(element);
// }
// else if (element.getName().equals(IWorkbenchRegistryConstants.TAG_CATEGORY))
// {
// reader.readCategory(element);
// }
// else if (element.getName().equals(IWorkbenchRegistryConstants.TAG_STICKYVIEW))
// {
// reader.readSticky(element);
// }
// }
//}
} // namespace berry
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewRegistry.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewRegistry.h
index 6280bcf3fd..b3436b4aba 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewRegistry.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewRegistry.h
@@ -1,224 +1,224 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYVIEWREGISTRY_H_
#define BERRYVIEWREGISTRY_H_
#include "berryIViewRegistry.h"
#include "berryIViewCategory.h"
#include "berryIViewDescriptor.h"
#include "berryCategory.h"
#include "berryViewDescriptor.h"
#include "berryViewRegistryReader.h"
#include "berryStickyViewDescriptor.h"
#include "service/berryIExtensionPoint.h"
#include <vector>
#include <string>
#include <set>
namespace berry
{
/**
* \ingroup org_blueberry_ui_internal
*
* The central manager for view descriptors.
*/
class ViewRegistry : public IViewRegistry
{
public:
typedef Category<IViewDescriptor::Pointer> IViewDescriptorCategory;
typedef IViewDescriptorCategory::Pointer IViewDescriptorCategoryPtr;
private:
/**
* Proxies a Category implementation.
*
*/
class ViewCategoryProxy : public IViewCategory
{
private:
typedef Category<IViewDescriptor::Pointer> IViewDescriptorCategory;
IViewDescriptorCategoryPtr rawCategory;
/**
* Create a new instance of this class
*
* @param rawCategory the category
*/
public:
ViewCategoryProxy(IViewDescriptorCategoryPtr rawCategory);
/* (non-Javadoc)
* @see org.blueberry.ui.views.IViewCategory#getViews()
*/
const std::vector<IViewDescriptor::Pointer>& GetViews() const;
/* (non-Javadoc)
* @see org.blueberry.ui.views.IViewCategory#getId()
*/
const std::string& GetId() const;
/* (non-Javadoc)
* @see org.blueberry.ui.views.IViewCategory#getPath()
*/
std::vector<std::string> GetPath() const;
/* (non-Javadoc)
* @see org.blueberry.ui.views.IViewCategory#getLabel()
*/
std::string GetLabel() const;
/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
bool operator==(const Object* o) const;
/* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
int HashCode();
};
private:
static std::string EXTENSIONPOINT_UNIQUE_ID;
/**
* A set that will only ever contain ViewDescriptors.
*/
std::vector<IViewDescriptor::Pointer> views; // = new TreeSet(new Comparator() {
// public int compare(Object o1, Object o2) {
// String id1 = ((ViewDescriptor) o1).getId();
// String id2 = ((ViewDescriptor) o2).getId();
//
// return id1.compareTo(id2);
// }});
std::vector<IStickyViewDescriptor::Pointer> sticky;
std::vector<IViewDescriptorCategoryPtr> categories;
IViewDescriptorCategoryPtr miscCategory;
ViewRegistryReader reader;
bool dirtyViewCategoryMappings;
/**
* Returns the category with no updating of the view/category mappings.
*
* @param id the category id
* @return the Category
* @since 3.1
*/
IViewDescriptorCategoryPtr InternalFindCategory(const std::string& id);
const IExtensionPoint* GetExtensionPointFilter();
protected:
static const std::string TAG_DESCRIPTION; // = "description";
public:
ViewRegistry();
/**
* Add a category to the registry.
*
* @param desc the descriptor to add
*/
void Add(IViewDescriptorCategoryPtr desc);
/**
* Add a descriptor to the registry.
*
* @param desc the descriptor to add
*/
void Add(ViewDescriptor::Pointer desc);
/**
* Add a sticky descriptor to the registry.
*
* @param desc the descriptor to add
*/
void Add(StickyViewDescriptor::Pointer desc);
/**
* Find a descriptor in the registry.
*/
IViewDescriptor::Pointer Find(const std::string& id) const;
/**
* Find a category with a given name.
*
* @param id the id to search for
* @return the category or <code>null</code>
*/
IViewCategory::Pointer FindCategory(const std::string& id);
/**
* Get the list of view categories.
*/
std::vector<IViewCategory::Pointer> GetCategories();
/**
* Get the list of sticky views minus the sticky views which failed the
* Expressions check.
*/
std::vector<IStickyViewDescriptor::Pointer> GetStickyViews() const;
/**
* Returns the Misc category. This may be <code>null</code> if there are
* no miscellaneous views.
*
* @return the misc category or <code>null</code>
*/
IViewDescriptorCategoryPtr GetMiscCategory() const;
/**
* Get an enumeration of view descriptors.
*/
const std::vector<IViewDescriptor::Pointer>& GetViews() const;
/**
* Adds each view in the registry to a particular category.
* The view category may be defined in xml. If not, the view is
* added to the "misc" category.
*/
void MapViewsToCategories();
/* (non-Javadoc)
* @see org.blueberry.core.runtime.dynamicHelpers.IExtensionChangeHandler#addExtension(org.blueberry.core.runtime.dynamicHelpers.IExtensionTracker, org.blueberry.core.runtime.IExtension)
*/
//void AddExtension(IExtensionTracker tracker, IExtension addedExtension);
};
} // namespace berry
#endif /*BERRYVIEWREGISTRY_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewRegistryReader.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewRegistryReader.cpp
index 5413dc3cc0..3cfa9683ee 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewRegistryReader.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewRegistryReader.cpp
@@ -1,114 +1,114 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryViewRegistryReader.h"
#include "berryViewRegistry.h"
#include "berryWorkbenchRegistryConstants.h"
#include "berryWorkbenchPlugin.h"
#include "berryImageDescriptor.h"
#include "berryPlatformUI.h"
namespace berry
{
std::string ViewRegistryReader::GENERAL_VIEW_ID = "org.blueberry.ui";
ViewRegistryReader::ViewRegistryReader() :
RegistryReader()
{
}
void ViewRegistryReader::ReadViews(ViewRegistry* out)
{
// this does not seem to really ever be throwing an the exception
viewRegistry = out;
this->ReadRegistry(PlatformUI::PLUGIN_ID,
WorkbenchRegistryConstants::PL_VIEWS);
}
void ViewRegistryReader::ReadCategory(IConfigurationElement::Pointer element)
{
try
{
Category<IViewDescriptor::Pointer>::Pointer cat(new Category<IViewDescriptor::Pointer>(element));
viewRegistry->Add(cat);
}
catch (CoreException e)
{
// log an error since its not safe to show a dialog here
WorkbenchPlugin::Log(
"Unable to create view category.", e);//$NON-NLS-1$
}
}
bool ViewRegistryReader::ReadElement(IConfigurationElement::Pointer element)
{
std::string elementName = element->GetName();
if (elementName == WorkbenchRegistryConstants::TAG_VIEW)
{
this->ReadView(element);
return true;
}
if (elementName == WorkbenchRegistryConstants::TAG_CATEGORY)
{
this->ReadCategory(element);
this->ReadElementChildren(element);
return true;
}
if (elementName == WorkbenchRegistryConstants::TAG_STICKYVIEW)
{
this->ReadSticky(element);
return true;
}
return false;
}
void ViewRegistryReader::ReadSticky(IConfigurationElement::Pointer element)
{
try
{
viewRegistry->Add(StickyViewDescriptor::Pointer(new StickyViewDescriptor(element)));
}
catch (CoreException& e)
{
//TODO IStatus
// log an error since its not safe to open a dialog here
// WorkbenchPlugin.log(
// "Unable to create sticky view descriptor.", e.getStatus());//$NON-NLS-1$
WorkbenchPlugin::Log("Unable to create sticky view descriptor.", e);
}
}
void ViewRegistryReader::ReadView(IConfigurationElement::Pointer element)
{
try
{
ViewDescriptor::Pointer desc(new ViewDescriptor(element));
viewRegistry->Add(desc);
}
catch (CoreException e)
{
// log an error since its not safe to open a dialog here
WorkbenchPlugin::Log(
"Unable to create view descriptor.", e);//$NON-NLS-1$
}
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewRegistryReader.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewRegistryReader.h
index 9dd5c22d3f..e2b51a725a 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewRegistryReader.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewRegistryReader.h
@@ -1,83 +1,83 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYVIEWREGISTRYREADER_H_
#define BERRYVIEWREGISTRYREADER_H_
#include "berryRegistryReader.h"
namespace berry
{
class ViewRegistry;
/**
* \ingroup org_blueberry_ui_internal
*
* A strategy to read view extensions from the registry.
*/
class ViewRegistryReader : public RegistryReader
{
public:
/**
* General view category id
*/
static std::string GENERAL_VIEW_ID ;
/**
* RegistryViewReader constructor comment.
*/
ViewRegistryReader();
/**
* Read the view extensions within a registry.
* @param in the extension registry
* @param out the view registry
*/
void ReadViews(ViewRegistry* out);
protected:
/**
* Reads the category element.
*/
void ReadCategory(IConfigurationElement::Pointer element);
/**
* readElement method comment.
*/
bool ReadElement(IConfigurationElement::Pointer element);
/**
* Reads the sticky view element.
*/
void ReadSticky(IConfigurationElement::Pointer element);
/**
* Reads the view element.
*/
void ReadView(IConfigurationElement::Pointer element);
private:
ViewRegistry* viewRegistry;
};
} // namespace berry
#endif /*BERRYVIEWREGISTRYREADER_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewSashContainer.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewSashContainer.cpp
index 586327d204..d9dfd485a0 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewSashContainer.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewSashContainer.cpp
@@ -1,298 +1,298 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryViewSashContainer.h"
#include "berryPerspective.h"
#include "berryPerspectiveHelper.h"
#include "berryLayoutTree.h"
#include "berryWorkbenchConstants.h"
#include "berryWorkbenchPlugin.h"
#include "berryImageDescriptor.h"
#include <Poco/HashMap.h>
namespace berry
{
ViewSashContainer::ViewSashContainer(WorkbenchPage* page, void* parent) :
PartSashContainer("root layout container", page, parent)
{
}
ViewSashContainer::Pointer ViewSashContainer::GetRootContainer()
{
return ViewSashContainer::Pointer(this);
}
void* ViewSashContainer::GetControl()
{
return this->parent;
}
bool ViewSashContainer::RestoreState(IMemento::Pointer memento)
{
//TODO ViewSashContainer restore state
// MultiStatus
// result =
// new MultiStatus(PlatformUI.PLUGIN_ID, IStatus.OK, WorkbenchMessages.RootLayoutContainer_problemsRestoringPerspective, null);
//
bool result = true;
// Read the info elements.
std::vector<IMemento::Pointer> children(memento->GetChildren(WorkbenchConstants::TAG_INFO));
// Create a part ID to part hashtable.
Poco::HashMap<std::string, LayoutPart::Pointer> mapIDtoPart(children.size());
// Loop through the info elements.
for (std::size_t i = 0; i < children.size(); i++)
{
// Get the info details.
IMemento::Pointer childMem = children[i];
std::string partID; childMem->GetString(WorkbenchConstants::TAG_PART, partID);
std::string relativeID; childMem->GetString(WorkbenchConstants::TAG_RELATIVE, relativeID);
int relationship = 0;
int left = 0, right = 0;
if (!relativeID.empty())
{
childMem->GetInteger(WorkbenchConstants::TAG_RELATIONSHIP, relationship);
childMem->GetInteger(WorkbenchConstants::TAG_RATIO_LEFT, left);
childMem->GetInteger(WorkbenchConstants::TAG_RATIO_RIGHT, right);
}
std::string strFolder; childMem->GetString(WorkbenchConstants::TAG_FOLDER, strFolder);
// Create the part.
LayoutPart::Pointer part;
if (strFolder.empty())
{
// this is the editor area
ContainerPlaceholder::Pointer placeholder(new ContainerPlaceholder(partID));
part = placeholder;
}
else
{
PartStack::Pointer folder(new PartStack(page));
folder->SetID(partID);
//result.add(folder->RestoreState(childMem->GetChild(WorkbenchConstants::TAG_FOLDER)));
result &= folder->RestoreState(childMem->GetChild(WorkbenchConstants::TAG_FOLDER));
ContainerPlaceholder::Pointer placeholder(new ContainerPlaceholder(partID));
placeholder->SetRealContainer(folder);
part = placeholder;
}
// 1FUN70C: ITPUI:WIN - Shouldn't set Container when not active
part->SetContainer(ILayoutContainer::Pointer(this));
const int myLeft = left, myRight = right, myRelationship = relationship;
LayoutPart::Pointer myPart = part;
// StartupThreading.runWithoutExceptions(new StartupRunnable()
// {
//
// public void runWithException() throws Throwable
// {
// Add the part to the layout
if (relativeID.empty())
{
this->Add(myPart);
}
else
{
LayoutPart::Pointer refPart = mapIDtoPart[relativeID];
if (refPart)
{
this->Add(myPart, myRelationship, myLeft, myRight, refPart);
}
else
{
WorkbenchPlugin::Log("Unable to find part for ID: " + relativeID);
}
}
// }}
// );
mapIDtoPart[partID] = part;
}
return result;
}
bool ViewSashContainer::SaveState(IMemento::Pointer memento)
{
std::vector<RelationshipInfo> relationships = this->ComputeRelation();
bool result = true;
// MultiStatus
// result =
// new MultiStatus(PlatformUI.PLUGIN_ID, IStatus.OK, WorkbenchMessages.RootLayoutContainer_problemsSavingPerspective, null);
// Loop through the relationship array.
for (std::size_t i = 0; i < relationships.size(); ++i)
{
// Save the relationship info ..
// private LayoutPart part;
// private int relationship;
// private float ratio;
// private LayoutPart relative;
RelationshipInfo& info = relationships[i];
IMemento::Pointer childMem = memento->CreateChild(WorkbenchConstants::TAG_INFO);
childMem->PutString(WorkbenchConstants::TAG_PART, info.part->GetID());
if (info.relative)
{
childMem->PutString(WorkbenchConstants::TAG_RELATIVE,
info.relative->GetID());
childMem->PutInteger(WorkbenchConstants::TAG_RELATIONSHIP,
info.relationship);
childMem->PutInteger(WorkbenchConstants::TAG_RATIO_LEFT, info.left);
childMem->PutInteger(WorkbenchConstants::TAG_RATIO_RIGHT, info.right);
}
// Is this part a folder or a placeholder for one?
PartStack::Pointer folder(info.part.Cast<PartStack>());
if (!folder && info.part.Cast<ContainerPlaceholder>())
{
IStackableContainer::Pointer part = info.part.Cast<ContainerPlaceholder>()->GetRealContainer();
folder = part.Cast<PartStack>();
}
// If this is a folder (PartStack) save the contents.
if (folder)
{
childMem->PutString(WorkbenchConstants::TAG_FOLDER, "true");
IMemento::Pointer folderMem(childMem->CreateChild(WorkbenchConstants::TAG_FOLDER));
//result.add(folder.saveState(folderMem));
result = folder->SaveState(folderMem);
}
}
return result;
}
bool ViewSashContainer::IsStackType(IStackableContainer::Pointer toTest)
{
if (toTest.Cast<PartStack> () == 0)
return false;
return (toTest.Cast<PartStack> ()->GetAppearance()
!= PresentationFactoryUtil::ROLE_EDITOR);
}
bool ViewSashContainer::IsPaneType(StackablePart::Pointer toTest)
{
if (toTest.Cast<PartPane> () == 0)
return false;
return (toTest.Cast<PartPane> ()->GetPartReference().Cast<IViewReference> ()
!= 0);
}
bool ViewSashContainer::AllowsAdd(LayoutPart::Pointer layoutPart)
{
return LayoutPart::AllowsAdd(layoutPart);
}
// void ViewSashContainer::Replace(StackablePart::Pointer oldChild,
// StackablePart::Pointer newChild)
// {
// if (!this->IsChild(oldChild))
// {
// return;
// }
//
// // Nasty hack: ensure that all views end up inside a tab folder.
// // Since the view title is provided by the tab folder, this ensures
// // that views don't get created without a title tab.
// if (newChild instanceof ViewPane)
// {
// ViewStack folder = new ViewStack(page);
// folder.add(newChild);
// newChild = folder;
// }
//
// super.replace(oldChild, newChild);
// }
void* ViewSashContainer::CreateParent(void* parentWidget)
{
return parentWidget;
}
void ViewSashContainer::DisposeParent()
{
// do nothing
}
float ViewSashContainer::GetDockingRatio(Object::Pointer dragged,
IStackableContainer::Pointer target)
{
if (this->IsStackType(target))
{
return PartSashContainer::GetDockingRatio(dragged, target);
}
else
{
return 0.25f;
}
}
PartStack::Pointer ViewSashContainer::CreateStack()
{
PartStack::Pointer result(new PartStack(page));
return result;
}
void ViewSashContainer::SetVisiblePart(IStackableContainer::Pointer container,
PartPane::Pointer visiblePart)
{
if (container.Cast<PartStack> () != 0)
{
PartStack::Pointer tabFolder = container.Cast<PartStack> ();
tabFolder->SetSelection(visiblePart);
}
}
StackablePart::Pointer ViewSashContainer::GetVisiblePart(
IStackableContainer::Pointer container)
{
return container.Cast<PartStack> ()->GetSelection();
}
void ViewSashContainer::DerefPart(StackablePart::Pointer sourcePart)
{
page->GetActivePerspective()->GetPresentation()->DerefPart(sourcePart);
}
// void ViewSashContainer::AddChild(const RelationshipInfo& info)
// {
// LayoutPart child = info.part;
//
// // Nasty hack: ensure that all views end up inside a tab folder.
// // Since the view title is provided by the tab folder, this ensures
// // that views don't get created without a title tab.
// if (child instanceof ViewPane)
// {
// ViewStack folder = new ViewStack(page);
// folder.add(child);
// info.part = folder;
// }
//
// super.addChild(info);
// }
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewSashContainer.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewSashContainer.h
index 583cbb45c5..34203b3146 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewSashContainer.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewSashContainer.h
@@ -1,125 +1,125 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYVIEWSASHCONTAINER_H_
#define BERRYVIEWSASHCONTAINER_H_
#include "berryPartSashContainer.h"
#include "berryPartStack.h"
namespace berry {
/**
* Represents the top level container.
*/
class ViewSashContainer : public PartSashContainer {
public:
berryObjectMacro(ViewSashContainer);
ViewSashContainer(WorkbenchPage* page, void* parent);
/**
* Gets root container for this part.
*/
ViewSashContainer::Pointer GetRootContainer();
/**
* Get the part control. This method may return null.
*/
void* GetControl();
/**
* @see IPersistablePart
*/
bool RestoreState(IMemento::Pointer memento);
/**
* @see IPersistablePart
*/
bool SaveState(IMemento::Pointer memento);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.PartSashContainer#isStackType(org.blueberry.ui.internal.LayoutPart)
*/
bool IsStackType(IStackableContainer::Pointer toTest);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.PartSashContainer#isPaneType(org.blueberry.ui.internal.LayoutPart)
*/
bool IsPaneType(StackablePart::Pointer toTest);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.ILayoutContainer#replace(org.blueberry.ui.internal.LayoutPart, org.blueberry.ui.internal.LayoutPart)
*/
//void Replace(LayoutPart::Pointer oldChild, LayoutPart::Pointer newChild);
bool AllowsAdd(LayoutPart::Pointer layoutPart);
protected:
/**
* Subclasses override this method to specify
* the composite to use to parent all children
* layout parts it contains.
*/
void* CreateParent(void* parentWidget);
/**
* Subclasses override this method to dispose
* of any swt resources created during createParent.
*/
void DisposeParent();
/* (non-Javadoc)
* @see org.blueberry.ui.internal.PartSashContainer#getDockingRatio(org.blueberry.ui.internal.LayoutPart, org.blueberry.ui.internal.LayoutPart)
*/
float GetDockingRatio(Object::Pointer dragged, IStackableContainer::Pointer target);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.PartSashContainer#createStack(org.blueberry.ui.internal.LayoutPart)
*/
PartStack::Pointer CreateStack();
/* (non-Javadoc)
* @see org.blueberry.ui.internal.PartSashContainer#setVisiblePart(org.blueberry.ui.internal.ILayoutContainer, org.blueberry.ui.internal.LayoutPart)
*/
void SetVisiblePart(IStackableContainer::Pointer container,
PartPane::Pointer visiblePart);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.PartSashContainer#getVisiblePart(org.blueberry.ui.internal.ILayoutContainer)
*/
StackablePart::Pointer GetVisiblePart(IStackableContainer::Pointer container);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.PartSashContainer#derefPart(org.blueberry.ui.internal.LayoutPart)
*/
void DerefPart(StackablePart::Pointer sourcePart);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.PartSashContainer#addChild(org.blueberry.ui.internal.PartSashContainer.RelationshipInfo)
*/
//void AddChild(const RelationshipInfo& info);
};
}
#endif /* BERRYVIEWSASHCONTAINER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewSite.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewSite.cpp
index 2b9ab8f3c7..212188602e 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewSite.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewSite.cpp
@@ -1,56 +1,56 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryViewSite.h"
#include "berryIViewReference.h"
#include "berryIViewPart.h"
#include "berryPartPane.h"
#include "berryImageDescriptor.h"
#include "berryViewDescriptor.h"
#include "berryWorkbenchPage.h"
namespace berry
{
ViewSite::ViewSite(IViewReference::Pointer ref, IViewPart::Pointer view,
WorkbenchPage* page, const std::string& id,
const std::string& pluginId, const std::string& registeredName)
: PartSite(ref, view, page)
{
SetId(id);
SetRegisteredName(registeredName);
SetPluginId(pluginId);
}
ViewSite::ViewSite(IViewReference::Pointer ref, IViewPart::Pointer view,
WorkbenchPage* page, IViewDescriptor::Pointer desc)
: PartSite(ref, view, page)
{
SetConfigurationElement(desc.Cast<ViewDescriptor>()->GetConfigurationElement());
}
std::string ViewSite::GetSecondaryId()
{
return GetPartReference().Cast<IViewReference>()->GetSecondaryId();
}
IViewPart::Pointer ViewSite::GetViewPart()
{
return GetPart().Cast<IViewPart>();
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewSite.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewSite.h
index 310a700382..2697a7a660 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewSite.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewSite.h
@@ -1,65 +1,65 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYVIEWSITE_H_
#define BERRYVIEWSITE_H_
#include "berryPartSite.h"
#include "berryIViewSite.h"
namespace berry {
class WorkbenchPage;
struct IViewReference;
struct IViewPart;
struct IViewDescriptor;
/**
* \ingroup org_blueberry_ui_internal
*
* A view container manages the services for a view.
*/
class ViewSite : public PartSite, public IViewSite {
public:
berryObjectMacro(ViewSite)
ViewSite(SmartPointer<IViewReference> ref, SmartPointer<IViewPart> view,
WorkbenchPage* page,
const std::string& id, const std::string& pluginId, const std::string& registeredName);
/**
* Creates a new ViewSite.
*/
ViewSite(SmartPointer<IViewReference> ref, SmartPointer<IViewPart> view, WorkbenchPage* page,
SmartPointer<IViewDescriptor> desc);
/**
* Returns the secondary id or <code>null</code>.
*/
std::string GetSecondaryId();
/**
* Returns the view.
*/
SmartPointer<IViewPart> GetViewPart();
};
}
#endif /*BERRYVIEWSITE_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWWinPartService.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWWinPartService.cpp
index fa605b3817..c51178ba9e 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWWinPartService.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWWinPartService.cpp
@@ -1,231 +1,231 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryWWinPartService.h"
#include "berryIWorkbenchWindow.h"
#include "berryWorkbenchPage.h"
namespace berry
{
struct WWinListener: public IPartListener
{ //, IPageChangedListener {
WWinListener(WWinPartService* wwps) :
wwps(wwps)
{
}
Events::Types GetPartEventTypes() const
{
return Events::ALL;
}
void PartActivated(IWorkbenchPartReference::Pointer /*ref*/)
{
wwps->UpdateActivePart();
}
void PartBroughtToTop(IWorkbenchPartReference::Pointer ref)
{
wwps->partService.FirePartBroughtToTop(ref);
}
void PartClosed(IWorkbenchPartReference::Pointer ref)
{
wwps->partService.FirePartClosed(ref);
}
void PartDeactivated(IWorkbenchPartReference::Pointer /*ref*/)
{
wwps->UpdateActivePart();
}
void PartOpened(IWorkbenchPartReference::Pointer ref)
{
wwps->partService.FirePartOpened(ref);
}
void PartHidden(IWorkbenchPartReference::Pointer ref)
{
wwps->partService.FirePartHidden(ref);
}
void PartVisible(IWorkbenchPartReference::Pointer ref)
{
wwps->partService.FirePartVisible(ref);
}
void PartInputChanged(IWorkbenchPartReference::Pointer ref)
{
wwps->partService.FirePartInputChanged(ref);
}
// void PageChanged(PageChangedEvent::Pointer event) {
// partService.firePageChanged(event);
// }
private:
WWinPartService* wwps;
};
WWinPartService::WWinPartService(IWorkbenchWindow* window) :
partService("", ""), selectionService(window), activePage(0),
partListener(new WWinListener(
this))
{
}
void WWinPartService::AddPartListener(IPartListener::Pointer l)
{
partService.AddPartListener(l);
}
void WWinPartService::RemovePartListener(IPartListener::Pointer l)
{
partService.RemovePartListener(l);
}
IWorkbenchPart::Pointer WWinPartService::GetActivePart()
{
return partService.GetActivePart();
}
void WWinPartService::UpdateActivePart()
{
IWorkbenchPartReference::Pointer activeRef;
IWorkbenchPart::Pointer activePart;
if (activePage)
{
activePart = activePage->GetActivePart();
activeRef = activePage->GetActivePartReference();
}
partService.SetActivePart(activeRef);
selectionService.SetActivePart(activePart);
}
IWorkbenchPartReference::Pointer WWinPartService::GetActivePartReference()
{
return partService.GetActivePartReference();
}
ISelectionService* WWinPartService::GetSelectionService()
{
return &selectionService;
}
void WWinPartService::PageActivated(SmartPointer<IWorkbenchPage> newPage)
{
// Optimize.
if (newPage == activePage)
{
return;
}
// Fire events in the following order:
// 1. For each open part in the new page, open it and then (if applicable) make it visible
// 2. Deactivate old active part
// 3. Activate the new active part
// 4. For each open part in the old page, make it invisible then close it
// Hook listener on the new page.
if (newPage)
{
std::vector<IWorkbenchPartReference::Pointer> refs(newPage.Cast<
WorkbenchPage> ()->GetOpenParts());
for (std::size_t i = 0; i < refs.size(); i++)
{
IWorkbenchPartReference::Pointer reference = refs[i];
partService.FirePartOpened(reference);
IWorkbenchPart::Pointer part = reference->GetPart(false);
if (part && newPage->IsPartVisible(part))
{
partService.FirePartVisible(reference);
}
}
partService.SetActivePart(newPage->GetActivePartReference());
selectionService.SetActivePart(newPage->GetActivePart());
}
else
{
partService.SetActivePart(IWorkbenchPartReference::Pointer(0));
selectionService.SetActivePart(IWorkbenchPart::Pointer(0));
}
// Unhook listener from the old page.
Reset();
// Update active page.
activePage = newPage.GetPointer();
if (newPage)
{
newPage->AddPartListener(partListener);
}
}
void WWinPartService::PageClosed(SmartPointer<IWorkbenchPage> page)
{
// Unhook listener from the old page.
if (page == activePage)
{
Reset();
}
}
void WWinPartService::PageOpened(SmartPointer<IWorkbenchPage> page)
{
PageActivated(page);
}
void WWinPartService::Reset()
{
IWorkbenchPage* tempPage = activePage;
activePage = 0;
if (tempPage)
{
WorkbenchPage* page = dynamic_cast<WorkbenchPage*>(tempPage);
std::vector<IWorkbenchPartReference::Pointer> refs(page->GetOpenParts());
for (std::size_t i = 0; i < refs.size(); i++)
{
IWorkbenchPartReference::Pointer reference = refs[i];
if (page->IsPartVisible(reference))
{
partService.FirePartHidden(reference);
}
partService.FirePartClosed(reference);
}
tempPage->RemovePartListener(partListener);
}
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWWinPartService.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWWinPartService.h
index 3fe149b43b..998e6aa16e 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWWinPartService.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWWinPartService.h
@@ -1,111 +1,111 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYWWINPARTSERVICE_H_
#define BERRYWWINPARTSERVICE_H_
#include "berryIPartService.h"
#include "berryPartService.h"
#include "berryWindowSelectionService.h"
namespace berry
{
/**
* A part service for a workbench window.
*/
class WWinPartService: public IPartService
{
private:
friend struct WWinListener;
PartService partService; // (UIListenerLogging.WINDOW_PARTLISTENER_EVENTS, UIListenerLogging.WINDOW_PARTLISTENER2_EVENTS);
WindowSelectionService selectionService;
IWorkbenchPage* activePage;
IPartListener::Pointer partListener; // = new WWinListener();
public:
/**
* Creates a new part service for a workbench window.
*/
WWinPartService(IWorkbenchWindow* window);
/*
* (non-Javadoc)
* Method declared on IPartService
*/
void AddPartListener(IPartListener::Pointer l);
/*
* (non-Javadoc)
* Method declared on IPartService
*/
void RemovePartListener(IPartListener::Pointer l);
/*
* (non-Javadoc)
* Method declared on IPartService
*/
IWorkbenchPart::Pointer GetActivePart();
/*
* (non-Javadoc)
* Method declared on IPartService
*/
IWorkbenchPartReference::Pointer GetActivePartReference();
/*
* Returns the selection service.
*/
ISelectionService* GetSelectionService();
/*
* Notifies that a page has been activated.
*/
void PageActivated(SmartPointer<IWorkbenchPage> newPage);
/*
* Notifies that a page has been closed
*/
void PageClosed(SmartPointer<IWorkbenchPage> page);
/*
* Notifies that a page has been opened.
*/
void PageOpened(SmartPointer<IWorkbenchPage> page);
private:
void UpdateActivePart();
/*
* Resets the part service. The active page, part and selection are
* dereferenced.
*/
void Reset();
};
}
#endif /* BERRYWWINPARTSERVICE_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWindowManager.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWindowManager.cpp
index e6d83c280e..449e4b2f75 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWindowManager.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWindowManager.cpp
@@ -1,103 +1,103 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryWindowManager.h"
#include "berryWindow.h"
#include <algorithm>
namespace berry
{
void WindowManager::AddWindowManager(WindowManager* wm)
{
if (std::find(subManagers.begin(), subManagers.end(), wm)
== subManagers.end())
{
subManagers.push_back(wm);
}
}
WindowManager::WindowManager()
{
}
WindowManager::WindowManager(WindowManager* parent)
{
poco_assert(parent != 0);
parent->AddWindowManager(this);
}
void WindowManager::Add(Window::Pointer window)
{
if (std::find(windows.begin(), windows.end(), window) == windows.end())
{
windows.push_back(window);
window->SetWindowManager(this);
}
}
bool WindowManager::Close()
{
std::vector<Window::Pointer> t = windows; // make iteration robust
for (std::vector<Window::Pointer>::iterator iter = t.begin();
iter != t.end(); ++iter)
{
bool closed = (*iter)->Close();
if (!closed)
{
return false;
}
}
if (!subManagers.empty())
{
for (std::list<WindowManager*>::iterator iter = subManagers.begin();
iter != subManagers.end(); ++iter)
{
WindowManager* wm = *iter;
bool closed = wm->Close();
if (!closed)
{
return false;
}
}
}
return true;
}
std::size_t WindowManager::GetWindowCount()
{
return windows.size();
}
std::vector<Window::Pointer> WindowManager::GetWindows()
{
return windows;
}
void WindowManager::Remove(Window::Pointer window)
{
std::vector<Window::Pointer>::iterator iter = std::find(windows.begin(), windows.end(), window);
if (iter != windows.end())
{
windows.erase(iter);
window->SetWindowManager(0);
}
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWindowManager.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWindowManager.h
index f927c9cd00..46ad30a042 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWindowManager.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWindowManager.h
@@ -1,134 +1,134 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYWINDOWMANAGER_H_
#define BERRYWINDOWMANAGER_H_
#include <vector>
#include <berrySmartPointer.h>
#include <list>
namespace berry
{
class Window;
/**
* A manager for a group of windows. Window managers are an optional JFace
* feature used in applications which create many different windows (dialogs,
* wizards, etc.) in addition to a main window. A window manager can be used to
* remember all the windows that an application has created (independent of
* whether they are presently open or closed). There can be several window
* managers, and they can be arranged into a tree. This kind of organization
* makes it simple to close whole subgroupings of windows.
* <p>
* Creating a window manager is as simple as creating an instance of
* <code>WindowManager</code>. Associating a window with a window manager is
* done with <code>WindowManager.add(Window)</code>. A window is automatically
* removed from its window manager as a side effect of closing the window.
* </p>
*
* @see Window
*/
class WindowManager {
private:
/**
* List of windows managed by this window manager
* (element type: <code>Window</code>).
*/
std::vector<SmartPointer<Window> > windows;
/**
* List of window managers who have this window manager
* as their parent (element type: <code>WindowManager</code>).
*/
std::list<WindowManager*> subManagers;
/**
* Adds the given window manager to the list of
* window managers that have this one as a parent.
* </p>
* @param wm the child window manager
*/
void AddWindowManager(WindowManager* wm);
public:
/**
* Creates an empty window manager without a parent window
* manager (that is, a root window manager).
*/
WindowManager();
/**
* Creates an empty window manager with the given
* window manager as parent.
*
* @param parent the parent window manager
*/
WindowManager(WindowManager* parent);
/**
* Adds the given window to the set of windows managed by
* this window manager. Does nothing is this window is
* already managed by this window manager.
*
* @param window the window
*/
void Add(SmartPointer<Window> window);
/**
* Attempts to close all windows managed by this window manager,
* as well as windows managed by any descendent window managers.
*
* @return <code>true</code> if all windows were sucessfully closed,
* and <code>false</code> if any window refused to close
*/
bool Close();
/**
* Returns this window manager's number of windows
*
* @return the number of windows
* @since 3.0
*/
std::size_t GetWindowCount();
/**
* Returns this window manager's set of windows.
*
* @return a possibly empty list of window
*/
std::vector<SmartPointer<Window> > GetWindows();
/**
* Removes the given window from the set of windows managed by
* this window manager. Does nothing is this window is
* not managed by this window manager.
*
* @param window the window
*/
void Remove(SmartPointer<Window> window);
};
}
#endif /* BERRYWINDOWMANAGER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWindowPartSelectionTracker.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWindowPartSelectionTracker.cpp
index dcfd0688dc..d28d451d3d 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWindowPartSelectionTracker.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWindowPartSelectionTracker.cpp
@@ -1,80 +1,80 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryWindowPartSelectionTracker.h"
#include "berryIWorkbenchWindow.h"
#include "berryIWorkbenchPage.h"
namespace berry
{
void WindowPartSelectionTracker::SetWindow(
IWorkbenchWindow* window)
{
fWindow = window;
}
WindowPartSelectionTracker::WindowPartSelectionTracker(IWorkbenchWindow* window,
const std::string& partId) :
AbstractPartSelectionTracker(partId), selListener(
new NullSelectionChangedAdapter<WindowPartSelectionTracker> (this,
&WindowPartSelectionTracker::FireSelection)), postSelListener(
new NullSelectionChangedAdapter<WindowPartSelectionTracker> (this,
&WindowPartSelectionTracker::FirePostSelection))
{
SetWindow(window);
//window.addPageListener(this);
IWorkbenchPage::Pointer page = window->GetActivePage();
if (page)
{
PageOpened(page);
}
}
void WindowPartSelectionTracker::PageActivated(
SmartPointer<IWorkbenchPage> /*page*/)
{
}
void WindowPartSelectionTracker::PageClosed(SmartPointer<IWorkbenchPage> page)
{
page->RemoveSelectionListener(GetPartId(), selListener);
page->RemovePostSelectionListener(GetPartId(), postSelListener);
}
void WindowPartSelectionTracker::PageOpened(SmartPointer<IWorkbenchPage> page)
{
page->AddSelectionListener(GetPartId(), selListener);
page->AddPostSelectionListener(GetPartId(), postSelListener);
}
ISelection::ConstPointer WindowPartSelectionTracker::GetSelection()
{
IWorkbenchPage::Pointer page = GetWindow()->GetActivePage();
if (page)
{
return page->GetSelection(GetPartId());
}
return ISelection::ConstPointer(0);
}
SmartPointer<IWorkbenchWindow> WindowPartSelectionTracker::GetWindow()
{
return IWorkbenchWindow::Pointer(fWindow);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWindowPartSelectionTracker.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWindowPartSelectionTracker.h
index 7b80cc04c8..b8f4f6e549 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWindowPartSelectionTracker.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWindowPartSelectionTracker.h
@@ -1,107 +1,107 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYWINDOWPARTSELECTIONTRACKER_H_
#define BERRYWINDOWPARTSELECTIONTRACKER_H_
#include "berryAbstractPartSelectionTracker.h"
#include "berryINullSelectionListener.h"
namespace berry {
struct IWorkbenchWindow;
struct IWorkbenchPage;
/**
* Provides part selection tracking for a part with a specific id
* in all pages of a specific workbench window. This tracker shields
* clients from a part opening and closing, and still provides selection
* notification/information even when the part is not active.
*/
class WindowPartSelectionTracker : public AbstractPartSelectionTracker {
// implements IPageListener {
private:
/**
* The window this selection tracker is working in
*/
IWorkbenchWindow* fWindow;
/**
* Part selection listener.
*/
INullSelectionListener::Pointer selListener;
/**
* Part post selection listener
*/
INullSelectionListener::Pointer postSelListener;
/**
* Sets the window this tracker is working in.
*
* @param window workbench window
*/
void SetWindow(IWorkbenchWindow* window);
public:
/**
* Constructs a new selection tracker for the given window and part id.
*
* @param window workbench window
* @param partId part identifier
*/
WindowPartSelectionTracker(IWorkbenchWindow* window, const std::string& partId);
/*
* @see IPageListener#pageActivated(IWorkbenchPage)
*/
void PageActivated(SmartPointer<IWorkbenchPage> page);
/*
* @see IPageListener#pageClosed(IWorkbenchPage)
*/
void PageClosed(SmartPointer<IWorkbenchPage> page);
/*
* @see IPageListener#pageOpened(IWorkbenchPage)
*/
void PageOpened(SmartPointer<IWorkbenchPage> page);
/*
* @see AbstractPartSelectionTracker#getSelection()
*/
ISelection::ConstPointer GetSelection();
protected:
/**
* Returns the window this tracker is working in.
*
* @return workbench window
*/
SmartPointer<IWorkbenchWindow> GetWindow();
};
}
#endif /* BERRYWINDOWPARTSELECTIONTRACKER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWindowSelectionService.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWindowSelectionService.cpp
index 42ee4dbb26..df0a5cc13a 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWindowSelectionService.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWindowSelectionService.cpp
@@ -1,49 +1,49 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryWindowSelectionService.h"
#include "berryWindowPartSelectionTracker.h"
#include "berryIWorkbenchWindow.h"
namespace berry
{
void WindowSelectionService::SetWindow(IWorkbenchWindow* window)
{
this->window = window;
}
IWorkbenchWindow* WindowSelectionService::GetWindow() const
{
return window;
}
AbstractPartSelectionTracker::Pointer WindowSelectionService::CreatePartTracker(
const std::string& partId) const
{
AbstractPartSelectionTracker::Pointer tracker(new WindowPartSelectionTracker(
GetWindow(), partId));
return tracker;
}
WindowSelectionService::WindowSelectionService(
IWorkbenchWindow* window)
{
SetWindow(window);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWindowSelectionService.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWindowSelectionService.h
index dfc9f0c436..c1e01df014 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWindowSelectionService.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWindowSelectionService.h
@@ -1,68 +1,68 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYWINDOWSELECTIONSERVICE_H_
#define BERRYWINDOWSELECTIONSERVICE_H_
#include "berryAbstractSelectionService.h"
namespace berry {
struct IWorkbenchWindow;
/**
* The selection service for a window.
*/
/* package */
class WindowSelectionService : public AbstractSelectionService {
private:
/**
* The window.
*/
IWorkbenchWindow* window;
/**
* Sets the window.
*/
void SetWindow(IWorkbenchWindow* window);
protected:
/**
* Returns the window.
*/
IWorkbenchWindow* GetWindow() const;
/*
* @see AbstractSelectionService#createPartTracker(String)
*/
AbstractPartSelectionTracker::Pointer CreatePartTracker(const std::string& partId) const;
public:
/**
* Creates a new selection service for the given window.
*/
WindowSelectionService(IWorkbenchWindow* window);
};
}
#endif /* BERRYWINDOWSELECTIONSERVICE_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbench.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbench.cpp
index 526cad28d5..cd5e031472 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbench.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbench.cpp
@@ -1,1778 +1,1778 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryLog.h"
#include "tweaklets/berryWorkbenchTweaklet.h"
#include "berryWorkbench.h"
#include <berrySafeRunner.h>
#include "berrySaveablesList.h"
#include "berryViewRegistry.h"
#include "berryEditorRegistry.h"
#include "berryServiceLocatorCreator.h"
#include "berryWorkbenchPage.h"
#include "berryPerspective.h"
#include "berryPreferenceConstants.h"
#include "dialogs/berryMessageDialog.h"
#include "berryWorkbenchWindow.h"
#include "berryImageDescriptor.h"
#include "berryDisplay.h"
#include "services/berryIServiceFactory.h"
#include "util/berrySafeRunnable.h"
#include "berryWorkbenchPlugin.h"
#include "berryWorkbenchConstants.h"
#include <Poco/Thread.h>
#include <Poco/Bugcheck.h>
#include <Poco/FileStream.h>
namespace berry
{
Workbench* Workbench::instance = 0;
WorkbenchTestable::Pointer Workbench::testableObject;
const unsigned int Workbench::VERSION_STRING_COUNT = 1;
const std::string Workbench::VERSION_STRING[Workbench::VERSION_STRING_COUNT] =
{ "1.0" };
const std::string Workbench::DEFAULT_WORKBENCH_STATE_FILENAME = "workbench.xml";
class RestoreStateRunnable: public SafeRunnable
{
private:
Workbench* workbench;
Poco::File stateFile;
bool& result;
public:
RestoreStateRunnable(Workbench* workbench, const Poco::File& stateFile,
bool& result) :
SafeRunnable(
"Unable to read workbench state. Workbench UI layout will be reset."),
workbench(workbench), stateFile(stateFile), result(result)
{
}
void Run()
{
Poco::FileInputStream input(stateFile.path());
IMemento::Pointer memento = XMLMemento::CreateReadRoot(input);
// Validate known version format
std::string version;
memento->GetString(WorkbenchConstants::TAG_VERSION, version);
bool valid = false;
for (std::size_t i = 0; i < Workbench::VERSION_STRING_COUNT; i++)
{
if (Workbench::VERSION_STRING[i] == version)
{
valid = true;
break;
}
}
if (!valid)
{
input.close();
std::string msg =
"Invalid workbench state version. workbench.xml will be deleted";
MessageDialog::OpenError(Shell::Pointer(0), "Restoring Problems", msg);
stateFile.remove();
// result[0] = new Status(IStatus.ERROR,
// WorkbenchPlugin.PI_WORKBENCH,
// IWorkbenchConfigurer.RESTORE_CODE_RESET, msg, null);
result = false;
return;
}
// // Validate compatible version format
// // We no longer support the release 1.0 format
// if (VERSION_STRING[0].equals(version))
// {
// reader.close();
// std::string msg = "The saved user interface layout is in an "
// "obsolete format and cannot be preserved. Your projects and files "
// "will not be affected. Press OK to convert to the new format. Press "
// "Cancel to exit with no changes.";
// std::vector<std::string> dlgLabels;
// dlgLabels.push_back("Ok");
// dlgLabels.push_back("Cancel");
// IDialog::Pointer dlg = MessageDialog::CreateDialog(Shell::Pointer(0),
// "Cannot Preserve Layout", 0, msg, IDialog::WARNING, dlgLabels, 0);
// IDialog::ReturnCode ignoreSavedState = dlg->Open();
// // OK is the default
// if (ignoreSavedState == IDialog::OK)
// {
// stateFile.remove();
// // result[0] = new Status(IStatus.WARNING,
// // WorkbenchPlugin.PI_WORKBENCH,
// // IWorkbenchConfigurer.RESTORE_CODE_RESET, msg,
// // null);
// result = false;
// }
// else
// {
// // result[0] = new Status(IStatus.WARNING,
// // WorkbenchPlugin.PI_WORKBENCH,
// // IWorkbenchConfigurer.RESTORE_CODE_EXIT, msg,
// // null);
// result = false;
// }
// return;
// }
// Restore the saved state
//final IStatus restoreResult = restoreState(memento);
/*bool restoreResult =*/ workbench->RestoreState(memento);
input.close();
// if (restoreResult.getSeverity() == IStatus.ERROR) {
// StartupThreading
// .runWithoutExceptions(new StartupRunnable() {
//
// public void runWithException() throws Throwable {
// StatusManager.getManager().handle(restoreResult, StatusManager.LOG);
// }
// });
//
// }
}
void HandleException(const std::exception& e)
{
//StartupThreading.runWithoutExceptions(new StartupRunnable() {
//public void runWithException() {
Handle(e);
// std::string msg = e.getMessage() == null ? "" : e.getMessage(); //$NON-NLS-1$
// result[0] = new Status(IStatus.ERROR,
// WorkbenchPlugin.PI_WORKBENCH,
// IWorkbenchConfigurer.RESTORE_CODE_RESET, msg, e);
result = false;
stateFile.remove();
// }});
}
private:
void Handle(const std::exception& e)
{
SafeRunnable::HandleException(e);
}
};
int Workbench::CreateAndRunWorkbench(Display* display,
WorkbenchAdvisor* advisor)
{
// create the workbench instance
Workbench workbench(display, advisor);
// run the workbench event loop
int returnCode = workbench.RunUI();
return returnCode;
}
Display* Workbench::CreateDisplay()
{
// create the display
Display* newDisplay = Tweaklets::Get(WorkbenchTweaklet::KEY)->CreateDisplay();
// workaround for 1GEZ9UR and 1GF07HN
//newDisplay.setWarnings(false);
// Set the priority higher than normal so as to be higher
// than the JobManager.
//Poco::Thread::current()->setPriority(Poco::Thread::PRIO_HIGH);
//initializeImages();
return newDisplay;
}
Workbench::ServiceLocatorOwner::ServiceLocatorOwner(Workbench* wb) :
workbench(wb)
{
}
void Workbench::ServiceLocatorOwner::Dispose()
{
MessageDialog::OpenInformation(
Shell::Pointer(0),
"Restart needed",
"A required plug-in is no longer available and the Workbench needs to be restarted. You will be prompted to save if there is any unsaved work.");
workbench->Close(PlatformUI::RETURN_RESTART, true);
}
Workbench::Workbench(Display* display, WorkbenchAdvisor* advisor) :
progressCount(-1), serviceLocatorOwner(new ServiceLocatorOwner(this)),
largeUpdates(0), introManager(0), isStarting(true), isClosing(false)
{
poco_check_ptr(display)
; poco_check_ptr(advisor);
// the reference count to the one and only workbench instance
// is increased, so that temporary smart pointer to the workbench
// do not delete it
this->Register();
this->display = display;
this->advisor = advisor;
Workbench::instance = this;
IServiceLocatorCreator::Pointer slc(new ServiceLocatorCreator());
this->serviceLocator =
slc->CreateServiceLocator(IServiceLocator::WeakPtr(),
IServiceFactory::ConstPointer(0),
IDisposable::WeakPtr(serviceLocatorOwner)).Cast<ServiceLocator>();
serviceLocator->RegisterService(IServiceLocatorCreator::GetManifestName(), slc);
returnCode = PlatformUI::RETURN_UNSTARTABLE;
}
Display* Workbench::GetDisplay()
{
return display;
}
Workbench* Workbench::GetInstance()
{
return instance;
}
WorkbenchTestable::Pointer Workbench::GetWorkbenchTestable()
{
if (!testableObject)
{
testableObject = new WorkbenchTestable();
}
return testableObject;
}
Workbench::~Workbench()
{
this->UnRegister(false);
}
Object::Pointer Workbench::GetService(const std::string& key)
{
return serviceLocator->GetService(key);
}
bool Workbench::HasService(const std::string& key) const
{
return serviceLocator->HasService(key);
}
bool Workbench::Init()
{
bool bail = false;
// create workbench window manager
//windowManager = new WindowManager();
IIntroRegistry* introRegistry = WorkbenchPlugin::GetDefault()
->GetIntroRegistry();
if (introRegistry->GetIntroCount() > 0) {
//TODO Product support
//IProduct product = Platform.getProduct();
//if (product != null) {
introDescriptor = introRegistry
->GetIntroForProduct("").Cast<IntroDescriptor>(); //product.getId());
//}
}
// TODO Correctly order service initialization
// there needs to be some serious consideration given to
// the services, and hooking them up in the correct order
//final EvaluationService restrictionService = new EvaluationService();
//final EvaluationService evaluationService = new EvaluationService();
// StartupThreading.runWithoutExceptions(new StartupRunnable() {
//
// public void runWithException() {
// serviceLocator.registerService(IRestrictionService.class,
// restrictionService);
// serviceLocator.registerService(IEvaluationService.class,
// evaluationService);
// }
// });
// Initialize the activity support.
//workbenchActivitySupport = new WorkbenchActivitySupport();
//activityHelper = ActivityPersistanceHelper.getInstance();
this->InitializeDefaultServices();
// initializeFonts();
// initializeColors();
// initializeApplicationColors();
// now that the workbench is sufficiently initialized, let the advisor
// have a turn.
advisor->InternalBasicInitialize(this->GetWorkbenchConfigurer());
// attempt to restore a previous workbench state
advisor->PreStartup();
if (!advisor->OpenWindows())
{
bail = true;
}
if (bail)
return false;
//forceOpenPerspective();
return true;
}
bool Workbench::RestoreState()
{
//return false;
if (!GetWorkbenchConfigurer()->GetSaveAndRestore())
{
// std::string msg = "This application does not save and restore previously saved state.";
// return new Status(IStatus.WARNING, WorkbenchPlugin.PI_WORKBENCH,
// IWorkbenchConfigurer.RESTORE_CODE_RESET, msg, null);
return false;
}
// Read the workbench state file.
Poco::File stateFile;
// If there is no state file cause one to open.
if (!GetWorkbenchStateFile(stateFile) || !stateFile.exists())
{
// std::string msg = "No previously saved state to restore.";
// return new Status(IStatus.WARNING, WorkbenchPlugin.PI_WORKBENCH,
// IWorkbenchConfigurer.RESTORE_CODE_RESET, msg, null);
return false;
}
// final IStatus result[] = { new Status(IStatus.OK,
// WorkbenchPlugin.PI_WORKBENCH, IStatus.OK, "", null) }; //$NON-NLS-1$
bool result = true;
ISafeRunnable::Pointer runnable(new RestoreStateRunnable(this, stateFile, result));
SafeRunner::Run(runnable);
// ensure at least one window was opened
//if (result[0].isOK() && windowManager.getWindows().length == 0)
if (result && windowManager.GetWindowCount() == 0)
{
std::string msg = "No windows restored.";
// result[0] = new Status(IStatus.ERROR, WorkbenchPlugin.PI_WORKBENCH,
// IWorkbenchConfigurer.RESTORE_CODE_RESET, msg, null);
result &= false;
}
return result;
}
bool Workbench::RestoreState(IMemento::Pointer memento)
{
// final MultiStatus result = new MultiStatus(PlatformUI.PLUGIN_ID,
// IStatus.OK, WorkbenchMessages.Workbench_problemsRestoring, null);
bool result = true;
const bool showProgress = false;
//TODO restore state progress
// final boolean showProgress = PrefUtil.getAPIPreferenceStore()
// .getBoolean(
// IWorkbenchPreferenceConstants.SHOW_PROGRESS_ON_STARTUP);
try
{
/*
* Restored windows will be set in the createdWindows field to be
* used by the openWindowsAfterRestore() method
*/
if (!showProgress)
{
DoRestoreState(memento, result);
}
else
{
// Retrieve how many plug-ins were loaded while restoring the
// workbench
int lastProgressCount = -1;
memento->GetInteger(WorkbenchConstants::TAG_PROGRESS_COUNT, lastProgressCount);
// If we don't know how many plug-ins were loaded last time,
// assume we are loading half of the installed plug-ins.
/*const std::size_t expectedProgressCount =*/
std::max<std::size_t>(1,
lastProgressCount == -1 ? WorkbenchPlugin::GetDefault()->GetBundleCount() / 2
: lastProgressCount);
//TODO restore state progress
// RunStartupWithProgress(expectedProgressCount, new Runnable() {
// public void Run() {
// DoRestoreState(memento, result);
// }
// });
}
}
catch (...)
{
OpenWindowsAfterRestore();
throw;
}
OpenWindowsAfterRestore();
return result;
}
void Workbench::DoRestoreState(IMemento::Pointer memento, bool& status) // final MultiStatus status)
{
IMemento::Pointer childMem;
try
{
// UIStats.start(UIStats.RESTORE_WORKBENCH, "MRUList"); //$NON-NLS-1$
IMemento::Pointer mruMemento = memento
->GetChild(WorkbenchConstants::TAG_MRU_LIST);
if (mruMemento)
{
// TODO restore editor history
//status.add(getEditorHistory().restoreState(mruMemento));
}
//UIStats.end(UIStats.RESTORE_WORKBENCH, this, "MRUList"); //$NON-NLS-1$
}
catch (...)
{
//UIStats.end(UIStats.RESTORE_WORKBENCH, this, "MRUList"); //$NON-NLS-1$
throw;
}
// Restore advisor state.
IMemento::Pointer advisorState = memento
->GetChild(WorkbenchConstants::TAG_WORKBENCH_ADVISOR);
if (advisorState)
{
//status.add(getAdvisor().restoreState(advisorState));
status &= GetAdvisor()->RestoreState(advisorState);
}
// Get the child windows.
std::vector<IMemento::Pointer> children = memento
->GetChildren(WorkbenchConstants::TAG_WINDOW);
createdWindows.clear();
// Read the workbench windows.
for (std::size_t i = 0; i < children.size(); i++)
{
childMem = children[i];
WorkbenchWindow::Pointer newWindow;
//StartupThreading.runWithoutExceptions(new StartupRunnable() {
// public void runWithException() {
newWindow = NewWorkbenchWindow();
newWindow->Create();
// }});
createdWindows.push_back(newWindow);
// allow the application to specify an initial perspective to open
// @issue temporary workaround for ignoring initial perspective
// String initialPerspectiveId =
// getAdvisor().getInitialWindowPerspectiveId();
// if (initialPerspectiveId != null) {
// IPerspectiveDescriptor desc =
// getPerspectiveRegistry().findPerspectiveWithId(initialPerspectiveId);
// result.merge(newWindow.restoreState(childMem, desc));
// }
// add the window so that any work done in newWindow.restoreState
// that relies on Workbench methods has windows to work with
windowManager.Add(newWindow);
// now that we've added it to the window manager we need to listen
// for any exception that might hose us before we get a chance to
// open it. If one occurs, remove the new window from the manager.
// Assume that the new window is a phantom for now
try
{
//status.merge(newWindow[0].restoreState(childMem, null));
status &= newWindow->RestoreState(childMem, IPerspectiveDescriptor::Pointer(0));
try
{
newWindow->FireWindowRestored();
}
catch (const WorkbenchException& /*e*/)
{
//status.add(e.getStatus());
status &= false;
}
// everything worked so far, don't close now
}
catch (...)
{
// null the window in newWindowHolder so that it won't be
// opened later on
createdWindows[i] = 0;
//StartupThreading.runWithoutExceptions(new StartupRunnable() {
// public void runWithException() throws Throwable {
newWindow->Close();
// }});
}
}
}
void Workbench::OpenWindowsAfterRestore()
{
if (createdWindows.empty())
{
return;
}
// now open the windows (except the ones that were nulled because we
// closed them above)
for (std::size_t i = 0; i < createdWindows.size(); i++)
{
if (createdWindows[i])
{
WorkbenchWindow::Pointer myWindow = createdWindows[i];
//StartupThreading.runWithoutExceptions(new StartupRunnable() {
// public void runWithException() throws Throwable {
try
{
myWindow->Open();
}
catch (...)
{
myWindow->Close();
throw;
}
// }});
}
}
createdWindows.clear();
}
void Workbench::InitializeDefaultServices()
{
// final IContributionService contributionService = new ContributionService(
// getAdvisor());
// serviceLocator.registerService(IContributionService.class,
// contributionService);
//
// // TODO Correctly order service initialization
// // there needs to be some serious consideration given to
// // the services, and hooking them up in the correct order
// final IEvaluationService evaluationService =
// (IEvaluationService) serviceLocator.getService(IEvaluationService.class);
//
//
//
// StartupThreading.runWithoutExceptions(new StartupRunnable() {
//
// public void runWithException() {
Object::Pointer service(new SaveablesList());
serviceLocator->RegisterService(ISaveablesLifecycleListener::GetManifestName(),
service);
// }});
//
// /*
// * Phase 1 of the initialization of commands. When this phase completes,
// * all the services and managers will exist, and be accessible via the
// * getService(Object) method.
// */
// StartupThreading.runWithoutExceptions(new StartupRunnable() {
//
// public void runWithException() {
// Command.DEBUG_COMMAND_EXECUTION = Policy.DEBUG_COMMANDS;
// commandManager = new CommandManager();
// }});
//
// final CommandService [] commandService = new CommandService[1];
// StartupThreading.runWithoutExceptions(new StartupRunnable() {
//
// public void runWithException() {
// commandService[0] = new CommandService(commandManager);
// commandService[0].readRegistry();
// serviceLocator.registerService(ICommandService.class, commandService[0]);
//
// }});
//
// StartupThreading.runWithoutExceptions(new StartupRunnable() {
//
// public void runWithException() {
// ContextManager.DEBUG = Policy.DEBUG_CONTEXTS;
// contextManager = new ContextManager();
// }});
//
// final IContextService contextService = new ContextService(
// contextManager);
//
// StartupThreading.runWithoutExceptions(new StartupRunnable() {
//
// public void runWithException() {
// contextService.readRegistry();
// }});
//
// serviceLocator.registerService(IContextService.class, contextService);
//
//
// final IBindingService [] bindingService = new BindingService[1];
//
// StartupThreading.runWithoutExceptions(new StartupRunnable() {
//
// public void runWithException() {
// BindingManager.DEBUG = Policy.DEBUG_KEY_BINDINGS;
// bindingManager = new BindingManager(contextManager, commandManager);
// bindingService[0] = new BindingService(
// bindingManager, commandService[0], Workbench.this);
//
// }});
//
// bindingService[0].readRegistryAndPreferences(commandService[0]);
// serviceLocator.registerService(IBindingService.class, bindingService[0]);
//
// final CommandImageManager commandImageManager = new CommandImageManager();
// final CommandImageService commandImageService = new CommandImageService(
// commandImageManager, commandService[0]);
// commandImageService.readRegistry();
// serviceLocator.registerService(ICommandImageService.class,
// commandImageService);
//
// final WorkbenchMenuService menuService = new WorkbenchMenuService(serviceLocator);
//
// serviceLocator.registerService(IMenuService.class, menuService);
// // the service must be registered before it is initialized - its
// // initialization uses the service locator to address a dependency on
// // the menu service
// StartupThreading.runWithoutExceptions(new StartupRunnable() {
//
// public void runWithException() {
// menuService.readRegistry();
// }});
//
// /*
// * Phase 2 of the initialization of commands. The source providers that
// * the workbench provides are creating and registered with the above
// * services. These source providers notify the services when particular
// * pieces of workbench state change.
// */
// final SourceProviderService sourceProviderService = new SourceProviderService(serviceLocator);
// serviceLocator.registerService(ISourceProviderService.class,
// sourceProviderService);
// StartupThreading.runWithoutExceptions(new StartupRunnable() {
//
// public void runWithException() {
// // this currently instantiates all players ... sigh
// sourceProviderService.readRegistry();
// ISourceProvider[] sp = sourceProviderService.getSourceProviders();
// for (int i = 0; i < sp.length; i++) {
// evaluationService.addSourceProvider(sp[i]);
// if (!(sp[i] instanceof ActiveContextSourceProvider)) {
// contextService.addSourceProvider(sp[i]);
// }
// }
// }});
//
// StartupThreading.runWithoutExceptions(new StartupRunnable() {
//
// public void runWithException() {
// // these guys are need to provide the variables they say
// // they source
// actionSetSourceProvider = (ActionSetSourceProvider) sourceProviderService
// .getSourceProvider(ISources.ACTIVE_ACTION_SETS_NAME);
//
// FocusControlSourceProvider focusControl = (FocusControlSourceProvider) sourceProviderService
// .getSourceProvider(ISources.ACTIVE_FOCUS_CONTROL_ID_NAME);
// serviceLocator.registerService(IFocusService.class,
// focusControl);
//
// menuSourceProvider = (MenuSourceProvider) sourceProviderService
// .getSourceProvider(ISources.ACTIVE_MENU_NAME);
// }});
//
// /*
// * Phase 3 of the initialization of commands. This handles the creation
// * of wrappers for legacy APIs. By the time this phase completes, any
// * code trying to access commands through legacy APIs should work.
// */
// final IHandlerService[] handlerService = new IHandlerService[1];
// StartupThreading.runWithoutExceptions(new StartupRunnable() {
//
// public void runWithException() {
// handlerService[0] = (IHandlerService) serviceLocator
// .getService(IHandlerService.class);
// }
// });
// workbenchContextSupport = new WorkbenchContextSupport(this,
// contextManager);
// workbenchCommandSupport = new WorkbenchCommandSupport(bindingManager,
// commandManager, contextManager, handlerService[0]);
// initializeCommandResolver();
//
// addWindowListener(windowListener);
// bindingManager.addBindingManagerListener(bindingManagerListener);
//
// serviceLocator.registerService(ISelectionConversionService.class,
// new SelectionConversionService());
}
int Workbench::RunUI()
{
// initialize workbench and restore or open one window
bool initOK = this->Init();
// let the advisor run its start up code
if (initOK)
{
advisor->PostStartup(); // may trigger a close/restart
}
//TODO start eager plug-ins
//startPlugins();
//addStartupRegistryListener();
isStarting = false;
BERRY_INFO << "BlueBerry Workbench ready";
this->GetWorkbenchTestable()->Init(Display::GetDefault(), this);
// spin event loop
return display->RunEventLoop();
}
std::string Workbench::GetDefaultPerspectiveId()
{
return this->GetAdvisor()->GetInitialWindowPerspectiveId();
}
IAdaptable* Workbench::GetDefaultPageInput()
{
return this->GetAdvisor()->GetDefaultPageInput();
}
std::string Workbench::GetPresentationId()
{
if (factoryID != "")
{
return factoryID;
}
//factoryID = PrefUtil.getAPIPreferenceStore().getString(
// IWorkbenchPreferenceConstants.PRESENTATION_FACTORY_ID);
// Workaround for bug 58975 - New preference mechanism does not properly
// initialize defaults
// Ensure that the UI plugin has started too.
factoryID = WorkbenchConstants::DEFAULT_PRESENTATION_ID;
return factoryID;
}
void Workbench::UpdateTheme()
{
WorkbenchPlugin::GetDefault()->GetPresentationFactory()->UpdateTheme();
}
void Workbench::LargeUpdateStart()
{
if (largeUpdates++ == 0)
{
// TODO Consider whether these lines still need to be here.
// workbenchCommandSupport.setProcessing(false);
// workbenchContextSupport.setProcessing(false);
std::vector<IWorkbenchWindow::Pointer> windows = this->GetWorkbenchWindows();
for (unsigned int i = 0; i < windows.size(); i++)
{
IWorkbenchWindow::Pointer window = windows[i];
if (window.Cast<WorkbenchWindow>() != 0)
{
window.Cast<WorkbenchWindow>()->LargeUpdateStart();
}
}
}
}
void Workbench::LargeUpdateEnd()
{
if (--largeUpdates == 0)
{
// TODO Consider whether these lines still need to be here.
// workbenchCommandSupport.setProcessing(true);
// workbenchContextSupport.setProcessing(true);
// Perform window-specific blocking.
std::vector<IWorkbenchWindow::Pointer> windows = this->GetWorkbenchWindows();
for (unsigned int i = 0; i < windows.size(); i++)
{
IWorkbenchWindow::Pointer window = windows[i];
if (window.Cast<WorkbenchWindow>() != 0)
{
window.Cast<WorkbenchWindow>()->LargeUpdateEnd();
}
}
}
}
void Workbench::OpenFirstTimeWindow()
{
try
{
IAdaptable* input;
//StartupThreading.runWithoutExceptions(new StartupRunnable() {
// public void runWithException() throws Throwable {
input = this->GetDefaultPageInput();
// }});
this->BusyOpenWorkbenchWindow(this->GetPerspectiveRegistry()->GetDefaultPerspective(), input);
}
catch (WorkbenchException& e)
{
// Don't use the window's shell as the dialog parent,
// as the window is not open yet (bug 76724).
//StartupThreading.runWithoutExceptions(new StartupRunnable() {
// public void runWithException() throws Throwable {
// ErrorDialog.openError(null,
// WorkbenchMessages.Problems_Opening_Page, e.getMessage(), e
// .getStatus());
// }});
BERRY_ERROR << "Error: Problems opening page. " << e.displayText() << std::endl;
}
}
WorkbenchConfigurer::Pointer Workbench::GetWorkbenchConfigurer()
{
if (workbenchConfigurer.IsNull())
{
workbenchConfigurer = new WorkbenchConfigurer();
}
return workbenchConfigurer;
}
WorkbenchAdvisor* Workbench::GetAdvisor()
{
return advisor;
}
IViewRegistry* Workbench::GetViewRegistry()
{
return WorkbenchPlugin::GetDefault()->GetViewRegistry();
}
IEditorRegistry* Workbench::GetEditorRegistry()
{
return WorkbenchPlugin::GetDefault()->GetEditorRegistry();
}
IPerspectiveRegistry* Workbench::GetPerspectiveRegistry()
{
return WorkbenchPlugin::GetDefault()->GetPerspectiveRegistry();
}
bool Workbench::Close()
{
return this->Close(PlatformUI::RETURN_OK, false);
}
bool Workbench::Close(int returnCode, bool force)
{
BERRY_INFO << "Closing workbench...";
this->returnCode = returnCode;
bool ret;
//BusyIndicator.showWhile(null, new Runnable() {
// public void run() {
ret = this->BusyClose(force);
// }
//});
return ret;
}
/**
* Closes the workbench. Assumes that the busy cursor is active.
*
* @param force
* true if the close is mandatory, and false if the close is
* allowed to fail
* @return true if the close succeeded, and false otherwise
*/
bool Workbench::BusyClose(bool force)
{
// notify the advisor of preShutdown and allow it to veto if not forced
isClosing = advisor->PreShutdown();
if (!force && !isClosing)
{
return false;
}
// notify regular workbench clients of preShutdown and allow them to
// veto if not forced
isClosing = this->FirePreShutdown(force);
if (!force && !isClosing)
{
return false;
}
// save any open editors if they are dirty
isClosing = this->SaveAllEditors(!force);
if (!force && !isClosing)
{
return false;
}
bool closeEditors = !force && false; // false is the default for the not yet implemented preference below
// && PrefUtil.getAPIPreferenceStore().getBoolean(
// IWorkbenchPreferenceConstants.CLOSE_EDITORS_ON_EXIT);
if (closeEditors)
{
// SafeRunner.run(new SafeRunnable() {
// public void run() {
std::vector<IWorkbenchWindow::Pointer> windows = this->GetWorkbenchWindows();
for (unsigned int i = 0; i < windows.size(); i++)
{
IWorkbenchPage::Pointer page = windows[i]->GetActivePage();
if (page)
isClosing = isClosing && page->CloseAllEditors(false);
}
// }
//});
if (!force && !isClosing)
{
return false;
}
}
if (this->GetWorkbenchConfigurer()->GetSaveAndRestore())
{
try
{
// SafeRunner.run(new SafeRunnable() {
// public void run() {
XMLMemento::Pointer mem = RecordWorkbenchState();
// Save the IMemento to a file.
SaveMementoToFile(mem);
// }
}
catch(const Poco::Exception& e)
{
// public void handleException(Throwable e) {
std::string message;
if (e.message().empty())
{
message = "An error has occurred. See error log for more details. Do you want to exit?";
}
else
{
message = "An error has occurred: " + e.message() + ". See error log for more details. Do you want to exit?";
}
if (!MessageDialog::OpenQuestion(Shell::Pointer(0), "Error", message))
{
isClosing = false;
}
}
// }
// });
}
if (!force && !isClosing)
{
return false;
}
//SafeRunner.run(new SafeRunnable(WorkbenchMessages.ErrorClosing) {
// public void run() {
if (isClosing || force)
{
isClosing = windowManager.Close();
}
// }
//});
if (!force && !isClosing)
{
return false;
}
this->Shutdown();
display->ExitEventLoop(0);
return true;
}
bool Workbench::GetWorkbenchStateFile(Poco::File& file)
{
Poco::Path path;
if (!WorkbenchPlugin::GetDefault()->GetDataPath(path))
{
return false;
}
path.append(DEFAULT_WORKBENCH_STATE_FILENAME);
file = path;
return true;
}
/*
* Save the workbench UI in a persistence file.
*/
bool Workbench::SaveMementoToFile(XMLMemento::Pointer memento)
{
// Save it to a file.
// XXX: nobody currently checks the return value of this method.
Poco::File stateFile;
if (!GetWorkbenchStateFile(stateFile))
{
return false;
}
//BERRY_INFO << "Saving state to: " << stateFile.path() << std::endl;
try
{
Poco::FileOutputStream stream(stateFile.path());
memento->Save(stream);
}
catch (const Poco::IOException& /*e*/)
{
stateFile.remove();
MessageDialog::OpenError(Shell::Pointer(0),
"Saving Problems",
"Unable to store workbench state.");
return false;
}
// Success !
return true;
}
IWorkbenchWindow::Pointer Workbench::GetActiveWorkbenchWindow()
{
// Look for the window that was last known being
// the active one
WorkbenchWindow::Pointer win = this->GetActivatedWindow();
return win;
}
std::size_t Workbench::GetWorkbenchWindowCount()
{
return windowManager.GetWindowCount();
}
std::vector<IWorkbenchWindow::Pointer> Workbench::GetWorkbenchWindows()
{
std::vector<Window::Pointer> windows = windowManager.GetWindows();
std::vector<IWorkbenchWindow::Pointer> result;
for (std::vector<Window::Pointer>::iterator iter = windows.begin();
iter != windows.end(); ++iter)
{
result.push_back(iter->Cast<WorkbenchWindow>());
}
return result;
}
IWorkbenchWindow::Pointer Workbench::OpenWorkbenchWindow(
const std::string& perspID, IAdaptable* input)
{
// Run op in busy cursor.
//final Object[] result = new Object[1];
//BusyIndicator.showWhile(null, new Runnable() {
// public void run() {
// try {
return this->BusyOpenWorkbenchWindow(perspID, input);
// } catch (WorkbenchException e) {
// result[0] = e;
// }
// }
//});
}
IWorkbenchWindow::Pointer Workbench::OpenWorkbenchWindow(IAdaptable* input)
{
return this->OpenWorkbenchWindow(this->GetPerspectiveRegistry()
->GetDefaultPerspective(), input);
}
IWorkbenchPage::Pointer Workbench::ShowPerspective(
const std::string& perspectiveId, IWorkbenchWindow::Pointer window)
{
// If the specified window has the requested perspective open, then the
// window
// is given focus and the perspective is shown. The page's input is
// ignored.
WorkbenchWindow::Pointer win = window.Cast<WorkbenchWindow> ();
if (win)
{
IWorkbenchPage::Pointer page = win->GetActivePage();
if (page)
{
std::vector<IPerspectiveDescriptor::Pointer> perspectives(page
->GetOpenPerspectives());
for (std::size_t i = 0; i < perspectives.size(); i++)
{
IPerspectiveDescriptor::Pointer persp = perspectives[i];
if (perspectiveId == persp->GetId())
{
win->MakeVisible();
page->SetPerspective(persp);
return page;
}
}
}
}
// If another window that has the workspace root as input and the
// requested
// perpective open and active, then the window is given focus.
IAdaptable* input = GetDefaultPageInput();
std::vector<IWorkbenchWindow::Pointer> windows(GetWorkbenchWindows());
for (std::size_t i = 0; i < windows.size(); i++)
{
win = windows[i].Cast<WorkbenchWindow>();
if (window != win)
{
WorkbenchPage::Pointer page = win->GetActivePage().Cast<WorkbenchPage>();
if (page)
{
bool inputSame = false;
if (input == 0)
{
inputSame = (page->GetInput() == 0);
}
else
{
inputSame = input == page->GetInput();
}
if (inputSame)
{
Perspective::Pointer persp = page->GetActivePerspective();
if (persp)
{
IPerspectiveDescriptor::Pointer desc = persp->GetDesc();
if (desc)
{
if (perspectiveId == desc->GetId())
{
Shell::Pointer shell = win->GetShell();
shell->Open();
if (shell->GetMinimized())
{
shell->SetMinimized(false);
}
return page;
}
}
}
}
}
}
}
// Otherwise the requested perspective is opened and shown in the
// specified
// window or in a new window depending on the current user preference
// for opening
// perspectives, and that window is given focus.
win = window.Cast<WorkbenchWindow>();
if (win)
{
IPreferencesService::Pointer store = WorkbenchPlugin::GetDefault()
->GetPreferencesService();
int mode = store->GetSystemPreferences()->GetInt(PreferenceConstants::OPEN_PERSP_MODE, PreferenceConstants::OPM_ACTIVE_PAGE);
IWorkbenchPage::Pointer page = win->GetActivePage();
IPerspectiveDescriptor::Pointer persp;
if (page)
{
persp = page->GetPerspective();
}
// Only open a new window if user preference is set and the window
// has an active perspective.
if (PreferenceConstants::OPM_NEW_WINDOW == mode && persp)
{
IWorkbenchWindow::Pointer newWindow = OpenWorkbenchWindow(perspectiveId,
input);
return newWindow->GetActivePage();
}
IPerspectiveDescriptor::Pointer desc = GetPerspectiveRegistry()
->FindPerspectiveWithId(perspectiveId);
if (desc == 0)
{
throw WorkbenchException(
"Unable to create perspective \"" + perspectiveId + "\". There is no corresponding perspective extension.");
}
win->GetShell()->Open();
if (page == 0)
{
page = win->OpenPage(perspectiveId, input);
}
else
{
page->SetPerspective(desc);
}
return page;
}
// Just throw an exception....
throw WorkbenchException("Problems opening perspective \"" +
perspectiveId + "\"");
}
IWorkbenchPage::Pointer Workbench::ShowPerspective(
const std::string& /*perspectiveId*/,
IWorkbenchWindow::Pointer /*window*/,
IAdaptable* /*input*/)
{
return IWorkbenchPage::Pointer(0);
// // If the specified window has the requested perspective open and the
// // same requested
// // input, then the window is given focus and the perspective is shown.
// bool inputSameAsWindow = false;
// WorkbenchWindow::Pointer win = window.Cast<WorkbenchWindow>();
// if (win.IsNotNull()) {
// WorkbenchPage::Pointer page = win->GetActiveWorkbenchPage();
// if (page.IsNotNull()) {
// bool inputSame = false;
// if (input == 0) {
// inputSame = (page->GetInput() == 0);
// } else {
// inputSame = input.equals(page.getInput());
// }
// if (inputSame) {
// inputSameAsWindow = true;
// IPerspectiveDescriptor perspectives[] = page
// .getOpenPerspectives();
// for (int i = 0; i < perspectives.length; i++) {
// IPerspectiveDescriptor persp = perspectives[i];
// if (perspectiveId.equals(persp.getId())) {
// win.makeVisible();
// page.setPerspective(persp);
// return page;
// }
// }
// }
// }
// }
//
// // If another window has the requested input and the requested
// // perpective open and active, then that window is given focus.
// IWorkbenchWindow[] windows = getWorkbenchWindows();
// for (int i = 0; i < windows.length; i++) {
// win = (WorkbenchWindow) windows[i];
// if (window != win) {
// WorkbenchPage page = win.getActiveWorkbenchPage();
// if (page != null) {
// boolean inputSame = false;
// if (input == null) {
// inputSame = (page.getInput() == null);
// } else {
// inputSame = input.equals(page.getInput());
// }
// if (inputSame) {
// Perspective persp = page.getActivePerspective();
// if (persp != null) {
// IPerspectiveDescriptor desc = persp.getDesc();
// if (desc != null) {
// if (perspectiveId.equals(desc.getId())) {
// win.getShell().open();
// return page;
// }
// }
// }
// }
// }
// }
// }
//
// // If the specified window has the same requested input but not the
// // requested
// // perspective, then the window is given focus and the perspective is
// // opened and shown
// // on condition that the user preference is not to open perspectives in
// // a new window.
// win = (WorkbenchWindow) window;
// if (inputSameAsWindow && win != null) {
// IPreferenceStore store = WorkbenchPlugin.getDefault()
// .getPreferenceStore();
// int mode = store.getInt(IPreferenceConstants.OPEN_PERSP_MODE);
//
// if (IPreferenceConstants.OPM_NEW_WINDOW != mode) {
// IWorkbenchPage page = win.getActiveWorkbenchPage();
// IPerspectiveDescriptor desc = getPerspectiveRegistry()
// .findPerspectiveWithId(perspectiveId);
// if (desc == null) {
// throw new WorkbenchException(
// NLS
// .bind(
// WorkbenchMessages.WorkbenchPage_ErrorCreatingPerspective,
// perspectiveId));
// }
// win.getShell().open();
// if (page == null) {
// page = win.openPage(perspectiveId, input);
// } else {
// page.setPerspective(desc);
// }
// return page;
// }
// }
//
// // If the specified window has no active perspective, then open the
// // requested perspective and show the specified window.
// if (win != null) {
// IWorkbenchPage page = win.getActiveWorkbenchPage();
// IPerspectiveDescriptor persp = null;
// if (page != null) {
// persp = page.getPerspective();
// }
// if (persp == null) {
// IPerspectiveDescriptor desc = getPerspectiveRegistry()
// .findPerspectiveWithId(perspectiveId);
// if (desc == null) {
// throw new WorkbenchException(
// NLS
// .bind(
// WorkbenchMessages.WorkbenchPage_ErrorCreatingPerspective,
// perspectiveId));
// }
// win.getShell().open();
// if (page == null) {
// page = win.openPage(perspectiveId, input);
// } else {
// page.setPerspective(desc);
// }
// return page;
// }
// }
//
// // Otherwise the requested perspective is opened and shown in a new
// // window, and the
// // window is given focus.
// IWorkbenchWindow newWindow = openWorkbenchWindow(perspectiveId, input);
// return newWindow.getActivePage();
}
bool Workbench::SaveAllEditors(bool /*confirm*/)
{
return true;
}
IIntroManager* Workbench::GetIntroManager()
{
return GetWorkbenchIntroManager();
}
WorkbenchIntroManager* Workbench::GetWorkbenchIntroManager()
{
if (introManager == 0)
{
introManager = new WorkbenchIntroManager(this);
}
return introManager;
}
IntroDescriptor::Pointer Workbench::GetIntroDescriptor() const
{
return introDescriptor;
}
void Workbench::SetIntroDescriptor(IntroDescriptor::Pointer descriptor)
{
if (GetIntroManager()->GetIntro())
{
GetIntroManager()->CloseIntro(GetIntroManager()->GetIntro());
}
introDescriptor = descriptor;
}
bool Workbench::IsRunning()
{
return Tweaklets::Get(WorkbenchTweaklet::KEY)->IsRunning();
}
bool Workbench::IsStarting()
{
return isStarting;
}
bool Workbench::IsClosing()
{
return isClosing;
}
WorkbenchWindow::Pointer Workbench::GetActivatedWindow()
{
return activatedWindow;
}
/*
* Sets the workbench window which was last known being the active one, or
* <code> null </code> .
*/
void Workbench::SetActivatedWindow(WorkbenchWindow::Pointer window)
{
activatedWindow = window;
}
WorkbenchWindow::Pointer Workbench::NewWorkbenchWindow()
{
WorkbenchWindow::Pointer wbw =
Tweaklets::Get(WorkbenchTweaklet::KEY)->CreateWorkbenchWindow(this->GetNewWindowNumber());
//wbw->Init();
return wbw;
}
int Workbench::GetNewWindowNumber()
{
// Get window list.
std::vector<Window::Pointer> windows = windowManager.GetWindows();
int count = static_cast<int>(windows.size());
// Create an array of booleans (size = window count).
// Cross off every number found in the window list.
bool *checkArray = new bool[count];
for (int nX = 0; nX < count; ++nX)
{
if (windows[nX].Cast<WorkbenchWindow> ().IsNotNull())
{
WorkbenchWindow::Pointer ww = windows[nX].Cast<WorkbenchWindow> ();
int index = ww->GetNumber() - 1;
if (index >= 0 && index < count)
{
checkArray[index] = true;
}
}
}
// Return first index which is not used.
// If no empty index was found then every slot is full.
// Return next index.
for (int index = 0; index < count; index++)
{
if (!checkArray[index])
{
delete[] checkArray;
return index + 1;
}
}
delete[] checkArray;
return static_cast<int>(count + 1);
}
IWorkbenchWindow::Pointer Workbench::BusyOpenWorkbenchWindow(
const std::string& perspID, IAdaptable* input)
{
// Create a workbench window (becomes active window)
//final WorkbenchWindow newWindowArray[] = new WorkbenchWindow[1];
//StartupThreading.runWithWorkbenchExceptions(new StartupRunnable() {
// public void runWithException() {
// newWindowArray[0] = newWorkbenchWindow();
WorkbenchWindow::Pointer newWindow = this->NewWorkbenchWindow();
// }
//});
//final WorkbenchWindow newWindow = newWindowArray[0];
//StartupThreading.runWithoutExceptions(new StartupRunnable() {
// public void runWithException() {
newWindow->Create(); // must be created before adding to window
// manager
// }
//});
windowManager.Add(newWindow);
//final WorkbenchException [] exceptions = new WorkbenchException[1];
// Create the initial page.
if (perspID != "")
{
//StartupThreading.runWithWorkbenchExceptions(new StartupRunnable() {
try
{
newWindow->BusyOpenPage(perspID, input);
}
catch (WorkbenchException& e)
{
windowManager.Remove(newWindow);
throw e;
}
}
// Open window after opening page, to avoid flicker.
//StartupThreading.runWithWorkbenchExceptions(new StartupRunnable() {
// public void runWithException() {
newWindow->Open();
// }
//});
return newWindow;
}
bool Workbench::SaveState(IMemento::Pointer memento)
{
// MultiStatus result = new MultiStatus(PlatformUI.PLUGIN_ID, IStatus.OK,
// WorkbenchMessages.Workbench_problemsSaving, null);
bool result = true;
// Save the version number.
memento->PutString(WorkbenchConstants::TAG_VERSION, VERSION_STRING[0]);
// Save how many plug-ins were loaded while restoring the workbench
if (progressCount != -1)
{
memento->PutInteger(WorkbenchConstants::TAG_PROGRESS_COUNT,
progressCount);
}
// Save the advisor state.
IMemento::Pointer advisorState = memento
->CreateChild(WorkbenchConstants::TAG_WORKBENCH_ADVISOR);
//result.add(getAdvisor().saveState(advisorState));
result &= GetAdvisor()->SaveState(advisorState);
// Save the workbench windows.
std::vector<IWorkbenchWindow::Pointer> windows(GetWorkbenchWindows());
for (std::size_t nX = 0; nX < windows.size(); nX++)
{
WorkbenchWindow::Pointer window = windows[nX].Cast<WorkbenchWindow>();
IMemento::Pointer childMem = memento->CreateChild(WorkbenchConstants::TAG_WINDOW);
//result.merge(window.saveState(childMem));
result &= window->SaveState(childMem);
}
// result.add(getEditorHistory().saveState(
// memento.createChild(IWorkbenchConstants.TAG_MRU_LIST)));
return result;
}
XMLMemento::Pointer Workbench::RecordWorkbenchState()
{
XMLMemento::Pointer memento = XMLMemento
::CreateWriteRoot(WorkbenchConstants::TAG_WORKBENCH);
//final IStatus status = saveState(memento);
bool status = SaveState(memento);
//if (status.getSeverity() != IStatus.OK) {
if (!status)
{
// // don't use newWindow as parent because it has not yet been opened
// // (bug 76724)
// StartupThreading.runWithoutExceptions(new StartupRunnable() {
//
// public void runWithException() throws Throwable {
// ErrorDialog.openError(null,
// WorkbenchMessages.Workbench_problemsSaving,
// WorkbenchMessages.Workbench_problemsSavingMsg, status);
// }});
}
return memento;
}
void Workbench::AddWorkbenchListener(IWorkbenchListener::Pointer listener)
{
workbenchEvents.AddListener(listener);
}
void Workbench::RemoveWorkbenchListener(IWorkbenchListener::Pointer listener)
{
workbenchEvents.RemoveListener(listener);
}
IWorkbenchListener::Events& Workbench::GetWorkbenchEvents()
{
return workbenchEvents;
}
void Workbench::AddWindowListener(IWindowListener::Pointer l)
{
windowEvents.AddListener(l);
}
void Workbench::RemoveWindowListener(IWindowListener::Pointer l)
{
windowEvents.RemoveListener(l);
}
IWindowListener::Events& Workbench::GetWindowEvents()
{
return windowEvents;
}
bool Workbench::FirePreShutdown(bool forced)
{
//SafeRunnable.run(new SafeRunnable() {
// public void run() {
typedef IWorkbenchListener::Events::PreShutdownEvent::ListenerList ListenerList;
const ListenerList& listeners = workbenchEvents.preShutdown.GetListeners();
for ( ListenerList::const_iterator iter = listeners.begin();
iter != listeners.end(); ++iter )
{
// notify each listener
if (! (*iter)->Execute(dynamic_cast<IWorkbench*>(this), forced))
return false;
}
// }
return true;
}
/**
* Fire workbench postShutdown event.
*
* @since 3.2
*/
void Workbench::FirePostShutdown()
{
// SafeRunnable.run(new SafeRunnable() {
// public void run() {
workbenchEvents.postShutdown(this);
// }
}
void Workbench::FireWindowOpened(IWorkbenchWindow::Pointer window)
{
// SafeRunner.run(new SafeRunnable() {
// public void run() {
windowEvents.windowOpened(window);
// }
}
void Workbench::FireWindowClosed(IWorkbenchWindow::Pointer window)
{
if (activatedWindow == window)
{
// Do not hang onto it so it can be GC'ed
activatedWindow = 0;
}
// SafeRunner.run(new SafeRunnable() {
// public void run() {
windowEvents.windowClosed(window);
// }
}
void Workbench::FireWindowActivated(IWorkbenchWindow::Pointer window)
{
// SafeRunner.run(new SafeRunnable() {
// public void run() {
windowEvents.windowActivated(window);
// }
}
void Workbench::FireWindowDeactivated(IWorkbenchWindow::Pointer window)
{
// SafeRunner.run(new SafeRunnable() {
// public void run() {
windowEvents.windowDeactivated(window);
// }
}
IWorkbenchWindow::Pointer Workbench::RestoreWorkbenchWindow(IMemento::Pointer memento)
{
WorkbenchWindow::Pointer newWindow = this->NewWorkbenchWindow();
//newWindow.create();
windowManager.Add(newWindow);
// whether the window was opened
bool opened = false;
try
{
newWindow->RestoreState(memento, IPerspectiveDescriptor::Pointer(0));
newWindow->FireWindowRestored();
newWindow->Open();
opened = true;
}
catch (...)
{
if (!opened)
{
newWindow->Close();
}
}
return newWindow;
}
void Workbench::Shutdown()
{
// shutdown application-specific portions first
advisor->PostShutdown();
// notify regular workbench clients of shutdown, and clear the list when
// done
this->FirePostShutdown();
//workbenchListeners.clear();
//cancelEarlyStartup();
// for dynamic UI
// Platform.getExtensionRegistry().removeRegistryChangeListener(
// extensionEventHandler);
// Platform.getExtensionRegistry().removeRegistryChangeListener(
// startupRegistryListener);
// ((GrabFocus) Tweaklets.get(GrabFocus.KEY)).dispose();
// Bring down all of the services.
// serviceLocator.dispose();
// workbenchActivitySupport.dispose();
// WorkbenchHelpSystem.disposeIfNecessary();
// shutdown the rest of the workbench
// WorkbenchColors.shutdown();
// activityHelper.shutdown();
// uninitializeImages();
// if (WorkbenchPlugin.getDefault() != null) {
// WorkbenchPlugin.getDefault().reset();
// }
// WorkbenchThemeManager.getInstance().dispose();
// PropertyPageContributorManager.getManager().dispose();
// ObjectActionContributorManager.getManager().dispose();
// if (tracker != null) {
// tracker.close();
// }
Tweaklets::Clear();
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbench.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbench.h
index a52a93d154..be2f9e58f4 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbench.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbench.h
@@ -1,601 +1,601 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYWORKBENCH_H_
#define BERRYWORKBENCH_H_
#include "berryIViewPart.h"
#include "berryIWorkbench.h"
#include "berryWorkbenchWindow.h"
#include "berryIWorkbenchPage.h"
#include "berryIWorkbenchPartReference.h"
#include "berryXMLMemento.h"
#include "berryPartPane.h"
#include "berryEditorAreaHelper.h"
#include "berryWindowManager.h"
#include "berryWorkbenchConfigurer.h"
#include "application/berryWorkbenchAdvisor.h"
#include "berryWorkbenchTestable.h"
#include "intro/berryIntroDescriptor.h"
#include "intro/berryWorkbenchIntroManager.h"
#include "berryIStackableContainer.h"
#include "berryServiceLocator.h"
#include <Poco/Exception.h>
#include <Poco/File.h>
namespace berry {
class ViewRegistry;
class EditorRegistry;
class WorkbenchWindowConfigurer;
/**
* \ingroup org_blueberry_ui
*
* The workbench class represents the top of the BlueBerry user interface. Its
* primary responsibility is the management of workbench windows, dialogs,
* wizards, and other workbench-related windows.
* <p>
* Note that any code that is run during the creation of a workbench instance
* should not required access to the display.
*/
class BERRY_UI Workbench : public IWorkbench
{
public:
berryObjectMacro(Workbench);
friend class RestoreStateRunnable;
/**
* Creates the workbench and associates it with the the given display and
* workbench advisor, and runs the workbench UI. This entails processing and
* dispatching events until the workbench is closed or restarted.
* <p>
* This method is intended to be called by <code>PlatformUI</code>. Fails
* if the workbench UI has already been created.
* </p>
* <p>
* The display passed in must be the default display.
* </p>
*
* @param display
* the display to be used for all UI interactions with the
* workbench
* @param advisor
* the application-specific advisor that configures and
* specializes the workbench
* @return return code {@link PlatformUI#RETURN_OK RETURN_OK}for normal
* exit; {@link PlatformUI#RETURN_RESTART RETURN_RESTART}if the
* workbench was terminated with a call to
* {@link IWorkbench#restart IWorkbench.restart}; other values
* reserved for future use
*/
static int CreateAndRunWorkbench(Display* display, WorkbenchAdvisor* advisor);
/**
* Creates the <code>Display</code> to be used by the workbench.
*
* @return the display
*/
static Display* CreateDisplay();
/**
* Returns the one and only instance of the workbench, if there is one.
*
* @return the workbench, or <code>null</code> if the workbench has not
* been created, or has been created and already completed
*/
static Workbench* GetInstance();
virtual ~Workbench();
/*
* (non-Javadoc)
*
* @see org.blueberry.ui.services.IServiceLocator#getService(java.lang.Object)
*/
Object::Pointer GetService(const std::string& key);
/*
* (non-Javadoc)
*
* @see org.blueberry.ui.services.IServiceLocator#hasService(java.lang.Object)
*/
bool HasService(const std::string& key) const;
/*
* Method declared on IWorkbench.
*/
bool Close();
/**
* Returns the testable object facade, for use by the test harness.
*
* @return the testable object facade
* @since 3.0
*/
static WorkbenchTestable::Pointer GetWorkbenchTestable();
/*
* Method declared on IWorkbench.
*/
void AddWorkbenchListener(IWorkbenchListener::Pointer listener);
/*
* Method declared on IWorkbench.
*/
void RemoveWorkbenchListener(IWorkbenchListener::Pointer listener);
/*
* Method declared on IWorkbench.
*/
IWorkbenchListener::Events& GetWorkbenchEvents();
/*
* Method declared on IWorkbench.
*/
void AddWindowListener(IWindowListener::Pointer l);
/*
* Method declared on IWorkbench.
*/
void RemoveWindowListener(IWindowListener::Pointer l);
/*
* Method declared on IWorkbench.
*/
IWindowListener::Events& GetWindowEvents();
IWorkbenchWindow::Pointer GetActiveWorkbenchWindow();
IViewRegistry* GetViewRegistry();
IEditorRegistry* GetEditorRegistry();
IPerspectiveRegistry* GetPerspectiveRegistry();
std::size_t GetWorkbenchWindowCount();
std::vector<IWorkbenchWindow::Pointer> GetWorkbenchWindows();
IWorkbenchWindow::Pointer OpenWorkbenchWindow(const std::string& perspectiveId,
IAdaptable* input);
IWorkbenchWindow::Pointer OpenWorkbenchWindow(IAdaptable* input);
IWorkbenchPage::Pointer ShowPerspective(const std::string& perspectiveId,
IWorkbenchWindow::Pointer window);
IWorkbenchPage::Pointer ShowPerspective(const std::string& perspectiveId,
IWorkbenchWindow::Pointer window, IAdaptable* input);
bool SaveAllEditors(bool confirm);
IIntroManager* GetIntroManager();
/**
* @return the workbench intro manager
*/
WorkbenchIntroManager* GetWorkbenchIntroManager();
/**
* @return the intro extension for this workbench.
*/
IntroDescriptor::Pointer GetIntroDescriptor() const;
/**
* This method exists as a test hook. This method should <strong>NEVER</strong>
* be called by clients.
*
* @param descriptor
* The intro descriptor to use.
*/
void SetIntroDescriptor(IntroDescriptor::Pointer descriptor);
/**
* Returns <code>true</code> if the workbench is running,
* <code>false</code> if it has been terminated.
*
* @return <code>true</code> if the workbench is running,
* <code>false</code> if it has been terminated.
*/
bool IsRunning();
/**
* Returns true if the Workbench is in the process of starting.
*
* @return <code>true</code> if the Workbench is starting, but not yet
* running the event loop.
*/
bool IsStarting();
bool IsClosing();
/**
* Returns the default perspective id, which may be <code>null</code>.
*
* @return the default perspective id, or <code>null</code>
*/
std::string GetDefaultPerspectiveId();
/**
* Returns the default workbench window page input.
*
* @return the default window page input or <code>null</code> if none
*/
IAdaptable* GetDefaultPageInput();
/**
* Return the presentation ID specified by the preference or the default ID
* if undefined.
*
* @return the presentation ID
* @see IWorkbenchPreferenceConstants#PRESENTATION_FACTORY_ID
*/
std::string GetPresentationId();
void UpdateTheme();
/**
* <p>
* Indicates the start of a large update within the workbench. This is used
* to disable CPU-intensive, change-sensitive services that were temporarily
* disabled in the midst of large changes. This method should always be
* called in tandem with <code>largeUpdateEnd</code>, and the event loop
* should not be allowed to spin before that method is called.
* </p>
* <p>
* Important: always use with <code>largeUpdateEnd</code>!
* </p>
*/
void LargeUpdateStart();
/**
* <p>
* Indicates the end of a large update within the workbench. This is used to
* re-enable services that were temporarily disabled in the midst of large
* changes. This method should always be called in tandem with
* <code>largeUpdateStart</code>, and the event loop should not be
* allowed to spin before this method is called.
* </p>
* <p>
* Important: always protect this call by using <code>finally</code>!
* </p>
*/
void LargeUpdateEnd();
protected:
friend class PlatformUI;
friend class WorkbenchConfigurer;
friend class WorkbenchWindowConfigurer;
friend class WorkbenchWindow;
friend struct WorkbenchWindow::ShellActivationListener;
int RunUI();
void OpenFirstTimeWindow();
IWorkbenchWindow::Pointer RestoreWorkbenchWindow(IMemento::Pointer memento);
bool Init();
/*
* Restores the workbench UI from the workbench state file (workbench.xml).
*
* @return a status object indicating OK if a window was opened,
* RESTORE_CODE_RESET if no window was opened but one should be, and
* RESTORE_CODE_EXIT if the workbench should close immediately
*/
/* package */
bool RestoreState();
/**
* Closes the workbench, returning the given return code from the run
* method. If forced, the workbench is closed no matter what.
*
* @param returnCode
* {@link PlatformUI#RETURN_OK RETURN_OK}for normal exit;
* {@link PlatformUI#RETURN_RESTART RETURN_RESTART}if the
* workbench was terminated with a call to
* {@link IWorkbench#restart IWorkbench.restart};
* {@link PlatformUI#RETURN_EMERGENCY_CLOSE} for an emergency
* shutdown
* {@link PlatformUI#RETURN_UNSTARTABLE RETURN_UNSTARTABLE}if
* the workbench could not be started; other values reserved for
* future use
*
* @param force
* true to force the workbench close, and false for a "soft"
* close that can be canceled
* @return true if the close was successful, and false if the close was
* canceled
*/
/* package */
bool Close(int returnCode, bool force);
/**
* Returns the unique object that applications use to configure the
* workbench.
* <p>
* IMPORTANT This method is declared protected to prevent regular
* plug-ins from downcasting IWorkbench to Workbench and getting hold of the
* workbench configurer that would allow them to tamper with the workbench.
* The workbench configurer is available only to the application.
* </p>
*/
WorkbenchConfigurer::Pointer GetWorkbenchConfigurer();
/**
* Returns the workbench advisor that created this workbench.
* <p>
* IMPORTANT This method is declared protected to prevent regular
* plug-ins from downcasting IWorkbench to Workbench and getting hold of the
* workbench advisor that would allow them to tamper with the workbench. The
* workbench advisor is internal to the application.
* </p>
*/
WorkbenchAdvisor* GetAdvisor();
/*
* Returns the workbench window which was last known being the active one,
* or <code> null </code> .
*/
SmartPointer<WorkbenchWindow> GetActivatedWindow();
/*
* Sets the workbench window which was last known being the active one, or
* <code> null </code> .
*/
void SetActivatedWindow(SmartPointer<WorkbenchWindow> window);
/**
* Fire workbench preShutdown event, stopping at the first one to veto
*
* @param forced
* flag indicating whether the shutdown is being forced
* @return <code>true</code> to allow the workbench to proceed with
* shutdown, <code>false</code> to veto a non-forced shutdown
* @since 3.2
*/
bool FirePreShutdown(bool forced);
/**
* Fire workbench postShutdown event.
*
* @since 3.2
*/
void FirePostShutdown();
/**
* Fire window opened event.
*
* @param window
* The window which just opened; should not be <code>null</code>.
*/
void FireWindowOpened(IWorkbenchWindow::Pointer window);
/**
* Fire window closed event.
*
* @param window
* The window which just closed; should not be <code>null</code>.
*/
void FireWindowClosed(IWorkbenchWindow::Pointer window);
/**
* Fire window activated event.
*
* @param window
* The window which was just activated; should not be
* <code>null</code>.
*/
void FireWindowActivated(IWorkbenchWindow::Pointer window);
/**
* Fire window deactivated event.
*
* @param window
* The window which was just deactivated; should not be
* <code>null</code>.
*/
void FireWindowDeactivated(IWorkbenchWindow::Pointer window);
private:
/**
* Holds onto the only instance of Workbench.
*/
static Workbench* instance;
/**
* The testable object facade.
*/
static WorkbenchTestable::Pointer testableObject;
static const unsigned int VERSION_STRING_COUNT; // = 1;
static const std::string VERSION_STRING[1];
static const std::string DEFAULT_WORKBENCH_STATE_FILENAME; // = "workbench.xml";
IWorkbenchListener::Events workbenchEvents;
IWindowListener::Events windowEvents;
WorkbenchAdvisor* advisor;
WorkbenchConfigurer::Pointer workbenchConfigurer;
/**
* The service locator maintained by the workbench. These services are
* initialized during workbench during the <code>init</code> method.
*/
ServiceLocator::Pointer serviceLocator;
/**
* A count of how many plug-ins were loaded while restoring the workbench
* state. Initially -1 for unknown number.
*/
int progressCount;
/**
* A field to hold the workbench windows that have been restored. In the
* event that not all windows have been restored, this field allows the
* openWindowsAfterRestore method to open some windows.
*/
std::vector<WorkbenchWindow::Pointer> createdWindows;
struct ServiceLocatorOwner : public IDisposable
{
ServiceLocatorOwner(Workbench* workbench);
void Dispose();
private:
Workbench* workbench;
};
friend struct ServiceLocatorOwner;
IDisposable::Pointer serviceLocatorOwner;
/**
* A count of how many large updates are going on. This tracks nesting of
* requests to disable services during a large update -- similar to the
* <code>setRedraw</code> functionality on <code>Control</code>. When
* this value becomes greater than zero, services are disabled. When this
* value becomes zero, services are enabled. Please see
* <code>largeUpdateStart()</code> and <code>largeUpdateEnd()</code>.
*/
int largeUpdates;
/**
* The display used for all UI interactions with this workbench.
*/
Display* display;
WindowManager windowManager;
SmartPointer<WorkbenchWindow> activatedWindow;
WorkbenchIntroManager* introManager;
/**
* The descriptor for the intro extension that is valid for this workspace,
* <code>null</code> if none.
*/
IntroDescriptor::Pointer introDescriptor;
bool isStarting;
bool isClosing;
int returnCode;
std::string factoryID;
/**
* Creates a new workbench.
*
* @param display
* the display to be used for all UI interactions with the
* workbench
* @param advisor
* the application-specific advisor that configures and
* specializes this workbench instance
*/
Workbench(Display*, WorkbenchAdvisor* advisor);
/**
* see IWorkbench#GetDisplay
*/
Display* GetDisplay();
/*
* Creates a new workbench window.
*
* @return the new workbench window
*/
SmartPointer<WorkbenchWindow> NewWorkbenchWindow();
void OpenWindowsAfterRestore();
/*
* Returns the number for a new window. This will be the first number > 0
* which is not used to identify another window in the workbench.
*/
int GetNewWindowNumber();
/**
* Initializes all of the default services for the workbench. For
* initializing the command-based services, this also parses the registry
* and hooks up all the required listeners.
*/
void InitializeDefaultServices();
/**
* Closes the workbench. Assumes that the busy cursor is active.
*
* @param force
* true if the close is mandatory, and false if the close is
* allowed to fail
* @return true if the close succeeded, and false otherwise
*/
bool BusyClose(bool force);
/*
* Record the workbench UI in a document
*/
XMLMemento::Pointer RecordWorkbenchState();
/*
* Restores the state of the previously saved workbench
*/
bool RestoreState(IMemento::Pointer memento);
void DoRestoreState(IMemento::Pointer memento, bool& result);
/*
* Saves the current state of the workbench so it can be restored later on
*/
bool SaveState(IMemento::Pointer memento);
/*
* Save the workbench UI in a persistence file.
*/
bool SaveMementoToFile(XMLMemento::Pointer memento);
/*
* Answer the workbench state file.
*/
bool GetWorkbenchStateFile(Poco::File& file);
/*
* Shuts down the application.
*/
void Shutdown();
/**
* Opens a new workbench window and page with a specific perspective.
*
* Assumes that busy cursor is active.
*/
IWorkbenchWindow::Pointer BusyOpenWorkbenchWindow(const std::string& perspID,
IAdaptable* input);
};
} // namespace berry
#endif /*BERRYWORKBENCH_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchConfigurer.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchConfigurer.cpp
index 3d46a01c0b..bf2282258b 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchConfigurer.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchConfigurer.cpp
@@ -1,132 +1,132 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryWorkbenchConfigurer.h"
#include "berryPlatformUI.h"
#include "berryWorkbenchWindow.h"
#include "berryImageDescriptor.h"
#include "berryWorkbench.h"
namespace berry
{
WorkbenchConfigurer::WorkbenchConfigurer() :
saveAndRestore(false), isEmergencyClosing(false), exitOnLastWindowClose(true)
{
}
IWorkbench* WorkbenchConfigurer::GetWorkbench()
{
return PlatformUI::GetWorkbench();
}
IWorkbenchWindowConfigurer::Pointer WorkbenchConfigurer::GetWindowConfigurer(
IWorkbenchWindow::Pointer window)
{
if (window.IsNull())
{
throw Poco::InvalidArgumentException();
}
return window.Cast<WorkbenchWindow> ()->GetWindowConfigurer();
}
bool WorkbenchConfigurer::GetSaveAndRestore()
{
return saveAndRestore;
}
void WorkbenchConfigurer::SetSaveAndRestore(bool enabled)
{
saveAndRestore = enabled;
}
Object::Pointer WorkbenchConfigurer::GetData(const std::string& key) const
{
if (key.empty())
{
throw Poco::InvalidArgumentException();
}
Poco::HashMap<std::string, Object::Pointer>::ConstIterator i =
extraData.find(key);
if (i != extraData.end())
return i->second;
return Object::Pointer(0);
}
void WorkbenchConfigurer::SetData(const std::string& key, Object::Pointer data)
{
if (key.empty())
{
throw Poco::InvalidArgumentException();
}
if (data)
{
extraData.insert(std::make_pair(key, data));
}
else
{
extraData.erase(key);
}
}
void WorkbenchConfigurer::EmergencyClose()
{
if (!isEmergencyClosing)
{
isEmergencyClosing = true;
if (Workbench::GetInstance() != 0 && !Workbench::GetInstance()->IsClosing())
{
Workbench::GetInstance()->Close(PlatformUI::RETURN_EMERGENCY_CLOSE, true);
}
}
}
bool WorkbenchConfigurer::EmergencyClosing()
{
return isEmergencyClosing;
}
bool WorkbenchConfigurer::RestoreState()
{
return dynamic_cast<Workbench*> (GetWorkbench())->RestoreState();
}
void WorkbenchConfigurer::OpenFirstTimeWindow()
{
dynamic_cast<Workbench*> (this->GetWorkbench())->OpenFirstTimeWindow();
}
IWorkbenchWindowConfigurer::Pointer WorkbenchConfigurer::RestoreWorkbenchWindow(
IMemento::Pointer memento)
{
return this->GetWindowConfigurer(
dynamic_cast<Workbench*> (this->GetWorkbench())->RestoreWorkbenchWindow(
memento));
}
bool WorkbenchConfigurer::GetExitOnLastWindowClose()
{
return exitOnLastWindowClose;
}
void WorkbenchConfigurer::SetExitOnLastWindowClose(bool enabled)
{
exitOnLastWindowClose = enabled;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchConfigurer.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchConfigurer.h
index 1537df8980..c76255b0b0 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchConfigurer.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchConfigurer.h
@@ -1,166 +1,166 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYWORKBENCHCONFIGURER_H_
#define BERRYWORKBENCHCONFIGURER_H_
#include "application/berryIWorkbenchConfigurer.h"
#include <Poco/HashMap.h>
namespace berry
{
/**
* Internal class providing special access for configuring the workbench.
* <p>
* Note that these objects are only available to the main application
* (the plug-in that creates and owns the workbench).
* </p>
* <p>
* This class is not intended to be instantiated or subclassed by clients.
* </p>
*
* @since 3.0
*/
class WorkbenchConfigurer : public IWorkbenchConfigurer {
public:
berryObjectMacro(WorkbenchConfigurer);
private:
/**
* Table to hold arbitrary key-data settings.
* @see #SetData
*/
Poco::HashMap<std::string, Object::Pointer> extraData;
/**
* Indicates whether workbench state should be saved on close and
* restored on subsequent open.
*/
bool saveAndRestore;
/**
* Indicates whether the workbench is being forced to close. During
* an emergency close, no interaction with the user should be done.
*/
bool isEmergencyClosing;
/**
* Indicates the behaviour when the last window is closed.
* If <code>true</code>, the workbench will exit (saving the last window's state,
* if configured to do so).
* If <code>false</code> the window will be closed, leaving the workbench running.
*
* @since 3.1
*/
bool exitOnLastWindowClose;
public:
/**
* Creates a new workbench configurer.
* <p>
* This method is declared package-private. Clients are passed an instance
* only via {@link WorkbenchAdvisor#initialize WorkbenchAdvisor.initialize}
* </p>
*/
WorkbenchConfigurer();
/* (non-javadoc)
* @see org.blueberry.ui.application.IWorkbenchConfigurer#getWorkbench
*/
IWorkbench* GetWorkbench();
/* (non-javadoc)
* @see org.blueberry.ui.application.IWorkbenchConfigurer#declareImage
*/
// void declareImage(String symbolicName, ImageDescriptor descriptor,
// boolean shared) {
// if (symbolicName == null || descriptor == null) {
// throw new IllegalArgumentException();
// }
// WorkbenchImages.declareImage(symbolicName, descriptor, shared);
// }
/* (non-javadoc)
* @see org.blueberry.ui.application.IWorkbenchConfigurer#getWindowConfigurer
*/
IWorkbenchWindowConfigurer::Pointer GetWindowConfigurer(IWorkbenchWindow::Pointer window);
/* (non-Javadoc)
* @see org.blueberry.ui.application.IWorkbenchConfigurer#getSaveAndRestore()
*/
bool GetSaveAndRestore();
/* (non-Javadoc)
* @see org.blueberry.ui.application.IWorkbenchConfigurer#setSaveAndRestore(boolean)
*/
void SetSaveAndRestore(bool enabled);
/* (non-Javadoc)
* @see org.blueberry.ui.application.IWorkbenchConfigurer#getData
*/
Object::Pointer GetData(const std::string& key) const;
/* (non-Javadoc)
* @see org.blueberry.ui.application.IWorkbenchConfigurer#setData(String, Object)
*/
void SetData(const std::string& key, Object::Pointer data);
/* (non-Javadoc)
* @see org.blueberry.ui.application.IWorkbenchConfigurer#emergencyClose()
*/
void EmergencyClose();
/* (non-Javadoc)
* @see org.blueberry.ui.application.IWorkbenchConfigurer#emergencyClosing()
*/
bool EmergencyClosing();
/* (non-Javadoc)
* @see org.blueberry.ui.application.IWorkbenchConfigurer#restoreState()
*/
bool RestoreState();
/* (non-Javadoc)
* @see org.blueberry.ui.application.IWorkbenchConfigurer#openFirstTimeWindow()
*/
void OpenFirstTimeWindow();
/* (non-Javadoc)
* @see org.blueberry.ui.application.IWorkbenchConfigurer#restoreWorkbenchWindow(org.blueberry.ui.IMemento)
*/
IWorkbenchWindowConfigurer::Pointer RestoreWorkbenchWindow(IMemento::Pointer memento);
/* (non-Javadoc)
* @see org.blueberry.ui.application.IWorkbenchConfigurer#getExitOnLastWindowClose()
*/
bool GetExitOnLastWindowClose();
/* (non-Javadoc)
* @see org.blueberry.ui.application.IWorkbenchConfigurer#setExitOnLastWindowClose(boolean)
*/
void SetExitOnLastWindowClose(bool enabled);
};
}
#endif /*BERRYWORKBENCHCONFIGURER_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchConstants.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchConstants.cpp
index 0bdd01d9fc..752f310ebc 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchConstants.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchConstants.cpp
@@ -1,349 +1,349 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryWorkbenchConstants.h"
#include "berryPlatformUI.h"
namespace berry
{
const std::string WorkbenchConstants::DEFAULT_PRESENTATION_ID =
"org.blueberry.ui.presentations.default"; //$NON-NLS-1$
const std::string WorkbenchConstants::RESOURCE_TYPE_FILE_NAME =
"resourcetypes.xml"; //$NON-NLS-1$
// Filename containing the workbench's preferences
const std::string WorkbenchConstants::PREFERENCE_BUNDLE_FILE_NAME =
"workbench.ini"; //$NON-NLS-1$
// Identifier for visible view parts.
const std::string WorkbenchConstants::WORKBENCH_VISIBLE_VIEW_ID =
"Workbench.visibleViewID"; //$NON-NLS-1$
// Identifier of workbench info properties page
//const std::string WorkbenchConstants::WORKBENCH_PROPERTIES_PAGE_INFO =
// PlatformUI::PLUGIN_ID + ".propertypages.info.file"; //$NON-NLS-1$
// Various editor.
//const std::string WorkbenchConstants::OLE_EDITOR_ID = PlatformUI::PLUGIN_ID
// + ".OleEditor"; //$NON-NLS-1$
// Default view category.
const std::string WorkbenchConstants::DEFAULT_CATEGORY_ID = "org.blueberry.ui";
//PlatformUI::PLUGIN_ID;
// Persistance tags.
const std::string WorkbenchConstants::TRUE_VAL = "true"; //$NON-NLS-1$
const std::string WorkbenchConstants::FALSE_VAL = "false"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_WORKBENCH_ADVISOR =
"workbenchAdvisor"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_WORKBENCH_WINDOW_ADVISOR =
"workbenchWindowAdvisor"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_ACTION_BAR_ADVISOR =
"actionBarAdvisor"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_ID = "id"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_FOCUS = "focus"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_EDITOR = "editor"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_DEFAULT_EDITOR = "defaultEditor"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_DELETED_EDITOR = "deletedEditor"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_EDITORS = "editors"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_WORKBOOK = "workbook"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_ACTIVE_WORKBOOK = "activeWorkbook"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_AREA = "editorArea"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_AREA_VISIBLE = "editorAreaVisible"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_AREA_HIDDEN = "editorAreaHidden"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_AREA_TRIM_STATE =
"editorAreaTrimState"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_INPUT = "input"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_FACTORY_ID = "factoryID"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_EDITOR_STATE = "editorState"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_TITLE = "title"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_X = "x"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_Y = "y"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_FLOAT = "float"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_ITEM_WRAP_INDEX = "wrapIndex"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_TOOLBAR_LAYOUT = "toolbarLayout"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_WIDTH = "width"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_HEIGHT = "height"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_MINIMIZED = "minimized"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_MAXIMIZED = "maximized"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_FOLDER = "folder"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_INFO = "info"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_PART = "part"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_PART_NAME = "partName"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_PROPERTIES = "properties"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_PROPERTY = "property"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_RELATIVE = "relative"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_RELATIONSHIP = "relationship"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_RATIO = "ratio"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_RATIO_LEFT = "ratioLeft"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_RATIO_RIGHT = "ratioRight"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_ACTIVE_PAGE_ID = "activePageID"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_EXPANDED = "expanded"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_PAGE = "page"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_INTRO = "intro"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_STANDBY = "standby"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_LABEL = "label"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_CONTENT = "content"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_CLASS = "class"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_FILE = "file"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_DESCRIPTOR = "descriptor"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_MAIN_WINDOW = "mainWindow"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_DETACHED_WINDOW = "detachedWindow"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_HIDDEN_WINDOW = "hiddenWindow"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_WORKBENCH = "workbench"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_WINDOW = "window"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_VERSION = "version"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_PROGRESS_COUNT = "progressCount"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_PERSPECTIVES = "perspectives"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_PERSPECTIVE = "perspective"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_ACTIVE_PERSPECTIVE =
"activePerspective"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_ACTIVE_PART = "activePart"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_ACTION_SET = "actionSet"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_ALWAYS_ON_ACTION_SET =
"alwaysOnActionSet"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_ALWAYS_OFF_ACTION_SET =
"alwaysOffActionSet"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_SHOW_VIEW_ACTION = "show_view_action"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_SHOW_IN_TIME = "show_in_time"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_TIME = "time"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_NEW_WIZARD_ACTION =
"new_wizard_action"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_PERSPECTIVE_ACTION =
"perspective_action"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_VIEW = "view"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_LAYOUT = "layout"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_EXTENSION = "extension"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_NAME = "name"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_IMAGE = "image"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_LAUNCHER = "launcher"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_PLUGIN = "plugin"; //$NON-NLS-1$
/** deprecated - use TAG_OPEN_MODE */
const std::string WorkbenchConstants::TAG_INTERNAL = "internal"; //$NON-NLS-1$
/** deprecated - use TAG_OPEN_MODE */
const std::string WorkbenchConstants::TAG_OPEN_IN_PLACE = "open_in_place"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_PROGRAM_NAME = "program_name"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_FAST_VIEWS = "fastViews"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_FAST_VIEW_BAR = "fastViewBar"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_FAST_VIEW_BARS = "fastViewBars"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_GLOBAL_FAST_VIEWS = "globalFastViews"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_FAST_GROUPS = "fastGroups"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_FIXED = "fixed";//$NON-NLS-1$
const std::string WorkbenchConstants::TAG_CLOSEABLE = "closeable";//$NON-NLS-1$
const std::string WorkbenchConstants::TAG_MOVEABLE = "moveable";//$NON-NLS-1$
const std::string WorkbenchConstants::TAG_APPEARANCE = "appearance"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_PRESENTATION = "presentation"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_STANDALONE = "standalone";//$NON-NLS-1$
const std::string WorkbenchConstants::TAG_SHOW_TITLE = "showTitle";//$NON-NLS-1$
const std::string WorkbenchConstants::TAG_VIEW_STATE = "viewState"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_SINGLETON = "singleton"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_EDITOR_REUSE_THRESHOLD =
"editorReuseThreshold"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_PERSISTABLE = "persistable"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_MRU_LIST = "mruList"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_PERSPECTIVE_HISTORY = "perspHistory"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_WORKING_SET_MANAGER =
"workingSetManager"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_WORKING_SETS = "workingSets"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_WORKING_SET = "workingSet"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_ITEM = "item"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_EDIT_PAGE_ID = "editPageId"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_COOLBAR_LAYOUT = "coolbarLayout"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_ITEM_SIZE = "itemSize"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_ITEM_X = "x"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_ITEM_Y = "y"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_ITEM_TYPE = "itemType"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_TYPE_SEPARATOR = "typeSeparator"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_TYPE_GROUPMARKER = "typeGroupMarker"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_TYPE_TOOLBARCONTRIBUTION =
"typeToolBarContribution"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_TYPE_PLACEHOLDER = "typePlaceholder"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_COOLITEM = "coolItem"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_INDEX = "index"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_PINNED = "pinned"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_PATH = "path";//$NON-NLS-1$
const std::string WorkbenchConstants::TAG_TOOLTIP = "tooltip";//$NON-NLS-1$
const std::string WorkbenchConstants::TAG_VIEWS = "views";//$NON-NLS-1$
const std::string WorkbenchConstants::TAG_POSITION = "position";//$NON-NLS-1$
const std::string WorkbenchConstants::TAG_NAVIGATION_HISTORY =
"navigationHistory";//$NON-NLS-1$
const std::string WorkbenchConstants::TAG_STICKY_STATE = "stickyState"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_ACTIVE = "active";//$NON-NLS-1$
const std::string WorkbenchConstants::TAG_REMOVED = "removed";//$NON-NLS-1$
const std::string WorkbenchConstants::TAG_HISTORY_LABEL = "historyLabel";//$NON-NLS-1$
const std::string WorkbenchConstants::TAG_LOCKED = "locked";//$NON-NLS-1$
const std::string WorkbenchConstants::TAG_OPEN_MODE = "openMode"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_STARTUP = "startup"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_FAST_VIEW_SIDE = "fastViewLocation"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_FAST_VIEW_DATA = "fastViewData"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_FAST_VIEW_ORIENTATION = "orientation"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_FAST_VIEW_SEL_ID = "selectedTabId"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_FAST_VIEW_STYLE = "style"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_THEME = "theme";//$NON-NLS-1$
const std::string WorkbenchConstants::TAG_VIEW_LAYOUT_REC = "viewLayoutRec"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_PERSPECTIVE_BAR = "perspectiveBar"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_TRIM = "trimLayout"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_TRIM_AREA = "trimArea"; //$NON-NLS-1$
const std::string WorkbenchConstants::TAG_TRIM_ITEM = "trimItem"; //$NON-NLS-1$
//Fonts
const std::string WorkbenchConstants::SMALL_FONT = "org.blueberry.ui.smallFont"; //$NON-NLS-1$
//Colors
const std::string WorkbenchConstants::COLOR_HIGHLIGHT_ =
"org.blueberry.ui.highlight"; //$NON-NLS-1$
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchConstants.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchConstants.h
index 17b7424aa5..20aa17e4a8 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchConstants.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchConstants.h
@@ -1,341 +1,341 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYWORKBENCHCONSTANTS_H_
#define BERRYWORKBENCHCONSTANTS_H_
#include <string>
#include <org_blueberry_ui_Export.h>
namespace berry
{
/**
* General constants used by the workbench.
*/
struct BERRY_UI WorkbenchConstants
{
static const std::string DEFAULT_PRESENTATION_ID; // = "org.blueberry.ui.presentations.default"; //$NON-NLS-1$
static const std::string RESOURCE_TYPE_FILE_NAME; // = "resourcetypes.xml"; //$NON-NLS-1$
// Filename containing the workbench's preferences
static const std::string PREFERENCE_BUNDLE_FILE_NAME; // = "workbench.ini"; //$NON-NLS-1$
// Identifier for visible view parts.
static const std::string WORKBENCH_VISIBLE_VIEW_ID; // = "Workbench.visibleViewID"; //$NON-NLS-1$
// Identifier of workbench info properties page
static const std::string WORKBENCH_PROPERTIES_PAGE_INFO; // = PlatformUI.PLUGIN_ID + ".propertypages.info.file"; //$NON-NLS-1$
// Various editor.
static const std::string OLE_EDITOR_ID; // = PlatformUI.PLUGIN_ID + ".OleEditor"; //$NON-NLS-1$
// Default view category.
static const std::string DEFAULT_CATEGORY_ID; // = PlatformUI.PLUGIN_ID;
// Persistance tags.
static const std::string TRUE_VAL; // = "true"; //$NON-NLS-1$
static const std::string FALSE_VAL; // = "false"; //$NON-NLS-1$
static const std::string TAG_WORKBENCH_ADVISOR; // = "workbenchAdvisor"; //$NON-NLS-1$
static const std::string TAG_WORKBENCH_WINDOW_ADVISOR; // = "workbenchWindowAdvisor"; //$NON-NLS-1$
static const std::string TAG_ACTION_BAR_ADVISOR; // = "actionBarAdvisor"; //$NON-NLS-1$
static const std::string TAG_ID; // = "id"; //$NON-NLS-1$
static const std::string TAG_FOCUS; // = "focus"; //$NON-NLS-1$
static const std::string TAG_EDITOR; // = "editor"; //$NON-NLS-1$
static const std::string TAG_DEFAULT_EDITOR; // = "defaultEditor"; //$NON-NLS-1$
static const std::string TAG_DELETED_EDITOR; // = "deletedEditor"; //$NON-NLS-1$
static const std::string TAG_EDITORS; // = "editors"; //$NON-NLS-1$
static const std::string TAG_WORKBOOK; // = "workbook"; //$NON-NLS-1$
static const std::string TAG_ACTIVE_WORKBOOK; // = "activeWorkbook"; //$NON-NLS-1$
static const std::string TAG_AREA; // = "editorArea"; //$NON-NLS-1$
static const std::string TAG_AREA_VISIBLE; // = "editorAreaVisible"; //$NON-NLS-1$
static const std::string TAG_AREA_HIDDEN; // = "editorAreaHidden"; //$NON-NLS-1$
static const std::string TAG_AREA_TRIM_STATE; // = "editorAreaTrimState"; //$NON-NLS-1$
static const std::string TAG_INPUT; // = "input"; //$NON-NLS-1$
static const std::string TAG_FACTORY_ID; // = "factoryID"; //$NON-NLS-1$
static const std::string TAG_EDITOR_STATE; // = "editorState"; //$NON-NLS-1$
static const std::string TAG_TITLE; // = "title"; //$NON-NLS-1$
static const std::string TAG_X; // = "x"; //$NON-NLS-1$
static const std::string TAG_Y; // = "y"; //$NON-NLS-1$
static const std::string TAG_FLOAT; // = "float"; //$NON-NLS-1$
static const std::string TAG_ITEM_WRAP_INDEX; // = "wrapIndex"; //$NON-NLS-1$
static const std::string TAG_TOOLBAR_LAYOUT; // = "toolbarLayout"; //$NON-NLS-1$
static const std::string TAG_WIDTH; // = "width"; //$NON-NLS-1$
static const std::string TAG_HEIGHT; // = "height"; //$NON-NLS-1$
static const std::string TAG_MINIMIZED; // = "minimized"; //$NON-NLS-1$
static const std::string TAG_MAXIMIZED; // = "maximized"; //$NON-NLS-1$
static const std::string TAG_FOLDER; // = "folder"; //$NON-NLS-1$
static const std::string TAG_INFO; // = "info"; //$NON-NLS-1$
static const std::string TAG_PART; // = "part"; //$NON-NLS-1$
static const std::string TAG_PART_NAME; // = "partName"; //$NON-NLS-1$
static const std::string TAG_PROPERTIES; // = "properties"; //$NON-NLS-1$
static const std::string TAG_PROPERTY; // = "property"; //$NON-NLS-1$
static const std::string TAG_RELATIVE; // = "relative"; //$NON-NLS-1$
static const std::string TAG_RELATIONSHIP; // = "relationship"; //$NON-NLS-1$
static const std::string TAG_RATIO; // = "ratio"; //$NON-NLS-1$
static const std::string TAG_RATIO_LEFT; // = "ratioLeft"; //$NON-NLS-1$
static const std::string TAG_RATIO_RIGHT; // = "ratioRight"; //$NON-NLS-1$
static const std::string TAG_ACTIVE_PAGE_ID; // = "activePageID"; //$NON-NLS-1$
static const std::string TAG_EXPANDED; // = "expanded"; //$NON-NLS-1$
static const std::string TAG_PAGE; // = "page"; //$NON-NLS-1$
static const std::string TAG_INTRO; // = "intro"; //$NON-NLS-1$
static const std::string TAG_STANDBY; // = "standby"; //$NON-NLS-1$
static const std::string TAG_LABEL; // = "label"; //$NON-NLS-1$
static const std::string TAG_CONTENT; // = "content"; //$NON-NLS-1$
static const std::string TAG_CLASS; // = "class"; //$NON-NLS-1$
static const std::string TAG_FILE; // = "file"; //$NON-NLS-1$
static const std::string TAG_DESCRIPTOR; // = "descriptor"; //$NON-NLS-1$
static const std::string TAG_MAIN_WINDOW; // = "mainWindow"; //$NON-NLS-1$
static const std::string TAG_DETACHED_WINDOW; // = "detachedWindow"; //$NON-NLS-1$
static const std::string TAG_HIDDEN_WINDOW; // = "hiddenWindow"; //$NON-NLS-1$
static const std::string TAG_WORKBENCH; // = "workbench"; //$NON-NLS-1$
static const std::string TAG_WINDOW; // = "window"; //$NON-NLS-1$
static const std::string TAG_VERSION; // = "version"; //$NON-NLS-1$
static const std::string TAG_PROGRESS_COUNT; // = "progressCount"; //$NON-NLS-1$
static const std::string TAG_PERSPECTIVES; // = "perspectives"; //$NON-NLS-1$
static const std::string TAG_PERSPECTIVE; // = "perspective"; //$NON-NLS-1$
static const std::string TAG_ACTIVE_PERSPECTIVE; // = "activePerspective"; //$NON-NLS-1$
static const std::string TAG_ACTIVE_PART; // = "activePart"; //$NON-NLS-1$
static const std::string TAG_ACTION_SET; // = "actionSet"; //$NON-NLS-1$
static const std::string TAG_ALWAYS_ON_ACTION_SET; // = "alwaysOnActionSet"; //$NON-NLS-1$
static const std::string TAG_ALWAYS_OFF_ACTION_SET; // = "alwaysOffActionSet"; //$NON-NLS-1$
static const std::string TAG_SHOW_VIEW_ACTION; // = "show_view_action"; //$NON-NLS-1$
static const std::string TAG_SHOW_IN_TIME; // = "show_in_time"; //$NON-NLS-1$
static const std::string TAG_TIME; // = "time"; //$NON-NLS-1$
static const std::string TAG_NEW_WIZARD_ACTION; // = "new_wizard_action"; //$NON-NLS-1$
static const std::string TAG_PERSPECTIVE_ACTION; // = "perspective_action"; //$NON-NLS-1$
static const std::string TAG_VIEW; // = "view"; //$NON-NLS-1$
static const std::string TAG_LAYOUT; // = "layout"; //$NON-NLS-1$
static const std::string TAG_EXTENSION; // = "extension"; //$NON-NLS-1$
static const std::string TAG_NAME; // = "name"; //$NON-NLS-1$
static const std::string TAG_IMAGE; // = "image"; //$NON-NLS-1$
static const std::string TAG_LAUNCHER; // = "launcher"; //$NON-NLS-1$
static const std::string TAG_PLUGIN; // = "plugin"; //$NON-NLS-1$
/** deprecated - use TAG_OPEN_MODE */
static const std::string TAG_INTERNAL; // = "internal"; //$NON-NLS-1$
/** deprecated - use TAG_OPEN_MODE */
static const std::string TAG_OPEN_IN_PLACE; // = "open_in_place"; //$NON-NLS-1$
static const std::string TAG_PROGRAM_NAME; // = "program_name"; //$NON-NLS-1$
static const std::string TAG_FAST_VIEWS; // = "fastViews"; //$NON-NLS-1$
static const std::string TAG_FAST_VIEW_BAR; // = "fastViewBar"; //$NON-NLS-1$
static const std::string TAG_FAST_VIEW_BARS; // = "fastViewBars"; //$NON-NLS-1$
static const std::string TAG_GLOBAL_FAST_VIEWS; // = "globalFastViews"; //$NON-NLS-1$
static const std::string TAG_FAST_GROUPS; // = "fastGroups"; //$NON-NLS-1$
static const std::string TAG_FIXED; // = "fixed";//$NON-NLS-1$
static const std::string TAG_CLOSEABLE; // = "closeable";//$NON-NLS-1$
static const std::string TAG_MOVEABLE; // = "moveable";//$NON-NLS-1$
static const std::string TAG_APPEARANCE; // = "appearance"; //$NON-NLS-1$
static const std::string TAG_PRESENTATION; // = "presentation"; //$NON-NLS-1$
static const std::string TAG_STANDALONE; // = "standalone";//$NON-NLS-1$
static const std::string TAG_SHOW_TITLE; // = "showTitle";//$NON-NLS-1$
static const std::string TAG_VIEW_STATE; // = "viewState"; //$NON-NLS-1$
static const std::string TAG_SINGLETON; // = "singleton"; //$NON-NLS-1$
static const std::string TAG_EDITOR_REUSE_THRESHOLD; // = "editorReuseThreshold"; //$NON-NLS-1$
static const std::string TAG_PERSISTABLE; // = "persistable"; //$NON-NLS-1$
static const std::string TAG_MRU_LIST; // = "mruList"; //$NON-NLS-1$
static const std::string TAG_PERSPECTIVE_HISTORY; // = "perspHistory"; //$NON-NLS-1$
static const std::string TAG_WORKING_SET_MANAGER; // = "workingSetManager"; //$NON-NLS-1$
static const std::string TAG_WORKING_SETS; // = "workingSets"; //$NON-NLS-1$
static const std::string TAG_WORKING_SET; // = "workingSet"; //$NON-NLS-1$
static const std::string TAG_ITEM; // = "item"; //$NON-NLS-1$
static const std::string TAG_EDIT_PAGE_ID; // = "editPageId"; //$NON-NLS-1$
static const std::string TAG_COOLBAR_LAYOUT; // = "coolbarLayout"; //$NON-NLS-1$
static const std::string TAG_ITEM_SIZE; // = "itemSize"; //$NON-NLS-1$
static const std::string TAG_ITEM_X; // = "x"; //$NON-NLS-1$
static const std::string TAG_ITEM_Y; // = "y"; //$NON-NLS-1$
static const std::string TAG_ITEM_TYPE; // = "itemType"; //$NON-NLS-1$
static const std::string TAG_TYPE_SEPARATOR; // = "typeSeparator"; //$NON-NLS-1$
static const std::string TAG_TYPE_GROUPMARKER; // = "typeGroupMarker"; //$NON-NLS-1$
static const std::string TAG_TYPE_TOOLBARCONTRIBUTION; // = "typeToolBarContribution"; //$NON-NLS-1$
static const std::string TAG_TYPE_PLACEHOLDER; // = "typePlaceholder"; //$NON-NLS-1$
static const std::string TAG_COOLITEM; // = "coolItem"; //$NON-NLS-1$
static const std::string TAG_INDEX; // = "index"; //$NON-NLS-1$
static const std::string TAG_PINNED; // = "pinned"; //$NON-NLS-1$
static const std::string TAG_PATH; // = "path";//$NON-NLS-1$
static const std::string TAG_TOOLTIP; // = "tooltip";//$NON-NLS-1$
static const std::string TAG_VIEWS; // = "views";//$NON-NLS-1$
static const std::string TAG_POSITION; // = "position";//$NON-NLS-1$
static const std::string TAG_NAVIGATION_HISTORY; // = "navigationHistory";//$NON-NLS-1$
static const std::string TAG_STICKY_STATE; // = "stickyState"; //$NON-NLS-1$
static const std::string TAG_ACTIVE; // = "active";//$NON-NLS-1$
static const std::string TAG_REMOVED; // = "removed";//$NON-NLS-1$
static const std::string TAG_HISTORY_LABEL; // = "historyLabel";//$NON-NLS-1$
static const std::string TAG_LOCKED; // = "locked";//$NON-NLS-1$
static const std::string TAG_OPEN_MODE; // = "openMode"; //$NON-NLS-1$
static const std::string TAG_STARTUP; // = "startup"; //$NON-NLS-1$
static const std::string TAG_FAST_VIEW_SIDE; // = "fastViewLocation"; //$NON-NLS-1$
static const std::string TAG_FAST_VIEW_DATA; // = "fastViewData"; //$NON-NLS-1$
static const std::string TAG_FAST_VIEW_ORIENTATION; // = "orientation"; //$NON-NLS-1$
static const std::string TAG_FAST_VIEW_SEL_ID; // = "selectedTabId"; //$NON-NLS-1$
static const std::string TAG_FAST_VIEW_STYLE; // = "style"; //$NON-NLS-1$
static const std::string TAG_THEME; // = "theme";//$NON-NLS-1$
static const std::string TAG_VIEW_LAYOUT_REC; // = "viewLayoutRec"; //$NON-NLS-1$
static const std::string TAG_PERSPECTIVE_BAR; // = "perspectiveBar"; //$NON-NLS-1$
static const std::string TAG_TRIM; // = "trimLayout"; //$NON-NLS-1$
static const std::string TAG_TRIM_AREA; // = "trimArea"; //$NON-NLS-1$
static const std::string TAG_TRIM_ITEM; // = "trimItem"; //$NON-NLS-1$
//Fonts
static const std::string SMALL_FONT; // = "org.blueberry.ui.smallFont"; //$NON-NLS-1$
//Colors
static const std::string COLOR_HIGHLIGHT_; // = "org.blueberry.ui.highlight"; //$NON-NLS-1$
};
}
#endif /* BERRYWORKBENCHCONSTANTS_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchPage.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchPage.cpp
index f6f619760f..7c5e60a398 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchPage.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchPage.cpp
@@ -1,4111 +1,4111 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryLog.h"
#include "tweaklets/berryGuiWidgetsTweaklet.h"
#include "tweaklets/berryWorkbenchPageTweaklet.h"
#include "berryWorkbenchPage.h"
#include "berryPartSite.h"
#include "berryWorkbenchRegistryConstants.h"
#include "berryPerspective.h"
#include "berryLayoutPartSash.h"
#include "berryWorkbenchPlugin.h"
#include "berryEditorAreaHelper.h"
#include "berrySaveablesList.h"
#include "berryPerspectiveHelper.h"
#include "berryLayoutTreeNode.h"
#include "berryWorkbench.h"
#include "berryWorkbenchConstants.h"
#include "berryPartService.h"
#include "berryStickyViewManager.h"
#include "intro/berryIntroConstants.h"
#include "intro/berryViewIntroAdapterPart.h"
#include "dialogs/berryMessageDialog.h"
#include "berryWorkbenchWindow.h"
#include "berryUIException.h"
#include "berryPlatformUI.h"
#include "berryPartPane.h"
#include "berryImageDescriptor.h"
#include <berryIExtensionPointService.h>
#include <berryPlatform.h>
namespace berry
{
WorkbenchPage::ActivationOrderPred::ActivationOrderPred(
WorkbenchPage::ActivationList* al) :
activationList(al)
{
}
bool WorkbenchPage::ActivationOrderPred::operator()(
const IViewReference::Pointer o1, const IViewReference::Pointer o2) const
{
WorkbenchPage::ActivationList::PartListIter pos1 = activationList->IndexOf(
o1.Cast<IWorkbenchPartReference> ());
WorkbenchPage::ActivationList::PartListIter pos2 = activationList->IndexOf(
o2.Cast<IWorkbenchPartReference> ());
return pos1 < pos2;
}
void WorkbenchPage::PerspectiveList::UpdateActionSets(
Perspective::Pointer /*oldPersp*/, Perspective::Pointer /*newPersp*/)
{
//TODO WorkbenchPage action sets
// // Update action sets
//
// IContextService service = (IContextService) window
// .getService(IContextService.class);
// try {
// service.activateContext(ContextAuthority.DEFER_EVENTS);
// if (newPersp != 0) {
// IActionSetDescriptor[] newAlwaysOn = newPersp
// .getAlwaysOnActionSets();
// for (int i = 0; i < newAlwaysOn.length; i++) {
// IActionSetDescriptor descriptor = newAlwaysOn[i];
//
// actionSets.showAction(descriptor);
// }
//
// IActionSetDescriptor[] newAlwaysOff = newPersp
// .getAlwaysOffActionSets();
// for (int i = 0; i < newAlwaysOff.length; i++) {
// IActionSetDescriptor descriptor = newAlwaysOff[i];
//
// actionSets.maskAction(descriptor);
// }
// }
//
// if (oldPersp != 0) {
// IActionSetDescriptor[] newAlwaysOn = oldPersp
// .getAlwaysOnActionSets();
// for (int i = 0; i < newAlwaysOn.length; i++) {
// IActionSetDescriptor descriptor = newAlwaysOn[i];
//
// actionSets.hideAction(descriptor);
// }
//
// IActionSetDescriptor[] newAlwaysOff = oldPersp
// .getAlwaysOffActionSets();
// for (int i = 0; i < newAlwaysOff.length; i++) {
// IActionSetDescriptor descriptor = newAlwaysOff[i];
//
// actionSets.unmaskAction(descriptor);
// }
// }
// } finally {
// service.activateContext(ContextAuthority.SEND_EVENTS);
// }
}
WorkbenchPage::PerspectiveList::PerspectiveList()
{
}
void WorkbenchPage::PerspectiveList::Reorder(
IPerspectiveDescriptor::Pointer perspective, int newLoc)
{
PerspectiveListType::iterator oldLocation = openedList.end();
Perspective::Pointer movedPerspective;
for (PerspectiveListType::iterator iterator = openedList.begin(); iterator
!= openedList.end(); ++iterator)
{
Perspective::Pointer openPerspective = *iterator;
if (openPerspective->GetDesc() == perspective)
{
oldLocation = std::find(openedList.begin(), openedList.end(),
openPerspective);
movedPerspective = openPerspective;
}
}
PerspectiveListType::iterator newLocation = openedList.begin();
for (int i = 0; i < newLoc; ++i, ++newLocation)
;
if (oldLocation == newLocation)
{
return;
}
openedList.erase(oldLocation);
openedList.insert(newLocation, movedPerspective);
}
WorkbenchPage::PerspectiveList::PerspectiveListType WorkbenchPage::PerspectiveList::GetSortedPerspectives()
{
return usedList;
}
bool WorkbenchPage::PerspectiveList::Add(Perspective::Pointer perspective)
{
openedList.push_back(perspective);
usedList.push_front(perspective);
//It will be moved to top only when activated.
return true;
}
WorkbenchPage::PerspectiveList::PerspectiveListType::iterator WorkbenchPage::PerspectiveList::Begin()
{
return openedList.begin();
}
WorkbenchPage::PerspectiveList::PerspectiveListType::iterator WorkbenchPage::PerspectiveList::End()
{
return openedList.end();
}
WorkbenchPage::PerspectiveList::PerspectiveListType WorkbenchPage::PerspectiveList::GetOpenedPerspectives()
{
return openedList;
}
bool WorkbenchPage::PerspectiveList::Remove(Perspective::Pointer perspective)
{
if (active == perspective)
{
this->UpdateActionSets(active, Perspective::Pointer(0));
active = 0;
}
usedList.remove(perspective);
PerspectiveListType::size_type origSize = openedList.size();
openedList.remove(perspective);
return openedList.size() != origSize;
}
void WorkbenchPage::PerspectiveList::Swap(Perspective::Pointer oldPerspective,
Perspective::Pointer newPerspective)
{
PerspectiveListType::iterator oldIter = std::find(openedList.begin(),
openedList.end(), oldPerspective);
PerspectiveListType::iterator newIter = std::find(openedList.begin(),
openedList.end(), newPerspective);
if (oldIter == openedList.end() || newIter == openedList.end())
{
return;
}
std::iter_swap(oldIter, newIter);
}
bool WorkbenchPage::PerspectiveList::IsEmpty()
{
return openedList.empty();
}
Perspective::Pointer WorkbenchPage::PerspectiveList::GetActive()
{
return active;
}
Perspective::Pointer WorkbenchPage::PerspectiveList::GetNextActive()
{
if (active == 0)
{
if (usedList.empty())
{
return Perspective::Pointer(0);
}
else
{
return usedList.back();
}
}
else
{
if (usedList.size() < 2)
{
return Perspective::Pointer(0);
}
else
{
return *(++usedList.rbegin());
}
}
}
WorkbenchPage::PerspectiveList::PerspectiveListType::size_type WorkbenchPage::PerspectiveList::Size()
{
return openedList.size();
}
void WorkbenchPage::PerspectiveList::SetActive(Perspective::Pointer perspective)
{
if (perspective == active)
{
return;
}
this->UpdateActionSets(active, perspective);
active = perspective;
if (perspective != 0)
{
usedList.remove(perspective);
usedList.push_back(perspective);
}
}
WorkbenchPage::ActivationList::ActivationList(WorkbenchPage* page) :
page(page)
{
}
void WorkbenchPage::ActivationList::SetActive(SmartPointer<IWorkbenchPart> part)
{
if (parts.empty())
{
return;
}
IWorkbenchPartReference::Pointer ref(page->GetReference(part));
if (ref)
{
if (ref == parts.back())
{
return;
}
parts.erase(std::find(parts.begin(), parts.end(), ref));
parts.push_back(ref);
}
}
void WorkbenchPage::ActivationList::BringToTop(SmartPointer<
IWorkbenchPartReference> ref)
{
IStackableContainer::Pointer targetContainer(page->GetContainer(ref));
PartListIter newIndex = this->LastIndexOfContainer(targetContainer);
if (newIndex != parts.end() && ref == *newIndex)
{
return;
}
if (newIndex == parts.end())
{
parts.push_back(ref);
}
else
{
PartListType::size_type index = newIndex - parts.begin();
parts.erase(std::find(parts.begin(), parts.end(), ref));
PartListIter insertIndex = parts.begin() + index;
parts.insert(insertIndex, ref);
}
}
WorkbenchPage::ActivationList::PartListIter WorkbenchPage::ActivationList::LastIndexOfContainer(
SmartPointer<IStackableContainer> container)
{
PartListReverseIter i = parts.rbegin();
while (i != parts.rend())
{
IWorkbenchPartReference::Pointer ref(*i);
IStackableContainer::Pointer cnt(page->GetContainer(ref));
if (cnt == container)
{
return --i.base();
}
++i;
}
return parts.end();
}
void WorkbenchPage::ActivationList::SetActive(SmartPointer<
IWorkbenchPartReference> ref)
{
this->SetActive(ref->GetPart(true));
}
void WorkbenchPage::ActivationList::Add(
SmartPointer<IWorkbenchPartReference> ref)
{
if (std::find(parts.begin(), parts.end(), ref) != parts.end())
{
return;
}
ref->GetPart(false);
parts.push_front(ref);
}
SmartPointer<IWorkbenchPart> WorkbenchPage::ActivationList::GetActive()
{
if (parts.empty())
{
return IWorkbenchPart::Pointer(0);
}
return this->GetActive(parts.end());
}
SmartPointer<IWorkbenchPart> WorkbenchPage::ActivationList::GetPreviouslyActive()
{
if (parts.size() < 2)
{
return IWorkbenchPart::Pointer(0);
}
return this->GetActive(--parts.end());
}
SmartPointer<IWorkbenchPartReference> WorkbenchPage::ActivationList::GetActiveReference(
bool editorsOnly)
{
return this->GetActiveReference(parts.end(), editorsOnly);
}
WorkbenchPage::ActivationList::PartListIter WorkbenchPage::ActivationList::IndexOf(
SmartPointer<IWorkbenchPart> part)
{
IWorkbenchPartReference::Pointer ref(page->GetReference(part));
if (ref == 0)
{
return parts.end();
}
return std::find(parts.begin(), parts.end(), ref);
}
WorkbenchPage::ActivationList::PartListIter WorkbenchPage::ActivationList::IndexOf(
SmartPointer<IWorkbenchPartReference> ref)
{
return std::find(parts.begin(), parts.end(), ref);
}
bool WorkbenchPage::ActivationList::Remove(
SmartPointer<IWorkbenchPartReference> ref)
{
bool contains = std::find(parts.begin(), parts.end(), ref) != parts.end();
parts.erase(std::find(parts.begin(), parts.end(), ref));
return contains;
}
SmartPointer<IEditorPart> WorkbenchPage::ActivationList::GetTopEditor()
{
IEditorReference::Pointer editor =
this->GetActiveReference(parts.end(), true).Cast<IEditorReference> ();
if (editor == 0)
{
return IEditorPart::Pointer(0);
}
return editor->GetEditor(true);
}
SmartPointer<IWorkbenchPart> WorkbenchPage::ActivationList::GetActive(
PartListIter start)
{
IWorkbenchPartReference::Pointer ref(this->GetActiveReference(start, false));
if (!ref)
{
return IWorkbenchPart::Pointer(0);
}
return ref->GetPart(true);
}
SmartPointer<IWorkbenchPartReference> WorkbenchPage::ActivationList::GetActiveReference(
PartListIter start, bool editorsOnly)
{
// First look for parts that aren't obscured by the current zoom state
IWorkbenchPartReference::Pointer nonObscured = this->GetActiveReference(
start, editorsOnly, true);
if (nonObscured)
{
return nonObscured;
}
// Now try all the rest of the parts
return this->GetActiveReference(start, editorsOnly, false);
}
SmartPointer<IWorkbenchPartReference> WorkbenchPage::ActivationList::GetActiveReference(
PartListIter start, bool editorsOnly, bool /*skipPartsObscuredByZoom*/)
{
std::vector<IViewReference::Pointer> views = page->GetViewReferences();
PartListReverseIter i(start);
while (i != parts.rend())
{
WorkbenchPartReference::Pointer ref(i->Cast<WorkbenchPartReference> ());
if (editorsOnly && (ref.Cast<IEditorReference> () == 0))
{
++i;
continue;
}
// Skip parts whose containers have disabled auto-focus
PartPane::Pointer pane(ref->GetPane());
if (pane)
{
if (!pane->AllowsAutoFocus())
{
++i;
continue;
}
// if (skipPartsObscuredByZoom) {
// if (pane.isObscuredByZoom()) {
// continue;
// }
// }
}
// Skip fastviews (unless overridden)
if (IViewReference::Pointer viewRef = ref.Cast<IViewReference>())
{
//if (ref == getActiveFastView() || !((IViewReference) ref).isFastView()) {
for (unsigned int j = 0; j < views.size(); j++)
{
if (views[j] == viewRef)
{
return viewRef.Cast<IWorkbenchPartReference> ();
}
}
//}
}
else
{
return ref.Cast<IWorkbenchPartReference> ();
}
++i;
}
return IWorkbenchPartReference::Pointer(0);
}
std::vector<SmartPointer<IEditorReference> > WorkbenchPage::ActivationList::GetEditors()
{
std::vector<IEditorReference::Pointer> editors;
for (PartListIter i = parts.begin(); i != parts.end(); ++i)
{
if (IEditorReference::Pointer part = i->Cast<IEditorReference>())
{
editors.push_back(part);
}
}
return editors;
}
std::vector<SmartPointer<IWorkbenchPartReference> > WorkbenchPage::ActivationList::GetParts()
{
std::vector<IViewReference::Pointer> views(page->GetViewReferences());
std::vector<IWorkbenchPartReference::Pointer> resultList;
for (PartListIter iterator = parts.begin(); iterator != parts.end(); ++iterator)
{
if (IViewReference::Pointer ref = iterator->Cast<IViewReference>())
{
//Filter views from other perspectives
for (unsigned int i = 0; i < views.size(); i++)
{
if (ref == views[i])
{
resultList.push_back(ref);
break;
}
}
}
else
{
resultList.push_back(*iterator);
}
}
return resultList;
}
void WorkbenchPage::ActionSwitcher::UpdateActivePart(
IWorkbenchPart::Pointer newPart)
{
IWorkbenchPart::Pointer _activePart = this->activePart.Lock();
IEditorPart::Pointer _topEditor = this->topEditor.Lock();
if (_activePart == newPart)
{
return;
}
bool isNewPartAnEditor = newPart.Cast<IEditorPart> ().IsNotNull();
if (isNewPartAnEditor)
{
std::string oldId;
if (_topEditor)
{
oldId = _topEditor->GetSite()->GetId();
}
std::string newId = newPart->GetSite()->GetId();
// if the active part is an editor and the new editor
// is the same kind of editor, then we don't have to do
// anything
if (activePart == topEditor && newId == oldId)
{
activePart = newPart;
topEditor = newPart.Cast<IEditorPart> ();
return;
}
// remove the contributions of the old editor
// if it is a different kind of editor
if (oldId != newId)
{
this->DeactivateContributions(_topEditor, true);
}
// if a view was the active part, disable its contributions
if (_activePart && _activePart != _topEditor)
{
this->DeactivateContributions(_activePart, true);
}
// show (and enable) the contributions of the new editor
// if it is a different kind of editor or if the
// old active part was a view
if (newId != oldId || _activePart != _topEditor)
{
this->ActivateContributions(newPart, true);
}
}
else if (newPart.IsNull())
{
if (_activePart)
{
// remove all contributions
this->DeactivateContributions(_activePart, true);
}
}
else
{
// new part is a view
// if old active part is a view, remove all contributions,
// but if old part is an editor only disable
if (_activePart)
{
this->DeactivateContributions(_activePart,
_activePart.Cast<IViewPart> ().IsNotNull());
}
this->ActivateContributions(newPart, true);
}
//TODO WorkbenchPage action sets
// ArrayList newActionSets = 0;
// if (isNewPartAnEditor || (activePart == topEditor && newPart == 0))
// {
// newActionSets = calculateActionSets(newPart, 0);
// }
// else
// {
// newActionSets = calculateActionSets(newPart, topEditor);
// }
//
// if (!updateActionSets(newActionSets))
// {
// updateActionBars();
// }
if (isNewPartAnEditor)
{
topEditor = newPart.Cast<IEditorPart> ();
}
else if (activePart == topEditor && newPart.IsNull())
{
// since we removed all the contributions, we clear the top
// editor
topEditor.Reset();
}
activePart = newPart;
}
void WorkbenchPage::ActionSwitcher::UpdateTopEditor(
IEditorPart::Pointer newEditor)
{
if (topEditor.Lock() == newEditor)
{
return;
}
if (activePart == topEditor)
{
this->UpdateActivePart(newEditor);
return;
}
std::string oldId;
if (!topEditor.Expired())
{
oldId = topEditor.Lock()->GetSite()->GetId();
}
std::string newId;
if (newEditor.IsNotNull())
{
newId = newEditor->GetSite()->GetId();
}
if (oldId == newId)
{
// we don't have to change anything
topEditor = newEditor;
return;
}
// Remove the contributions of the old editor
if (!topEditor.Expired())
{
this->DeactivateContributions(topEditor.Lock(), true);
}
// Show (disabled) the contributions of the new editor
if (newEditor.IsNotNull())
{
this->ActivateContributions(newEditor, false);
}
// ArrayList newActionSets = calculateActionSets(activePart, newEditor);
// if (!updateActionSets(newActionSets))
// {
// updateActionBars();
// }
topEditor = newEditor;
}
void WorkbenchPage::ActionSwitcher::ActivateContributions(
IWorkbenchPart::Pointer /*part*/, bool /*enable*/)
{
//PartSite::Pointer site = part->GetSite().Cast<PartSite> ();
//site->ActivateActionBars(enable);
}
void WorkbenchPage::ActionSwitcher::DeactivateContributions(
IWorkbenchPart::Pointer /*part*/, bool /*remove*/)
{
//PartSite::Pointer site = part->GetSite().Cast<PartSite> ();
//site->DeactivateActionBars(remove);
}
const IExtensionPoint* WorkbenchPage::GetPerspectiveExtensionPoint()
{
return Platform::GetExtensionPointService()->GetExtensionPoint(
PlatformUI::PLUGIN_ID + "."
+ WorkbenchRegistryConstants::PL_PERSPECTIVE_EXTENSIONS);
}
WorkbenchPage::WorkbenchPage(WorkbenchWindow* w, const std::string& layoutID,
IAdaptable* input)
{
if (layoutID == "")
{
throw WorkbenchException("Perspective ID is undefined");
}
this->Register();
this->Init(w, layoutID, input, true);
this->UnRegister(false);
}
WorkbenchPage::WorkbenchPage(WorkbenchWindow* w, IAdaptable* input)
{
this->Register();
this->Init(w, "", input, false);
this->UnRegister(false);
}
void WorkbenchPage::Activate(IWorkbenchPart::Pointer part)
{
// Sanity check.
if (!this->CertifyPart(part))
{
return;
}
if (window->IsClosing())
{
return;
}
// if (composite!=0 && composite.isVisible() && !((GrabFocus)Tweaklets.get(GrabFocus.KEY)).grabFocusAllowed(part))
// {
// return;
// }
// Activate part.
//if (window.getActivePage() == this) {
IWorkbenchPartReference::Pointer ref = this->GetReference(part);
this->InternalBringToTop(ref);
this->SetActivePart(part);
}
void WorkbenchPage::ActivatePart(const IWorkbenchPart::Pointer part)
{
// Platform.run(new SafeRunnable(WorkbenchMessages.WorkbenchPage_ErrorActivatingView)
// {
// public void WorkbenchPage::run()
// {
if (part.IsNotNull())
{
//part.setFocus();
PartPane::Pointer pane = this->GetPane(part);
pane->SetFocus();
PartSite::Pointer site = part->GetSite().Cast<PartSite> ();
pane->ShowFocus(true);
//this->UpdateTabList(part);
//SubActionBars bars = (SubActionBars) site.getActionBars();
//bars.partChanged(part);
}
// }
// }
// );
}
void WorkbenchPage::AddPartListener(IPartListener::Pointer l)
{
partList->GetPartService()->AddPartListener(l);
}
void WorkbenchPage::AddSelectionListener(ISelectionListener::Pointer listener)
{
selectionService->AddSelectionListener(listener);
}
void WorkbenchPage::AddSelectionListener(const std::string& partId,
ISelectionListener::Pointer listener)
{
selectionService->AddSelectionListener(partId, listener);
}
void WorkbenchPage::AddPostSelectionListener(
ISelectionListener::Pointer listener)
{
selectionService->AddPostSelectionListener(listener);
}
void WorkbenchPage::AddPostSelectionListener(const std::string& partId,
ISelectionListener::Pointer listener)
{
selectionService->AddPostSelectionListener(partId, listener);
}
IStackableContainer::Pointer WorkbenchPage::GetContainer(
IWorkbenchPart::Pointer part)
{
PartPane::Pointer pane = this->GetPane(part);
if (pane == 0)
{
return IStackableContainer::Pointer(0);
}
return pane->GetContainer();
}
IStackableContainer::Pointer WorkbenchPage::GetContainer(
IWorkbenchPartReference::Pointer part)
{
PartPane::Pointer pane = this->GetPane(part);
if (pane == 0)
{
return IStackableContainer::Pointer(0);
}
return pane->GetContainer();
}
PartPane::Pointer WorkbenchPage::GetPane(IWorkbenchPart::Pointer part)
{
if (part.IsNull())
{
return PartPane::Pointer(0);
}
return this->GetPane(this->GetReference(part));
}
PartPane::Pointer WorkbenchPage::GetPane(IWorkbenchPartReference::Pointer part)
{
if (part.IsNull())
{
return PartPane::Pointer(0);
}
return part.Cast<WorkbenchPartReference> ()->GetPane();
}
bool WorkbenchPage::InternalBringToTop(IWorkbenchPartReference::Pointer part)
{
bool broughtToTop = false;
// Move part.
if (part.Cast<IEditorReference> ().IsNotNull())
{
IStackableContainer::Pointer container = this->GetContainer(part);
if (container.Cast<PartStack> () != 0)
{
PartStack::Pointer stack = container.Cast<PartStack> ();
PartPane::Pointer newPart = this->GetPane(part);
if (stack->GetSelection() != newPart)
{
stack->SetSelection(newPart);
}
broughtToTop = true;
}
}
else if (part.Cast<IViewReference> ().IsNotNull())
{
Perspective::Pointer persp = this->GetActivePerspective();
if (persp != 0)
{
broughtToTop = persp->BringToTop(part.Cast<IViewReference> ());
}
}
// Ensure that this part is considered the most recently activated part
// in this stack
activationList->BringToTop(part);
return broughtToTop;
}
void WorkbenchPage::BringToTop(IWorkbenchPart::Pointer part)
{
// Sanity check.
Perspective::Pointer persp = this->GetActivePerspective();
if (persp == 0 || !this->CertifyPart(part))
{
return;
}
// if (!((GrabFocus)Tweaklets.get(GrabFocus.KEY)).grabFocusAllowed(part))
// {
// return;
// }
// std::string label; // debugging only
// if (UIStats.isDebugging(UIStats.BRING_PART_TO_TOP))
// {
// label = part != 0 ? part.getTitle() : "none"; //$NON-NLS-1$
// }
IWorkbenchPartReference::Pointer ref = this->GetReference(part);
IStackableContainer::Pointer activeEditorContainer = this->GetContainer(
this->GetActiveEditor().Cast<IWorkbenchPart> ());
IStackableContainer::Pointer activePartContainer = this->GetContainer(
this->GetActivePart());
IStackableContainer::Pointer newPartContainer = this->GetContainer(part);
if (newPartContainer == activePartContainer)
{
this->MakeActive(ref);
}
else if (newPartContainer == activeEditorContainer)
{
if (ref.Cast<IEditorReference> () != 0)
{
if (part != 0)
{
IWorkbenchPartSite::Pointer site = part->GetSite();
if (site.Cast<PartSite> () != 0)
{
ref = site.Cast<PartSite> ()->GetPane()->GetPartReference();
}
}
this->MakeActiveEditor(ref.Cast<IEditorReference> ());
}
else
{
this->MakeActiveEditor(IEditorReference::Pointer(0));
}
}
else
{
this->InternalBringToTop(ref);
if (ref != 0)
{
partList->FirePartBroughtToTop(ref);
}
}
}
void WorkbenchPage::BusyResetPerspective()
{
ViewIntroAdapterPart::Pointer
introViewAdapter =
dynamic_cast<WorkbenchIntroManager*> (GetWorkbenchWindow() ->GetWorkbench()->GetIntroManager())->GetIntroAdapterPart().Cast<
ViewIntroAdapterPart> ();
// PartPane introPane = 0;
// boolean introFullScreen = false;
// if (introViewAdapter != 0)
// {
// introPane = ((PartSite) introViewAdapter.getSite()).getPane();
// introViewAdapter.setHandleZoomEvents(false);
// introFullScreen = introPane.isZoomed();
// }
// //try to prevent intro flicker.
// if (introFullScreen)
// {
// window.getShell().setRedraw(false);
// }
// try
// {
// // Always unzoom
// if (isZoomed())
// {
// zoomOut();
// }
// Get the current perspective.
// This describes the working layout of the page and differs from
// the original template.
Perspective::Pointer oldPersp = this->GetActivePerspective();
// Map the current perspective to the original template.
// If the original template cannot be found then it has been deleted.
// In that case just return. (PR#1GDSABU).
IPerspectiveRegistry* reg =
WorkbenchPlugin::GetDefault() ->GetPerspectiveRegistry();
PerspectiveDescriptor::Pointer desc = reg->FindPerspectiveWithId(
oldPersp->GetDesc()->GetId()).Cast<PerspectiveDescriptor> ();
if (desc == 0)
{
desc
= reg->FindPerspectiveWithId(oldPersp ->GetDesc().Cast<
PerspectiveDescriptor> ()->GetOriginalId()).Cast<
PerspectiveDescriptor> ();
}
if (desc == 0)
{
return;
}
// Notify listeners that we are doing a reset.
window->FirePerspectiveChanged(IWorkbenchPage::Pointer(this), desc,
CHANGE_RESET);
// Create new persp from original template.
// Suppress the perspectiveOpened and perspectiveClosed events otherwise it looks like two
// instances of the same perspective are open temporarily (see bug 127470).
Perspective::Pointer newPersp = this->CreatePerspective(desc, false);
if (newPersp == 0)
{
// We're not going through with the reset, so it is complete.
window->FirePerspectiveChanged(IWorkbenchPage::Pointer(this), desc,
CHANGE_RESET_COMPLETE);
return;
}
// Update the perspective list and shortcut
perspList.Swap(oldPersp, newPersp);
// Install new persp.
this->SetPerspective(newPersp);
// Destroy old persp.
this->DisposePerspective(oldPersp, false);
// Update the Coolbar layout.
this->ResetToolBarLayout();
// restore the maximized intro
if (introViewAdapter)
{
try
{
// ensure that the intro is visible in the new perspective
ShowView(IntroConstants::INTRO_VIEW_ID);
// if (introFullScreen)
// {
// toggleZoom(introPane.getPartReference());
// }
} catch (PartInitException& e)
{
//TODO IStatus
WorkbenchPlugin::Log("Could not restore intro", e);
// WorkbenchPlugin.getStatus(e));
}
// finally
// {
// // we want the intro back to a normal state before we fire the event
// introViewAdapter.setHandleZoomEvents(true);
// }
}
// Notify listeners that we have completed our reset.
window->FirePerspectiveChanged(IWorkbenchPage::Pointer(this), desc,
CHANGE_RESET_COMPLETE);
// }
// finally
// {
// // reset the handling of zoom events (possibly for the second time) in case there was
// // an exception thrown
// if (introViewAdapter != 0)
// {
// introViewAdapter.setHandleZoomEvents(true);
// }
//
// if (introFullScreen)
// {
// window.getShell().setRedraw(true);
// }
// }
}
void WorkbenchPage::BusySetPerspective(IPerspectiveDescriptor::Pointer desc)
{
// Create new layout.
std::string label = desc->GetId(); // debugging only
Perspective::Pointer newPersp;
//try
//{
//UIStats.start(UIStats.SWITCH_PERSPECTIVE, label);
PerspectiveDescriptor::Pointer realDesc = desc.Cast<PerspectiveDescriptor> ();
newPersp = this->FindPerspective(realDesc);
if (newPersp == 0)
{
newPersp = this->CreatePerspective(realDesc, true);
if (newPersp == 0)
{
return;
}
}
// Change layout.
this->SetPerspective(newPersp);
// }
// catch (std::exception& e)
// {
// UIStats.end(UIStats.SWITCH_PERSPECTIVE, desc.getId(), label);
// throw e;
// }
}
IViewPart::Pointer WorkbenchPage::BusyShowView(const std::string& viewID,
const std::string& secondaryID, int mode)
{
Perspective::Pointer persp = this->GetActivePerspective();
if (persp == 0)
{
return IViewPart::Pointer(0);
}
// If this view is already visible just return.
IViewReference::Pointer ref = persp->FindView(viewID, secondaryID);
IViewPart::Pointer view;
if (ref != 0)
{
view = ref->GetView(true);
}
if (view != 0)
{
this->BusyShowView(view, mode);
return view;
}
// Show the view.
view = persp->ShowView(viewID, secondaryID);
if (view != 0)
{
this->BusyShowView(view, mode);
IWorkbenchPartReference::Pointer partReference = this->GetReference(view);
PartPane::Pointer partPane = this->GetPane(partReference);
partPane->SetInLayout(true);
IWorkbenchPage::Pointer thisPage(this);
window->FirePerspectiveChanged(thisPage, GetPerspective(), partReference,
CHANGE_VIEW_SHOW);
window->FirePerspectiveChanged(thisPage, GetPerspective(), CHANGE_VIEW_SHOW);
}
return view;
}
void WorkbenchPage::BusyShowView(IViewPart::Pointer part, int mode)
{
// if (!((GrabFocus) Tweaklets.get(GrabFocus.KEY)).grabFocusAllowed(part))
// {
// return;
// }
if (mode == VIEW_ACTIVATE)
{
this->Activate(part);
}
else if (mode == VIEW_VISIBLE)
{
IWorkbenchPartReference::Pointer ref = this->GetActivePartReference();
// if there is no active part or it's not a view, bring to top
if (ref == 0 || ref.Cast<IViewReference> () == 0)
{
this->BringToTop(part);
}
else
{
// otherwise check to see if the we're in the same stack as the active view
IViewReference::Pointer activeView = ref.Cast<IViewReference> ();
std::vector<IViewReference::Pointer> viewStack =
this->GetViewReferenceStack(part);
for (unsigned int i = 0; i < viewStack.size(); i++)
{
if (viewStack[i] == activeView)
{
return;
}
}
this->BringToTop(part);
}
}
}
bool WorkbenchPage::CertifyPart(IWorkbenchPart::Pointer part)
{
//Workaround for bug 22325
if (part != 0 && part->GetSite().Cast<PartSite> () == 0)
{
return false;
}
if (part.Cast<IEditorPart> () != 0)
{
IEditorReference::Pointer ref = this->GetReference(part).Cast<
IEditorReference> ();
return ref != 0 && this->GetEditorManager()->ContainsEditor(ref);
}
if (part.Cast<IViewPart> () != 0)
{
Perspective::Pointer persp = this->GetActivePerspective();
return persp != 0 && persp->ContainsView(part.Cast<IViewPart> ());
}
return false;
}
bool WorkbenchPage::Close()
{
bool ret;
//BusyIndicator.showWhile(0, new Runnable()
// {
// public void WorkbenchPage::run()
// {
ret = window->ClosePage(IWorkbenchPage::Pointer(this), true);
// }
// });
return ret;
}
bool WorkbenchPage::CloseAllSavedEditors()
{
// get the Saved editors
std::list<IEditorReference::Pointer> editors = this->GetEditorReferences();
std::list<IEditorReference::Pointer> savedEditors;
for (std::list<IEditorReference::Pointer>::iterator iter = editors.begin(); iter
!= editors.end(); ++iter)
{
IEditorReference::Pointer editor = *iter;
if (!editor->IsDirty())
{
savedEditors.push_back(editor);
}
}
//there are no unsaved editors
if (savedEditors.empty())
{
return true;
}
return this->CloseEditors(savedEditors, false);
}
bool WorkbenchPage::CloseAllEditors(bool save)
{
return this->CloseEditors(this->GetEditorReferences(), save);
}
void WorkbenchPage::UpdateActivePart()
{
if (this->IsDeferred())
{
return;
}
IWorkbenchPartReference::Pointer oldActivePart =
partList->GetActivePartReference();
IWorkbenchPartReference::Pointer oldActiveEditor =
partList->GetActiveEditorReference();
IWorkbenchPartReference::Pointer newActivePart;
IEditorReference::Pointer newActiveEditor;
if (!window->IsClosing())
{
// If an editor is active, try to keep an editor active
if (oldActiveEditor && oldActivePart == oldActiveEditor)
{
newActiveEditor = activationList->GetActiveReference(true).Cast<
IEditorReference> ();
newActivePart = newActiveEditor;
if (newActivePart == 0)
{
// Only activate a non-editor if there's no editors left
newActivePart = activationList->GetActiveReference(false);
}
}
else
{
// If a non-editor is active, activate whatever was activated most recently
newActivePart = activationList->GetActiveReference(false);
if (newActivePart.Cast<IEditorReference> () != 0)
{
// If that happens to be an editor, make it the active editor as well
newActiveEditor = newActivePart.Cast<IEditorReference> ();
}
else
{
// Otherwise, select whatever editor was most recently active
newActiveEditor = activationList->GetActiveReference(true).Cast<
IEditorReference> ();
}
}
}
if (oldActiveEditor != newActiveEditor)
{
this->MakeActiveEditor(newActiveEditor);
}
if (newActivePart != oldActivePart)
{
this->MakeActive(newActivePart);
}
}
void WorkbenchPage::MakeActive(IWorkbenchPartReference::Pointer ref)
{
if (ref == 0)
{
this->SetActivePart(IWorkbenchPart::Pointer(0));
}
else
{
IWorkbenchPart::Pointer newActive = ref->GetPart(true);
if (newActive == 0)
{
this->SetActivePart(IWorkbenchPart::Pointer(0));
}
else
{
this->Activate(newActive);
}
}
}
void WorkbenchPage::MakeActiveEditor(IEditorReference::Pointer ref)
{
if (ref == this->GetActiveEditorReference())
{
return;
}
IEditorPart::Pointer part = (ref == 0) ? IEditorPart::Pointer(0)
: ref->GetEditor(true);
if (part)
{
editorMgr->SetVisibleEditor(ref, false);
//navigationHistory.MarkEditor(part);
}
actionSwitcher.UpdateTopEditor(part);
if (ref)
{
activationList->BringToTop(this->GetReference(part));
}
partList->SetActiveEditor(ref);
}
bool WorkbenchPage::CloseEditors(
const std::list<IEditorReference::Pointer>& refArray, bool save)
{
if (refArray.empty())
{
return true;
}
IWorkbenchPage::Pointer thisPage(this);
// Check if we're being asked to close any parts that are already closed or cannot
// be closed at this time
std::vector<IEditorReference::Pointer> editorRefs;
for (std::list<IEditorReference::Pointer>::const_iterator iter =
refArray.begin(); iter != refArray.end(); ++iter)
{
IEditorReference::Pointer reference = *iter;
// If we're in the middle of creating this part, this is a programming error. Abort the entire
// close operation. This usually occurs if someone tries to open a dialog in a method that
// isn't allowed to do so, and a *syncExec tries to close the part. If this shows up in a log
// file with a dialog's event loop on the stack, then the code that opened the dialog is usually
// at fault.
if (partBeingActivated == reference)
{
Poco::RuntimeException re(
"WARNING: Blocked recursive attempt to close part " //$NON-NLS-1$
+ partBeingActivated->GetId()
+ " while still in the middle of activating it");
WorkbenchPlugin::Log(re);
return false;
}
// if (reference.Cast<WorkbenchPartReference> () != 0)
// {
// WorkbenchPartReference::Pointer ref = reference.Cast<WorkbenchPartReference>();
//
// // If we're being asked to close a part that is disposed (ie: already closed),
// // skip it and proceed with closing the remaining parts.
// if (ref.isDisposed())
// {
// continue;
// }
// }
editorRefs.push_back(reference);
}
// notify the model manager before the close
std::list<IWorkbenchPart::Pointer> partsToClose;
for (unsigned int i = 0; i < editorRefs.size(); i++)
{
IWorkbenchPart::Pointer refPart = editorRefs[i]->GetPart(false);
if (refPart != 0)
{
partsToClose.push_back(refPart);
}
}
SaveablesList::Pointer modelManager;
SaveablesList::PostCloseInfo::Pointer postCloseInfo;
if (partsToClose.size() > 0)
{
modelManager = this->GetWorkbenchWindow()->GetService(
ISaveablesLifecycleListener::GetManifestName()).Cast<SaveablesList> ();
// this may prompt for saving and return 0 if the user canceled:
postCloseInfo = modelManager->PreCloseParts(partsToClose, save,
this->GetWorkbenchWindow());
if (postCloseInfo == 0)
{
return false;
}
}
// Fire pre-removal changes
for (unsigned int i = 0; i < editorRefs.size(); i++)
{
IEditorReference::Pointer ref = editorRefs[i];
// Notify interested listeners before the close
window->FirePerspectiveChanged(thisPage, this->GetPerspective(), ref,
CHANGE_EDITOR_CLOSE);
}
this->DeferUpdates(true);
try
{
if (modelManager != 0)
{
modelManager->PostClose(postCloseInfo);
}
// Close all editors.
for (unsigned int i = 0; i < editorRefs.size(); i++)
{
IEditorReference::Pointer ref = editorRefs[i];
// Remove editor from the presentation
editorPresentation->CloseEditor(ref);
this->PartRemoved(ref.Cast<WorkbenchPartReference> ());
}
} catch (...)
{
}
this->DeferUpdates(false);
// Notify interested listeners after the close
window->FirePerspectiveChanged(thisPage, this->GetPerspective(),
CHANGE_EDITOR_CLOSE);
// Return true on success.
return true;
}
void WorkbenchPage::DeferUpdates(bool shouldDefer)
{
if (shouldDefer)
{
if (deferCount == 0)
{
this->StartDeferring();
}
deferCount++;
}
else
{
deferCount--;
if (deferCount == 0)
{
this->HandleDeferredEvents();
}
}
}
void WorkbenchPage::StartDeferring()
{
//editorPresentation.getLayoutPart().deferUpdates(true);
}
void WorkbenchPage::HandleDeferredEvents()
{
editorPresentation->GetLayoutPart()->DeferUpdates(false);
this->UpdateActivePart();
std::vector<WorkbenchPartReference::Pointer> disposals = pendingDisposals;
pendingDisposals.clear();
for (unsigned int i = 0; i < disposals.size(); i++)
{
this->DisposePart(disposals[i]);
}
}
bool WorkbenchPage::IsDeferred()
{
return deferCount > 0;
}
bool WorkbenchPage::CloseEditor(IEditorReference::Pointer editorRef, bool save)
{
std::list<IEditorReference::Pointer> list;
list.push_back(editorRef);
return this->CloseEditors(list, save);
}
bool WorkbenchPage::CloseEditor(IEditorPart::Pointer editor, bool save)
{
IWorkbenchPartReference::Pointer ref = this->GetReference(editor);
if (ref.Cast<IEditorReference> ().IsNotNull())
{
std::list<IEditorReference::Pointer> list;
list.push_back(ref.Cast<IEditorReference> ());
return this->CloseEditors(list, save);
}
return false;
}
void WorkbenchPage::ClosePerspective(IPerspectiveDescriptor::Pointer desc,
bool saveParts, bool closePage)
{
Perspective::Pointer persp = this->FindPerspective(desc);
if (persp != 0)
{
this->ClosePerspective(persp, saveParts, closePage);
}
}
void WorkbenchPage::ClosePerspective(Perspective::Pointer persp,
bool saveParts, bool closePage)
{
// // Always unzoom
// if (isZoomed())
// {
// zoomOut();
// }
std::vector<IWorkbenchPart::Pointer> partsToSave;
std::list<IWorkbenchPart::Pointer> viewsToClose;
// collect views that will go away and views that are dirty
std::vector<IViewReference::Pointer> viewReferences =
persp->GetViewReferences();
for (unsigned int i = 0; i < viewReferences.size(); i++)
{
IViewReference::Pointer reference = viewReferences[i];
if (this->GetViewFactory()->GetReferenceCount(reference) == 1)
{
IViewPart::Pointer viewPart = reference->GetView(false);
if (viewPart != 0)
{
viewsToClose.push_back(viewPart);
if (saveParts && reference->IsDirty())
{
partsToSave.push_back(viewPart);
}
}
}
}
if (saveParts && perspList.Size() == 1)
{
// collect editors that are dirty
std::list<IEditorReference::Pointer> editorReferences =
this->GetEditorReferences();
for (std::list<IEditorReference::Pointer>::iterator refIter =
editorReferences.begin(); refIter != editorReferences.end(); ++refIter)
{
IEditorReference::Pointer reference = *refIter;
if (reference->IsDirty())
{
IEditorPart::Pointer editorPart = reference->GetEditor(false);
if (editorPart != 0)
{
partsToSave.push_back(editorPart);
}
}
}
}
if (saveParts && !partsToSave.empty())
{
if (!EditorManager::SaveAll(partsToSave, true, true, false,
IWorkbenchWindow::Pointer(window)))
{
// user canceled
return;
}
}
// Close all editors on last perspective close
if (perspList.Size() == 1 && this->GetEditorManager()->GetEditorCount() > 0)
{
// Close all editors
if (!this->CloseAllEditors(false))
{
return;
}
}
// closeAllEditors already notified the saveables list about the editors.
SaveablesList::Pointer
saveablesList =
this->GetWorkbenchWindow()->GetWorkbench()->GetService(
ISaveablesLifecycleListener::GetManifestName()).Cast<
SaveablesList> ();
// we took care of the saving already, so pass in false (postCloseInfo will be non-0)
SaveablesList::PostCloseInfo::Pointer postCloseInfo =
saveablesList->PreCloseParts(viewsToClose, false,
this->GetWorkbenchWindow());
saveablesList->PostClose(postCloseInfo);
// Dispose of the perspective
bool isActive = (perspList.GetActive() == persp);
if (isActive)
{
this->SetPerspective(perspList.GetNextActive());
}
this->DisposePerspective(persp, true);
if (closePage && perspList.Size() == 0)
{
this->Close();
}
}
void WorkbenchPage::CloseAllPerspectives(bool saveEditors, bool closePage)
{
if (perspList.IsEmpty())
{
return;
}
// // Always unzoom
// if (isZoomed())
// {
// zoomOut();
// }
if (saveEditors)
{
if (!this->SaveAllEditors(true))
{
return;
}
}
// Close all editors
if (!this->CloseAllEditors(false))
{
return;
}
// Deactivate the active perspective and part
this->SetPerspective(Perspective::Pointer(0));
// Close each perspective in turn
PerspectiveList oldList = perspList;
perspList = PerspectiveList();
for (PerspectiveList::iterator itr = oldList.Begin(); itr != oldList.End(); ++itr)
{
this->ClosePerspective(*itr, false, false);
}
if (closePage)
{
this->Close();
}
}
void WorkbenchPage::CreateClientComposite()
{
void* parent = window->GetPageComposite();
// StartupThreading.runWithoutExceptions(new StartupRunnable()
// {
//
// public void WorkbenchPage::runWithException()
// {
composite
= Tweaklets::Get(WorkbenchPageTweaklet::KEY)->CreateClientComposite(
parent);
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->SetVisible(composite, false); // Make visible on activate.
// force the client composite to be layed out
// parent.layout();
// }
// });
}
Perspective::Pointer WorkbenchPage::CreatePerspective(
PerspectiveDescriptor::Pointer desc, bool notify)
{
std::string label = desc->GetId(); // debugging only
try
{
//UIStats.start(UIStats.CREATE_PERSPECTIVE, label);
WorkbenchPage::Pointer thisPage(this);
Perspective::Pointer persp(new Perspective(desc, thisPage));
perspList.Add(persp);
if (notify)
{
window->FirePerspectiveOpened(thisPage, desc);
}
//if the perspective is fresh and uncustomzied then it is not dirty
//no reset will be prompted for
if (!desc->HasCustomDefinition())
{
dirtyPerspectives.erase(desc->GetId());
}
return persp;
} catch (WorkbenchException& /*e*/)
{
if (!window->GetWorkbenchImpl()->IsStarting())
{
MessageDialog::OpenError(window->GetShell(), "Error",
"Problems opening perspective \"" + desc->GetId() + "\"");
}
return Perspective::Pointer(0);
}
// finally
// {
// UIStats.end(UIStats.CREATE_PERSPECTIVE, desc.getId(), label);
// }
}
void WorkbenchPage::PartAdded(WorkbenchPartReference::Pointer ref)
{
activationList->Add(ref);
partList->AddPart(ref);
this->UpdateActivePart();
}
void WorkbenchPage::PartRemoved(WorkbenchPartReference::Pointer ref)
{
activationList->Remove(ref);
this->DisposePart(ref);
}
void WorkbenchPage::DisposePart(WorkbenchPartReference::Pointer ref)
{
if (this->IsDeferred())
{
pendingDisposals.push_back(ref);
}
else
{
partList->RemovePart(ref);
ref->Dispose();
}
}
void WorkbenchPage::DeactivatePart(IWorkbenchPart::Pointer part)
{
if (part.IsNotNull())
{
PartSite::Pointer site = part->GetSite().Cast<PartSite> ();
site->GetPane()->ShowFocus(false);
}
}
void WorkbenchPage::DetachView(IViewReference::Pointer ref)
{
Perspective::Pointer persp = this->GetActivePerspective();
if (persp == 0)
{
return;
}
PerspectiveHelper* presentation = persp->GetPresentation();
presentation->DetachPart(ref);
}
void WorkbenchPage::AttachView(IViewReference::Pointer ref)
{
PerspectiveHelper* presentation = this->GetPerspectivePresentation();
presentation->AttachPart(ref);
}
WorkbenchPage::~WorkbenchPage()
{
// increment reference count to prevent recursive deletes
this->Register();
{
{
this->MakeActiveEditor(IEditorReference::Pointer(0));
this->MakeActive(IWorkbenchPartReference::Pointer(0));
// Close and dispose the editors.
this->CloseAllEditors(false);
// Need to make sure model data is cleaned up when the page is
// disposed. Collect all the views on the page and notify the
// saveable list of a pre/post close. This will free model data.
std::vector<IWorkbenchPartReference::Pointer> partsToClose =
this->GetOpenParts();
std::list<IWorkbenchPart::Pointer> dirtyParts;
for (unsigned int i = 0; i < partsToClose.size(); i++)
{
IWorkbenchPart::Pointer part = partsToClose[i]->GetPart(false);
if (part != 0 && part.Cast<IViewPart> () != 0)
{
dirtyParts.push_back(part);
}
}
SaveablesList::Pointer saveablesList =
this->GetWorkbenchWindow()->GetWorkbench()->GetService(
ISaveablesLifecycleListener::GetManifestName()).Cast<
SaveablesList> ();
SaveablesList::PostCloseInfo::Pointer postCloseInfo =
saveablesList->PreCloseParts(dirtyParts, false,
this->GetWorkbenchWindow());
saveablesList->PostClose(postCloseInfo);
IWorkbenchPage::Pointer thisPage(this);
// Get rid of perspectives. This will close the views
for (PerspectiveList::iterator itr = perspList.Begin(); itr
!= perspList.End(); ++itr)
{
Perspective::Pointer perspective = *itr;
window->FirePerspectiveClosed(thisPage, perspective->GetDesc());
//perspective->Dispose();
}
perspList = PerspectiveList();
// Capture views.
std::vector<IViewReference::Pointer> refs = viewFactory->GetViews();
// if (refs.size() > 0)
// {
// // Dispose views.
// for (unsigned int i = 0; i < refs.size(); i++)
// {
// WorkbenchPartReference::Pointer ref = refs[i].Cast<WorkbenchPartReference>();
// //partList.RemovePart(ref);
// //this->FirePartClosed(refs[i]);
// // Platform.run(new SafeRunnable() {
// // public void run() {
// // // WorkbenchPlugin.log(new Status(IStatus.WARNING, WorkbenchPlugin.PI_WORKBENCH,
// // // Status.OK, "WorkbenchPage leaked a refcount for view " + ref.getId(), 0)); //$NON-NLS-1$//$NON-NLS-2$
//
// ref.dispose();
// // }
//
// // public void handleException(Throwable e) {
// // }
// // });
// }
// }
// Get rid of editor presentation.
//editorPresentation->Dispose();
// Get rid of composite.
//composite.dispose();
//navigationHistory.dispose();
//stickyViewMan.clear();
// if (tracker != 0)
// {
// tracker.close();
// }
// // if we're destroying a window in a non-shutdown situation then we should
// // clean up the working set we made.
// if (!window->GetWorkbench()->IsClosing())
// {
// if (aggregateWorkingSet != 0)
// {
// PlatformUI.getWorkbench().getWorkingSetManager().removeWorkingSet(
// aggregateWorkingSet);
// }
// }
}
partBeingActivated = 0;
pendingDisposals.clear();
stickyViewMan = 0;
delete viewFactory;
delete editorPresentation;
delete editorMgr;
delete activationList;
deferredActivePersp = 0;
dirtyPerspectives.clear();
delete selectionService;
partList = 0;
}
// decrement reference count again, without explicit deletion
this->UnRegister(false);
}
void WorkbenchPage::DisposePerspective(Perspective::Pointer persp, bool notify)
{
// Get rid of perspective.
perspList.Remove(persp);
if (notify)
{
IWorkbenchPage::Pointer thisPage(this);
window->FirePerspectiveClosed(thisPage, persp->GetDesc());
}
//persp->Dispose();
stickyViewMan->Remove(persp->GetDesc()->GetId());
}
Perspective::Pointer WorkbenchPage::FindPerspective(
IPerspectiveDescriptor::Pointer desc)
{
for (PerspectiveList::iterator itr = perspList.Begin(); itr
!= perspList.End(); ++itr)
{
Perspective::Pointer mgr = *itr;
if (desc->GetId() == mgr->GetDesc()->GetId())
{
return mgr;
}
}
return Perspective::Pointer(0);
}
IViewPart::Pointer WorkbenchPage::FindView(const std::string& id)
{
IViewReference::Pointer ref = this->FindViewReference(id);
if (ref == 0)
{
return IViewPart::Pointer(0);
}
return ref->GetView(true);
}
IViewReference::Pointer WorkbenchPage::FindViewReference(
const std::string& viewId)
{
return this->FindViewReference(viewId, "");
}
IViewReference::Pointer WorkbenchPage::FindViewReference(
const std::string& viewId, const std::string& secondaryId)
{
Perspective::Pointer persp = this->GetActivePerspective();
if (persp == 0)
{
return IViewReference::Pointer(0);
}
return persp->FindView(viewId, secondaryId);
}
IEditorPart::Pointer WorkbenchPage::GetActiveEditor()
{
return partList->GetActiveEditor();
}
IEditorReference::Pointer WorkbenchPage::GetActiveEditorReference()
{
return partList->GetActiveEditorReference();
}
IWorkbenchPart::Pointer WorkbenchPage::GetActivePart()
{
return partList->GetActivePart();
}
IWorkbenchPartReference::Pointer WorkbenchPage::GetActivePartReference()
{
return partList->GetActivePartReference();
}
Perspective::Pointer WorkbenchPage::GetActivePerspective()
{
return perspList.GetActive();
}
void* WorkbenchPage::GetClientComposite()
{
return composite;
}
EditorManager* WorkbenchPage::GetEditorManager()
{
return editorMgr;
}
PerspectiveHelper* WorkbenchPage::GetPerspectivePresentation()
{
if (this->GetActivePerspective() != 0)
{
return this->GetActivePerspective()->GetPresentation();
}
return 0;
}
/**
* Answer the editor presentation.
*/
EditorAreaHelper* WorkbenchPage::GetEditorPresentation()
{
return editorPresentation;
}
std::vector<IEditorPart::Pointer> WorkbenchPage::GetEditors()
{
std::list<IEditorReference::Pointer> refs = this->GetEditorReferences();
std::vector<IEditorPart::Pointer> result;
//Display d = getWorkbenchWindow().getShell().getDisplay();
//Must be backward compatible.
// d.syncExec(new Runnable()
// {
// public void WorkbenchPage::run()
// {
for (std::list<IEditorReference::Pointer>::iterator iter = refs.begin(); iter
!= refs.end(); ++iter)
{
IEditorPart::Pointer part = (*iter)->GetEditor(true);
if (part != 0)
{
result.push_back(part);
}
}
// }
// });
return result;
}
std::vector<IEditorPart::Pointer> WorkbenchPage::GetDirtyEditors()
{
return this->GetEditorManager()->GetDirtyEditors();
}
std::vector<ISaveablePart::Pointer> WorkbenchPage::GetDirtyParts()
{
std::vector<ISaveablePart::Pointer> result;
std::vector<IWorkbenchPartReference::Pointer> allParts = this->GetAllParts();
for (unsigned int i = 0; i < allParts.size(); i++)
{
IWorkbenchPartReference::Pointer reference = allParts[i];
IWorkbenchPart::Pointer part = reference->GetPart(false);
if (part != 0 && part.Cast<ISaveablePart> () != 0)
{
ISaveablePart::Pointer saveable = part.Cast<ISaveablePart> ();
if (saveable->IsDirty())
{
result.push_back(saveable);
}
}
}
return result;
}
IEditorPart::Pointer WorkbenchPage::FindEditor(IEditorInput::Pointer input)
{
return this->GetEditorManager()->FindEditor(input);
}
std::vector<IEditorReference::Pointer> WorkbenchPage::FindEditors(
IEditorInput::Pointer input, const std::string& editorId, int matchFlags)
{
return this->GetEditorManager()->FindEditors(input, editorId, matchFlags);
}
std::list<IEditorReference::Pointer> WorkbenchPage::GetEditorReferences()
{
return editorPresentation->GetEditors();
}
IAdaptable* WorkbenchPage::GetInput()
{
return input;
}
std::string WorkbenchPage::GetLabel()
{
std::string label = "<Unknown label>";
// IWorkbenchAdapter adapter = (IWorkbenchAdapter) Util.getAdapter(input,
// IWorkbenchAdapter.class);
// if (adapter != 0)
// {
// label = adapter.getLabel(input);
// }
Perspective::Pointer persp = this->GetActivePerspective();
if (persp != 0)
{
label = label + " - " + persp->GetDesc()->GetLabel();
}
else if (deferredActivePersp != 0)
{
label = label + " - " + deferredActivePersp->GetLabel();
}
return label;
}
IPerspectiveDescriptor::Pointer WorkbenchPage::GetPerspective()
{
if (deferredActivePersp != 0)
{
return deferredActivePersp;
}
Perspective::Pointer persp = this->GetActivePerspective();
if (persp != 0)
{
return persp->GetDesc();
}
else
{
return IPerspectiveDescriptor::Pointer(0);
}
}
ISelection::ConstPointer WorkbenchPage::GetSelection() const
{
return selectionService->GetSelection();
}
ISelection::ConstPointer WorkbenchPage::GetSelection(const std::string& partId)
{
return selectionService->GetSelection(partId);
}
//ISelectionService::SelectionEvents& WorkbenchPage::GetSelectionEvents(const std::string& partId)
//{
// return selectionService->GetSelectionEvents(partId);
//}
ViewFactory* WorkbenchPage::GetViewFactory()
{
if (viewFactory == 0)
{
viewFactory = new ViewFactory(this,
WorkbenchPlugin::GetDefault()->GetViewRegistry());
}
return viewFactory;
}
std::vector<IViewReference::Pointer> WorkbenchPage::GetViewReferences()
{
Perspective::Pointer persp = this->GetActivePerspective();
if (persp != 0)
{
return persp->GetViewReferences();
}
else
{
return std::vector<IViewReference::Pointer>();
}
}
std::vector<IViewPart::Pointer> WorkbenchPage::GetViews()
{
return this->GetViews(Perspective::Pointer(0), true);
}
std::vector<IViewPart::Pointer> WorkbenchPage::GetViews(
Perspective::Pointer persp, bool restore)
{
if (persp == 0)
{
persp = this->GetActivePerspective();
}
std::vector<IViewPart::Pointer> parts;
if (persp != 0)
{
std::vector<IViewReference::Pointer> refs = persp->GetViewReferences();
for (unsigned int i = 0; i < refs.size(); i++)
{
IViewPart::Pointer part = refs[i]->GetPart(restore).Cast<IViewPart> ();
if (part != 0)
{
parts.push_back(part);
}
}
}
return parts;
}
IWorkbenchWindow::Pointer WorkbenchPage::GetWorkbenchWindow()
{
return IWorkbenchWindow::Pointer(window);
}
void WorkbenchPage::HideView(IViewReference::Pointer ref)
{
// Sanity check.
if (ref == 0)
{
return;
}
Perspective::Pointer persp = this->GetActivePerspective();
if (persp == 0)
{
return;
}
bool promptedForSave = false;
IViewPart::Pointer view = ref->GetView(false);
if (view != 0)
{
if (!this->CertifyPart(view))
{
return;
}
// Confirm.
if (view.Cast<ISaveablePart> () != 0)
{
ISaveablePart::Pointer saveable = view.Cast<ISaveablePart> ();
if (saveable->IsSaveOnCloseNeeded())
{
IWorkbenchWindow::Pointer window =
view->GetSite()->GetWorkbenchWindow();
std::vector<IWorkbenchPart::Pointer> partsToSave;
partsToSave.push_back(view);
bool success = EditorManager::SaveAll(partsToSave, true, true, false,
window);
if (!success)
{
// the user cancelled.
return;
}
promptedForSave = true;
}
}
}
int refCount = this->GetViewFactory()->GetReferenceCount(ref);
SaveablesList::Pointer saveablesList;
SaveablesList::PostCloseInfo::Pointer postCloseInfo;
if (refCount == 1)
{
IWorkbenchPart::Pointer actualPart = ref->GetPart(false);
if (actualPart != 0)
{
saveablesList
= actualPart->GetSite()->GetService(
ISaveablesLifecycleListener::GetManifestName()).Cast<
SaveablesList> ();
std::list<IWorkbenchPart::Pointer> partsToClose;
partsToClose.push_back(actualPart);
postCloseInfo = saveablesList->PreCloseParts(partsToClose,
!promptedForSave, this->GetWorkbenchWindow());
if (postCloseInfo == 0)
{
// cancel
return;
}
}
}
IWorkbenchPage::Pointer thisPage(this);
// Notify interested listeners before the hide
window->FirePerspectiveChanged(thisPage, persp->GetDesc(), ref,
CHANGE_VIEW_HIDE);
PartPane::Pointer pane = this->GetPane(ref.Cast<IWorkbenchPartReference> ());
pane->SetInLayout(false);
this->UpdateActivePart();
if (saveablesList != 0)
{
saveablesList->PostClose(postCloseInfo);
}
// Hide the part.
persp->HideView(ref);
// Notify interested listeners after the hide
window->FirePerspectiveChanged(thisPage, this->GetPerspective(),
CHANGE_VIEW_HIDE);
}
void WorkbenchPage::RefreshActiveView()
{
this->UpdateActivePart();
}
void WorkbenchPage::HideView(IViewPart::Pointer view)
{
this->HideView(this->GetReference(view).Cast<IViewReference> ());
}
void WorkbenchPage::Init(WorkbenchWindow* w, const std::string& layoutID,
IAdaptable* input, bool openExtras)
{
// Save args.
this->window = w;
this->input = input;
this->composite = 0;
this->viewFactory = 0;
this->activationList = new ActivationList(this);
this->selectionService = new PageSelectionService(this);
this->partList = new WorkbenchPagePartList(this->selectionService);
this->stickyViewMan = new StickyViewManager(this);
//actionSets = new ActionSetManager(w);
deferCount = 0;
// Create presentation.
this->CreateClientComposite();
editorPresentation = new EditorAreaHelper(this);
editorMgr = new EditorManager(WorkbenchWindow::Pointer(window),
WorkbenchPage::Pointer(this), editorPresentation);
//TODO WorkbenchPage perspective reorder listener?
// // add this page as a client to be notified when the UI has re-ordered perspectives
// // so that the order can be properly maintained in the receiver.
// // E.g. a UI might support drag-and-drop and will need to make this known to ensure
// // #saveState and #restoreState do not lose this re-ordering
// w.addPerspectiveReorderListener(new IReorderListener()
// {
// public void WorkbenchPage::reorder(Object perspective, int newLoc)
// {
// perspList.reorder((IPerspectiveDescriptor)perspective, newLoc);
// }
// });
if (openExtras)
{
this->OpenPerspectiveExtras();
}
// Get perspective descriptor.
if (layoutID != "")
{
PerspectiveDescriptor::Pointer
desc =
WorkbenchPlugin::GetDefault()->GetPerspectiveRegistry()->FindPerspectiveWithId(
layoutID).Cast<PerspectiveDescriptor> ();
if (desc == 0)
{
throw WorkbenchException("Unable to create Perspective " + layoutID
+ ". There is no corresponding perspective extension.");
}
Perspective::Pointer persp = this->FindPerspective(desc);
if (persp == 0)
{
persp = this->CreatePerspective(desc, true);
}
perspList.SetActive(persp);
window->FirePerspectiveActivated(IWorkbenchPage::Pointer(this), desc);
}
// getExtensionTracker() .registerHandler(perspectiveChangeHandler,
// ExtensionTracker .createExtensionPointFilter(
// getPerspectiveExtensionPoint()));
}
void WorkbenchPage::OpenPerspectiveExtras()
{
//TODO WorkbenchPage perspectice extras
std::string extras = ""; //PrefUtil.getAPIPreferenceStore().getString(
// IWorkbenchPreferenceConstants.PERSPECTIVE_BAR_EXTRAS);
Poco::StringTokenizer tok(extras, ", ", Poco::StringTokenizer::TOK_TRIM
| Poco::StringTokenizer::TOK_IGNORE_EMPTY); //$NON-NLS-1$
std::vector<IPerspectiveDescriptor::Pointer> descs;
for (Poco::StringTokenizer::Iterator itr = tok.begin(); itr != tok.end(); ++itr)
{
std::string id = *itr;
IPerspectiveDescriptor::Pointer
desc =
WorkbenchPlugin::GetDefault()->GetPerspectiveRegistry()->FindPerspectiveWithId(
id);
if (desc != 0)
{
descs.push_back(desc);
}
}
// HACK: The perspective switcher currently adds the button for a new perspective to the beginning of the list.
// So, we process the extra perspectives in reverse order here to have their buttons appear in the order declared.
for (int i = (int) descs.size(); --i >= 0;)
{
PerspectiveDescriptor::Pointer desc =
descs[i].Cast<PerspectiveDescriptor> ();
if (this->FindPerspective(desc) == 0)
{
this->CreatePerspective(desc, true);
}
}
}
bool WorkbenchPage::IsPartVisible(IWorkbenchPart::Pointer part)
{
PartPane::Pointer pane = this->GetPane(part);
return pane != 0 && pane->GetVisible();
}
bool WorkbenchPage::IsEditorAreaVisible()
{
Perspective::Pointer persp = this->GetActivePerspective();
if (persp == 0)
{
return false;
}
return persp->IsEditorAreaVisible();
}
bool WorkbenchPage::IsFastView(IViewReference::Pointer /*ref*/)
{
Perspective::Pointer persp = this->GetActivePerspective();
if (persp != 0)
{
//return persp->IsFastView(ref);
return false;
}
else
{
return false;
}
}
bool WorkbenchPage::IsCloseable(IViewReference::Pointer ref)
{
Perspective::Pointer persp = this->GetActivePerspective();
if (persp != 0)
{
return persp->IsCloseable(ref);
}
return false;
}
bool WorkbenchPage::IsMoveable(IViewReference::Pointer ref)
{
Perspective::Pointer persp = this->GetActivePerspective();
if (persp != 0)
{
return persp->IsMoveable(ref);
}
return false;
}
bool WorkbenchPage::IsFixedLayout()
{
Perspective::Pointer persp = this->GetActivePerspective();
if (persp != 0)
{
return persp->IsFixedLayout();
}
else
{
return false;
}
}
bool WorkbenchPage::IsSaveNeeded()
{
return this->GetEditorManager()->IsSaveAllNeeded();
}
void WorkbenchPage::OnActivate()
{
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->SetVisible(composite, true);
Perspective::Pointer persp = this->GetActivePerspective();
if (persp != 0)
{
persp->OnActivate();
this->UpdateVisibility(Perspective::Pointer(0), persp);
}
}
void WorkbenchPage::OnDeactivate()
{
this->MakeActiveEditor(IEditorReference::Pointer(0));
this->MakeActive(IWorkbenchPartReference::Pointer(0));
if (this->GetActivePerspective() != 0)
{
this->GetActivePerspective()->OnDeactivate();
}
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->SetVisible(composite, false);
}
void WorkbenchPage::ReuseEditor(IReusableEditor::Pointer editor,
IEditorInput::Pointer input)
{
// Rather than calling editor.setInput on the editor directly, we do it through the part reference.
// This case lets us detect badly behaved editors that are not firing a PROP_INPUT event in response
// to the input change... but if all editors obeyed their API contract, the "else" branch would be
// sufficient.
IWorkbenchPartReference::Pointer ref = this->GetReference(editor);
if (ref.Cast<EditorReference> () != 0)
{
EditorReference::Pointer editorRef = ref.Cast<EditorReference> ();
editorRef->SetInput(input);
}
else
{
editor->SetInput(input);
}
//navigationHistory.markEditor(editor);
}
IEditorPart::Pointer WorkbenchPage::OpenEditor(IEditorInput::Pointer input,
const std::string& editorID)
{
return this->OpenEditor(input, editorID, true, MATCH_INPUT);
}
IEditorPart::Pointer WorkbenchPage::OpenEditor(IEditorInput::Pointer input,
const std::string& editorID, bool activate)
{
return this->OpenEditor(input, editorID, activate, MATCH_INPUT);
}
IEditorPart::Pointer WorkbenchPage::OpenEditor(
const IEditorInput::Pointer input, const std::string& editorID,
bool activate, int matchFlags)
{
return this->OpenEditor(input, editorID, activate, matchFlags,
IMemento::Pointer(0));
}
IEditorPart::Pointer WorkbenchPage::OpenEditor(
const IEditorInput::Pointer input, const std::string& editorID,
bool activate, int matchFlags, IMemento::Pointer editorState)
{
if (input == 0 || editorID == "")
{
throw Poco::InvalidArgumentException();
}
// BusyIndicator.showWhile(window.getWorkbench().getDisplay(),
// new Runnable()
// {
// public void WorkbenchPage::run()
// {
return this->BusyOpenEditor(input, editorID, activate, matchFlags,
editorState);
}
IEditorPart::Pointer WorkbenchPage::OpenEditorFromDescriptor(
IEditorInput::Pointer input, IEditorDescriptor::Pointer editorDescriptor,
bool activate, IMemento::Pointer editorState)
{
if (input == 0 || !(editorDescriptor.Cast<EditorDescriptor> () != 0))
{
throw Poco::InvalidArgumentException();
}
// BusyIndicator.showWhile(window.getWorkbench().getDisplay(),
// new Runnable()
// {
// public void WorkbenchPage::run()
// {
return this->BusyOpenEditorFromDescriptor(input, editorDescriptor.Cast<
EditorDescriptor> (), activate, editorState);
// }
// });
}
IEditorPart::Pointer WorkbenchPage::BusyOpenEditor(IEditorInput::Pointer input,
const std::string& editorID, bool activate, int matchFlags,
IMemento::Pointer editorState)
{
Workbench* workbench =
this->GetWorkbenchWindow().Cast<WorkbenchWindow> ()->GetWorkbenchImpl();
workbench->LargeUpdateStart();
IEditorPart::Pointer result;
try
{
result = this->BusyOpenEditorBatched(input, editorID, activate, matchFlags,
editorState);
} catch (std::exception& e)
{
workbench->LargeUpdateEnd();
throw e;
}
workbench->LargeUpdateEnd();
return result;
}
IEditorPart::Pointer WorkbenchPage::BusyOpenEditorFromDescriptor(
IEditorInput::Pointer input, EditorDescriptor::Pointer editorDescriptor,
bool activate, IMemento::Pointer editorState)
{
Workbench* workbench =
this->GetWorkbenchWindow().Cast<WorkbenchWindow> ()->GetWorkbenchImpl();
workbench->LargeUpdateStart();
IEditorPart::Pointer result;
try
{
result = this->BusyOpenEditorFromDescriptorBatched(input, editorDescriptor,
activate, editorState);
} catch (std::exception& e)
{
workbench->LargeUpdateEnd();
throw e;
}
workbench->LargeUpdateEnd();
return result;
}
IEditorPart::Pointer WorkbenchPage::BusyOpenEditorBatched(
IEditorInput::Pointer input, const std::string& editorID, bool activate,
int matchFlags, IMemento::Pointer editorState)
{
// If an editor already exists for the input, use it.
IEditorPart::Pointer editor;
// Reuse an existing open editor, unless we are in "new editor tab management" mode
editor = this->GetEditorManager()->FindEditor(editorID, input, matchFlags);
if (editor != 0)
{
if (IEditorRegistry::SYSTEM_EXTERNAL_EDITOR_ID == editorID)
{
if (editor->IsDirty())
{
std::vector<std::string> dlgLabels;
dlgLabels.push_back("Yes");
dlgLabels.push_back("No");
dlgLabels.push_back("Cancel");
IDialog::Pointer
dialog =
MessageDialog::CreateMessageDialog(
this->GetWorkbenchWindow()->GetShell(),
"Save",
(void*) 0, // accept the default window icon
"\"" + input->GetName()
+ "\" is opened and has unsaved changes. Do you want to save it?",
IDialog::QUESTION, dlgLabels, 0);
int saveFile = dialog->Open();
if (saveFile == 0)
{
// try
// {
IEditorPart::Pointer editorToSave = editor;
// getWorkbenchWindow().run(false, false,
// new IRunnableWithProgress()
// {
// public void WorkbenchPage::run(IProgressMonitor monitor)
// throws InvocationTargetException,
// InterruptedException
// {
//TODO progress monitor
editorToSave->DoSave();//monitor);
// }
// });
// }
// catch (InvocationTargetException& e)
// {
// throw(RuntimeException) e->GetTargetException();
// }
// catch (InterruptedException& e)
// {
// return 0;
// }
}
else if (saveFile == 2)
{
return IEditorPart::Pointer(0);
}
}
}
else
{
// // do the IShowEditorInput notification before showing the editor
// // to reduce flicker
// if (editor.Cast<IShowEditorInput> () != 0)
// {
// ((IShowEditorInput) editor).showEditorInput(input);
// }
this->ShowEditor(activate, editor);
return editor;
}
}
// Otherwise, create a new one. This may cause the new editor to
// become the visible (i.e top) editor.
IEditorReference::Pointer ref = this->GetEditorManager()->OpenEditor(
editorID, input, true, editorState);
if (ref != 0)
{
editor = ref->GetEditor(true);
}
if (editor != 0)
{
this->SetEditorAreaVisible(true);
if (activate)
{
this->Activate(editor);
}
else
{
this->BringToTop(editor);
}
IWorkbenchPage::Pointer thisPage(this);
window->FirePerspectiveChanged(thisPage, this->GetPerspective(), ref,
CHANGE_EDITOR_OPEN);
window->FirePerspectiveChanged(thisPage, this->GetPerspective(),
CHANGE_EDITOR_OPEN);
}
return editor;
}
/*
* Added to fix Bug 178235 [EditorMgmt] DBCS 3.3 - Cannot open file with external program.
* See openEditorFromDescriptor().
*/
IEditorPart::Pointer WorkbenchPage::BusyOpenEditorFromDescriptorBatched(
IEditorInput::Pointer input, EditorDescriptor::Pointer editorDescriptor,
bool activate, IMemento::Pointer editorState)
{
IEditorPart::Pointer editor;
// Create a new one. This may cause the new editor to
// become the visible (i.e top) editor.
IEditorReference::Pointer ref;
ref = this->GetEditorManager()->OpenEditorFromDescriptor(editorDescriptor,
input, editorState);
if (ref != 0)
{
editor = ref->GetEditor(true);
}
if (editor != 0)
{
this->SetEditorAreaVisible(true);
if (activate)
{
this->Activate(editor);
}
else
{
this->BringToTop(editor);
}
IWorkbenchPage::Pointer thisPage(this);
window->FirePerspectiveChanged(thisPage, this->GetPerspective(), ref,
CHANGE_EDITOR_OPEN);
window->FirePerspectiveChanged(thisPage, this->GetPerspective(),
CHANGE_EDITOR_OPEN);
}
return editor;
}
void WorkbenchPage::OpenEmptyTab()
{
IEditorPart::Pointer editor;
EditorReference::Pointer ref;
ref = this->GetEditorManager()->OpenEmptyTab().Cast<EditorReference> ();
if (ref != 0)
{
editor
= ref->GetEmptyEditor(
dynamic_cast<EditorRegistry*> (WorkbenchPlugin::GetDefault()->GetEditorRegistry())->FindEditor(
EditorRegistry::EMPTY_EDITOR_ID).Cast<EditorDescriptor> ());
}
if (editor != 0)
{
this->SetEditorAreaVisible(true);
this->Activate(editor);
IWorkbenchPage::Pointer thisPage(this);
window->FirePerspectiveChanged(thisPage, this->GetPerspective(), ref,
CHANGE_EDITOR_OPEN);
window->FirePerspectiveChanged(thisPage, this->GetPerspective(),
CHANGE_EDITOR_OPEN);
}
}
void WorkbenchPage::ShowEditor(bool activate, IEditorPart::Pointer editor)
{
this->SetEditorAreaVisible(true);
if (activate)
{
//zoomOutIfNecessary(editor);
this->Activate(editor);
}
else
{
this->BringToTop(editor);
}
}
bool WorkbenchPage::IsEditorPinned(IEditorPart::Pointer editor)
{
WorkbenchPartReference::Pointer ref = this->GetReference(editor).Cast<
WorkbenchPartReference> ();
return ref != 0 && ref->IsPinned();
}
/**
* Removes an IPartListener from the part service.
*/
void WorkbenchPage::RemovePartListener(IPartListener::Pointer l)
{
partList->GetPartService()->RemovePartListener(l);
}
/**
* Implements IWorkbenchPage
*
* @see org.blueberry.ui.IWorkbenchPage#removePropertyChangeListener(IPropertyChangeListener)
* @since 2.0
* @deprecated individual views should store a working set if needed and
* register a property change listener directly with the
* working set manager to receive notification when the view
* working set is removed.
*/
// void WorkbenchPage::RemovePropertyChangeListener(IPropertyChangeListener listener) {
// propertyChangeListeners.remove(listener);
// }
void WorkbenchPage::RemoveSelectionListener(
ISelectionListener::Pointer listener)
{
selectionService->RemoveSelectionListener(listener);
}
void WorkbenchPage::RemoveSelectionListener(const std::string& partId,
ISelectionListener::Pointer listener)
{
selectionService->RemoveSelectionListener(partId, listener);
}
void WorkbenchPage::RemovePostSelectionListener(
ISelectionListener::Pointer listener)
{
selectionService->RemovePostSelectionListener(listener);
}
void WorkbenchPage::RemovePostSelectionListener(const std::string& partId,
ISelectionListener::Pointer listener)
{
selectionService->RemovePostSelectionListener(partId, listener);
}
void WorkbenchPage::RequestActivation(IWorkbenchPart::Pointer part)
{
// Sanity check.
if (!this->CertifyPart(part))
{
return;
}
// Real work.
this->SetActivePart(part);
}
/**
* Resets the layout for the perspective. The active part in the old layout
* is activated in the new layout for consistent user context.
*/
void WorkbenchPage::ResetPerspective()
{
// Run op in busy cursor.
// Use set redraw to eliminate the "flash" that can occur in the
// coolbar as the perspective is reset.
// ICoolBarManager2 mgr = (ICoolBarManager2) window.getCoolBarManager2();
// try
// {
// mgr.getControl2().setRedraw(false);
// BusyIndicator.showWhile(0, new Runnable()
// {
// public void WorkbenchPage::run()
// {
this->BusyResetPerspective();
// }
// });
// }finally
// {
// mgr.getControl2().setRedraw(true);
// }
}
bool WorkbenchPage::RestoreState(IMemento::Pointer memento,
const IPerspectiveDescriptor::Pointer activeDescriptor)
{
// StartupThreading.runWithoutExceptions(new StartupRunnable()
// {
//
// public void WorkbenchPage::runWithException() throws Throwable
// {
this->DeferUpdates(true);
// }});
try
{
// Restore working set
std::string pageName;
memento->GetString(WorkbenchConstants::TAG_LABEL, pageName);
// String label = 0; // debugging only
// if (UIStats.isDebugging(UIStats.RESTORE_WORKBENCH))
// {
// label = pageName == 0 ? "" : "::" + pageName; //$NON-NLS-1$ //$NON-NLS-2$
// }
try
{
//UIStats.start(UIStats.RESTORE_WORKBENCH, "WorkbenchPage" + label); //$NON-NLS-1$
// MultiStatus result =
// new MultiStatus(PlatformUI.PLUGIN_ID, IStatus.OK, NLS.bind(
// WorkbenchMessages.WorkbenchPage_unableToRestorePerspective,
// pageName), 0);
bool result = true;
// String workingSetName = memento .getString(
// IWorkbenchConstants.TAG_WORKING_SET);
// if (workingSetName != 0)
// {
// AbstractWorkingSetManager
// workingSetManager =
// (AbstractWorkingSetManager) getWorkbenchWindow() .getWorkbench().getWorkingSetManager();
// setWorkingSet(workingSetManager.getWorkingSet(workingSetName));
// }
//
// IMemento workingSetMem = memento .getChild(
// IWorkbenchConstants.TAG_WORKING_SETS);
// if (workingSetMem != 0)
// {
// std::vector<IMemento::Pointer> workingSetChildren =
// workingSetMem .getChildren(IWorkbenchConstants.TAG_WORKING_SET);
// List workingSetList = new ArrayList(workingSetChildren.length);
// for (int i = 0; i < workingSetChildren.length; i++)
// {
// IWorkingSet
// set =
// getWorkbenchWindow().getWorkbench() .getWorkingSetManager().getWorkingSet(
// workingSetChildren[i].getID());
// if (set != 0)
// {
// workingSetList.add(set);
// }
// }
//
// workingSets = (IWorkingSet[]) workingSetList .toArray(
// new IWorkingSet[workingSetList.size()]);
// }
//
// aggregateWorkingSetId = memento.getString(ATT_AGGREGATE_WORKING_SET_ID);
//
// IWorkingSet setWithId =
// window.getWorkbench().getWorkingSetManager().getWorkingSet(
// aggregateWorkingSetId);
//
// // check to see if the set has already been made and assign it if it has
// if (setWithId.Cast<AggregateWorkingSet> () != 0)
// {
// aggregateWorkingSet = (AggregateWorkingSet) setWithId;
// }
// Restore editor manager.
IMemento::Pointer childMem = memento->GetChild(
WorkbenchConstants::TAG_EDITORS);
//result.merge(getEditorManager().restoreState(childMem));
result &= this->GetEditorManager()->RestoreState(childMem);
childMem = memento->GetChild(WorkbenchConstants::TAG_VIEWS);
if (childMem)
{
//result.merge(getViewFactory().restoreState(childMem));
result &= this->GetViewFactory()->RestoreState(childMem);
}
// Get persp block.
childMem = memento->GetChild(WorkbenchConstants::TAG_PERSPECTIVES);
std::string activePartID;
childMem->GetString(WorkbenchConstants::TAG_ACTIVE_PART, activePartID);
std::string activePartSecondaryID;
if (!activePartID.empty())
{
activePartSecondaryID = ViewFactory::ExtractSecondaryId(activePartID);
if (!activePartSecondaryID.empty())
{
activePartID = ViewFactory::ExtractPrimaryId(activePartID);
}
}
std::string activePerspectiveID;
childMem->GetString(WorkbenchConstants::TAG_ACTIVE_PERSPECTIVE,
activePerspectiveID);
// Restore perspectives.
std::vector<IMemento::Pointer> perspMems(childMem->GetChildren(
WorkbenchConstants::TAG_PERSPECTIVE));
Perspective::Pointer activePerspective;
for (std::size_t i = 0; i < perspMems.size(); i++)
{
IMemento::Pointer current = perspMems[i];
// StartupThreading
// .runWithoutExceptions(new StartupRunnable()
// {
//
// public void WorkbenchPage::runWithException() throws Throwable
// {
Perspective::Pointer persp(new Perspective(
PerspectiveDescriptor::Pointer(0), WorkbenchPage::Pointer(this)));
//result.merge(persp.restoreState(current));
result &= persp->RestoreState(current);
IPerspectiveDescriptor::Pointer desc = persp->GetDesc();
if (desc == activeDescriptor)
{
activePerspective = persp;
}
else if ((activePerspective == 0) && desc->GetId()
== activePerspectiveID)
{
activePerspective = persp;
}
perspList.Add(persp);
window->FirePerspectiveOpened(WorkbenchPage::Pointer(this), desc);
// }
// });
}
bool restoreActivePerspective = false;
if (!activeDescriptor)
{
restoreActivePerspective = true;
}
else if (activePerspective && activePerspective->GetDesc()
== activeDescriptor)
{
restoreActivePerspective = true;
}
else
{
restoreActivePerspective = false;
activePerspective = this->CreatePerspective(activeDescriptor.Cast<
PerspectiveDescriptor> (), true);
if (activePerspective == 0)
{
// result .merge(
// new Status(IStatus.ERR, PlatformUI.PLUGIN_ID, 0, NLS.bind(
// WorkbenchMessages.Workbench_showPerspectiveError,
// activeDescriptor.getId()), 0));
result &= false;
}
}
perspList.SetActive(activePerspective);
// Make sure we have a valid perspective to work with,
// otherwise return.
activePerspective = perspList.GetActive();
if (activePerspective == 0)
{
activePerspective = perspList.GetNextActive();
perspList.SetActive(activePerspective);
}
if (activePerspective && restoreActivePerspective)
{
//result.merge(activePerspective.restoreState());
result &= activePerspective->RestoreState();
}
if (activePerspective)
{
Perspective::Pointer myPerspective = activePerspective;
std::string myActivePartId = activePartID;
std::string mySecondaryId = activePartSecondaryID;
// StartupThreading.runWithoutExceptions(new StartupRunnable()
// {
//
// public void WorkbenchPage::runWithException() throws Throwable
// {
window->FirePerspectiveActivated(WorkbenchPage::Pointer(this),
myPerspective->GetDesc());
// Restore active part.
if (!myActivePartId.empty())
{
IWorkbenchPartReference::Pointer ref = myPerspective->FindView(
myActivePartId, mySecondaryId);
if (ref)
{
activationList->SetActive(ref);
}
}
// }});
}
// childMem = memento->GetChild(WorkbenchConstants::TAG_NAVIGATION_HISTORY);
// if (childMem)
// {
// navigationHistory.restoreState(childMem);
// }
// else if (GetActiveEditor())
// {
// navigationHistory.markEditor(getActiveEditor());
// }
//
// restore sticky view state
stickyViewMan->Restore(memento);
// std::string blame = activeDescriptor == 0 ? pageName
// : activeDescriptor.getId();
// UIStats.end(UIStats.RESTORE_WORKBENCH, blame, "WorkbenchPage" + label); //$NON-NLS-1$
// StartupThreading.runWithoutExceptions(new StartupRunnable()
// {
// public void WorkbenchPage::runWithException() throws Throwable
// {
DeferUpdates(false);
// }
// });
return result;
} catch (...)
{
// std::string blame = activeDescriptor == 0 ? pageName
// : activeDescriptor.getId();
// UIStats.end(UIStats.RESTORE_WORKBENCH, blame, "WorkbenchPage" + label); //$NON-NLS-1$
throw ;
}
}
catch (...)
{
// StartupThreading.runWithoutExceptions(new StartupRunnable()
// {
// public void WorkbenchPage::runWithException() throws Throwable
// {
DeferUpdates(false);
// }
// });
throw;
}
}
bool WorkbenchPage::SaveAllEditors(bool confirm)
{
return this->SaveAllEditors(confirm, false);
}
bool WorkbenchPage::SaveAllEditors(bool confirm, bool addNonPartSources)
{
return this->GetEditorManager()->SaveAll(confirm, false, addNonPartSources);
}
bool WorkbenchPage::SavePart(ISaveablePart::Pointer saveable,
IWorkbenchPart::Pointer part, bool confirm)
{
// Do not certify part do allow editors inside a multipageeditor to
// call this.
return this->GetEditorManager()->SavePart(saveable, part, confirm);
}
bool WorkbenchPage::SaveEditor(IEditorPart::Pointer editor, bool confirm)
{
return this->SavePart(editor, editor, confirm);
}
/**
* Saves the current perspective.
*/
void WorkbenchPage::SavePerspective()
{
Perspective::Pointer persp = this->GetActivePerspective();
if (persp == 0)
{
return;
}
// // Always unzoom.
// if (isZoomed())
// {
// zoomOut();
// }
persp->SaveDesc();
}
/**
* Saves the perspective.
*/
void WorkbenchPage::SavePerspectiveAs(IPerspectiveDescriptor::Pointer newDesc)
{
Perspective::Pointer persp = this->GetActivePerspective();
if (persp == 0)
{
return;
}
IPerspectiveDescriptor::Pointer oldDesc = persp->GetDesc();
// // Always unzoom.
// if (isZoomed())
// {
// zoomOut();
// }
persp->SaveDescAs(newDesc);
window->FirePerspectiveSavedAs(IWorkbenchPage::Pointer(this), oldDesc, newDesc);
}
/**
* Save the state of the page.
*/
bool WorkbenchPage::SaveState(IMemento::Pointer memento)
{
// // We must unzoom to get correct layout.
// if (isZoomed())
// {
// zoomOut();
// }
// MultiStatus
// result =
// new MultiStatus(PlatformUI.PLUGIN_ID, IStatus.OK, NLS.bind(
// WorkbenchMessages.WorkbenchPage_unableToSavePerspective,
// getLabel()), 0);
bool result = true;
// Save editor manager.
IMemento::Pointer childMem = memento->CreateChild(WorkbenchConstants::TAG_EDITORS);
//result.merge(editorMgr.saveState(childMem));
result &= editorMgr->SaveState(childMem);
childMem = memento->CreateChild(WorkbenchConstants::TAG_VIEWS);
//result.merge(getViewFactory().saveState(childMem));
result &= this->GetViewFactory()->SaveState(childMem);
// Create persp block.
childMem = memento->CreateChild(WorkbenchConstants::TAG_PERSPECTIVES);
if (this->GetPerspective())
{
childMem->PutString(WorkbenchConstants::TAG_ACTIVE_PERSPECTIVE,
this->GetPerspective()->GetId());
}
if (this->GetActivePart() != 0)
{
if (this->GetActivePart().Cast<IViewPart> ())
{
IViewReference::Pointer ref = this->GetReference(this->GetActivePart()).Cast<IViewReference>();
if (ref)
{
childMem->PutString(WorkbenchConstants::TAG_ACTIVE_PART,
ViewFactory::GetKey(ref));
}
}
else
{
childMem->PutString(WorkbenchConstants::TAG_ACTIVE_PART,
this->GetActivePart()->GetSite()->GetId());
}
}
// Save each perspective in opened order
for (PerspectiveList::PerspectiveListType::iterator itr = perspList.Begin();
itr != perspList.End(); ++itr)
{
IMemento::Pointer gChildMem = childMem->CreateChild(
WorkbenchConstants::TAG_PERSPECTIVE);
//result.merge(persp.saveState(gChildMem));
result &= (*itr)->SaveState(gChildMem);
}
// // Save working set if set
// if (workingSet != 0)
// {
// memento.putString(IWorkbenchConstants.TAG_WORKING_SET,
// workingSet .getName());
// }
//
// IMemento workingSetMem = memento .createChild(
// IWorkbenchConstants.TAG_WORKING_SETS);
// for (int i = 0; i < workingSets.length; i++)
// {
// workingSetMem.createChild(IWorkbenchConstants.TAG_WORKING_SET,
// workingSets[i].getName());
// }
//
// if (aggregateWorkingSetId != 0)
// {
// memento.putString(ATT_AGGREGATE_WORKING_SET_ID, aggregateWorkingSetId);
// }
//
// navigationHistory.saveState(memento .createChild(
// IWorkbenchConstants.TAG_NAVIGATION_HISTORY));
//
// save the sticky activation state
stickyViewMan->Save(memento);
return result;
}
std::string WorkbenchPage::GetId(IWorkbenchPart::Pointer part)
{
return this->GetId(this->GetReference(part));
}
std::string WorkbenchPage::GetId(IWorkbenchPartReference::Pointer ref)
{
if (ref == 0)
{
return "0"; //$NON-NLS-1$
}
return ref->GetId();
}
void WorkbenchPage::SetActivePart(IWorkbenchPart::Pointer newPart)
{
// Optimize it.
if (this->GetActivePart() == newPart)
{
return;
}
if (partBeingActivated != 0)
{
if (partBeingActivated->GetPart(false) != newPart)
{
WorkbenchPlugin::Log(Poco::RuntimeException(
"WARNING: Prevented recursive attempt to activate part "
+ this->GetId(newPart)
+ " while still in the middle of activating part " + this->GetId(
partBeingActivated)));
}
return;
}
//No need to change the history if the active editor is becoming the
// active part
// String label = 0; // debugging only
// if (UIStats.isDebugging(UIStats.ACTIVATE_PART))
// {
// label = newPart != 0 ? newPart.getTitle() : "none"; //$NON-NLS-1$
// }
try
{
IWorkbenchPartReference::Pointer partref = this->GetReference(newPart);
IWorkbenchPartReference::Pointer realPartRef;
if (newPart != 0)
{
IWorkbenchPartSite::Pointer site = newPart->GetSite();
if (site.Cast<PartSite> () != 0)
{
realPartRef = site.Cast<PartSite> ()->GetPane()->GetPartReference();
}
}
partBeingActivated = realPartRef;
//UIStats.start(UIStats.ACTIVATE_PART, label);
// Notify perspective. It may deactivate fast view.
Perspective::Pointer persp = this->GetActivePerspective();
if (persp != 0)
{
persp->PartActivated(newPart);
}
// Deactivate old part
IWorkbenchPart::Pointer oldPart = this->GetActivePart();
if (oldPart != 0)
{
this->DeactivatePart(oldPart);
}
// Set active part.
if (newPart != 0)
{
activationList->SetActive(newPart);
if (newPart.Cast<IEditorPart> () != 0)
{
this->MakeActiveEditor(realPartRef.Cast<IEditorReference> ());
}
}
this->ActivatePart(newPart);
actionSwitcher.UpdateActivePart(newPart);
partList->SetActivePart(partref);
}
catch (std::exception& e)
{
partBeingActivated = 0;
// Object blame = newPart == 0 ? (Object) this : newPart;
// UIStats.end(UIStats.ACTIVATE_PART, blame, label);
throw e;
}
partBeingActivated = 0;
}
void WorkbenchPage::SetEditorAreaVisible(bool showEditorArea)
{
Perspective::Pointer persp = this->GetActivePerspective();
if (persp == 0)
{
return;
}
if (showEditorArea == persp->IsEditorAreaVisible())
{
return;
}
// // If parts change always update zoom.
// if (isZoomed())
// {
// zoomOut();
// }
// Update editor area visibility.
IWorkbenchPage::Pointer thisPage(this);
if (showEditorArea)
{
persp->ShowEditorArea();
window->FirePerspectiveChanged(thisPage, this->GetPerspective(),
CHANGE_EDITOR_AREA_SHOW);
}
else
{
persp->HideEditorArea();
this->UpdateActivePart();
window->FirePerspectiveChanged(thisPage, this->GetPerspective(),
CHANGE_EDITOR_AREA_HIDE);
}
}
/**
* Sets the layout of the page. Assumes the new perspective is not 0.
* Keeps the active part if possible. Updates the window menubar and
* toolbar if necessary.
*/
void WorkbenchPage::SetPerspective(Perspective::Pointer newPersp)
{
// Don't do anything if already active layout
Perspective::Pointer oldPersp = this->GetActivePerspective();
if (oldPersp == newPersp)
{
return;
}
window->LargeUpdateStart();
std::exception exc;
bool exceptionOccured = false;
try
{
IWorkbenchPage::Pointer thisPage(this);
if (oldPersp != 0)
{
// fire the pre-deactivate
window->FirePerspectivePreDeactivate(thisPage, oldPersp->GetDesc());
}
if (newPersp != 0)
{
bool status = newPersp->RestoreState();
if (!status)
{
std::string title = "Restoring problems";
std::string msg = "Unable to read workbench state.";
MessageDialog::OpenError(this->GetWorkbenchWindow()->GetShell(), title,
msg);
}
}
// Deactivate the old layout
if (oldPersp != 0)
{
oldPersp->OnDeactivate();
// Notify listeners of deactivation
window->FirePerspectiveDeactivated(thisPage, oldPersp->GetDesc());
}
// Activate the new layout
perspList.SetActive(newPersp);
if (newPersp != 0)
{
newPersp->OnActivate();
// Notify listeners of activation
window->FirePerspectiveActivated(thisPage, newPersp->GetDesc());
}
this->UpdateVisibility(oldPersp, newPersp);
// Update the window
//TODO action sets
//window->UpdateActionSets();
// Update sticky views
stickyViewMan->Update(oldPersp, newPersp);
}
catch (std::exception& e)
{
exc = e;
exceptionOccured = true;
}
window->LargeUpdateEnd();
if (newPersp == 0)
{
return;
}
IPerspectiveDescriptor::Pointer desc = newPersp->GetDesc();
if (desc == 0)
{
return;
}
if (dirtyPerspectives.erase(desc->GetId()))
{
this->SuggestReset();
}
if (exceptionOccured)
throw exc;
}
void WorkbenchPage::UpdateVisibility(Perspective::Pointer oldPersp,
Perspective::Pointer newPersp)
{
// Flag all parts in the old perspective
std::vector<IViewReference::Pointer> oldRefs;
if (oldPersp != 0)
{
oldRefs = oldPersp->GetViewReferences();
for (unsigned int i = 0; i < oldRefs.size(); i++)
{
PartPane::Pointer pane =
oldRefs[i].Cast<WorkbenchPartReference> ()->GetPane();
pane->SetInLayout(false);
}
}
PerspectiveHelper* pres = 0;
// Make parts in the new perspective visible
if (newPersp != 0)
{
pres = newPersp->GetPresentation();
std::vector<IViewReference::Pointer> newRefs =
newPersp->GetViewReferences();
for (unsigned int i = 0; i < newRefs.size(); i++)
{
WorkbenchPartReference::Pointer ref = newRefs[i].Cast<
WorkbenchPartReference> ();
PartPane::Pointer pane = ref->GetPane();
if (pres->IsPartVisible(ref))
{
activationList->BringToTop(ref);
}
pane->SetInLayout(true);
}
}
this->UpdateActivePart();
// Hide any parts in the old perspective that are no longer visible
for (unsigned int i = 0; i < oldRefs.size(); i++)
{
WorkbenchPartReference::Pointer ref = oldRefs[i].Cast<
WorkbenchPartReference> ();
PartPane::Pointer pane = ref->GetPane();
if (pres == 0 || !pres->IsPartVisible(ref))
{
pane->SetVisible(false);
}
}
}
/**
* Sets the perspective.
*
* @param desc
* identifies the new perspective.
*/
void WorkbenchPage::SetPerspective(IPerspectiveDescriptor::Pointer desc)
{
if (this->GetPerspective() == desc)
{
return;
}
// // Going from multiple to single rows can make the coolbar
// // and its adjacent views appear jumpy as perspectives are
// // switched. Turn off redraw to help with this.
// ICoolBarManager2 mgr = (ICoolBarManager2) window.getCoolBarManager2();
std::exception exc;
bool exceptionOccured = false;
try
{
//mgr.getControl2().setRedraw(false);
//getClientComposite().setRedraw(false);
// Run op in busy cursor.
// BusyIndicator.showWhile(0, new Runnable()
// {
// public void WorkbenchPage::run()
// {
this->BusySetPerspective(desc);
// }
// });
}
catch (std::exception& e)
{
exc = e;
exceptionOccured = true;
}
// getClientComposite().setRedraw(true);
// mgr.getControl2().setRedraw(true);
IWorkbenchPart::Pointer part = this->GetActivePart();
if (part != 0)
{
part->SetFocus();
}
if (exceptionOccured)
throw exc;
}
PartService* WorkbenchPage::GetPartService()
{
return dynamic_cast<PartService*> (partList->GetPartService());
}
void WorkbenchPage::ResetToolBarLayout()
{
// ICoolBarManager2 mgr = (ICoolBarManager2) window.getCoolBarManager2();
// mgr.resetItemOrder();
}
IViewPart::Pointer WorkbenchPage::ShowView(const std::string& viewID)
{
return this->ShowView(viewID, "", VIEW_ACTIVATE);
}
IViewPart::Pointer WorkbenchPage::ShowView(const std::string& viewID,
const std::string& secondaryID, int mode)
{
if (secondaryID != "")
{
if (secondaryID.size() == 0 || secondaryID.find_first_of(
ViewFactory::ID_SEP) != std::string::npos)
{
throw Poco::InvalidArgumentException(
"Illegal secondary id (cannot be empty or contain a colon)");
}
}
if (!this->CertifyMode(mode))
{
throw Poco::InvalidArgumentException("Illegal view mode");
}
// Run op in busy cursor.
// BusyIndicator.showWhile(0, new Runnable()
// {
// public void WorkbenchPage::run()
// {
// try
// {
return this->BusyShowView(viewID, secondaryID, mode);
// } catch (PartInitException& e)
// {
// result = e;
// }
// }
// });
}
bool WorkbenchPage::CertifyMode(int mode)
{
if (mode == VIEW_ACTIVATE || mode == VIEW_VISIBLE || mode == VIEW_CREATE)
return true;
return false;
}
std::vector<IEditorReference::Pointer> WorkbenchPage::GetSortedEditors()
{
return activationList->GetEditors();
}
std::vector<IPerspectiveDescriptor::Pointer> WorkbenchPage::GetOpenPerspectives()
{
std::list<Perspective::Pointer> opened = perspList.GetOpenedPerspectives();
std::vector<IPerspectiveDescriptor::Pointer> result;
for (std::list<Perspective::Pointer>::iterator iter = opened.begin(); iter
!= opened.end(); ++iter)
{
result.push_back((*iter)->GetDesc());
}
return result;
}
std::list<Perspective::Pointer> WorkbenchPage::GetOpenInternalPerspectives()
{
return perspList.GetOpenedPerspectives();
}
Perspective::Pointer WorkbenchPage::GetFirstPerspectiveWithView(
IViewPart::Pointer part)
{
std::list<Perspective::Pointer> perspectives =
perspList.GetSortedPerspectives();
for (std::list<Perspective::Pointer>::reverse_iterator iter =
perspectives.rbegin(); iter != perspectives.rend(); ++iter)
{
if ((*iter)->ContainsView(part))
{
return *iter;
}
}
// we should never get here
return Perspective::Pointer(0);
}
std::vector<IPerspectiveDescriptor::Pointer> WorkbenchPage::GetSortedPerspectives()
{
std::list<Perspective::Pointer> sortedArray =
perspList.GetSortedPerspectives();
std::vector<IPerspectiveDescriptor::Pointer> result;
for (std::list<Perspective::Pointer>::iterator iter = sortedArray.begin();
iter != sortedArray.end(); ++iter)
{
result.push_back((*iter)->GetDesc());
}
return result;
}
std::vector<IWorkbenchPartReference::Pointer> WorkbenchPage::GetSortedParts()
{
//return partList->GetParts(this->GetViewReferences());
return activationList->GetParts();
}
IWorkbenchPartReference::Pointer WorkbenchPage::GetReference(
IWorkbenchPart::Pointer part)
{
if (part == 0)
{
return IWorkbenchPartReference::Pointer(0);
}
IWorkbenchPartSite::Pointer site = part->GetSite();
if (site.Cast<PartSite> () == 0)
{
return IWorkbenchPartReference::Pointer(0);
}
PartSite::Pointer partSite = site.Cast<PartSite> ();
PartPane::Pointer pane = partSite->GetPane();
return partSite->GetPartReference();
}
// for dynamic UI
void WorkbenchPage::AddPerspective(Perspective::Pointer persp)
{
perspList.Add(persp);
IWorkbenchPage::Pointer thisPage(this);
window->FirePerspectiveOpened(thisPage, persp->GetDesc());
}
std::vector<IViewReference::Pointer> WorkbenchPage::GetViewReferenceStack(
IViewPart::Pointer part)
{
// Sanity check.
Perspective::Pointer persp = this->GetActivePerspective();
if (persp == 0 || !this->CertifyPart(part))
{
return std::vector<IViewReference::Pointer>();
}
IStackableContainer::Pointer container =
part->GetSite().Cast<PartSite> ()->GetPane()->GetContainer();
if (container.Cast<PartStack> () != 0)
{
PartStack::Pointer folder = container.Cast<PartStack> ();
std::vector<IViewReference::Pointer> list;
IStackableContainer::ChildrenType children = folder->GetChildren();
for (IStackableContainer::ChildrenType::iterator childIter =
children.begin(); childIter != children.end(); ++childIter)
{
StackablePart::Pointer stackablePart = *childIter;
if (stackablePart.Cast<PartPane> () != 0)
{
IViewReference::Pointer view =
stackablePart.Cast<PartPane> ()->GetPartReference().Cast<
IViewReference> ();
if (view != 0)
{
list.push_back(view);
}
}
}
// sort the list by activation order (most recently activated first)
std::sort(list.begin(), list.end(), ActivationOrderPred(activationList));
return list;
}
std::vector<IViewReference::Pointer> result;
result.push_back(this->GetReference(part).Cast<IViewReference> ());
return result;
}
std::vector<IViewPart::Pointer> WorkbenchPage::GetViewStack(
IViewPart::Pointer part)
{
std::vector<IViewReference::Pointer> refStack = this->GetViewReferenceStack(
part);
std::vector<IViewPart::Pointer> result;
for (unsigned int i = 0; i < refStack.size(); i++)
{
IViewPart::Pointer next = refStack[i]->GetView(false);
if (next != 0)
{
result.push_back(next);
}
}
return result;
}
void WorkbenchPage::ResizeView(IViewPart::Pointer part, int width, int height)
{
SashInfo sashInfo;
PartPane::Pointer pane = part->GetSite().Cast<PartSite> ()->GetPane();
IStackableContainer::Pointer container = pane->GetContainer();
LayoutTree::Pointer tree =
this->GetPerspectivePresentation()->GetLayout()->GetLayoutTree()->Find(
container.Cast<PartStack> ());
// retrieve our layout sashes from the layout tree
this->FindSashParts(tree, pane->FindSashes(), sashInfo);
// first set the width
int deltaWidth = width - pane->GetBounds().width;
if (sashInfo.right != 0)
{
Rectangle rightBounds = sashInfo.rightNode->GetBounds();
// set the new ratio
sashInfo.right->SetRatio(static_cast<float>((deltaWidth + sashInfo.right->GetBounds().x)
- rightBounds.x) / rightBounds.width);
// complete the resize
sashInfo.rightNode->SetBounds(rightBounds);
}
else if (sashInfo.left != 0)
{
Rectangle leftBounds = sashInfo.leftNode->GetBounds();
// set the ratio
sashInfo.left->SetRatio(static_cast<float>((sashInfo.left->GetBounds().x - deltaWidth)
- leftBounds.x) / leftBounds.width);
// complete the resize
sashInfo.leftNode->SetBounds(sashInfo.leftNode->GetBounds());
}
// next set the height
int deltaHeight = height - pane->GetBounds().height;
if (sashInfo.bottom != 0)
{
Rectangle bottomBounds = sashInfo.bottomNode->GetBounds();
// set the new ratio
sashInfo.bottom->SetRatio(static_cast<float>((deltaHeight + sashInfo.bottom->GetBounds().y)
- bottomBounds.y) / bottomBounds.height);
// complete the resize
sashInfo.bottomNode->SetBounds(bottomBounds);
}
else if (sashInfo.top != 0)
{
Rectangle topBounds = sashInfo.topNode->GetBounds();
// set the ratio
sashInfo.top->SetRatio(static_cast<float>((sashInfo.top->GetBounds().y - deltaHeight)
- topBounds.y) / topBounds.height);
// complete the resize
sashInfo.topNode->SetBounds(topBounds);
}
}
void WorkbenchPage::FindSashParts(LayoutTree::Pointer tree,
const PartPane::Sashes& sashes, SashInfo& info)
{
LayoutTree::Pointer parent(tree->GetParent());
if (parent == 0)
{
return;
}
if (parent->part.Cast<LayoutPartSash> () != 0)
{
// get the layout part sash from this tree node
LayoutPartSash::Pointer sash = parent->part.Cast<LayoutPartSash> ();
// make sure it has a sash control
void* control = sash->GetControl();
if (control != 0)
{
// check for a vertical sash
if (sash->IsVertical())
{
if (sashes.left == control)
{
info.left = sash;
info.leftNode = parent->FindSash(sash);
}
else if (sashes.right == control)
{
info.right = sash;
info.rightNode = parent->FindSash(sash);
}
}
// check for a horizontal sash
else
{
if (sashes.top == control)
{
info.top = sash;
info.topNode = parent->FindSash(sash);
}
else if (sashes.bottom == control)
{
info.bottom = sash;
info.bottomNode = parent->FindSash(sash);
}
}
}
}
// recursive call to continue up the tree
this->FindSashParts(parent, sashes, info);
}
std::vector<IWorkbenchPartReference::Pointer> WorkbenchPage::GetAllParts()
{
std::vector<IViewReference::Pointer> views = viewFactory->GetViews();
std::list<IEditorReference::Pointer> editors = this->GetEditorReferences();
std::vector<IWorkbenchPartReference::Pointer> result;
for (unsigned int i = 0; i < views.size(); i++)
{
result.push_back(views[i]);
}
for (std::list<IEditorReference::Pointer>::iterator iter = editors.begin(); iter
!= editors.end(); ++iter)
{
result.push_back(*iter);
}
return result;
}
std::vector<IWorkbenchPartReference::Pointer> WorkbenchPage::GetOpenParts()
{
std::vector<IWorkbenchPartReference::Pointer> refs = this->GetAllParts();
std::vector<IWorkbenchPartReference::Pointer> result;
for (unsigned int i = 0; i < refs.size(); i++)
{
IWorkbenchPartReference::Pointer reference = refs[i];
IWorkbenchPart::Pointer part = reference->GetPart(false);
if (part != 0)
{
result.push_back(reference);
}
}
return result;
}
void WorkbenchPage::TestInvariants()
{
Perspective::Pointer persp = this->GetActivePerspective();
if (persp != 0)
{
persp->TestInvariants();
// When we have widgets, ensure that there is no situation where the editor area is visible
// and the perspective doesn't want an editor area.
if (this->GetClientComposite()
&& editorPresentation->GetLayoutPart()->IsVisible())
{
poco_assert(persp->IsEditorAreaVisible());
}
}
}
/* (non-Javadoc)
* @see org.blueberry.ui.IWorkbenchPage#getExtensionTracker()
*/
// IExtensionTracker WorkbenchPage::GetExtensionTracker()
// {
// if (tracker == 0)
// {
// tracker = new UIExtensionTracker(getWorkbenchWindow().getWorkbench().getDisplay());
// }
// return tracker;
// }
/*
* (non-Javadoc)
*
* @see org.blueberry.ui.IWorkbenchPage#getPerspectiveShortcuts()
*/
std::vector<std::string> WorkbenchPage::GetPerspectiveShortcuts()
{
Perspective::Pointer persp = this->GetActivePerspective();
if (persp == 0)
{
return std::vector<std::string>();
}
return persp->GetPerspectiveShortcuts();
}
std::vector<std::string> WorkbenchPage::GetShowViewShortcuts()
{
Perspective::Pointer persp = this->GetActivePerspective();
if (persp == 0)
{
return std::vector<std::string>();
}
return persp->GetShowViewShortcuts();
}
void WorkbenchPage::SuggestReset()
{
IWorkbench* workbench = this->GetWorkbenchWindow()->GetWorkbench();
// workbench.getDisplay().asyncExec(new Runnable()
// {
// public void WorkbenchPage::run()
// {
Shell::Pointer parentShell;
IWorkbenchWindow::Pointer window = workbench->GetActiveWorkbenchWindow();
if (window == 0)
{
if (workbench->GetWorkbenchWindowCount() == 0)
{
return;
}
window = workbench->GetWorkbenchWindows()[0];
}
parentShell = window->GetShell();
if (MessageDialog::OpenQuestion(parentShell,
"Reset Perspective?",
"Changes to installed plug-ins have affected this perspective. Would you like to reset this perspective to accept these changes?"))
{
IWorkbenchPage::Pointer page = window->GetActivePage();
if (page == 0)
{
return;
}
page->ResetPerspective();
}
// }
// });
}
bool WorkbenchPage::IsPartVisible(
IWorkbenchPartReference::Pointer reference)
{
IWorkbenchPart::Pointer part = reference->GetPart(false);
// Can't be visible if it isn't created yet
if (part == 0)
{
return false;
}
return this->IsPartVisible(part);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchPage.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchPage.h
index 940a839bae..d8c948d082 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchPage.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchPage.h
@@ -1,1786 +1,1786 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYWORKBENCHPAGE_H_
#define BERRYWORKBENCHPAGE_H_
#include <berryIAdaptable.h>
#include <berryIExtensionPoint.h>
#include "berryIWorkbenchPage.h"
#include "berryIWorkbenchPartReference.h"
#include "berryIReusableEditor.h"
#include "berryIStackableContainer.h"
#include "berryIStickyViewManager.h"
#include "berryWorkbenchPagePartList.h"
#include "berryWorkbenchPartReference.h"
#include "berryPageSelectionService.h"
#include "berryEditorManager.h"
#include "berryViewFactory.h"
#include "berryPartPane.h"
#include <list>
namespace berry
{
//class PartPane;
//class PartPane::Sashes;
class EditorAreaHelper;
class WorkbenchWindow;
class Perspective;
class PerspectiveHelper;
class PerspectiveDescriptor;
class LayoutPartSash;
class LayoutTree;
class LayoutTreeNode;
class PartService;
/**
* \ingroup org_blueberry_ui_internal
*
* A collection of views and editors in a workbench.
*/
class BERRY_UI WorkbenchPage: public IWorkbenchPage
{
public:
berryObjectMacro(WorkbenchPage)
;
protected:
//TODO Weakpointer
WorkbenchWindow* window;
friend class ViewFactory;
friend class WorkbenchWindow;
friend class EditorAreaHelper;
friend class WWinPartService;
private:
/**
* Manages editor contributions and action set part associations.
*/
class ActionSwitcher
{
private:
IWorkbenchPart::WeakPtr activePart;
IEditorPart::WeakPtr topEditor;
/**
* Updates the contributions given the new part as the active part.
*
* @param newPart
* the new active part, may be <code>null</code>
*/
public:
void UpdateActivePart(IWorkbenchPart::Pointer newPart);
/**
* Updates the contributions given the new part as the topEditor.
*
* @param newEditor
* the new top editor, may be <code>null</code>
*/
public:
void UpdateTopEditor(IEditorPart::Pointer newEditor);
/**
* Activates the contributions of the given part. If <code>enable</code>
* is <code>true</code> the contributions are visible and enabled,
* otherwise they are disabled.
*
* @param part
* the part whose contributions are to be activated
* @param enable
* <code>true</code> the contributions are to be enabled,
* not just visible.
*/
private:
void ActivateContributions(IWorkbenchPart::Pointer part, bool enable);
/**
* Deactivates the contributions of the given part. If <code>remove</code>
* is <code>true</code> the contributions are removed, otherwise they
* are disabled.
*
* @param part
* the part whose contributions are to be deactivated
* @param remove
* <code>true</code> the contributions are to be removed,
* not just disabled.
*/
private:
void DeactivateContributions(IWorkbenchPart::Pointer part, bool remove);
};
class ActivationList
{
public:
//List of parts in the activation order (oldest first)
typedef std::deque<IWorkbenchPartReference::Pointer> PartListType;
typedef std::deque<IWorkbenchPartReference::Pointer>::iterator PartListIter;
typedef std::deque<IWorkbenchPartReference::Pointer>::reverse_iterator PartListReverseIter;
private:
PartListType parts;
WorkbenchPage* page;
public:
ActivationList(WorkbenchPage* page);
/*
* Add/Move the active part to end of the list;
*/
void SetActive(SmartPointer<IWorkbenchPart> part);
/*
* Ensures that the given part appears AFTER any other part in the same
* container.
*/
void BringToTop(SmartPointer<IWorkbenchPartReference> ref);
/*
* Returns the last (most recent) iterator (index) of the given container in the activation list, or returns
* end() if the given container does not appear in the activation list.
*/
PartListIter LastIndexOfContainer(SmartPointer<IStackableContainer> container);
/*
* Add/Move the active part to end of the list;
*/
void SetActive(SmartPointer<IWorkbenchPartReference> ref);
/*
* Add the active part to the beginning of the list.
*/
void Add(SmartPointer<IWorkbenchPartReference> ref);
/*
* Return the active part. Filter fast views.
*/
SmartPointer<IWorkbenchPart> GetActive();
/*
* Return the previously active part. Filter fast views.
*/
SmartPointer<IWorkbenchPart> GetPreviouslyActive();
SmartPointer<IWorkbenchPartReference> GetActiveReference(bool editorsOnly);
/*
* Retuns the index of the part within the activation list. The higher
* the index, the more recently it was used.
*/
PartListIter IndexOf(SmartPointer<IWorkbenchPart> part);
/*
* Returns the index of the part reference within the activation list.
* The higher the index, the more recent it was used.
*/
PartListIter IndexOf(SmartPointer<IWorkbenchPartReference> ref);
/*
* Remove a part from the list
*/
bool Remove(SmartPointer<IWorkbenchPartReference> ref);
/*
* Returns the topmost editor on the stack, or null if none.
*/
SmartPointer<IEditorPart> GetTopEditor();
/*
* Returns the editors in activation order (oldest first).
*/
std::vector<SmartPointer<IEditorReference> > GetEditors();
/*
* Return a list with all parts (editors and views).
*/
std::vector<SmartPointer<IWorkbenchPartReference> > GetParts();
private:
SmartPointer<IWorkbenchPart> GetActive(PartListIter start);
SmartPointer<IWorkbenchPartReference> GetActiveReference(PartListIter start, bool editorsOnly);
/*
* Find a part in the list starting from the end and filter
* and views from other perspectives. Will filter fast views
* unless 'includeActiveFastViews' is true;
*/
SmartPointer<IWorkbenchPartReference> GetActiveReference(PartListIter start, bool editorsOnly, bool skipPartsObscuredByZoom);
};
/**
* Helper class to keep track of all opened perspective. Both the opened
* and used order is kept.
*/
struct PerspectiveList
{
public:
typedef std::list<SmartPointer<Perspective> > PerspectiveListType;
typedef PerspectiveListType::iterator iterator;
private:
/**
* List of perspectives in the order they were opened;
*/
PerspectiveListType openedList;
/**
* List of perspectives in the order they were used. Last element is
* the most recently used, and first element is the least recently
* used.
*/
PerspectiveListType usedList;
/**
* The perspective explicitly set as being the active one
*/
SmartPointer<Perspective> active;
void UpdateActionSets(SmartPointer<Perspective> oldPersp,
SmartPointer<Perspective> newPersp);
public:
/**
* Creates an empty instance of the perspective list
*/
PerspectiveList();
/**
* Update the order of the perspectives in the opened list
*
* @param perspective
* @param newLoc
*/
void Reorder(IPerspectiveDescriptor::Pointer perspective, int newLoc);
/**
* Return all perspectives in the order they were activated.
*
* @return an array of perspectives sorted by activation order, least
* recently activated perspective last.
*/
PerspectiveListType GetSortedPerspectives();
/**
* Adds a perspective to the list. No check is done for a duplicate when
* adding.
* @param perspective the perspective to add
* @return boolean <code>true</code> if the perspective was added
*/
bool Add(SmartPointer<Perspective> perspective);
/**
* Returns an iterator on the perspective list in the order they were
* opened.
*/
PerspectiveListType::iterator Begin();
PerspectiveListType::iterator End();
/**
* Returns an array with all opened perspectives
*/
PerspectiveListType GetOpenedPerspectives();
/**
* Removes a perspective from the list.
*/
bool Remove(SmartPointer<Perspective> perspective);
/**
* Swap the opened order of old perspective with the new perspective.
*/
void Swap(SmartPointer<Perspective> oldPerspective,
SmartPointer<Perspective> newPerspective);
/**
* Returns whether the list contains any perspectives
*/
bool IsEmpty();
/**
* Returns the most recently used perspective in the list.
*/
SmartPointer<Perspective> GetActive();
/**
* Returns the next most recently used perspective in the list.
*/
SmartPointer<Perspective> GetNextActive();
/**
* Returns the number of perspectives opened
*/
PerspectiveListType::size_type Size();
/**
* Marks the specified perspective as the most recently used one in the
* list.
*/
void SetActive(SmartPointer<Perspective> perspective);
};
IAdaptable* input;
void* composite;
//Could be delete. This information is in the active part list;
ActivationList* activationList;
EditorManager* editorMgr;
EditorAreaHelper* editorPresentation;
//ListenerList propertyChangeListeners = new ListenerList();
PageSelectionService* selectionService;
WorkbenchPagePartList::Pointer partList; // = new WorkbenchPagePartList(selectionService);
//IActionBars actionBars;
ViewFactory* viewFactory;
PerspectiveList perspList;
SmartPointer<PerspectiveDescriptor> deferredActivePersp;
//NavigationHistory navigationHistory = new NavigationHistory(this);
IStickyViewManager::Pointer stickyViewMan;
/**
* If we're in the process of activating a part, this points to the new part.
* Otherwise, this is null.
*/
IWorkbenchPartReference::Pointer partBeingActivated;
/**
* Contains a list of perspectives that may be dirty due to plugin
* installation and removal.
*/
std::set<std::string> dirtyPerspectives;
ActionSwitcher actionSwitcher;
//IExtensionTracker tracker;
// Deferral count... delays disposing parts and sending certain events if nonzero
int deferCount;
// Parts waiting to be disposed
std::vector<WorkbenchPartReference::Pointer> pendingDisposals;
const IExtensionPoint* GetPerspectiveExtensionPoint();
public:
/**
* Constructs a new page with a given perspective and input.
*
* @param w
* the parent window
* @param layoutID
* must not be <code>null</code>
* @param input
* the page input
* @throws WorkbenchException
* on null layout id
*/
WorkbenchPage(WorkbenchWindow* w, const std::string& layoutID,
IAdaptable* input);
/**
* Constructs a page. <code>restoreState(IMemento)</code> should be
* called to restore this page from data stored in a persistance file.
*
* @param w
* the parent window
* @param input
* the page input
* @throws WorkbenchException
*/
WorkbenchPage(WorkbenchWindow* w, IAdaptable* input);
~WorkbenchPage();
/**
* Activates a part. The part will be brought to the front and given focus.
*
* @param part
* the part to activate
*/
void Activate(IWorkbenchPart::Pointer part);
/**
* Activates a part. The part is given focus, the pane is hilighted.
*/
private:
void ActivatePart(const IWorkbenchPart::Pointer part);
/**
* Adds an IPartListener to the part service.
*/
public:
void AddPartListener(IPartListener::Pointer l);
/*
* (non-Javadoc) Method declared on ISelectionListener.
*/
public:
void AddSelectionListener(ISelectionListener::Pointer listener);
/*
* (non-Javadoc) Method declared on ISelectionListener.
*/
public:
void AddSelectionListener(const std::string& partId,
ISelectionListener::Pointer listener);
/*
* (non-Javadoc) Method declared on ISelectionListener.
*/
public:
void AddPostSelectionListener(ISelectionListener::Pointer listener);
/*
* (non-Javadoc) Method declared on ISelectionListener.
*/
public:
void AddPostSelectionListener(const std::string& partId,
ISelectionListener::Pointer listener);
private:
IStackableContainer::Pointer GetContainer(IWorkbenchPart::Pointer part);
private:
IStackableContainer::Pointer GetContainer(IWorkbenchPartReference::Pointer part);
private:
SmartPointer<PartPane> GetPane(IWorkbenchPart::Pointer part);
private:
SmartPointer<PartPane> GetPane(IWorkbenchPartReference::Pointer part);
/**
* Brings a part to the front of its stack. Does not update the active part or
* active editor. This should only be called if the caller knows that the part
* is not in the same stack as the active part or active editor, or if the caller
* is prepared to update activation after the call.
*
* @param part
*/
private:
bool InternalBringToTop(IWorkbenchPartReference::Pointer part);
/**
* Moves a part forward in the Z order of a perspective so it is visible.
* If the part is in the same stack as the active part, the new part is
* activated.
*
* @param part
* the part to bring to move forward
*/
public:
void BringToTop(IWorkbenchPart::Pointer part);
/**
* Resets the layout for the perspective. The active part in the old layout
* is activated in the new layout for consistent user context.
*
* Assumes the busy cursor is active.
*/
private:
void BusyResetPerspective();
/**
* Implements <code>setPerspective</code>.
*
* Assumes that busy cursor is active.
*
* @param desc
* identifies the new perspective.
*/
private:
void BusySetPerspective(IPerspectiveDescriptor::Pointer desc);
/**
* Shows a view.
*
* Assumes that a busy cursor is active.
*/
protected:
IViewPart::Pointer BusyShowView(const std::string& viewID,
const std::string& secondaryID, int mode);
/*
* Performs showing of the view in the given mode.
*/
private:
void BusyShowView(IViewPart::Pointer part, int mode);
/**
* Returns whether a part exists in the current page.
*/
private:
bool CertifyPart(IWorkbenchPart::Pointer part);
/**
* Closes the perspective.
*/
public:
bool Close();
/**
* See IWorkbenchPage
*/
public:
bool CloseAllSavedEditors();
/**
* See IWorkbenchPage
*/
public:
bool CloseAllEditors(bool save);
private:
void UpdateActivePart();
/**
* Makes the given part active. Brings it in front if necessary. Permits null
* (indicating that no part should be active).
*
* @since 3.1
*
* @param ref new active part (or null)
*/
private:
void MakeActive(IWorkbenchPartReference::Pointer ref);
/**
* Makes the given editor active. Brings it to front if necessary. Permits <code>null</code>
* (indicating that no editor is active).
*
* @since 3.1
*
* @param ref the editor to make active, or <code>null</code> for no active editor
*/
private:
void MakeActiveEditor(IEditorReference::Pointer ref);
/**
* See IWorkbenchPage
*/
public:
bool CloseEditors(const std::list<IEditorReference::Pointer>& refArray,
bool save);
/**
* Enables or disables listener notifications. This is used to delay listener notifications until the
* end of a public method.
*
* @param shouldDefer
*/
private:
void DeferUpdates(bool shouldDefer);
private:
void StartDeferring();
private:
void HandleDeferredEvents();
private:
bool IsDeferred();
/**
* See IWorkbenchPage#closeEditor
*/
public:
bool CloseEditor(IEditorReference::Pointer editorRef, bool save);
/**
* See IWorkbenchPage#closeEditor
*/
public:
bool CloseEditor(IEditorPart::Pointer editor, bool save);
/**
* @see IWorkbenchPage#closePerspective(IPerspectiveDescriptor, boolean, boolean)
*/
public:
void ClosePerspective(IPerspectiveDescriptor::Pointer desc, bool saveParts,
bool closePage);
/**
* Closes the specified perspective. If last perspective, then entire page
* is closed.
*
* @param persp
* the perspective to be closed
* @param saveParts
* whether the parts that are being closed should be saved
* (editors if last perspective, views if not shown in other
* parspectives)
*/
/* package */
protected:
void ClosePerspective(SmartPointer<Perspective> persp, bool saveParts,
bool closePage);
/**
* @see IWorkbenchPage#closeAllPerspectives(boolean, boolean)
*/
public:
void CloseAllPerspectives(bool saveEditors, bool closePage);
/**
* Creates the client composite.
*/
private:
void CreateClientComposite();
/**
* Creates a new view set. Return null on failure.
*
* @param desc the perspective descriptor
* @param notify whether to fire a perspective opened event
*/
private:
SmartPointer<Perspective> CreatePerspective(SmartPointer<PerspectiveDescriptor> desc,
bool notify);
/**
* This is called by child objects after a part has been added to the page.
* The page will in turn notify its listeners.
*/
/* package */
protected:
void PartAdded(WorkbenchPartReference::Pointer ref);
/**
* This is called by child objects after a part has been added to the page.
* The part will be queued for disposal after all listeners have been notified
*/
/* package */
protected:
void PartRemoved(WorkbenchPartReference::Pointer ref);
private:
void DisposePart(WorkbenchPartReference::Pointer ref);
/**
* Deactivates a part. The pane is unhilighted.
*/
private:
void DeactivatePart(IWorkbenchPart::Pointer part);
/**
* Detaches a view from the WorkbenchWindow.
*/
public:
void DetachView(IViewReference::Pointer ref);
/**
* Removes a detachedwindow.
*/
public:
void AttachView(IViewReference::Pointer ref);
/**
* Dispose a perspective.
*
* @param persp the perspective descriptor
* @param notify whether to fire a perspective closed event
*/
private:
void DisposePerspective(SmartPointer<Perspective> persp, bool notify);
/**
* Returns the first view manager with given ID.
*/
public:
SmartPointer<Perspective> FindPerspective(IPerspectiveDescriptor::Pointer desc);
/**
* See IWorkbenchPage@findView.
*/
public:
IViewPart::Pointer FindView(const std::string& id);
/*
* (non-Javadoc)
*
* @see org.blueberry.ui.IWorkbenchPage
*/
public:
IViewReference::Pointer FindViewReference(const std::string& viewId);
/*
* (non-Javadoc)
*
* @see org.blueberry.ui.IWorkbenchPage
*/
public:
IViewReference::Pointer FindViewReference(const std::string& viewId,
const std::string& secondaryId);
/**
* Notify property change listeners about a property change.
*
* @param changeId
* the change id
* @param oldValue
* old property value
* @param newValue
* new property value
*/
//private: void FirePropertyChange(String changeId, Object oldValue,
// Object newValue) {
//
// UIListenerLogging.logPagePropertyChanged(this, changeId, oldValue, newValue);
//
// Object[] listeners = propertyChangeListeners.getListeners();
// PropertyChangeEvent event = new PropertyChangeEvent(this, changeId,
// oldValue, newValue);
//
// for (int i = 0; i < listeners.length; i++) {
// ((IPropertyChangeListener) listeners[i]).propertyChange(event);
// }
// }
/**
* @see IWorkbenchPage
*/
public:
IEditorPart::Pointer GetActiveEditor();
/**
* Returns the reference for the active editor, or <code>null</code>
* if there is no active editor.
*
* @return the active editor reference or <code>null</code>
*/
public:
IEditorReference::Pointer GetActiveEditorReference();
/*
* (non-Javadoc) Method declared on IPartService
*/
public:
IWorkbenchPart::Pointer GetActivePart();
/*
* (non-Javadoc) Method declared on IPartService
*/
public:
IWorkbenchPartReference::Pointer GetActivePartReference();
/**
* Returns the active perspective for the page, <code>null</code> if
* none.
*/
public:
SmartPointer<Perspective> GetActivePerspective();
/**
* Returns the client composite.
*/
public:
void* GetClientComposite();
// for dynamic UI - change access from private to protected
// for testing purposes only, changed from protected to public
/**
* Answer the editor manager for this window.
*/
public:
EditorManager* GetEditorManager();
/**
* Answer the perspective presentation.
*/
public:
PerspectiveHelper* GetPerspectivePresentation();
/**
* Answer the editor presentation.
*/
public:
EditorAreaHelper* GetEditorPresentation();
/**
* Allow access to the part service for this page ... used internally to
* propogate certain types of events to the page part listeners.
* @return the part service for this page.
*/
public: PartService* GetPartService();
/**
* See IWorkbenchPage.
*/
public:
std::vector<IEditorPart::Pointer> GetEditors();
public:
std::vector<IEditorPart::Pointer> GetDirtyEditors();
public:
std::vector<ISaveablePart::Pointer> GetDirtyParts();
/**
* See IWorkbenchPage.
*/
public:
IEditorPart::Pointer FindEditor(IEditorInput::Pointer input);
/**
* See IWorkbenchPage.
*/
public:
std::vector<IEditorReference::Pointer> FindEditors(
IEditorInput::Pointer input, const std::string& editorId, int matchFlags);
/**
* See IWorkbenchPage.
*/
public:
std::list<IEditorReference::Pointer> GetEditorReferences();
/**
* @see IWorkbenchPage
*/
public:
IAdaptable* GetInput();
/**
* Returns the page label. This is a combination of the page input and
* active perspective.
*/
public:
std::string GetLabel();
/**
* Returns the perspective.
*/
public:
IPerspectiveDescriptor::Pointer GetPerspective();
/*
* (non-Javadoc) Method declared on ISelectionService
*/
public:
ISelection::ConstPointer GetSelection() const;
/*
* (non-Javadoc) Method declared on ISelectionService
*/
public:
ISelection::ConstPointer GetSelection(const std::string& partId);
//public:
// SelectionEvents& GetSelectionEvents(const std::string& partId = "");
/*
* Returns the view factory.
*/
public:
ViewFactory* GetViewFactory();
/**
* See IWorkbenchPage.
*/
public:
std::vector<IViewReference::Pointer> GetViewReferences();
/**
* See IWorkbenchPage.
*/
public:
std::vector<IViewPart::Pointer> GetViews();
/**
* Returns all view parts in the specified perspective
*
* @param persp the perspective
* @return an array of view parts
* @since 3.1
*/
/*package*/
protected:
std::vector<IViewPart::Pointer> GetViews(SmartPointer<Perspective> persp,
bool restore);
/**
* See IWorkbenchPage.
*/
public:
IWorkbenchWindow::Pointer GetWorkbenchWindow();
/*
* (non-Javadoc)
*
* @see org.blueberry.ui.IWorkbenchPage#hideView(org.blueberry.ui.IViewReference)
*/
public:
void HideView(IViewReference::Pointer ref);
/* package */
protected:
void RefreshActiveView();
/**
* See IPerspective
*/
public:
void HideView(IViewPart::Pointer view);
/**
* Initialize the page.
*
* @param w
* the parent window
* @param layoutID
* may be <code>null</code> if restoring from file
* @param input
* the page input
* @param openExtras
* whether to process the perspective extras preference
*/
private:
void Init(WorkbenchWindow* w, const std::string& layoutID,
IAdaptable* input, bool openExtras);
/**
* Opens the perspectives specified in the PERSPECTIVE_BAR_EXTRAS preference (see bug 84226).
*/
public:
void OpenPerspectiveExtras();
/**
* See IWorkbenchPage.
*/
public:
bool IsPartVisible(IWorkbenchPart::Pointer part);
/**
* See IWorkbenchPage.
*/
public:
bool IsEditorAreaVisible();
/**
* Returns whether the view is fast.
*/
public:
bool IsFastView(IViewReference::Pointer ref);
/**
* Return whether the view is closeable or not.
*
* @param ref the view reference to check. Must not be <code>null</code>.
* @return true if the part is closeable.
* @since 3.1.1
*/
public:
bool IsCloseable(IViewReference::Pointer ref);
/**
* Return whether the view is moveable or not.
*
* @param ref the view reference to check. Must not be <code>null</code>.
* @return true if the part is moveable.
* @since 3.1.1
*/
public:
bool IsMoveable(IViewReference::Pointer ref);
/**
* Returns whether the layout of the active
* perspective is fixed.
*/
public:
bool IsFixedLayout();
/**
* Return true if the perspective has a dirty editor.
*/
protected:
bool IsSaveNeeded();
/**
* This method is called when the page is activated.
*/
protected:
void OnActivate();
/**
* This method is called when the page is deactivated.
*/
protected:
void OnDeactivate();
/**
* See IWorkbenchPage.
*/
public:
void
ReuseEditor(IReusableEditor::Pointer editor, IEditorInput::Pointer input);
/**
* See IWorkbenchPage.
*/
public:
IEditorPart::Pointer OpenEditor(IEditorInput::Pointer input,
const std::string& editorID);
/**
* See IWorkbenchPage.
*/
public:
IEditorPart::Pointer OpenEditor(IEditorInput::Pointer input,
const std::string& editorID, bool activate);
/**
* See IWorkbenchPage.
*/
public:
IEditorPart::Pointer OpenEditor(IEditorInput::Pointer input,
const std::string& editorID, bool activate, int matchFlags);
/**
* This is not public API but for use internally. editorState can be <code>null</code>.
*/
public:
IEditorPart::Pointer OpenEditor(IEditorInput::Pointer input,
const std::string& editorID, bool activate, int matchFlags,
IMemento::Pointer editorState);
/*
* Added to fix Bug 178235 [EditorMgmt] DBCS 3.3 - Cannot open file with external program.
* Opens a new editor using the given input and descriptor. (Normally, editors are opened using
* an editor ID and an input.)
*/
public:
IEditorPart::Pointer OpenEditorFromDescriptor(IEditorInput::Pointer input,
IEditorDescriptor::Pointer editorDescriptor, bool activate,
IMemento::Pointer editorState);
/**
* @see #openEditor(IEditorInput, String, boolean, int)
*/
private:
IEditorPart::Pointer BusyOpenEditor(IEditorInput::Pointer input,
const std::string& editorID, bool activate, int matchFlags,
IMemento::Pointer editorState);
/*
* Added to fix Bug 178235 [EditorMgmt] DBCS 3.3 - Cannot open file with external program.
* See openEditorFromDescriptor().
*/
private:
IEditorPart::Pointer BusyOpenEditorFromDescriptor(
IEditorInput::Pointer input,
EditorDescriptor::Pointer editorDescriptor, bool activate,
IMemento::Pointer editorState);
/**
* Do not call this method. Use <code>busyOpenEditor</code>.
*
* @see IWorkbenchPage#openEditor(IEditorInput, String, boolean)
*/
protected:
IEditorPart::Pointer BusyOpenEditorBatched(IEditorInput::Pointer input,
const std::string& editorID, bool activate, int matchFlags,
IMemento::Pointer editorState);
/*
* Added to fix Bug 178235 [EditorMgmt] DBCS 3.3 - Cannot open file with external program.
* See openEditorFromDescriptor().
*/
private:
IEditorPart::Pointer BusyOpenEditorFromDescriptorBatched(
IEditorInput::Pointer input, EditorDescriptor::Pointer editorDescriptor,
bool activate, IMemento::Pointer editorState);
public:
void OpenEmptyTab();
protected:
void ShowEditor(bool activate, IEditorPart::Pointer editor);
/**
* See IWorkbenchPage.
*/
public:
bool IsEditorPinned(IEditorPart::Pointer editor);
/**
* Removes an IPartListener from the part service.
*/
public:
void RemovePartListener(IPartListener::Pointer l);
/*
* (non-Javadoc) Method declared on ISelectionListener.
*/
public:
void RemoveSelectionListener(ISelectionListener::Pointer listener);
/*
* (non-Javadoc) Method declared on ISelectionListener.
*/
public:
void RemoveSelectionListener(const std::string& partId,
ISelectionListener::Pointer listener);
/*
* (non-Javadoc) Method declared on ISelectionListener.
*/
public:
void RemovePostSelectionListener(ISelectionListener::Pointer listener);
/*
* (non-Javadoc) Method declared on ISelectionListener.
*/
public:
void RemovePostSelectionListener(const std::string& partId,
ISelectionListener::Pointer listener);
/**
* This method is called when a part is activated by clicking within it. In
* response, the part, the pane, and all of its actions will be activated.
*
* In the current design this method is invoked by the part pane when the
* pane, the part, or any children gain focus.
*/
public:
void RequestActivation(IWorkbenchPart::Pointer part);
/**
* Resets the layout for the perspective. The active part in the old layout
* is activated in the new layout for consistent user context.
*/
public:
void ResetPerspective();
/**
* Restore this page from the memento and ensure that the active
* perspective is equals the active descriptor otherwise create a new
* perspective for that descriptor. If activeDescriptor is null active the
* old perspective.
*/
public:
/*IStatus*/bool RestoreState(IMemento::Pointer memento,
IPerspectiveDescriptor::Pointer activeDescriptor);
/**
* See IWorkbenchPage
*/
public:
bool SaveAllEditors(bool confirm);
/**
* @param confirm
* @param addNonPartSources true if saveables from non-part sources should be saved too
* @return false if the user cancelled
*
*/
public:
bool SaveAllEditors(bool confirm, bool addNonPartSources);
/*
* Saves the workbench part.
*/
protected:
bool SavePart(ISaveablePart::Pointer saveable, IWorkbenchPart::Pointer part,
bool confirm);
/**
* Saves an editors in the workbench. If <code>confirm</code> is <code>true</code>
* the user is prompted to confirm the command.
*
* @param confirm
* if user confirmation should be sought
* @return <code>true</code> if the command succeeded, or <code>false</code>
* if the user cancels the command
*/
public:
bool SaveEditor(IEditorPart::Pointer editor, bool confirm);
/**
* Saves the current perspective.
*/
public:
void SavePerspective();
/**
* Saves the perspective.
*/
public:
void SavePerspectiveAs(IPerspectiveDescriptor::Pointer newDesc);
/**
* Save the state of the page.
*/
public:
/*IStatus*/bool SaveState(IMemento::Pointer memento);
private:
std::string GetId(IWorkbenchPart::Pointer part);
private:
std::string GetId(IWorkbenchPartReference::Pointer ref);
/**
* Sets the active part.
*/
private:
void SetActivePart(IWorkbenchPart::Pointer newPart);
/**
* See IWorkbenchPage.
*/
public:
void SetEditorAreaVisible(bool showEditorArea);
/**
* Sets the layout of the page. Assumes the new perspective is not null.
* Keeps the active part if possible. Updates the window menubar and
* toolbar if necessary.
*/
private:
void SetPerspective(SmartPointer<Perspective> newPersp);
/*
* Update visibility state of all views.
*/
private:
void UpdateVisibility(SmartPointer<Perspective> oldPersp,
SmartPointer<Perspective> newPersp);
/**
* Sets the perspective.
*
* @param desc
* identifies the new perspective.
*/
public:
void SetPerspective(IPerspectiveDescriptor::Pointer desc);
/**
* Restore the toolbar layout for the active perspective.
*/
protected:
void ResetToolBarLayout();
/**
* See IWorkbenchPage.
*/
public:
IViewPart::Pointer ShowView(const std::string& viewID);
/*
* (non-Javadoc)
*
* @see org.blueberry.ui.IWorkbenchPage#showView(java.lang.String,
* java.lang.String, int)
*/
public:
IViewPart::Pointer ShowView(const std::string& viewID,
const std::string& secondaryID, int mode);
/**
* @param mode the mode to test
* @return whether the mode is recognized
* @since 3.0
*/
private:
bool CertifyMode(int mode);
/*
* Returns the editors in activation order (oldest first).
*/
public:
std::vector<IEditorReference::Pointer> GetSortedEditors();
/**
* @see IWorkbenchPage#getOpenPerspectives()
*/
public:
std::vector<IPerspectiveDescriptor::Pointer> GetOpenPerspectives();
/**
* Return all open Perspective objects.
*
* @return all open Perspective objects
* @since 3.1
*/
/*package*/
protected:
std::list<SmartPointer<Perspective> > GetOpenInternalPerspectives();
/**
* Checks perspectives in the order they were activiated
* for the specfied part. The first sorted perspective
* that contains the specified part is returned.
*
* @param part specified part to search for
* @return the first sorted perspespective containing the part
* @since 3.1
*/
/*package*/
protected:
SmartPointer<Perspective> GetFirstPerspectiveWithView(IViewPart::Pointer part);
/**
* Returns the perspectives in activation order (oldest first).
*/
public:
std::vector<IPerspectiveDescriptor::Pointer> GetSortedPerspectives();
/*
* Returns the parts in activation order (oldest first).
*/
public:
std::vector<IWorkbenchPartReference::Pointer> GetSortedParts();
/**
* Returns the reference to the given part, or <code>null</code> if it has no reference
* (i.e. it is not a top-level part in this workbench page).
*
* @param part the part
* @return the part's reference or <code>null</code> if the given part does not belong
* to this workbench page
*/
public:
IWorkbenchPartReference::Pointer GetReference(IWorkbenchPart::Pointer part);
// private: class ActivationList {
// //List of parts in the activation order (oldest first)
// List parts = new ArrayList();
//
// /*
// * Add/Move the active part to end of the list;
// */
// void setActive(IWorkbenchPart part) {
// if (parts.size() <= 0) {
// return;
// }
// IWorkbenchPartReference ref = getReference(part);
// if (ref != null) {
// if (ref == parts.get(parts.size() - 1)) {
// return;
// }
// parts.remove(ref);
// parts.add(ref);
// }
// }
//
// /*
// * Ensures that the given part appears AFTER any other part in the same
// * container.
// */
// void bringToTop(IWorkbenchPartReference ref) {
// ILayoutContainer targetContainer = getContainer(ref);
//
// int newIndex = lastIndexOfContainer(targetContainer);
//
// //New index can be -1 if there is no last index
// if (newIndex >= 0 && ref == parts.get(newIndex))
// return;
//
// parts.remove(ref);
// if(newIndex >= 0)
// parts.add(newIndex, ref);
// else
// parts.add(ref);
// }
//
// /*
// * Returns the last (most recent) index of the given container in the activation list, or returns
// * -1 if the given container does not appear in the activation list.
// */
// int lastIndexOfContainer(ILayoutContainer container) {
// for (int i = parts.size() - 1; i >= 0; i--) {
// IWorkbenchPartReference ref = (IWorkbenchPartReference)parts.get(i);
//
// ILayoutContainer cnt = getContainer(ref);
// if (cnt == container) {
// return i;
// }
// }
//
// return -1;
// }
//
// /*
// * Add/Move the active part to end of the list;
// */
// void setActive(IWorkbenchPartReference ref) {
// setActive(ref.getPart(true));
// }
//
// /*
// * Add the active part to the beginning of the list.
// */
// void add(IWorkbenchPartReference ref) {
// if (parts.indexOf(ref) >= 0) {
// return;
// }
//
// IWorkbenchPart part = ref.getPart(false);
// if (part != null) {
// PartPane pane = ((PartSite) part.getSite()).getPane();
// if (pane instanceof MultiEditorInnerPane) {
// MultiEditorInnerPane innerPane = (MultiEditorInnerPane) pane;
// add(innerPane.getParentPane().getPartReference());
// return;
// }
// }
// parts.add(0, ref);
// }
//
// /*
// * Return the active part. Filter fast views.
// */
// IWorkbenchPart getActive() {
// if (parts.isEmpty()) {
// return null;
// }
// return getActive(parts.size() - 1);
// }
//
// /*
// * Return the previously active part. Filter fast views.
// */
// IWorkbenchPart getPreviouslyActive() {
// if (parts.size() < 2) {
// return null;
// }
// return getActive(parts.size() - 2);
// }
//
// private: IWorkbenchPart getActive(int start) {
// IWorkbenchPartReference ref = getActiveReference(start, false);
//
// if (ref == null) {
// return null;
// }
//
// return ref.getPart(true);
// }
//
// public: IWorkbenchPartReference getActiveReference(boolean editorsOnly) {
// return getActiveReference(parts.size() - 1, editorsOnly);
// }
//
// private: IWorkbenchPartReference getActiveReference(int start, boolean editorsOnly) {
// // First look for parts that aren't obscured by the current zoom state
// IWorkbenchPartReference nonObscured = getActiveReference(start, editorsOnly, true);
//
// if (nonObscured != null) {
// return nonObscured;
// }
//
// // Now try all the rest of the parts
// return getActiveReference(start, editorsOnly, false);
// }
//
// /*
// * Find a part in the list starting from the end and filter
// * and views from other perspectives. Will filter fast views
// * unless 'includeActiveFastViews' is true;
// */
// private: IWorkbenchPartReference getActiveReference(int start, boolean editorsOnly, boolean skipPartsObscuredByZoom) {
// IWorkbenchPartReference[] views = getViewReferences();
// for (int i = start; i >= 0; i--) {
// WorkbenchPartReference ref = (WorkbenchPartReference) parts
// .get(i);
//
// if (editorsOnly && !(ref instanceof IEditorReference)) {
// continue;
// }
//
// // Skip parts whose containers have disabled auto-focus
// PartPane pane = ref.getPane();
//
// if (pane != null) {
// if (!pane.allowsAutoFocus()) {
// continue;
// }
//
// if (skipPartsObscuredByZoom) {
// if (pane.isObscuredByZoom()) {
// continue;
// }
// }
// }
//
// // Skip fastviews (unless overridden)
// if (ref instanceof IViewReference) {
// if (ref == getActiveFastView() || !((IViewReference) ref).isFastView()) {
// for (int j = 0; j < views.length; j++) {
// if (views[j] == ref) {
// return ref;
// }
// }
// }
// } else {
// return ref;
// }
// }
// return null;
// }
//
// /*
// * Retuns the index of the part within the activation list. The higher
// * the index, the more recently it was used.
// */
// int indexOf(IWorkbenchPart part) {
// IWorkbenchPartReference ref = getReference(part);
// if (ref == null) {
// return -1;
// }
// return parts.indexOf(ref);
// }
//
// /*
// * Returns the index of the part reference within the activation list.
// * The higher the index, the more recent it was used.
// */
// int indexOf(IWorkbenchPartReference ref) {
// return parts.indexOf(ref);
// }
//
// /*
// * Remove a part from the list
// */
// boolean remove(IWorkbenchPartReference ref) {
// return parts.remove(ref);
// }
//
// /*
// * Returns the editors in activation order (oldest first).
// */
// private: IEditorReference[] getEditors() {
// ArrayList editors = new ArrayList(parts.size());
// for (Iterator i = parts.iterator(); i.hasNext();) {
// IWorkbenchPartReference part = (IWorkbenchPartReference) i
// .next();
// if (part instanceof IEditorReference) {
// editors.add(part);
// }
// }
// return (IEditorReference[]) editors
// .toArray(new IEditorReference[editors.size()]);
// }
//
// /*
// * Return a list with all parts (editors and views).
// */
// private: IWorkbenchPartReference[] getParts() {
// IWorkbenchPartReference[] views = getViewReferences();
// ArrayList resultList = new ArrayList(parts.size());
// for (Iterator iterator = parts.iterator(); iterator.hasNext();) {
// IWorkbenchPartReference ref = (IWorkbenchPartReference) iterator
// .next();
// if (ref instanceof IViewReference) {
// //Filter views from other perspectives
// for (int i = 0; i < views.length; i++) {
// if (views[i] == ref) {
// resultList.add(ref);
// break;
// }
// }
// } else {
// resultList.add(ref);
// }
// }
// IWorkbenchPartReference[] result = new IWorkbenchPartReference[resultList
// .size()];
// return (IWorkbenchPartReference[]) resultList.toArray(result);
// }
//
// /*
// * Returns the topmost editor on the stack, or null if none.
// */
// IEditorPart getTopEditor() {
// IEditorReference editor = (IEditorReference)getActiveReference(parts.size() - 1, true);
//
// if (editor == null) {
// return null;
// }
//
// return editor.getEditor(true);
// }
// };
// for dynamic UI
protected:
void AddPerspective(SmartPointer<Perspective> persp);
/**
* Find the stack of view references stacked with this view part.
*
* @param part
* the part
* @return the stack of references
* @since 3.0
*/
private:
std::vector<IViewReference::Pointer> GetViewReferenceStack(
IViewPart::Pointer part);
/*
* (non-Javadoc)
*
* @see org.blueberry.ui.IWorkbenchPage#getViewStack(org.blueberry.ui.IViewPart)
*/
public:
std::vector<IViewPart::Pointer> GetViewStack(IViewPart::Pointer part);
/**
* Allow for programmatically resizing a part.
* <p>
* <em>EXPERIMENTAL</em>
* </p>
* <p>
* Known limitations:
* <ul>
* <li>currently applies only to views</li>
* <li>has no effect when view is zoomed</li>
* </ul>
*/
public:
void ResizeView(IViewPart::Pointer part, int width, int height);
private:
struct ActivationOrderPred : std::binary_function<IViewReference::Pointer,
IViewReference::Pointer, bool>
{
ActivationOrderPred(ActivationList* partList);
ActivationList* activationList;
bool operator()(const IViewReference::Pointer o1, const IViewReference::Pointer o2) const;
};
// provides sash information for the given pane
struct SashInfo
{
SmartPointer<LayoutPartSash> right;
SmartPointer<LayoutPartSash> left;
SmartPointer<LayoutPartSash> top;
SmartPointer<LayoutPartSash> bottom;
SmartPointer<LayoutTreeNode> rightNode;
SmartPointer<LayoutTreeNode> leftNode;
SmartPointer<LayoutTreeNode> topNode;
SmartPointer<LayoutTreeNode> bottomNode;
};
void FindSashParts(SmartPointer<LayoutTree> tree, const PartPane::Sashes& sashes,
SashInfo& info);
/**
* Returns all parts that are owned by this page
*
* @return
*/
protected:
std::vector<IWorkbenchPartReference::Pointer> GetAllParts();
/**
* Returns all open parts that are owned by this page (that is, all parts
* for which a part opened event would have been sent -- these would be
* activated parts whose controls have already been created.
*/
protected:
std::vector<IWorkbenchPartReference::Pointer> GetOpenParts();
/**
* Sanity-checks the objects in this page. Throws an Assertation exception
* if an object's internal state is invalid. ONLY INTENDED FOR USE IN THE
* UI TEST SUITES.
*/
public:
void TestInvariants();
/* (non-Javadoc)
* @see org.blueberry.ui.IWorkbenchPage#getExtensionTracker()
*/
//public: IExtensionTracker GetExtensionTracker();
/*
* (non-Javadoc)
*
* @see org.blueberry.ui.IWorkbenchPage#getPerspectiveShortcuts()
*/
public:
std::vector<std::string> GetPerspectiveShortcuts();
/*
* (non-Javadoc)
*
* @see org.blueberry.ui.IWorkbenchPage#getShowViewShortcuts()
*/
public:
std::vector<std::string> GetShowViewShortcuts();
/**
* @since 3.1
*/
private:
void SuggestReset();
public:
bool IsPartVisible(IWorkbenchPartReference::Pointer reference);
};
}
#endif /*BERRYWORKBENCHPAGE_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchPagePartList.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchPagePartList.cpp
index ac8628ae84..c4fe2837c7 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchPagePartList.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchPagePartList.cpp
@@ -1,97 +1,97 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryWorkbenchPagePartList.h"
#include "berryPartPane.h"
#include "berryImageDescriptor.h"
namespace berry
{
void WorkbenchPagePartList::FirePartOpened(IWorkbenchPartReference::Pointer part)
{
partService.FirePartOpened(part);
}
void WorkbenchPagePartList::FirePartClosed(IWorkbenchPartReference::Pointer part)
{
partService.FirePartClosed(part);
}
void WorkbenchPagePartList::FirePartAdded(IWorkbenchPartReference::Pointer /*part*/)
{
// TODO: There is no listener for workbench page additions yet
}
void WorkbenchPagePartList::FirePartRemoved(
IWorkbenchPartReference::Pointer /*part*/)
{
// TODO: There is no listener for workbench page removals yet
}
void WorkbenchPagePartList::FireActiveEditorChanged(
IWorkbenchPartReference::Pointer ref)
{
if (ref.IsNotNull())
{
this->FirePartBroughtToTop(ref);
}
}
void WorkbenchPagePartList::FireActivePartChanged(
IWorkbenchPartReference::Pointer /*oldRef*/,
IWorkbenchPartReference::Pointer newRef)
{
partService.SetActivePart(newRef);
IWorkbenchPart::Pointer realPart = newRef == 0 ? IWorkbenchPart::Pointer(0) : newRef->GetPart(false);
selectionService->SetActivePart(realPart);
}
void WorkbenchPagePartList::FirePartHidden(IWorkbenchPartReference::Pointer ref)
{
partService.FirePartHidden(ref);
}
void WorkbenchPagePartList::FirePartVisible(IWorkbenchPartReference::Pointer ref)
{
partService.FirePartVisible(ref);
}
void WorkbenchPagePartList::FirePartInputChanged(
IWorkbenchPartReference::Pointer ref)
{
partService.FirePartInputChanged(ref);
}
WorkbenchPagePartList::WorkbenchPagePartList(PageSelectionService* selService) :
selectionService(selService), partService("", "")
{
}
IPartService* WorkbenchPagePartList::GetPartService()
{
return &partService;
}
void WorkbenchPagePartList::FirePartBroughtToTop(
IWorkbenchPartReference::Pointer ref)
{
partService.FirePartBroughtToTop(ref);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchPagePartList.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchPagePartList.h
index b8a49eb4a1..49ab7ea72a 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchPagePartList.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchPagePartList.h
@@ -1,80 +1,80 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYWORKBENCHPAGEPARTLIST_H_
#define BERRYWORKBENCHPAGEPARTLIST_H_
#include <berrySmartPointer.h>
#include "berryPartList.h"
#include "berryPartService.h"
#include "berryPageSelectionService.h"
namespace berry
{
/**
* \ingroup org_blueberry_ui_internal
*
*/
class WorkbenchPagePartList : public PartList
{
public:
berryObjectMacro(WorkbenchPagePartList);
private:
PageSelectionService* selectionService;
PartService partService; // = new PartService(UIListenerLogging.PAGE_PARTLISTENER_EVENTS,
//UIListenerLogging.PAGE_PARTLISTENER2_EVENTS);
protected:
void FirePartOpened(IWorkbenchPartReference::Pointer part);
void FirePartClosed(IWorkbenchPartReference::Pointer part);
void FirePartAdded(IWorkbenchPartReference::Pointer part);
void FirePartRemoved(IWorkbenchPartReference::Pointer part);
void FireActiveEditorChanged(IWorkbenchPartReference::Pointer ref);
void FireActivePartChanged(IWorkbenchPartReference::Pointer oldRef,
IWorkbenchPartReference::Pointer newRef);
void FirePartHidden(IWorkbenchPartReference::Pointer ref);
void FirePartVisible(IWorkbenchPartReference::Pointer ref);
void FirePartInputChanged(IWorkbenchPartReference::Pointer ref);
public:
WorkbenchPagePartList(PageSelectionService* selectionService);
IPartService* GetPartService();
void FirePartBroughtToTop(IWorkbenchPartReference::Pointer ref);
};
}
#endif /*BERRYWORKBENCHPAGEPARTLIST_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchPartReference.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchPartReference.cpp
index 22dec84654..ffbd05923b 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchPartReference.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchPartReference.cpp
@@ -1,716 +1,716 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryWorkbenchPartReference.h"
#include <berryPlatformException.h>
#include <berryObjects.h>
#include "berryWorkbenchPlugin.h"
#include "berryUtil.h"
#include "berryPartPane.h"
#include "berryIWorkbenchPartSite.h"
#include "berryIEditorPart.h"
#include "berryIWorkbenchPartConstants.h"
#include "berryImageDescriptor.h"
namespace berry
{
int WorkbenchPartReference::STATE_LAZY = 0;
int WorkbenchPartReference::STATE_CREATION_IN_PROGRESS = 1;
int WorkbenchPartReference::STATE_CREATED = 2;
int WorkbenchPartReference::STATE_DISPOSED = 3;
WorkbenchPartReference::PropertyChangeListener::PropertyChangeListener(
WorkbenchPartReference* ref) :
partRef(ref)
{
}
void WorkbenchPartReference::PropertyChangeListener::PropertyChange(
PropertyChangeEvent::Pointer event)
{
if (event->GetProperty() == IWorkbenchPartConstants::INTEGER_PROPERTY)
{
partRef->PropertyChanged(event->GetSource(), event->GetNewValue().Cast<ObjectInt>()->GetValue());
}
else
{
partRef->PropertyChanged(event);
}
}
WorkbenchPartReference::WorkbenchPartReference() :
state(STATE_LAZY), pinned(false), image(0)
{
propertyChangeListener = new PropertyChangeListener(this);
}
WorkbenchPartReference::~WorkbenchPartReference()
{
this->Register();
part = 0;
pane = 0;
this->UnRegister(false);
}
bool WorkbenchPartReference::IsDisposed() const
{
return state == STATE_DISPOSED;
}
void WorkbenchPartReference::CheckReference()
{
if (state == STATE_DISPOSED)
{
throw Poco::RuntimeException("Error: IWorkbenchPartReference disposed"); //$NON-NLS-1$
}
}
/**
* Calling this with deferEvents(true) will queue all property change events until a subsequent
* call to deferEvents(false). This should be used at the beginning of a batch of related changes
* to prevent duplicate property change events from being sent.
*
* @param shouldQueue
*/
//void WorkbenchPartReference::DeferEvents(bool shouldQueue) {
// queueEvents = shouldQueue;
//
// if (queueEvents == false) {
// // do not use nextSetBit, to allow compilation against JCL Foundation (bug 80053)
// for (int i = 0, n = queuedEvents.size(); i < n; ++i) {
// if (queuedEvents.get(i)) {
// firePropertyChange(i);
// queuedEvents.clear(i);
// }
// }
// }
// }
void WorkbenchPartReference::SetPartName(const std::string& newPartName)
{
if (partName == newPartName)
{
return;
}
partName = newPartName;
this->FirePropertyChange(IWorkbenchPartConstants::PROP_PART_NAME);
}
void WorkbenchPartReference::SetContentDescription(
const std::string& newContentDescription)
{
if (contentDescription == newContentDescription)
{
return;
}
contentDescription = newContentDescription;
this->FirePropertyChange(IWorkbenchPartConstants::PROP_CONTENT_DESCRIPTION);
}
void WorkbenchPartReference::SetImageDescriptor(
ImageDescriptor::Pointer descriptor)
{
if (imageDescriptor == descriptor)
{
return;
}
void* oldImage = image;
ImageDescriptor::Pointer oldDescriptor = imageDescriptor;
image = 0;
imageDescriptor = descriptor;
// Don't queue events triggered by image changes. We'll dispose the image
// immediately after firing the event, so we need to fire it right away.
this->ImmediateFirePropertyChange(IWorkbenchPartConstants::PROP_TITLE);
if (queueEvents)
{
// If there's a PROP_TITLE event queued, remove it from the queue because
// we've just fired it.
queuedEvents.erase(IWorkbenchPartConstants::PROP_TITLE);
}
// If we had allocated the old image, deallocate it now (AFTER we fire the property change
// -- listeners may need to clean up references to the old image)
if (oldImage && oldDescriptor)
{
//JFaceResources.getResources().destroy(oldDescriptor);
oldDescriptor->DestroyImage(oldImage);
}
}
void WorkbenchPartReference::SetToolTip(const std::string& newToolTip)
{
if (tooltip == newToolTip)
{
return;
}
tooltip = newToolTip;
this->FirePropertyChange(IWorkbenchPartConstants::PROP_TITLE);
}
void WorkbenchPartReference::PropertyChanged(Object::Pointer /*source*/, int propId)
{
// We handle these properties directly (some of them may be transformed
// before firing events to workbench listeners)
if (propId == IWorkbenchPartConstants::PROP_CONTENT_DESCRIPTION || propId
== IWorkbenchPartConstants::PROP_PART_NAME || propId
== IWorkbenchPartConstants::PROP_TITLE)
{
this->RefreshFromPart();
}
else
{
// Any other properties are just reported to listeners verbatim
this->FirePropertyChange(propId);
}
// Let the model manager know as well
// if (propId == IWorkbenchPartConstants::PROP_DIRTY) {
// IWorkbenchPart actualPart = getPart(false);
// if (actualPart != null) {
// SaveablesList modelManager = (SaveablesList) actualPart.getSite().getService(ISaveablesLifecycleListener.class);
// modelManager.dirtyChanged(actualPart);
// }
// }
}
void WorkbenchPartReference::PropertyChanged(PropertyChangeEvent::Pointer event)
{
this->FirePropertyChange(event);
}
/**
* Refreshes all cached values with the values from the real part
*/
void WorkbenchPartReference::RefreshFromPart()
{
this->DeferEvents(true);
SetPartName(ComputePartName());
SetContentDescription(ComputeContentDescription());
SetToolTip(GetRawToolTip());
//SetImageDescriptor(ComputeImageDescriptor());
this->DeferEvents(false);
}
ImageDescriptor::Pointer WorkbenchPartReference::ComputeImageDescriptor()
{
if (part)
{
return ImageDescriptor::CreateFromImage(part->GetTitleImage());
}
return defaultImageDescriptor;
}
void WorkbenchPartReference::Init(const std::string& id,
const std::string& tooltip, ImageDescriptor::Pointer desc,
const std::string& paneName, const std::string& contentDescription)
{
this->id = id;
this->tooltip = tooltip;
this->partName = paneName;
this->contentDescription = contentDescription;
this->defaultImageDescriptor = desc;
this->imageDescriptor = this->ComputeImageDescriptor();
}
/**
* @see IWorkbenchPart
*/
void WorkbenchPartReference::AddPropertyListener(
IPropertyChangeListener::Pointer listener)
{
propChangeEvents.AddListener(listener);
}
/**
* @see IWorkbenchPart
*/
void WorkbenchPartReference::RemovePropertyListener(
IPropertyChangeListener::Pointer listener)
{
propChangeEvents.RemoveListener(listener);
}
std::string WorkbenchPartReference::GetId() const
{
if (!part.IsNull())
{
IWorkbenchPartSite::Pointer site = part->GetSite();
if (!site.IsNull())
{
return site->GetId();
}
}
return id;
}
std::string WorkbenchPartReference::GetTitleToolTip() const
{
return tooltip;
}
std::string WorkbenchPartReference::GetRawToolTip() const
{
return part->GetTitleToolTip();
}
/**
* Returns the pane name for the part
*
* @return the pane name for the part
*/
std::string WorkbenchPartReference::GetPartName() const
{
return partName;
}
/**
* Gets the part name directly from the associated workbench part,
* or the empty string if none.
*
* @return
*/
std::string WorkbenchPartReference::GetRawPartName() const
{
return part->GetPartName();
}
std::string WorkbenchPartReference::ComputePartName() const
{
return this->GetRawPartName();
}
/**
* Returns the content description for this part.
*
* @return the pane name for the part
*/
std::string WorkbenchPartReference::GetContentDescription() const
{
return contentDescription;
}
/**
* Computes a new content description for the part. Subclasses may override to change the
* default behavior
*
* @return the new content description for the part
*/
std::string WorkbenchPartReference::ComputeContentDescription() const
{
return this->GetRawContentDescription();
}
/**
* Returns the content description as set directly by the part, or the empty string if none
*
* @return the unmodified content description from the part (or the empty string if none)
*/
std::string WorkbenchPartReference::GetRawContentDescription() const
{
return part->GetContentDescription();
}
bool WorkbenchPartReference::IsDirty() const
{
if (part.Cast<IEditorPart> ().IsNull())
{
return false;
}
return part.Cast<IEditorPart> ()->IsDirty();
}
void* WorkbenchPartReference::GetTitleImage()
{
if (this->IsDisposed())
{
//return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_DEF_VIEW);
return 0;
}
if (!image && imageDescriptor)
{
//image = JFaceResources.getResources().createImageWithDefault(imageDescriptor);
image = imageDescriptor->CreateImage();
}
return image;
}
ImageDescriptor::Pointer WorkbenchPartReference::GetTitleImageDescriptor() const
{
if (this->IsDisposed())
{
//return PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_DEF_VIEW);
return ImageDescriptor::Pointer(0);
}
return imageDescriptor;
}
void WorkbenchPartReference::FireVisibilityChange()
{
this->FirePropertyChange(IWorkbenchPartConstants::PROP_VISIBLE);
}
// /* package */ void fireZoomChange() {
// fireInternalPropertyChange(INTERNAL_PROPERTY_ZOOMED);
// }
bool WorkbenchPartReference::GetVisible()
{
if (this->IsDisposed())
{
return false;
}
return this->GetPane()->GetVisible();
}
void WorkbenchPartReference::SetVisible(bool isVisible)
{
if (this->IsDisposed())
{
return;
}
this->GetPane()->SetVisible(isVisible);
}
void WorkbenchPartReference::DeferEvents(bool shouldQueue)
{
queueEvents = shouldQueue;
if (queueEvents == false)
{
std::set<int>::iterator iter = queuedEvents.begin();
while (iter != queuedEvents.end())
{
this->FirePropertyChange(*iter);
queuedEvents.erase(iter++);
}
}
}
void WorkbenchPartReference::FirePropertyChange(int id)
{
if (queueEvents)
{
queuedEvents.insert(id);
return;
}
this->ImmediateFirePropertyChange(id);
}
void WorkbenchPartReference::ImmediateFirePropertyChange(int id)
{
//UIListenerLogging.logPartReferencePropertyChange(this, id);
ObjectInt::Pointer value(new ObjectInt(id));
Object::Pointer source(this);
PropertyChangeEvent::Pointer
event(
new PropertyChangeEvent(source, IWorkbenchPartConstants::INTEGER_PROPERTY, value, value));
propChangeEvents.propertyChange(event);
}
IWorkbenchPart::Pointer WorkbenchPartReference::GetPart(bool restore)
{
if (this->IsDisposed())
{
return IWorkbenchPart::Pointer(0);
}
if (part.IsNull() && restore)
{
if (state == STATE_CREATION_IN_PROGRESS)
{
// IStatus result = WorkbenchPlugin.getStatus(
// new PartInitException(NLS.bind("Warning: Detected recursive attempt by part {0} to create itself (this is probably, but not necessarily, a bug)", //$NON-NLS-1$
// getId())));
WorkbenchPlugin::Log("Warning: Detected recursive attempt by part "
+ GetId()
+ " to create itself (this is probably, but not necessarily, a bug)");
return IWorkbenchPart::Pointer(0);
}
try
{
state = STATE_CREATION_IN_PROGRESS;
IWorkbenchPart::Pointer newPart = this->CreatePart();
if (!newPart.IsNull())
{
part = newPart;
// Add a dispose listener to the part. This dispose listener does nothing but log an exception
// if the part's widgets get disposed unexpectedly. The workbench part reference is the only
// object that should dispose this control, and it will remove the listener before it does so.
//this->GetPane().getControl().addDisposeListener(prematureDisposeListener);
part->AddPropertyListener(propertyChangeListener);
this->RefreshFromPart();
this->FirePropertyChange(IWorkbenchPartConstants::PROP_OPENED);
//ISizeProvider sizeProvider = (ISizeProvider) Util.getAdapter(part, ISizeProvider.class);
//if (sizeProvider != null) {
// If this part has a preferred size, indicate that the preferred size may have changed at this point
if (this->GetSizeFlags(true) != 0 || this->GetSizeFlags(false) != 0)
{
this->FirePropertyChange(IWorkbenchPartConstants::PROP_PREFERRED_SIZE);
}
//}
}
state = STATE_CREATED;
} catch (Poco::Exception& e)
{
state = STATE_CREATED;
std::cerr << e.displayText() << std::flush;
throw e;
} catch (std::exception& e)
{
state = STATE_CREATED;
throw e;
}
}
return part;
}
/**
* Returns the part pane for this part reference. Does not return null. Should not be called
* if the reference has been disposed.
*
* TODO: clean up all code that has any possibility of calling this on a disposed reference
* and make this method throw an exception if anyone else attempts to do so.
*
* @return
*/
PartPane::Pointer WorkbenchPartReference::GetPane()
{
// Note: we should never call this if the reference has already been disposed, since it
// may cause a PartPane to be created and leaked.
if (pane.IsNull())
{
pane = this->CreatePane();
}
return pane;
}
void WorkbenchPartReference::Dispose()
{
if (this->IsDisposed())
{
return;
}
// Store the current title, tooltip, etc. so that anyone that they can be returned to
// anyone that held on to the disposed reference.
partName = GetPartName();
contentDescription = GetContentDescription();
tooltip = GetTitleToolTip();
if (state == STATE_CREATION_IN_PROGRESS)
{
// IStatus result = WorkbenchPlugin.getStatus(
// new PartInitException(NLS.bind("Warning: Blocked recursive attempt by part {0} to dispose itself during creation", //$NON-NLS-1$
// getId())));
WorkbenchPlugin::Log("Warning: Blocked recursive attempt by part" + GetId()
+ " to dispose itself during creation");
return;
}
// Disposing the pane disposes the part's widgets. The part's widgets need to be disposed before the part itself.
// if (pane != 0) {
// // Remove the dispose listener since this is the correct place for the widgets to get disposed
// Control targetControl = getPane().getControl();
// if (targetControl != null) {
// targetControl.removeDisposeListener(prematureDisposeListener);
// }
// pane->Dispose();
// }
this->DoDisposePart();
if (!pane.IsNull())
{
//pane.removeContributions();
}
//clearListenerList(internalPropChangeListeners);
//clearListenerList(partChangeListeners);
void* oldImage = image;
ImageDescriptor::Pointer oldDescriptor = imageDescriptor;
image = 0;
state = STATE_DISPOSED;
imageDescriptor = ImageDescriptor::GetMissingImageDescriptor();
defaultImageDescriptor = ImageDescriptor::GetMissingImageDescriptor();
this->ImmediateFirePropertyChange(IWorkbenchPartConstants::PROP_TITLE);
//clearListenerList(propChangeListeners);
if (oldImage)
{
//JFaceResources.getResources().destroy(oldDescriptor);
oldDescriptor->DestroyImage(oldImage);
}
pane = 0;
}
void WorkbenchPartReference::DoDisposePart()
{
if (part)
{
//this->FireInternalPropertyChange(INTERNAL_PROPERTY_CLOSED);
this->FirePropertyChange(IWorkbenchPartConstants::PROP_CLOSED);
// Don't let exceptions in client code bring us down. Log them and continue.
try
{
part->RemovePropertyListener(propertyChangeListener);
// if (part instanceof IWorkbenchPart3)
// {
// ((IWorkbenchPart3) part).removePartPropertyListener(
// partPropertyChangeListener);
// }
// part->Dispose();
part = 0;
} catch (const Poco::RuntimeException& e)
{
WorkbenchPlugin::Log(e);
}
catch (const std::exception& e)
{
std::string msg("Exception in WorkbenchPartReference::DoDisposePart: ");
msg.append(e.what());
WorkbenchPlugin::Log(msg);
}
part = 0;
}
}
/**
* Clears all of the listeners in a listener list. TODO Bug 117519 Remove
* this method when fixed.
*
* @param list
* The list to be clear; must not be <code>null</code>.
*/
//private: void clearListenerList(const ListenerList list) {
// final Object[] listeners = list.getListeners();
// for (int i = 0; i < listeners.length; i++) {
// list.remove(listeners[i]);
// }
// }
void WorkbenchPartReference::SetPinned(bool newPinned)
{
if (IsDisposed())
{
return;
}
if (newPinned == pinned)
{
return;
}
pinned = newPinned;
//SetImageDescriptor(computeImageDescriptor());
this->FirePropertyChange(IWorkbenchPartConstants::PROP_PINNED);
}
bool WorkbenchPartReference::IsPinned() const
{
return pinned;
}
std::string WorkbenchPartReference::GetPartProperty(const std::string& key) const
{
if (part != 0)
{
return part->GetPartProperty(key);
}
else
{
std::map<std::string, std::string>::const_iterator itr =
propertyCache.find(key);
if (itr == propertyCache.end())
return "";
return itr->second;
}
}
void WorkbenchPartReference::FirePropertyChange(
PropertyChangeEvent::Pointer event)
{
propChangeEvents.propertyChange(event);
}
void WorkbenchPartReference::CreatePartProperties(
IWorkbenchPart::Pointer workbenchPart)
{
for (std::map<std::string, std::string>::iterator iter =
propertyCache.begin(); iter != propertyCache.end(); ++iter)
{
workbenchPart->SetPartProperty(iter->first, iter->second);
}
}
int WorkbenchPartReference::ComputePreferredSize(bool width,
int availableParallel, int availablePerpendicular, int preferredResult)
{
ISizeProvider* sizeProvider = Util::GetAdapter<ISizeProvider>(part);
if (sizeProvider)
{
return sizeProvider->ComputePreferredSize(width, availableParallel,
availablePerpendicular, preferredResult);
}
return preferredResult;
}
int WorkbenchPartReference::GetSizeFlags(bool width)
{
ISizeProvider* sizeProvider = Util::GetAdapter<ISizeProvider>(part);
if (sizeProvider)
{
return sizeProvider->GetSizeFlags(width);
}
return 0;
}
} // namespace berry
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchPartReference.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchPartReference.h
index aced5b09e7..1696d1357a 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchPartReference.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchPartReference.h
@@ -1,303 +1,303 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYWORKBENCHPARTREFERENCE_H_
#define BERRYWORKBENCHPARTREFERENCE_H_
#include <berryMessage.h>
#include "berryISizeProvider.h"
#include "berryIWorkbenchPartReference.h"
#include "berryIWorkbenchPart.h"
#include <set>
//TODO should be removed
#include <org_blueberry_ui_Export.h>
#include "berryImageDescriptor.h"
namespace berry {
class PartPane;
/**
* \ingroup org_blueberry_ui_internal
*
*/
class BERRY_UI WorkbenchPartReference : virtual public IWorkbenchPartReference, public ISizeProvider {
public: berryObjectMacro(WorkbenchPartReference);
// State constants //////////////////////////////
/**
* State constant indicating that the part is not created yet
*/
public: static int STATE_LAZY; // = 0
/**
* State constant indicating that the part is in the process of being created
*/
public: static int STATE_CREATION_IN_PROGRESS; // = 1
/**
* State constant indicating that the part has been created
*/
public: static int STATE_CREATED; // = 2
/**
* State constant indicating that the reference has been disposed (the reference shouldn't be
* used anymore)
*/
public: static int STATE_DISPOSED; // = 3
/**
* Current state of the reference. Used to detect recursive creation errors, disposed
* references, etc.
*/
private: int state;
protected: IWorkbenchPart::Pointer part;
protected: SmartPointer<PartPane> pane;
private: std::string id;
private: bool pinned;
private: std::string tooltip;
/**
* Stores the current Image for this part reference. Lazily created. Null if not allocated.
*/
private: void* image;
private: SmartPointer<ImageDescriptor> defaultImageDescriptor;
/**
* Stores the current image descriptor for the part.
*/
private: SmartPointer<ImageDescriptor> imageDescriptor;
/**
* API listener list
*/
private: IPropertyChangeListener::Events propChangeEvents;
//private: ListenerList partChangeListeners = new ListenerList();
private: std::string partName;
private: std::string contentDescription;
protected: std::map<std::string, std::string> propertyCache;
/**
* Used to remember which events have been queued.
*/
private: std::set<int> queuedEvents;
private: bool queueEvents;
//private: static DisposeListener prematureDisposeListener = new DisposeListener() {
// public void widgetDisposed(DisposeEvent e) {
// WorkbenchPlugin.log(new RuntimeException("Widget disposed too early!")); //$NON-NLS-1$
// }
// };
private: struct PropertyChangeListener : public IPropertyChangeListener
{
PropertyChangeListener(WorkbenchPartReference* ref);
void PropertyChange(PropertyChangeEvent::Pointer event);
private: WorkbenchPartReference* partRef;
};
private: IPropertyChangeListener::Pointer propertyChangeListener;
/**
* Calling this with deferEvents(true) will queue all property change events until a subsequent
* call to deferEvents(false). This should be used at the beginning of a batch of related changes
* to prevent duplicate property change events from being sent.
*
* @param shouldQueue
*/
private: void DeferEvents(bool shouldQueue);
public: WorkbenchPartReference();
public: ~WorkbenchPartReference();
public: virtual bool IsDisposed() const;
protected: virtual void CheckReference();
/**
* Calling this with deferEvents(true) will queue all property change events until a subsequent
* call to deferEvents(false). This should be used at the beginning of a batch of related changes
* to prevent duplicate property change events from being sent.
*
* @param shouldQueue
*/
//private: virtual void DeferEvents(bool shouldQueue);
protected: virtual void SetPartName(const std::string& newPartName);
protected: virtual void SetContentDescription(const std::string& newContentDescription);
protected: virtual void SetImageDescriptor(SmartPointer<ImageDescriptor> descriptor);
protected: virtual void SetToolTip(const std::string& newToolTip);
protected: virtual void PropertyChanged(Object::Pointer source, int propId);
protected: virtual void PropertyChanged(PropertyChangeEvent::Pointer event);
/**
* Refreshes all cached values with the values from the real part
*/
protected: virtual void RefreshFromPart();
protected: virtual SmartPointer<ImageDescriptor> ComputeImageDescriptor();
public: virtual void Init(const std::string& id, const std::string& tooltip,
SmartPointer<ImageDescriptor> desc, const std::string& paneName, const std::string& contentDescription);
/**
* @see IWorkbenchPart
*/
public: virtual void AddPropertyListener(IPropertyChangeListener::Pointer listener);
/**
* @see IWorkbenchPart
*/
public: virtual void RemovePropertyListener(IPropertyChangeListener::Pointer listener);
public: std::string GetId() const;
public: virtual std::string GetTitleToolTip() const;
protected: std::string GetRawToolTip() const;
/**
* Returns the pane name for the part
*
* @return the pane name for the part
*/
public: virtual std::string GetPartName() const;
/**
* Gets the part name directly from the associated workbench part,
* or the empty string if none.
*
* @return
*/
protected: std::string GetRawPartName() const;
protected: virtual std::string ComputePartName() const;
/**
* Returns the content description for this part.
*
* @return the pane name for the part
*/
public: virtual std::string GetContentDescription() const;
/**
* Computes a new content description for the part. Subclasses may override to change the
* default behavior
*
* @return the new content description for the part
*/
protected: virtual std::string ComputeContentDescription() const;
/**
* Returns the content description as set directly by the part, or the empty string if none
*
* @return the unmodified content description from the part (or the empty string if none)
*/
protected: std::string GetRawContentDescription() const;
public: virtual bool IsDirty() const;
public: virtual void* GetTitleImage();
public: virtual SmartPointer<ImageDescriptor> GetTitleImageDescriptor() const;
public: virtual void FireVisibilityChange();
// /* package */ virtual void fireZoomChange();
public: virtual bool GetVisible();
public: virtual void SetVisible(bool isVisible);
protected: virtual void FirePropertyChange(int id);
private: void ImmediateFirePropertyChange(int id);
public: IWorkbenchPart::Pointer GetPart(bool restore);
protected: virtual IWorkbenchPart::Pointer CreatePart() = 0;
protected: virtual SmartPointer<PartPane> CreatePane() = 0;
/**
* Returns the part pane for this part reference. Does not return null.
*
* @return
*/
public: SmartPointer<PartPane> GetPane();
public: void Dispose();
/**
* Clears all of the listeners in a listener list. TODO Bug 117519 Remove
* this method when fixed.
*
* @param list
* The list to be clear; must not be <code>null</code>.
*/
//private: void clearListenerList(const ListenerList list);
public: virtual void SetPinned(bool newPinned);
public: virtual bool IsPinned() const;
protected: void DoDisposePart();
/* (non-Javadoc)
* @see org.blueberry.ui.IWorkbenchPartReference#getPartProperty(java.lang.String)
*/
public: virtual std::string GetPartProperty(const std::string& key) const;
protected: virtual void FirePropertyChange(PropertyChangeEvent::Pointer event);
protected: virtual void CreatePartProperties(IWorkbenchPart::Pointer workbenchPart);
public: int ComputePreferredSize(bool width, int availableParallel,
int availablePerpendicular, int preferredResult);
public: int GetSizeFlags(bool width);
};
} // namespace berry
#endif /*BERRYWORKBENCHPARTREFERENCE_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchPlugin.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchPlugin.cpp
index b8184350f3..8c812a61e2 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchPlugin.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchPlugin.cpp
@@ -1,329 +1,329 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryLog.h"
#include "berryWorkbenchPlugin.h"
#include "berryWorkbenchRegistryConstants.h"
#include "berryWorkbench.h"
#include "berryPlatform.h"
#include "intro/berryEditorIntroAdapterPart.h"
#include "berryImageDescriptor.h"
#include <Poco/String.h>
#include <QDebug>
namespace berry
{
bool WorkbenchPlugin::DEBUG = false;
char WorkbenchPlugin::PREFERENCE_PAGE_CATEGORY_SEPARATOR = '/';
WorkbenchPlugin* WorkbenchPlugin::inst = 0;
WorkbenchPlugin::WorkbenchPlugin()
: AbstractUICTKPlugin()
{
inst = this;
presentationFactory = 0;
editorRegistry = 0;
viewRegistry = 0;
perspRegistry = 0;
introRegistry = 0;
}
WorkbenchPlugin::~WorkbenchPlugin()
{
delete editorRegistry;
delete viewRegistry;
delete perspRegistry;
delete introRegistry;
}
bool WorkbenchPlugin::HasExecutableExtension(
IConfigurationElement::Pointer element, const std::string& extensionName)
{
std::string attr;
if (element->GetAttribute(extensionName, attr))
return true;
std::string elementText(element->GetValue());
if (elementText != "")
return true;
IConfigurationElement::vector children(element->GetChildren(extensionName));
if (children.size() == 1)
{
if (children[0]->GetAttribute(WorkbenchRegistryConstants::ATT_CLASS, attr))
return true;
}
return false;
}
bool WorkbenchPlugin::IsBundleLoadedForExecutableExtension(
IConfigurationElement::Pointer element, const std::string& extensionName)
{
IBundle::Pointer bundle(WorkbenchPlugin::GetBundleForExecutableExtension(element, extensionName));
if (bundle.IsNull())
return true;
return bundle->GetState() == IBundle::BUNDLE_ACTIVE;
}
IBundle::Pointer WorkbenchPlugin::GetBundleForExecutableExtension(
IConfigurationElement::Pointer element, const std::string& extensionName)
{
// this code is derived heavily from
// ConfigurationElement.createExecutableExtension.
std::string prop;
std::string executable;
std::string contributorName;
std::string::size_type i;
if (extensionName != "")
element->GetAttribute(extensionName, prop);
else
{
// property not specified, try as element value
prop = element->GetValue();
if (prop != "")
{
Poco::trimInPlace(prop);
}
}
if (prop == "")
{
// property not defined, try as a child element
IConfigurationElement::vector exec(element->GetChildren(extensionName));
if (exec.size() != 0)
exec[0]->GetAttribute("plugin", contributorName); //$NON-NLS-1$
}
else
{
// simple property or element value, parse it into its components
i = prop.find_first_of(':');
if (i != std::string::npos)
executable = Poco::trim(prop.substr(0, i));
else
executable = prop;
i = executable.find_first_of('/');
if (i != std::string::npos)
contributorName = Poco::trim(executable.substr(0, i));
}
if (contributorName == "")
contributorName = element->GetContributor();
return Platform::GetBundle(contributorName);
}
WorkbenchPlugin* WorkbenchPlugin::GetDefault()
{
return inst;
}
std::size_t WorkbenchPlugin::GetBundleCount()
{
// TODO BundleContext GetBundles
//return bundleContext->GetBundles().size();
return 0;
}
// ImageRegistry createImageRegistry() {
// return WorkbenchImages.getImageRegistry();
// }
IPerspectiveRegistry* WorkbenchPlugin::GetPerspectiveRegistry() {
if (perspRegistry == 0) {
perspRegistry = new PerspectiveRegistry();
// the load methods can touch on WorkbenchImages if an image is
// missing so we need to wrap the call in
// a startup block for the case where a custom descriptor exists on
// startup that does not have an image
// associated with it. See bug 196352.
//StartupThreading.runWithoutExceptions(new StartupRunnable() {
// public void runWithException() throws Throwable {
perspRegistry->Load();
// }
//});
}
return perspRegistry;
}
// PreferenceManager getPreferenceManager() {
// if (preferenceManager == null) {
// preferenceManager = new WorkbenchPreferenceManager(
// PREFERENCE_PAGE_CATEGORY_SEPARATOR);
//
// //Get the pages from the registry
// PreferencePageRegistryReader registryReader = new PreferencePageRegistryReader(
// getWorkbench());
// registryReader
// .loadFromRegistry(Platform.getExtensionRegistry());
// preferenceManager.addPages(registryReader.getTopLevelNodes());
//
// }
// return preferenceManager;
// }
// ISharedImages getSharedImages() {
// if (sharedImages == null) {
// sharedImages = new SharedImages();
// }
// return sharedImages;
// }
IIntroRegistry* WorkbenchPlugin::GetIntroRegistry()
{
if (introRegistry == 0)
{
introRegistry = new IntroRegistry();
}
return introRegistry;
}
IViewRegistry* WorkbenchPlugin::GetViewRegistry()
{
if (!viewRegistry)
viewRegistry = new ViewRegistry();
return viewRegistry;
}
IEditorRegistry* WorkbenchPlugin::GetEditorRegistry()
{
if (!editorRegistry)
editorRegistry = new EditorRegistry();
return editorRegistry;
}
IPresentationFactory* WorkbenchPlugin::GetPresentationFactory() {
if (presentationFactory != 0) return presentationFactory;
std::string targetID = Workbench::GetInstance()->GetPresentationId();
presentationFactory = this->CreateExtension<IPresentationFactory>(
WorkbenchRegistryConstants::PL_PRESENTATION_FACTORIES,
"factory", targetID);
if (presentationFactory == 0)
WorkbenchPlugin::Log("Error creating presentation factory: " +
targetID + " -- class is not an IPresentationFactory");
return presentationFactory;
}
void WorkbenchPlugin::Log(const std::string& message)
{
BERRY_INFO << "LOG: " << message << std::endl;
//inst->GetLog().log(message);
}
void WorkbenchPlugin::Log(const Poco::RuntimeException& exc)
{
BERRY_INFO << "LOG: " << exc.message() << std::endl;
//inst->GetLog().log(exc);
}
void WorkbenchPlugin::Log(const std::string& message, const Poco::RuntimeException& t)
{
PlatformException exc(message, t);
WorkbenchPlugin::Log(exc);
}
void WorkbenchPlugin::Log(const std::string& clazz,
const std::string& methodName, const Poco::RuntimeException& t)
{
std::string msg = "Exception in " + clazz + "." + methodName + ": "
+ t.what();
WorkbenchPlugin::Log(msg, t);
}
void WorkbenchPlugin::start(ctkPluginContext* context)
{
//context.addBundleListener(getBundleListener());
AbstractUICTKPlugin::start(context);
bundleContext = context;
BERRY_REGISTER_EXTENSION_CLASS(EditorIntroAdapterPart, context)
// The UI plugin needs to be initialized so that it can install the callback in PrefUtil,
// which needs to be done as early as possible, before the workbench
// accesses any API preferences.
// Bundle uiBundle = Platform.getBundle(PlatformUI.PLUGIN_ID);
// try
// {
// // Attempt to load the activator of the ui bundle. This will force lazy start
// // of the ui bundle. Using the bundle activator class here because it is a
// // class that needs to be loaded anyway so it should not cause extra classes
// // to be loaded.
// if(uiBundle != null)
// uiBundle.loadClass(UI_BUNDLE_ACTIVATOR);
// }
// catch (ClassNotFoundException e)
// {
// WorkbenchPlugin.log("Unable to load UI activator", e); //$NON-NLS-1$
// }
/*
* DO NOT RUN ANY OTHER CODE AFTER THIS LINE. If you do, then you are
* likely to cause a deadlock in class loader code. Please see Bug 86450
* for more information.
*/
}
//const std::vector<IBundle::Pointer> WorkbenchPlugin::GetBundles()
//{
// return bundleContext.IsNull() ? std::vector<IBundle::Pointer>() : bundleContext->GetBundles();
//}
ctkPluginContext* WorkbenchPlugin::GetPluginContext()
{
return bundleContext;
}
void WorkbenchPlugin::stop(ctkPluginContext* context)
{
AbstractUICTKPlugin::stop(context);
delete perspRegistry;
}
bool WorkbenchPlugin::GetDataPath(Poco::Path& path)
{
QFileInfo fileInfo = bundleContext->getDataFile("");
path.assign(fileInfo.absolutePath().toStdString() + '/');
return fileInfo.isWritable();
}
}
Q_EXPORT_PLUGIN2(org_blueberry_ui, berry::WorkbenchPlugin)
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchPlugin.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchPlugin.h
index 1d91187162..f1c49b4cf9 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchPlugin.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchPlugin.h
@@ -1,474 +1,474 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYWORKBENCHPLUGIN_H_
#define BERRYWORKBENCHPLUGIN_H_
#include <Poco/Path.h>
#include <berryIExtensionPoint.h>
#include <berryIExtensionPointService.h>
#include <berryPlatform.h>
#include "berryAbstractUICTKPlugin.h"
#include "berryPlatformUI.h"
#include "presentations/berryIPresentationFactory.h"
#include "berryViewRegistry.h"
#include "berryEditorRegistry.h"
#include "berryPerspectiveRegistry.h"
#include "intro/berryIntroRegistry.h"
namespace berry {
/**
* \ingroup org_blueberry_ui_internal
*
* This class represents the TOP of the workbench UI world
* A plugin class is effectively an application wrapper
* for a plugin & its classes. This class should be thought
* of as the workbench UI's application class.
*
* This class is responsible for tracking various registries
* font, preference, graphics, dialog store.
*
* This class is explicitly referenced by the
* workbench plugin's "plugin.xml" and places it
* into the UI start extension point of the main
* overall application harness
*
* When is this class started?
* When the Application
* calls createExecutableExtension to create an executable
* instance of our workbench class.
*/
class WorkbenchPlugin : public QObject, public AbstractUICTKPlugin {
Q_OBJECT
Q_INTERFACES(ctkPluginActivator)
private:
//static const std::string UI_BUNDLE_ACTIVATOR = "org.blueberry.ui.internal.UIPlugin"; //$NON-NLS-1$
// Default instance of the receiver
static WorkbenchPlugin* inst;
// The presentation factory
IPresentationFactory* presentationFactory;
// Manager that maps resources to descriptors of editors to use
EditorRegistry* editorRegistry;
// The context within which this plugin was started.
ctkPluginContext* bundleContext;
// Other data.
//WorkbenchPreferenceManager preferenceManager;
ViewRegistry* viewRegistry;
PerspectiveRegistry* perspRegistry;
IntroRegistry* introRegistry;
//SharedImages sharedImages;
public:
/**
* Global workbench ui plugin flag. Only workbench implementation is allowed to use this flag
* All other plugins, examples, or test cases must *not* use this flag.
*/
static bool DEBUG;
/**
* The character used to separate preference page category ids
*/
static char PREFERENCE_PAGE_CATEGORY_SEPARATOR;
/**
* Create an instance of the WorkbenchPlugin. The workbench plugin is
* effectively the "application" for the workbench UI. The entire UI
* operates as a good plugin citizen.
*/
WorkbenchPlugin();
~WorkbenchPlugin();
/**
* Creates an extension. If the extension plugin has not
* been loaded a busy cursor will be activated during the duration of
* the load.
*
* @param element the config element defining the extension
* @param classAttribute the name of the attribute carrying the class
* @return the extension object
* @throws CoreException if the extension cannot be created
*/
// template<class E>
// static E* CreateExtension(IConfigurationElement::ConstPointer element,
// const std::string& classAttribute) {
// try {
// // If plugin has been loaded create extension.
// // Otherwise, show busy cursor then create extension.
// if (BundleUtility.isActivated(element.getDeclaringExtension()
// .getNamespace())) {
// return element.createExecutableExtension(classAttribute);
// }
// final Object[] ret = new Object[1];
// final CoreException[] exc = new CoreException[1];
// BusyIndicator.showWhile(null, new Runnable() {
// public void run() {
// try {
// ret[0] = element
// .createExecutableExtension(classAttribute);
// } catch (CoreException e) {
// exc[0] = e;
// }
// }
// });
// if (exc[0] != null) {
// throw exc[0];
// }
// return ret[0];
//
// } catch (CoreException core) {
// throw core;
// } catch (Exception e) {
// throw new CoreException(new Status(IStatus.ERR, PI_WORKBENCH,
// IStatus.ERR, WorkbenchMessages.WorkbenchPlugin_extension,e));
// }
// }
/**
* Answers whether the provided element either has an attribute with the
* given name or a child element with the given name with an attribute
* called class.
*
* @param element
* the element to test
* @param extensionName
* the name of the extension to test for
* @return whether or not the extension is declared
* @since 3.3
*/
static bool HasExecutableExtension(IConfigurationElement::Pointer element,
const std::string& extensionName);
/**
* Checks to see if the provided element has the syntax for an executable
* extension with a given name that resides in a bundle that is already
* active. Determining the bundle happens in one of two ways:<br/>
* <ul>
* <li>The element has an attribute with the specified name or element text
* in the form <code>bundle.id/class.name[:optional attributes]</code></li>
* <li>The element has a child element with the specified name that has a
* <code>plugin</code> attribute</li>
* </ul>
*
* @param element
* the element to test
* @param extensionName
* the name of the extension to test for
* @return whether or not the bundle expressed by the above criteria is
* active. If the bundle cannot be determined then the state of the
* bundle that declared the element is returned.
* @since 3.3
*/
static bool IsBundleLoadedForExecutableExtension(
IConfigurationElement::Pointer element, const std::string& extensionName);
/**
* Returns the bundle that contains the class referenced by an executable
* extension. Determining the bundle happens in one of two ways:<br/>
* <ul>
* <li>The element has an attribute with the specified name or element text
* in the form <code>bundle.id/class.name[:optional attributes]</code></li>
* <li>The element has a child element with the specified name that has a
* <code>plugin</code> attribute</li>
* </ul>
*
* @param element
* the element to test
* @param extensionName
* the name of the extension to test for
* @return the bundle referenced by the extension. If that bundle cannot be
* determined the bundle that declared the element is returned. Note
* that this may be <code>null</code>.
* @since 3.3
*/
static IBundle::Pointer GetBundleForExecutableExtension(IConfigurationElement::Pointer element, const std::string& extensionName);
/**
* Return the default instance of the receiver. This represents the runtime plugin.
* @return WorkbenchPlugin
* @see AbstractUICTKPlugin for the typical implementation pattern for plugin classes.
*/
static WorkbenchPlugin* GetDefault();
std::size_t GetBundleCount();
/**
* Answer the manager that maps resource types to a the
* description of the editor to use
* @return IEditorRegistry the editor registry used
* by this plug-in.
*/
IEditorRegistry* GetEditorRegistry();
/**
* Returns the presentation factory with the given id, or <code>null</code> if not found.
* @param targetID The id of the presentation factory to use.
* @return IPresentationFactory or <code>null</code>
* if not factory matches that id.
*/
IPresentationFactory* GetPresentationFactory();
protected:
/**
* Returns the image registry for this plugin.
*
* Where are the images? The images (typically gifs) are found in the same
* plugins directory.
*
* @see ImageRegistry
*
* Note: The workbench uses the standard JFace ImageRegistry to track its
* images. In addition the class WorkbenchGraphicResources provides
* convenience access to the graphics resources and fast field access for
* some of the commonly used graphical images.
*/
// ImageRegistry createImageRegistry();
private:
/**
* Looks up the configuration element with the given id on the given extension point
* and instantiates the class specified by the class attributes.
*
* @param extensionPointId the extension point id (simple id)
* @param elementName the name of the configuration element, or <code>null</code>
* to match any element
* @param targetID the target id
* @return the instantiated extension object, or <code>null</code> if not found
*/
template<class C>
C* CreateExtension(const std::string extensionPointId, const std::string& elementName,
const std::string& targetID) {
const IExtensionPoint* extensionPoint = Platform::GetExtensionPointService()
->GetExtensionPoint("" + PlatformUI::PLUGIN_ID + "." + extensionPointId);
if (extensionPoint == 0) {
WorkbenchPlugin
::Log("Unable to find extension. Extension point: " + extensionPointId + " not found"); //$NON-NLS-1$ //$NON-NLS-2$
return 0;
}
// Loop through the config elements.
IConfigurationElement::Pointer targetElement(0);
IConfigurationElement::vector elements(Platform::GetExtensionPointService()
->GetConfigurationElementsFor("" + PlatformUI::PLUGIN_ID + "." + extensionPointId));
for (unsigned int j = 0; j < elements.size(); j++) {
if (elementName == "" || elementName == elements[j]->GetName()) {
std::string strID;
elements[j]->GetAttribute("id", strID);
if (targetID == strID) {
targetElement = elements[j];
break;
}
}
}
if (targetElement.IsNull()) {
// log it since we cannot safely display a dialog.
WorkbenchPlugin::Log("Unable to find extension: " + targetID //$NON-NLS-1$
+ " in extension point: " + extensionPointId); //$NON-NLS-1$
return 0;
}
// Create the extension.
try {
C* impl = targetElement->CreateExecutableExtension<C>("class"); //$NON-NLS-1$
if (impl == 0)
{
// support legacy BlueBerry extensions
impl = targetElement->CreateExecutableExtension<C>("class", C::GetManifestName());
}
return impl;
} catch (CoreException e) {
// log it since we cannot safely display a dialog.
WorkbenchPlugin::Log("Unable to create extension: " + targetID //$NON-NLS-1$
+ " in extension point: " + extensionPointId); //$NON-NLS-1$
}
return 0;
}
public:
/**
* Return the perspective registry.
* @return IPerspectiveRegistry. The registry for the receiver.
*/
IPerspectiveRegistry* GetPerspectiveRegistry();
/**
* Returns the introduction registry.
*
* @return the introduction registry.
* @since 3.0
*/
IIntroRegistry* GetIntroRegistry();
/**
* Get the preference manager.
* @return PreferenceManager the preference manager for
* the receiver.
*/
// PreferenceManager getPreferenceManager();
/**
* Returns the shared images for the workbench.
*
* @return the shared image manager
*/
// ISharedImages getSharedImages();
/**
* Answer the view registry.
* @return IViewRegistry the view registry for the
* receiver.
*/
IViewRegistry* GetViewRegistry();
/**
* Logs the given message to the platform log.
*
* If you have an exception in hand, call log(String, Throwable) instead.
*
* If you have a status object in hand call log(String, IStatus) instead.
*
* This convenience method is for internal use by the Workbench only and
* must not be called outside the Workbench.
*
* @param message
* A high level UI message describing when the problem happened.
*/
static void Log(const std::string& message);
/**
* Log the throwable.
* @param t
*/
static void Log(const Poco::RuntimeException& exc);
/**
* Logs the given message and throwable to the platform log.
*
* If you have a status object in hand call log(String, IStatus) instead.
*
* This convenience method is for internal use by the Workbench only and
* must not be called outside the Workbench.
*
* @param message
* A high level UI message describing when the problem happened.
* @param t
* The throwable from where the problem actually occurred.
*/
static void Log(const std::string& message, const Poco::RuntimeException& t);
/**
* Logs the given throwable to the platform log, indicating the class and
* method from where it is being logged (this is not necessarily where it
* occurred).
*
* This convenience method is for internal use by the Workbench only and
* must not be called outside the Workbench.
*
* @param clazz
* The calling class.
* @param methodName
* The calling method name.
* @param t
* The throwable from where the problem actually occurred.
*/
static void Log(const std::string& clazz, const std::string& methodName, const Poco::RuntimeException& t);
/*
* (non-Javadoc)
* @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
*/
void start(ctkPluginContext* context);
/**
* Return an array of all bundles contained in this workbench.
*
* @return an array of bundles in the workbench or an empty array if none
* @since 3.0
*/
//const std::vector<IBundle::Pointer> GetBundles();
/**
* Returns the bundle context associated with the workbench plug-in.
*
* @return the bundle context
* @since 3.1
*/
ctkPluginContext* GetPluginContext();
/* (non-Javadoc)
* @see org.blueberry.ui.plugin.AbstractUICTKPlugin#stop(org.osgi.framework.BundleContext)
*/
void stop(ctkPluginContext* context);
/**
* FOR INTERNAL WORKBENCH USE ONLY.
*
* Returns the path to a location in the file system that can be used
* to persist/restore state between workbench invocations.
* If the location did not exist prior to this call it will be created.
* Returns <code>null</code> if no such location is available.
*
* @return path to a location in the file system where this plug-in can
* persist data between sessions, or <code>null</code> if no such
* location is available.
* @since 3.1
*/
bool GetDataPath(Poco::Path& path);
};
}
#endif /*BERRYWORKBENCHPLUGIN_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchRegistryConstants.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchRegistryConstants.cpp
index 936f7ff6cc..53f8eebe9f 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchRegistryConstants.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchRegistryConstants.cpp
@@ -1,565 +1,565 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryWorkbenchRegistryConstants.h"
#include "berryPlatformUI.h"
namespace berry {
const std::string WorkbenchRegistryConstants::ATT_ACCELERATOR = "accelerator"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_ADAPTABLE = "adaptable"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_ADVISORID = "triggerPointAdvisorId"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_ALLOW_LABEL_UPDATE = "allowLabelUpdate";//$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_ALLOW_MULTIPLE = "allowMultiple"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_RESTORABLE = "restorable";
const std::string WorkbenchRegistryConstants::ATT_CAN_FINISH_EARLY = "canFinishEarly"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_CATEGORY = "category"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_CATEGORY_ID = "categoryId"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_CLASS = "class"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_CLOSEABLE = "closeable"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_COLORFACTORY = "colorFactory"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_COMMAND = "command";//$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_COMMAND_ID = "commandId"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_CONFIGURATION = "configuration"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_CONTENT_DETECTOR = "contentDetector"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_CONTENT_TYPE_ID = "contentTypeId"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_CONTEXT_ID = "contextId"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_CONTRIBUTOR_CLASS = "contributorClass"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_CONVERTER = "converter"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_DEFAULT = "default";//$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_DEFAULT_HANDLER = "defaultHandler"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_DEFAULTS_TO = "defaultsTo"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_DEFINITION_ID = "definitionId";//$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_DESCRIPTION = "description"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_DESCRIPTION_IMAGE = "descriptionImage"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_DISABLEDICON = "disabledIcon";//$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_ENABLES_FOR = "enablesFor"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_EXTENSIONS = "extensions";//$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_FAST_VIEW_WIDTH_RATIO = "fastViewWidthRatio"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_FILENAMES = "filenames";//$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_FILL_MAJOR = "fillMajor";//$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_FILL_MINOR = "fillMinor";//$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_FIXED = "fixed";//$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_HAS_PAGES = "hasPages"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_HELP_CONTEXT_ID = "helpContextId";//$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_HELP_HREF = "helpHref"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_HOVERICON = "hoverIcon";//$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_ICON = "icon"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_ID = "id"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_IMAGE_STYLE = "imageStyle"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_IS_EDITABLE = "isEditable"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_KEY = "key"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_KEY_CONFIGURATION_ID = "keyConfigurationId"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_KEY_SEQUENCE = "keySequence"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_LABEL = "label"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_LAUNCHER = "launcher";//$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_LIGHTWEIGHT = "lightweight"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_LOCALE = "locale"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_LOCATION = "location"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_MATCHING_STRATEGY = "matchingStrategy"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_MENU_ID = "menuId"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_MENUBAR_PATH = "menubarPath";//$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_MNEMONIC = "mnemonic"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_MINIMIZED = "minimized"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_MOVEABLE = "moveable"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_NAME = "name"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_NAME_FILTER = "nameFilter"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_NODE = "node"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_OBJECTCLASS = "objectClass";//$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_OPTIONAL = "optional"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_OS = "os"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_PARENT = "parent"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_PARENT_CATEGORY = "parentCategory"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_PARENT_ID = "parentId"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_PARENT_SCOPE = "parentScope"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_PATH = "path"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_PLATFORM = "platform"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_POSITION = "position"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_PRESENTATIONID = "presentationId"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_PRODUCTID = "productId"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_PROJECT = "project";//$NON-NLS-1$ /**
const std::string WorkbenchRegistryConstants::ATT_PULLDOWN = "pulldown"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_RATIO = "ratio"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_RELATIONSHIP = "relationship";//$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_RELATIVE = "relative";//$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_RELATIVE_TO = "relativeTo"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_RETARGET = "retarget";//$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_RETURN_TYPE_ID = "returnTypeId"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_ROLE = "role";
const std::string WorkbenchRegistryConstants::ATT_SCHEME_ID = "schemeId"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_SCOPE = "scope"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_SEPARATORS_VISIBLE = "separatorsVisible"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_SEQUENCE = "sequence"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_SHOW_TITLE = "showTitle";//$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_SINGLETON = "singleton";//$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_SPLASH_ID = "splashId"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_STANDALONE = "standalone";//$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_STATE = "state";//$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_STRING = "string"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_STYLE = "style";//$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_TARGET_ID = "targetID";//$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_TOOLBAR_PATH = "toolbarPath";//$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_TOOLTIP = "tooltip";//$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_TYPE = "type"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_TYPE_ID = "typeId"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_VALUE = "value"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_VISIBLE = "visible";//$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_WS = "ws"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::AUTOGENERATED_PREFIX = "AUTOGEN:::"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::PL_ACCELERATOR_CONFIGURATIONS = "acceleratorConfigurations"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::PL_ACCELERATOR_SCOPES = "acceleratorScopes"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::PL_ACTION_DEFINITIONS = "actionDefinitions"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::PL_ACTION_SET_PART_ASSOCIATIONS = "actionSetPartAssociations"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::PL_ACTION_SETS = "actionSets"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::PL_ACTIVITIES = "activities"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::PL_ACTIVITYSUPPORT = "activitySupport"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::PL_BINDINGS = "bindings"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::PL_BROWSER_SUPPORT = "browserSupport"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::PL_COLOR_DEFINITIONS = "colorDefinitions"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::PL_COMMAND_IMAGES = "commandImages"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::PL_COMMANDS = "commands"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::PL_CONTEXTS = "contexts"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::PL_DECORATORS = "decorators"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::PL_DROP_ACTIONS = "dropActions"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::PL_EDITOR = "editors"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::PL_EDITOR_ACTIONS = "editorActions"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::PL_ELEMENT_FACTORY = "elementFactories"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::PL_ENCODINGS = "encodings"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::PL_EXPORT = "exportWizards"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::PL_FONT_DEFINITIONS = "fontDefinitions"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::PL_HANDLERS = "handlers"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::PL_HELPSUPPORT = "helpSupport"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::PL_IMPORT = "importWizards"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::PL_INTRO = "intro"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::PL_KEYWORDS = "keywords"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::PL_MENUS = "menus"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::PL_MENU_CONTRIBUTION = "menuContribution"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::PL_NEW = "newWizards"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::PL_PERSPECTIVE_EXTENSIONS = "perspectiveExtensions"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::PL_PERSPECTIVES = "perspectives"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::PL_POPUP_MENU = "popupMenus"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::PL_PREFERENCE_TRANSFER = "preferenceTransfer"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::PL_PREFERENCES = "preferencePages"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::PL_PRESENTATION_FACTORIES = "presentationFactories"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::PL_PROPERTY_PAGES = "propertyPages"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::PL_STARTUP = "startup"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::PL_SPLASH_HANDLERS = "splashHandlers"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::PL_SYSTEM_SUMMARY_SECTIONS = "systemSummarySections"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::PL_THEMES = "themes"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::PL_VIEW_ACTIONS = "viewActions"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::PL_VIEWS = "views"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::PL_WORKINGSETS = "workingSets"; //$NON-NLS-1$
// const std::string WorkbenchRegistryConstants::EXTENSION_ACCELERATOR_CONFIGURATIONS = PlatformUI::PLUGIN_ID
// + '.' + PL_ACCELERATOR_CONFIGURATIONS;
//
// const std::string WorkbenchRegistryConstants::EXTENSION_ACCELERATOR_SCOPES = PlatformUI::PLUGIN_ID
// + '.' + PL_ACCELERATOR_SCOPES;
//
// const std::string WorkbenchRegistryConstants::EXTENSION_ACTION_DEFINITIONS = PlatformUI::PLUGIN_ID
// + '.' + PL_ACTION_DEFINITIONS;
//
// const std::string WorkbenchRegistryConstants::EXTENSION_ACTION_SETS = PlatformUI::PLUGIN_ID
// + '.' + WorkbenchRegistryConstants::PL_ACTION_SETS;
//
// const std::string WorkbenchRegistryConstants::EXTENSION_BINDINGS = PlatformUI::PLUGIN_ID + '.'
// + PL_BINDINGS;
//
// const std::string WorkbenchRegistryConstants::EXTENSION_COMMAND_IMAGES = PlatformUI::PLUGIN_ID
// + '.' + PL_COMMAND_IMAGES;
//
// const std::string WorkbenchRegistryConstants::EXTENSION_COMMANDS = PlatformUI::PLUGIN_ID + '.'
// + PL_COMMANDS;
//
// const std::string WorkbenchRegistryConstants::EXTENSION_CONTEXTS = PlatformUI::PLUGIN_ID + '.'
// + PL_CONTEXTS;
//
// const std::string WorkbenchRegistryConstants::EXTENSION_EDITOR_ACTIONS = PlatformUI::PLUGIN_ID
// + '.' + PL_EDITOR_ACTIONS;
//
// const std::string WorkbenchRegistryConstants::EXTENSION_HANDLERS = PlatformUI::PLUGIN_ID + '.'
// + PL_HANDLERS;
//
// const std::string WorkbenchRegistryConstants::EXTENSION_MENUS = PlatformUI::PLUGIN_ID + '.'
// + PL_MENUS;
//
// const std::string WorkbenchRegistryConstants::COMMON_MENU_ADDITIONS = PlatformUI::PLUGIN_ID + '.'
// + PL_MENUS + '2';
//
// const std::string WorkbenchRegistryConstants::EXTENSION_POPUP_MENUS = PlatformUI::PLUGIN_ID
// + '.' + PL_POPUP_MENU;
//
// const std::string WorkbenchRegistryConstants::EXTENSION_VIEW_ACTIONS = PlatformUI::PLUGIN_ID
// + '.' + PL_VIEW_ACTIONS;
const std::string WorkbenchRegistryConstants::POSITION_AFTER = "after"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::POSITION_BEFORE = "before"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::POSITION_END = "end"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::POSITION_START = "start"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::STYLE_PULLDOWN = "pulldown"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::STYLE_RADIO = "radio"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::STYLE_TOGGLE = "toggle"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_ACCELERATOR_CONFIGURATION = "acceleratorConfiguration"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_ACCELERATOR_SCOPE = "acceleratorScope"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_ACTION = "action"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_ACTION_DEFINITION = "actionDefinition"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_ACTION_SET = "actionSet";//$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_ACTION_SET_PART_ASSOCIATION = "actionSetPartAssociation";//$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_ACTIVE_KEY_CONFIGURATION = "activeKeyConfiguration"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_ACTIVE_WHEN = "activeWhen"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_ACTIVITY_IMAGE_BINDING = "activityImageBinding"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_ADVISORPRODUCTBINDING = "triggerPointAdvisorProductBinding"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_BAR = "bar"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_CATEGORY = "category";//$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_CATEGORY_IMAGE_BINDING = "categoryImageBinding"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_CATEGORYDEFINITION = "themeElementCategory"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_CATEGORYPRESENTATIONBINDING = "categoryPresentationBinding"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_CLASS = ATT_CLASS;
const std::string WorkbenchRegistryConstants::TAG_COLORDEFINITION = "colorDefinition"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_COLOROVERRIDE = "colorOverride"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_COLORVALUE = "colorValue"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_COMMAND = "command"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_COMMAND_PARAMETER = "commandParameter"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_COMMAND_PARAMETER_TYPE = "commandParameterType"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_CONTENT_TYPE_BINDING = "contentTypeBinding"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_CONTEXT = "context"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_DATA = "data"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_DEFAULT_HANDLER = ATT_DEFAULT_HANDLER;
const std::string WorkbenchRegistryConstants::TAG_DESCRIPTION = "description"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_DYNAMIC = "dynamic"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_EDITOR = "editor";//$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_EDITOR_CONTRIBUTION = "editorContribution"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_ENABLED_WHEN = "enabledWhen"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_ENABLEMENT = "enablement"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_ENTRY = "entry"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_FILTER = "filter"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_FONTDEFINITION = "fontDefinition"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_FONTOVERRIDE = "fontOverride"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_FONTVALUE = "fontValue"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_GROUP = "group"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_GROUP_MARKER = "groupMarker"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_HANDLER = "handler"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_HANDLER_SUBMISSION = "handlerSubmission"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_HINT = "hint"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_IMAGE = "image"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_KEY = "key"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_KEY_BINDING = "keyBinding"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_KEY_CONFIGURATION = "keyConfiguration"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_LOCATION = "location"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_LOCATION_URI = "locationURI"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_LAYOUT = "layout"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_MAPPING = "mapping"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_MENU = "menu"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_NEW_WIZARD_SHORTCUT = "newWizardShortcut";//$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_OBJECT_CONTRIBUTION = "objectContribution";//$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_ORDER = "order"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_PARAMETER = "parameter"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_PART = "part";//$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_PERSP_SHORTCUT = "perspectiveShortcut";//$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_PERSPECTIVE = "perspective";//$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_PERSPECTIVE_EXTENSION = "perspectiveExtension";//$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_PRIMARYWIZARD = "primaryWizard"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_REFERENCE = "reference"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_SCHEME = "scheme"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_SCOPE = "scope"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_SELECTION = "selection"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_SEPARATOR = "separator"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_SETTINGS_TRANSFER = "settingsTransfer"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_SHOW_IN_PART = "showInPart";//$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_STATE = "state"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_SPLASH_HANDLER = "splashHandler"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_SPLASH_HANDLER_PRODUCT_BINDING = "splashHandlerProductBinding"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_STICKYVIEW = "stickyView";//$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_SUPPORT = "support"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_THEME = "theme";//$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_TRANSFER = "transfer";//$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_TRIGGERPOINT = "triggerPoint"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_TRIGGERPOINTADVISOR = "triggerPointAdvisor"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_VIEW = "view";//$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_VIEW_SHORTCUT = "viewShortcut";//$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_VIEW_CONTRIBUTION = "viewContribution"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_VIEWER_CONTRIBUTION = "viewerContribution"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_VISIBILITY = "visibility"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_VISIBLE_WHEN = "visibleWhen"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_WIDGET = "widget"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_CONTROL = "control"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_WIZARD = "wizard";//$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_WORKING_SET = "workingSet"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TYPE_GROUP = "group"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TYPE_ITEM = "item"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TYPE_MENU = "menu"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TYPE_WIDGET = "widget"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_TOOLBAR = "toolbar"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_SERVICE_FACTORY = "serviceFactory"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_SERVICE = "service"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATTR_FACTORY_CLASS = "factoryClass"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATTR_SERVICE_CLASS = "serviceClass"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_SOURCE_PROVIDER = "sourceProvider"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATTR_PROVIDER = "provider"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::TAG_VARIABLE = "variable"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_PRIORITY_LEVEL = "priorityLevel"; //$NON-NLS-1$
const std::string WorkbenchRegistryConstants::ATT_MODE = "mode";
} // namespace berry
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchRegistryConstants.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchRegistryConstants.h
index ef459da4ea..1be03164e5 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchRegistryConstants.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchRegistryConstants.h
@@ -1,1322 +1,1322 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 __BERRY_WORKBENCH_REGISTRY_CONSTANTS__
#define __BERRY_WORKBENCH_REGISTRY_CONSTANTS__
#include <iostream>
namespace berry {
/**
* \ingroup org_blueberry_ui_internal
*
* Interface containing various registry constants (tag and attribute names).
*
*/
struct WorkbenchRegistryConstants {
/**
* Accelerator attribute. Value <code>accelerator</code>.
*/
static const std::string ATT_ACCELERATOR; // "accelerator"; //$NON-NLS-1$
/**
* Adaptable attribute. Value <code>adaptable</code>.
*/
static const std::string ATT_ADAPTABLE; // "adaptable"; //$NON-NLS-1$
/**
* Advisor id attribute. Value <code>triggerPointAdvisorId</code>.
*/
static const std::string ATT_ADVISORID; // "triggerPointAdvisorId"; //$NON-NLS-1$
/**
* Allow label update attribute. Value <code>allowLabelUpdate</code>.
*/
static const std::string ATT_ALLOW_LABEL_UPDATE; // "allowLabelUpdate";//$NON-NLS-1$
/**
* View multiple attribute. Value <code>allowMultiple</code>.
*/
static const std::string ATT_ALLOW_MULTIPLE; // "allowMultiple"; //$NON-NLS-1$
/**
* Attribute that specifies whether a view gets restored upon workbench restart. Value <code>restorable</code>.
*/
static const std::string ATT_RESTORABLE; // = "restorable";
/**
* Attribute that specifies whether a wizard is immediately capable of
* finishing. Value <code>canFinishEarly</code>.
*/
static const std::string ATT_CAN_FINISH_EARLY; // "canFinishEarly"; //$NON-NLS-1$
/**
* The name of the category attribute, which appears on a command
* definition.
*/
static const std::string ATT_CATEGORY; // "category"; //$NON-NLS-1$
/**
* Category id attribute. Value <code>categoryId</code>.
*/
static const std::string ATT_CATEGORY_ID; // "categoryId"; //$NON-NLS-1$
/**
* Class attribute. Value <code>class</code>.
*/
static const std::string ATT_CLASS; // "class"; //$NON-NLS-1$
/**
* Sticky view closable attribute. Value <code>closable</code>.
*/
static const std::string ATT_CLOSEABLE; // "closeable"; //$NON-NLS-1$
/**
* Color factory attribute. Value <code>colorFactory</code>.
*/
static const std::string ATT_COLORFACTORY; // "colorFactory"; //$NON-NLS-1$
/**
* Editor command attribute. Value <code>command</code>.
*/
static const std::string ATT_COMMAND; // "command";//$NON-NLS-1$
/**
* The name of the attribute storing the command id.
*/
static const std::string ATT_COMMAND_ID; // "commandId"; //$NON-NLS-1$
/**
* The name of the configuration attribute storing the scheme id for a
* binding.
*/
static const std::string ATT_CONFIGURATION; // "configuration"; //$NON-NLS-1$
/**
* Intro content detector class attribute (optional). Value <code>contentDetector</code>.
*/
static const std::string ATT_CONTENT_DETECTOR; // "contentDetector"; //$NON-NLS-1$
/**
* Editor content type id binding attribute. Value
* <code>contentTypeId</code>.
*/
static const std::string ATT_CONTENT_TYPE_ID; // "contentTypeId"; //$NON-NLS-1$
/**
* The name of the attribute storing the context id for a binding.
*/
static const std::string ATT_CONTEXT_ID; // "contextId"; //$NON-NLS-1$
/**
* Editor contributor class attribute. Value <code>contributorClass</code>.
*/
static const std::string ATT_CONTRIBUTOR_CLASS; // "contributorClass"; //$NON-NLS-1$
/**
* The name of the attribute storing the AbstractParameterValueConverter for
* a commandParameterType.
*/
static const std::string ATT_CONVERTER; // "converter"; //$NON-NLS-1$
/**
* Perspective default attribute. Value <code>default</code>.
*/
static const std::string ATT_DEFAULT; // "default";//$NON-NLS-1$
/**
* The name of the default handler attribute, which appears on a command
* definition.
*/
static const std::string ATT_DEFAULT_HANDLER; // "defaultHandler"; //$NON-NLS-1$
/**
* Defaults-to attribute. Value <code>defaultsTo</code>.
*/
static const std::string ATT_DEFAULTS_TO; // "defaultsTo"; //$NON-NLS-1$
/**
* Action definition id attribute. Value <code>definitionId</code>.
*/
static const std::string ATT_DEFINITION_ID; // "definitionId";//$NON-NLS-1$
/**
* The name of the description attribute, which appears on named handle
* objects.
*/
static const std::string ATT_DESCRIPTION; // "description"; //$NON-NLS-1$
/**
* Description image attribute. Value <code>descriptionImage</code>.
*/
static const std::string ATT_DESCRIPTION_IMAGE; // "descriptionImage"; //$NON-NLS-1$
/**
* Disabled icon attribute. Value <code>disabledIcon</code>.
*/
static const std::string ATT_DISABLEDICON; // "disabledIcon";//$NON-NLS-1$
/**
* Enables-for attribute. Value <code>enablesFor</code>.
*/
static const std::string ATT_ENABLES_FOR; // "enablesFor"; //$NON-NLS-1$
/**
* Editor extensions attribute. Value <code>extensions</code>.
*/
static const std::string ATT_EXTENSIONS; // "extensions";//$NON-NLS-1$
/**
* View ratio attribute. Value <code>fastViewWidthRatio</code>.
*/
static const std::string ATT_FAST_VIEW_WIDTH_RATIO; // "fastViewWidthRatio"; //$NON-NLS-1$
/**
* Editor filenames attribute. Value <code>filenames</code>.
*/
static const std::string ATT_FILENAMES; // "filenames";//$NON-NLS-1$
/**
* Trim fill major attribute. Value <code>fillMajor</code>.
*/
static const std::string ATT_FILL_MAJOR; // "fillMajor";//$NON-NLS-1$
/**
* Trim fill minor attribute. Value <code>fillMinor</code>.
*/
static const std::string ATT_FILL_MINOR; // "fillMinor";//$NON-NLS-1$
/**
* Perspective fixed attribute. Value <code>fixed</code>.
*/
static const std::string ATT_FIXED; // "fixed";//$NON-NLS-1$
/**
* Attribute that specifies whether a wizard has any pages. Value
* <code>hasPages</code>.
*/
static const std::string ATT_HAS_PAGES; // "hasPages"; //$NON-NLS-1$
/**
* Help context id attribute. Value <code>helpContextId</code>.
*/
static const std::string ATT_HELP_CONTEXT_ID; // "helpContextId";//$NON-NLS-1$
/**
* Help url attribute. Value <code>helpHref</code>.
*/
static const std::string ATT_HELP_HREF; // "helpHref"; //$NON-NLS-1$
/**
* Hover icon attribute. Value <code>hoverIcon</code>.
*/
static const std::string ATT_HOVERICON; // "hoverIcon";//$NON-NLS-1$
/**
* Icon attribute. Value <code>icon</code>.
*/
static const std::string ATT_ICON; // "icon"; //$NON-NLS-1$
/**
* Id attribute. Value <code>id</code>.
*/
static const std::string ATT_ID; // "id"; //$NON-NLS-1$
/**
* The name of the image style attribute, which is used on location elements
* in the menus extension point.
*/
static const std::string ATT_IMAGE_STYLE; // "imageStyle"; //$NON-NLS-1$
/**
* Is-editable attribute. Value <code>isEditable</code>.
*/
static const std::string ATT_IS_EDITABLE; // "isEditable"; //$NON-NLS-1$
/**
* Keys attribute. Value <code>keys</code>.
*/
static const std::string ATT_KEY; // "key"; //$NON-NLS-1$
/**
* The name of the attribute storing the identifier for the active key
* configuration identifier. This provides legacy support for the
* <code>activeKeyConfiguration</code> element in the commands extension
* point.
*/
static const std::string ATT_KEY_CONFIGURATION_ID; // "keyConfigurationId"; //$NON-NLS-1$
/**
* The name of the attribute storing the trigger sequence for a binding.
* This is called a 'keySequence' for legacy reasons.
*/
static const std::string ATT_KEY_SEQUENCE; // "keySequence"; //$NON-NLS-1$
/**
* Label attribute. Value <code>label</code>.
*/
static const std::string ATT_LABEL; // "label"; //$NON-NLS-1$
/**
* Editor launcher attribute. Value <code>launcher</code>.
*/
static const std::string ATT_LAUNCHER; // "launcher";//$NON-NLS-1$
/**
* Lightweight decorator tag. Value <code>lightweight</code>.
*/
static const std::string ATT_LIGHTWEIGHT; // "lightweight"; //$NON-NLS-1$
/**
* The name of the attribute storing the locale for a binding.
*/
static const std::string ATT_LOCALE; // "locale"; //$NON-NLS-1$
/**
* Sticky view location attribute. Value <code>location</code>.
*/
static const std::string ATT_LOCATION; // "location"; //$NON-NLS-1$
/**
* Editor management strategy attribute. Value <code>matchingStrategy</code>.
*/
static const std::string ATT_MATCHING_STRATEGY; // "matchingStrategy"; //$NON-NLS-1$
/**
* The name of the menu identifier attribute, which appears on items.
*/
static const std::string ATT_MENU_ID; // "menuId"; //$NON-NLS-1$
/**
* Menubar path attribute. Value <code>menubarPath</code>.
*/
static const std::string ATT_MENUBAR_PATH; // "menubarPath";//$NON-NLS-1$
/**
* The name of the mnemonic attribute, which appears on locations.
*/
static const std::string ATT_MNEMONIC; // "mnemonic"; //$NON-NLS-1$
/**
* The name of the minimized attribute, which appears
* when adding a view in a perspectiveExtension.
*/
static const std::string ATT_MINIMIZED; // "minimized"; //$NON-NLS-1$
/**
* Sticky view moveable attribute. Value <code>moveable</code>.
*/
static const std::string ATT_MOVEABLE; // "moveable"; //$NON-NLS-1$
/**
* Name attribute. Value <code>name</code>.
*/
static const std::string ATT_NAME; // "name"; //$NON-NLS-1$
/**
* Name filter attribute. Value <code>nameFilter</code>.
*/
static const std::string ATT_NAME_FILTER; // "nameFilter"; //$NON-NLS-1$
/**
* Node attribute. Value <code>node</code>.
*/
static const std::string ATT_NODE; // "node"; //$NON-NLS-1$
/**
* Object class attribute. Value <code>objectClass</code>.
*/
static const std::string ATT_OBJECTCLASS; // "objectClass";//$NON-NLS-1$
/**
* The name of the optional attribute, which appears on parameter
* definitions.
*/
static const std::string ATT_OPTIONAL; // "optional"; //$NON-NLS-1$
/**
* Operating system attribute. Value <code>os</code>.
*/
static const std::string ATT_OS; // "os"; //$NON-NLS-1$
/**
* The name of the deprecated parent attribute, which appears on scheme
* definitions.
*/
static const std::string ATT_PARENT; // "parent"; //$NON-NLS-1$
/**
* View parent category attribute. Value <code>parentCategory</code>.
*/
static const std::string ATT_PARENT_CATEGORY; // "parentCategory"; //$NON-NLS-1$
/**
* Parent id attribute. Value <code>parentId</code>.
*/
static const std::string ATT_PARENT_ID; // "parentId"; //$NON-NLS-1$
/**
* The name of the deprecated parent scope attribute, which appears on
* contexts definitions.
*/
static const std::string ATT_PARENT_SCOPE; // "parentScope"; //$NON-NLS-1$
/**
* Path attribute. Value <code>path</code>.
*/
static const std::string ATT_PATH; // "path"; //$NON-NLS-1$
/**
* The name of the attribute storing the platform for a binding.
*/
static const std::string ATT_PLATFORM; // "platform"; //$NON-NLS-1$
/**
* The name of the position attribute, which appears on order elements.
*/
static const std::string ATT_POSITION; // "position"; //$NON-NLS-1$
/**
* Presentation id attribute. Value <code>presentationId</code>.
*/
static const std::string ATT_PRESENTATIONID; // "presentationId"; //$NON-NLS-1$
/**
* Product id attribute. Value <code>productId</code>.
*/
static const std::string ATT_PRODUCTID; // "productId"; //$NON-NLS-1$
/**
* Project attribute. Value <code>project</code>.
*/
// @issue project-specific attribute and behavior
static const std::string ATT_PROJECT; // "project";//$NON-NLS-1$ /**
/**
* The name of the pulldown attribute, which indicates whether the class is
* a pulldown delegate.
*/
static const std::string ATT_PULLDOWN; // "pulldown"; //$NON-NLS-1$
/**
* View ratio attribute. Value <code>ratio</code>.
*/
static const std::string ATT_RATIO; // "ratio"; //$NON-NLS-1$
/**
* Relationship attribute. Value <code>relationship</code>.
*/
static const std::string ATT_RELATIONSHIP; // "relationship";//$NON-NLS-1$
/**
* Relative attribute. Value <code>relative</code>.
*/
static const std::string ATT_RELATIVE; // "relative";//$NON-NLS-1$
/**
* The name of the relativeTo attribute, which appears on order elements.
*/
static const std::string ATT_RELATIVE_TO; // "relativeTo"; //$NON-NLS-1$
/**
* Retarget attribute. Value <code>retarget</code>.
*/
static const std::string ATT_RETARGET; // "retarget";//$NON-NLS-1$
/**
* The name of the returnTypeId attribute, which appears on command
* elements.
*/
static const std::string ATT_RETURN_TYPE_ID; // "returnTypeId"; //$NON-NLS-1$
/**
* Role attribue. Value <code>role</code>.
*/
static const std::string ATT_ROLE; // "role";
/**
* The name of the attribute storing the identifier for the active scheme.
* This is called a 'keyConfigurationId' for legacy reasons.
*/
static const std::string ATT_SCHEME_ID; // "schemeId"; //$NON-NLS-1$
/**
* Scope attribute. Value <code>scope</code>.
*/
static const std::string ATT_SCOPE; // "scope"; //$NON-NLS-1$
/**
* The name of the separatorsVisible attribute, which appears on group
* elements.
*/
static const std::string ATT_SEPARATORS_VISIBLE; // "separatorsVisible"; //$NON-NLS-1$
/**
* The name of the sequence attribute for a key binding.
*/
static const std::string ATT_SEQUENCE; // "sequence"; //$NON-NLS-1$
/**
* Show title attribute. Value <code>showTitle</code>.
*/
static const std::string ATT_SHOW_TITLE; // "showTitle";//$NON-NLS-1$
/**
* Perspective singleton attribute. Value <code>singleton</code>.
*/
static const std::string ATT_SINGLETON; // "singleton";//$NON-NLS-1$
/**
* Splash id attribute. Value <code>splashId</code>.
*
* @since 3.3
*/
static const std::string ATT_SPLASH_ID; // "splashId"; //$NON-NLS-1$
/**
* Standalone attribute. Value <code>standalone</code>.
*/
static const std::string ATT_STANDALONE; // "standalone";//$NON-NLS-1$
/**
* Action state attribute. Value <code>state</code>.
*/
static const std::string ATT_STATE; // "state";//$NON-NLS-1$
/**
* The name of the string attribute (key sequence) for a binding in the
* commands extension point.
*/
static const std::string ATT_STRING; // "string"; //$NON-NLS-1$
/**
* Action style attribute. Value <code>style</code>.
*/
static const std::string ATT_STYLE; // "style";//$NON-NLS-1$
/**
* Target attribute. Value <code>targetID</code>.
*/
static const std::string ATT_TARGET_ID; // "targetID";//$NON-NLS-1$
/**
* Toolbar path attribute. Value <code>toolbarPath</code>.
*/
static const std::string ATT_TOOLBAR_PATH; // "toolbarPath";//$NON-NLS-1$
/**
* Tooltip attribute. Value <code>tooltip</code>.
*/
static const std::string ATT_TOOLTIP; // "tooltip";//$NON-NLS-1$
/**
* The name of the type attribute, which appears on bar elements and
* commandParameterType elments.
*/
static const std::string ATT_TYPE; // "type"; //$NON-NLS-1$
/**
* The name of the typeId attribute, which appears on commandParameter
* elements.
*/
static const std::string ATT_TYPE_ID; // "typeId"; //$NON-NLS-1$
/**
* Value attribute. Value <code>value</code>.
*/
static const std::string ATT_VALUE; // "value"; //$NON-NLS-1$
/**
* Visible attribute. Value <code>visible</code>.
*/
// ATT_VISIBLE added by dan_rubel@instantiations.com
static const std::string ATT_VISIBLE; // "visible";//$NON-NLS-1$
/**
* Windowing system attribute. Value <code>ws</code>.
*/
static const std::string ATT_WS; // "ws"; //$NON-NLS-1$
/**
* The prefix that all auto-generated identifiers start with. This makes the
* identifier recognizable as auto-generated, and further helps ensure that
* it does not conflict with existing identifiers.
*/
static const std::string AUTOGENERATED_PREFIX; // "AUTOGEN:::"; //$NON-NLS-1$
/**
* The legacy extension point (2.1.x and earlier) for specifying a key
* binding scheme.
*
* @since 3.1.1
*/
static const std::string PL_ACCELERATOR_CONFIGURATIONS; // "acceleratorConfigurations"; //$NON-NLS-1$
/**
* The legacy extension point (2.1.x and earlier) for specifying a context.
*
* @since 3.1.1
*/
static const std::string PL_ACCELERATOR_SCOPES; // "acceleratorScopes"; //$NON-NLS-1$
/**
* The legacy extension point (2.1.x and earlier) for specifying a command.
*
* @since 3.1.1
*/
static const std::string PL_ACTION_DEFINITIONS; // "actionDefinitions"; //$NON-NLS-1$
static const std::string PL_ACTION_SET_PART_ASSOCIATIONS; // "actionSetPartAssociations"; //$NON-NLS-1$
static const std::string PL_ACTION_SETS; // "actionSets"; //$NON-NLS-1$
static const std::string PL_ACTIVITIES; // "activities"; //$NON-NLS-1$
static const std::string PL_ACTIVITYSUPPORT; // "activitySupport"; //$NON-NLS-1$
/**
* The extension point (3.1 and later) for specifying bindings, such as
* keyboard shortcuts.
*
* @since 3.1.1
*/
static const std::string PL_BINDINGS; // "bindings"; //$NON-NLS-1$
static const std::string PL_BROWSER_SUPPORT; // "browserSupport"; //$NON-NLS-1$
static const std::string PL_COLOR_DEFINITIONS; // "colorDefinitions"; //$NON-NLS-1$
/**
* The extension point (3.2 and later) for associating images with commands.
*
* @since 3.2
*/
static const std::string PL_COMMAND_IMAGES; // "commandImages"; //$NON-NLS-1$
/**
* The extension point (2.1.x and later) for specifying a command. A lot of
* other things have appeared first in this extension point and then been
* moved to their own extension point.
*
* @since 3.1.1
*/
static const std::string PL_COMMANDS; // "commands"; //$NON-NLS-1$
/**
* The extension point (3.0 and later) for specifying a context.
*
* @since 3.1.1
*/
static const std::string PL_CONTEXTS; // "contexts"; //$NON-NLS-1$
static const std::string PL_DECORATORS; // "decorators"; //$NON-NLS-1$
static const std::string PL_DROP_ACTIONS; // "dropActions"; //$NON-NLS-1$
static const std::string PL_EDITOR; // "editors"; //$NON-NLS-1$
static const std::string PL_EDITOR_ACTIONS; // "editorActions"; //$NON-NLS-1$
static const std::string PL_ELEMENT_FACTORY; // "elementFactories"; //$NON-NLS-1$
/**
* The extension point for encoding definitions.
*/
static const std::string PL_ENCODINGS; // "encodings"; //$NON-NLS-1$
static const std::string PL_EXPORT; // "exportWizards"; //$NON-NLS-1$
static const std::string PL_FONT_DEFINITIONS; // "fontDefinitions"; //$NON-NLS-1$
/**
* The extension point (3.1 and later) for specifying handlers.
*
* @since 3.1.1
*/
static const std::string PL_HANDLERS; // "handlers"; //$NON-NLS-1$
static const std::string PL_HELPSUPPORT; // "helpSupport"; //$NON-NLS-1$
static const std::string PL_IMPORT; // "importWizards"; //$NON-NLS-1$
static const std::string PL_INTRO; // "intro"; //$NON-NLS-1$
/**
* The extension point for keyword definitions.
*
* @since 3.1
*/
static const std::string PL_KEYWORDS; // "keywords"; //$NON-NLS-1$
/**
* The extension point (3.2 and later) for specifying menu contributions.
*
* @since 3.2
*/
static const std::string PL_MENUS; // "menus"; //$NON-NLS-1$
/**
* The extension point (3.3 and later) for specifying menu contributions.
*
* @since 3.3
*/
static const std::string PL_MENU_CONTRIBUTION; // "menuContribution"; //$NON-NLS-1$
static const std::string PL_NEW; // "newWizards"; //$NON-NLS-1$
static const std::string PL_PERSPECTIVE_EXTENSIONS; // "perspectiveExtensions"; //$NON-NLS-1$
static const std::string PL_PERSPECTIVES; // "perspectives"; //$NON-NLS-1$
static const std::string PL_POPUP_MENU; // "popupMenus"; //$NON-NLS-1$
static const std::string PL_PREFERENCE_TRANSFER; // "preferenceTransfer"; //$NON-NLS-1$
static const std::string PL_PREFERENCES; // "preferencePages"; //$NON-NLS-1$
static const std::string PL_PRESENTATION_FACTORIES; // "presentationFactories"; //$NON-NLS-1$
static const std::string PL_PROPERTY_PAGES; // "propertyPages"; //$NON-NLS-1$
static const std::string PL_STARTUP; // "startup"; //$NON-NLS-1$
/**
* @since 3.3
*/
static const std::string PL_SPLASH_HANDLERS; // "splashHandlers"; //$NON-NLS-1$
static const std::string PL_SYSTEM_SUMMARY_SECTIONS; // "systemSummarySections"; //$NON-NLS-1$
static const std::string PL_THEMES; // "themes"; //$NON-NLS-1$
static const std::string PL_VIEW_ACTIONS; // "viewActions"; //$NON-NLS-1$
static const std::string PL_VIEWS; // "views"; //$NON-NLS-1$
static const std::string PL_WORKINGSETS; // "workingSets"; //$NON-NLS-1$
/**
* The name of the deprecated accelerator configurations extension point.
*/
static const std::string EXTENSION_ACCELERATOR_CONFIGURATIONS;
/**
* The name of the accelerator scopes extension point.
*/
static const std::string EXTENSION_ACCELERATOR_SCOPES;
/**
* The name of the action definitions extension point.
*/
static const std::string EXTENSION_ACTION_DEFINITIONS;
/**
* The name of the <code>org.blueberry.ui.actionSets</code> extension point.
*/
static const std::string EXTENSION_ACTION_SETS;
/**
* The name of the bindings extension point.
*/
static const std::string EXTENSION_BINDINGS;
/**
* The name of the commands extension point.
*/
static const std::string EXTENSION_COMMAND_IMAGES;
/**
* The name of the commands extension point, and the name of the key for the
* commands preferences.
*/
static const std::string EXTENSION_COMMANDS;
/**
* The name of the contexts extension point.
*/
static const std::string EXTENSION_CONTEXTS;
/**
* The name of the <code>org.blueberry.ui.editorActions</code> extension
* point.
*/
static const std::string EXTENSION_EDITOR_ACTIONS;
/**
* The name of the commands extension point.
*/
static const std::string EXTENSION_HANDLERS;
/**
* The name of the <code>org.blueberry.ui.menus</code> extension point.
*/
static const std::string EXTENSION_MENUS;
/**
* The name of the <code>org.blueberry.ui.menus2</code> extension point.
*/
static const std::string COMMON_MENU_ADDITIONS;
/**
* The name of the <code>org.blueberry.ui.popupMenus</code> extension point.
*/
static const std::string EXTENSION_POPUP_MENUS;
/**
* The name of the <code>org.blueberry.ui.viewActions</code> extension
* point.
*/
static const std::string EXTENSION_VIEW_ACTIONS;
/**
* The constant for the position attribute corresponding to
* {@link SOrder#POSITION_AFTER}.
*/
static const std::string POSITION_AFTER; // "after"; //$NON-NLS-1$
/**
* The constant for the position attribute corresponding to
* {@link SOrder#POSITION_BEFORE}.
*/
static const std::string POSITION_BEFORE; // "before"; //$NON-NLS-1$
/**
* The constant for the position attribute corresponding to
* {@link SOrder#POSITION_END}.
*/
static const std::string POSITION_END; // "end"; //$NON-NLS-1$
/**
* The constant for the position attribute corresponding to
* {@link SOrder#POSITION_START}.
*/
static const std::string POSITION_START; // "start"; //$NON-NLS-1$
/**
* The action style for drop-down menus.
*/
static const std::string STYLE_PULLDOWN; // "pulldown"; //$NON-NLS-1$
/**
* The action style for radio buttons.
*/
static const std::string STYLE_RADIO; // "radio"; //$NON-NLS-1$
/**
* The action style for check boxes.
*/
static const std::string STYLE_TOGGLE; // "toggle"; //$NON-NLS-1$
/**
* The name of the deprecated accelerator configuration element. This
* element was used in 2.1.x and earlier to define groups of what are now
* called schemes.
*/
static const std::string TAG_ACCELERATOR_CONFIGURATION; // "acceleratorConfiguration"; //$NON-NLS-1$
/**
* The name of the element storing a deprecated accelerator scope.
*/
static const std::string TAG_ACCELERATOR_SCOPE; // "acceleratorScope"; //$NON-NLS-1$
/**
* Action tag. Value <code>action</code>.
*/
static const std::string TAG_ACTION; // "action"; //$NON-NLS-1$
/**
* The name of the element storing an action definition. This element only
* existed in
*/
static const std::string TAG_ACTION_DEFINITION; // "actionDefinition"; //$NON-NLS-1$
/**
* Action set tag. Value <code>actionSet</code>.
*/
static const std::string TAG_ACTION_SET; // "actionSet";//$NON-NLS-1$
/**
* Part association tag. Value <code>actionSetPartAssociation</code>.
*/
static const std::string TAG_ACTION_SET_PART_ASSOCIATION; // "actionSetPartAssociation";//$NON-NLS-1$
/**
* The name of the element storing the active key configuration from the
* commands extension point.
*/
static const std::string TAG_ACTIVE_KEY_CONFIGURATION; // "activeKeyConfiguration"; //$NON-NLS-1$
/**
* The name of the active when element, which appears on a handler
* definition.
*/
static const std::string TAG_ACTIVE_WHEN; // "activeWhen"; //$NON-NLS-1$
/**
* Activity image binding tag. Value <code>activityImageBindingw</code>.
*/
static const std::string TAG_ACTIVITY_IMAGE_BINDING; // "activityImageBinding"; //$NON-NLS-1$
/**
* Advisor to product binding element. Value
* <code>triggerPointAdvisorProductBinding</code>.
*/
static const std::string TAG_ADVISORPRODUCTBINDING; // "triggerPointAdvisorProductBinding"; //$NON-NLS-1$
/**
* The name of the bar element, which appears in a location definition.
*/
static const std::string TAG_BAR; // "bar"; //$NON-NLS-1$
/**
* Category tag. Value <code>category</code>.
*/
static const std::string TAG_CATEGORY; // "category";//$NON-NLS-1$
/**
* Category image binding tag. Value <code>categoryImageBinding</code>.
*/
static const std::string TAG_CATEGORY_IMAGE_BINDING; // "categoryImageBinding"; //$NON-NLS-1$
/**
* Element category tag. Value <code>themeElementCategory</code>.
*/
static const std::string TAG_CATEGORYDEFINITION; // "themeElementCategory"; //$NON-NLS-1$
/**
* Category presentation tag. Value <code>categoryPresentationBinding</code>.
*/
static const std::string TAG_CATEGORYPRESENTATIONBINDING; // "categoryPresentationBinding"; //$NON-NLS-1$
/**
* The name of the class element, which appears on an executable extension.
*/
static const std::string TAG_CLASS; // ATT_CLASS;
/**
* Color definition tag. Value <code>colorDefinition</code>.
*/
static const std::string TAG_COLORDEFINITION; // "colorDefinition"; //$NON-NLS-1$
/**
* Color override tag. Value <code>colorOverride</code>.
*/
static const std::string TAG_COLOROVERRIDE; // "colorOverride"; //$NON-NLS-1$
/**
* Color value tag. Value <code>colorValue</code>.
*/
static const std::string TAG_COLORVALUE; // "colorValue"; //$NON-NLS-1$
/**
* The name of the element storing a command.
*/
static const std::string TAG_COMMAND; // "command"; //$NON-NLS-1$
/**
* The name of the element storing a parameter.
*/
static const std::string TAG_COMMAND_PARAMETER; // "commandParameter"; //$NON-NLS-1$
/**
* The name of the element storing a parameter type.
*/
static const std::string TAG_COMMAND_PARAMETER_TYPE; // "commandParameterType"; //$NON-NLS-1$
/**
* Editor content type binding tag. Value <code>contentTypeBinding</code>.
*/
static const std::string TAG_CONTENT_TYPE_BINDING; // "contentTypeBinding"; //$NON-NLS-1$
/**
* The name of the element storing a context.
*/
static const std::string TAG_CONTEXT; // "context"; //$NON-NLS-1$
/**
* Data tag. Value <code>data</code>.
*/
static const std::string TAG_DATA; // "data"; //$NON-NLS-1$
/**
* The name of the default handler element, which appears on a command
* definition.
*/
static const std::string TAG_DEFAULT_HANDLER; // ATT_DEFAULT_HANDLER;
/**
* Description element. Value <code>description</code>.
*/
static const std::string TAG_DESCRIPTION; // "description"; //$NON-NLS-1$
/**
* The name of the dynamic menu element, which appears in a group or menu
* definition.
*/
static const std::string TAG_DYNAMIC; // "dynamic"; //$NON-NLS-1$
/**
* Editor tag. Value <code>editor</code>.
*/
static const std::string TAG_EDITOR; // "editor";//$NON-NLS-1$
/**
* The name of the deprecated editorContribution element. This is used for
* contributing actions to the top-level menus and tool bars when particular
* editors are visible.
*/
static const std::string TAG_EDITOR_CONTRIBUTION; // "editorContribution"; //$NON-NLS-1$
/**
* The name of the enabled when element, which appears on a handler
* definition.
*/
static const std::string TAG_ENABLED_WHEN; // "enabledWhen"; //$NON-NLS-1$
/**
* Enablement tag. Value <code>enablement</code>.
*/
static const std::string TAG_ENABLEMENT; // "enablement"; //$NON-NLS-1$
/**
* Entry tag. Value <code>entry</code>.
*/
static const std::string TAG_ENTRY; // "entry"; //$NON-NLS-1$
/**
* Filter tag. Value <code>filter</code>.
*/
static const std::string TAG_FILTER; // "filter"; //$NON-NLS-1$
/***************************************************************************
* Font definition tag. Value <code>fontDefinition</code>.
*/
static const std::string TAG_FONTDEFINITION; // "fontDefinition"; //$NON-NLS-1$
/**
* Font override tag. Value <code>fontOverride</code>.
*/
static const std::string TAG_FONTOVERRIDE; // "fontOverride"; //$NON-NLS-1$
/**
* Font value tag. Value <code>fontValue</code>.
*/
static const std::string TAG_FONTVALUE; // "fontValue"; //$NON-NLS-1$
/**
* The name of the element storing a group.
*/
static const std::string TAG_GROUP; // "group"; //$NON-NLS-1$
/**
* Group marker tag. Value <code>groupMarker</code>.
*/
static const std::string TAG_GROUP_MARKER; // "groupMarker"; //$NON-NLS-1$
/**
* The name of the element storing a handler.
*/
static const std::string TAG_HANDLER; // "handler"; //$NON-NLS-1$
/**
* The name of the element storing a handler submission.
*/
static const std::string TAG_HANDLER_SUBMISSION; // "handlerSubmission"; //$NON-NLS-1$
/**
* Trigger point hint tag. Value <code>hint</code>.
*/
static const std::string TAG_HINT; // "hint"; //$NON-NLS-1$
/**
* The name of the element storing an image.
*/
static const std::string TAG_IMAGE; // "image"; //$NON-NLS-1$
/**
* The name of the element storing a key binding.
*/
static const std::string TAG_KEY; // "key"; //$NON-NLS-1$
/**
* The name of the key binding element in the commands extension point.
*/
static const std::string TAG_KEY_BINDING; // "keyBinding"; //$NON-NLS-1$
/**
* The name of the deprecated key configuration element in the commands
* extension point. This element has been replaced with the scheme element
* in the bindings extension point.
*/
static const std::string TAG_KEY_CONFIGURATION; // "keyConfiguration"; //$NON-NLS-1$
/**
* The name of the element storing a location.
*/
static const std::string TAG_LOCATION; // "location"; //$NON-NLS-1$
/**
* The name of the element defining the insertion point for menu
* additions.
*
* @since 3.3
*/
static const std::string TAG_LOCATION_URI; // "locationURI"; //$NON-NLS-1$
/**
* The name of the element storing trim layout info for a widget.
*/
static const std::string TAG_LAYOUT; // "layout"; //$NON-NLS-1$
/**
* Mapping tag. Value <code>mapping</code>.
*/
static const std::string TAG_MAPPING; // "mapping"; //$NON-NLS-1$
/**
* Menu tag. Value <code>menu</code>.
*/
static const std::string TAG_MENU; // "menu"; //$NON-NLS-1$
/**
* Wizard shortcut tag. Value <code>newWizardShortcut</code>.
*/
static const std::string TAG_NEW_WIZARD_SHORTCUT; // "newWizardShortcut";//$NON-NLS-1$
/**
* Object contribution tag. Value <code>objectContribution</code>.
*/
static const std::string TAG_OBJECT_CONTRIBUTION; // "objectContribution";//$NON-NLS-1$
/**
* The name of the element storing the ordering information.
*/
static const std::string TAG_ORDER; // "order"; //$NON-NLS-1$
/**
* The name of the element storing a parameter.
*/
static const std::string TAG_PARAMETER; // "parameter"; //$NON-NLS-1$
/**
* Part tag. Value <code>part</code>.
*/
static const std::string TAG_PART; // "part";//$NON-NLS-1$
/**
* Perspective shortcut tag. Value <code>perspectiveShortcut</code>.
*/
static const std::string TAG_PERSP_SHORTCUT; // "perspectiveShortcut";//$NON-NLS-1$
/**
* Perspective tag. Value <code>perspective</code>.
*/
static const std::string TAG_PERSPECTIVE; // "perspective";//$NON-NLS-1$
/**
* Perspective extension tag. Value <code>perspectiveExtension</code>.
*/
static const std::string TAG_PERSPECTIVE_EXTENSION; // "perspectiveExtension";//$NON-NLS-1$
/**
* Primary wizard tag. Value <code>primaryWizard</code>.
*/
static const std::string TAG_PRIMARYWIZARD; // "primaryWizard"; //$NON-NLS-1$
/**
* The name of the element storing the a menu element reference.
*/
static const std::string TAG_REFERENCE; // "reference"; //$NON-NLS-1$
/**
* The name of the scheme element in the bindings extension point.
*/
static const std::string TAG_SCHEME; // "scheme"; //$NON-NLS-1$
/**
* The name of the element storing a deprecated scope.
*/
static const std::string TAG_SCOPE; // "scope"; //$NON-NLS-1$
/**
* Selectiont tag. Value <code>selection</code>.
*/
static const std::string TAG_SELECTION; // "selection"; //$NON-NLS-1$
/**
* Separator tag. Value <code>separator</code>.
*/
static const std::string TAG_SEPARATOR; // "separator"; //$NON-NLS-1$
/**
* Tag for the settings transfer entry.
*/
static const std::string TAG_SETTINGS_TRANSFER; // "settingsTransfer"; //$NON-NLS-1$
/**
* Show in part tag. Value <code>showInPart</code>.
*/
static const std::string TAG_SHOW_IN_PART; // "showInPart";//$NON-NLS-1$
/**
* The name of the element storing some state.
*/
static const std::string TAG_STATE; // "state"; //$NON-NLS-1$
/**
* The name of the element describing splash handlers. Value
* <code>splashHandler</code>.
* @since 3.3
*/
static const std::string TAG_SPLASH_HANDLER; // "splashHandler"; //$NON-NLS-1$
/**
* The name of the element describing splash handler product bindings. Value
* <code>splashHandlerProductBinding</code>.
* @since 3.3
*/
static const std::string TAG_SPLASH_HANDLER_PRODUCT_BINDING; // "splashHandlerProductBinding"; //$NON-NLS-1$
/**
* Sticky view tag. Value <code>stickyView</code>.
*/
static const std::string TAG_STICKYVIEW; // "stickyView";//$NON-NLS-1$
/**
* Browser support tag. Value <code>support</code>.
*/
static const std::string TAG_SUPPORT; // "support"; //$NON-NLS-1$
/**
* Theme tag. Value <code>theme</code>.
*/
static const std::string TAG_THEME; // "theme";//$NON-NLS-1$
/**
* Transfer tag. Value <code>transfer</code>.
*/
static const std::string TAG_TRANSFER; // "transfer";//$NON-NLS-1$
/**
* Trigger point tag. Value <code>triggerPoint</code>.
*/
static const std::string TAG_TRIGGERPOINT; // "triggerPoint"; //$NON-NLS-1$
/**
* Advisor tag. Value <code>triggerPointAdvisor</code>.
*/
static const std::string TAG_TRIGGERPOINTADVISOR; // "triggerPointAdvisor"; //$NON-NLS-1$
/**
* View tag. Value <code>view</code>.
*/
static const std::string TAG_VIEW; // "view";//$NON-NLS-1$
/**
* View shortcut tag. Value <code>viewShortcut</code>.
*/
static const std::string TAG_VIEW_SHORTCUT; // "viewShortcut";//$NON-NLS-1$
/**
* The name of the element storing a view contribution.
*/
static const std::string TAG_VIEW_CONTRIBUTION; // "viewContribution"; //$NON-NLS-1$
/**
* Viewer contribution tag. Value <code>viewerContribution</code>.
*/
static const std::string TAG_VIEWER_CONTRIBUTION; // "viewerContribution"; //$NON-NLS-1$
/**
* Visibility tag. Value <code>visibility</code>.
*/
static const std::string TAG_VISIBILITY; // "visibility"; //$NON-NLS-1$
/**
* The name of the element storing the visible when condition.
*/
static const std::string TAG_VISIBLE_WHEN; // "visibleWhen"; //$NON-NLS-1$
/**
* The name of the element storing a widget.
*/
static const std::string TAG_WIDGET; // "widget"; //$NON-NLS-1$
/**
* The name of the element storing a control hosted in a ToolBar.
*/
static const std::string TAG_CONTROL; // "control"; //$NON-NLS-1$
/**
* Wizard tag. Value <code>wizard</code>.
*/
static const std::string TAG_WIZARD; // "wizard";//$NON-NLS-1$
/**
* Working set tag. Value <code>workingSet</code>.
*/
static const std::string TAG_WORKING_SET; // "workingSet"; //$NON-NLS-1$
/**
* The type of reference which refers to a group.
*/
static const std::string TYPE_GROUP; // "group"; //$NON-NLS-1$
/**
* The type of reference which refers to an item.
*/
static const std::string TYPE_ITEM; // "item"; //$NON-NLS-1$
/**
* The type of reference which refers to an menu.
*/
static const std::string TYPE_MENU; // "menu"; //$NON-NLS-1$
/**
* The type of reference which refers to the widget.
*/
static const std::string TYPE_WIDGET; // "widget"; //$NON-NLS-1$
static const std::string TAG_TOOLBAR; // "toolbar"; //$NON-NLS-1$
static const std::string TAG_SERVICE_FACTORY; // "serviceFactory"; //$NON-NLS-1$
static const std::string TAG_SERVICE; // "service"; //$NON-NLS-1$
static const std::string ATTR_FACTORY_CLASS; // "factoryClass"; //$NON-NLS-1$
static const std::string ATTR_SERVICE_CLASS; // "serviceClass"; //$NON-NLS-1$
static const std::string TAG_SOURCE_PROVIDER; // "sourceProvider"; //$NON-NLS-1$
static const std::string ATTR_PROVIDER; // "provider"; //$NON-NLS-1$
static const std::string TAG_VARIABLE; // "variable"; //$NON-NLS-1$
static const std::string ATT_PRIORITY_LEVEL; // "priorityLevel"; //$NON-NLS-1$
static const std::string ATT_MODE; // "mode"; //$NON-NLS-1$
};
} // namespace berry
#endif // __BERRY_WORKBENCH_REGISTRY_CONSTANTS__
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchServiceRegistry.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchServiceRegistry.cpp
index d79816824e..d66039e72d 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchServiceRegistry.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchServiceRegistry.cpp
@@ -1,265 +1,265 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryLog.h"
#include "berryWorkbenchServiceRegistry.h"
#include "berryISources.h"
#include "berryISourceProvider.h"
#include "berryPlatformUI.h"
#include "berryImageDescriptor.h"
#include "services/berryIServiceFactory.h"
#include "berryServiceLocator.h"
#include "berryWorkbenchPlugin.h"
#include "berryWorkbenchRegistryConstants.h"
#include "berrySourcePriorityNameMapping.h"
#include <berryIExtensionPointService.h>
namespace berry
{
const std::string WorkbenchServiceRegistry::WORKBENCH_LEVEL = "workbench"; //$NON-NLS-1$
const std::string WorkbenchServiceRegistry::EXT_ID_SERVICES =
"org.blueberry.ui.services"; //$NON-NLS-1$
WorkbenchServiceRegistry* WorkbenchServiceRegistry::registry = 0;
const IServiceLocator::Pointer WorkbenchServiceRegistry::GLOBAL_PARENT =
IServiceLocator::Pointer(new GlobalParentLocator());
std::string* WorkbenchServiceRegistry::supportedLevels()
{
static std::string levels[] = {
ISources::ACTIVE_CONTEXT_NAME(),
ISources::ACTIVE_SHELL_NAME(),
ISources::ACTIVE_WORKBENCH_WINDOW_NAME(),
ISources::ACTIVE_EDITOR_ID_NAME(),
ISources::ACTIVE_PART_ID_NAME(),
ISources::ACTIVE_SITE_NAME() };
return levels;
}
const unsigned int WorkbenchServiceRegistry::supportedLevelsCount = 6;
WorkbenchServiceRegistry::WorkbenchServiceRegistry()
{
// PlatformUI::GetWorkbench().getExtensionTracker().registerHandler(this,
// ExtensionTracker .createExtensionPointFilter(getExtensionPoint()));
}
WorkbenchServiceRegistry::ServiceFactoryHandle::ServiceFactoryHandle(
IServiceFactory::ConstPointer _factory)
: factory(_factory)
{
}
WorkbenchServiceRegistry::ServiceFactoryHandle::Pointer WorkbenchServiceRegistry::LoadFromRegistry(
const std::string& key)
{
ServiceFactoryHandle::Pointer result;
const std::vector<IConfigurationElement::Pointer> serviceFactories =
this->GetExtensionPoint()->GetConfigurationElements();
try
{
bool done = false;
for (unsigned int i = 0; i < serviceFactories.size() && !done; i++)
{
std::vector<IConfigurationElement::Pointer> serviceNameElements =
serviceFactories[i]->GetChildren(
WorkbenchRegistryConstants::TAG_SERVICE);
for (unsigned int j = 0; j < serviceNameElements.size() && !done; j++)
{
std::string serviceName;
serviceNameElements[j]->GetAttribute(
WorkbenchRegistryConstants::ATTR_SERVICE_CLASS, serviceName);
if (key == serviceName)
{
done = true;
}
}
if (done)
{
IServiceFactory::Pointer f(
serviceFactories[i]->CreateExecutableExtension<IServiceFactory>(
WorkbenchRegistryConstants::ATTR_FACTORY_CLASS));
if (f.IsNull())
{
// support legacy BlueBerry extensions
f = serviceFactories[i]->CreateExecutableExtension<IServiceFactory>(
WorkbenchRegistryConstants::ATTR_FACTORY_CLASS, IServiceFactory::GetManifestName());
}
ServiceFactoryHandle::Pointer handle(new ServiceFactoryHandle(f));
// PlatformUI.getWorkbench().getExtensionTracker().registerObject(
// serviceFactories[i].getDeclaringExtension(), handle,
// IExtensionTracker.REF_WEAK);
std::vector<std::string> serviceNames;
for (unsigned int j = 0; j < serviceNameElements.size(); j++)
{
std::string serviceName;
serviceNameElements[j]->GetAttribute(
WorkbenchRegistryConstants::ATTR_SERVICE_CLASS, serviceName);
if (factories.find(serviceName) != factories.end())
{
WorkbenchPlugin::Log("Factory already exists for " + serviceName);
}
else
{
factories.insert(std::make_pair(serviceName, handle));
serviceNames.push_back(serviceName);
}
}
handle->serviceNames = serviceNames;
result = handle;
}
}
} catch (CoreException& e)
{
//StatusManager.getManager().handle(e.getStatus());
BERRY_ERROR << "CoreException: " << e.displayText() << std::endl;
}
return result;
}
const IExtensionPoint* WorkbenchServiceRegistry::GetExtensionPoint()
{
IExtensionPointService::Pointer reg = Platform::GetExtensionPointService();
const IExtensionPoint* ep = reg->GetExtensionPoint(EXT_ID_SERVICES);
return ep;
}
void WorkbenchServiceRegistry::ProcessVariables(
const std::vector<IConfigurationElement::Pointer>& children)
{
for (unsigned int i = 0; i < children.size(); i++)
{
std::string name;
children[i]->GetAttribute(WorkbenchRegistryConstants::ATT_NAME, name);
if (name.empty())
{
continue;
}
std::string level;
children[i]->GetAttribute(WorkbenchRegistryConstants::ATT_PRIORITY_LEVEL, level);
if (level.empty())
{
level = WORKBENCH_LEVEL;
}
else
{
bool found = false;
const std::string* const supportedLevels = this->supportedLevels();
for (unsigned int j = 0; j < supportedLevelsCount && !found; j++)
{
if (supportedLevels[j] == level)
{
found = true;
}
}
if (!found)
{
level = WORKBENCH_LEVEL;
}
}
int existingPriority = SourcePriorityNameMapping::GetMapping(level);
int newPriority = existingPriority << 1;
SourcePriorityNameMapping::AddMapping(name, newPriority);
}
}
Object::Pointer WorkbenchServiceRegistry::GlobalParentLocator::GetService(
const std::string& /*api*/)
{
return Object::Pointer(0);
}
bool WorkbenchServiceRegistry::GlobalParentLocator::HasService(
const std::string& /*api*/) const
{
return false;
}
WorkbenchServiceRegistry* WorkbenchServiceRegistry::GetRegistry()
{
if (registry == 0)
{
registry = new WorkbenchServiceRegistry();
}
return registry;
}
Object::Pointer WorkbenchServiceRegistry::GetService(const std::string& key,
const IServiceLocator::Pointer parentLocator, const ServiceLocator::ConstPointer locator)
{
ServiceFactoryHandle::Pointer handle(factories[key]);
if (!handle)
{
handle = this->LoadFromRegistry(key);
}
if (handle)
{
Object::Pointer result(handle->factory->Create(key, parentLocator, locator));
if (result)
{
//handle->serviceLocators.insert(locator, new Object());
return result;
}
}
return Object::Pointer(0);
}
std::vector<ISourceProvider::Pointer> WorkbenchServiceRegistry::GetSourceProviders()
{
std::vector<ISourceProvider::Pointer> providers;
const IExtensionPoint* ep = this->GetExtensionPoint();
std::vector<IConfigurationElement::Pointer> elements =
ep->GetConfigurationElements();
for (unsigned int i = 0; i < elements.size(); i++)
{
if (elements[i]->GetName() ==
WorkbenchRegistryConstants::TAG_SOURCE_PROVIDER)
{
try
{
ISourceProvider::Pointer provider(elements[i]->CreateExecutableExtension<ISourceProvider>(
WorkbenchRegistryConstants::ATTR_PROVIDER));
if (provider.IsNull())
{
// support legacy BlueBerry extensions
provider = elements[i]->CreateExecutableExtension<ISourceProvider>(
WorkbenchRegistryConstants::ATTR_PROVIDER, ISourceProvider::GetManifestName());
}
providers.push_back(provider);
this->ProcessVariables(elements[i]->GetChildren(
WorkbenchRegistryConstants::TAG_VARIABLE));
} catch (CoreException& e)
{
//StatusManager.getManager().handle(e.getStatus());
BERRY_ERROR << "CoreException: " << e.displayText() << std::endl;
}
}
}
return providers;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchServiceRegistry.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchServiceRegistry.h
index a66248c534..890a429469 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchServiceRegistry.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchServiceRegistry.h
@@ -1,146 +1,146 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYWORKBENCHSERVICEREGISTRY_H_
#define BERRYWORKBENCHSERVICEREGISTRY_H_
#include "services/berryIServiceLocator.h"
#include <vector>
#include <map>
namespace berry
{
struct ISourceProvider;
struct IServiceFactory;
struct IExtensionPoint;
struct IConfigurationElement;
class ServiceLocator;
/**
* This class will create a service from the matching factory. If the factory
* doesn't exist, it will try and load it from the registry.
*
* @since 3.4
*/
class WorkbenchServiceRegistry
{ // implements IExtensionChangeHandler {
private:
/**
*
*/
static const std::string WORKBENCH_LEVEL; // = "workbench"; //$NON-NLS-1$
static const std::string EXT_ID_SERVICES; // = "org.blueberry.ui.services"; //$NON-NLS-1$
static WorkbenchServiceRegistry* registry; // = 0;
WorkbenchServiceRegistry();
struct ServiceFactoryHandle : public Object
{
berryObjectMacro(ServiceFactoryHandle)
SmartPointer<const IServiceFactory> factory;
// TODO used in removeExtension to react to bundles being unloaded
//WeakHashMap serviceLocators = new WeakHashMap();
std::vector<std::string> serviceNames;
ServiceFactoryHandle(SmartPointer<const IServiceFactory> factory);
};
std::map<std::string, ServiceFactoryHandle::Pointer> factories;
ServiceFactoryHandle::Pointer LoadFromRegistry(const std::string& key);
const IExtensionPoint* GetExtensionPoint();
static std::string* supportedLevels();
static const unsigned int supportedLevelsCount;
void ProcessVariables(
const std::vector<SmartPointer<IConfigurationElement> >& children);
struct GlobalParentLocator: public IServiceLocator
{
Object::Pointer GetService(const std::string& api);
bool HasService(const std::string& api) const;
};
public:
static WorkbenchServiceRegistry* GetRegistry();
/**
* Used as the global service locator's parent.
*/
static const IServiceLocator::Pointer GLOBAL_PARENT; // = new GlobalParentLocator();
Object::Pointer GetService(const std::string& key,
const IServiceLocator::Pointer parentLocator, const SmartPointer<const ServiceLocator> locator);
std::vector<SmartPointer<ISourceProvider> > GetSourceProviders();
// void addExtension(IExtensionTracker tracker, IExtension extension) {
// // we don't need to react to adds because we are not caching the extensions we find -
// // next time a service is requested, we will look at all extensions again in
// // loadFromRegistry
// }
// void removeExtension(IExtension extension, Object[] objects) {
// for (int i = 0; i < objects.length; i++) {
// Object object = objects[i];
// if (object instanceof ServiceFactoryHandle) {
// ServiceFactoryHandle handle = (ServiceFactoryHandle) object;
// Set locatorSet = handle.serviceLocators.keySet();
// ServiceLocator[] locators = (ServiceLocator[]) locatorSet.toArray(new ServiceLocator[locatorSet.size()]);
// Arrays.sort(locators, new Comparator(){
// public int compare(Object o1, Object o2) {
// ServiceLocator loc1 = (ServiceLocator) o1;
// ServiceLocator loc2 = (ServiceLocator) o2;
// int l1 = ((IWorkbenchLocationService) loc1
// .getService(IWorkbenchLocationService.class))
// .getServiceLevel();
// int l2 = ((IWorkbenchLocationService) loc2
// .getService(IWorkbenchLocationService.class))
// .getServiceLevel();
// return l1 < l2 ? -1 : (l1 > l2 ? 1 : 0);
// }
// });
// for (int j = 0; j < locators.length; j++) {
// ServiceLocator serviceLocator = locators[j];
// if (!serviceLocator.isDisposed()) {
// serviceLocator.unregisterServices(handle.serviceNames);
// }
// }
// handle.factory = null;
// for (int j = 0; j < handle.serviceNames.length; j++) {
// String serviceName = handle.serviceNames[j];
// if (factories.get(serviceName) == handle) {
// factories.remove(serviceName);
// }
// }
// }
// }
// }
};
}
#endif /* BERRYWORKBENCHSERVICEREGISTRY_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchTestable.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchTestable.cpp
index 413a8f881f..b4ded45ca3 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchTestable.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchTestable.cpp
@@ -1,109 +1,109 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryWorkbenchTestable.h"
#include "berryDisplay.h"
#include "berryIWorkbench.h"
#include <Poco/Thread.h>
namespace berry
{
WorkbenchTestable::WorkbenchTestRunnable::WorkbenchTestRunnable(TestableObject* testable) :
testable(testable)
{
}
void WorkbenchTestable::WorkbenchTestRunnable::run()
{
// // Some tests (notably the startup performance tests) do not want to wait for early startup.
// // Allow this to be disabled by specifying the system property: org.eclipse.ui.testsWaitForEarlyStartup=false
// // For details, see bug 94129 [Workbench] Performance test regression caused by workbench harness change
// if (!"false".equalsIgnoreCase(System.getProperty(PlatformUI.PLUGIN_ID + ".testsWaitForEarlyStartup"))) { //$NON-NLS-1$ //$NON-NLS-2$
// waitForEarlyStartup();
// }
testable->GetTestHarness()->RunTests();
}
class WorkbenchCloseRunnable: public Poco::Runnable
{
public:
WorkbenchCloseRunnable(IWorkbench* workbench) :
workbench(workbench)
{
}
void run()
{
poco_assert(workbench->Close());
}
private:
IWorkbench* workbench;
};
WorkbenchTestable::WorkbenchTestable()
: thread("WorkbenchTestable"), testRunnable(this)
{
// do nothing
}
void WorkbenchTestable::Init(Display* display, IWorkbench* workbench)
{
poco_assert(display);
poco_assert(workbench);
this->display = display;
this->workbench = workbench;
if (GetTestHarness())
{
// don't use a job, since tests often wait for all jobs to complete before proceeding
thread.start(testRunnable);
}
}
void WorkbenchTestable::TestingStarting()
{
poco_assert(workbench);
// oldAutomatedMode = ErrorDialog.AUTOMATED_MODE;
// ErrorDialog.AUTOMATED_MODE = true;
// oldIgnoreErrors = SafeRunnable.getIgnoreErrors();
// SafeRunnable.setIgnoreErrors(true);
}
void WorkbenchTestable::RunTest(Poco::Runnable* testRunnable)
{
poco_assert(workbench);
display->SyncExec(testRunnable);
}
void WorkbenchTestable::TestingFinished()
{
// force events to be processed, and ensure the close is done in the UI thread
WorkbenchCloseRunnable runnable(workbench);
display->SyncExec(&runnable);
// ErrorDialog.AUTOMATED_MODE = oldAutomatedMode;
// SafeRunnable.setIgnoreErrors(oldIgnoreErrors);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchTestable.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchTestable.h
index bdbdaff319..17a7d16c63 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchTestable.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchTestable.h
@@ -1,124 +1,124 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYWORKBENCHTESTABLE_H_
#define BERRYWORKBENCHTESTABLE_H_
#include "testing/berryTestableObject.h"
#include <Poco/Thread.h>
namespace berry
{
class Display;
struct IWorkbench;
/**
* The Workbench's testable object facade to a test harness.
*
* @since 3.0
*/
class WorkbenchTestable: public TestableObject
{
private:
Display* display;
IWorkbench* workbench;
bool oldAutomatedMode;
bool oldIgnoreErrors;
Poco::Thread thread;
class WorkbenchTestRunnable: public Poco::Runnable
{
public:
WorkbenchTestRunnable(TestableObject* testable);
void run();
private:
TestableObject* testable;
};
WorkbenchTestRunnable testRunnable;
public:
berryObjectMacro( WorkbenchTestable)
/**
* Constructs a new workbench testable object.
*/
WorkbenchTestable();
/**
* Initializes the workbench testable with the display and workbench,
* and notifies all listeners that the tests can be run.
*
* @param display the display
* @param workbench the workbench
*/
void Init(Display* display, IWorkbench* workbench);
/**
* The <code>WorkbenchTestable</code> implementation of this
* <code>TestableObject</code> method ensures that the workbench
* has been set.
*/
void TestingStarting();
/**
* The <code>WorkbenchTestable</code> implementation of this
* <code>TestableObject</code> method flushes the event queue,
* runs the test in a <code>syncExec</code>, then flushes the
* event queue again.
*/
void RunTest(Poco::Runnable* testRunnable);
/**
* The <code>WorkbenchTestable</code> implementation of this
* <code>TestableObject</code> method flushes the event queue,
* then closes the workbench.
*/
void TestingFinished();
private:
/**
* Waits for the early startup job to complete.
*/
// void WaitForEarlyStartup() {
// try {
// Job::GetJobManager()->Join(Workbench::EARLY_STARTUP_FAMILY, 0);
// } catch (OperationCanceledException e) {
// // ignore
// } catch (InterruptedException e) {
// // ignore
// }
// }
};
}
#endif /* BERRYWORKBENCHTESTABLE_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchWindow.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchWindow.cpp
index 01b256f73c..a194d26130 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchWindow.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchWindow.cpp
@@ -1,1778 +1,1778 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryWorkbenchWindow.h"
#include "berryIWorkbenchPage.h"
#include "berryIPerspectiveDescriptor.h"
#include "berryUIException.h"
#include "berryConstants.h"
#include "intro/berryIntroConstants.h"
#include "berryWorkbenchPlugin.h"
#include "berryWorkbenchPage.h"
#include "berryWorkbench.h"
#include "berryWorkbenchConstants.h"
#include "berryPartSite.h"
#include "berryIServiceLocatorCreator.h"
#include "tweaklets/berryGuiWidgetsTweaklet.h"
#include "tweaklets/berryWorkbenchTweaklet.h"
#include "services/berryIServiceFactory.h"
#include "berryPlatformUI.h"
#include "berryDebugUtil.h"
namespace berry
{
const int WorkbenchWindow::FILL_ALL_ACTION_BARS =
ActionBarAdvisor::FILL_MENU_BAR | ActionBarAdvisor::FILL_COOL_BAR
| ActionBarAdvisor::FILL_STATUS_LINE;
WorkbenchWindow::WorkbenchWindow(int number) :
Window(Shell::Pointer(0)), pageComposite(0), windowAdvisor(0),
actionBarAdvisor(0), number(number), largeUpdates(0), closing(false),
shellActivated(false), updateDisabled(true), emptyWindowContentsCreated(
false), emptyWindowContents(0), asMaximizedState(false), partService(
this), serviceLocatorOwner(
new ServiceLocatorOwner(this))
{
this->Register(); // increase the reference count to avoid deleting
// this object when temporary smart pointers
// go out of scope
// Make sure there is a workbench. This call will throw
// an exception if workbench not created yet.
IWorkbench* workbench = PlatformUI::GetWorkbench();
IServiceLocatorCreator::Pointer slc =
workbench->GetService(IServiceLocatorCreator::GetManifestName()).Cast<
IServiceLocatorCreator> ();
IServiceLocator::Pointer locator(workbench);
this->serviceLocator = slc->CreateServiceLocator(IServiceLocator::WeakPtr(
locator), IServiceFactory::ConstPointer(0), IDisposable::WeakPtr(
serviceLocatorOwner)).Cast<ServiceLocator> ();
// initializeDefaultServices();
// Add contribution managers that are exposed to other plugins.
//addMenuBar();
//addCoolBar(SWT.NONE); // style is unused
//addStatusLine();
this->FireWindowOpening();
// Fill the action bars
this->FillActionBars(FILL_ALL_ACTION_BARS);
this->UnRegister(false); // decrease reference count and avoid deleting
// the window
}
WorkbenchWindow::~WorkbenchWindow()
{
//BERRY_INFO << "WorkbenchWindow::~WorkbenchWindow()";
}
Object::Pointer WorkbenchWindow::GetService(const std::string& key)
{
return serviceLocator->GetService(key);
}
bool WorkbenchWindow::HasService(const std::string& key) const
{
return serviceLocator->HasService(key);
}
Shell::Pointer WorkbenchWindow::GetShell()
{
return Window::GetShell();
}
bool WorkbenchWindow::ClosePage(IWorkbenchPage::Pointer in, bool save)
{
// Validate the input.
if (!pageList.Contains(in))
{
return false;
}
WorkbenchPage::Pointer oldPage = in.Cast<WorkbenchPage> ();
// Save old perspective.
if (save && oldPage->IsSaveNeeded())
{
if (!oldPage->SaveAllEditors(true))
{
return false;
}
}
// If old page is activate deactivate.
bool oldIsActive = (oldPage == this->GetActivePage());
if (oldIsActive)
{
this->SetActivePage(IWorkbenchPage::Pointer(0));
}
// Close old page.
pageList.Remove(oldPage);
partService.PageClosed(oldPage);
//this->FirePageClosed(oldPage);
//oldPage->Dispose();
// Activate new page.
if (oldIsActive)
{
IWorkbenchPage::Pointer newPage = pageList.GetNextActive();
if (newPage != 0)
{
this->SetActivePage(newPage);
}
}
if (!closing && pageList.IsEmpty())
{
this->ShowEmptyWindowContents();
}
return true;
}
void WorkbenchWindow::AddPerspectiveListener(IPerspectiveListener::Pointer l)
{
perspectiveEvents.AddListener(l);
}
void WorkbenchWindow::RemovePerspectiveListener(IPerspectiveListener::Pointer l)
{
perspectiveEvents.RemoveListener(l);
}
IPerspectiveListener::Events& WorkbenchWindow::GetPerspectiveEvents()
{
return perspectiveEvents;
}
void WorkbenchWindow::FireWindowOpening()
{
// let the application do further configuration
this->GetWindowAdvisor()->PreWindowOpen();
}
void WorkbenchWindow::FireWindowRestored()
{
//StartupThreading.runWithWorkbenchExceptions(new StartupRunnable() {
// public void runWithException() throws Throwable {
this->GetWindowAdvisor()->PostWindowRestore();
// }
//});
}
void WorkbenchWindow::FireWindowCreated()
{
this->GetWindowAdvisor()->PostWindowCreate();
}
void WorkbenchWindow::FireWindowOpened()
{
this->GetWorkbenchImpl()->FireWindowOpened(IWorkbenchWindow::Pointer(this));
this->GetWindowAdvisor()->PostWindowOpen();
}
bool WorkbenchWindow::FireWindowShellClosing()
{
return this->GetWindowAdvisor()->PreWindowShellClose();
}
void WorkbenchWindow::FireWindowClosed()
{
// let the application do further deconfiguration
this->GetWindowAdvisor()->PostWindowClose();
this->GetWorkbenchImpl()->FireWindowClosed(IWorkbenchWindow::Pointer(this));
}
///**
// * Fires page activated
// */
//void WorkbenchWindow::FirePageActivated(IWorkbenchPage::Pointer page) {
//// String label = null; // debugging only
//// if (UIStats.isDebugging(UIStats.NOTIFY_PAGE_LISTENERS)) {
//// label = "activated " + page.getLabel(); //$NON-NLS-1$
//// }
//// try {
//// UIStats.start(UIStats.NOTIFY_PAGE_LISTENERS, label);
//// UIListenerLogging.logPageEvent(this, page,
//// UIListenerLogging.WPE_PAGE_ACTIVATED);
// pageEvents.FirePageActivated(page);
// partService.pageActivated(page);
//// } finally {
//// UIStats.end(UIStats.NOTIFY_PAGE_LISTENERS, page.getLabel(), label);
//// }
//}
//
///**
// * Fires page closed
// */
//void WorkbenchWindow::FirePageClosed(IWorkbenchPage::Pointer page) {
// String label = null; // debugging only
// if (UIStats.isDebugging(UIStats.NOTIFY_PAGE_LISTENERS)) {
// label = "closed " + page.getLabel(); //$NON-NLS-1$
// }
// try {
// UIStats.start(UIStats.NOTIFY_PAGE_LISTENERS, label);
// UIListenerLogging.logPageEvent(this, page,
// UIListenerLogging.WPE_PAGE_CLOSED);
// pageListeners.firePageClosed(page);
// partService.pageClosed(page);
// } finally {
// UIStats.end(UIStats.NOTIFY_PAGE_LISTENERS, page.getLabel(), label);
// }
//
//}
//
///**
// * Fires page opened
// */
//void WorkbenchWindow::FirePageOpened(IWorkbenchPage::Pointer page) {
// String label = null; // debugging only
// if (UIStats.isDebugging(UIStats.NOTIFY_PAGE_LISTENERS)) {
// label = "opened " + page.getLabel(); //$NON-NLS-1$
// }
// try {
// UIStats.start(UIStats.NOTIFY_PAGE_LISTENERS, label);
// UIListenerLogging.logPageEvent(this, page,
// UIListenerLogging.WPE_PAGE_OPENED);
// pageListeners.firePageOpened(page);
// partService.pageOpened(page);
// } finally {
// UIStats.end(UIStats.NOTIFY_PAGE_LISTENERS, page.getLabel(), label);
// }
//}
void WorkbenchWindow::FirePerspectiveActivated(IWorkbenchPage::Pointer page,
IPerspectiveDescriptor::Pointer perspective)
{
// UIListenerLogging.logPerspectiveEvent(this, page, perspective,
// UIListenerLogging.PLE_PERSP_ACTIVATED);
perspectiveEvents.perspectiveActivated(page, perspective);
}
void WorkbenchWindow::FirePerspectivePreDeactivate(
IWorkbenchPage::Pointer page, IPerspectiveDescriptor::Pointer perspective)
{
// UIListenerLogging.logPerspectiveEvent(this, page, perspective,
// UIListenerLogging.PLE_PERSP_PRE_DEACTIVATE);
perspectiveEvents.perspectivePreDeactivate(page, perspective);
}
void WorkbenchWindow::FirePerspectiveDeactivated(IWorkbenchPage::Pointer page,
IPerspectiveDescriptor::Pointer perspective)
{
// UIListenerLogging.logPerspectiveEvent(this, page, perspective,
// UIListenerLogging.PLE_PERSP_DEACTIVATED);
perspectiveEvents.perspectiveDeactivated(page, perspective);
}
void WorkbenchWindow::FirePerspectiveChanged(IWorkbenchPage::Pointer page,
IPerspectiveDescriptor::Pointer perspective, const std::string& changeId)
{
// Some callers call this even when there is no active perspective.
// Just ignore this case.
if (perspective != 0)
{
// UIListenerLogging.logPerspectiveChangedEvent(this, page,
// perspective, null, changeId);
perspectiveEvents.perspectiveChanged(page, perspective, changeId);
}
}
void WorkbenchWindow::FirePerspectiveChanged(IWorkbenchPage::Pointer page,
IPerspectiveDescriptor::Pointer perspective,
IWorkbenchPartReference::Pointer partRef, const std::string& changeId)
{
// Some callers call this even when there is no active perspective.
// Just ignore this case.
if (perspective != 0)
{
// UIListenerLogging.logPerspectiveChangedEvent(this, page,
// perspective, partRef, changeId);
perspectiveEvents.perspectivePartChanged(page, perspective, partRef,
changeId);
}
}
void WorkbenchWindow::FirePerspectiveClosed(IWorkbenchPage::Pointer page,
IPerspectiveDescriptor::Pointer perspective)
{
// UIListenerLogging.logPerspectiveEvent(this, page, perspective,
// UIListenerLogging.PLE_PERSP_CLOSED);
perspectiveEvents.perspectiveClosed(page, perspective);
}
void WorkbenchWindow::FirePerspectiveOpened(IWorkbenchPage::Pointer page,
IPerspectiveDescriptor::Pointer perspective)
{
// UIListenerLogging.logPerspectiveEvent(this, page, perspective,
// UIListenerLogging.PLE_PERSP_OPENED);
perspectiveEvents.perspectiveOpened(page, perspective);
}
void WorkbenchWindow::FirePerspectiveSavedAs(IWorkbenchPage::Pointer page,
IPerspectiveDescriptor::Pointer oldPerspective,
IPerspectiveDescriptor::Pointer newPerspective)
{
// UIListenerLogging.logPerspectiveSavedAs(this, page, oldPerspective,
// newPerspective);
perspectiveEvents.perspectiveSavedAs(page, oldPerspective, newPerspective);
}
void WorkbenchWindow::FillActionBars(int flags)
{
// Workbench workbench = getWorkbenchImpl();
// workbench.largeUpdateStart();
//try {
this->GetActionBarAdvisor()->FillActionBars(flags);
// final IMenuService menuService = (IMenuService) serviceLocator
// .getService(IMenuService.class);
// menuService.populateContributionManager(
// (ContributionManager) getActionBars().getMenuManager(),
// MenuUtil.MAIN_MENU);
// ICoolBarManager coolbar = getActionBars().getCoolBarManager();
// if (coolbar != null) {
// menuService.populateContributionManager(
// (ContributionManager) coolbar,
// MenuUtil.MAIN_TOOLBAR);
// }
//
// } finally {
// workbench.largeUpdateEnd();
// }
}
Point WorkbenchWindow::GetInitialSize()
{
return this->GetWindowConfigurer()->GetInitialSize();
}
bool WorkbenchWindow::Close()
{
//BERRY_INFO << "WorkbenchWindow::Close()";
if (controlResizeListener)
{
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->RemoveControlListener(GetShell()->GetControl(), controlResizeListener);
}
bool ret = false;
//BusyIndicator.showWhile(null, new Runnable() {
// public void run() {
ret = this->BusyClose();
// }
// });
if (!ret && controlResizeListener)
{
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->AddControlListener(GetShell()->GetControl(), controlResizeListener);
}
return ret;
}
bool WorkbenchWindow::BusyClose()
{
// Whether the window was actually closed or not
bool windowClosed = false;
// Setup internal flags to indicate window is in
// progress of closing and no update should be done.
closing = true;
updateDisabled = true;
try
{
// Only do the check if it is OK to close if we are not closing
// via the workbench as the workbench will check this itself.
Workbench* workbench = this->GetWorkbenchImpl();
std::size_t count = workbench->GetWorkbenchWindowCount();
// also check for starting - if the first window dies on startup
// then we'll need to open a default window.
if (!workbench->IsStarting() && !workbench->IsClosing() && count <= 1
&& workbench->GetWorkbenchConfigurer() ->GetExitOnLastWindowClose())
{
windowClosed = workbench->Close();
}
else
{
if (this->OkToClose())
{
windowClosed = this->HardClose();
}
}
} catch (std::exception& exc)
{
if (!windowClosed)
{
// Reset the internal flags if window was not closed.
closing = false;
updateDisabled = false;
}
throw exc;
}
// if (windowClosed && tracker != null) {
// tracker.close();
// }
return windowClosed;
}
void WorkbenchWindow::MakeVisible()
{
Shell::Pointer shell = GetShell();
if (shell)
{
// see bug 96700 and bug 4414 for a discussion on the use of open()
// here
shell->Open();
}
}
bool WorkbenchWindow::OkToClose()
{
// Save all of the editors.
if (!this->GetWorkbenchImpl()->IsClosing())
{
if (!this->SaveAllPages(true))
{
return false;
}
}
return true;
}
bool WorkbenchWindow::SaveAllPages(bool bConfirm)
{
bool bRet = true;
PageList::iterator itr = pageList.Begin();
while (bRet && itr != pageList.End())
{
bRet = (*itr)->SaveAllEditors(bConfirm);
++itr;
}
return bRet;
}
bool WorkbenchWindow::HardClose()
{
std::exception exc;
bool exceptionOccured = false;
try
{
// Clear the action sets, fix for bug 27416.
//getActionPresentation().clearActionSets();
// Remove the handler submissions. Bug 64024.
/*
final IWorkbench workbench = getWorkbench();
final IHandlerService handlerService = (IHandlerService) workbench.getService(IHandlerService.class);
handlerService.deactivateHandlers(handlerActivations);
final Iterator activationItr = handlerActivations.iterator();
while (activationItr.hasNext()) {
final IHandlerActivation activation = (IHandlerActivation) activationItr
.next();
activation.getHandler().dispose();
}
handlerActivations.clear();
globalActionHandlersByCommandId.clear();
*/
// Remove the enabled submissions. Bug 64024.
/*
final IContextService contextService = (IContextService) workbench.getService(IContextService.class);
contextService.unregisterShell(getShell());
*/
this->CloseAllPages();
this->FireWindowClosed();
// time to wipe out our populate
/*
IMenuService menuService = (IMenuService) workbench
.getService(IMenuService.class);
menuService
.releaseContributions(((ContributionManager) getActionBars()
.getMenuManager()));
ICoolBarManager coolbar = getActionBars().getCoolBarManager();
if (coolbar != null) {
menuService
.releaseContributions(((ContributionManager) coolbar));
}
*/
//getActionBarAdvisor().dispose();
//getWindowAdvisor().dispose();
//detachedWindowShells.dispose();
delete windowAdvisor;
windowAdvisor = 0;
// Null out the progress region. Bug 64024.
//progressRegion = null;
// Remove drop targets
/*
DragUtil.removeDragTarget(null, trimDropTarget);
DragUtil.removeDragTarget(getShell(), trimDropTarget);
trimDropTarget = null;
if (trimMgr2 != null) {
trimMgr2.dispose();
trimMgr2 = null;
}
if (trimContributionMgr != null) {
trimContributionMgr.dispose();
trimContributionMgr = null;
}
*/
} catch (std::exception& e)
{
exc = e;
exceptionOccured = true;
}
bool result = Window::Close();
// Bring down all of the services ... after the window goes away
serviceLocator->Dispose();
//menuRestrictions.clear();
if (exceptionOccured)
throw exc;
return result;
}
void WorkbenchWindow::CloseAllPages()
{
// Deactivate active page.
this->SetActivePage(IWorkbenchPage::Pointer(0));
// Clone and deref all so that calls to getPages() returns
// empty list (if called by pageClosed event handlers)
PageList oldList = pageList;
pageList.Clear();
// Close all.
for (PageList::iterator itr = oldList.Begin(); itr != oldList.End(); ++itr)
{
partService.PageClosed(*itr);
//(*itr)->FirePageClosed(page);
//page.dispose();
}
if (!closing)
{
this->ShowEmptyWindowContents();
}
}
IWorkbenchPage::Pointer WorkbenchWindow::GetActivePage()
{
return pageList.GetActive();
}
IWorkbench* WorkbenchWindow::GetWorkbench()
{
return PlatformUI::GetWorkbench();
}
IPartService* WorkbenchWindow::GetPartService()
{
return &partService;
}
ISelectionService* WorkbenchWindow::GetSelectionService()
{
return partService.GetSelectionService();
}
bool WorkbenchWindow::IsClosing()
{
return closing || this->GetWorkbenchImpl()->IsClosing();
}
int WorkbenchWindow::Open()
{
if (pageList.IsEmpty())
{
this->ShowEmptyWindowContents();
}
this->FireWindowCreated();
this->GetWindowAdvisor()->OpenIntro();
int result = Window::Open();
// It's time for a layout ... to insure that if TrimLayout
// is in play, it updates all of the trim it's responsible
// for. We have to do this before updating in order to get
// the PerspectiveBar management correct...see defect 137334
//getShell().layout();
this->FireWindowOpened();
// if (perspectiveSwitcher != null) {
// perspectiveSwitcher.updatePerspectiveBar();
// perspectiveSwitcher.updateBarParent();
// }
return result;
}
void* WorkbenchWindow::GetPageComposite()
{
return pageComposite;
}
void* WorkbenchWindow::CreateContents(Shell::Pointer parent)
{
// we know from Window.create that the parent is a Shell.
this->GetWindowAdvisor()->CreateWindowContents(parent);
// the page composite must be set by createWindowContents
poco_assert(pageComposite != 0)
; // "createWindowContents must call configurer.createPageComposite"); //$NON-NLS-1$
return pageComposite;
}
void WorkbenchWindow::CreateDefaultContents(Shell::Pointer shell)
{
//pageComposite = Tweaklets::Get(WorkbenchTweaklet::KEY)->CreateDefaultWindowContents(shell);
this->CreatePageComposite(shell->GetControl());
}
bool WorkbenchWindow::UnableToRestorePage(IMemento::Pointer pageMem)
{
std::string pageName;
pageMem->GetString(WorkbenchConstants::TAG_LABEL, pageName);
// return new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, 0, NLS.bind(
// WorkbenchMessages.WorkbenchWindow_unableToRestorePerspective,
// pageName), null);
WorkbenchPlugin::Log("Unable to restore perspective: " + pageName);
return false;
}
bool WorkbenchWindow::RestoreState(IMemento::Pointer memento,
IPerspectiveDescriptor::Pointer activeDescriptor)
{
//TODO WorkbenchWindow restore state
poco_assert(GetShell());
// final MultiStatus result = new MultiStatus(PlatformUI.PLUGIN_ID, IStatus.OK,
// WorkbenchMessages.WorkbenchWindow_problemsRestoringWindow, null);
bool result = true;
// Restore the window advisor state.
IMemento::Pointer windowAdvisorState = memento
->GetChild(WorkbenchConstants::TAG_WORKBENCH_WINDOW_ADVISOR);
if (windowAdvisorState)
{
//result.add(getWindowAdvisor().restoreState(windowAdvisorState));
result &= GetWindowAdvisor()->RestoreState(windowAdvisorState);
}
// Restore actionbar advisor state.
IMemento::Pointer actionBarAdvisorState = memento
->GetChild(WorkbenchConstants::TAG_ACTION_BAR_ADVISOR);
if (actionBarAdvisorState)
{
// result.add(getActionBarAdvisor()
// .restoreState(actionBarAdvisorState));
result &= GetActionBarAdvisor()
->RestoreState(actionBarAdvisorState);
}
// Read window's bounds and state.
Rectangle displayBounds;
// StartupThreading.runWithoutExceptions(new StartupRunnable() {
//
// public void runWithException() {
displayBounds = Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetScreenSize();
//displayBounds = GetShell()->GetDisplay()->GetBounds();
// }});
Rectangle shellBounds;
// final IMemento fastViewMem = memento
// .getChild(IWorkbenchConstants.TAG_FAST_VIEW_DATA);
// if (fastViewMem != null) {
// if (fastViewBar != null) {
// StartupThreading.runWithoutExceptions(new StartupRunnable() {
//
// public void runWithException() {
// fastViewBar.restoreState(fastViewMem);
// }});
//
// }
// }
memento->GetInteger(WorkbenchConstants::TAG_X, shellBounds.x);
memento->GetInteger(WorkbenchConstants::TAG_Y, shellBounds.y);
memento->GetInteger(WorkbenchConstants::TAG_WIDTH, shellBounds.width);
memento->GetInteger(WorkbenchConstants::TAG_HEIGHT, shellBounds.height);
if (!shellBounds.IsEmpty())
{
// StartupThreading.runWithoutExceptions(new StartupRunnable() {
//
// public void runWithException() {
if (!shellBounds.Intersects(displayBounds))
{
Rectangle clientArea(Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetAvailableScreenSize());
shellBounds.x = clientArea.x;
shellBounds.y = clientArea.y;
}
GetShell()->SetBounds(shellBounds);
// }});
}
std::string maximized; memento->GetString(WorkbenchConstants::TAG_MAXIMIZED, maximized);
if (maximized == "true")
{
// StartupThreading.runWithoutExceptions(new StartupRunnable() {
//
// public void runWithException() {
GetShell()->SetMaximized(true);
// }});
}
std::string minimized; memento->GetString(WorkbenchConstants::TAG_MINIMIZED, minimized);
if (minimized == "true")
{
// getShell().setMinimized(true);
}
// // restore the width of the perspective bar
// if (perspectiveSwitcher != null) {
// perspectiveSwitcher.restoreState(memento);
// }
// // Restore the cool bar order by creating all the tool bar contribution
// // items
// // This needs to be done before pages are created to ensure proper
// // canonical creation
// // of cool items
// final ICoolBarManager2 coolBarMgr = (ICoolBarManager2) getCoolBarManager2();
// if (coolBarMgr != null) {
// IMemento coolBarMem = memento
// .getChild(IWorkbenchConstants.TAG_COOLBAR_LAYOUT);
// if (coolBarMem != null) {
// // Check if the layout is locked
// final Integer lockedInt = coolBarMem
// .getInteger(IWorkbenchConstants.TAG_LOCKED);
// StartupThreading.runWithoutExceptions(new StartupRunnable(){
//
// public void runWithException() {
// if ((lockedInt != null) && (lockedInt.intValue() == 1)) {
// coolBarMgr.setLockLayout(true);
// } else {
// coolBarMgr.setLockLayout(false);
// }
// }});
//
// // The new layout of the cool bar manager
// ArrayList coolBarLayout = new ArrayList();
// // Traverse through all the cool item in the memento
// IMemento contributionMems[] = coolBarMem
// .getChildren(IWorkbenchConstants.TAG_COOLITEM);
// for (int i = 0; i < contributionMems.length; i++) {
// IMemento contributionMem = contributionMems[i];
// String type = contributionMem
// .getString(IWorkbenchConstants.TAG_ITEM_TYPE);
// if (type == null) {
// // Do not recognize that type
// continue;
// }
// String id = contributionMem
// .getString(IWorkbenchConstants.TAG_ID);
//
// // Prevent duplicate items from being read back in.
// IContributionItem existingItem = coolBarMgr.find(id);
// if ((id != null) && (existingItem != null)) {
// if (Policy.DEBUG_TOOLBAR_DISPOSAL) {
// System.out
// .println("Not loading duplicate cool bar item: " + id); //$NON-NLS-1$
// }
// coolBarLayout.add(existingItem);
// continue;
// }
// IContributionItem newItem = null;
// if (type.equals(IWorkbenchConstants.TAG_TYPE_SEPARATOR)) {
// if (id != null) {
// newItem = new Separator(id);
// } else {
// newItem = new Separator();
// }
// } else if (id != null) {
// if (type
// .equals(IWorkbenchConstants.TAG_TYPE_GROUPMARKER)) {
// newItem = new GroupMarker(id);
//
// } else if (type
// .equals(IWorkbenchConstants.TAG_TYPE_TOOLBARCONTRIBUTION)
// || type
// .equals(IWorkbenchConstants.TAG_TYPE_PLACEHOLDER)) {
//
// // Get Width and height
// Integer width = contributionMem
// .getInteger(IWorkbenchConstants.TAG_ITEM_X);
// Integer height = contributionMem
// .getInteger(IWorkbenchConstants.TAG_ITEM_Y);
// // Look for the object in the current cool bar
// // manager
// IContributionItem oldItem = coolBarMgr.find(id);
// // If a tool bar contribution item already exists
// // for this id then use the old object
// if (oldItem != null) {
// newItem = oldItem;
// } else {
// IActionBarPresentationFactory actionBarPresentation = getActionBarPresentationFactory();
// newItem = actionBarPresentation.createToolBarContributionItem(
// actionBarPresentation.createToolBarManager(), id);
// if (type
// .equals(IWorkbenchConstants.TAG_TYPE_PLACEHOLDER)) {
// IToolBarContributionItem newToolBarItem = (IToolBarContributionItem) newItem;
// if (height != null) {
// newToolBarItem.setCurrentHeight(height
// .intValue());
// }
// if (width != null) {
// newToolBarItem.setCurrentWidth(width
// .intValue());
// }
// newItem = new PlaceholderContributionItem(
// newToolBarItem);
// }
// // make it invisible by default
// newItem.setVisible(false);
// // Need to add the item to the cool bar manager
// // so that its canonical order can be preserved
// IContributionItem refItem = findAlphabeticalOrder(
// IWorkbenchActionConstants.MB_ADDITIONS,
// id, coolBarMgr);
// if (refItem != null) {
// coolBarMgr.insertAfter(refItem.getId(),
// newItem);
// } else {
// coolBarMgr.add(newItem);
// }
// }
// // Set the current height and width
// if ((width != null)
// && (newItem instanceof IToolBarContributionItem)) {
// ((IToolBarContributionItem) newItem)
// .setCurrentWidth(width.intValue());
// }
// if ((height != null)
// && (newItem instanceof IToolBarContributionItem)) {
// ((IToolBarContributionItem) newItem)
// .setCurrentHeight(height.intValue());
// }
// }
// }
// // Add new item into cool bar manager
// if (newItem != null) {
// coolBarLayout.add(newItem);
// newItem.setParent(coolBarMgr);
// coolBarMgr.markDirty();
// }
// }
//
// // We need to check if we have everything we need in the layout.
// boolean newlyAddedItems = false;
// IContributionItem[] existingItems = coolBarMgr.getItems();
// for (int i = 0; i < existingItems.length && !newlyAddedItems; i++) {
// IContributionItem existingItem = existingItems[i];
//
// /*
// * This line shouldn't be necessary, but is here for
// * robustness.
// */
// if (existingItem == null) {
// continue;
// }
//
// boolean found = false;
// Iterator layoutItemItr = coolBarLayout.iterator();
// while (layoutItemItr.hasNext()) {
// IContributionItem layoutItem = (IContributionItem) layoutItemItr
// .next();
// if ((layoutItem != null)
// && (layoutItem.equals(existingItem))) {
// found = true;
// break;
// }
// }
//
// if (!found) {
// if (existingItem != null) {
// newlyAddedItems = true;
// }
// }
// }
//
// // Set the cool bar layout to the given layout.
// if (!newlyAddedItems) {
// final IContributionItem[] itemsToSet = new IContributionItem[coolBarLayout
// .size()];
// coolBarLayout.toArray(itemsToSet);
// StartupThreading
// .runWithoutExceptions(new StartupRunnable() {
//
// public void runWithException() {
// coolBarMgr.setItems(itemsToSet);
// }
// });
// }
//
// } else {
// // For older workbenchs
// coolBarMem = memento
// .getChild(IWorkbenchConstants.TAG_TOOLBAR_LAYOUT);
// if (coolBarMem != null) {
// // Restore an older layout
// restoreOldCoolBar(coolBarMem);
// }
// }
// }
// Recreate each page in the window.
IWorkbenchPage::Pointer newActivePage;
std::vector<IMemento::Pointer> pageArray = memento
->GetChildren(WorkbenchConstants::TAG_PAGE);
for (std::size_t i = 0; i < pageArray.size(); i++)
{
IMemento::Pointer pageMem = pageArray[i];
std::string strFocus; pageMem->GetString(WorkbenchConstants::TAG_FOCUS, strFocus);
if (strFocus.empty())
{
continue;
}
// Get the input factory.
IAdaptable* input = 0;
IMemento::Pointer inputMem = pageMem->GetChild(WorkbenchConstants::TAG_INPUT);
if (inputMem)
{
std::string factoryID; inputMem->GetString(WorkbenchConstants::TAG_FACTORY_ID, factoryID);
if (factoryID.empty())
{
WorkbenchPlugin
::Log("Unable to restore page - no input factory ID.");
//result.add(unableToRestorePage(pageMem));
result &= UnableToRestorePage(pageMem);
continue;
}
// try {
// UIStats.start(UIStats.RESTORE_WORKBENCH,
// "WorkbenchPageFactory"); //$NON-NLS-1$
// StartupThreading
// .runWithoutExceptions(new StartupRunnable() {
//
// public void runWithException() throws Throwable {
// IElementFactory factory = PlatformUI
// .getWorkbench().getElementFactory(
// factoryID);
// if (factory == null) {
// WorkbenchPlugin
// .log("Unable to restore page - cannot instantiate input factory: " + factoryID); //$NON-NLS-1$
// result
// .add(unableToRestorePage(pageMem));
// return;
// }
//
// // Get the input element.
// input[0] = factory.createElement(inputMem);
// }
// });
//
// if (input[0] == null) {
// WorkbenchPlugin
// .log("Unable to restore page - cannot instantiate input element: " + factoryID); //$NON-NLS-1$
// result.add(unableToRestorePage(pageMem));
// continue;
// }
// } finally {
// UIStats.end(UIStats.RESTORE_WORKBENCH, factoryID,
// "WorkbenchPageFactory"); //$NON-NLS-1$
// }
}
// Open the perspective.
IAdaptable* finalInput = input;
WorkbenchPage::Pointer newPage;
try
{
// StartupThreading.runWithWorkbenchExceptions(new StartupRunnable(){
//
// public void runWithException() throws WorkbenchException {
newPage = new WorkbenchPage(this, finalInput);
// }});
//result.add(newPage[0].restoreState(pageMem, activeDescriptor));
result &= newPage->RestoreState(pageMem, activeDescriptor);
pageList.Add(newPage);
// StartupThreading.runWithoutExceptions(new StartupRunnable() {
//
// public void runWithException() throws Throwable {
partService.PageOpened(newPage);
// firePageOpened(newPage[0]);
// }});
}
catch (const WorkbenchException& e)
{
WorkbenchPlugin::Log(
"Unable to restore perspective - constructor failed.", e); //$NON-NLS-1$
//result.add(e.getStatus());
continue;
}
if (!strFocus.empty())
{
newActivePage = newPage;
}
}
// If there are no pages create a default.
if (pageList.IsEmpty())
{
try
{
const std::string defPerspID = this->GetWorkbenchImpl()->GetPerspectiveRegistry()
->GetDefaultPerspective();
if (!defPerspID.empty())
{
WorkbenchPage::Pointer newPage;
//StartupThreading.runWithWorkbenchExceptions(new StartupRunnable() {
// public void runWithException() throws Throwable {
newPage = new WorkbenchPage(this, defPerspID,
this->GetDefaultPageInput());
// }});
pageList.Add(newPage);
//StartupThreading.runWithoutExceptions(new StartupRunnable() {
// public void runWithException() throws Throwable {
// firePageOpened(newPage[0]);
partService.PageOpened(newPage);
// }});
}
}
catch (WorkbenchException& e)
{
WorkbenchPlugin
::Log(
"Unable to create default perspective - constructor failed.", e);
result = false;
//TODO set product name
// String productName = WorkbenchPlugin.getDefault()
// .getProductName();
// if (productName == null) {
// productName = ""; //$NON-NLS-1$
// }
// getShell().setText(productName);
}
}
// Set active page.
if (newActivePage.IsNull())
{
newActivePage = pageList.GetNextActive().Cast<IWorkbenchPage>();
}
//StartupThreading.runWithoutExceptions(new StartupRunnable() {
// public void runWithException() throws Throwable {
this->SetActivePage(newActivePage);
// }});
IMemento::Pointer introMem = memento->GetChild(WorkbenchConstants::TAG_INTRO);
if (introMem) {
// StartupThreading.runWithoutExceptions(new StartupRunnable() {
//
// public void runWithException() throws Throwable {
bool isStandby = false;
introMem->GetBoolean(WorkbenchConstants::TAG_STANDBY, isStandby);
GetWorkbench()->GetIntroManager()->ShowIntro(
IWorkbenchWindow::Pointer(this), isStandby);
// }
// });
}
//
// // Only restore the trim state if we're using the default layout
// if (defaultLayout != null) {
// // Restore the trim state. We pass in the 'root'
// // memento since we have to check for pre-3.2
// // state.
// result.add(restoreTrimState(memento));
// }
return result;
}
IAdaptable* WorkbenchWindow::GetDefaultPageInput()
{
return this->GetWorkbenchImpl()->GetDefaultPageInput();
}
IWorkbenchPage::Pointer WorkbenchWindow::OpenPage(
const std::string& perspId, IAdaptable* input)
{
// Run op in busy cursor.
IWorkbenchPage::Pointer result;
//BusyIndicator.showWhile(null, new Runnable() {
// public void run() {
result = this->BusyOpenPage(perspId, input);
// }
return result;
}
SmartPointer<IWorkbenchPage> WorkbenchWindow::OpenPage(IAdaptable* input)
{
std::string perspId = this->GetWorkbenchImpl()->GetDefaultPerspectiveId();
return this->OpenPage(perspId, input);
}
IWorkbenchPage::Pointer WorkbenchWindow::BusyOpenPage(
const std::string& perspID, IAdaptable* input)
{
IWorkbenchPage::Pointer newPage;
if (pageList.IsEmpty())
{
newPage = new WorkbenchPage(this, perspID, input);
pageList.Add(newPage);
//this->FirePageOpened(newPage);
partService.PageOpened(newPage);
this->SetActivePage(newPage);
}
else
{
IWorkbenchWindow::Pointer window = this->GetWorkbench()->OpenWorkbenchWindow(perspID, input);
newPage = window->GetActivePage();
}
return newPage;
}
int WorkbenchWindow::GetNumber()
{
return number;
}
void WorkbenchWindow::LargeUpdateStart()
{
largeUpdates++;
}
void WorkbenchWindow::LargeUpdateEnd()
{
if (--largeUpdates == 0)
{
//TODO WorkbenchWindow update action bars after large update
//this->UpdateActionBars();
}
}
void WorkbenchWindow::SetActivePage(IWorkbenchPage::Pointer in)
{
if (this->GetActivePage() == in)
{
return;
}
// 1FVGTNR: ITPUI:WINNT - busy cursor for switching perspectives
//BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {
// public void run() {
// Deactivate old persp.
WorkbenchPage::Pointer currentPage = pageList.GetActive();
if (currentPage.IsNotNull())
{
currentPage->OnDeactivate();
}
// Activate new persp.
if (in.IsNull() || pageList.Contains(in))
{
pageList.SetActive(in);
}
WorkbenchPage::Pointer newPage = pageList.GetActive();
//Composite parent = getPageComposite();
//StackLayout layout = (StackLayout) parent.getLayout();
if (newPage.IsNotNull())
{
//layout.topControl = newPage.getClientComposite();
//parent.layout();
this->HideEmptyWindowContents();
newPage->OnActivate();
//this->FirePageActivated(newPage);
partService.PageActivated(newPage);
//TODO perspective
if (newPage->GetPerspective() != 0)
{
this->FirePerspectiveActivated(newPage, newPage->GetPerspective());
}
}
else
{
//layout.topControl = null;
//parent.layout();
}
//updateFastViewBar();
if (this->IsClosing())
{
return;
}
updateDisabled = false;
// Update action bars ( implicitly calls updateActionBars() )
//updateActionSets();
//submitGlobalActions();
//if (perspectiveSwitcher != null) {
// perspectiveSwitcher.update(false);
//}
//getMenuManager().update(IAction.TEXT);
// }
//});
}
bool WorkbenchWindow::SaveState(IMemento::Pointer memento)
{
// MultiStatus result = new MultiStatus(PlatformUI.PLUGIN_ID, IStatus.OK,
// WorkbenchMessages.WorkbenchWindow_problemsSavingWindow, null);
bool result = true;
// Save the window's state and bounds.
if (GetShell()->GetMaximized() || asMaximizedState)
{
memento->PutString(WorkbenchConstants::TAG_MAXIMIZED, "true");
}
if (GetShell()->GetMinimized())
{
memento->PutString(WorkbenchConstants::TAG_MINIMIZED, "true");
}
if (normalBounds.IsEmpty())
{
normalBounds = GetShell()->GetBounds();
}
// IMemento fastViewBarMem = memento
// .createChild(IWorkbenchConstants.TAG_FAST_VIEW_DATA);
// if (fastViewBar != null) {
// fastViewBar.saveState(fastViewBarMem);
// }
memento->PutInteger(WorkbenchConstants::TAG_X, normalBounds.x);
memento->PutInteger(WorkbenchConstants::TAG_Y, normalBounds.y);
memento->PutInteger(WorkbenchConstants::TAG_WIDTH, normalBounds.width);
memento->PutInteger(WorkbenchConstants::TAG_HEIGHT, normalBounds.height);
IWorkbenchPage::Pointer activePage = GetActivePage();
if (activePage
&& activePage->FindView(IntroConstants::INTRO_VIEW_ID))
{
IMemento::Pointer introMem = memento
->CreateChild(WorkbenchConstants::TAG_INTRO);
bool isStandby = GetWorkbench()->GetIntroManager()
->IsIntroStandby(GetWorkbench()->GetIntroManager()->GetIntro());
introMem->PutBoolean(WorkbenchConstants::TAG_STANDBY, isStandby);
}
// // save the width of the perspective bar
// IMemento persBarMem = memento
// .createChild(IWorkbenchConstants.TAG_PERSPECTIVE_BAR);
// if (perspectiveSwitcher != null) {
// perspectiveSwitcher.saveState(persBarMem);
// }
// // / Save the order of the cool bar contribution items
// ICoolBarManager2 coolBarMgr = (ICoolBarManager2) getCoolBarManager2();
// if (coolBarMgr != null) {
// coolBarMgr.refresh();
// IMemento coolBarMem = memento
// .createChild(IWorkbenchConstants.TAG_COOLBAR_LAYOUT);
// if (coolBarMgr.getLockLayout() == true) {
// coolBarMem.putInteger(IWorkbenchConstants.TAG_LOCKED, 1);
// } else {
// coolBarMem.putInteger(IWorkbenchConstants.TAG_LOCKED, 0);
// }
// IContributionItem[] items = coolBarMgr.getItems();
// for (int i = 0; i < items.length; i++) {
// IMemento coolItemMem = coolBarMem
// .createChild(IWorkbenchConstants.TAG_COOLITEM);
// IContributionItem item = items[i];
// // The id of the contribution item
// if (item.getId() != null) {
// coolItemMem.putString(IWorkbenchConstants.TAG_ID, item
// .getId());
// }
// // Write out type and size if applicable
// if (item.isSeparator()) {
// coolItemMem.putString(IWorkbenchConstants.TAG_ITEM_TYPE,
// IWorkbenchConstants.TAG_TYPE_SEPARATOR);
// } else if (item.isGroupMarker() && !item.isSeparator()) {
// coolItemMem.putString(IWorkbenchConstants.TAG_ITEM_TYPE,
// IWorkbenchConstants.TAG_TYPE_GROUPMARKER);
// } else {
// if (item instanceof PlaceholderContributionItem) {
// coolItemMem.putString(
// IWorkbenchConstants.TAG_ITEM_TYPE,
// IWorkbenchConstants.TAG_TYPE_PLACEHOLDER);
// } else {
// // Store the identifier.
// coolItemMem
// .putString(
// IWorkbenchConstants.TAG_ITEM_TYPE,
// IWorkbenchConstants.TAG_TYPE_TOOLBARCONTRIBUTION);
// }
//
// /*
// * Retrieve a reasonable approximation of the height and
// * width, if possible.
// */
// final int height;
// final int width;
// if (item instanceof IToolBarContributionItem) {
// IToolBarContributionItem toolBarItem = (IToolBarContributionItem) item;
// toolBarItem.saveWidgetState();
// height = toolBarItem.getCurrentHeight();
// width = toolBarItem.getCurrentWidth();
// } else if (item instanceof PlaceholderContributionItem) {
// PlaceholderContributionItem placeholder = (PlaceholderContributionItem) item;
// height = placeholder.getHeight();
// width = placeholder.getWidth();
// } else {
// height = -1;
// width = -1;
// }
//
// // Store the height and width.
// coolItemMem.putInteger(IWorkbenchConstants.TAG_ITEM_X,
// width);
// coolItemMem.putInteger(IWorkbenchConstants.TAG_ITEM_Y,
// height);
// }
// }
// }
// Save each page.
for (PageList::iterator itr = pageList.Begin();
itr != pageList.End(); ++itr)
{
WorkbenchPage::Pointer page = itr->Cast<WorkbenchPage>();
// Save perspective.
IMemento::Pointer pageMem = memento
->CreateChild(WorkbenchConstants::TAG_PAGE);
pageMem->PutString(WorkbenchConstants::TAG_LABEL, page->GetLabel());
//result.add(page.saveState(pageMem));
result &= page->SaveState(pageMem);
if (page == GetActivePage().Cast<WorkbenchPage>())
{
pageMem->PutString(WorkbenchConstants::TAG_FOCUS, "true");
}
// // Get the input.
// IAdaptable* input = page->GetInput();
// if (input != 0) {
// IPersistableElement persistable = (IPersistableElement) Util.getAdapter(input,
// IPersistableElement.class);
// if (persistable == null) {
// WorkbenchPlugin
// .log("Unable to save page input: " //$NON-NLS-1$
// + input
// + ", because it does not adapt to IPersistableElement"); //$NON-NLS-1$
// } else {
// // Save input.
// IMemento inputMem = pageMem
// .createChild(IWorkbenchConstants.TAG_INPUT);
// inputMem.putString(IWorkbenchConstants.TAG_FACTORY_ID,
// persistable.getFactoryId());
// persistable.saveState(inputMem);
// }
// }
}
// Save window advisor state.
IMemento::Pointer windowAdvisorState = memento
->CreateChild(WorkbenchConstants::TAG_WORKBENCH_WINDOW_ADVISOR);
//result.add(getWindowAdvisor().saveState(windowAdvisorState));
result &= GetWindowAdvisor()->SaveState(windowAdvisorState);
// Save actionbar advisor state.
IMemento::Pointer actionBarAdvisorState = memento
->CreateChild(WorkbenchConstants::TAG_ACTION_BAR_ADVISOR);
//result.add(getActionBarAdvisor().saveState(actionBarAdvisorState));
result &= GetActionBarAdvisor()->SaveState(actionBarAdvisorState);
// // Only save the trim state if we're using the default layout
// if (defaultLayout != null) {
// IMemento trimState = memento.createChild(IWorkbenchConstants.TAG_TRIM);
// result.add(saveTrimState(trimState));
// }
return result;
}
WorkbenchWindowConfigurer::Pointer WorkbenchWindow::GetWindowConfigurer()
{
if (windowConfigurer.IsNull())
{
// lazy initialize
windowConfigurer = new WorkbenchWindowConfigurer(WorkbenchWindow::Pointer(this));
}
return windowConfigurer;
}
void WorkbenchWindow::ConfigureShell(Shell::Pointer shell)
{
Window::ConfigureShell(shell);
detachedWindowShells = new ShellPool(shell, Constants::TITLE
| Constants::MAX | Constants::CLOSE | Constants::RESIZE | Constants::BORDER );
std::string title = this->GetWindowConfigurer()->BasicGetTitle();
if (title != "")
{
shell->SetText(title);
}
// final IWorkbench workbench = getWorkbench();
// workbench.getHelpSystem().setHelp(shell,
// IWorkbenchHelpContextIds.WORKBENCH_WINDOW);
// final IContextService contextService = (IContextService) getWorkbench().getService(IContextService.class);
// contextService.registerShell(shell, IContextService.TYPE_WINDOW);
this->TrackShellActivation(shell);
this->TrackShellResize(shell);
}
ShellPool::Pointer WorkbenchWindow::GetDetachedWindowPool()
{
return detachedWindowShells;
}
WorkbenchAdvisor* WorkbenchWindow::GetAdvisor()
{
return this->GetWorkbenchImpl()->GetAdvisor();
}
WorkbenchWindowAdvisor* WorkbenchWindow::GetWindowAdvisor()
{
if (windowAdvisor == 0)
{
windowAdvisor = this->GetAdvisor()->CreateWorkbenchWindowAdvisor(this->GetWindowConfigurer());
poco_check_ptr(windowAdvisor);
}
return windowAdvisor;
}
ActionBarAdvisor::Pointer WorkbenchWindow::GetActionBarAdvisor()
{
if (actionBarAdvisor.IsNull())
{
actionBarAdvisor = this->GetWindowAdvisor()->CreateActionBarAdvisor(this->GetWindowConfigurer()->GetActionBarConfigurer());
poco_assert(actionBarAdvisor.IsNotNull());
}
return actionBarAdvisor;
}
Workbench* WorkbenchWindow::GetWorkbenchImpl()
{
return dynamic_cast<Workbench*>(this->GetWorkbench());
}
void WorkbenchWindow::ShowEmptyWindowContents()
{
if (!emptyWindowContentsCreated)
{
void* parent = this->GetPageComposite();
emptyWindowContents = this->GetWindowAdvisor()->CreateEmptyWindowContents(
parent);
emptyWindowContentsCreated = true;
// // force the empty window composite to be layed out
// ((StackLayout) parent.getLayout()).topControl = emptyWindowContents;
// parent.layout();
}
}
void WorkbenchWindow::HideEmptyWindowContents()
{
if (emptyWindowContentsCreated)
{
if (emptyWindowContents != 0)
{
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->Dispose(emptyWindowContents);
emptyWindowContents = 0;
//this->GetPageComposite().layout();
}
emptyWindowContentsCreated = false;
}
}
WorkbenchWindow::ServiceLocatorOwner::ServiceLocatorOwner(WorkbenchWindow* wnd)
: window(wnd)
{
}
void WorkbenchWindow::ServiceLocatorOwner::Dispose()
{
Shell::Pointer shell = window->GetShell();
if (shell != 0)
{
window->Close();
}
}
bool WorkbenchWindow::PageList::Add(IWorkbenchPage::Pointer object)
{
pagesInCreationOrder.push_back(object);
pagesInActivationOrder.push_front(object);
// It will be moved to top only when activated.
return true;
}
WorkbenchWindow::PageList::iterator WorkbenchWindow::PageList::Begin()
{
return pagesInCreationOrder.begin();
}
WorkbenchWindow::PageList::iterator WorkbenchWindow::PageList::End()
{
return pagesInCreationOrder.end();
}
bool WorkbenchWindow::PageList::Contains(IWorkbenchPage::Pointer object)
{
return std::find(pagesInCreationOrder.begin(), pagesInCreationOrder.end(),
object) != pagesInCreationOrder.end();
}
bool WorkbenchWindow::PageList::Remove(IWorkbenchPage::Pointer object)
{
if (active == object)
{
active = 0;
}
pagesInActivationOrder.remove(object);
std::size_t origSize = pagesInCreationOrder.size();
pagesInCreationOrder.remove(object);
return origSize != pagesInCreationOrder.size();
}
void WorkbenchWindow::PageList::Clear()
{
pagesInCreationOrder.clear();
pagesInActivationOrder.clear();
active = 0;
}
bool WorkbenchWindow::PageList::IsEmpty()
{
return pagesInCreationOrder.empty();
}
const std::list<IWorkbenchPage::Pointer>& WorkbenchWindow::PageList::GetPages()
{
return pagesInCreationOrder;
}
void WorkbenchWindow::PageList::SetActive(IWorkbenchPage::Pointer page)
{
if (active == page)
{
return;
}
active = page;
if (page.IsNotNull())
{
pagesInActivationOrder.remove(page);
pagesInActivationOrder.push_back(page);
}
}
WorkbenchPage::Pointer WorkbenchWindow::PageList::GetActive()
{
return active.Cast<WorkbenchPage>();
}
WorkbenchPage::Pointer WorkbenchWindow::PageList::GetNextActive()
{
if (active.IsNull())
{
if (pagesInActivationOrder.empty())
{
return WorkbenchPage::Pointer(0);
}
return pagesInActivationOrder.back().Cast<WorkbenchPage>();
}
if (pagesInActivationOrder.size() < 2)
{
return WorkbenchPage::Pointer(0);
}
std::list<IWorkbenchPage::Pointer>::reverse_iterator riter =
pagesInActivationOrder.rbegin();
return (++riter)->Cast<WorkbenchPage>();
}
WorkbenchWindow::ShellActivationListener::ShellActivationListener(WorkbenchWindow::Pointer w) :
window(w)
{
}
void WorkbenchWindow::ShellActivationListener::ShellActivated(ShellEvent::Pointer /*event*/)
{
WorkbenchWindow::Pointer wnd(window);
wnd->shellActivated = true;
wnd->serviceLocator->Activate();
wnd->GetWorkbenchImpl()->SetActivatedWindow(wnd);
WorkbenchPage::Pointer currentPage = wnd->GetActivePage().Cast<WorkbenchPage>();
if (currentPage != 0)
{
IWorkbenchPart::Pointer part = currentPage->GetActivePart();
if (part != 0)
{
PartSite::Pointer site = part->GetSite().Cast<PartSite>();
site->GetPane()->ShellActivated();
}
IEditorPart::Pointer editor = currentPage->GetActiveEditor();
if (editor != 0)
{
PartSite::Pointer site = editor->GetSite().Cast<PartSite>();
site->GetPane()->ShellActivated();
}
wnd->GetWorkbenchImpl()->FireWindowActivated(wnd);
}
//liftRestrictions();
}
void WorkbenchWindow::ShellActivationListener::ShellDeactivated(ShellEvent::Pointer /*event*/)
{
WorkbenchWindow::Pointer wnd(window);
wnd->shellActivated = false;
//imposeRestrictions();
wnd->serviceLocator->Deactivate();
WorkbenchPage::Pointer currentPage = wnd->GetActivePage().Cast<WorkbenchPage>();
if (currentPage != 0)
{
IWorkbenchPart::Pointer part = currentPage->GetActivePart();
if (part != 0)
{
PartSite::Pointer site = part->GetSite().Cast<PartSite>();
site->GetPane()->ShellDeactivated();
}
IEditorPart::Pointer editor = currentPage->GetActiveEditor();
if (editor != 0)
{
PartSite::Pointer site = editor->GetSite().Cast<PartSite>();
site->GetPane()->ShellDeactivated();
}
wnd->GetWorkbenchImpl()->FireWindowDeactivated(wnd);
}
}
void WorkbenchWindow::TrackShellActivation(Shell::Pointer shell)
{
shellActivationListener = new ShellActivationListener(WorkbenchWindow::Pointer(this));
shell->AddShellListener(shellActivationListener);
}
WorkbenchWindow::ControlResizeListener::ControlResizeListener(WorkbenchWindow* w)
: window(w)
{
}
GuiTk::IControlListener::Events::Types WorkbenchWindow::ControlResizeListener::GetEventTypes() const
{
return Events::MOVED | Events::RESIZED;
}
void WorkbenchWindow::
ControlResizeListener::ControlMoved(GuiTk::ControlEvent::Pointer /*e*/)
{
this->SaveBounds();
}
void WorkbenchWindow::
ControlResizeListener::ControlResized(GuiTk::ControlEvent::Pointer /*e*/)
{
this->SaveBounds();
}
void WorkbenchWindow::ControlResizeListener::SaveBounds()
{
WorkbenchWindow::Pointer wnd(window);
Shell::Pointer shell = wnd->GetShell();
if (shell == 0)
{
return;
}
// if (shell->IsDisposed())
// {
// return;
// }
if (shell->GetMinimized())
{
return;
}
if (shell->GetMaximized())
{
wnd->asMaximizedState = true;
return;
}
wnd->asMaximizedState = false;
wnd->normalBounds = shell->GetBounds();
}
void WorkbenchWindow::TrackShellResize(Shell::Pointer newShell)
{
controlResizeListener = new ControlResizeListener(this);
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->AddControlListener(newShell->GetControl(), controlResizeListener);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchWindow.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchWindow.h
index 317e5349dd..950303ceff 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchWindow.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchWindow.h
@@ -1,630 +1,630 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYWORKBENCHWINDOW_H_
#define BERRYWORKBENCHWINDOW_H_
#include "berryIWorkbenchWindow.h"
#include "berryIPerspectiveListener.h"
#include "guitk/berryGuiTkIControlListener.h"
#include "berryWindow.h"
#include "berryWorkbenchWindowConfigurer.h"
#include "berryShellPool.h"
#include "berryServiceLocator.h"
#include "berryWWinPartService.h"
#include "application/berryWorkbenchAdvisor.h"
#include "application/berryWorkbenchWindowAdvisor.h"
#include "application/berryActionBarAdvisor.h"
#include <list>
namespace berry
{
struct IWorkbench;
struct IWorkbenchPage;
class WorkbenchPage;
struct IPartService;
struct ISelectionService;
struct IPerspectiveDescriptor;
class Workbench;
/**
* \ingroup org_blueberry_ui
*
*/
class BERRY_UI WorkbenchWindow: public Window, public IWorkbenchWindow
{
public:
berryObjectMacro(WorkbenchWindow);
WorkbenchWindow(int number);
~WorkbenchWindow();
Object::Pointer GetService(const std::string& key);
bool HasService(const std::string& key) const;
int Open();
bool Close();
Shell::Pointer GetShell();
/**
* @see org.blueberry.ui.IPageService
*/
void AddPerspectiveListener(IPerspectiveListener::Pointer l);
/**
* @see org.blueberry.ui.IPageService
*/
void RemovePerspectiveListener(IPerspectiveListener::Pointer l);
/**
* @see org.blueberry.ui.IPageService
*/
IPerspectiveListener::Events& GetPerspectiveEvents();
SmartPointer<IWorkbenchPage> GetActivePage();
/**
* Sets the active page within the window.
*
* @param in
* identifies the new active page, or <code>null</code> for no
* active page
*/
void SetActivePage(SmartPointer<IWorkbenchPage> in);
IWorkbench* GetWorkbench();
IPartService* GetPartService();
ISelectionService* GetSelectionService();
SmartPointer<IWorkbenchPage> OpenPage(const std::string& perspectiveId,
IAdaptable* input);
SmartPointer<IWorkbenchPage> OpenPage(IAdaptable* input);
//TODO menu manager
//virtual void* GetMenuManager() = 0;
virtual bool SaveState(IMemento::Pointer memento);
/**
* Called when this window is about to be closed.
*
* Subclasses may overide to add code that returns <code>false</code> to
* prevent closing under certain conditions.
*/
virtual bool OkToClose();
bool RestoreState(IMemento::Pointer memento, SmartPointer<
IPerspectiveDescriptor> activeDescriptor);
/**
* Returns the number. This corresponds to a page number in a window or a
* window number in the workbench.
*/
int GetNumber();
/**
* <p>
* Indicates the start of a large update within this window. This is used to
* disable CPU-intensive, change-sensitive services that were temporarily
* disabled in the midst of large changes. This method should always be
* called in tandem with <code>largeUpdateEnd</code>, and the event loop
* should not be allowed to spin before that method is called.
* </p>
* <p>
* Important: always use with <code>largeUpdateEnd</code>!
* </p>
*
* @since 3.1
*/
void LargeUpdateStart();
/**
* <p>
* Indicates the end of a large update within this window. This is used to
* re-enable services that were temporarily disabled in the midst of large
* changes. This method should always be called in tandem with
* <code>largeUpdateStart</code>, and the event loop should not be
* allowed to spin before this method is called.
* </p>
* <p>
* Important: always protect this call by using <code>finally</code>!
* </p>
*
* @since 3.1
*/
void LargeUpdateEnd();
protected:
friend class WorkbenchConfigurer;
friend class WorkbenchWindowConfigurer;
friend class WorkbenchWindowConfigurer::WindowActionBarConfigurer;
friend class Workbench;
friend class LayoutPartSash;
friend class EditorSashContainer;
friend class WorkbenchPage;
friend class DetachedWindow;
/**
* Returns the GUI dependent page composite, under which the window's
* pages create their controls.
*/
void* GetPageComposite();
/**
* Creates and remembers the client composite, under which workbench pages
* create their controls.
*
* @since 3.0
*/
virtual void* CreatePageComposite(void* parent) = 0;
/**
* Creates the contents of the workbench window, including trim controls and
* the client composite. This MUST create the client composite via a call to
* <code>createClientComposite</code>.
*
* @since 3.0
*/
void* CreateContents(Shell::Pointer parent);
/**
* Creates the default contents and layout of the shell.
*
* @param shell
* the shell
*/
virtual void CreateDefaultContents(Shell::Pointer shell);
/**
* Returns the unique object that applications use to configure this window.
* <p>
* IMPORTANT This method is declared package-private to prevent regular
* plug-ins from downcasting IWorkbenchWindow to WorkbenchWindow and getting
* hold of the workbench window configurer that would allow them to tamper
* with the workbench window. The workbench window configurer is available
* only to the application.
* </p>
*/
WorkbenchWindowConfigurer::Pointer GetWindowConfigurer();
/*
* @see berry::Window#configureShell(Shell::Pointer)
*/
void ConfigureShell(Shell::Pointer shell);
ShellPool::Pointer GetDetachedWindowPool();
/**
* Fills the window's real action bars.
*
* @param flags
* indicate which bars to fill
*/
void FillActionBars(int flags);
/**
* The <code>WorkbenchWindow</code> implementation of this method
* delegates to the window configurer.
*
* @since 3.0
*/
Point GetInitialSize();
/**
* Returns the default page input for workbench pages opened in this window.
*
* @return the default page input or <code>null</code> if none
* @since 3.1
*/
IAdaptable* GetDefaultPageInput();
bool IsClosing();
/**
* Opens a new page. Assumes that busy cursor is active.
* <p>
* <b>Note:</b> 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 <code>IWorkbench.openPerspective</code> APIs to
* programmatically show a perspective.
* </p>
*/
SmartPointer<IWorkbenchPage> BusyOpenPage(const std::string& perspID,
IAdaptable* input);
bool ClosePage(SmartPointer<IWorkbenchPage> in, bool save);
/**
* Makes the window visible and frontmost.
*/
void MakeVisible();
/**
* The composite under which workbench pages create their controls.
*
* @since 3.0
*/
void* pageComposite;
private:
/**
* Constant indicating that all the actions bars should be filled.
*
* @since 3.0
*/
static const int FILL_ALL_ACTION_BARS;
ShellPool::Pointer detachedWindowShells;
/**
* Object for configuring this workbench window. Lazily initialized to an
* instance unique to this window.
*
* @since 3.0
*/
WorkbenchWindowConfigurer::Pointer windowConfigurer;
WorkbenchWindowAdvisor* windowAdvisor;
ActionBarAdvisor::Pointer actionBarAdvisor;
int number;
/**
* The number of large updates that are currently going on. If this is
* number is greater than zero, then UI updateActionBars is a no-op.
*/
int largeUpdates;
bool closing;
bool shellActivated;
bool updateDisabled;
/**
* The map of services maintained by the workbench window. These services
* are initialized during workbench window during the
* {@link #configureShell(Shell)}.
*/
ServiceLocator::Pointer serviceLocator;
bool emptyWindowContentsCreated;
void* emptyWindowContents;
Rectangle normalBounds;
bool asMaximizedState;
IPerspectiveListener::Events perspectiveEvents;
WWinPartService partService;
struct ServiceLocatorOwner: public IDisposable
{
ServiceLocatorOwner(WorkbenchWindow* wnd);
WorkbenchWindow* window;
void Dispose();
};
IDisposable::Pointer serviceLocatorOwner;
class PageList
{
private:
// List of pages in the order they were created;
std::list<SmartPointer<IWorkbenchPage> > pagesInCreationOrder;
// List of pages where the top is the last activated.
std::list<SmartPointer<IWorkbenchPage> > pagesInActivationOrder;
// The page explicitly activated
SmartPointer<IWorkbenchPage> active;
public:
typedef std::list<SmartPointer<IWorkbenchPage> >::iterator iterator;
bool Add(SmartPointer<IWorkbenchPage> object);
iterator Begin();
iterator End();
void Clear();
bool Contains(SmartPointer<IWorkbenchPage> object);
bool Remove(SmartPointer<IWorkbenchPage> object);
bool IsEmpty();
const std::list<SmartPointer<IWorkbenchPage> >& GetPages();
void SetActive(SmartPointer<IWorkbenchPage> page);
SmartPointer<WorkbenchPage> GetActive();
SmartPointer<WorkbenchPage> GetNextActive();
};
PageList pageList;
/**
* Notifies interested parties (namely the advisor) that the window is about
* to be opened.
*
* @since 3.1
*/
void FireWindowOpening();
/**
* Notifies interested parties (namely the advisor) that the window has been
* restored from a previously saved state.
*
* @throws WorkbenchException
* passed through from the advisor
* @since 3.1
*/
void FireWindowRestored();
/**
* Notifies interested parties (namely the advisor) that the window has been
* created.
*
* @since 3.1
*/
void FireWindowCreated();
/**
* Notifies interested parties (namely the advisor and the window listeners)
* that the window has been opened.
*
* @since 3.1
*/
void FireWindowOpened();
/**
* Notifies interested parties (namely the advisor) that the window's shell
* is closing. Allows the close to be vetoed.
*
* @return <code>true</code> if the close should proceed,
* <code>false</code> if it should be canceled
* @since 3.1
*/
bool FireWindowShellClosing();
/**
* Notifies interested parties (namely the advisor and the window listeners)
* that the window has been closed.
*
* @since 3.1
*/
void FireWindowClosed();
// /**
// * Fires page activated
// */
// void FirePageActivated(IWorkbenchPage::Pointer page);
//
// /**
// * Fires page closed
// */
// void FirePageClosed(IWorkbenchPage::Pointer page);
//
// /**
// * Fires page opened
// */
// void FirePageOpened(IWorkbenchPage::Pointer page);
/**
* Fires perspective activated
*/
void FirePerspectiveActivated(SmartPointer<IWorkbenchPage> page,
IPerspectiveDescriptor::Pointer perspective);
/**
* Fires perspective deactivated.
*
* @since 3.2
*/
void FirePerspectivePreDeactivate(SmartPointer<IWorkbenchPage> page,
IPerspectiveDescriptor::Pointer perspective);
/**
* Fires perspective deactivated.
*
* @since 3.1
*/
void FirePerspectiveDeactivated(SmartPointer<IWorkbenchPage> page,
IPerspectiveDescriptor::Pointer perspective);
/**
* Fires perspective changed
*/
void FirePerspectiveChanged(SmartPointer<IWorkbenchPage> ,
IPerspectiveDescriptor::Pointer perspective, const std::string& changeId);
/**
* Fires perspective changed for an affected part
*/
void FirePerspectiveChanged(SmartPointer<IWorkbenchPage> ,
IPerspectiveDescriptor::Pointer perspective,
IWorkbenchPartReference::Pointer partRef, const std::string& changeId);
/**
* Fires perspective closed
*/
void FirePerspectiveClosed(SmartPointer<IWorkbenchPage> ,
IPerspectiveDescriptor::Pointer perspective);
/**
* Fires perspective opened
*/
void FirePerspectiveOpened(SmartPointer<IWorkbenchPage> ,
IPerspectiveDescriptor::Pointer perspective);
/**
* Fires perspective saved as.
*
* @since 3.1
*/
void FirePerspectiveSavedAs(SmartPointer<IWorkbenchPage> ,
IPerspectiveDescriptor::Pointer oldPerspective,
IPerspectiveDescriptor::Pointer newPerspective);
/**
* Returns the workbench advisor. Assumes the workbench has been created
* already.
* <p>
* IMPORTANT This method is declared private to prevent regular plug-ins
* from downcasting IWorkbenchWindow to WorkbenchWindow and getting hold of
* the workbench advisor that would allow them to tamper with the workbench.
* The workbench advisor is internal to the application.
* </p>
*/
/* private - DO NOT CHANGE */
WorkbenchAdvisor* GetAdvisor();
/**
* Returns the window advisor, creating a new one for this window if needed.
* <p>
* IMPORTANT This method is declared private to prevent regular plug-ins
* from downcasting IWorkbenchWindow to WorkbenchWindow and getting hold of
* the window advisor that would allow them to tamper with the window. The
* window advisor is internal to the application.
* </p>
*/
/* private - DO NOT CHANGE */
WorkbenchWindowAdvisor* GetWindowAdvisor();
/**
* Returns the action bar advisor, creating a new one for this window if
* needed.
* <p>
* IMPORTANT This method is declared private to prevent regular plug-ins
* from downcasting IWorkbenchWindow to WorkbenchWindow and getting hold of
* the action bar advisor that would allow them to tamper with the window's
* action bars. The action bar advisor is internal to the application.
* </p>
*/
/* private - DO NOT CHANGE */
ActionBarAdvisor::Pointer GetActionBarAdvisor();
/*
* Returns the IWorkbench implementation.
*/
Workbench* GetWorkbenchImpl();
bool UnableToRestorePage(IMemento::Pointer pageMem);
/**
* Close the window.
*
* Assumes that busy cursor is active.
*/
bool BusyClose();
/**
* Unconditionally close this window. Assumes the proper flags have been set
* correctly (e.i. closing and updateDisabled)
*/
bool HardClose();
/**
* Close all of the pages.
*/
void CloseAllPages();
/**
* Save all of the pages. Returns true if the operation succeeded.
*/
bool SaveAllPages(bool bConfirm);
void ShowEmptyWindowContents();
void HideEmptyWindowContents();
struct ShellActivationListener: public IShellListener
{
ShellActivationListener(WorkbenchWindow::Pointer window);
void ShellActivated(ShellEvent::Pointer event);
void ShellDeactivated(ShellEvent::Pointer event);
private:
WorkbenchWindow::WeakPtr window;
};
IShellListener::Pointer shellActivationListener;
/**
* Hooks a listener to track the activation and deactivation of the window's
* shell. Notifies the active part and editor of the change
*/
void TrackShellActivation(Shell::Pointer shell);
struct ControlResizeListener: public GuiTk::IControlListener
{
ControlResizeListener(WorkbenchWindow* window);
GuiTk::IControlListener::Events::Types GetEventTypes() const;
void ControlMoved(GuiTk::ControlEvent::Pointer e);
void ControlResized(GuiTk::ControlEvent::Pointer e);
private:
void SaveBounds();
WorkbenchWindow* window;
};
GuiTk::IControlListener::Pointer controlResizeListener;
/**
* Hooks a listener to track the resize of the window's shell. Stores the
* new bounds if in normal state - that is, not in minimized or maximized
* state)
*/
void TrackShellResize(Shell::Pointer newShell);
};
}
#endif /*BERRYWORKBENCHWINDOW_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchWindowConfigurer.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchWindowConfigurer.cpp
index a87301a944..2596659bbd 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchWindowConfigurer.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchWindowConfigurer.cpp
@@ -1,266 +1,266 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryWorkbenchWindowConfigurer.h"
#include "berryWorkbenchWindow.h"
#include "berryImageDescriptor.h"
#include "berryWorkbench.h"
#include "berryWorkbenchPage.h"
#include "berryEditorSashContainer.h"
#include "berryWorkbenchPlugin.h"
#include "berryQtDnDControlWidget.h"
namespace berry
{
WorkbenchWindowConfigurer::WindowActionBarConfigurer::WindowActionBarConfigurer(WorkbenchWindow::WeakPtr wnd)
: window(wnd)
{
}
void WorkbenchWindowConfigurer::WindowActionBarConfigurer::SetProxy(IActionBarConfigurer::Pointer proxy)
{
this->proxy = proxy;
}
IWorkbenchWindowConfigurer::Pointer WorkbenchWindowConfigurer::WindowActionBarConfigurer::GetWindowConfigurer()
{
return WorkbenchWindow::Pointer(window)->GetWindowConfigurer();
}
void* WorkbenchWindowConfigurer::WindowActionBarConfigurer::GetMenuManager()
{
if (proxy.IsNotNull())
{
return proxy->GetMenuManager();
}
//TODO window menu manager
//return window->GetMenuManager();
return 0;
}
WorkbenchWindowConfigurer::WorkbenchWindowConfigurer(WorkbenchWindow::Pointer window)
: shellStyle(0), showPerspectiveBar(false), showStatusLine(true), showToolBar(true),
showMenuBar(true), showProgressIndicator(false), initialSize(1024,768)
{
if (window.IsNull())
{
throw Poco::InvalidArgumentException();
}
this->window = window;
windowTitle = "BlueBerry Application";
}
IWorkbenchWindow::Pointer WorkbenchWindowConfigurer::GetWindow()
{
return IWorkbenchWindow::Pointer(window);
}
IWorkbenchConfigurer::Pointer WorkbenchWindowConfigurer::GetWorkbenchConfigurer()
{
return dynamic_cast<Workbench*>(PlatformUI::GetWorkbench())->GetWorkbenchConfigurer();
}
std::string WorkbenchWindowConfigurer::BasicGetTitle()
{
return windowTitle;
}
std::string WorkbenchWindowConfigurer::GetTitle()
{
Shell::Pointer shell = window.Lock()->GetShell();
if (shell)
{
// update the cached title
windowTitle = shell->GetText();
}
return windowTitle;
}
void WorkbenchWindowConfigurer::SetTitle(const std::string& title)
{
windowTitle = title;
Shell::Pointer shell = window.Lock()->GetShell();
if (shell)
{
shell->SetText(title);
}
}
bool WorkbenchWindowConfigurer::GetShowMenuBar()
{
return showMenuBar;
}
void WorkbenchWindowConfigurer::SetShowMenuBar(bool show)
{
showMenuBar = show;
// WorkbenchWindow win = (WorkbenchWindow) getWindow();
// Shell shell = win.getShell();
// if (shell != null)
// {
// boolean showing = shell.getMenuBar() != null;
// if (show != showing)
// {
// if (show)
// {
// shell.setMenuBar(win.getMenuBarManager().getMenu());
// }
// else
// {
// shell.setMenuBar(null);
// }
// }
// }
}
bool WorkbenchWindowConfigurer::GetShowCoolBar()
{
return showToolBar;
}
void WorkbenchWindowConfigurer::SetShowCoolBar(bool show)
{
showToolBar = show;
//window.setCoolBarVisible(show);
// @issue need to be able to reconfigure after window's controls created
}
bool WorkbenchWindowConfigurer::GetShowPerspectiveBar()
{
return showPerspectiveBar;
}
void WorkbenchWindowConfigurer::SetShowPerspectiveBar(bool show)
{
showPerspectiveBar = show;
//window.setPerspectiveBarVisible(show);
// @issue need to be able to reconfigure after window's controls created
}
bool WorkbenchWindowConfigurer::GetShowStatusLine()
{
return showStatusLine;
}
void WorkbenchWindowConfigurer::SetShowStatusLine(bool show)
{
showStatusLine = show;
// @issue need to be able to reconfigure after window's controls created
}
bool WorkbenchWindowConfigurer::GetShowProgressIndicator()
{
return showProgressIndicator;
}
void WorkbenchWindowConfigurer::SetShowProgressIndicator(bool show)
{
showProgressIndicator = show;
// @issue need to be able to reconfigure after window's controls created
}
void WorkbenchWindowConfigurer::AddEditorAreaTransfer(const QStringList& transfers)
{
if (transfers.isEmpty()) return;
int oldSize = transferTypes.size();
transferTypes.unite(QSet<QString>::fromList(transfers));
if (transferTypes.size() == oldSize) return;
WorkbenchPage::Pointer page = window.Lock()->GetActivePage().Cast<WorkbenchPage>();
if (page)
{
QtDnDControlWidget* dropTarget =
static_cast<QtDnDControlWidget*>(page->GetEditorPresentation()->GetLayoutPart().Cast<EditorSashContainer>()->GetParent());
dropTarget->SetTransferTypes(transferTypes.toList());
}
}
void WorkbenchWindowConfigurer::ConfigureEditorAreaDropListener(const IDropTargetListener::Pointer& listener)
{
if (listener == 0) return;
dropTargetListener = listener;
WorkbenchPage::Pointer page = window.Lock()->GetActivePage().Cast<WorkbenchPage>();
if (page)
{
QtDnDControlWidget* dropTarget =
static_cast<QtDnDControlWidget*>(page->GetEditorPresentation()->GetLayoutPart().Cast<EditorSashContainer>()->GetParent());
dropTarget->AddDropListener(listener.GetPointer());
}
}
QStringList WorkbenchWindowConfigurer::GetTransfers() const
{
return transferTypes.toList();
}
IDropTargetListener::Pointer WorkbenchWindowConfigurer::GetDropTargetListener() const
{
return dropTargetListener;
}
IActionBarConfigurer::Pointer WorkbenchWindowConfigurer::GetActionBarConfigurer()
{
if (actionBarConfigurer.IsNull())
{
// lazily initialize
actionBarConfigurer = new WindowActionBarConfigurer(window);
}
return actionBarConfigurer;
}
int WorkbenchWindowConfigurer::GetShellStyle()
{
return shellStyle;
}
void WorkbenchWindowConfigurer::SetShellStyle(int shellStyle)
{
this->shellStyle = shellStyle;
}
Point WorkbenchWindowConfigurer::GetInitialSize()
{
return initialSize;
}
void WorkbenchWindowConfigurer::SetInitialSize(Point size)
{
initialSize = size;
}
void WorkbenchWindowConfigurer::CreateDefaultContents(Shell::Pointer shell)
{
WorkbenchWindow::Pointer(window)->CreateDefaultContents(shell);
}
void* WorkbenchWindowConfigurer::CreatePageComposite(void* parent)
{
return WorkbenchWindow::Pointer(window)->CreatePageComposite(parent);
}
bool WorkbenchWindowConfigurer::SaveState(IMemento::Pointer memento)
{
return WorkbenchWindow::Pointer(window)->SaveState(memento);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchWindowConfigurer.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchWindowConfigurer.h
index 1f6eeb32b1..5e93682058 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchWindowConfigurer.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchWindowConfigurer.h
@@ -1,456 +1,456 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYWORKBENCHWINDOWCONFIGURER_H_
#define BERRYWORKBENCHWINDOWCONFIGURER_H_
#include "application/berryIActionBarConfigurer.h"
#include "application/berryIWorkbenchConfigurer.h"
#include "application/berryIWorkbenchWindowConfigurer.h"
#include <berryWeakPointer.h>
#include <QSet>
namespace berry
{
class WorkbenchWindow;
/**
* Internal class providing special access for configuring workbench windows.
* <p>
* Note that these objects are only available to the main application
* (the plug-in that creates and owns the workbench).
* </p>
* <p>
* This class is not intended to be instantiated or subclassed by clients.
* </p>
*
* @since 3.0
*/
class WorkbenchWindowConfigurer : public IWorkbenchWindowConfigurer {
friend class WorkbenchWindow;
public:
berryObjectMacro(WorkbenchWindowConfigurer);
/**
* The workbench window associated with this configurer.
*/
private: WeakPointer<WorkbenchWindow> window;
/**
* The shell style bits to use when the window's shell is being created.
*/
private: int shellStyle;
/**
* The window title to set when the window's shell has been created.
*/
private: std::string windowTitle;
/**
* Whether the workbench window should show the fast view bars.
*/
//private: boolean showFastViewBars = false;
/**
* Whether the workbench window should show the perspective bar
*/
private: bool showPerspectiveBar;
/**
* Whether the workbench window should show the status line.
*/
private: bool showStatusLine;
/**
* Whether the workbench window should show the main tool bar.
*/
private: bool showToolBar;
/**
* Whether the workbench window should show the main menu bar.
*/
private: bool showMenuBar;
/**
* Whether the workbench window should have a progress indicator.
*/
private: bool showProgressIndicator;
/**
* Table to hold arbitrary key-data settings (key type: <code>String</code>,
* value type: <code>Object</code>).
* @see #setData
*/
//private: Map extraData = new HashMap(1);
/**
* Holds the list drag and drop <code>Transfer</code> for the
* editor area
*/
private: QSet<QString> transferTypes;
/**
* The <code>DropTargetListener</code> implementation for handling a
* drop into the editor area.
*/
private: IDropTargetListener::Pointer dropTargetListener;
/**
* The initial size to use for the shell.
*/
private: Point initialSize;
/**
* Action bar configurer that changes this workbench window.
* This implementation keeps track of of cool bar items
*/
private:
class WindowActionBarConfigurer : public IActionBarConfigurer {
private: IActionBarConfigurer::Pointer proxy;
private: WeakPointer<WorkbenchWindow> window;
public: berryObjectMacro(WindowActionBarConfigurer);
public: WindowActionBarConfigurer(WeakPointer<WorkbenchWindow> wnd);
/**
* Sets the proxy to use, or <code>null</code> for none.
*
* @param proxy the proxy
*/
public: void SetProxy(IActionBarConfigurer::Pointer proxy);
/* (non-Javadoc)
* @see org.blueberry.ui.application.IActionBarConfigurer#getWindowConfigurer()
*/
public: IWorkbenchWindowConfigurer::Pointer GetWindowConfigurer();
/**
* Returns whether the given id is for a cool item.
*
* @param the item id
* @return <code>true</code> if it is a cool item,
* and <code>false</code> otherwise
*/
// /* package */boolean containsCoolItem(String id) {
// ICoolBarManager cbManager = getCoolBarManager();
// if (cbManager == null) {
// return false;
// }
// IContributionItem cbItem = cbManager.find(id);
// if (cbItem == null) {
// return false;
// }
// //@ issue: maybe we should check if cbItem is visible?
// return true;
// }
/* (non-Javadoc)
* @see org.blueberry.ui.application.IActionBarConfigurer
*/
// public: IStatusLineManager getStatusLineManager() {
// if (proxy != null) {
// return proxy.getStatusLineManager();
// }
// return window.getStatusLineManager();
// }
/* (non-Javadoc)
* @see org.blueberry.ui.application.IActionBarConfigurer
*/
public: void* GetMenuManager();
/* (non-Javadoc)
* @see org.blueberry.ui.internal.AbstractActionBarConfigurer
*/
// public: ICoolBarManager getCoolBarManager() {
// if (proxy != null) {
// return proxy.getCoolBarManager();
// }
// return window.getCoolBarManager2();
// }
/* (non-Javadoc)
* @see org.blueberry.ui.application.IActionBarConfigurer
*/
// public: void registerGlobalAction(IAction action) {
// if (proxy != null) {
// proxy.registerGlobalAction(action);
// }
// window.registerGlobalAction(action);
// }
/* (non-Javadoc)
* @see org.blueberry.ui.application.IActionBarConfigurer#createToolBarManager()
*/
// public: IToolBarManager createToolBarManager() {
// if (proxy != null) {
// return proxy.createToolBarManager();
// }
// return getActionBarPresentationFactory().createToolBarManager();
// }
/* (non-Javadoc)
* @see org.blueberry.ui.application.IActionBarConfigurer#createToolBarContributionItem(org.blueberry.jface.action.IToolBarManager, java.lang.String)
*/
// public: IToolBarContributionItem createToolBarContributionItem(IToolBarManager toolBarManager, String id) {
// if (proxy != null) {
// return proxy.createToolBarContributionItem(toolBarManager, id);
// }
// return getActionBarPresentationFactory().createToolBarContributionItem(toolBarManager, id);
// }
};
/**
* Object for configuring this workbench window's action bars.
* Lazily initialized to an instance unique to this window.
*/
private: WindowActionBarConfigurer::Pointer actionBarConfigurer;
/**
* Creates a new workbench window configurer.
* <p>
* This method is declared package-private:. Clients obtain instances
* via {@link WorkbenchAdvisor#getWindowConfigurer
* WorkbenchAdvisor.getWindowConfigurer}
* </p>
*
* @param window the workbench window that this object configures
* @see WorkbenchAdvisor#getWindowConfigurer
*/
public: WorkbenchWindowConfigurer(SmartPointer<WorkbenchWindow> window);
/* (non-javadoc)
* @see org.blueberry.ui.application.IWorkbenchWindowConfigurer#getWindow
*/
public: IWorkbenchWindow::Pointer GetWindow();
/* (non-Javadoc)
* @see org.blueberry.ui.application.IWorkbenchWindowConfigurer#getWorkbenchConfigurer()
*/
public: IWorkbenchConfigurer::Pointer GetWorkbenchConfigurer();
/**
* Returns the title as set by <code>setTitle</code>, without consulting the shell.
*
* @return the window title as set, or <code>null</code> if not set
*/
/* package */std::string BasicGetTitle();
/* (non-javadoc)
* @see org.blueberry.ui.application.IWorkbenchWindowConfigurer#getTitle
*/
public: std::string GetTitle();
/* (non-javadoc)
* @see org.blueberry.ui.application.IWorkbenchWindowConfigurer#setTitle
*/
public: void SetTitle(const std::string& title);
/* (non-javadoc)
* @see org.blueberry.ui.application.IWorkbenchWindowConfigurer#getShowMenuBar
*/
public: bool GetShowMenuBar();
/* (non-javadoc)
* @see org.blueberry.ui.application.IWorkbenchWindowConfigurer#setShowMenuBar
*/
public: void SetShowMenuBar(bool show);
/* (non-javadoc)
* @see org.blueberry.ui.application.IWorkbenchWindowConfigurer#getShowToolBar
*/
public: bool GetShowCoolBar();
/* (non-javadoc)
* @see org.blueberry.ui.application.IWorkbenchWindowConfigurer
*/
public: void SetShowCoolBar(bool show);
/* (non-javadoc)
* @see org.blueberry.ui.application.IWorkbenchWindowConfigurer
*/
public: bool GetShowPerspectiveBar();
/* (non-javadoc)
* @see org.blueberry.ui.application.IWorkbenchWindowConfigurer
*/
public: void SetShowPerspectiveBar(bool show);
/* (non-javadoc)
* @see org.blueberry.ui.application.IWorkbenchWindowConfigurer#getShowStatusLine
*/
public: bool GetShowStatusLine();
/* (non-javadoc)
* @see org.blueberry.ui.application.IWorkbenchWindowConfigurer#setShowStatusLine
*/
public: void SetShowStatusLine(bool show);
/* (non-Javadoc)
* @see org.blueberry.ui.application.IWorkbenchWindowConfigurer
*/
public: bool GetShowProgressIndicator();
/* (non-Javadoc)
* @see org.blueberry.ui.application.IWorkbenchWindowConfigurer
*/
public: void SetShowProgressIndicator(bool show);
/* (non-javadoc)
* @see org.blueberry.ui.application.IWorkbenchWindowConfigurer#getData
*/
// public: Object getData(String key) {
// if (key == null) {
// throw new IllegalArgumentException();
// }
// return extraData.get(key);
// }
/* (non-javadoc)
* @see org.blueberry.ui.application.IWorkbenchWindowConfigurer#setData
*/
// public: void setData(String key, Object data) {
// if (key == null) {
// throw new IllegalArgumentException();
// }
// if (data != null) {
// extraData.put(key, data);
// } else {
// extraData.remove(key);
// }
// }
/* (non-Javadoc)
* @see org.blueberry.ui.application.IWorkbenchWindowConfigurer#addEditorAreaTransfer
*/
public: void AddEditorAreaTransfer(const QStringList& transferTypes);
/* (non-Javadoc)
* @see org.blueberry.ui.application.IWorkbenchWindowConfigurer
*/
public: void ConfigureEditorAreaDropListener(const IDropTargetListener::Pointer &listener);
/**
* Returns the array of <code>Transfer</code> added by the application
*/
public: QStringList GetTransfers() const;
/**
* Returns the drop listener provided by the application.
*/
public: IDropTargetListener::Pointer GetDropTargetListener() const;
/* (non-javadoc)
* @see org.blueberry.ui.application.IWorkbenchWindowConfigurer
*/
public: IActionBarConfigurer::Pointer GetActionBarConfigurer();
/**
* Returns whether the given id is for a cool item.
*
* @param the item id
* @return <code>true</code> if it is a cool item,
* and <code>false</code> otherwise
*/
// /* package */boolean containsCoolItem(String id) {
// // trigger lazy initialization
// getActionBarConfigurer();
// return actionBarConfigurer.containsCoolItem(id);
// }
/* (non-Javadoc)
* @see org.blueberry.ui.application.IWorkbenchWindowConfigurer
*/
public: int GetShellStyle();
/* (non-Javadoc)
* @see org.blueberry.ui.application.IWorkbenchWindowConfigurer
*/
public: void SetShellStyle(int shellStyle);
/* (non-Javadoc)
* @see org.blueberry.ui.application.IWorkbenchWindowConfigurer
*/
public: Point GetInitialSize();
/* (non-Javadoc)
* @see org.blueberry.ui.application.IWorkbenchWindowConfigurer
*/
public: void SetInitialSize(Point size);
/**
* Creates the default window contents.
*
* @param shell the shell
*/
public: void CreateDefaultContents(Shell::Pointer shell);
/* (non-Javadoc)
* @see org.blueberry.ui.application.IWorkbenchWindowConfigurer
*/
// public: Menu createMenuBar() {
// return window.getMenuManager().createMenuBar(window.getShell());
// }
/* (non-Javadoc)
* @see org.blueberry.ui.application.IWorkbenchWindowConfigurer
*/
// public: Control createCoolBarControl(Composite parent) {
// ICoolBarManager coolBarManager = window.getCoolBarManager2();
// if (coolBarManager != null) {
// if (coolBarManager instanceof ICoolBarManager2) {
// return ((ICoolBarManager2) coolBarManager).createControl2(parent);
// }
// if (coolBarManager instanceof CoolBarManager) {
// return ((CoolBarManager) coolBarManager).createControl(parent);
// }
// }
// return null;
// }
/* (non-Javadoc)
* @see org.blueberry.ui.application.IWorkbenchWindowConfigurer
*/
// public: Control createStatusLineControl(Composite parent) {
// return window.getStatusLineManager().createControl(parent);
// }
/* (non-Javadoc)
* @see org.blueberry.ui.application.IWorkbenchWindowConfigurer
*/
public: void* CreatePageComposite(void* parent);
/* (non-Javadoc)
* @see org.blueberry.ui.application.IWorkbenchWindowConfigurer#saveState(org.blueberry.ui.IMemento)
*/
public: bool SaveState(IMemento::Pointer memento) ;
};
}
#endif /*BERRYWORKBENCHWINDOWCONFIGURER_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryEditorIntroAdapterPart.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryEditorIntroAdapterPart.cpp
index 3377d8ce38..d9502cf7f5 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryEditorIntroAdapterPart.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryEditorIntroAdapterPart.cpp
@@ -1,147 +1,147 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryEditorIntroAdapterPart.h"
#include "berryIntroPartAdapterSite.h"
#include "internal/berryWorkbench.h"
#include "internal/berryWorkbenchPlugin.h"
namespace berry
{
EditorIntroAdapterPart::EditorIntroAdapterPart() :
propChangeListener(new PropertyChangeIntAdapter<EditorIntroAdapterPart>(this, &EditorIntroAdapterPart::PropertyChange))
{
}
EditorIntroAdapterPart::EditorIntroAdapterPart(const EditorIntroAdapterPart& other)
{
Q_UNUSED(other)
throw std::runtime_error("Copy constructor not implemented");
}
void EditorIntroAdapterPart::SetStandby(bool standby)
{
// final Control control = ((PartSite) getSite()).getPane().getControl();
// BusyIndicator.showWhile(control.getDisplay(), new Runnable() {
// public void run() {
// try {
// control.setRedraw(false);
introPart->StandbyStateChanged(standby);
// } finally {
// control.setRedraw(true);
// }
//
// setBarVisibility(standby);
// }
// });
}
void EditorIntroAdapterPart::CreatePartControl(void* parent)
{
//addPaneListener();
introPart->CreatePartControl(parent);
}
EditorIntroAdapterPart::~EditorIntroAdapterPart()
{
//setBarVisibility(true);
if(introPart)
{
introPart->RemovePropertyListener(propChangeListener);
GetSite()->GetWorkbenchWindow()->GetWorkbench()->GetIntroManager()->CloseIntro(
introPart);
}
}
void* EditorIntroAdapterPart::GetTitleImage()
{
return introPart->GetTitleImage();
}
std::string EditorIntroAdapterPart::GetPartName()
{
// this method is called eagerly before our init method is called (and
// therefore before our intropart is created). By default return
// the view title from the view declaration. We will fire a property
// change to set the title to the proper value in the init method.
return introPart.IsNull() ? EditorPart::GetPartName() : introPart->GetPartName();
}
void EditorIntroAdapterPart::Init(IEditorSite::Pointer site,
IEditorInput::Pointer input)
{
Workbench* workbench =
dynamic_cast<Workbench*>(site->GetWorkbenchWindow()->GetWorkbench());
try
{
introPart = workbench->GetWorkbenchIntroManager()->CreateNewIntroPart();
// reset the part name of this view to be that of the intro title
SetPartName(introPart->GetPartName());
introPart->AddPropertyListener(propChangeListener);
introSite
= IIntroSite::Pointer(new IntroPartAdapterSite(site, workbench->GetIntroDescriptor()));
introPart->Init(introSite, IMemento::Pointer(0));
}
catch (CoreException& e)
{
//TODO IStatus
// WorkbenchPlugin.log(
// IntroMessages.Intro_could_not_create_proxy,
// new Status(IStatus.ERROR, WorkbenchPlugin.PI_WORKBENCH,
// IStatus.ERROR, IntroMessages.Intro_could_not_create_proxy, e));
WorkbenchPlugin::Log("Could not create intro editor proxy.", e);
}
this->SetSite(site);
this->SetInput(input);
}
void EditorIntroAdapterPart::DoSave(/*IProgressMonitor monitor*/)
{
}
void EditorIntroAdapterPart::DoSaveAs()
{
}
bool EditorIntroAdapterPart::IsDirty() const
{
return false;
}
bool EditorIntroAdapterPart::IsSaveAsAllowed() const
{
return false;
}
void EditorIntroAdapterPart::PropertyChange(Object::Pointer /*source*/,
int propId)
{
FirePropertyChange(propId);
}
void EditorIntroAdapterPart::SetFocus()
{
introPart->SetFocus();
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryEditorIntroAdapterPart.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryEditorIntroAdapterPart.h
index 09fbeb17e0..967c8eaf2c 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryEditorIntroAdapterPart.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryEditorIntroAdapterPart.h
@@ -1,162 +1,162 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYEDITORINTROADAPTERPART_H_
#define BERRYEDITORINTROADAPTERPART_H_
#include <berryEditorPart.h>
#include <intro/berryIIntroPart.h>
#include <intro/berryIIntroSite.h>
namespace berry
{
/**
* Simple editor that will wrap an <code>IIntroPart</code>.
*
* @since 3.0
*/
class EditorIntroAdapterPart: public EditorPart
{
Q_OBJECT
private:
IIntroPart::Pointer introPart;
IIntroSite::Pointer introSite;
IPropertyChangeListener::Pointer propChangeListener;
friend struct PropertyChangeIntAdapter<EditorIntroAdapterPart> ;
void PropertyChange(Object::Pointer source, int propId);
// bool handleZoomEvents = true;
// /**
// * Adds a listener that toggles standby state if the view pane is zoomed.
// */
// void AddPaneListener() {
// IWorkbenchPartSite site = getSite();
// if (site instanceof PartSite) {
// final WorkbenchPartReference ref = ((WorkbenchPartReference)((PartSite) site).getPartReference());
// ref.addInternalPropertyListener(
// new IPropertyListener() {
// public void propertyChanged(Object source, int propId) {
// if (handleZoomEvents) {
// if (propId == WorkbenchPartReference.INTERNAL_PROPERTY_ZOOMED) {
// setStandby(!ref.getPane().isZoomed());
// }
// }
// }
// });
// }
// }
// /**
// * Sets whether the CoolBar/PerspectiveBar should be visible.
// *
// * @param visible whether the CoolBar/PerspectiveBar should be visible
// */
// void SetBarVisibility(bool visible) {
// WorkbenchWindow window = (WorkbenchWindow) getSite()
// .getWorkbenchWindow();
//
// final boolean layout = (visible != window.getCoolBarVisible())
// || (visible != window.getPerspectiveBarVisible()); // don't layout unless things have actually changed
// if (visible) {
// window.setCoolBarVisible(true);
// window.setPerspectiveBarVisible(true);
// } else {
// window.setCoolBarVisible(false);
// window.setPerspectiveBarVisible(false);
// }
//
// if (layout) {
// window.getShell().layout();
// }
// }
public:
EditorIntroAdapterPart();
EditorIntroAdapterPart(const EditorIntroAdapterPart& other);
/**
* Forces the standby state of the intro part.
*
* @param standby update the standby state
*/
void SetStandby(bool standby);
// /**
// * Toggles handling of zoom events.
// *
// * @param handle whether to handle zoom events
// */
// void SetHandleZoomEvents(boolean handle) {
// handleZoomEvents = handle;
// }
/* (non-Javadoc)
* @see org.eclipse.ui.IWorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
void CreatePartControl(void* parent);
/* (non-Javadoc)
* @see org.eclipse.ui.IWorkbenchPart#dispose()
*/
~EditorIntroAdapterPart();
/* (non-Javadoc)
* @see org.eclipse.ui.IWorkbenchPart#getTitleImage()
*/
void* GetTitleImage();
/* (non-Javadoc)
* @see org.eclipse.ui.part.WorkbenchPart#GetPartName()
*/
std::string GetPartName();
void Init(IEditorSite::Pointer site, IEditorInput::Pointer input);
void DoSave(/*IProgressMonitor monitor*/);
void DoSaveAs();
bool IsDirty() const;
bool IsSaveAsAllowed() const;
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.IWorkbenchPart#setFocus()
*/
void SetFocus();
/* (non-Javadoc)
* @see org.eclipse.ui.IViewPart#saveState(org.eclipse.ui.IMemento)
*/
void SaveState(IMemento::Pointer memento);
};
}
#endif /* BERRYEDITORINTROADAPTERPART_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryIIntroDescriptor.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryIIntroDescriptor.h
index fe4807ad18..866a198e09 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryIIntroDescriptor.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryIIntroDescriptor.h
@@ -1,78 +1,78 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIINTRODESCRIPTOR_H_
#define BERRYIINTRODESCRIPTOR_H_
#include <berryObject.h>
#include <berryMacros.h>
#include "intro/berryIIntroPart.h"
#include <berryPlatformException.h>
#include <berryImageDescriptor.h>
namespace berry {
/**
* Describes an introduction extension.
*
* @since 3.0
*/
struct BERRY_UI IIntroDescriptor : public Object {
berryInterfaceMacro(IIntroDescriptor, berry)
~IIntroDescriptor();
/**
* Creates an instance of the intro part defined in the descriptor.
*/
virtual IIntroPart::Pointer CreateIntro() throw(CoreException) = 0;
/**
* Returns the role of the intro part (view or editor)
* @return the role of the part
*/
virtual int GetRole() const = 0;
/**
* Returns the part id.
*
* @return the id of the part
*/
virtual std::string GetId() const = 0;
/**
* Returns the descriptor of the image for this part.
*
* @return the descriptor of the image to display next to this part
*/
virtual ImageDescriptor::Pointer GetImageDescriptor() const = 0;
/**
* Return the label override string for this part.
*
* @return the label override string or the empty string if one has not
* been specified
*/
virtual std::string GetLabelOverride() const = 0;
};
}
#endif /* BERRYIINTRODESCRIPTOR_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryIIntroRegistry.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryIIntroRegistry.h
index 4ad4b14d5b..cdf35a1003 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryIIntroRegistry.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryIIntroRegistry.h
@@ -1,69 +1,69 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIINTROREGISTRY_H_
#define BERRYIINTROREGISTRY_H_
#include "berryIIntroDescriptor.h"
#include <vector>
namespace berry {
/**
* Registry for introduction elements.
*
* @since 3.0
*/
struct BERRY_UI IIntroRegistry {
virtual ~IIntroRegistry();
/**
* Return the number of introduction extensions known by this registry.
*
* @return the number of introduction extensions known by this registry
*/
virtual int GetIntroCount() const = 0;
/**
* Return the introduction extensions known by this registry.
*
* @return the introduction extensions known by this registry
*/
virtual std::vector<IIntroDescriptor::Pointer> GetIntros() const = 0;
/**
* Return the introduction extension that is bound to the given product.
*
* @param productId the product identifier
* @return the introduction extension that is bound to the given product,
* or <code>null</code> if there is no such binding
*/
virtual IIntroDescriptor::Pointer GetIntroForProduct(const std::string& productId) const = 0;
/**
* Find an intro descriptor with the given identifier.
*
* @param id the id
* @return the intro descriptor, or <code>null</code>
*/
virtual IIntroDescriptor::Pointer GetIntro(const std::string& id) const = 0;
};
}
#endif /* BERRYIINTROREGISTRY_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryIntroConstants.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryIntroConstants.cpp
index 531d6ecc34..42e4ed7ef9 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryIntroConstants.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryIntroConstants.cpp
@@ -1,26 +1,26 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryIntroConstants.h"
namespace berry {
const std::string IntroConstants::INTRO_VIEW_ID = "org.blueberry.ui.internal.introview";
const std::string IntroConstants::INTRO_EDITOR_ID = "org.blueberry.ui.internal.introeditor";
const int IntroConstants::INTRO_ROLE_VIEW = 0x01;
const int IntroConstants::INTRO_ROLE_EDITOR = 0x02;
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryIntroConstants.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryIntroConstants.h
index 295359feb4..3778ae150a 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryIntroConstants.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryIntroConstants.h
@@ -1,57 +1,57 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYINTROCONSTANTS_H_
#define BERRYINTROCONSTANTS_H_
#include <string>
namespace berry {
/**
* Contains constants used by the intro implementation
*
* @since 3.0
*/
struct IntroConstants {
/**
* The id of the view that is used as the intro host.
*/
static const std::string INTRO_VIEW_ID; // = "org.blueberry.ui.internal.introview";
/**
* The id of the editor that is used as the intro host.
*/
static const std::string INTRO_EDITOR_ID; // = "org.blueberry.ui.internal.introeditor";
/**
* Constant defining the realization of the intro part as a view.
*/
static const int INTRO_ROLE_VIEW; // = 0x01;
/**
* Constant defining the realization of the intro part as an editor.
*/
static const int INTRO_ROLE_EDITOR; // = 0x02;
};
}
#endif /* BERRYINTROCONSTANTS_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryIntroDescriptor.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryIntroDescriptor.cpp
index 0a01869e5b..d69842a79f 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryIntroDescriptor.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryIntroDescriptor.cpp
@@ -1,131 +1,131 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryIntroDescriptor.h"
#include "berryIntroConstants.h"
#include "internal/berryWorkbenchRegistryConstants.h"
#include <berryAbstractUIPlugin.h>
namespace berry
{
IntroDescriptor::IntroDescriptor(IConfigurationElement::Pointer configElement)
throw (CoreException) :
element(configElement)
{
std::string val;
if (!configElement->GetAttribute(WorkbenchRegistryConstants::ATT_CLASS, val))
{
//TODO IStatus
/*
throw CoreException(new Status(IStatus.ERROR,
configElement .getNamespace(), 0,
"Invalid extension (Missing class name): " + getId(), //$NON-NLS-1$
null));
*/
throw CoreException(configElement->GetContributor() + ": Invalid extension (Missing className): " + GetId());
}
}
SmartPointer<IIntroPart> IntroDescriptor::CreateIntro() throw (CoreException)
{
IIntroPart::Pointer intro(element->CreateExecutableExtension<IIntroPart>(
WorkbenchRegistryConstants::ATT_CLASS));
if (intro.IsNull())
{
intro = element->CreateExecutableExtension<IIntroPart>(
WorkbenchRegistryConstants::ATT_CLASS, IIntroPart::GetManifestName());
}
return intro;
}
IntroContentDetector::Pointer IntroDescriptor::GetIntroContentDetector()
throw (CoreException)
{
std::string val;
if (!element->GetAttribute(WorkbenchRegistryConstants::ATT_CONTENT_DETECTOR, val))
{
return IntroContentDetector::Pointer(0);
}
IntroContentDetector::Pointer detector(
element->CreateExecutableExtension<IntroContentDetector>(
WorkbenchRegistryConstants::ATT_CONTENT_DETECTOR));
if (detector.IsNull())
{
// support legacy BlueBerry extensions
detector = element->CreateExecutableExtension<IntroContentDetector>(
WorkbenchRegistryConstants::ATT_CONTENT_DETECTOR, IntroContentDetector::GetManifestName());
}
return detector;
}
int IntroDescriptor::GetRole() const
{
std::string role;
if (!element->GetAttribute(WorkbenchRegistryConstants::ATT_ROLE, role))
{
return IntroConstants::INTRO_ROLE_VIEW;
}
if (role == "editor") return IntroConstants::INTRO_ROLE_EDITOR;
else return IntroConstants::INTRO_ROLE_VIEW;
}
std::string IntroDescriptor::GetId() const
{
std::string id;
element->GetAttribute(WorkbenchRegistryConstants::ATT_ID, id);
return id;
}
std::string IntroDescriptor::GetPluginId() const
{
return element->GetContributor();
}
ImageDescriptor::Pointer IntroDescriptor::GetImageDescriptor() const
{
if (imageDescriptor)
{
return imageDescriptor;
}
std::string iconName;
if (!element->GetAttribute(WorkbenchRegistryConstants::ATT_ICON, iconName))
{
return ImageDescriptor::Pointer();
}
imageDescriptor = AbstractUIPlugin::ImageDescriptorFromPlugin(
element->GetContributor(), iconName);
return imageDescriptor;
}
IConfigurationElement::Pointer IntroDescriptor::GetConfigurationElement() const
{
return element;
}
std::string IntroDescriptor::GetLabelOverride() const
{
std::string label;
element->GetAttribute(WorkbenchRegistryConstants::ATT_LABEL, label);
return label;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryIntroDescriptor.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryIntroDescriptor.h
index 1442011df4..d4599f451f 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryIntroDescriptor.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryIntroDescriptor.h
@@ -1,90 +1,90 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYINTRODESCRIPTOR_H_
#define BERRYINTRODESCRIPTOR_H_
#include "berryIIntroDescriptor.h"
#include "intro/berryIntroContentDetector.h"
#include "intro/berryIIntroPart.h"
#include <berryIConfigurationElement.h>
#include <berryImageDescriptor.h>
namespace berry
{
/**
* Describes an introduction extension.
*
*/
class IntroDescriptor: public IIntroDescriptor
{
private:
IConfigurationElement::Pointer element;
mutable ImageDescriptor::Pointer imageDescriptor;
public:
berryObjectMacro(IntroDescriptor)
/**
* Create a new IntroDescriptor for an extension.
*/
IntroDescriptor(IConfigurationElement::Pointer configElement)
throw (CoreException);
/*
* @see IIntroDescriptor#CreateIntro()
*/
IIntroPart::Pointer CreateIntro() throw (CoreException);
IntroContentDetector::Pointer GetIntroContentDetector() throw (CoreException);
int GetRole() const;
/*
* @see IIntroDescriptor#GetId()
*/
std::string GetId() const;
std::string GetPluginId() const;
/*
* @see IIntroDescriptor#GetImageDescriptor()
*/
ImageDescriptor::Pointer GetImageDescriptor() const;
/**
* Returns the configuration element.
*
* @return the configuration element
*/
IConfigurationElement::Pointer GetConfigurationElement() const;
/*
* @see IIntroDescriptor#GetLabelOverride()
*/
std::string GetLabelOverride() const;
};
}
#endif /* BERRYINTRODESCRIPTOR_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryIntroPartAdapterSite.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryIntroPartAdapterSite.cpp
index 179ee58f0f..171375758c 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryIntroPartAdapterSite.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryIntroPartAdapterSite.cpp
@@ -1,78 +1,78 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryIntroPartAdapterSite.h"
#include <berryIWorkbenchPage.h>
#include <berryISelectionProvider.h>
namespace berry
{
IntroPartAdapterSite::IntroPartAdapterSite(IWorkbenchPartSite::Pointer site,
IntroDescriptor::Pointer descriptor) :
descriptor(descriptor), partSite(site)
{
}
Object::Pointer IntroPartAdapterSite::GetService(const std::string& key)
{
return partSite->GetService(key);
}
bool IntroPartAdapterSite::HasService(const std::string& key) const
{
return partSite->HasService(key);
}
std::string IntroPartAdapterSite::GetId() const
{
return descriptor->GetId();
}
SmartPointer<IWorkbenchPage> IntroPartAdapterSite::GetPage()
{
return partSite->GetPage();
}
std::string IntroPartAdapterSite::GetPluginId() const
{
return descriptor->GetPluginId();
}
SmartPointer<ISelectionProvider> IntroPartAdapterSite::GetSelectionProvider()
{
return partSite->GetSelectionProvider();
}
SmartPointer<Shell> IntroPartAdapterSite::GetShell()
{
return partSite->GetShell();
}
SmartPointer<IWorkbenchWindow> IntroPartAdapterSite::GetWorkbenchWindow()
{
return partSite->GetWorkbenchWindow();
}
void IntroPartAdapterSite::SetSelectionProvider(
SmartPointer<ISelectionProvider> provider)
{
partSite->SetSelectionProvider(provider);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryIntroPartAdapterSite.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryIntroPartAdapterSite.h
index e286efbe10..9931a14c41 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryIntroPartAdapterSite.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryIntroPartAdapterSite.h
@@ -1,100 +1,100 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYVIEWINTROADAPTERSITE_H_
#define BERRYVIEWINTROADAPTERSITE_H_
#include <intro/berryIIntroSite.h>
#include "berryIntroDescriptor.h"
#include <berryIWorkbenchPartSite.h>
namespace berry {
/**
* Simple <code>IIntroSite</code> that wraps a <code>IViewSite</code>. For use in conjunction with
* <code>ViewIntroAdapterPart</code>.
*
*/
class IntroPartAdapterSite : public IIntroSite {
private:
IntroDescriptor::Pointer descriptor;
IWorkbenchPartSite::Pointer partSite;
public:
IntroPartAdapterSite(IWorkbenchPartSite::Pointer viewSite, IntroDescriptor::Pointer descriptor);
/* (non-Javadoc)
* @see org.eclipse.ui.intro.IIntroSite#getActionBars()
*/
// IActionBars getActionBars() {
// return viewSite.getActionBars();
// }
/* (non-Javadoc)
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
*/
// Object getAdapter(Class adapter) {
// return viewSite.getAdapter(adapter);
// }
Object::Pointer GetService(const std::string& key);
bool HasService(const std::string& key) const;
/* (non-Javadoc)
* @see org.eclipse.ui.IWorkbenchPartSite#getId()
*/
std::string GetId() const;
/* (non-Javadoc)
* @see org.eclipse.ui.IWorkbenchSite#getPage()
*/
SmartPointer<IWorkbenchPage> GetPage();
/* (non-Javadoc)
* @see org.eclipse.ui.IWorkbenchPartSite#getPluginId()
*/
std::string GetPluginId() const;
/* (non-Javadoc)
* @see org.eclipse.ui.IWorkbenchSite#getSelectionProvider()
*/
SmartPointer<ISelectionProvider> GetSelectionProvider();
SmartPointer<Shell> GetShell();
/* (non-Javadoc)
* @see org.eclipse.ui.IWorkbenchSite#getWorkbenchWindow()
*/
SmartPointer<IWorkbenchWindow> GetWorkbenchWindow();
/* (non-Javadoc)
* @see org.eclipse.ui.IWorkbenchSite#setSelectionProvider(org.eclipse.jface.viewers.ISelectionProvider)
*/
void SetSelectionProvider(SmartPointer<ISelectionProvider> provider);
};
}
#endif /* BERRYVIEWINTROADAPTERSITE_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryIntroRegistry.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryIntroRegistry.cpp
index b0abc68652..71ff489b6f 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryIntroRegistry.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryIntroRegistry.cpp
@@ -1,172 +1,172 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryIntroRegistry.h"
#include "berryIConfigurationElement.h"
#include "berryIntroDescriptor.h"
#include "internal/berryRegistryReader.h"
#include "internal/berryWorkbenchPlugin.h"
namespace berry
{
const std::string IntroRegistry::TAG_INTRO = "intro";
const std::string IntroRegistry::TAG_INTROPRODUCTBINDING = "introProductBinding";
const std::string IntroRegistry::ATT_INTROID = "introId";
const std::string IntroRegistry::ATT_PRODUCTID = "productId";
std::string IntroRegistry::GetIntroForProduct(
const std::string& targetProductId,
const std::vector<const IExtension*>& extensions) const
{
for (std::size_t i = 0; i < extensions.size(); i++)
{
std::vector<IConfigurationElement::Pointer> elements(
extensions[i] ->GetConfigurationElements());
for (std::size_t j = 0; j < elements.size(); j++)
{
if (elements[j]->GetName() == TAG_INTROPRODUCTBINDING)
{
std::string introId;
bool hasIntroId = elements[j]->GetAttribute(ATT_INTROID, introId);
std::string productId;
bool hasProductId = elements[j]->GetAttribute(ATT_PRODUCTID, productId);
if (!hasIntroId || !hasProductId)
{
//TODO IStatus
/*
IStatus status = new Status(
IStatus.ERROR,
elements[j].getDeclaringExtension()
.getNamespace(),
IStatus.ERROR,
"introId and productId must be defined.", new IllegalArgumentException()); //$NON-NLS-1$
WorkbenchPlugin.log("Invalid intro binding", status); //$NON-NLS-1$
*/
WorkbenchPlugin::Log(
elements[j]->GetDeclaringExtension()->GetNamespace()
+ ": Invalid intro binding. introId and productId must be defined");
continue;
}
if (targetProductId == productId)
{
return introId;
}
}
}
}
return "";
}
int IntroRegistry::GetIntroCount() const
{
return static_cast<int> (GetIntros().size());
}
std::vector<IIntroDescriptor::Pointer> IntroRegistry::GetIntros() const
{
const IExtensionPoint* point =
Platform::GetExtensionPointService()->GetExtensionPoint(
PlatformUI::PLUGIN_ID + "." + WorkbenchRegistryConstants::PL_INTRO);
if (!point)
{
return std::vector<IIntroDescriptor::Pointer>();
}
std::vector<const IExtension*> extensions(point->GetExtensions());
extensions = RegistryReader::OrderExtensions(extensions);
std::vector<IIntroDescriptor::Pointer> list;
for (std::size_t i = 0; i < extensions.size(); i++)
{
std::vector<IConfigurationElement::Pointer> elements(
extensions[i] ->GetConfigurationElements());
for (std::size_t j = 0; j < elements.size(); j++)
{
if (elements[j]->GetName() == TAG_INTRO)
{
try
{
IIntroDescriptor::Pointer
descriptor(new IntroDescriptor(elements[j]));
list.push_back(descriptor);
} catch (CoreException& e)
{
// log an error since its not safe to open a dialog here
//TODO IStatus
WorkbenchPlugin::Log("Unable to create intro descriptor", e); // e.getStatus());
}
}
}
}
return list;
}
IIntroDescriptor::Pointer IntroRegistry::GetIntroForProduct(
const std::string& targetProductId) const
{
const IExtensionPoint* point =
Platform::GetExtensionPointService()->GetExtensionPoint(
PlatformUI::PLUGIN_ID + "." + WorkbenchRegistryConstants::PL_INTRO);
if (!point)
{
return IIntroDescriptor::Pointer();
}
std::vector<const IExtension*> extensions(point->GetExtensions());
extensions = RegistryReader::OrderExtensions(extensions);
std::string targetIntroId = GetIntroForProduct(targetProductId, extensions);
if (targetIntroId.empty())
{
return IIntroDescriptor::Pointer();
}
IIntroDescriptor::Pointer descriptor;
std::vector<IIntroDescriptor::Pointer> intros(GetIntros());
for (std::size_t i = 0; i < intros.size(); i++)
{
if (intros[i]->GetId() == targetIntroId)
{
descriptor = intros[i];
break;
}
}
return descriptor;
}
IIntroDescriptor::Pointer IntroRegistry::GetIntro(const std::string& id) const
{
std::vector<IIntroDescriptor::Pointer> intros(GetIntros());
for (std::size_t i = 0; i < intros.size(); i++)
{
IIntroDescriptor::Pointer desc = intros[i];
if (desc->GetId() == id)
{
return desc;
}
}
return IIntroDescriptor::Pointer();
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryIntroRegistry.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryIntroRegistry.h
index a773864348..4e9609d921 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryIntroRegistry.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryIntroRegistry.h
@@ -1,82 +1,82 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYINTROREGISTRY_H_
#define BERRYINTROREGISTRY_H_
#include "berryIIntroRegistry.h"
namespace berry {
struct IExtension;
/**
* Registry for introduction elements.
*
*/
class IntroRegistry : public IIntroRegistry {
private:
static const std::string TAG_INTRO; // = "intro";
static const std::string TAG_INTROPRODUCTBINDING; // = "introProductBinding";
static const std::string ATT_INTROID; // = "introId";
static const std::string ATT_PRODUCTID; // = "productId";
/**
* @param targetProductId
* @param extensions
* @return
*/
std::string GetIntroForProduct(const std::string& targetProductId,
const std::vector<const IExtension*>& extensions) const;
public:
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.internal.intro.IIntroRegistry#getIntroCount()
*/
int GetIntroCount() const;
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.internal.intro.IIntroRegistry#getIntros()
*/
std::vector<IIntroDescriptor::Pointer> GetIntros() const;
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.internal.intro.IIntroRegistry#getIntroForProduct(java.lang.String)
*/
IIntroDescriptor::Pointer GetIntroForProduct(const std::string& targetProductId) const;
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.internal.intro.IIntroRegistry#getIntro(java.lang.String)
*/
IIntroDescriptor::Pointer GetIntro(const std::string& id) const;
};
}
#endif /* BERRYINTROREGISTRY_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryViewIntroAdapterPart.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryViewIntroAdapterPart.cpp
index 6c43f6e44b..346663712c 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryViewIntroAdapterPart.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryViewIntroAdapterPart.cpp
@@ -1,121 +1,121 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryViewIntroAdapterPart.h"
#include "berryIntroPartAdapterSite.h"
#include "internal/berryWorkbench.h"
#include "internal/berryWorkbenchPlugin.h"
namespace berry
{
ViewIntroAdapterPart::ViewIntroAdapterPart() :
propChangeListener(new PropertyChangeIntAdapter<ViewIntroAdapterPart>(this, &ViewIntroAdapterPart::PropertyChange))
{
}
void ViewIntroAdapterPart::SetStandby(bool standby)
{
// final Control control = ((PartSite) getSite()).getPane().getControl();
// BusyIndicator.showWhile(control.getDisplay(), new Runnable() {
// public void run() {
// try {
// control.setRedraw(false);
introPart->StandbyStateChanged(standby);
// } finally {
// control.setRedraw(true);
// }
//
// setBarVisibility(standby);
// }
// });
}
void ViewIntroAdapterPart::CreatePartControl(void* parent)
{
//addPaneListener();
introPart->CreatePartControl(parent);
}
ViewIntroAdapterPart::~ViewIntroAdapterPart()
{
//setBarVisibility(true);
introPart->RemovePropertyListener(propChangeListener);
GetSite()->GetWorkbenchWindow()->GetWorkbench()->GetIntroManager()->CloseIntro(
introPart);
}
void* ViewIntroAdapterPart::GetTitleImage()
{
return introPart->GetTitleImage();
}
std::string ViewIntroAdapterPart::GetPartName()
{
// this method is called eagerly before our init method is called (and
// therefore before our intropart is created). By default return
// the view title from the view declaration. We will fire a property
// change to set the title to the proper value in the init method.
return introPart.IsNull() ? ViewPart::GetPartName() : introPart->GetPartName();
}
void ViewIntroAdapterPart::Init(IViewSite::Pointer site,
IMemento::Pointer memento) throw (PartInitException)
{
ViewPart::Init(site);
Workbench* workbench =
dynamic_cast<Workbench*>(site->GetWorkbenchWindow()->GetWorkbench());
try
{
introPart = workbench->GetWorkbenchIntroManager() ->CreateNewIntroPart();
// reset the part name of this view to be that of the intro title
SetPartName(introPart->GetPartName());
introPart->AddPropertyListener(propChangeListener);
introSite
= IIntroSite::Pointer(new IntroPartAdapterSite(site, workbench->GetIntroDescriptor()));
introPart->Init(introSite, memento);
} catch (CoreException& e)
{
//TODO IStatus
// WorkbenchPlugin.log(
// IntroMessages.Intro_could_not_create_proxy,
// new Status(IStatus.ERROR, WorkbenchPlugin.PI_WORKBENCH,
// IStatus.ERROR, IntroMessages.Intro_could_not_create_proxy, e));
WorkbenchPlugin::Log("Could not create intro view proxy.", e);
}
}
void ViewIntroAdapterPart::PropertyChange(Object::Pointer /*source*/,
int propId)
{
FirePropertyChange(propId);
}
void ViewIntroAdapterPart::SetFocus()
{
introPart->SetFocus();
}
void ViewIntroAdapterPart::SaveState(IMemento::Pointer memento)
{
introPart->SaveState(memento);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryViewIntroAdapterPart.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryViewIntroAdapterPart.h
index 90230592ab..665149cbb9 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryViewIntroAdapterPart.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryViewIntroAdapterPart.h
@@ -1,155 +1,155 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYVIEWINTROADAPTERPART_H_
#define BERRYVIEWINTROADAPTERPART_H_
#include <berryViewPart.h>
#include <intro/berryIIntroPart.h>
#include <intro/berryIIntroSite.h>
namespace berry
{
/**
* Simple view that will wrap an <code>IIntroPart</code>.
*
* @since 3.0
*/
class ViewIntroAdapterPart: public ViewPart
{
private:
IIntroPart::Pointer introPart;
IIntroSite::Pointer introSite;
IPropertyChangeListener::Pointer propChangeListener;
friend struct PropertyChangeIntAdapter<ViewIntroAdapterPart> ;
void PropertyChange(Object::Pointer source, int propId);
// bool handleZoomEvents = true;
// /**
// * Adds a listener that toggles standby state if the view pane is zoomed.
// */
// void AddPaneListener() {
// IWorkbenchPartSite site = getSite();
// if (site instanceof PartSite) {
// final WorkbenchPartReference ref = ((WorkbenchPartReference)((PartSite) site).getPartReference());
// ref.addInternalPropertyListener(
// new IPropertyListener() {
// public void propertyChanged(Object source, int propId) {
// if (handleZoomEvents) {
// if (propId == WorkbenchPartReference.INTERNAL_PROPERTY_ZOOMED) {
// setStandby(!ref.getPane().isZoomed());
// }
// }
// }
// });
// }
// }
// /**
// * Sets whether the CoolBar/PerspectiveBar should be visible.
// *
// * @param visible whether the CoolBar/PerspectiveBar should be visible
// */
// void SetBarVisibility(bool visible) {
// WorkbenchWindow window = (WorkbenchWindow) getSite()
// .getWorkbenchWindow();
//
// final boolean layout = (visible != window.getCoolBarVisible())
// || (visible != window.getPerspectiveBarVisible()); // don't layout unless things have actually changed
// if (visible) {
// window.setCoolBarVisible(true);
// window.setPerspectiveBarVisible(true);
// } else {
// window.setCoolBarVisible(false);
// window.setPerspectiveBarVisible(false);
// }
//
// if (layout) {
// window.getShell().layout();
// }
// }
public:
ViewIntroAdapterPart();
/**
* Forces the standby state of the intro part.
*
* @param standby update the standby state
*/
void SetStandby(bool standby);
// /**
// * Toggles handling of zoom events.
// *
// * @param handle whether to handle zoom events
// */
// void SetHandleZoomEvents(boolean handle) {
// handleZoomEvents = handle;
// }
/* (non-Javadoc)
* @see org.eclipse.ui.IWorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
void CreatePartControl(void* parent);
/* (non-Javadoc)
* @see org.eclipse.ui.IWorkbenchPart#dispose()
*/
~ViewIntroAdapterPart();
/* (non-Javadoc)
* @see org.eclipse.ui.IWorkbenchPart#getTitleImage()
*/
void* GetTitleImage();
/* (non-Javadoc)
* @see org.eclipse.ui.part.WorkbenchPart#GetPartName()
*/
std::string GetPartName();
/* (non-Javadoc)
* @see org.eclipse.ui.IViewPart#init(org.eclipse.ui.IViewSite, org.eclipse.ui.IMemento)
*/
void Init(IViewSite::Pointer site, IMemento::Pointer memento =
IMemento::Pointer(0)) throw (PartInitException);
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.IWorkbenchPart#setFocus()
*/
void SetFocus();
/* (non-Javadoc)
* @see org.eclipse.ui.IViewPart#saveState(org.eclipse.ui.IMemento)
*/
void SaveState(IMemento::Pointer memento);
};
}
#endif /* BERRYVIEWINTROADAPTERPART_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryWorkbenchIntroManager.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryWorkbenchIntroManager.cpp
index 8479639ce5..de61ddb010 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryWorkbenchIntroManager.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryWorkbenchIntroManager.cpp
@@ -1,346 +1,346 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryWorkbenchIntroManager.h"
#include "berryIntroConstants.h"
#include "internal/berryWorkbench.h"
#include "internal/berryWorkbenchPage.h"
#include "internal/berryWorkbenchPlugin.h"
#include "internal/berryPerspective.h"
#include "internal/berryNullEditorInput.h"
namespace berry
{
void WorkbenchIntroManager::CreateIntro(
SmartPointer<IWorkbenchWindow> preferredWindow)
{
IIntroDescriptor::Pointer descr = this->workbench->GetIntroDescriptor();
if (!descr)
{
return;
}
IWorkbenchPage::Pointer workbenchPage = preferredWindow->GetActivePage();
if (!workbenchPage)
{
return;
}
try
{
if (IntroIsView())
{
workbenchPage->ShowView(IntroConstants::INTRO_VIEW_ID);
}
else
{
IEditorInput::Pointer input(new NullEditorInput());
workbenchPage->OpenEditor(input, IntroConstants::INTRO_EDITOR_ID);
}
} catch (PartInitException& e)
{
//TODO IStatus
// WorkbenchPlugin::Log(IntroMessages.Intro_could_not_create_part, new Status(
// IStatus.ERROR, WorkbenchPlugin.PI_WORKBENCH, IStatus.ERROR,
// IntroMessages.Intro_could_not_create_part, e));
WorkbenchPlugin::Log("Could not create intro part.", e);
}
}
bool WorkbenchIntroManager::IntroIsView() const
{
IIntroDescriptor::Pointer descr = this->workbench->GetIntroDescriptor();
if (descr)
{
return descr->GetRole() == IntroConstants::INTRO_ROLE_VIEW;
}
return true;
}
WorkbenchIntroManager::WorkbenchIntroManager(Workbench* workbench)
: workbench(workbench)
{
// workbench.getExtensionTracker().registerHandler(new IExtensionChangeHandler(){
//
// /* (non-Javadoc)
// * @see org.eclipse.core.runtime.dynamicHelpers.IExtensionChangeHandler#addExtension(org.eclipse.core.runtime.dynamicHelpers.IExtensionTracker, org.eclipse.core.runtime.IExtension)
// */
// public void addExtension(IExtensionTracker tracker,IExtension extension) {
// //Do nothing
// }
//
// /* (non-Javadoc)
// * @see org.eclipse.core.runtime.dynamicHelpers.IExtensionChangeHandler#removeExtension(org.eclipse.core.runtime.IExtension, java.lang.Object[])
// */
// public void removeExtension(IExtension source, Object[] objects) {
// for (int i = 0; i < objects.length; i++) {
// if (objects[i] instanceof IIntroPart) {
// closeIntro((IIntroPart) objects[i]);
// }
// }
//
// }}, null);
}
bool WorkbenchIntroManager::CloseIntro(IIntroPart::Pointer part)
{
if (!introPart || introPart != part)
{
return false;
}
IWorkbenchPart::Pointer introView = GetIntroAdapterPart();
if (introView)
{
//assumption is that there is only ever one intro per workbench
//if we ever support one per window then this will need revisiting
IWorkbenchPage::Pointer page = introView->GetSite()->GetPage();
if (IntroIsView())
{
IViewReference::Pointer reference = page->FindViewReference(
IntroConstants::INTRO_VIEW_ID);
page->HideView(introView.Cast<IViewPart>());
if (!reference || reference->GetPart(false) == 0)
{
introPart = 0;
return true;
}
return false;
}
else
{
std::vector<IEditorReference::Pointer> references(page->FindEditors(IEditorInput::Pointer(0), IntroConstants::INTRO_EDITOR_ID, IWorkbenchPage::MATCH_ID));
poco_assert(references.size() < 2);
if (references.empty())
return false;
if (page->CloseEditors(std::list<IEditorReference::Pointer>(references.begin(), references.end()), false))
{
introPart = 0;
return true;
}
return false;
}
}
// if there is no part then null our reference
introPart = 0;
return true;
}
IIntroPart::Pointer WorkbenchIntroManager::ShowIntro(SmartPointer<
IWorkbenchWindow> preferredWindow, bool standby)
{
if (!preferredWindow)
{
preferredWindow = this->workbench->GetActiveWorkbenchWindow();
}
if (!preferredWindow)
{
return IIntroPart::Pointer(0);
}
IWorkbenchPart::Pointer part = GetIntroAdapterPart();
if (!part)
{
CreateIntro(preferredWindow);
}
else
{
try
{
IWorkbenchPage::Pointer page = part->GetSite()->GetPage();
IWorkbenchWindow::Pointer window = page->GetWorkbenchWindow();
if (window != preferredWindow)
{
window->GetShell()->SetActive();
}
if (IntroIsView())
{
page->ShowView(IntroConstants::INTRO_VIEW_ID);
}
else
{
IEditorInput::Pointer input(new NullEditorInput());
page->OpenEditor(input, IntroConstants::INTRO_EDITOR_ID);
}
} catch (PartInitException& e)
{
//TODO IStatus
// WorkbenchPlugin::Log("Could not open intro", new Status(IStatus.ERROR,
// WorkbenchPlugin.PI_WORKBENCH, IStatus.ERROR, "Could not open intro",
// e)); //$NON-NLS-1$ //$NON-NLS-2$
WorkbenchPlugin::Log("Could not open intro", e);
}
}
SetIntroStandby(introPart, standby);
return introPart;
}
bool WorkbenchIntroManager::IsIntroInWindow(
SmartPointer<IWorkbenchWindow> testWindow) const
{
IWorkbenchPart::Pointer part = GetIntroAdapterPart();
if (!part)
{
return false;
}
IWorkbenchWindow::Pointer window = part->GetSite()->GetWorkbenchWindow();
if (window == testWindow)
{
return true;
}
return false;
}
void WorkbenchIntroManager::SetIntroStandby(IIntroPart::Pointer part,
bool /*standby*/)
{
if (!introPart || introPart != part)
{
return;
}
IWorkbenchPart::Pointer introPart = GetIntroAdapterPart();
if (!introPart)
{
return;
}
// PartPane::Pointer pane = viewIntroAdapterPart->GetSite().Cast<PartSite>()->GetPane();
// if (standby == !pane.isZoomed())
// {
// // the zoom state is already correct - just update the part's state.
// viewIntroAdapterPart.setStandby(standby);
// return;
// }
//
// viewIntroAdapterPart.getSite().getPage().toggleZoom(pane.getPartReference());
}
bool WorkbenchIntroManager::IsIntroStandby(IIntroPart::Pointer part) const
{
if (!introPart || introPart != part)
{
return false;
}
IWorkbenchPart::Pointer introPart = GetIntroAdapterPart();
if (!introPart)
{
return false;
}
//return !((PartSite) introPart.getSite()).getPane().isZoomed();
return false;
}
IIntroPart::Pointer WorkbenchIntroManager::GetIntro() const
{
return introPart;
}
IWorkbenchPart::Pointer WorkbenchIntroManager::GetIntroAdapterPart() const
{
std::vector<IWorkbenchWindow::Pointer> windows(this->workbench->GetWorkbenchWindows());
for (std::size_t i = 0; i < windows.size(); i++)
{
IWorkbenchWindow::Pointer window = windows[i];
WorkbenchPage::Pointer page = window->GetActivePage().Cast<WorkbenchPage>();
if (!page)
{
continue;
}
if (IntroIsView())
{
std::vector<IPerspectiveDescriptor::Pointer> perspDescs(page->GetOpenPerspectives());
for (std::size_t j = 0; j < perspDescs.size(); j++)
{
IPerspectiveDescriptor::Pointer descriptor = perspDescs[j];
IViewReference::Pointer reference = page->FindPerspective(descriptor)->FindView(
IntroConstants::INTRO_VIEW_ID);
if (reference)
{
return reference->GetView(false);
}
}
}
else
{
std::vector<IEditorReference::Pointer> references(page->FindEditors(IEditorInput::Pointer(0), IntroConstants::INTRO_EDITOR_ID, IWorkbenchPage::MATCH_ID));
poco_assert(references.size() < 2);
if (references.size() == 1)
return references.front()->GetEditor(false);
}
}
return IWorkbenchPart::Pointer(0);
}
IIntroPart::Pointer WorkbenchIntroManager::CreateNewIntroPart()
throw (CoreException)
{
IntroDescriptor::Pointer introDescriptor(workbench->GetIntroDescriptor());
introPart = (introDescriptor == 0 ? IIntroPart::Pointer(0) : introDescriptor->CreateIntro());
// if (introPart)
// {
// workbench.getExtensionTracker().registerObject(
// introDescriptor.getConfigurationElement() .getDeclaringExtension(),
// introPart, IExtensionTracker.REF_WEAK);
// }
return introPart;
}
bool WorkbenchIntroManager::HasIntro() const
{
return workbench->GetIntroDescriptor() != 0;
}
bool WorkbenchIntroManager::IsNewContentAvailable()
{
IntroDescriptor::Pointer introDescriptor = workbench->GetIntroDescriptor();
if (!introDescriptor)
{
return false;
}
try
{
IntroContentDetector::Pointer contentDetector =
introDescriptor->GetIntroContentDetector();
if (contentDetector)
{
return contentDetector->IsNewContentAvailable();
}
} catch (CoreException& ex)
{
//TODO IStatus
// WorkbenchPlugin.log(new Status(IStatus.WARNING,
// WorkbenchPlugin.PI_WORKBENCH, IStatus.WARNING,
// "Could not load intro content detector", ex)); //$NON-NLS-1$
WorkbenchPlugin::Log("Could not load intro content detector", ex);
}
return false;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryWorkbenchIntroManager.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryWorkbenchIntroManager.h
index f1291a41a7..73c3624e30 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryWorkbenchIntroManager.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/intro/berryWorkbenchIntroManager.h
@@ -1,123 +1,123 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYWORKBENCHINTROMANAGER_H_
#define BERRYWORKBENCHINTROMANAGER_H_
#include <intro/berryIIntroManager.h>
#include "berryIWorkbenchPart.h"
namespace berry
{
struct IWorkbenchWindow;
class Workbench;
/**
* Workbench implementation of the IIntroManager interface.
*
* @since 3.0
*/
class WorkbenchIntroManager: public IIntroManager
{
private:
Workbench* workbench;
/**
* The currently active introPart in this workspace, <code>null</code> if none.
*/
IIntroPart::Pointer introPart;
/**
* Create a new Intro area (a view, currently) in the provided window. If there is no intro
* descriptor for this workbench then no work is done.
*
* @param preferredWindow the window to create the intro in.
*/
void CreateIntro(SmartPointer<IWorkbenchWindow> preferredWindow);
bool IntroIsView() const;
public:
/**
* Create a new instance of the receiver.
*
* @param workbench the workbench instance
*/
WorkbenchIntroManager(Workbench* workbench);
/* (non-Javadoc)
* @see org.eclipse.ui.IWorkbench#closeIntro(org.eclipse.ui.intro.IIntroPart)
*/
bool CloseIntro(IIntroPart::Pointer part);
/* (non-Javadoc)
* @see org.eclipse.ui.IWorkbench#showIntro(org.eclipse.ui.IWorkbenchWindow)
*/
IIntroPart::Pointer ShowIntro(SmartPointer<IWorkbenchWindow> preferredWindow,
bool standby);
/**
* @param testWindow the window to test
* @return whether the intro exists in the given window
*/
bool IsIntroInWindow(SmartPointer<IWorkbenchWindow> testWindow) const;
/* (non-Javadoc)
* @see org.eclipse.ui.IWorkbench#setIntroStandby(org.eclipse.ui.intro.IIntroPart, boolean)
*/
void SetIntroStandby(IIntroPart::Pointer part, bool standby);
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.IWorkbench#isIntroStandby(org.eclipse.ui.intro.IIntroPart)
*/
bool IsIntroStandby(IIntroPart::Pointer part) const;
/* (non-Javadoc)
* @see org.eclipse.ui.IWorkbench#findIntro()
*/
IIntroPart::Pointer GetIntro() const;
/**
* @return the <code>ViewIntroAdapterPart</code> for this workbench, <code>null</code> if it
* cannot be found.
*/
IWorkbenchPart::Pointer GetIntroAdapterPart() const;
/**
* @return a new IIntroPart. This has the side effect of setting the introPart field to the new
* value.
*/
IIntroPart::Pointer CreateNewIntroPart() throw (CoreException);
/* (non-Javadoc)
* @see org.eclipse.ui.IWorkbench#hasIntro()
*/
bool HasIntro() const;
bool IsNewContentAvailable();
};
}
#endif /* BERRYWORKBENCHINTROMANAGER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/intro/berryIIntroManager.h b/BlueBerry/Bundles/org.blueberry.ui/src/intro/berryIIntroManager.h
index 8e8f01a824..9993c9ca7b 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/intro/berryIIntroManager.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/intro/berryIIntroManager.h
@@ -1,141 +1,141 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIINTROMANAGER_H_
#define BERRYIINTROMANAGER_H_
#include "berryIIntroPart.h"
#include <berryIWorkbenchWindow.h>
namespace berry
{
/**
* Manages the intro part that introduces the product to new users.
* The intro part is typically shown the first time a product is started up.
* <p>
* The initial behavior of the intro part is controlled by the application
* from via the {@link org.eclipse.ui.application.WorkbenchWindowAdvisor#openIntro()}
* method.
* </p>
* <p>
* See {@link org.eclipse.ui.intro.IIntroPart} for details on where intro parts
* come from.
* </p>
* <p>
* This interface is not intended to be extended or implemented by clients.
* </p>
*
* @see org.eclipse.ui.IWorkbench#getIntroManager()
* @since 3.0
* @noimplement This interface is not intended to be implemented by clients.
*/
struct BERRY_UI IIntroManager
{
virtual ~IIntroManager();
/**
* Closes the given intro part.
*
* @param part the intro part
* @return <code>true</code> if the intro part was closed, and
* <code>false</code> otherwise. <code>false</code> is returned
* if part is <code>null</code> or it is not the intro part returned
* by {@link #getIntro()}.
*/
virtual bool CloseIntro(IIntroPart::Pointer part) = 0;
/**
* Returns the intro part. Returns <code>null</code> if there is no intro
* part, if it has been previously closed via {@link #closeIntro(IIntroPart)}
* or if there is an intro part but {@link #showIntro(IWorkbenchWindow, boolean)}
* has not yet been called to create it.
*
* @return the intro part, or <code>null</code> if none is available
*/
virtual IIntroPart::Pointer GetIntro() const = 0;
/**
* Return whether an intro is available. Note that this checks whether
* there is an applicable intro part that could be instantiated and shown
* to the user.
* Use {@link #getIntro()} to discover whether an intro part has already
* been created.
*
* @return <code>true</code> if there is an intro that could be shown, and
* <code>false</code> if there is no intro
*/
virtual bool HasIntro() const = 0;
/**
* Return the standby state of the given intro part.
*
* @param part the intro part
* @return <code>true</code> if the part in its partially
* visible standy mode, and <code>false</code> if in its fully visible state.
* <code>false</code> is returned if part is <code>null</code> or it is not
* the intro part returned by {@link #getIntro()}.
*/
virtual bool IsIntroStandby(IIntroPart::Pointer part) const = 0;
/**
* Sets the standby state of the given intro part. Intro part usually should
* render themselves differently in the full and standby modes. In standby
* mode, the part should be partially visible to the user but otherwise
* allow them to work. In full mode, the part should be fully visible and
* be the center of the user's attention.
* <p>
* This method does nothing if the part is <code>null</code> or is not
* the intro part returned by {@link #getIntro()}.
* </p>
*
* @param part the intro part, or <code>null</code>
* @param standby <code>true</code> to put the part in its partially
* visible standy mode, and <code>false</code> to make it fully visible.
*/
virtual void SetIntroStandby(IIntroPart::Pointer part, bool standby) = 0;
/**
* Shows the intro part in the given workbench window. If the intro part has
* not been created yet, one will be created. If the intro part is currently
* being shown in some workbench window, that other window is made active.
*
* @param preferredWindow the preferred workbench window, or
* <code>null</code> to indicate the currently active workbench window
* @param standby <code>true</code> to put the intro part in its partially
* visible standy mode, and <code>false</code> to make it fully visible
* @return the newly-created or existing intro part, or <code>null</code>
* if no intro part is available or if <code>preferredWindow</code> is
* <code>null</code> and there is no currently active workbench window
*/
virtual IIntroPart::Pointer ShowIntro(
IWorkbenchWindow::Pointer preferredWindow, bool standby) = 0;
/**
* Returns <code>true</code> if there is an intro content detector and it
* reports that new intro content is available.
*
* @return <code>true</code> if new intro content is available
*
* @since 3.3
*/
virtual bool IsNewContentAvailable() = 0;
};
}
#endif /* BERRYIINTROMANAGER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/intro/berryIIntroPart.h b/BlueBerry/Bundles/org.blueberry.ui/src/intro/berryIIntroPart.h
index 7bee9624f1..fda35f30af 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/intro/berryIIntroPart.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/intro/berryIIntroPart.h
@@ -1,214 +1,214 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIINTROPART_H_
#define BERRYIINTROPART_H_
#include <berryObject.h>
#include <berryMacros.h>
#include <berryIMemento.h>
#include <berryIPropertyChangeListener.h>
#include <berryUIException.h>
#include "berryIIntroSite.h"
#include <QObject>
namespace berry {
/**
* The intro part is a visual component within the workbench responsible for
* introducing the product to new users. The intro part is typically shown the
* first time a product is started up.
* <p>
* The intro part implementation is contributed to the workbench via the
* <code>org.blueberry.ui.intro</code> extension point. There can be several
* intro part implementations, and associations between intro part
* implementations and products. The workbench will only make use of the intro
* part implementation for the current product (as given by
* {@link berry::Platform#GetProduct()}. There is at most one
* intro part instance in the entire workbench, and it resides in exactly one
* workbench window at a time.
* </p>
* <p>
* This interface in not intended to be directly implemented. Rather, clients
* providing a intro part implementation should subclass
* {@link berry::IntroPart}.
* </p>
*
* @see IIntroManager#ShowIntro(IWorkbenchWindow::Pointer, bool)
* @noimplement This interface is not intended to be implemented by clients.
*/
struct BERRY_UI IIntroPart : public virtual Object { // IAdaptable {
berryInterfaceMacro(IIntroPart, berry)
~IIntroPart();
/**
* The property id for <code>getTitleImage</code> and
* <code>getTitle</code>.
*
* @since 3.2 this property now covers changes to <code>getTitle</code> in
* addition to <code>getTitleImage</code>
*/
//static const int PROP_TITLE = IWorkbenchPart::PROP_TITLE;
/**
* Returns the site for this intro part.
*
* @return the intro site
*/
virtual IIntroSite::Pointer GetIntroSite() const = 0;
/**
* Initializes this intro part with the given intro site. A memento is
* passed to the part which contains a snapshot of the part state from a
* previous session. Where possible, the part should try to recreate that
* state.
* <p>
* This method is automatically called by the workbench shortly after
* part construction. It marks the start of the intro's lifecycle. Clients
* must not call this method.
* </p>
*
* @param site the intro site
* @param memento the intro part state or <code>null</code> if there is no previous
* saved state
* @exception PartInitException if this part was not initialized
* successfully
*/
virtual void Init(IIntroSite::Pointer site, IMemento::Pointer memento)
throw(PartInitException) = 0;
/**
* Sets the standby state of this intro part. An intro part should render
* itself differently in the full and standby modes. In standby mode, the
* part should be partially visible to the user but otherwise allow them
* to work. In full mode, the part should be fully visible and be the center
* of the user's attention.
* <p>
* This method is automatically called by the workbench at appropriate
* times. Clients must not call this method directly (call
* {@link IIntroManager#setIntroStandby(IIntroPart, boolean)} instead.
* </p>
*
* @param standby <code>true</code> to put this part in its partially
* visible standy mode, and <code>false</code> to make it fully visible
*/
virtual void StandbyStateChanged(bool standby) = 0;
/**
* Saves the object state within a memento.
* <p>
* This method is automatically called by the workbench at appropriate
* times. Clients must not call this method directly.
* </p>
*
* @param memento a memento to receive the object state
*/
virtual void SaveState(IMemento::Pointer memento) = 0;
/**
* Adds a listener for changes to properties of this intro part.
* Has no effect if an identical listener is already registered.
* <p>
* The properties ids are as follows:
* <ul>
* <li><code>IIntroPart.PROP_TITLE</code> </li>
* </ul>
* </p>
*
* @param listener a property listener
*/
virtual void AddPropertyListener(IPropertyChangeListener::Pointer listener) = 0;
/**
* Creates the SWT controls for this intro part.
* <p>
* Clients should not call this method (the workbench calls this method when
* it needs to, which may be never).
* </p>
* <p>
* For implementors this is a multi-step process:
* <ol>
* <li>Create one or more controls within the parent.</li>
* <li>Set the parent layout as needed.</li>
* <li>Register any global actions with the <code>IActionService</code>.</li>
* <li>Register any popup menus with the <code>IActionService</code>.</li>
* <li>Register a selection provider with the <code>ISelectionService</code>
* (optional). </li>
* </ol>
* </p>
*
* @param parent the parent control
*/
virtual void CreatePartControl(void* parent) = 0;
/**
* Returns the title image of this intro part. If this value changes
* the part must fire a property listener event with
* {@link IIntroPart#PROP_TITLE}.
* <p>
* The title image is usually used to populate the title bar of this part's
* visual container. Since this image is managed by the part itself, callers
* must <b>not</b> dispose the returned image.
* </p>
*
* @return the title image
*/
virtual void* GetTitleImage() const = 0;
/**
* Returns the title of this intro part. If this value changes
* the part must fire a property listener event with
* {@link IIntroPart#PROP_TITLE}.
* <p>
* The title is used to populate the title bar of this part's visual
* container.
* </p>
*
* @return the intro part title (not <code>null</code>)
* @since 3.2
*/
virtual std::string GetPartName() const = 0;
/**
* Removes the given property listener from this intro part.
* Has no affect if an identical listener is not registered.
*
* @param listener a property listener
*/
virtual void RemovePropertyListener(IPropertyChangeListener::Pointer listener) = 0;
/**
* Asks this part to take focus within the workbench.
* <p>
* Clients should not call this method (the workbench calls this method at
* appropriate times). To have the workbench activate a part, use
* {@link IIntroManager#showIntro(IWorkbenchWindow, boolean)}.
* </p>
*/
virtual void SetFocus() = 0;
};
}
Q_DECLARE_INTERFACE(berry::IIntroPart, "org.blueberry.IIntroPart")
#endif /* BERRYIINTROPART_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/intro/berryIIntroSite.h b/BlueBerry/Bundles/org.blueberry.ui/src/intro/berryIIntroSite.h
index 95494b5a4b..c5a6661d9c 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/intro/berryIIntroSite.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/intro/berryIIntroSite.h
@@ -1,72 +1,72 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIINTROSITE_H_
#define BERRYIINTROSITE_H_
#include <berryIWorkbenchSite.h>
namespace berry {
/**
* The primary interface between an intro part and the workbench.
* <p>
* The workbench exposes its implemention of intro part sites via this
* interface, which is not intended to be implemented or extended by clients.
* </p>
*
* @since 3.0
* @noimplement This interface is not intended to be implemented by clients.
*/
struct BERRY_UI IIntroSite : public IWorkbenchSite {
berryInterfaceMacro(IIntroSite, berry)
~IIntroSite();
/**
* Returns the part registry extension id for this intro site's part.
* <p>
* The name comes from the <code>id</code> attribute in the configuration
* element.
* </p>
*
* @return the registry extension id
*/
virtual std::string GetId() const = 0;
/**
* Returns the unique identifier of the plug-in that defines this intro
* site's part.
*
* @return the unique identifier of the declaring plug-in
* @see org.eclipse.core.runtime.IPluginDescriptor#getUniqueIdentifier()
*/
virtual std::string GetPluginId() const = 0;
/**
* Returns the action bars for this part site.
* The intro part has exclusive use of its site's action bars.
*
* @return the action bars
*/
//virtual IActionBars GetActionBars() const = 0;
};
}
#endif /* BERRYIINTROSITE_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/intro/berryIntroContentDetector.h b/BlueBerry/Bundles/org.blueberry.ui/src/intro/berryIntroContentDetector.h
index 1b5eab0c83..6241eb1044 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/intro/berryIntroContentDetector.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/intro/berryIntroContentDetector.h
@@ -1,57 +1,57 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYINTROCONTENTDETECTOR_H_
#define BERRYINTROCONTENTDETECTOR_H_
#include <berryObject.h>
#include <berryMacros.h>
#include <org_blueberry_ui_Export.h>
namespace berry {
/**
* An intro content detector is used when starting the Workbench to determine if
* new intro content is available. Since calling this method is part of the
* Workbench start sequence, subclasses should be implemented with care as not
* to introduce noticeable delay at startup. If an intro content detector
* reports new available content, the view part showing the content will be
* opened again even if the user had closed it in a previous session. Because of
* this, the intro view part should draw the user's attention to the new content
* to avoid confusion about why the intro view part was opened again without the
* user requesting it.
*
*/
struct BERRY_UI IntroContentDetector : public Object {
berryInterfaceMacro(IntroContentDetector, berry)
/**
* Returns <code>true</code> if new intro content is available.
*
* @return <code>true</code> if new intro content is available
*/
virtual bool IsNewContentAvailable() const = 0;
};
}
Q_DECLARE_INTERFACE(berry::IntroContentDetector, "org.blueberr.IntroContentDetector")
#endif /* BERRYINTROCONTENTDETECTOR_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/intro/berryIntroPart.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/intro/berryIntroPart.cpp
index d6fa700699..50120f506b 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/intro/berryIntroPart.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/intro/berryIntroPart.cpp
@@ -1,189 +1,189 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryIntroPart.h"
#include <berrySafeRunner.h>
#include <berryObjects.h>
#include <berryIWorkbenchPartConstants.h>
#include <berryAbstractUIPlugin.h>
#include "util/berrySafeRunnable.h"
#include "internal/berryWorkbenchRegistryConstants.h"
namespace berry
{
class PropChangedRunnable: public SafeRunnable
{
public:
berryObjectMacro(PropChangedRunnable)
IPropertyChangeListener::Events::EventType::AbstractDelegate* delegate;
PropChangedRunnable(PropertyChangeEvent::Pointer event) :
event(event)
{
}
void Run()
{
delegate->Execute(event);
}
private:
PropertyChangeEvent::Pointer event;
};
std::string IntroPart::GetDefaultTitle() const
{
return "Welcome";
}
void IntroPart::FirePropertyChange(int propertyId)
{
ObjectInt::Pointer val(new ObjectInt(propertyId));
Object::Pointer source(this);
PropertyChangeEvent::Pointer event(new PropertyChangeEvent(source,
IWorkbenchPartConstants::INTEGER_PROPERTY, val, val));
typedef IPropertyChangeListener::Events::EventType::ListenerList ListenerList;
PropChangedRunnable::Pointer runnable(new PropChangedRunnable(event));
const ListenerList& listeners =
propChangeEvents.propertyChange.GetListeners();
for (ListenerList::const_iterator iter = listeners.begin(); iter
!= listeners.end(); ++iter)
{
runnable->delegate = *iter;
SafeRunner::Run(runnable);
}
}
IConfigurationElement::Pointer IntroPart::GetConfigurationElement()
{
return configElement;
}
void* IntroPart::GetDefaultImage() const
{
return 0;
}
void IntroPart::SetSite(IIntroSite::Pointer site)
{
this->partSite = site;
}
void IntroPart::SetTitleImage(void* titleImage)
{
//Do not send changes if they are the same
if (this->titleImage == titleImage)
{
return;
}
this->titleImage = titleImage;
FirePropertyChange(IWorkbenchPartConstants::PROP_TITLE);
}
void IntroPart::SetTitle(const std::string& titleLabel)
{
if (this->titleLabel == titleLabel)
return;
this->titleLabel = titleLabel;
FirePropertyChange(IWorkbenchPartConstants::PROP_TITLE);
}
void IntroPart::AddPropertyListener(IPropertyChangeListener::Pointer l)
{
propChangeEvents.AddListener(l);
}
IntroPart::~IntroPart()
{
}
IIntroSite::Pointer IntroPart::GetIntroSite() const
{
return partSite;
}
void* IntroPart::GetTitleImage() const
{
if (titleImage != 0)
{
return titleImage;
}
return GetDefaultImage();
}
std::string IntroPart::GetPartName() const
{
if (!titleLabel.empty())
{
return titleLabel;
}
return GetDefaultTitle();
}
void IntroPart::Init(IIntroSite::Pointer site, IMemento::Pointer /*memento*/)
throw (PartInitException)
{
SetSite(site);
}
void IntroPart::RemovePropertyListener(IPropertyChangeListener::Pointer l)
{
propChangeEvents.RemoveListener(l);
}
void IntroPart::SaveState(IMemento::Pointer /*memento*/)
{
//no-op
}
void IntroPart::SetInitializationData(IConfigurationElement::Pointer cfig,
const std::string& /*propertyName*/, Object::Pointer /*data*/)
{
// Save config element.
configElement = cfig;
cfig->GetAttribute(WorkbenchRegistryConstants::ATT_LABEL, titleLabel);
// Icon.
std::string strIcon;
if (!cfig->GetAttribute(WorkbenchRegistryConstants::ATT_ICON, strIcon))
{
return;
}
imageDescriptor = AbstractUIPlugin::ImageDescriptorFromPlugin(
configElement->GetContributor(), strIcon);
if (!imageDescriptor)
{
return;
}
titleImage = imageDescriptor->CreateImage(true);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/intro/berryIntroPart.h b/BlueBerry/Bundles/org.blueberry.ui/src/intro/berryIntroPart.h
index 8f73a40255..971fbdae84 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/intro/berryIntroPart.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/intro/berryIntroPart.h
@@ -1,225 +1,225 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYINTROPART_H_
#define BERRYINTROPART_H_
#include "berryIIntroPart.h"
#include "berryIIntroSite.h"
#include <berryIConfigurationElement.h>
#include <berryImageDescriptor.h>
#include <berryIExecutableExtension.h>
#include <berryIPropertyChangeListener.h>
namespace berry
{
/**
* Abstract base implementation of an intro part.
* <p>
* Subclasses must implement the following methods:
* <ul>
* <li><code>CreatePartControl</code>- to create the intro part's controls
* </li>
* <li><code>SetFocus</code>- to accept focus</li>
* <li><code>StandbyStateChanged</code>- to change the standby mode</li>
* </ul>
* </p>
* <p>
* Subclasses may extend or reimplement the following methods as required:
* <ul>
* <li><code>SetInitializationData</code>- extend to provide additional
* initialization when the intro extension is instantiated</li>
* <li><code>Init(IIntroSite::Pointer, IMemento::Pointer)</code>- extend to provide additional
* initialization when intro is assigned its site</li>
* <li><code>GetAdapter</code>- reimplement to make their intro adaptable
* </li>
* </ul>
* </p>
*/
class BERRY_UI IntroPart: public QObject, public IIntroPart, public IExecutableExtension
{
Q_OBJECT
Q_INTERFACES(berry::IIntroPart berry::IExecutableExtension)
private:
IConfigurationElement::Pointer configElement;
ImageDescriptor::Pointer imageDescriptor;
IIntroSite::Pointer partSite;
void* titleImage;
std::string titleLabel;
IPropertyChangeListener::Events propChangeEvents;
/**
* Return the default title string.
*
* @return the default title string
*/
std::string GetDefaultTitle() const;
protected:
/**
* Fires a property changed event.
*
* @param propertyId
* the id of the property that changed
*/
void FirePropertyChange(int propertyId);
/**
* Returns the configuration element for this part. The configuration
* element comes from the plug-in registry entry for the extension defining
* this part.
*
* @return the configuration element for this part
*/
IConfigurationElement::Pointer GetConfigurationElement();
/**
* Returns the default title image.
*
* @return the default image
*/
void* GetDefaultImage() const;
/**
* Sets the part site.
* <p>
* Subclasses must invoke this method from {@link org.eclipse.ui.intro.IIntroPart#init(IIntroSite, IMemento)}.
* </p>
*
* @param site the intro part site
*/
void SetSite(IIntroSite::Pointer site);
/**
* Sets or clears the title image of this part.
*
* @param titleImage
* the title image, or <code>null</code> to clear
*/
void SetTitleImage(void* titleImage);
/**
* Set the title string for this part.
*
* @param titleLabel the title string. Must not be <code>null</code>.
* @since 3.2
*/
void SetTitle(const std::string& titleLabel);
public:
/* (non-Javadoc)
* @see org.eclipse.ui.intro.IIntroPart#addPropertyListener(org.eclipse.ui.IPropertyListener)
*/
void AddPropertyListener(IPropertyChangeListener::Pointer l);
/**
* The <code>IntroPart</code> implementation of this
* <code>IIntroPart</code> method disposes the title image loaded by
* <code>setInitializationData</code>. Subclasses may extend.
*/
~IntroPart();
/**
* This implementation of the method declared by <code>IAdaptable</code>
* passes the request along to the platform's adapter manager; roughly
* <code>Platform.getAdapterManager().getAdapter(this, adapter)</code>.
* Subclasses may override this method (however, if they do so, they should
* invoke the method on their superclass to ensure that the Platform's
* adapter manager is consulted).
*/
// Object getAdapter(Class adapter) {
// return Platform.getAdapterManager().getAdapter(this, adapter);
// }
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.intro.IIntroPart#getIntroSite()
*/
IIntroSite::Pointer GetIntroSite() const;
/* (non-Javadoc)
* @see org.eclipse.ui.intro.IIntroPart#getTitleImage()
*/
void* GetTitleImage() const;
/* (non-Javadoc)
* @see org.eclipse.ui.intro.IIntroPart#getTitle()
*/
std::string GetPartName() const;
/**
* The base implementation of this {@link org.eclipse.ui.intro.IIntroPart}method ignores the
* memento and initializes the part in a fresh state. Subclasses may extend
* to perform any state restoration, but must call the super method.
*
* @param site
* the intro site
* @param memento
* the intro part state or <code>null</code> if there is no
* previous saved state
* @exception PartInitException
* if this part was not initialized successfully
*/
void Init(IIntroSite::Pointer site, IMemento::Pointer memento)
throw (PartInitException);
/* (non-Javadoc)
* @see org.eclipse.ui.intro.IIntroPart#removePropertyListener(org.eclipse.ui.IPropertyListener)
*/
void RemovePropertyListener(IPropertyChangeListener::Pointer l);
/**
* The base implementation of this {@link org.eclipse.ui.intro.IIntroPart} method does nothing.
* Subclasses may override.
*
* @param memento
* a memento to receive the object state
*/
void SaveState(IMemento::Pointer memento);
/**
* The <code>IntroPart</code> implementation of this
* <code>IExecutableExtension</code> records the configuration element in
* and internal state variable (accessible via <code>getConfigElement</code>).
* It also loads the title image, if one is specified in the configuration
* element. Subclasses may extend.
*
* Should not be called by clients. It is called by the core plugin when
* creating this executable extension.
*/
void SetInitializationData(IConfigurationElement::Pointer cfig,
const std::string& propertyName, Object::Pointer data);
};
}
#endif /* BERRYINTROPART_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/presentations/berryIPresentablePart.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/presentations/berryIPresentablePart.cpp
index 5e4144648a..af1f1c3637 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/presentations/berryIPresentablePart.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/presentations/berryIPresentablePart.cpp
@@ -1,43 +1,43 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryIPresentablePart.h"
#include "berryIWorkbenchPartConstants.h"
namespace berry
{
const int IPresentablePart::PROP_DIRTY = IWorkbenchPartConstants::PROP_DIRTY;
const int IPresentablePart::PROP_INPUT = IWorkbenchPartConstants::PROP_INPUT;
const int IPresentablePart::PROP_TITLE = IWorkbenchPartConstants::PROP_TITLE;
const int IPresentablePart::PROP_CONTENT_DESCRIPTION =
IWorkbenchPartConstants::PROP_CONTENT_DESCRIPTION;
const int IPresentablePart::PROP_PART_NAME =
IWorkbenchPartConstants::PROP_PART_NAME;
const int IPresentablePart::PROP_BUSY = 0x92;
const int IPresentablePart::PROP_TOOLBAR = 0x93;
const int IPresentablePart::PROP_HIGHLIGHT_IF_BACK = 0x94;
const int IPresentablePart::PROP_PANE_MENU = 0x302;
const int IPresentablePart::PROP_PREFERRED_SIZE =
IWorkbenchPartConstants::PROP_PREFERRED_SIZE;
IPresentablePart::~IPresentablePart()
{
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/presentations/berryIPresentablePart.h b/BlueBerry/Bundles/org.blueberry.ui/src/presentations/berryIPresentablePart.h
index c125ed1359..361d2f4d1c 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/presentations/berryIPresentablePart.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/presentations/berryIPresentablePart.h
@@ -1,269 +1,269 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIPRESENTABLEPART_H_
#define BERRYIPRESENTABLEPART_H_
#include <berryMacros.h>
#include "berryISizeProvider.h"
#include "berryRectangle.h"
#include "berryIPropertyChangeListener.h"
namespace berry {
/**
* This is a skin's interface to the contents of a view or editor. Note that this
* is essentially the same as IWorkbenchPart, except it does not provide access
* to lifecycle events and allows repositioning of the part.
*
* Not intended to be implemented by clients.
*
* @since 3.0
* @since 3.4 now extends {@link org.blueberry.ui.ISizeProvider}
* @noimplement This interface is not intended to be implemented by clients.
*/
struct BERRY_UI IPresentablePart : public Object, public ISizeProvider {
berryInterfaceMacro(IPresentablePart, berry);
~IPresentablePart();
/**
* The property id for <code>isDirty</code>.
*/
static const int PROP_DIRTY; // = IWorkbenchPartConstants.PROP_DIRTY;
/**
* The property id for <code>getEditorInput</code>.
*/
static const int PROP_INPUT; // = IWorkbenchPartConstants.PROP_INPUT;
/**
* The property id for <code>getTitle</code>, <code>getTitleImage</code>
* and <code>getTitleToolTip</code>.
*/
static const int PROP_TITLE; // = IWorkbenchPartConstants.PROP_TITLE;
/**
* The property id for <code>IWorkbenchPart2.getContentDescription()</code>
*/
static const int PROP_CONTENT_DESCRIPTION; // = IWorkbenchPartConstants.PROP_CONTENT_DESCRIPTION;
/**
* The property id for <code>IWorkbenchPart2.getContentDescription()</code>
*/
static const int PROP_PART_NAME; // = IWorkbenchPartConstants.PROP_PART_NAME;
/**
* The property id for <code>isBusy</code>.
*/
static const int PROP_BUSY; // = 0x92;
/**
* The property id for toolbar changes
*/
static const int PROP_TOOLBAR; // = 0x93;
/**
* The property id for highlighting the
* part if it is not in front.
*/
static const int PROP_HIGHLIGHT_IF_BACK; // = 0x94;
/**
* The property id for pane menu changes
*/
static const int PROP_PANE_MENU; // = 0x302;
/**
* The property id for preferred size changes
* @since 3.4
*/
static const int PROP_PREFERRED_SIZE; // = IWorkbenchPartConstants.PROP_PREFERRED_SIZE;
/**
* Sets the bounds of this part.
*
* @param bounds bounding rectangle (not null)
*/
virtual void SetBounds(const Rectangle& bounds) = 0;
/**
* Notifies the part whether or not it is visible in the current
* perspective. A part is visible iff any part of its widgetry can
* be seen.
*
* @param isVisible true if the part has just become visible, false
* if the part has just become hidden
*/
virtual void SetVisible(bool isVisible) = 0;
/**
* Forces this part to have focus.
*/
virtual void SetFocus() = 0;
/**
* Adds a listener for changes to properties of this workbench part.
* Has no effect if an identical listener is already registered.
* <p>
* The properties ids are defined by the PROP_* constants, above.
* </p>
*
* @param listener a property listener (not null)
*/
virtual void AddPropertyListener(IPropertyChangeListener::Pointer listener) = 0;
/**
* Remove a listener that was previously added using addPropertyListener.
*
* @param listener a property listener (not null)
*/
virtual void RemovePropertyListener(IPropertyChangeListener::Pointer listener) = 0;
/**
* Returns the short name of the part. This is used as the text on
* the tab when this part is stacked on top of other parts.
*
* @return the short name of the part (not null)
*/
virtual std::string GetName() const = 0;
/**
* Returns the title of this workbench part. If this value changes
* the part must fire a property listener event with
* <code>PROP_TITLE</code>.
* <p>
* The title is used to populate the title bar of this part's visual
* container.
* </p>
*
* @return the workbench part title (not null)
*/
virtual std::string GetTitle() const = 0;
/**
* Returns the status message from the part's title, or the empty string if none.
* This is a substring of the part's title. A typical title will consist of
* the part name, a separator, and a status message describing the current contents.
* <p>
* Presentations can query getName() and getTitleStatus() if they want to display
* the status message and name separately, or they can use getTitle() if they want
* to display the entire title.
* </p>
*
* @return the status message or the empty string if none (not null)
*/
virtual std::string GetTitleStatus() const = 0;
/**
* Returns the title image of this workbench part. If this value changes
* the part must fire a property listener event with
* <code>PROP_TITLE</code>.
* <p>
* The title image is usually used to populate the title bar of this part's
* visual container. Since this image is managed by the part itself, callers
* must <b>not</b> dispose the returned image.
* </p>
*
* @return the title image
*/
virtual void* GetTitleImage() = 0;
/**
* Returns the title tool tip text of this workbench part. If this value
* changes the part must fire a property listener event with
* <code>PROP_TITLE</code>.
* <p>
* The tool tip text is used to populate the title bar of this part's
* visual container.
* </p>
*
* @return the workbench part title tool tip (not null)
*/
virtual std::string GetTitleToolTip() const = 0;
/**
* Returns true iff the contents of this part have changed recently. For
* editors, this indicates that the part has changed since the last save.
* For views, this indicates that the view contains interesting changes
* that it wants to draw the user's attention to.
*
* @return true iff the part is dirty
*/
virtual bool IsDirty() const = 0;
/**
* Return true if the the receiver is currently in a busy state.
* @return boolean true if busy
*/
virtual bool IsBusy() const = 0;
/**
* Returns true iff this part can be closed
*
* @return true iff this part can be closed
* @since 3.1
*/
virtual bool IsCloseable() const = 0;
/**
* Returns the local toolbar for this part, or null if this part does not
* have a local toolbar. Callers must not dispose or downcast the return value.
*
* @return the local toolbar for the part, or null if none
*/
virtual void* GetToolBar() = 0;
/**
* Returns the menu for this part or null if none
*
* @return the menu for this part or null if none
*/
//virtual IPartMenu getMenu();
/**
* Returns an SWT control that can be used to indicate the tab order for
* this part. This can be returned as part of the result to
* {@link StackPresentation#getTabList(IPresentablePart)}. Any other use of this control is
* unsupported. This may return a placeholder control that is only
* meaningful in the context of <code>getTabList</code>.
*
* @return the part's control (not null)
*/
virtual void* GetControl() = 0;
/**
* Get a property from the part's arbitrary property set.
* <p>
* <b>Note:</b> this is a different set of properties than the ones covered
* by the PROP_* constants.
* </p>
*
* @param key
* The property key to retrieve. Must not be <code>null</code>.
* @return the property, or <code>null</code> if that property is not set.
* @since 3.3
*/
virtual std::string GetPartProperty(const std::string& key) const = 0;
};
}
#endif /* BERRYIPRESENTABLEPART_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/presentations/berryIPresentationFactory.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/presentations/berryIPresentationFactory.cpp
index 563a6de5e6..630fdcae0e 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/presentations/berryIPresentationFactory.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/presentations/berryIPresentationFactory.cpp
@@ -1,34 +1,34 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryIPresentationFactory.h"
#include "berryConstants.h"
namespace berry
{
IPresentationFactory::~IPresentationFactory()
{
}
int IPresentationFactory::SASHTYPE_NORMAL = 0;
int IPresentationFactory::SASHTYPE_FLOATING = 1 << 1;
int IPresentationFactory::SASHORIENTATION_HORIZONTAL = Constants::HORIZONTAL; // 1<<8
int IPresentationFactory::SASHORIENTATION_VERTICAL = Constants::VERTICAL; // 1<<9
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/presentations/berryIPresentationFactory.h b/BlueBerry/Bundles/org.blueberry.ui/src/presentations/berryIPresentationFactory.h
index ae2ba8077c..58b43b10c2 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/presentations/berryIPresentationFactory.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/presentations/berryIPresentationFactory.h
@@ -1,187 +1,187 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIPRESENTATIONFACTORY_H_
#define BERRYIPRESENTATIONFACTORY_H_
#include <berryMacros.h>
#include "berryStackPresentation.h"
#include <QObject>
namespace berry
{
/**
* This is a factory for presentation objects that control the appearance of
* editors, views and other components in the workbench.
*
* @since 3.0
*/
class BERRY_UI IPresentationFactory {
public:
berryManifestMacro(IPresentationFactory, berry);
virtual ~IPresentationFactory();
/**
* Bit value for the createSash method's 'style' parameter.
* @since 3.4
*/
static int SASHTYPE_NORMAL; // = 0;
/**
* Bit value for the createSash method's 'style' parameter.
* @since 3.4
*/
static int SASHTYPE_FLOATING; // = 1<<1;
/**
* Bit value for the createSash method's 'style' parameter.
* @since 3.4
*/
static int SASHORIENTATION_HORIZONTAL; // = SWT.HORIZONTAL; // 1<<8
/**
* Bit value for the createSash method's 'style' parameter.
* @since 3.4
*/
static int SASHORIENTATION_VERTICAL; // = SWT.VERTICAL; // 1<<9
/**
* Creates an editor presentation for presenting editors.
* <p>
* The presentation creates its controls under the given parent composite.
* </p>
*
* @param parent
* the parent composite to use for the presentation's controls
* @param site
* the site used for communication between the presentation and
* the workbench
* @return a newly created part presentation
*/
virtual StackPresentation::Pointer CreateEditorPresentation(
void* parent, IStackPresentationSite::Pointer site) = 0;
/**
* Creates a stack presentation for presenting regular docked views.
* <p>
* The presentation creates its controls under the given parent composite.
* </p>
*
* @param parent
* the parent composite to use for the presentation's controls
* @param site
* the site used for communication between the presentation and
* the workbench
* @return a newly created part presentation
*/
virtual StackPresentation::Pointer CreateViewPresentation(void* parent,
IStackPresentationSite::Pointer site) = 0;
/**
* Creates a standalone stack presentation for presenting a standalone view.
* A standalone view cannot be docked together with other views. The title
* of a standalone view may be hidden.
* <p>
* The presentation creates its controls under the given parent composite.
* </p>
*
* @param parent
* the parent composite to use for the presentation's controls
* @param site
* the site used for communication between the presentation and
* the workbench
* @param showTitle
* <code>true</code> to show the title for the view,
* <code>false</code> to hide it
* @return a newly created part presentation
*/
virtual StackPresentation::Pointer CreateStandaloneViewPresentation(
void* parent, IStackPresentationSite::Pointer site, bool showTitle) = 0;
/**
* Creates the status line manager for the window.
* Subclasses may override.
*
* @return the window's status line manager
*/
// public IStatusLineManager createStatusLineManager() {
// return new StatusLineManager();
// }
/**
* Creates the control for the window's status line.
* Subclasses may override.
*
* @param statusLine the window's status line manager
* @param parent the parent composite
* @return the window's status line control
*/
// public Control createStatusLineControl(IStatusLineManager statusLine,
// Composite parent) {
// return ((StatusLineManager) statusLine).createControl(parent, SWT.NONE);
// }
/**
* Returns a globally unique identifier for this type of presentation factory. This is used
* to ensure that one presentation is not restored from mementos saved by a different
* presentation.
*
* @return a globally unique identifier for this type of presentation factory.
*/
virtual std::string GetId() = 0;
/**
* Creates the Sash control that is used to separate view and editor parts.
*
* @param parent the parent composite
* @param style A bit set giving both the 'type' of the desired sash and
* its orientation (i.e. one 'SASHTYPE' value and one "SASHORIENTATION" value).
* @return the sash control
* @since 3.4
*/
virtual void* CreateSash(void* parent, int style) = 0;
// {
// int orientation = style & (SASHORIENTATION_HORIZONTAL
// | SASHORIENTATION_VERTICAL);
// Sash sash = new Sash(parent, orientation | SWT.SMOOTH);
// return sash;
// }
/**
* Returns the size of the Sash control that is used to separate view and editor parts.
*
* @param style A bit set giving both the 'type' of the desired sash and
* its orientation.
* @return the sash size
* @since 3.4
*/
virtual int GetSashSize(int style) = 0;
/**
* Applies changes of the current theme to the user interface.
*/
virtual void UpdateTheme() = 0;
};
}
Q_DECLARE_INTERFACE(berry::IPresentationFactory, "org.blueberry.IPresentationFactory")
#endif /* BERRYABSTRACTPRESENTATIONFACTORY_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/presentations/berryIPresentationSerializer.h b/BlueBerry/Bundles/org.blueberry.ui/src/presentations/berryIPresentationSerializer.h
index ca52a07498..bb85400cf2 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/presentations/berryIPresentationSerializer.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/presentations/berryIPresentationSerializer.h
@@ -1,66 +1,66 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIPRESENTATIONSERIALIZER_H_
#define BERRYIPRESENTATIONSERIALIZER_H_
#include "berryIPresentablePart.h"
#include <string>
namespace berry {
/**
* This interface is given to a StackPresentation when it is loading or saving
* its state.
*
* Not intended to be implemented by clients
*
* @since 3.0
* @noimplement This interface is not intended to be implemented by clients.
*/
struct BERRY_UI IPresentationSerializer {
/**
* Returns a unique identifier for the given part. The identifier can later
* be used to restore the original part by calling getPart(...). This identifier
* is guaranteed to be unique within a particular StackPresentation. However,
* the same part may be assigned a different ID each time the presentation is saved.
*
* @param part a part to be identified (not null)
* @return a unique identifier for the part (not null)
*/
virtual std::string GetId(IPresentablePart::Pointer part) = 0;
/**
* Returns a presentable part, given an id that was generated when the presentation
* was saved.
*
* @param id an ID that was generated by getId(IPresentablePart) when the presentation
* was saved
* @return the presentable part associated with the given id, or null if none. Note
* that even if the ID was valid when the presentation was saved, it may not
* be valid when the presentation is restored. Callers must be prepared
* to handle a null result.
*/
virtual IPresentablePart::Pointer GetPart(const std::string& id) = 0;
virtual ~IPresentationSerializer();
};
}
#endif /* BERRYIPRESENTATIONSERIALIZER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/presentations/berryIStackPresentationSite.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/presentations/berryIStackPresentationSite.cpp
index ee6c917934..e91fba242b 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/presentations/berryIStackPresentationSite.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/presentations/berryIStackPresentationSite.cpp
@@ -1,30 +1,30 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryIStackPresentationSite.h"
namespace berry {
int IStackPresentationSite::STATE_MINIMIZED = 0;
int IStackPresentationSite::STATE_MAXIMIZED = 1;
int IStackPresentationSite::STATE_RESTORED = 2;
IStackPresentationSite::~IStackPresentationSite()
{
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/presentations/berryIStackPresentationSite.h b/BlueBerry/Bundles/org.blueberry.ui/src/presentations/berryIStackPresentationSite.h
index ea4a549e2e..b719fc5491 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/presentations/berryIStackPresentationSite.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/presentations/berryIStackPresentationSite.h
@@ -1,193 +1,193 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYISTACKPRESENTATIONSITE_H_
#define BERRYISTACKPRESENTATIONSITE_H_
#include <berryMacros.h>
#include <list>
#include "berryIPresentablePart.h"
#include <org_blueberry_ui_Export.h>
#include "berryPoint.h"
namespace berry
{
/**
* Represents the main interface between a StackPresentation and the workbench.
*
* Not intended to be implemented by clients.
*
* @since 3.0
* @noimplement This interface is not intended to be implemented by clients.
*/
struct BERRY_UI IStackPresentationSite : public Object
{
berryInterfaceMacro(IStackPresentationSite, berry);
static int STATE_MINIMIZED; // = 0;
static int STATE_MAXIMIZED; // = 1;
static int STATE_RESTORED; // = 2;
~IStackPresentationSite();
/**
* Sets the state of the container. Called by the presentation when the
* user causes the the container to be minimized, maximized, etc.
*
* @param newState one of the STATE_* constants
*/
virtual void SetState(int newState) = 0;
/**
* Returns the current state of the site (one of the STATE_* constants)
*
* @return the current state of the site (one of the STATE_* constants)
*/
virtual int GetState() = 0;
/**
* Returns true iff the site supports the given state
*
* @param state one of the STATE_* constants, above
* @return true iff the site supports the given state
*/
virtual bool SupportsState(int state) = 0;
/**
* Begins dragging the given part
*
* @param beingDragged the part to drag (not null)
* @param initialPosition the mouse position at the time of the initial mousedown
* (display coordinates, not null)
* @param keyboard true iff the drag was initiated via mouse dragging,
* and false if the drag may be using the keyboard
*/
virtual void DragStart(IPresentablePart::Pointer beingDragged,
Point& initialPosition, bool keyboard) = 0;
/**
* Closes the given set of parts.
*
* @param toClose the set of parts to close (Not null. All of the entries must be non-null)
*/
virtual void Close(const std::vector<IPresentablePart::Pointer>& toClose) = 0;
/**
* Begins dragging the entire stack of parts
*
* @param initialPosition the mouse position at the time of the initial mousedown (display coordinates,
* not null)
* @param keyboard true iff the drag was initiated via mouse dragging,
* and false if the drag may be using the keyboard
*/
virtual void DragStart(Point& initialPosition, bool keyboard) = 0;
/**
* Returns true iff this site will allow the given part to be closed
*
* @param toClose part to test (not null)
* @return true iff the part may be closed
*/
virtual bool IsCloseable(IPresentablePart::Pointer toClose) = 0;
/**
* Returns true iff the given part can be dragged. If this
* returns false, the given part should not trigger a drag.
*
* @param toMove part to test (not null)
* @return true iff this part is a valid drag source
*/
virtual bool IsPartMoveable(IPresentablePart::Pointer toMove) = 0;
/**
* Returns true iff this entire stack can be dragged
*
* @return true iff the stack can be dragged
*/
virtual bool IsStackMoveable() = 0;
/**
* Makes the given part active
*
* @param toSelect
*/
virtual void SelectPart(IPresentablePart::Pointer toSelect) = 0;
/**
* Returns the currently selected part or null if the stack is empty
*
* @return the currently selected part or null if the stack is empty
*/
virtual IPresentablePart::Pointer GetSelectedPart() = 0;
/**
* Adds system actions to the given menu manager. The site may
* make use of the following group ids:
* <ul>
* <li><code>close</code>, for close actions</li>
* <li><code>size</code>, for resize actions</li>
* <li><code>misc</code>, for miscellaneous actions</li>
* </ul>
* The presentation can control the insertion position by creating
* these group IDs where appropriate.
*
* @param menuManager the menu manager to populate
*/
//virtual void AddSystemActions(IMenuManager menuManager);
/**
* Notifies the workbench that the preferred size of the presentation has
* changed. Hints to the workbench that it should trigger a layout at the
* next opportunity.
*
* @since 3.1
*/
virtual void FlushLayout() = 0;
/**
* Returns the list of presentable parts currently in this site
*
* @return the list of presentable parts currently in this site
* @since 3.1
*/
virtual std::list<IPresentablePart::Pointer> GetPartList() = 0;
/**
* Returns the property with the given id or <code>null</code>. Folder
* properties are an extensible mechanism for perspective authors to
* customize the appearance of view stacks. The list of customizable
* properties is determined by the presentation factory, and set in the
* perspective factory.
*
* @param id
* Must not be <code>null</code>.
* @return property value, or <code>null</code> if the property is not
* set.
* @since 3.3
*/
virtual std::string GetProperty(const std::string& id) = 0;
};
}
#endif /* BERRYISTACKPRESENTATIONSITE_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/presentations/berryStackDropResult.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/presentations/berryStackDropResult.cpp
index 0c67f919f5..befe56e8fc 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/presentations/berryStackDropResult.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/presentations/berryStackDropResult.cpp
@@ -1,39 +1,39 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryStackDropResult.h"
namespace berry
{
StackDropResult::StackDropResult(const Rectangle& snapRectangle,
Object::Pointer cookie) :
snapRectangle(snapRectangle), cookie(cookie)
{
}
Rectangle StackDropResult::GetSnapRectangle()
{
return snapRectangle;
}
Object::Pointer StackDropResult::GetCookie()
{
return cookie;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/presentations/berryStackDropResult.h b/BlueBerry/Bundles/org.blueberry.ui/src/presentations/berryStackDropResult.h
index 0b1c07ccb7..81f04d5f9c 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/presentations/berryStackDropResult.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/presentations/berryStackDropResult.h
@@ -1,79 +1,79 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYSTACKDROPRESULT_H_
#define BERRYSTACKDROPRESULT_H_
#include <berryMacros.h>
#include <berryObject.h>
#include "berryRectangle.h"
namespace berry {
/**
* This structure describes a drop event that will cause a dragged part
* to be stacked in a position currently occupied by another part.
*
*/
class BERRY_UI StackDropResult : public Object {
public:
berryObjectMacro(StackDropResult);
private:
Rectangle snapRectangle;
Object::Pointer cookie;
public:
/**
* Creates a drop result
*
* @param snapRectangle region that should be highlighted by the tracking
* rectangle (display coordinates)
* @param cookie the presentation may attach an object to this drop result
* in order to identify the drop location. This object will be passed back into the
* presentation's add method.
*/
StackDropResult(const Rectangle& snapRectangle, Object::Pointer cookie);
/**
* Returns a rectangle (screen coordinates) describing the target location
* for this drop operation. While dragging, the tracking rectangle will
* snap to this position.
*
* @return a snap rectangle (not null)
*/
Rectangle GetSnapRectangle();
/**
* Returns the cookie for this drop result. This object provided by the presentation,
* but is remembered by the workbench. It will be given back to the presentation's add
* method to indicate that a part is being added as a result of a drop operation.
*
* @return the drop cookie for this drop result
*/
Object::Pointer GetCookie();
};
}
#endif /* BERRYSTACKDROPRESULT_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/presentations/berryStackPresentation.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/presentations/berryStackPresentation.cpp
index 82d20e4e46..6950cdc509 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/presentations/berryStackPresentation.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/presentations/berryStackPresentation.cpp
@@ -1,105 +1,105 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryStackPresentation.h"
#include "berryConstants.h"
namespace berry
{
const int StackPresentation::AS_INACTIVE = 0;
const int StackPresentation::AS_ACTIVE_FOCUS = 1;
const int StackPresentation::AS_ACTIVE_NOFOCUS = 2;
StackPresentation::StackPresentation(IStackPresentationSite::Pointer stackSite)
: site(stackSite)
{
poco_assert(stackSite.IsNotNull());
}
StackPresentation::~StackPresentation()
{
// Do not remove empty destructor. Otherwise, the WeakPointer member "site"
// will be destroyed in a strange way and the destruction of a DefaultStackPresentationSite
// instance will notify the WeakPointer "site" (although it was destroyed, the
// DefaultStackPresentationSite somehow still has a MessageDelegate for the destroy
// event, pointing to the destroyed "site").
}
IStackPresentationSite::Pointer StackPresentation::GetSite()
{
return site.Lock();
}
Point StackPresentation::ComputeMinimumSize()
{
return Point(0, 0);
}
int StackPresentation::GetSizeFlags(bool /*width*/)
{
bool hasMaximumSize = this->GetSite()->GetState()
== IStackPresentationSite::STATE_MINIMIZED;
return Constants::MIN | (hasMaximumSize ? Constants::MAX : 0);
}
int StackPresentation::ComputePreferredSize(bool width, int /*availableParallel*/,
int /*availablePerpendicular*/, int preferredResult)
{
Point p = this->ComputeMinimumSize();
int minSize = width ? p.x : p.y;
if (this->GetSite()->GetState() == IStackPresentationSite::STATE_MINIMIZED
|| preferredResult < minSize)
{
return minSize;
}
return preferredResult;
}
void StackPresentation::MovePart(IPresentablePart::Pointer toMove,
Object::Pointer cookie)
{
this->RemovePart(toMove);
this->AddPart(toMove, cookie);
if (this->GetSite()->GetSelectedPart() == toMove)
{
this->SelectPart(toMove);
toMove->SetFocus();
}
}
void StackPresentation::SaveState(IPresentationSerializer* /*context*/, IMemento::Pointer /*memento*/)
{
}
void StackPresentation::RestoreState(IPresentationSerializer* /*context*/, IMemento::Pointer /*memento*/)
{
}
void StackPresentation::ShowPartList()
{
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/presentations/berryStackPresentation.h b/BlueBerry/Bundles/org.blueberry.ui/src/presentations/berryStackPresentation.h
index 7e30ebcc55..af1c22f45b 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/presentations/berryStackPresentation.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/presentations/berryStackPresentation.h
@@ -1,275 +1,275 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYSTACKPRESENTATION_H_
#define BERRYSTACKPRESENTATION_H_
#include <berryMacros.h>
#include <org_blueberry_ui_Export.h>
#include "berryIStackPresentationSite.h"
#include "berryIPresentationSerializer.h"
#include "berryStackDropResult.h"
#include "berryISizeProvider.h"
#include "berryIMemento.h"
namespace berry
{
/**
* This represents an object that can supply trim around a IPresentablePart.
* Clients can implement subclasses to provide the appearance for editor workbooks,
* view folders, fast views, and detached windows.
* <p>
* StackPresentations do not store any persistent state and cannot
* directly make changes to the workbench. They are given an IStackPresentationSite
* reference on creation, which allows them to send events and requests to the workbench.
* However, the workbench is free to ignore these requests. The workbench will call one
* of the public methods on StackPresentation when (and if) the presentation is expected to
* change state.
* </p>
* <p>
* For example, if the user clicks a button that is intended to close a part, the
* StackPresentation will send a close request to its site, but should not assume
* that the part has been closed until the workbench responds with a call
* <code>StackPresentation.remove</code>.
* </p>
*
* @since 3.0
*/
class BERRY_UI StackPresentation : public Object, public ISizeProvider {
public:
berryObjectMacro(StackPresentation);
private:
/**
* The presentation site.
*/
IStackPresentationSite::WeakPtr site;
protected:
/**
* Constructs a new stack presentation with the given site.
*
* @param stackSite the stack site
*/
StackPresentation(IStackPresentationSite::Pointer stackSite);
~StackPresentation();
/**
* Returns the presentation site (not null).
* @return IStackPresentationSite
*/
IStackPresentationSite::Pointer GetSite();
public:
/**
* Inactive state. This is the default state for deselected presentations.
*/
static const int AS_INACTIVE; // = 0;
/**
* Activation state indicating that one of the parts in the presentation currently has focus
*/
static const int AS_ACTIVE_FOCUS; // = 1;
/**
* Activation state indicating that none of the parts in the presentation have focus, but
* one of the parts is being used as the context for global menus and toolbars
*/
static const int AS_ACTIVE_NOFOCUS; // = 2;
/**
* Sets the bounding rectangle for this presentation.
*
* @param bounds new bounding rectangle (not null)
*/
virtual void SetBounds(const Rectangle& bounds) = 0;
/**
* Returns the minimum size for this stack. The stack is prevented
* from being resized smaller than this amount, and this is used as
* the default size for the stack when it is minimized. Typically,
* this is the amount of space required to fit the minimize, close,
* and maximize buttons and one tab.
*
* @return the minimum size for this stack (not null)
*
* @deprecated replaced by computePreferredSize
*/
virtual Point ComputeMinimumSize();
/*
* @see ISizeProvider#getSizeFlags(boolean)
*/
virtual int GetSizeFlags(bool width);
/*
* @see ISizeProvider#computePreferredSize(boolean, int, int, int)
*/
virtual int ComputePreferredSize(bool width, int availableParallel, int availablePerpendicular, int preferredResult);
/**
* This is invoked to notify the presentation that its activation
* state has changed. StackPresentations can have three possible activation
* states (see the AS_* constants above)
*
* @param newState one of AS_INACTIVE, AS_ACTIVE, or AS_ACTIVE_NOFOCUS
*/
virtual void SetActive(int newState) = 0;
/**
* This causes the presentation to become visible or invisible.
* When a presentation is invisible, it must not respond to user
* input or modify its parts. For example, a presentations will
* be made invisible if it belongs to a perspective and the user
* switches to another perspective.
*
* @param isVisible the state to set visibility to
*
* @since 3.0
*/
virtual void SetVisible(bool isVisible) = 0;
/**
* Sets the state of the presentation. That is, notifies the presentation
* that is has been minimized, maximized, or restored. Note that this method
* is the only way that a presentation is allowed to change its state.
* <p>
* If a presentation wishes to minimize itself, it must call setState
* on its associated IStackPresentationSite. If the site chooses to respond
* to the state change, it will call this method at the correct time.
* The presentation should not call this method directly.
* </p>
*
* @param state one of the IStackPresentationSite.STATE_* constants.
*/
virtual void SetState(int state) = 0;
/**
* Returns the control for this presentation
*
* @return the control for this presentation (not null)
*/
virtual void* GetControl() = 0;
/**
* Adds the given part to the stack. The presentation is free to determine
* where the part should be inserted. If the part is being inserted as the
* result of a drag/drop operation, it will be given a cookie
* identifying the drop location. Has no effect if an identical part is
* already in the presentation.
*
* @param newPart the new part to add (not null)
* @param cookie an identifier for a drop location, or null. When the presentation
* attaches a cookie to a StackDropResult, that cookie is passed back into
* addPart when a part is actually dropped in that location.
*/
virtual void AddPart(IPresentablePart::Pointer newPart, Object::Pointer cookie) = 0;
/**
* Removes the given part from the stack.
*
* @param oldPart the part to remove (not null)
*/
virtual void RemovePart(IPresentablePart::Pointer oldPart) = 0;
/**
* Moves a part to a new location as the result of a drag/drop
* operation within this presentation.
*
* @param toMove a part that already belongs to this presentation
* @param cookie a drop cookie returned by <code>StackPresentation#dragOver</code>
* @since 3.1
*/
virtual void MovePart(IPresentablePart::Pointer toMove, Object::Pointer cookie);
/**
* Brings the specified part to the foreground. This should not affect
* the current focus.
*
* @param toSelect the new active part (not null)
*/
virtual void SelectPart(IPresentablePart::Pointer toSelect) = 0;
/**
* This method is invoked whenever a part is dragged over the stack's control.
* It returns a StackDropResult if and only if the part may be dropped in this
* location.
*
* @param currentControl the control being dragged over
* @param location cursor location (display coordinates)
* @return a StackDropResult or null if the presentation does not have
* a drop target in this location.
*/
virtual StackDropResult::Pointer DragOver(void* currentControl, const Point& location) = 0;
/**
* Instructs the presentation to display the system menu
*
*/
// virtual void ShowSystemMenu() = 0;
/**
* Instructs the presentation to display the pane menu
*/
// virtual void ShowPaneMenu() = 0;
/**
* Instructs the presentation to display a list of all parts in the stack, and
* allow the user to change the selection using the keyboard.
*/
virtual void ShowPartList();
/**
* Saves the state of this presentation to the given memento.
*
* @param context object that can be used to generate unique IDs for IPresentableParts (this
* may be a temporary object - the presentation should not keep any references to it)
* @param memento memento where the data will be saved
*/
virtual void SaveState(IPresentationSerializer* context, IMemento::Pointer memento);
/**
* Restores the state of this presentation to a previously saved state.
*
* @param context object that can be used to find IPresentableParts given string IDs (this
* may be a temporary object - the presentation should not keep any references to it)
* @param memento memento where the data will be saved
*/
virtual void RestoreState(IPresentationSerializer* context, IMemento::Pointer memento);
/**
* Returns the tab-key traversal order for the given <code>IPresentablePart</code>.
*
* @param part the part
* @return the tab-key traversal order
*/
virtual std::vector<void*> GetTabList(IPresentablePart::Pointer part) = 0;
};
}
#endif /* BERRYSTACKPRESENTATION_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/services/berryIDisposable.h b/BlueBerry/Bundles/org.blueberry.ui/src/services/berryIDisposable.h
index 05ad52c1d5..42a707ad44 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/services/berryIDisposable.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/services/berryIDisposable.h
@@ -1,69 +1,69 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIDISPOSABLE_H_
#define BERRYIDISPOSABLE_H_
#include <org_blueberry_ui_Export.h>
#include <berryObject.h>
#include <berryMacros.h>
namespace berry {
/**
* <p>
* The interface that should be implemented by services that make themselves
* available through the <code>IAdaptable</code> mechanism. This is the
* interface that drives the majority of services provided at the workbench
* level.
* </p>
* <p>
* A service has life-cycle. When the constructor completes, the service must be
* fully functional. When it comes time for the service to go away, then the
* service will receive a {@link #dispose()} call. At this point, the service
* must release all resources and detach all listeners. A service can only be
* disposed once; it cannot be reused.
* </p>
* <p>
* This interface has nothing to do with OSGi services.
* </p>
* <p>
* This interface can be extended or implemented by clients.
* </p>
*
* @since 3.2
*/
struct BERRY_UI IDisposable : public virtual Object
{
berryInterfaceMacro(IDisposable, berry)
~IDisposable();
/**
* Disposes of this service. All resources must be freed. All listeners must
* be detached. Dispose will only be called once during the life cycle of a
* service.
*/
virtual void Dispose() = 0;
};
}
#endif /* BERRYIDISPOSABLE_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/services/berryINestable.h b/BlueBerry/Bundles/org.blueberry.ui/src/services/berryINestable.h
index 7a399ca201..f6360414e6 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/services/berryINestable.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/services/berryINestable.h
@@ -1,82 +1,82 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYINESTABLE_H_
#define BERRYINESTABLE_H_
#include <org_blueberry_ui_Export.h>
#include <berryObject.h>
#include <berryMacros.h>
namespace berry {
/**
* </p>
* A service which can appear on a component which is wholly contained with
* another component. The component on which it appears can be active or
* inactive -- depending on the state of the application. For example, a
* workbench part is a component which appears within a workbench window. This
* workbench part can either be active or inactive, depending on what the user
* is doing.
* </p>
* <p>
* Services implement this interface, and are then notified by the component
* when the activation changes. It is the responsibility of the component to
* notify such services when the activation changes.
* </p>
* <p>
* This class is not intended for use outside of the
* <code>org.blueberry.ui.workbench</code> plug-in.
* </p>
* <p>
* <strong>PROVISIONAL</strong>. This class or interface has been added as part
* of a work in progress. There is a guarantee neither that this API will work
* nor that it will remain the same. Please do not use this API without
* consulting with the Platform/UI team.
* </p>
* <p>
* This class should eventually move to <code>org.blueberry.ui.services</code>.
* </p>
*
* @since 3.2
*/
struct BERRY_UI INestable : public virtual Object
{
berryInterfaceMacro(INestable, berry)
~INestable();
/**
* Notifies this service that the component within which it exists has
* become active. The service should modify its state as appropriate.
*
*/
virtual void Activate() = 0;
/**
* Notifies this service that the component within which it exists has
* become inactive. The service should modify its state as appropriate.
*/
virtual void Deactivate() = 0;
};
}
#endif /* BERRYINESTABLE_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/services/berryIServiceFactory.h b/BlueBerry/Bundles/org.blueberry.ui/src/services/berryIServiceFactory.h
index e0938f94be..c503b3ba68 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/services/berryIServiceFactory.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/services/berryIServiceFactory.h
@@ -1,76 +1,76 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYISERVICEFACTORY_H_
#define BERRYISERVICEFACTORY_H_
#include <org_blueberry_ui_Export.h>
#include <berryObject.h>
#include <berryMacros.h>
#include <QObject>
namespace berry {
struct IServiceLocator;
/**
* A factory for creating services for use with the
* <code>org.blueberry.ui.services</code> extension point. You are given a
* service locator to look up other services, and can retrieve your parent
* service (if one has already been created).
*
* @since 3.4
*/
struct BERRY_UI IServiceFactory : public virtual Object {
berryInterfaceMacro(IServiceFactory, berry);
~IServiceFactory();
/**
* When a service locator cannot find a service it will request one from the
* registry, which will call this factory create method.
* <p>
* You can use the locator to get any needed services and a parent service
* locator will be provided if you need access to the parent service. If the
* parent object return from the parent locator is not <code>null</code>
* it can be cast to the service interface that is requested. The parent
* service locator will only return the serviceInterface service.
* </p>
*
* @param serviceInterface
* the service we need to create. Will not be <code>null</code>.
* @param parentLocator
* A locator that can return a parent service instance if
* desired. The parent service can be cast to serviceInterface.
* Will not be <code>null</code>.
* @param locator
* the service locator which can be used to retrieve dependent
* services. Will not be <code>null</code>
* @return the created service or <code>null</code>
*/
virtual Object::Pointer Create(const std::string& serviceInterface,
const SmartPointer<const IServiceLocator> parentLocator, const SmartPointer<const IServiceLocator> locator) const = 0;
};
}
Q_DECLARE_INTERFACE(berry::IServiceFactory, "org.blueberry.IServiceFactory")
#endif /* BERRYISERVICEFACTORY_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/services/berryIServiceLocator.h b/BlueBerry/Bundles/org.blueberry.ui/src/services/berryIServiceLocator.h
index 4e75f00e65..415bc16f13 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/services/berryIServiceLocator.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/services/berryIServiceLocator.h
@@ -1,81 +1,81 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYISERVICELOCATOR_H_
#define BERRYISERVICELOCATOR_H_
#include <org_blueberry_ui_Export.h>
#include <berryObject.h>
#include <berryMacros.h>
namespace berry {
/**
* <p>
* A component with which one or more services are registered. The services can
* be retrieved from this locator using some key -- typically the class
* representing the interface the service must implement. For example:
* </p>
*
* <pre>
* IHandlerService service = (IHandlerService) workbenchWindow
* .getService(IHandlerService.class);
* </pre>
*
* <p>
* This interface is not to be implemented or extended by clients.
* </p>
*
* @since 3.2
*/
struct BERRY_UI IServiceLocator : public virtual Object {
berryInterfaceMacro(IServiceLocator, berry)
~IServiceLocator();
/**
* Retrieves the service corresponding to the given API.
*
* @param api
* This is the interface that the service implements. Must not be
* <code>null</code>.
* @return The service, or <code>null</code> if no such service could be
* found.
*/
virtual Object::Pointer GetService(const std::string& api) = 0;
/**
* Whether this service exists within the scope of this service locator.
* This does not include looking for the service within the scope of the
* parents. This method can be used to determine whether a particular
* service supports nesting in this scope.
*
* @param api
* This is the interface that the service implements. Must not be
* <code>null</code>.
* @return <code>true</code> iff the service locator can find a service
* for the given API; <code>false</code> otherwise.
*/
virtual bool HasService(const std::string& api) const = 0;
};
}
#endif /* BERRYISERVICELOCATOR_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/services/berryIServiceWithSources.h b/BlueBerry/Bundles/org.blueberry.ui/src/services/berryIServiceWithSources.h
index 75a79a334f..ebdf94acdc 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/services/berryIServiceWithSources.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/services/berryIServiceWithSources.h
@@ -1,68 +1,68 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYISERVICEWITHSOURCES_H_
#define BERRYISERVICEWITHSOURCES_H_
#include "berryIDisposable.h"
namespace berry {
struct ISourceProvider;
/**
* <p>
* A service that responds to changes in one or more sources. These sources can
* be plugged into the service. Sources represent a common event framework for
* services.
* </p>
* <p>
* Clients must not extend or implement.
* </p>
*
*/
struct BERRY_UI IServiceWithSources : public IDisposable {
berryInterfaceMacro(IServiceWithSources, berry)
~IServiceWithSources();
/**
* Adds a source provider to this service. A source provider will notify the
* service when the source it provides changes. An example of a source might
* be an active editor or the current selection. This amounts to a pluggable
* state tracker for the service.
*
* @param provider
* The provider to add; must not be <code>null</code>.
*/
virtual void AddSourceProvider(SmartPointer<ISourceProvider> provider) = 0;
/**
* Removes a source provider from this service. Most of the time, this
* method call is not required as source providers typically share the same
* life span as the workbench itself.
*
* @param provider
* The provider to remove; must not be <code>null</code>.
*/
virtual void RemoveSourceProvider(SmartPointer<ISourceProvider> provider) = 0;
};
}
#endif /* BERRYISERVICEWITHSOURCES_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/testing/berryITestHarness.h b/BlueBerry/Bundles/org.blueberry.ui/src/testing/berryITestHarness.h
index b6064a5b14..98f9a2ede1 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/testing/berryITestHarness.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/testing/berryITestHarness.h
@@ -1,50 +1,50 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYITESTHARNESS_H_
#define BERRYITESTHARNESS_H_
#include <berryObject.h>
#include <berryMacros.h>
#include <org_blueberry_ui_Export.h>
#include <QtPlugin>
namespace berry {
/**
* Represents an arbitrary test harness.
*
* @since 3.0
*/
struct BERRY_UI ITestHarness : public virtual Object {
berryInterfaceMacro(ITestHarness, berry)
/**
* Runs the tests.
*/
virtual void RunTests() = 0;
};
}
Q_DECLARE_INTERFACE(berry::ITestHarness, "org.blueberry.ITestHarness")
#endif /* BERRYITESTHARNESS_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/testing/berryTestableObject.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/testing/berryTestableObject.cpp
index 4ea5046a19..904276dfa2 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/testing/berryTestableObject.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/testing/berryTestableObject.cpp
@@ -1,48 +1,48 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryTestableObject.h"
namespace berry
{
ITestHarness::Pointer TestableObject::GetTestHarness() const
{
return testHarness;
}
void TestableObject::SetTestHarness(ITestHarness::Pointer testHarness)
{
poco_assert(testHarness);
this->testHarness = testHarness;
}
void TestableObject::RunTest(Poco::Runnable* testRunnable)
{
testRunnable->run();
}
void TestableObject::TestingStarting()
{
// do nothing
}
void TestableObject::TestingFinished()
{
// do nothing
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/testing/berryTestableObject.h b/BlueBerry/Bundles/org.blueberry.ui/src/testing/berryTestableObject.h
index 888a8e3df4..e1f7615b5c 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/testing/berryTestableObject.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/testing/berryTestableObject.h
@@ -1,95 +1,95 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYTESTABLEOBJECT_H_
#define BERRYTESTABLEOBJECT_H_
#include <berryObject.h>
#include <berryMacros.h>
#include "berryITestHarness.h"
#include <Poco/Runnable.h>
namespace berry {
/**
* A testable object.
* Allows a test harness to register itself with a testable object.
* The test harness is notified of test-related lifecycle events,
* such as when is an appropriate time to run tests on the object.
* This also provides API for running tests as a runnable, and for signaling
* when the tests are starting and when they are finished.
* <p>
* The workbench provides an implementation of this facade, available
* via <code>PlatformUI.getTestableObject()</code>.
* </p>
*
* @since 3.0
*/
class BERRY_UI TestableObject : public virtual Object {
private:
ITestHarness::Pointer testHarness;
public:
berryObjectMacro(TestableObject)
/**
* Returns the test harness, or <code>null</code> if it has not yet been set.
*
* @return the test harness or <code>null</code>
*/
virtual ITestHarness::Pointer GetTestHarness() const;
/**
* Sets the test harness.
*
* @param testHarness the test harness
*/
virtual void SetTestHarness(ITestHarness::Pointer testHarness);
/**
* Runs the given test runnable.
* The default implementation simply invokes <code>run</code> on the
* given test runnable. Subclasses may extend.
*
* @param testRunnable the test runnable to run
*/
virtual void RunTest(Poco::Runnable* testRunnable);
/**
* Notification from the test harness that it is starting to run
* the tests.
* The default implementation does nothing.
* Subclasses may override.
*/
virtual void TestingStarting();
/**
* Notification from the test harness that it has finished running the
* tests.
* The default implementation does nothing.
* Subclasses may override.
*/
virtual void TestingFinished();
};
}
#endif /* BERRYTESTABLEOBJECT_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/tweaklets/berryDnDTweaklet.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/tweaklets/berryDnDTweaklet.cpp
index 6dbbf22950..a481d465a1 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/tweaklets/berryDnDTweaklet.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/tweaklets/berryDnDTweaklet.cpp
@@ -1,64 +1,64 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryDnDTweaklet.h"
#include "berryConstants.h"
namespace berry
{
Tweaklets::TweakKey<DnDTweaklet> DnDTweaklet::KEY =
Tweaklets::TweakKey<DnDTweaklet>();
DnDTweaklet::CursorType DnDTweaklet::PositionToCursorType(int positionConstant)
{
if (positionConstant == Constants::LEFT)
return CURSOR_LEFT;
if (positionConstant == Constants::RIGHT)
return CURSOR_RIGHT;
if (positionConstant == Constants::TOP)
return CURSOR_TOP;
if (positionConstant == Constants::BOTTOM)
return CURSOR_BOTTOM;
if (positionConstant == Constants::CENTER)
return CURSOR_CENTER;
return CURSOR_INVALID;
}
int DnDTweaklet::CursorTypeToPosition(CursorType dragCursorId)
{
switch (dragCursorId)
{
case CURSOR_LEFT:
return Constants::LEFT;
case CURSOR_RIGHT:
return Constants::RIGHT;
case CURSOR_TOP:
return Constants::TOP;
case CURSOR_BOTTOM:
return Constants::BOTTOM;
case CURSOR_CENTER:
return Constants::CENTER;
default:
return Constants::DEFAULT;
}
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/tweaklets/berryDnDTweaklet.h b/BlueBerry/Bundles/org.blueberry.ui/src/tweaklets/berryDnDTweaklet.h
index 49addc05b7..e792479c13 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/tweaklets/berryDnDTweaklet.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/tweaklets/berryDnDTweaklet.h
@@ -1,67 +1,67 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYDNDTWEAKLET_H_
#define BERRYDNDTWEAKLET_H_
#include <berryMacros.h>
#include <org_blueberry_ui_Export.h>
#include "internal/berryTweaklets.h"
namespace berry
{
struct ITracker;
/**
* Provides the set of cursors used for drag-and-drop.
*/
struct BERRY_UI DnDTweaklet
{
static Tweaklets::TweakKey<DnDTweaklet> KEY;
enum CursorType
{ CURSOR_INVALID,
CURSOR_LEFT,
CURSOR_RIGHT,
CURSOR_TOP,
CURSOR_BOTTOM,
CURSOR_CENTER,
CURSOR_OFFSCREEN,
CURSOR_FASTVIEW};
static CursorType PositionToCursorType(int positionConstant);
/**
* Converts a DnDTweaklet::CursorType (CURSOR_LEFT, CURSOR_RIGHT, CURSOR_TOP, CURSOR_BOTTOM, CURSOR_CENTER) into a BlueBerry constant
* (Constants::LEFT, Constants::RIGHT, Constants::TOP, Constants::BOTTOM, Constants::CENTER)
*
* @param dragCursorId
* @return a BlueBerry Constants::* constant
*/
static int CursorTypeToPosition(CursorType dragCursorId);
virtual ITracker* CreateTracker() = 0;
};
}
Q_DECLARE_INTERFACE(berry::DnDTweaklet, "org.blueberry.DnDTweaklet")
#endif /* BERRYDNDTWEAKLET_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/tweaklets/berryGuiWidgetsTweaklet.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/tweaklets/berryGuiWidgetsTweaklet.cpp
index a86a5026bf..2e1a48d8f5 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/tweaklets/berryGuiWidgetsTweaklet.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/tweaklets/berryGuiWidgetsTweaklet.cpp
@@ -1,25 +1,25 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryGuiWidgetsTweaklet.h"
namespace berry
{
Tweaklets::TweakKey<GuiWidgetsTweaklet> GuiWidgetsTweaklet::KEY =
Tweaklets::TweakKey<GuiWidgetsTweaklet>();
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/tweaklets/berryGuiWidgetsTweaklet.h b/BlueBerry/Bundles/org.blueberry.ui/src/tweaklets/berryGuiWidgetsTweaklet.h
index 7ad4705a36..3201ed6056 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/tweaklets/berryGuiWidgetsTweaklet.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/tweaklets/berryGuiWidgetsTweaklet.h
@@ -1,213 +1,213 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYGUIWIDGETSTWEAKLET_H_
#define BERRYGUIWIDGETSTWEAKLET_H_
#include <berryMacros.h>
#include "internal/berryTweaklets.h"
#include "guitk/berryGuiTkISelectionListener.h"
#include "guitk/berryGuiTkIControlListener.h"
#include "berryRectangle.h"
#include "berryShell.h"
//#include "commands/berryIMenu.h"
//#include "commands/berryIMenuItem.h"
namespace berry {
struct BERRY_UI GuiWidgetsTweaklet
{
static Tweaklets::TweakKey<GuiWidgetsTweaklet> KEY;
virtual void AddSelectionListener(void* widget, GuiTk::ISelectionListener::Pointer listener) = 0;
virtual void RemoveSelectionListener(void* widget, GuiTk::ISelectionListener::Pointer listener) = 0;
/**
* Adds the listener to the collection of listeners who will
* be notified when the widget is moved or resized, by sending
* it one of the messages defined in the <code>IControlListener</code>
* interface.
*
* @param listener the listener which should be notified
*
* @see IControlListener
* @see #RemoveControlListener
*/
virtual void AddControlListener(void* widget, GuiTk::IControlListener::Pointer listener) = 0;
/**
* Removes the listener from the collection of listeners who will
* be notified when the widget is moved or resized.
*
* @param listener the listener which should no longer be notified
*
* @see IControlListener
* @see #AddControlListener
*/
virtual void RemoveControlListener(void* widget, GuiTk::IControlListener::Pointer listener) = 0;
virtual bool GetEnabled(void* widget) = 0;
virtual void SetEnabled(void* widget, bool enabled) = 0;
virtual void SetBounds(void* widget, const Rectangle& bounds) = 0;
virtual Rectangle GetBounds(void* widget) = 0;
virtual void SetVisible(void* widget, bool visible) = 0;
virtual bool GetVisible(void* widget) = 0;
virtual bool IsVisible(void* widget) = 0;
virtual Rectangle GetClientArea(void* widget) = 0;
virtual void* GetParent(void* widget) = 0;
virtual bool SetParent(void* widget, void* parent) = 0;
virtual void SetData(void* widget, const std::string& id, Object::Pointer data) = 0;
virtual Object::Pointer GetData(void* widget, const std::string& id) = 0;
virtual Point GetCursorLocation() = 0;
virtual void* GetCursorControl() = 0;
virtual void* FindControl(const std::vector<Shell::Pointer>& shells, const Point& location) = 0;
/**
* Determines if one control is a child of another. Returns true iff the second
* argument is a child of the first (or the same object).
*
* @param potentialParent
* @param childToTest
* @return
*/
virtual bool IsChild(void* potentialParent, void* childToTest) = 0;
/**
* Returns the control which currently has keyboard focus,
* or null if keyboard events are not currently going to
* any of the controls built by the currently running
* application.
*
* @return the control under the cursor
*/
virtual void* GetFocusControl() = 0;
virtual bool IsReparentable(void* widget) = 0;
virtual void MoveAbove(void* widgetToMove, void* widget) = 0;
virtual void MoveBelow(void* widgetToMove, void* widget) = 0;
virtual void Dispose(void* widget) = 0;
virtual Shell::Pointer CreateShell(Shell::Pointer parent, int style) = 0;
virtual void DisposeShell(Shell::Pointer shell) = 0;
virtual void* CreateComposite(void* parent) = 0;
virtual std::vector<Shell::Pointer> GetShells() = 0;
virtual Shell::Pointer GetShell(void* widget) = 0;
virtual Shell::Pointer GetActiveShell() = 0;
// command framework interface classes
//virtual IMenu::Pointer CreateMenu(void*, IMenu::Style = IMenu::POP_UP) = 0;
//virtual IMenu::Pointer CreateMenu(IMenu::Pointer parent) = 0;
//virtual IMenuItem::Pointer CreateMenuItem(IMenu::Pointer, IMenuItem::Style, int index = -1) = 0;
/**
* @brief returns the coordinates of the center point of the primary screen
* (where the application starts) of the current desktop.
*
* @param i the number of the screen (if there are multiple). If i = -1
* a rectangle representing the size of the virtual desktop is returned.
* @return the screen Geometry.
* @see GetScreenNumber()
* @see GetPrimaryScreenNumber()
*/
virtual Rectangle GetScreenSize(int i = -1) = 0;
virtual Rectangle GetAvailableScreenSize(int i = -1) = 0;
virtual int GetClosestScreenNumber(const Rectangle&) = 0;
/**
* @brief Gets the number of available screens in a multi-screen environment.
*
* @return the number of available screens in a multi-screen environment.
*/
virtual unsigned int GetScreenNumber() = 0;
/**
* @brief Gets the number of the primary screen.
*
* @return the number of the primary screen.
*/
virtual int GetPrimaryScreenNumber() = 0;
/**
* Converts the given rectangle from display coordinates to the local coordinate system
* of the given object
*
* @param coordinateSystem local coordinate system (widget) being converted to
* @param toConvert rectangle to convert
* @return a rectangle in control coordinates
* @since 3.0
*/
virtual Rectangle ToControl(void* coordinateSystem,
const Rectangle& toConvert) = 0;
/**
* Converts the given point from display coordinates to the local coordinate system
* of the given object
*
* @param coordinateSystem local coordinate system (widget) being converted to
* @param toConvert point to convert
* @return a point in control coordinates
* @since 3.0
*/
virtual Point ToControl(void* coordinateSystem,
const Point& toConvert) = 0;
/**
* Converts the given rectangle from the local coordinate system of the given object
* into display coordinates.
*
* @param coordinateSystem local coordinate system (widget) being converted from
* @param toConvert rectangle to convert
* @return a rectangle in display coordinates
* @since 3.0
*/
virtual Rectangle ToDisplay(void* coordinateSystem,
const Rectangle& toConvert) = 0;
/**
* Converts the given point from the local coordinate system of the given object
* into display coordinates.
*
* @param coordinateSystem local coordinate system (widget) being converted from
* @param toConvert point to convert
* @return a point in display coordinates
* @since 3.0
*/
virtual Point ToDisplay(void* coordinateSystem,
const Point& toConvert) = 0;
};
}
Q_DECLARE_INTERFACE(berry::GuiWidgetsTweaklet, "org.blueberry.GuiWidgetsTweaklet")
#endif /* BERRYGUIWIDGETSTWEAKLET_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/tweaklets/berryITracker.h b/BlueBerry/Bundles/org.blueberry.ui/src/tweaklets/berryITracker.h
index 0239edc695..718830776e 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/tweaklets/berryITracker.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/tweaklets/berryITracker.h
@@ -1,55 +1,55 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYITRACKER_H_
#define BERRYITRACKER_H_
#include "berryDnDTweaklet.h"
#include "berryRectangle.h"
#include "guitk/berryGuiTkIControlListener.h"
namespace berry {
/**
* Instances of this class implement a rubber banding rectangle that is
* drawn onto a parent control or display.
* These rectangles can be specified to respond to mouse and key events
* by either moving or resizing themselves accordingly. Trackers are
* typically used to represent window geometries in a lightweight manner.
*
*/
struct BERRY_UI ITracker
{
virtual ~ITracker();
virtual Rectangle GetRectangle() = 0;
virtual void SetRectangle(const Rectangle& rectangle) = 0;
virtual void SetCursor(DnDTweaklet::CursorType cursor) = 0;
virtual bool Open() = 0;
virtual void AddControlListener(GuiTk::IControlListener::Pointer listener) = 0;
virtual void RemoveControlListener(GuiTk::IControlListener::Pointer listener) = 0;
};
}
#endif /* BERRYITRACKER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/tweaklets/berryImageTweaklet.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/tweaklets/berryImageTweaklet.cpp
index 2d6f611094..7ab44d17e1 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/tweaklets/berryImageTweaklet.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/tweaklets/berryImageTweaklet.cpp
@@ -1,25 +1,25 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryImageTweaklet.h"
namespace berry
{
Tweaklets::TweakKey<ImageTweaklet> ImageTweaklet::KEY =
Tweaklets::TweakKey<ImageTweaklet>();
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/tweaklets/berryImageTweaklet.h b/BlueBerry/Bundles/org.blueberry.ui/src/tweaklets/berryImageTweaklet.h
index 0c8ceaa56c..52588b68a8 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/tweaklets/berryImageTweaklet.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/tweaklets/berryImageTweaklet.h
@@ -1,48 +1,48 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIMAGETWEAKLET_H_
#define BERRYIMAGETWEAKLET_H_
#include <org_blueberry_ui_Export.h>
#include "internal/berryTweaklets.h"
#include "berryImageDescriptor.h"
#include <iostream>
namespace berry
{
/**
* Provides the set of cursors used for drag-and-drop.
*/
struct BERRY_UI ImageTweaklet
{
static Tweaklets::TweakKey<ImageTweaklet> KEY;
virtual SmartPointer<ImageDescriptor> CreateFromFile(const std::string& filename, const std::string& pluginid) = 0;
virtual SmartPointer<ImageDescriptor> CreateFromImage(void* img) = 0;
virtual SmartPointer<ImageDescriptor> GetMissingImageDescriptor() = 0;
virtual void DestroyImage(const void* img) = 0;
};
}
Q_DECLARE_INTERFACE(berry::ImageTweaklet, "org.blueberry.ImageTweaklet")
#endif /* BERRYIMAGETWEAKLET_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/tweaklets/berryMessageDialogTweaklet.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/tweaklets/berryMessageDialogTweaklet.cpp
index 25d906be38..9cf1670633 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/tweaklets/berryMessageDialogTweaklet.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/tweaklets/berryMessageDialogTweaklet.cpp
@@ -1,24 +1,24 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryMessageDialogTweaklet.h"
namespace berry {
Tweaklets::TweakKey<MessageDialogTweaklet> MessageDialogTweaklet::KEY =
Tweaklets::TweakKey<MessageDialogTweaklet>();
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/tweaklets/berryMessageDialogTweaklet.h b/BlueBerry/Bundles/org.blueberry.ui/src/tweaklets/berryMessageDialogTweaklet.h
index 89df956b4f..0c23ff0eb5 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/tweaklets/berryMessageDialogTweaklet.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/tweaklets/berryMessageDialogTweaklet.h
@@ -1,157 +1,157 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYMESSAGEDIALOGTWEAKLET_H_
#define BERRYMESSAGEDIALOGTWEAKLET_H_
#include <org_blueberry_ui_Export.h>
#include "berryShell.h"
#include "dialogs/berryIDialog.h"
#include "internal/berryTweaklets.h"
#include <berryMacros.h>
#include <vector>
#include <string>
namespace berry {
/**
* A dialog for showing messages to the user.
*/
struct BERRY_UI MessageDialogTweaklet
{
static Tweaklets::TweakKey<MessageDialogTweaklet> KEY;
/**
* Convenience method to open a simple confirm (OK/Cancel) dialog.
*
* @param parent
* the parent shell of the dialog, or <code>null</code> if none
* @param title
* the dialog's title, or <code>null</code> if none
* @param message
* the message
* @return <code>true</code> if the user presses the OK button,
* <code>false</code> otherwise
*/
virtual bool OpenConfirm(Shell::Pointer parent, const std::string& title, const std::string& message) = 0;
/**
* Convenience method to open a standard error dialog.
*
* @param parent
* the parent shell of the dialog, or <code>null</code> if none
* @param title
* the dialog's title, or <code>null</code> if none
* @param message
* the message
*/
virtual void OpenError(Shell::Pointer parent, const std::string& title, const std::string& message) = 0;
/**
* Convenience method to open a standard information dialog.
*
* @param parent
* the parent shell of the dialog, or <code>null</code> if none
* @param title
* the dialog's title, or <code>null</code> if none
* @param message
* the message
*/
virtual void OpenInformation(Shell::Pointer parent, const std::string& title,
const std::string& message) = 0;
/**
* Convenience method to open a simple Yes/No question dialog.
*
* @param parent
* the parent shell of the dialog, or <code>null</code> if none
* @param title
* the dialog's title, or <code>null</code> if none
* @param message
* the message
* @return <code>true</code> if the user presses the OK button,
* <code>false</code> otherwise
*/
virtual bool OpenQuestion(Shell::Pointer parent, const std::string& title,
const std::string& message) = 0;
/**
* Convenience method to open a standard warning dialog.
*
* @param parent
* the parent shell of the dialog, or <code>null</code> if none
* @param title
* the dialog's title, or <code>null</code> if none
* @param message
* the message
*/
virtual void OpenWarning(Shell::Pointer parent, const std::string& title, const std::string& message) = 0;
/**
* Create a message dialog. Note that the dialog will have no visual
* representation (no widgets) until it is told to open.
* <p>
* The labels of the buttons to appear in the button bar are supplied in
* this constructor as an array. The <code>open</code> method will return
* the index of the label in this array corresponding to the button that was
* pressed to close the dialog. If the dialog was dismissed without pressing
* a button (ESC, etc.) then -1 is returned. Note that the <code>open</code>
* method blocks.
* </p>
*
* @param parentShell
* the parent shell
* @param dialogTitle
* the dialog title, or <code>null</code> if none
* @param dialogTitleImage
* the dialog title image, or <code>null</code> if none
* @param dialogMessage
* the dialog message
* @param dialogImageType
* one of the following values:
* <ul>
* <li><code>IDialog::NONE</code> for a dialog with no
* image</li>
* <li><code>IDialog::ERR</code> for a dialog with an
* error image</li>
* <li><code>IDialog::INFORMATION</code> for a dialog
* with an information image</li>
* <li><code>IDialog::QUESTION </code> for a dialog with a
* question image</li>
* <li><code>IDialog::WARNING</code> for a dialog with a
* warning image</li>
* </ul>
* @param dialogButtonLabels
* an array of labels for the buttons in the button bar
* @param defaultIndex
* the index in the button label array of the default button
*/
virtual IDialog::Pointer MessageDialog(Shell::Pointer parentShell, const std::string& dialogTitle,
void* dialogTitleImage, const std::string& dialogMessage, int dialogImageType,
const std::vector<std::string>& dialogButtonLabels, int defaultIndex) = 0;
};
}
Q_DECLARE_INTERFACE(berry::MessageDialogTweaklet, "org.blueberry.MessageDialogTweaklet")
#endif /* BERRYMESSAGEDIALOGTWEAKLET_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/tweaklets/berryWorkbenchPageTweaklet.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/tweaklets/berryWorkbenchPageTweaklet.cpp
index 6fd2f52c3f..c13641ddb5 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/tweaklets/berryWorkbenchPageTweaklet.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/tweaklets/berryWorkbenchPageTweaklet.cpp
@@ -1,26 +1,26 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryWorkbenchPageTweaklet.h"
namespace berry
{
Tweaklets::TweakKey<WorkbenchPageTweaklet> WorkbenchPageTweaklet::KEY =
Tweaklets::TweakKey<WorkbenchPageTweaklet>();
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/tweaklets/berryWorkbenchPageTweaklet.h b/BlueBerry/Bundles/org.blueberry.ui/src/tweaklets/berryWorkbenchPageTweaklet.h
index cacfeec77d..1c5189da55 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/tweaklets/berryWorkbenchPageTweaklet.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/tweaklets/berryWorkbenchPageTweaklet.h
@@ -1,44 +1,44 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYWORKBENCHPAGETWEAKLET_H_
#define BERRYWORKBENCHPAGETWEAKLET_H_
#include "internal/berryTweaklets.h"
#include "berryIWorkbenchPage.h"
namespace berry
{
struct BERRY_UI WorkbenchPageTweaklet
{
static Tweaklets::TweakKey<WorkbenchPageTweaklet> KEY;
virtual void* CreateClientComposite(void* pageControl) = 0;
virtual void* CreatePaneControl(void* parent) = 0;
virtual Object::Pointer CreateStatusPart(void* parent, const std::string& title, const std::string& msg) = 0;
virtual IEditorPart::Pointer CreateErrorEditorPart(const std::string& partName, const std::string& msg) = 0;
};
}
Q_DECLARE_INTERFACE(berry::WorkbenchPageTweaklet, "org.blueberry.WorkbenchPageTweaklet")
#endif /* BERRYWORKBENCHPAGETWEAKLET_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/tweaklets/berryWorkbenchTweaklet.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/tweaklets/berryWorkbenchTweaklet.cpp
index 702f6108c7..4779d213d1 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/tweaklets/berryWorkbenchTweaklet.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/tweaklets/berryWorkbenchTweaklet.cpp
@@ -1,28 +1,28 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryWorkbenchTweaklet.h"
namespace berry
{
Tweaklets::TweakKey<WorkbenchTweaklet> WorkbenchTweaklet::KEY =
Tweaklets::TweakKey<WorkbenchTweaklet>();
const std::string WorkbenchTweaklet::DIALOG_ID_SHOW_VIEW =
"org.blueberry.ui.dialogs.showview";
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/tweaklets/berryWorkbenchTweaklet.h b/BlueBerry/Bundles/org.blueberry.ui/src/tweaklets/berryWorkbenchTweaklet.h
index a039e01f18..25c0950907 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/tweaklets/berryWorkbenchTweaklet.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/tweaklets/berryWorkbenchTweaklet.h
@@ -1,53 +1,53 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYWORKBENCHTWEAKLET_H_
#define BERRYWORKBENCHTWEAKLET_H_
#include "internal/berryTweaklets.h"
#include "berryShell.h"
#include "berryDisplay.h"
#include "dialogs/berryIDialog.h"
namespace berry
{
class WorkbenchWindow;
struct BERRY_UI WorkbenchTweaklet
{
static Tweaklets::TweakKey<WorkbenchTweaklet> KEY;
static const std::string DIALOG_ID_SHOW_VIEW; // = "org.blueberry.ui.dialogs.showview";
virtual Display* CreateDisplay() = 0;
virtual bool IsRunning() = 0;
virtual SmartPointer<WorkbenchWindow> CreateWorkbenchWindow(int number) = 0;
virtual IDialog::Pointer CreateStandardDialog(const std::string& id) = 0;
};
}
Q_DECLARE_INTERFACE(berry::WorkbenchTweaklet, "org.blueberry.WorkbenchTweaklet")
#endif /* BERRYWORKBENCHTWEAKLET_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/util/berryISafeRunnableRunner.h b/BlueBerry/Bundles/org.blueberry.ui/src/util/berryISafeRunnableRunner.h
index c3034edffd..7c36d81b84 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/util/berryISafeRunnableRunner.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/util/berryISafeRunnableRunner.h
@@ -1,63 +1,63 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYISAFERUNNABLERUNNER_H_
#define BERRYISAFERUNNABLERUNNER_H_
#include <org_blueberry_ui_Export.h>
#include <berryObject.h>
#include <berryMacros.h>
#include <berryISafeRunnable.h>
namespace berry {
/**
* Runs a safe runnables.
* <p>
* Clients may provide their own implementation to change
* how safe runnables are run from within the workbench.
* </p>
*
* @see SafeRunnable#GetRunner()
* @see SafeRunnable#SetRunner(ISafeRunnableRunner::Pointer)
* @see SafeRunnable#Run(ISafeRunnable::Pointer)
*/
struct BERRY_UI ISafeRunnableRunner : public Object {
public:
berryInterfaceMacro(ISafeRunnableRunner, berry)
~ISafeRunnableRunner();
/**
* Runs the runnable. All <code>ISafeRunnableRunners</code> must catch any exception
* thrown by the <code>ISafeRunnable</code> and pass the exception to
* <code>ISafeRunnable::HandleException()</code>.
* @param code the code executed as a save runnable
*
* @see SafeRunnable#Run(ISafeRunnable::Pointer)
*/
virtual void Run(ISafeRunnable::Pointer code) = 0;
};
}
#endif /* BERRYISAFERUNNABLERUNNER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/util/berrySafeRunnable.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/util/berrySafeRunnable.cpp
index 8c82957fb8..b6f1b2cef3 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/util/berrySafeRunnable.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/util/berrySafeRunnable.cpp
@@ -1,132 +1,132 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berrySafeRunnable.h"
#include <typeinfo>
#include <berrySolsticeExceptions.h>
namespace berry
{
bool SafeRunnable::ignoreErrors = false;
ISafeRunnableRunner::Pointer SafeRunnable::runner;
class DefaultSafeRunnableRunner: public ISafeRunnableRunner
{
public:
void Run(ISafeRunnable::Pointer code)
{
try
{
code->Run();
} catch (const std::exception& e)
{
HandleException(code, e);
} catch (...)
{
HandleException(code);
}
}
private:
void HandleException(ISafeRunnable::Pointer code, const std::exception& e =
std::exception())
{
try
{
dynamic_cast<const OperationCanceledException&> (e);
} catch (const std::bad_cast&)
{
// TODO logging
try
{
// Policy.getLog()
// .log(
// new Status(IStatus.ERROR, Policy.JFACE,
// IStatus.ERROR,
// "Exception occurred", e)); //$NON-NLS-1$
} catch (...)
{
//e.printStackTrace();
std::cerr << "Exception occurred" << std::endl;
}
}
code->HandleException(e);
}
};
SmartPointer<ISafeRunnableRunner> SafeRunnable::CreateDefaultRunner()
{
ISafeRunnableRunner::Pointer runner(new DefaultSafeRunnableRunner());
return runner;
}
SafeRunnable::SafeRunnable(const std::string& message) :
message(message)
{
}
void SafeRunnable::HandleException(const std::exception& /*e*/)
{
// Workaround to avoid interactive error dialogs during
// automated testing
if (ignoreErrors)
return;
if (message.empty())
message = "An error has occurred. See error log for more details.";
// TODO status bar
// Policy.getStatusHandler().show(
// new Status(IStatus.ERROR, Policy.JFACE, message, e),
// JFaceResources.getString("SafeRunnable.errorMessage")); //$NON-NLS-1$
std::cerr << message << std::endl;
}
bool SafeRunnable::GetIgnoreErrors()
{
return ignoreErrors;
}
void SafeRunnable::SetIgnoreErrors(bool flag)
{
ignoreErrors = flag;
}
SmartPointer<ISafeRunnableRunner> SafeRunnable::GetRunner()
{
if (!runner)
{
runner = CreateDefaultRunner();
}
return runner;
}
void SafeRunnable::SetRunner(SmartPointer<ISafeRunnableRunner> runner)
{
SafeRunnable::runner = runner;
}
void SafeRunnable::Run(SmartPointer<ISafeRunnable> runnable)
{
GetRunner()->Run(runnable);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/util/berrySafeRunnable.h b/BlueBerry/Bundles/org.blueberry.ui/src/util/berrySafeRunnable.h
index 5981791c84..475d82cef5 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/util/berrySafeRunnable.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/util/berrySafeRunnable.h
@@ -1,115 +1,115 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYSAFERUNNABLE_H_
#define BERRYSAFERUNNABLE_H_
#include <berryISafeRunnable.h>
#include "berryISafeRunnableRunner.h"
namespace berry {
/**
* Implements a default implementation of ISafeRunnable. The default
* implementation of <code>HandleException</code> opens a dialog to show any
* errors as they accumulate.
* <p>
* This may be executed on any thread.
*/
class BERRY_UI SafeRunnable : public ISafeRunnable {
private:
static bool ignoreErrors;
static ISafeRunnableRunner::Pointer runner;
std::string message;
/**
* Creates the default safe runnable runner.
*
* @return the default safe runnable runner
*/
static ISafeRunnableRunner::Pointer CreateDefaultRunner();
public:
/**
* Creates a new instance of SafeRunnable with the given error message.
*
* @param message
* the error message to use
*/
SafeRunnable(const std::string& message = "");
/*
* (non-Javadoc)
*
* @see ISafeRunnable#HandleException(const std::exception&)
*/
void HandleException(const std::exception& e);
/**
* Flag to avoid interactive error dialogs during automated testing.
*
* @return true if errors should be ignored
*
*/
static bool GetIgnoreErrors();
/**
* Flag to avoid interactive error dialogs during automated testing.
*
* @param flag
* set to true if errors should be ignored
*/
static void SetIgnoreErrors(bool flag);
/**
* Returns the safe runnable runner.
*
* @return the safe runnable runner
*
*/
static ISafeRunnableRunner::Pointer GetRunner();
/**
* Sets the safe runnable runner.
*
* @param runner
* the runner to set, or <code>null</code> to reset to the
* default runner
*/
static void SetRunner(ISafeRunnableRunner::Pointer runner);
/**
* Runs the given safe runnable using the safe runnable runner. This is a
* convenience method, equivalent to:
* <code>SafeRunnable#GetRunner()->Run(runnable)</code>.
*
* @param runnable
* the runnable to run
*/
static void Run(ISafeRunnable::Pointer runnable);
};
}
#endif /* BERRYSAFERUNNABLE_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.uitest/src/berryUITestApplication.cpp b/BlueBerry/Bundles/org.blueberry.uitest/src/berryUITestApplication.cpp
index 23d637fa7a..716540239f 100644
--- a/BlueBerry/Bundles/org.blueberry.uitest/src/berryUITestApplication.cpp
+++ b/BlueBerry/Bundles/org.blueberry.uitest/src/berryUITestApplication.cpp
@@ -1,205 +1,205 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryUITestApplication.h"
#include <berryBlueBerryTestDriver.h>
#include <berryPlatformUI.h>
#include <berryIExtensionPointService.h>
#include <berryStarter.h>
#include "internal/berryUITestWorkbenchAdvisor.h"
namespace berry
{
class WorkbenchCloseRunnable: public Poco::Runnable
{
public:
WorkbenchCloseRunnable(IWorkbench* workbench) :
workbench(workbench)
{
}
void run()
{
workbench->Close();
}
private:
IWorkbench* workbench;
};
UITestApplication::TestRunnable::TestRunnable(UITestApplication* app,
const std::string& testPlugin) :
app(app), testPlugin(testPlugin)
{
}
void UITestApplication::TestRunnable::run()
{
try
{
app->testDriverResult = BlueBerryTestDriver::Run(testPlugin, true);
} catch (Poco::IOException& e)
{
std::cerr << e.displayText() << std::endl;
//TODO print stack trace
//Debug::PrintStackTrace();
}
}
UITestApplication::UITestApplication()
{
}
UITestApplication::UITestApplication(const UITestApplication& other)
{
Q_UNUSED(other)
throw std::logic_error("Copy constructor not implemented");
}
int UITestApplication::Start()
{
// Get the plug-in to test
try
{
testPlugin = Platform::GetConfiguration().getString(
Platform::ARG_TESTPLUGIN);
} catch (const Poco::NotFoundException& /*e*/)
{
BERRY_ERROR << "You must specify a test plug-in id via "
<< Platform::ARG_TESTPLUGIN << "=<id>";
return 1;
}
// Get the application to test
IApplication* application = GetApplication();
poco_assert(application);
int result = RunApplication(application);
if (IApplication::EXIT_OK != result)
{
std::cerr << "UITestRunner: Unexpected result from running application " << application << ": " << result << std::endl;
}
return testDriverResult;
}
void UITestApplication::Stop()
{
IWorkbench* workbench = PlatformUI::GetWorkbench();
if (!workbench)
return;
Display* display = workbench->GetDisplay();
WorkbenchCloseRunnable runnable(workbench);
display->SyncExec(&runnable);
}
void UITestApplication::RunTests()
{
TestRunnable runnable(this, testPlugin);
testableObject->TestingStarting();
testableObject->RunTest(&runnable);
testableObject->TestingFinished();
}
IApplication* UITestApplication::GetApplication() throw (CoreException)
{
const IExtension* extension = 0;
/*Platform::GetExtensionPointService()->GetExtension(
Starter::XP_APPLICATIONS, GetApplicationToRun());*/
IConfigurationElement::vector extensions(
Platform::GetExtensionPointService()->GetConfigurationElementsFor(Starter::XP_APPLICATIONS));
IConfigurationElement::vector::iterator iter;
std::string appToRun = GetApplicationToRun();
std::string id;
for (iter = extensions.begin(); iter != extensions.end(); ++iter)
{
if((*iter)->GetAttribute("id", id))
{
if(id == appToRun)
{
extension = (*iter)->GetDeclaringExtension();
break;
}
}
}
IApplication* app = 0;
if (extension)
{
std::vector<IConfigurationElement::Pointer> elements(
extension->GetConfigurationElements());
if (elements.size() > 0)
{
std::vector<IConfigurationElement::Pointer> runs(
elements[0]->GetChildren("run"));
if (runs.size() > 0)
{
app = runs[0]->CreateExecutableExtension<IApplication> ("class"); //$NON-NLS-1$
if (app == 0)
{
// support legacy BlueBerry extensions
app = runs[0]->CreateExecutableExtension<IApplication> ("class", IApplication::GetManifestName());
}
}
}
return app;
}
return this;
}
std::string UITestApplication::GetApplicationToRun()
{
std::string testApp;
try
{
testApp = Platform::GetConfiguration().getString(
Platform::ARG_TESTAPPLICATION);
}
catch (Poco::NotFoundException)
{
}
return testApp;
}
int UITestApplication::RunApplication(IApplication* application)
{
testableObject = PlatformUI::GetTestableObject();
testableObject->SetTestHarness(ITestHarness::Pointer(this));
if (application == dynamic_cast<IApplication*>(this))
return RunUITestWorkbench();
return application->Start();
}
int UITestApplication::RunUITestWorkbench()
{
Display* display = PlatformUI::CreateDisplay();
UITestWorkbenchAdvisor advisor;
return PlatformUI::CreateAndRunWorkbench(display, &advisor);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.uitest/src/berryUITestApplication.h b/BlueBerry/Bundles/org.blueberry.uitest/src/berryUITestApplication.h
index 9cb75a2bba..b7013e85fb 100644
--- a/BlueBerry/Bundles/org.blueberry.uitest/src/berryUITestApplication.h
+++ b/BlueBerry/Bundles/org.blueberry.uitest/src/berryUITestApplication.h
@@ -1,86 +1,86 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYUITESTAPPLICATION_H_
#define BERRYUITESTAPPLICATION_H_
#include <berryIApplication.h>
#include <berryITestHarness.h>
#include <berryTestableObject.h>
#include <berryPlatformException.h>
#include <org_blueberry_uitest_Export.h>
namespace berry
{
class BERRY_UITEST_EXPORT UITestApplication: public QObject, public IApplication, public ITestHarness
{
Q_OBJECT
Q_INTERFACES(berry::IApplication berry::ITestHarness)
public:
UITestApplication();
UITestApplication(const UITestApplication& other);
int Start();
void Stop();
/*
* @see berry#ITestHarness#RunTests()
*/
void RunTests();
private:
TestableObject::Pointer testableObject;
int testDriverResult;
std::string testPlugin;
/*
* return the application to run, or null if not even the default application
* is found.
*/
IApplication* GetApplication() throw (CoreException);
/**
* The -BlueBerry.testApplication argument specifies the application to be run.
* If the argument is not set, an empty string is returned and the UITestApplication
* itself will be started.
*/
std::string GetApplicationToRun();
int RunApplication(IApplication* application);
int RunUITestWorkbench();
struct TestRunnable: public Poco::Runnable
{
TestRunnable(UITestApplication* app, const std::string& testPlugin);
void run();
private:
UITestApplication* app;
std::string testPlugin;
};
};
}
#endif /* BERRYUITESTAPPLICATION_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.uitest/src/harness/berryUITestCase.cpp b/BlueBerry/Bundles/org.blueberry.uitest/src/harness/berryUITestCase.cpp
index ce41754863..32ded461ee 100644
--- a/BlueBerry/Bundles/org.blueberry.uitest/src/harness/berryUITestCase.cpp
+++ b/BlueBerry/Bundles/org.blueberry.uitest/src/harness/berryUITestCase.cpp
@@ -1,268 +1,268 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryUITestCase.h"
#include <berryPlatformUI.h>
#include <berryUIException.h>
#include "util/berryEmptyPerspective.h"
#ifdef BLUEBERRY_DEBUG_SMARTPOINTER
#include <berryDebugUtil.h>
#endif
namespace berry
{
IAdaptable* UITestCase::GetPageInput()
{
return 0;
}
UITestCase::UITestCase(const std::string& testName) :
TestCase(testName)
{
// ErrorDialog.NO_UI = true;
fWorkbench = PlatformUI::GetWorkbench();
}
void UITestCase::failexc(const std::string& message, const std::exception& e,
long lineNumber, const std::string& fileName)
{
//TODO IStatus
// If the exception is a CoreException with a multistatus
// then print out the multistatus so we can see all the info.
// if (e instanceof CoreException) {
// IStatus status = ((CoreException) e).getStatus();
// write(status, 0);
// } else
// e.printStackTrace();
fail(message + ": " + e.what(), lineNumber, fileName);
}
IWorkbenchWindow::Pointer UITestCase::OpenTestWindow()
{
return OpenTestWindow(EmptyPerspective::PERSP_ID);
}
IWorkbenchWindow::Pointer UITestCase::OpenTestWindow(
const std::string& perspectiveId)
{
try
{
IWorkbenchWindow::Pointer window = fWorkbench->OpenWorkbenchWindow(
perspectiveId, GetPageInput());
WaitOnShell(window->GetShell());
return window;
} catch (WorkbenchException& e)
{
failmsg(e.displayText());
return IWorkbenchWindow::Pointer(0);
}
}
void UITestCase::CloseAllTestWindows()
{
std::list<IWorkbenchWindow::Pointer>::iterator i = testWindows.begin();
while (!testWindows.empty())
{
testWindows.back()->Close();
testWindows.pop_back();
}
}
IWorkbenchPage::Pointer UITestCase::OpenTestPage(IWorkbenchWindow::Pointer /*win*/)
{
// IWorkbenchPage[] pages = openTestPage(win, 1);
// if (pages != null)
// return pages[0];
// else
return IWorkbenchPage::Pointer(0);
}
std::vector<IWorkbenchPage::Pointer> UITestCase::OpenTestPage(
IWorkbenchWindow::Pointer /*win*/, int /*pageTotal*/)
{
// try {
// IWorkbenchPage[] pages = new IWorkbenchPage[pageTotal];
// IAdaptable input = getPageInput();
//
// for (int i = 0; i < pageTotal; i++) {
// pages[i] = win.openPage(EmptyPerspective.PERSP_ID, input);
// }
// return pages;
// } catch (WorkbenchException e) {
// fail();
// return null;
// }
return std::vector<IWorkbenchPage::Pointer>();
}
void UITestCase::CloseAllPages(IWorkbenchWindow::Pointer /*window*/)
{
// IWorkbenchPage[] pages = window.getPages();
// for (int i = 0; i < pages.length; i++)
// pages[i].close();
}
void UITestCase::Trace(const std::string& msg)
{
std::cerr << msg << std::endl;
}
void UITestCase::setUp()
{
Trace("----- " + this->name());
Trace(this->name() + ": setUp...");
AddWindowListener();
berry::TestCase::setUp();
}
void UITestCase::DoSetUp()
{
// do nothing.
}
void UITestCase::tearDown()
{
Trace(this->name() + ": tearDown...\n");
RemoveWindowListener();
berry::TestCase::tearDown();
}
void UITestCase::DoTearDown()
{
ProcessEvents();
CloseAllTestWindows();
ProcessEvents();
}
void UITestCase::ProcessEvents()
{
// Display display = PlatformUI.getWorkbench().getDisplay();
// if (display != null)
// while (display.readAndDispatch())
// ;
}
void UITestCase::ManageWindows(bool manage)
{
windowListener->SetEnabled(manage);
}
IWorkbench* UITestCase::GetWorkbench()
{
return fWorkbench;
}
UITestCase::TestWindowListener::TestWindowListener(std::list<
IWorkbenchWindow::Pointer>& testWindows) :
enabled(true), testWindows(testWindows)
{
}
void UITestCase::TestWindowListener::SetEnabled(bool enabled)
{
this->enabled = enabled;
}
void UITestCase::TestWindowListener::WindowActivated(
IWorkbenchWindow::Pointer /*window*/)
{
// do nothing
}
void UITestCase::TestWindowListener::WindowDeactivated(
IWorkbenchWindow::Pointer /*window*/)
{
// do nothing
}
void UITestCase::TestWindowListener::WindowClosed(
IWorkbenchWindow::Pointer window)
{
if (enabled)
testWindows.remove(window);
}
void UITestCase::TestWindowListener::WindowOpened(
IWorkbenchWindow::Pointer window)
{
if (enabled)
testWindows.push_back(window);
}
void UITestCase::Indent(std::ostream& output, unsigned int indent)
{
for (unsigned int i = 0; i < indent; i++)
output << " ";
}
// void UITestCase::Write(IStatus status, unsigned int indent) {
// PrintStream output = System.out;
// indent(output, indent);
// output.println("Severity: " + status.getSeverity());
//
// indent(output, indent);
// output.println("Plugin ID: " + status.getPlugin());
//
// indent(output, indent);
// output.println("Code: " + status.getCode());
//
// indent(output, indent);
// output.println("Message: " + status.getMessage());
//
// if (status.getException() != null) {
// indent(output, indent);
// output.print("Exception: ");
// status.getException().printStackTrace(output);
// }
//
// if (status.isMultiStatus()) {
// IStatus[] children = status.getChildren();
// for (int i = 0; i < children.length; i++)
// write(children[i], indent + 1);
// }
// }
void UITestCase::AddWindowListener()
{
windowListener = new TestWindowListener(testWindows);
fWorkbench->AddWindowListener(windowListener);
}
void UITestCase::RemoveWindowListener()
{
if (windowListener)
{
fWorkbench->RemoveWindowListener(windowListener);
}
}
void UITestCase::WaitOnShell(Shell::Pointer /*shell*/)
{
ProcessEvents();
// long endTime = System.currentTimeMillis() + 5000;
//
// while (shell.getDisplay().getActiveShell() != shell
// && System.currentTimeMillis() < endTime) {
// processEvents();
// }
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.uitest/src/harness/berryUITestCase.h b/BlueBerry/Bundles/org.blueberry.uitest/src/harness/berryUITestCase.h
index 421c359b49..0d891596e0 100644
--- a/BlueBerry/Bundles/org.blueberry.uitest/src/harness/berryUITestCase.h
+++ b/BlueBerry/Bundles/org.blueberry.uitest/src/harness/berryUITestCase.h
@@ -1,213 +1,213 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYUITESTCASE_H_
#define BERRYUITESTCASE_H_
#include <berryTestCase.h>
#include <berryIWindowListener.h>
#include <berryIWorkbench.h>
#include <berryIWorkbenchPage.h>
#include <org_blueberry_uitest_Export.h>
#include <list>
namespace berry
{
/**
* <code>UITestCase</code> is a useful super class for most
* UI tests cases. It contains methods to create new windows
* and pages. It will also automatically close the test
* windows when the tearDown method is called.
*/
class BERRY_UITEST_EXPORT UITestCase: public TestCase
{
public:
/**
* Returns the workbench page input to use for newly created windows.
*
* @return the page input to use for newly created windows
* @since 3.1
*/
static IAdaptable* GetPageInput();
UITestCase(const std::string& testName);
/**
* Sets up the fixture, for example, open a network connection.
* This method is called before a test is executed.
* The default implementation does nothing.
* Subclasses may extend.
*/
virtual void DoSetUp();
/**
* Tears down the fixture, for example, close a network connection.
* This method is called after a test is executed.
* The default implementation closes all test windows, processing events both before
* and after doing so.
* Subclasses may extend.
*/
virtual void DoTearDown();
/**
* Fails the test due to the given throwable.
*/
void failexc(const std::string& message, const std::exception& e,
long lineNumber = CppUnit::CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
const std::string& fileName =
CppUnit::CppUnitException::CPPUNIT_UNKNOWNFILENAME);
/**
* Open a test window with the empty perspective.
*/
IWorkbenchWindow::Pointer OpenTestWindow();
/**
* Open a test window with the provided perspective.
*/
IWorkbenchWindow::Pointer OpenTestWindow(const std::string& perspectiveId);
/**
* Close all test windows.
*/
void CloseAllTestWindows();
/**
* Open a test page with the empty perspective in a window.
*/
IWorkbenchPage::Pointer OpenTestPage(IWorkbenchWindow::Pointer win);
/**
* Open "n" test pages with the empty perspective in a window.
*/
std::vector<IWorkbenchPage::Pointer> OpenTestPage(
IWorkbenchWindow::Pointer win, int pageTotal);
/**
* Close all pages within a window.
*/
void CloseAllPages(IWorkbenchWindow::Pointer window);
protected:
/**
* Outputs a trace message to the trace output device, if enabled.
* By default, trace messages are sent to <code>System.out</code>.
*
* @param msg the trace message
*/
void Trace(const std::string& msg);
/**
* Simple implementation of setUp. Subclasses are prevented
* from overriding this method to maintain logging consistency.
* DoSetUp() should be overriden instead.
*/
void setUp();
/**
* Simple implementation of tearDown. Subclasses are prevented
* from overriding this method to maintain logging consistency.
* DoTearDown() should be overriden instead.
*/
void tearDown();
static void ProcessEvents();
/**
* Set whether the window listener will manage opening and closing of created windows.
*/
void ManageWindows(bool manage);
/**
* Returns the workbench.
*
* @return the workbench
* @since 3.1
*/
IWorkbench* GetWorkbench();
class TestWindowListener: public IWindowListener
{
private:
bool enabled;
std::list<IWorkbenchWindow::Pointer>& testWindows;
public:
berryObjectMacro(TestWindowListener)
TestWindowListener(std::list<IWorkbenchWindow::Pointer>& testWindows);
void SetEnabled(bool enabled);
void WindowActivated(IWorkbenchWindow::Pointer window);
void WindowDeactivated(IWorkbenchWindow::Pointer window);
void WindowClosed(IWorkbenchWindow::Pointer window);
void WindowOpened(IWorkbenchWindow::Pointer window);
};
IWorkbench* fWorkbench;
private:
std::list<IWorkbenchWindow::Pointer> testWindows;
TestWindowListener::Pointer windowListener;
static void Indent(std::ostream& output, unsigned int indent);
//static void Write(IStatus status, unsigned int indent);
/**
* Adds a window listener to the workbench to keep track of
* opened test windows.
*/
void AddWindowListener();
/**
* Removes the listener added by <code>addWindowListener</code>.
*/
void RemoveWindowListener();
/**
* Try and process events until the new shell is the active shell. This may
* never happen, so time out after a suitable period.
*
* @param shell
* the shell to wait on
* @since 3.2
*/
void WaitOnShell(Shell::Pointer shell);
};
#define failuimsg(msg, exc) \
(this->failexc(msg, exc, __LINE__, __FILE__))
}
#endif /* BERRYUITESTCASE_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.uitest/src/internal/berryPluginActivator.cpp b/BlueBerry/Bundles/org.blueberry.uitest/src/internal/berryPluginActivator.cpp
index d1f9aea792..4bfe5d2446 100644
--- a/BlueBerry/Bundles/org.blueberry.uitest/src/internal/berryPluginActivator.cpp
+++ b/BlueBerry/Bundles/org.blueberry.uitest/src/internal/berryPluginActivator.cpp
@@ -1,45 +1,45 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryPluginActivator.h"
#include "berryUITestApplication.h"
#include "util/berryEmptyPerspective.h"
#include <QtPlugin>
namespace berry {
org_blueberry_uitest_Activator::org_blueberry_uitest_Activator()
{
}
void org_blueberry_uitest_Activator::start(ctkPluginContext* context)
{
BERRY_REGISTER_EXTENSION_CLASS(UITestApplication, context)
BERRY_REGISTER_EXTENSION_CLASS(EmptyPerspective, context)
}
void org_blueberry_uitest_Activator::stop(ctkPluginContext* context)
{
Q_UNUSED(context)
}
}
Q_EXPORT_PLUGIN2(org_blueberry_uitest, berry::org_blueberry_uitest_Activator)
diff --git a/BlueBerry/Bundles/org.blueberry.uitest/src/internal/berryPluginActivator.h b/BlueBerry/Bundles/org.blueberry.uitest/src/internal/berryPluginActivator.h
index 1cddca2423..2eaad57e59 100644
--- a/BlueBerry/Bundles/org.blueberry.uitest/src/internal/berryPluginActivator.h
+++ b/BlueBerry/Bundles/org.blueberry.uitest/src/internal/berryPluginActivator.h
@@ -1,42 +1,42 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYPLUGINACTIVATOR_H
#define BERRYPLUGINACTIVATOR_H
#include <ctkPluginActivator.h>
namespace berry {
class org_blueberry_uitest_Activator :
public QObject, public ctkPluginActivator
{
Q_OBJECT
Q_INTERFACES(ctkPluginActivator)
public:
org_blueberry_uitest_Activator();
void start(ctkPluginContext* context);
void stop(ctkPluginContext* context);
};
typedef org_blueberry_uitest_Activator PluginActivator;
}
#endif // BERRYPLUGINACTIVATOR_H
diff --git a/BlueBerry/Bundles/org.blueberry.uitest/src/internal/berryUITestWorkbenchAdvisor.cpp b/BlueBerry/Bundles/org.blueberry.uitest/src/internal/berryUITestWorkbenchAdvisor.cpp
index 36ad755d72..39443abe72 100644
--- a/BlueBerry/Bundles/org.blueberry.uitest/src/internal/berryUITestWorkbenchAdvisor.cpp
+++ b/BlueBerry/Bundles/org.blueberry.uitest/src/internal/berryUITestWorkbenchAdvisor.cpp
@@ -1,39 +1,39 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryUITestWorkbenchAdvisor.h"
#include "berryUITestWorkbenchWindowAdvisor.h"
namespace berry
{
UITestWorkbenchAdvisor::UITestWorkbenchAdvisor()
{
}
WorkbenchWindowAdvisor* UITestWorkbenchAdvisor::CreateWorkbenchWindowAdvisor(
IWorkbenchWindowConfigurer::Pointer configurer)
{
return new UITestWorkbenchWindowAdvisor(configurer);
}
std::string UITestWorkbenchAdvisor::GetInitialWindowPerspectiveId()
{
return "";
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.uitest/src/internal/berryUITestWorkbenchAdvisor.h b/BlueBerry/Bundles/org.blueberry.uitest/src/internal/berryUITestWorkbenchAdvisor.h
index 9674b2778f..0e0db19692 100644
--- a/BlueBerry/Bundles/org.blueberry.uitest/src/internal/berryUITestWorkbenchAdvisor.h
+++ b/BlueBerry/Bundles/org.blueberry.uitest/src/internal/berryUITestWorkbenchAdvisor.h
@@ -1,41 +1,41 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYUITESTWORKBENCHADVISOR_H_
#define BERRYUITESTWORKBENCHADVISOR_H_
#include <berryWorkbenchAdvisor.h>
namespace berry {
class UITestWorkbenchAdvisor : public WorkbenchAdvisor
{
public:
UITestWorkbenchAdvisor();
WorkbenchWindowAdvisor* CreateWorkbenchWindowAdvisor(
IWorkbenchWindowConfigurer::Pointer configurer);
std::string GetInitialWindowPerspectiveId();
};
}
#endif /* BERRYUITESTWORKBENCHADVISOR_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.uitest/src/internal/berryUITestWorkbenchWindowAdvisor.cpp b/BlueBerry/Bundles/org.blueberry.uitest/src/internal/berryUITestWorkbenchWindowAdvisor.cpp
index 2df27dca47..eb7298660d 100644
--- a/BlueBerry/Bundles/org.blueberry.uitest/src/internal/berryUITestWorkbenchWindowAdvisor.cpp
+++ b/BlueBerry/Bundles/org.blueberry.uitest/src/internal/berryUITestWorkbenchWindowAdvisor.cpp
@@ -1,27 +1,27 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryUITestWorkbenchWindowAdvisor.h"
namespace berry {
UITestWorkbenchWindowAdvisor::UITestWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer::Pointer configurer)
: WorkbenchWindowAdvisor(configurer)
{
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.uitest/src/internal/berryUITestWorkbenchWindowAdvisor.h b/BlueBerry/Bundles/org.blueberry.uitest/src/internal/berryUITestWorkbenchWindowAdvisor.h
index 12e172b5ca..f43d503914 100644
--- a/BlueBerry/Bundles/org.blueberry.uitest/src/internal/berryUITestWorkbenchWindowAdvisor.h
+++ b/BlueBerry/Bundles/org.blueberry.uitest/src/internal/berryUITestWorkbenchWindowAdvisor.h
@@ -1,34 +1,34 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYUITESTWORKBENCHWINDOWADVISOR_H_
#define BERRYUITESTWORKBENCHWINDOWADVISOR_H_
#include <berryWorkbenchWindowAdvisor.h>
namespace berry {
class UITestWorkbenchWindowAdvisor : public WorkbenchWindowAdvisor
{
public:
UITestWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer::Pointer configurer);
};
}
#endif /* BERRYUITESTWORKBENCHWINDOWADVISOR_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.uitest/src/util/berryEmptyPerspective.cpp b/BlueBerry/Bundles/org.blueberry.uitest/src/util/berryEmptyPerspective.cpp
index b24da1a242..2ef02ab3e5 100644
--- a/BlueBerry/Bundles/org.blueberry.uitest/src/util/berryEmptyPerspective.cpp
+++ b/BlueBerry/Bundles/org.blueberry.uitest/src/util/berryEmptyPerspective.cpp
@@ -1,54 +1,54 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryEmptyPerspective.h"
namespace berry
{
std::string EmptyPerspective::LastPerspective;
const std::string EmptyPerspective::PERSP_ID =
"org.blueberry.uitest.util.EmptyPerspective";
const std::string EmptyPerspective::PERSP_ID2 =
"org.blueberry.uitest.util.EmptyPerspective2";
EmptyPerspective::EmptyPerspective()
{
}
EmptyPerspective::EmptyPerspective(const EmptyPerspective& other)
{
Q_UNUSED(other)
}
std::string EmptyPerspective::GetLastPerspective()
{
return LastPerspective;
}
void EmptyPerspective::SetLastPerspective(const std::string& perspId)
{
LastPerspective = perspId;
}
void EmptyPerspective::CreateInitialLayout(IPageLayout::Pointer layout)
{
SetLastPerspective(layout->GetDescriptor()->GetId());
// do no layout, this is the empty perspective
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.uitest/src/util/berryEmptyPerspective.h b/BlueBerry/Bundles/org.blueberry.uitest/src/util/berryEmptyPerspective.h
index 1bee057fd3..b005ea7bf2 100644
--- a/BlueBerry/Bundles/org.blueberry.uitest/src/util/berryEmptyPerspective.h
+++ b/BlueBerry/Bundles/org.blueberry.uitest/src/util/berryEmptyPerspective.h
@@ -1,93 +1,93 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYEMPTYPERSPECTIVE_H_
#define BERRYEMPTYPERSPECTIVE_H_
#include <berryIPerspectiveFactory.h>
#include <org_blueberry_uitest_Export.h>
namespace berry
{
/**
* This perspective is used for testing api. It defines an initial
* layout with no parts, just an editor area.
*/
class BERRY_UITEST_EXPORT EmptyPerspective: public QObject, public IPerspectiveFactory
{
Q_OBJECT
Q_INTERFACES(berry::IPerspectiveFactory)
private:
static std::string LastPerspective;
public:
EmptyPerspective(const EmptyPerspective& other);
/**
* The perspective id for the empty perspective.
*/
static const std::string PERSP_ID; // = "org.blueberry.uitest.util.EmptyPerspective";
/**
* The perspective id for the second empty perspective.
*/
static const std::string PERSP_ID2; // = "org.blueberry.uitest.util.EmptyPerspective2";
/**
* Returns the descriptor for the perspective last opened using this factory.
*
* @return the descriptor for the perspective last opened using this factory, or <code>null</code>
*/
static std::string GetLastPerspective();
/**
* Sets the descriptor for the perspective last opened using this factory.
*
* @param persp the descriptor for the perspective last opened using this factory, or <code>null</code>
*/
static void SetLastPerspective(const std::string& perspId);
/**
* Constructs a new Default layout engine.
*/
EmptyPerspective();
/**
* Defines the initial layout for a perspective.
*
* Implementors of this method may add additional views to a
* perspective. The perspective already contains an editor folder
* with <code>ID = ILayoutFactory::ID_EDITORS</code>. Add additional views
* to the perspective in reference to the editor folder.
*
* This method is only called when a new perspective is created. If
* an old perspective is restored from a persistence file then
* this method is not called.
*
* @param factory the factory used to add views to the perspective
*/
void CreateInitialLayout(IPageLayout::Pointer layout);
};
}
#endif /* BERRYEMPTYPERSPECTIVE_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.uitest/src/util/berryUITestCaller.h b/BlueBerry/Bundles/org.blueberry.uitest/src/util/berryUITestCaller.h
index 0c4a3d74b7..a7268244f9 100644
--- a/BlueBerry/Bundles/org.blueberry.uitest/src/util/berryUITestCaller.h
+++ b/BlueBerry/Bundles/org.blueberry.uitest/src/util/berryUITestCaller.h
@@ -1,71 +1,71 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYUITESTCALLER_H_
#define BERRYUITESTCALLER_H_
#include <CppUnit/TestCase.h>
#include <CppUnit/Guards.h>
#include <memory>
namespace berry {
template <class Fixture>
class UITestCaller: public CppUnit::TestCase
{
REFERENCEOBJECT (UITestCaller)
typedef void (Fixture::*TestMethod)();
public:
UITestCaller(const std::string& name, TestMethod test):
CppUnit::TestCase(name),
_test(test),
_fixture(new Fixture(name))
{
}
protected:
void runTest()
{
(_fixture.get()->*_test)();
}
void setUp()
{
_fixture.get()->DoSetUp();
}
void tearDown()
{
_fixture.get()->DoTearDown();
}
private:
TestMethod _test;
std::auto_ptr<Fixture> _fixture;
};
} // namespace berry
#define CppUnit_addUITest(suite, cls, mth) \
suite->addTest(new berry::UITestCaller<cls>(#mth, &cls::mth))
#endif /* BERRYUITESTCALLER_H_ */
diff --git a/BlueBerry/Testing/org.blueberry.core.runtime.tests/src/berryCoreRuntimeTestSuite.cpp b/BlueBerry/Testing/org.blueberry.core.runtime.tests/src/berryCoreRuntimeTestSuite.cpp
index c98f173bfc..e80b57ce1c 100644
--- a/BlueBerry/Testing/org.blueberry.core.runtime.tests/src/berryCoreRuntimeTestSuite.cpp
+++ b/BlueBerry/Testing/org.blueberry.core.runtime.tests/src/berryCoreRuntimeTestSuite.cpp
@@ -1,41 +1,41 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 <CppUnit/TestCase.h>
#include <CppUnit/TestSuite.h>
#include <CppUnit/TestCaller.h>
#include "berryCoreRuntimeTestSuite.h"
#include "berryPreferencesTest.h"
#include "berryPreferencesServiceTest.h"
namespace berry {
CoreRuntimeTestSuite::CoreRuntimeTestSuite(const CoreRuntimeTestSuite& other)
{
}
CoreRuntimeTestSuite::CoreRuntimeTestSuite()
: CppUnit::TestSuite("CoreRuntimeTestSuite")
{
addTest(PreferencesTest::Suite());
addTest(PreferencesServiceTest::Suite());
}
}
diff --git a/BlueBerry/Testing/org.blueberry.core.runtime.tests/src/berryCoreRuntimeTestSuite.h b/BlueBerry/Testing/org.blueberry.core.runtime.tests/src/berryCoreRuntimeTestSuite.h
index 18611986bc..86da5395ac 100644
--- a/BlueBerry/Testing/org.blueberry.core.runtime.tests/src/berryCoreRuntimeTestSuite.h
+++ b/BlueBerry/Testing/org.blueberry.core.runtime.tests/src/berryCoreRuntimeTestSuite.h
@@ -1,42 +1,42 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYCORERUNTIMETESTSUITE_H_
#define BERRYCORERUNTIMETESTSUITE_H_
#include <CppUnit/TestSuite.h>
#include <QObject>
Q_DECLARE_INTERFACE(CppUnit::Test, "CppUnit.Test")
namespace berry {
class CoreRuntimeTestSuite : public QObject, public CppUnit::TestSuite
{
Q_OBJECT
Q_INTERFACES(CppUnit::Test)
public:
CoreRuntimeTestSuite();
CoreRuntimeTestSuite(const CoreRuntimeTestSuite& other);
};
}
#endif /* BERRYCORERUNTIMETESTSUITE_H_ */
diff --git a/BlueBerry/Testing/org.blueberry.core.runtime.tests/src/berryPluginActivator.cpp b/BlueBerry/Testing/org.blueberry.core.runtime.tests/src/berryPluginActivator.cpp
index 47cebeae59..c79a788fcd 100644
--- a/BlueBerry/Testing/org.blueberry.core.runtime.tests/src/berryPluginActivator.cpp
+++ b/BlueBerry/Testing/org.blueberry.core.runtime.tests/src/berryPluginActivator.cpp
@@ -1,39 +1,39 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 <berryMacros.h>
#include "berryPluginActivator.h"
#include "berryCoreRuntimeTestSuite.h"
#include <QtPlugin>
namespace berry {
void org_blueberry_core_runtime_tests_Activator::start(ctkPluginContext* context)
{
BERRY_REGISTER_EXTENSION_CLASS(CoreRuntimeTestSuite, context)
}
void org_blueberry_core_runtime_tests_Activator::stop(ctkPluginContext* context)
{
Q_UNUSED(context)
}
}
Q_EXPORT_PLUGIN2(org_blueberry_core_runtime_tests, berry::org_blueberry_core_runtime_tests_Activator)
diff --git a/BlueBerry/Testing/org.blueberry.core.runtime.tests/src/berryPluginActivator.h b/BlueBerry/Testing/org.blueberry.core.runtime.tests/src/berryPluginActivator.h
index 8c17c29d94..793a65a1eb 100644
--- a/BlueBerry/Testing/org.blueberry.core.runtime.tests/src/berryPluginActivator.h
+++ b/BlueBerry/Testing/org.blueberry.core.runtime.tests/src/berryPluginActivator.h
@@ -1,43 +1,43 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYPLUGINACTIVATOR_H
#define BERRYPLUGINACTIVATOR_H
#include <ctkPluginActivator.h>
#include <ctkServiceRegistration.h>
namespace berry {
class org_blueberry_core_runtime_tests_Activator :
public QObject, public ctkPluginActivator
{
Q_OBJECT
Q_INTERFACES(ctkPluginActivator)
public:
void start(ctkPluginContext* context);
void stop(ctkPluginContext* context);
};
typedef org_blueberry_core_runtime_tests_Activator PluginActivator;
}
#endif // BERRYPLUGINACTIVATOR_H
diff --git a/BlueBerry/Testing/org.blueberry.core.runtime.tests/src/berryPreferencesServiceTest.h b/BlueBerry/Testing/org.blueberry.core.runtime.tests/src/berryPreferencesServiceTest.h
index 36edd8b732..72c80130b8 100644
--- a/BlueBerry/Testing/org.blueberry.core.runtime.tests/src/berryPreferencesServiceTest.h
+++ b/BlueBerry/Testing/org.blueberry.core.runtime.tests/src/berryPreferencesServiceTest.h
@@ -1,38 +1,38 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYPREFERENCESSERVICETEST_H_
#define BERRYPREFERENCESSERVICETEST_H_
#include <berryTestCase.h>
namespace berry {
class PreferencesServiceTest : public berry::TestCase
{
public:
static CppUnit::Test* Suite();
PreferencesServiceTest(const std::string& testName);
void TestAll();
};
}
#endif /* BERRYPREFERENCESSERVICETEST_H_ */
diff --git a/BlueBerry/Testing/org.blueberry.core.runtime.tests/src/berryPreferencesTest.h b/BlueBerry/Testing/org.blueberry.core.runtime.tests/src/berryPreferencesTest.h
index 65881199f2..b3d2d8b741 100644
--- a/BlueBerry/Testing/org.blueberry.core.runtime.tests/src/berryPreferencesTest.h
+++ b/BlueBerry/Testing/org.blueberry.core.runtime.tests/src/berryPreferencesTest.h
@@ -1,39 +1,39 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYPREFERENCESTEST_H_
#define BERRYPREFERENCESTEST_H_
#include <berryTestCase.h>
namespace berry {
class PreferencesTest : public berry::TestCase
{
public:
PreferencesTest(const std::string& testName);
static CppUnit::Test* Suite();
void TestAll();
};
}
#endif /* BERRYPREFERENCESTEST_H_ */
diff --git a/BlueBerry/Testing/org.blueberry.osgi.tests/src/berryMessageTest.cpp b/BlueBerry/Testing/org.blueberry.osgi.tests/src/berryMessageTest.cpp
index 4fc5a0ec4f..07a979d40d 100755
--- a/BlueBerry/Testing/org.blueberry.osgi.tests/src/berryMessageTest.cpp
+++ b/BlueBerry/Testing/org.blueberry.osgi.tests/src/berryMessageTest.cpp
@@ -1,331 +1,331 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryMessageTest.h"
#include <berryMessage.h>
//#include <cstdlib>
#include <CppUnit/TestSuite.h>
#include <CppUnit/TestCaller.h>
namespace berry
{
struct MessageReceiver
{
bool received;
MessageReceiver() : received(false) {}
void PureSignal() { received = true; }
bool PureSignalWithReturn() { received = true; return received; }
void Message1(int i) { received = (i != 0); }
bool Message1WithReturn(int i) { received = (i != 0); return received; }
void Message2(int i, float d) { received = (i != 0 && d != 0); }
bool Message2WithReturn(int i, float d) { received = (i != 0 && d!= 0); return received; }
void Message3(int i, float d, double e) { received = (i != 0 && d != 0 && e != 0); }
bool Message3WithReturn(int i, float d, double e) { received = (i != 0 && d != 0 && e != 0); return received; }
void Message4(int i, float d, double e, bool b) { received = (i != 0 && d != 0 && e != 0 && b); }
bool Message4WithReturn(int i, float d, double e, bool b) { received = (i != 0 && d != 0 && e != 0 && b); return received; }
};
MessageTest::MessageTest(const std::string& testName)
: TestCase(testName)
{
}
CppUnit::Test* MessageTest::Suite()
{
CppUnit::TestSuite* suite = new CppUnit::TestSuite("MessageTest");
CppUnit_addTest(suite, MessageTest, TestMessage);
CppUnit_addTest(suite, MessageTest, TestMessageWithReturn);
CppUnit_addTest(suite, MessageTest, TestMessage1);
CppUnit_addTest(suite, MessageTest, TestMessage1WithReturn);
CppUnit_addTest(suite, MessageTest, TestMessage2);
CppUnit_addTest(suite, MessageTest, TestMessage2WithReturn);
CppUnit_addTest(suite, MessageTest, TestMessage3);
CppUnit_addTest(suite, MessageTest, TestMessage3WithReturn);
CppUnit_addTest(suite, MessageTest, TestMessage4);
CppUnit_addTest(suite, MessageTest, TestMessage4WithReturn);
return suite;
}
void MessageTest::TestMessage()
{
berry::Message<> msg;
MessageReceiver receiver;
MessageReceiver receiver2;
typedef berry::MessageDelegate<MessageReceiver> Delegate;
msg += Delegate(&receiver, &MessageReceiver::PureSignal);
assertEqual(1, (long)msg.GetListeners().size());
msg += Delegate(&receiver2, &MessageReceiver::PureSignal);
// duplicate entry
msg += Delegate(&receiver, &MessageReceiver::PureSignal);
assertEqual(2, (long)msg.GetListeners().size());
msg.Send();
assert(receiver.received && receiver2.received);
receiver.received = false;
receiver2.received = false;
msg -= Delegate(&receiver, &MessageReceiver::PureSignal);
assertEqual(1, (long)msg.GetListeners().size());
msg.Send();
assert(receiver.received == false && receiver2.received);
}
void MessageTest::TestMessageWithReturn()
{
berry::Message<bool> msg;
MessageReceiver receiver;
typedef berry::MessageDelegate<MessageReceiver, bool> Delegate;
msg += Delegate(&receiver, &MessageReceiver::PureSignalWithReturn);
msg();
assert(receiver.received);
receiver.received = false;
typedef berry::Message<bool>::ListenerList Listeners;
const Listeners& listeners = msg.GetListeners();
bool valueReturned = false;
for (Listeners::const_iterator iter = listeners.begin();
iter != listeners.end(); ++iter)
{
valueReturned = (*iter)->Execute();
if (valueReturned) break;
}
assert(valueReturned);
}
void MessageTest::TestMessage1()
{
berry::Message1<int> msg;
MessageReceiver receiver;
MessageReceiver receiver2;
typedef berry::MessageDelegate1<MessageReceiver, int> Delegate;
msg += Delegate(&receiver, &MessageReceiver::Message1);
assertEqual(1, (long)msg.GetListeners().size());
msg += Delegate(&receiver2, &MessageReceiver::Message1);
// duplicate entry
msg += Delegate(&receiver, &MessageReceiver::Message1);
assertEqual(2, (long)msg.GetListeners().size());
msg.Send(1);
assert(receiver.received && receiver2.received);
receiver.received = false;
receiver2.received = false;
msg -= Delegate(&receiver, &MessageReceiver::Message1);
assertEqual(1, (long)msg.GetListeners().size());
msg.Send(1);
assert(receiver.received == false && receiver2.received);
}
void MessageTest::TestMessage1WithReturn()
{
berry::Message1<int, bool> msg;
MessageReceiver receiver;
typedef berry::MessageDelegate1<MessageReceiver, int, bool> Delegate;
msg += Delegate(&receiver, &MessageReceiver::Message1WithReturn);
msg(1);
assert(receiver.received);
receiver.received = false;
typedef berry::Message1<int,bool>::ListenerList Listeners;
const Listeners& listeners = msg.GetListeners();
bool valueReturned = false;
for (Listeners::const_iterator iter = listeners.begin();
iter != listeners.end(); ++iter)
{
valueReturned = (*iter)->Execute(1);
if (valueReturned) break;
}
assert(valueReturned);
}
void MessageTest::TestMessage2()
{
berry::Message2<int, float> msg;
MessageReceiver receiver;
MessageReceiver receiver2;
typedef berry::MessageDelegate2<MessageReceiver, int, float> Delegate;
msg += Delegate(&receiver, &MessageReceiver::Message2);
assertEqual(1, (long)msg.GetListeners().size());
msg += Delegate(&receiver2, &MessageReceiver::Message2);
// duplicate entry
msg += Delegate(&receiver, &MessageReceiver::Message2);
assertEqual(2, (long)msg.GetListeners().size());
msg.Send(1, 1.0);
assert(receiver.received && receiver2.received);
receiver.received = false;
receiver2.received = false;
msg -= Delegate(&receiver, &MessageReceiver::Message2);
assertEqual(1, (long)msg.GetListeners().size());
msg.Send(1, 1.0);
assert(receiver.received == false && receiver2.received);
}
void MessageTest::TestMessage2WithReturn()
{
berry::Message2<int, float, bool> msg;
MessageReceiver receiver;
typedef berry::MessageDelegate2<MessageReceiver, int, float, bool> Delegate;
msg += Delegate(&receiver, &MessageReceiver::Message2WithReturn);
msg(1, 2);
assert(receiver.received);
receiver.received = false;
typedef berry::Message2<int,float,bool>::ListenerList Listeners;
const Listeners& listeners = msg.GetListeners();
bool valueReturned = false;
for (Listeners::const_iterator iter = listeners.begin();
iter != listeners.end(); ++iter)
{
valueReturned = (*iter)->Execute(1, 0.4f);
if (valueReturned) break;
}
assert(valueReturned);
}
void MessageTest::TestMessage3()
{
berry::Message3<int, float, double> msg;
MessageReceiver receiver;
MessageReceiver receiver2;
typedef berry::MessageDelegate3<MessageReceiver, int, float, double> Delegate;
msg += Delegate(&receiver, &MessageReceiver::Message3);
assertEqual(1, (long)msg.GetListeners().size());
msg += Delegate(&receiver2, &MessageReceiver::Message3);
// duplicate entry
msg += Delegate(&receiver, &MessageReceiver::Message3);
assertEqual(2, (long)msg.GetListeners().size());
msg.Send(1, 1.0, 2.0);
assert(receiver.received && receiver2.received);
receiver.received = false;
receiver2.received = false;
msg -= Delegate(&receiver, &MessageReceiver::Message3);
assertEqual(1, (long)msg.GetListeners().size());
msg.Send(1, -1.0, 5.0);
assert(receiver.received == false && receiver2.received);
}
void MessageTest::TestMessage3WithReturn()
{
berry::Message3<int, float, double, bool> msg;
MessageReceiver receiver;
typedef berry::MessageDelegate3<MessageReceiver, int, float, double, bool> Delegate;
msg += Delegate(&receiver, &MessageReceiver::Message3WithReturn);
msg(1, -2, 0.2);
assert(receiver.received);
receiver.received = false;
typedef berry::Message3<int,float,double,bool>::ListenerList Listeners;
const Listeners& listeners = msg.GetListeners();
bool valueReturned = false;
for (Listeners::const_iterator iter = listeners.begin();
iter != listeners.end(); ++iter)
{
valueReturned = (*iter)->Execute(1, 23.5, -12.2);
if (valueReturned) break;
}
assert(valueReturned);
}
void MessageTest::TestMessage4()
{
berry::Message4<int, float, double, bool> msg;
MessageReceiver receiver;
MessageReceiver receiver2;
typedef berry::MessageDelegate4<MessageReceiver, int, float, double, bool> Delegate;
msg += Delegate(&receiver, &MessageReceiver::Message4);
assertEqual(1, (long)msg.GetListeners().size());
msg += Delegate(&receiver2, &MessageReceiver::Message4);
// duplicate entry
msg += Delegate(&receiver, &MessageReceiver::Message4);
assertEqual(2, (long)msg.GetListeners().size());
msg.Send(1, 5.4f, -1.0f, true);
assert(receiver.received && receiver2.received);
receiver.received = false;
receiver2.received = false;
msg -= Delegate(&receiver, &MessageReceiver::Message4);
assertEqual(1, (long)msg.GetListeners().size());
msg.Send(1, 0.2f, 12.0f, true);
assert(receiver.received == false && receiver2.received);
}
void MessageTest::TestMessage4WithReturn()
{
berry::Message4<int, float, double, bool, bool> msg;
MessageReceiver receiver;
typedef berry::MessageDelegate4<MessageReceiver, int, float, double, bool, bool> Delegate;
msg += Delegate(&receiver, &MessageReceiver::Message4WithReturn);
msg(1, 4.1f, -1, true);
assert(receiver.received);
receiver.received = false;
typedef berry::Message4<int,float,double,bool,bool>::ListenerList Listeners;
const Listeners& listeners = msg.GetListeners();
bool valueReturned = false;
for (Listeners::const_iterator iter = listeners.begin();
iter != listeners.end(); ++iter)
{
valueReturned = (*iter)->Execute(1, -34.21f, 2, true);
if (valueReturned) break;
}
assert(valueReturned);
}
}
diff --git a/BlueBerry/Testing/org.blueberry.osgi.tests/src/berryMessageTest.h b/BlueBerry/Testing/org.blueberry.osgi.tests/src/berryMessageTest.h
index 514095e7a1..f49e01fff6 100644
--- a/BlueBerry/Testing/org.blueberry.osgi.tests/src/berryMessageTest.h
+++ b/BlueBerry/Testing/org.blueberry.osgi.tests/src/berryMessageTest.h
@@ -1,48 +1,48 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYMESSAGETEST_H_
#define BERRYMESSAGETEST_H_
#include <berryTestCase.h>
namespace berry {
class MessageTest : public TestCase {
public:
MessageTest(const std::string& testName);
static CppUnit::Test* Suite();
void TestMessage();
void TestMessageWithReturn();
void TestMessage1();
void TestMessage1WithReturn();
void TestMessage2();
void TestMessage2WithReturn();
void TestMessage3();
void TestMessage3WithReturn();
void TestMessage4();
void TestMessage4WithReturn();
};
}
#endif /* BERRYMESSAGETEST_H_ */
diff --git a/BlueBerry/Testing/org.blueberry.osgi.tests/src/berryOSGiCoreTestSuite.cpp b/BlueBerry/Testing/org.blueberry.osgi.tests/src/berryOSGiCoreTestSuite.cpp
index 37bea78a6c..2c862b6594 100644
--- a/BlueBerry/Testing/org.blueberry.osgi.tests/src/berryOSGiCoreTestSuite.cpp
+++ b/BlueBerry/Testing/org.blueberry.osgi.tests/src/berryOSGiCoreTestSuite.cpp
@@ -1,45 +1,45 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 <CppUnit/TestCase.h>
#include <CppUnit/TestSuite.h>
#include <CppUnit/TestCaller.h>
#include "berryOSGiCoreTestSuite.h"
#include "berryObjectTest.h"
#include "berrySmartPointerTest.h"
#include "berryWeakPointerTest.h"
#include "berryMessageTest.h"
namespace berry {
OSGiCoreTestSuite::OSGiCoreTestSuite()
: CppUnit::TestSuite("OSGiCoreTestSuite")
{
addTest(ObjectTest::Suite());
addTest(SmartPointerTest::Suite());
addTest(WeakPointerTest::Suite());
addTest(MessageTest::Suite());
}
OSGiCoreTestSuite::OSGiCoreTestSuite(const OSGiCoreTestSuite& other)
{
Q_UNUSED(other)
}
}
diff --git a/BlueBerry/Testing/org.blueberry.osgi.tests/src/berryOSGiCoreTestSuite.h b/BlueBerry/Testing/org.blueberry.osgi.tests/src/berryOSGiCoreTestSuite.h
index edb3e89ebd..b922d3a150 100644
--- a/BlueBerry/Testing/org.blueberry.osgi.tests/src/berryOSGiCoreTestSuite.h
+++ b/BlueBerry/Testing/org.blueberry.osgi.tests/src/berryOSGiCoreTestSuite.h
@@ -1,42 +1,42 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYOSGICORETESTSUITE_H_
#define BERRYOSGICORETESTSUITE_H_
#include <CppUnit/TestSuite.h>
#include <QObject>
Q_DECLARE_INTERFACE(CppUnit::Test, "CppUnit.Test")
namespace berry {
class OSGiCoreTestSuite : public QObject, public CppUnit::TestSuite
{
Q_OBJECT
Q_INTERFACES(CppUnit::Test)
public:
OSGiCoreTestSuite();
OSGiCoreTestSuite(const OSGiCoreTestSuite& other);
};
}
#endif /* BERRYOSGICORETESTSUITE_H_ */
diff --git a/BlueBerry/Testing/org.blueberry.osgi.tests/src/berryObjectTest.cpp b/BlueBerry/Testing/org.blueberry.osgi.tests/src/berryObjectTest.cpp
index bb749bca8a..cebaaca154 100755
--- a/BlueBerry/Testing/org.blueberry.osgi.tests/src/berryObjectTest.cpp
+++ b/BlueBerry/Testing/org.blueberry.osgi.tests/src/berryObjectTest.cpp
@@ -1,113 +1,113 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryObjectTest.h"
#include <CppUnit/TestSuite.h>
#include <CppUnit/TestCaller.h>
#include <berryObject.h>
//#include <cstdlib>
namespace berry
{
class TestObject: public Object
{
public:
TestObject() :
Object()
{
}
};
/**
* used for listening to destroy events
*/
struct ObjectListener
{
bool m_ObjectDeleted;
ObjectListener() :
m_ObjectDeleted(false)
{
}
void DestroyListener()
{
m_ObjectDeleted = true;
}
};
CppUnit::Test* ObjectTest::Suite()
{
CppUnit::TestSuite* suite = new CppUnit::TestSuite("ObjectTest");
CppUnit_addTest(suite, ObjectTest, TestReferenceCount);
CppUnit_addTest(suite, ObjectTest, TestAddDestroyListener);
CppUnit_addTest(suite, ObjectTest, TestRemoveDestroyListener);
return suite;
}
ObjectTest::ObjectTest(const std::string& testName) :
TestCase(testName)
{
}
void ObjectTest::TestReferenceCount()
{
TestObject* obj = new TestObject();
assertEqual(obj->GetReferenceCount(), 0);
obj->Register();
assertEqual(obj->GetReferenceCount(), 1);
obj->SetReferenceCount(3);
assertEqual(obj->GetReferenceCount(), 3);
obj->SetReferenceCount(0);
}
void ObjectTest::TestAddDestroyListener()
{
TestObject* obj = new TestObject();
ObjectListener objectListener;
obj->AddDestroyListener(berry::MessageDelegate<ObjectListener>(
&objectListener, &ObjectListener::DestroyListener));
delete obj;
assertEqual(true, objectListener.m_ObjectDeleted);
}
void ObjectTest::TestRemoveDestroyListener()
{
TestObject* obj = new TestObject();
ObjectListener objectListener;
obj->AddDestroyListener(berry::MessageDelegate<ObjectListener>(
&objectListener, &ObjectListener::DestroyListener));
obj->RemoveDestroyListener(berry::MessageDelegate<ObjectListener>(
&objectListener, &ObjectListener::DestroyListener));
delete obj;
assertEqual(false, objectListener.m_ObjectDeleted);
}
}
diff --git a/BlueBerry/Testing/org.blueberry.osgi.tests/src/berryObjectTest.h b/BlueBerry/Testing/org.blueberry.osgi.tests/src/berryObjectTest.h
index 095a477c8d..bcda9f27af 100644
--- a/BlueBerry/Testing/org.blueberry.osgi.tests/src/berryObjectTest.h
+++ b/BlueBerry/Testing/org.blueberry.osgi.tests/src/berryObjectTest.h
@@ -1,40 +1,40 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYOBJECTTEST_H_
#define BERRYOBJECTTEST_H_
#include <berryTestCase.h>
namespace berry {
class ObjectTest : public TestCase
{
public:
static CppUnit::Test* Suite();
ObjectTest(const std::string& testName);
void TestReferenceCount();
void TestAddDestroyListener();
void TestRemoveDestroyListener();
};
}
#endif /* BERRYOBJECTTEST_H_ */
diff --git a/BlueBerry/Testing/org.blueberry.osgi.tests/src/berryPluginActivator.cpp b/BlueBerry/Testing/org.blueberry.osgi.tests/src/berryPluginActivator.cpp
index 9a76312c70..3b4371150a 100644
--- a/BlueBerry/Testing/org.blueberry.osgi.tests/src/berryPluginActivator.cpp
+++ b/BlueBerry/Testing/org.blueberry.osgi.tests/src/berryPluginActivator.cpp
@@ -1,41 +1,41 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 <berryMacros.h>
#include "berryPluginActivator.h"
#include "berryOSGiCoreTestSuite.h"
#include <QtPlugin>
namespace berry {
void org_blueberry_osgi_tests_Activator::start(ctkPluginContext* context)
{
Q_UNUSED(context)
BERRY_REGISTER_EXTENSION_CLASS(OSGiCoreTestSuite, context)
}
void org_blueberry_osgi_tests_Activator::stop(ctkPluginContext* context)
{
Q_UNUSED(context)
}
}
Q_EXPORT_PLUGIN2(org_blueberry_osgi_tests, berry::org_blueberry_osgi_tests_Activator)
diff --git a/BlueBerry/Testing/org.blueberry.osgi.tests/src/berryPluginActivator.h b/BlueBerry/Testing/org.blueberry.osgi.tests/src/berryPluginActivator.h
index bd404aea75..7ea9b64421 100644
--- a/BlueBerry/Testing/org.blueberry.osgi.tests/src/berryPluginActivator.h
+++ b/BlueBerry/Testing/org.blueberry.osgi.tests/src/berryPluginActivator.h
@@ -1,43 +1,43 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYPLUGINACTIVATOR_H
#define BERRYPLUGINACTIVATOR_H
#include <ctkPluginActivator.h>
#include <ctkServiceRegistration.h>
namespace berry {
class org_blueberry_osgi_tests_Activator :
public QObject, public ctkPluginActivator
{
Q_OBJECT
Q_INTERFACES(ctkPluginActivator)
public:
void start(ctkPluginContext* context);
void stop(ctkPluginContext* context);
};
typedef org_blueberry_osgi_tests_Activator PluginActivator;
}
#endif // BERRYPLUGINACTIVATOR_H
diff --git a/BlueBerry/Testing/org.blueberry.osgi.tests/src/berrySmartPointerTest.cpp b/BlueBerry/Testing/org.blueberry.osgi.tests/src/berrySmartPointerTest.cpp
index 3b880fcfaa..71a066705f 100755
--- a/BlueBerry/Testing/org.blueberry.osgi.tests/src/berrySmartPointerTest.cpp
+++ b/BlueBerry/Testing/org.blueberry.osgi.tests/src/berrySmartPointerTest.cpp
@@ -1,213 +1,213 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berrySmartPointerTest.h"
#include <CppUnit/TestSuite.h>
#include <CppUnit/TestCaller.h>
#include <berryObject.h>
#include <berrySmartPointer.h>
#include <berryWeakPointer.h>
#include <typeinfo>
//#include <cstdlib>
namespace berry
{
class TestObject : public berry::Object
{
public:
TestObject() : Object(), m_Val(0) {}
TestObject(int value) : m_Val(value) {}
bool operator==(const Object* o) const
{
if (const TestObject* to = dynamic_cast<const TestObject*>(o))
return m_Val == to->m_Val;
return false;
}
private:
int m_Val;
};
SmartPointerTest::SmartPointerTest(const std::string& testName)
: TestCase(testName)
{}
CppUnit::Test* SmartPointerTest::Suite()
{
CppUnit::TestSuite* suite = new CppUnit::TestSuite("SmartPointerTest");
CppUnit_addTest(suite, SmartPointerTest, TestConstructors);
CppUnit_addTest(suite, SmartPointerTest, TestCasting);
CppUnit_addTest(suite, SmartPointerTest, TestReferenceCounting);
CppUnit_addTest(suite, SmartPointerTest, TestOperators);
return suite;
}
void SmartPointerTest::TestConstructors()
{
{
// standard constructor
berry::SmartPointer<TestObject> testobj;
assertNullPtr(testobj.GetPointer());
}
{
// standard pointer constructor
berry::SmartPointer<TestObject> testobj(new TestObject());
assertNotNullPtr(testobj.GetPointer());
assertEqual(1, testobj->GetReferenceCount());
// copy constructor
berry::SmartPointer<TestObject> testobj2 = testobj;
assertEqual(testobj.GetPointer(), testobj2.GetPointer());
assertEqual(2, testobj2->GetReferenceCount());
}
{
// WeakPointer constructor
berry::WeakPointer<TestObject> ptr_weak;
try {
berry::SmartPointer<TestObject> testobj(ptr_weak);
failmsg("this should throw a BadWeakPointerException");
}
catch (BadWeakPointerException )
{
// expected
}
}
{
// const_cast template constructor
berry::SmartPointer<TestObject> testobj(new TestObject());
berry::SmartPointer<berry::Object> obj(testobj);
assertNotNullPtr(obj.GetPointer());
assertEqual(2, obj->GetReferenceCount());
assert(typeid(*(obj.GetPointer())) == typeid(TestObject));
}
}
void SmartPointerTest::TestCasting()
// cast tests
{
berry::SmartPointer<berry::Object> obj(new TestObject());
assertNotNullPtr(obj.GetPointer());
assertEqual(1, obj->GetReferenceCount());
berry::SmartPointer<TestObject> testobj = obj.Cast<TestObject>();
assertNotNullPtr(testobj.GetPointer());
assertEqual(2, testobj->GetReferenceCount());
assertEqual(testobj.GetPointer(), obj.GetPointer());
}
void SmartPointerTest::TestReferenceCounting()
// reference count tests
{
berry::SmartPointer<berry::Object> obj(new TestObject());
{
berry::SmartPointer<berry::Object> tmpobj = obj;
}
assertEqual(1, obj->GetReferenceCount());
}
void SmartPointerTest::TestOperators()
{
// operator tests
{
berry::SmartPointer<berry::Object> obj(new TestObject(1));
berry::SmartPointer<TestObject> testobj(new TestObject(2));
berry::SmartPointer<berry::Object> nullobj;
// boolean conversions
assert(obj.IsNotNull());
assert(false == obj.IsNull());
assert(obj);
assert(false == !obj);
// != operators
assert(obj != 0);
try
{
obj != 1;
failmsg("should throw a std::invalid_argument exception");
}
catch (std::invalid_argument)
{ //expectted }
}
// operator!=(R)
assert(obj != testobj.GetPointer());
// operator!=(const berry::SmartPointer<R>&)
assert(obj != testobj);
// == operators
// operator==(int)
assert((obj == 0) == false);
try {
obj == 1;
failmsg("should throw a std::invalid_argument exception");
}
catch (std::invalid_argument)
{ // expected }
}
// operator==(R)
assert((obj == testobj.GetPointer()) == false);
// operator==(R)
assert(obj == obj.GetPointer());
// operator==(R)
assert((obj == nullobj.GetPointer()) == false);
// operator==(const berry::SmartPointer<R>&)
assert((obj == testobj) == false);
// operator==(const berry::SmartPointer<R>&)
assert(obj == obj);
// operator==(const berry::SmartPointer<R>&)
assert((obj == nullobj) == false);
}
{
// = operators
berry::SmartPointer<berry::Object> obj(new TestObject(1));
berry::SmartPointer<TestObject> testobj(new TestObject(2));
obj = testobj;
// operator=(const berry::SmartPointer<R>&)
assert(obj == testobj);
assertEqual(2, obj->GetReferenceCount());
// operator=(Object*)
obj = testobj.GetPointer();
assert(obj == testobj);
assertEqual(2, obj->GetReferenceCount());
}
}
}
diff --git a/BlueBerry/Testing/org.blueberry.osgi.tests/src/berrySmartPointerTest.h b/BlueBerry/Testing/org.blueberry.osgi.tests/src/berrySmartPointerTest.h
index b1b3e4f03c..e53cf9bd2e 100644
--- a/BlueBerry/Testing/org.blueberry.osgi.tests/src/berrySmartPointerTest.h
+++ b/BlueBerry/Testing/org.blueberry.osgi.tests/src/berrySmartPointerTest.h
@@ -1,42 +1,42 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYSMARTPOINTERTEST_H_
#define BERRYSMARTPOINTERTEST_H_
#include <berryTestCase.h>
namespace berry {
class SmartPointerTest : public TestCase
{
public:
SmartPointerTest(const std::string& testName);
static CppUnit::Test* Suite();
void TestConstructors();
void TestCasting();
void TestReferenceCounting();
void TestOperators();
};
}
#endif /* BERRYSMARTPOINTERTEST_H_ */
diff --git a/BlueBerry/Testing/org.blueberry.osgi.tests/src/berryWeakPointerTest.cpp b/BlueBerry/Testing/org.blueberry.osgi.tests/src/berryWeakPointerTest.cpp
index b8b11f9218..8f6352584e 100644
--- a/BlueBerry/Testing/org.blueberry.osgi.tests/src/berryWeakPointerTest.cpp
+++ b/BlueBerry/Testing/org.blueberry.osgi.tests/src/berryWeakPointerTest.cpp
@@ -1,102 +1,102 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 <berryMessage.h>
#include <berryObject.h>
#include <berrySmartPointer.h>
#include <berryWeakPointer.h>
//#include <cstdlib>
#include "berryWeakPointerTest.h"
#include <CppUnit/TestSuite.h>
#include <CppUnit/TestCaller.h>
namespace berry
{
struct TestObject: public Object
{
/** creating a test object in order to test the weakpointer functions */
TestObject()
{ }
};
WeakPointerTest::WeakPointerTest(const std::string& testName) :
TestCase(testName)
{
}
CppUnit::Test* WeakPointerTest::Suite()
{
CppUnit::TestSuite* suite = new CppUnit::TestSuite("WeakPointerTest");
CppUnit_addTest(suite, WeakPointerTest, TestReferenceCounting);
CppUnit_addTest(suite, WeakPointerTest, TestConstructorAndLock);
CppUnit_addTest(suite, WeakPointerTest, TestOperators);
return suite;
}
void WeakPointerTest::TestReferenceCounting()
{
SmartPointer<TestObject> ptr_smart(new TestObject());
WeakPointer<TestObject> ptr_weak(ptr_smart);
assertEqual(1, ptr_smart->GetReferenceCount());
/* Testing the Object reference counter after returning a smartpointer
* to an object, Reference counter should be increased to 2 */
SmartPointer<TestObject> ptr_smart2(ptr_weak);
assertEqual(2, ptr_smart->GetReferenceCount());
}
void WeakPointerTest::TestConstructorAndLock()
{
SmartPointer<TestObject>* ptr_smart = new SmartPointer<TestObject> (
new TestObject);
WeakPointer<TestObject> ptr_weak(*ptr_smart);
WeakPointer<TestObject> ptr_weak2(ptr_weak);
{
SmartPointer<TestObject> ptr_smart1(ptr_weak);
SmartPointer<TestObject> ptr_smart2(ptr_weak2);
assertEqual(ptr_smart1.GetPointer(), ptr_smart2.GetPointer());
}
assertEqual(1, (*ptr_smart)->GetReferenceCount());
delete ptr_smart;
assert(ptr_weak2.Lock() == 0);
}
void WeakPointerTest::TestOperators()
{
SmartPointer<TestObject> ptr_smart(new TestObject);
SmartPointer<TestObject> ptr_smart2(new TestObject);
{
WeakPointer<TestObject> ptr_weak(ptr_smart);
WeakPointer<TestObject> ptr_weak2(ptr_smart2);
ptr_weak = ptr_weak2;
SmartPointer<TestObject> ptr_smart3(ptr_weak2);
SmartPointer<TestObject> ptr_smart4(ptr_weak);
assertEqual(ptr_smart3.GetPointer(), ptr_smart4.GetPointer());
}
}
}
diff --git a/BlueBerry/Testing/org.blueberry.osgi.tests/src/berryWeakPointerTest.h b/BlueBerry/Testing/org.blueberry.osgi.tests/src/berryWeakPointerTest.h
index c02cab1a11..e8025877f3 100644
--- a/BlueBerry/Testing/org.blueberry.osgi.tests/src/berryWeakPointerTest.h
+++ b/BlueBerry/Testing/org.blueberry.osgi.tests/src/berryWeakPointerTest.h
@@ -1,40 +1,40 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYWEAKPOINTERTEST_H_
#define BERRYWEAKPOINTERTEST_H_
#include <berryTestCase.h>
namespace berry {
class WeakPointerTest : public TestCase
{
public:
WeakPointerTest(const std::string& testName);
static CppUnit::Test* Suite();
void TestReferenceCounting();
void TestConstructorAndLock();
void TestOperators();
};
}
#endif /* BERRYWEAKPOINTERTEST_H_ */
diff --git a/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryIPageLayoutTest.cpp b/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryIPageLayoutTest.cpp
index 78801fd335..3c6a755d0c 100644
--- a/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryIPageLayoutTest.cpp
+++ b/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryIPageLayoutTest.cpp
@@ -1,52 +1,52 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryIPageLayoutTest.h"
#include <CppUnit/TestSuite.h>
#include <CppUnit/TestCaller.h>
#include <berryEmptyPerspective.h>
namespace berry
{
IPageLayoutTest::IPageLayoutTest(const std::string& testName) :
UITestCase(testName)
{
}
CppUnit::Test* IPageLayoutTest::Suite()
{
CppUnit::TestSuite* suite = new CppUnit::TestSuite("IPageLayoutTest");
CppUnit_addTest(suite, IPageLayoutTest, TestGetDescriptor);
return suite;
}
void IPageLayoutTest::TestGetDescriptor()
{
this->IgnoreLeakingObjects();
//this->LeakDetailsOn();
EmptyPerspective::SetLastPerspective("");
OpenTestWindow(EmptyPerspective::PERSP_ID);
assertEqual(EmptyPerspective::PERSP_ID, EmptyPerspective::GetLastPerspective());
}
}
diff --git a/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryIPageLayoutTest.h b/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryIPageLayoutTest.h
index 66ab565ac6..3ab51c3b3d 100644
--- a/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryIPageLayoutTest.h
+++ b/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryIPageLayoutTest.h
@@ -1,48 +1,48 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIPAGELAYOUTTEST_H_
#define BERRYIPAGELAYOUTTEST_H_
#include <berryUITestCase.h>
#include <CppUnit/TestCaller.h>
namespace berry {
/**
* Test cases for the <code>IPageLayout</code> API.
*
* @since 3.2
*/
class IPageLayoutTest : public UITestCase {
public:
friend class CppUnit::TestCaller<IPageLayoutTest>;
IPageLayoutTest(const std::string& testName);
static CppUnit::Test* Suite();
void TestGetDescriptor();
};
}
#endif /* BERRYIPAGELAYOUTTEST_H_ */
diff --git a/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryIViewPartTest.cpp b/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryIViewPartTest.cpp
index 2d7583b571..269df49b3f 100644
--- a/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryIViewPartTest.cpp
+++ b/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryIViewPartTest.cpp
@@ -1,94 +1,94 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryIViewPartTest.h"
#include "berrySaveableMockViewPart.h"
#include <berryDebugBreakpointManager.h>
#include <CppUnit/TestSuite.h>
namespace berry
{
IViewPartTest::IViewPartTest(const std::string& testName) :
IWorkbenchPartTest(testName)
{
}
CppUnit::Test* IViewPartTest::Suite()
{
CppUnit::TestSuite* suite = new CppUnit::TestSuite("IViewPartTest");
CppUnit_addTest(suite, IViewPartTest, TestOpenAndCloseSaveNotNeeded);
CppUnit_addTest(suite, IViewPartTest, TestOpenAndClose);
CppUnit_addTest(suite, IViewPartTest, TestOpenAndWindowClose);
return suite;
}
void IViewPartTest::TestOpenAndCloseSaveNotNeeded()
{
this->IgnoreLeakingObjects();
//this->LeakDetailsOn();
CallHistory::Pointer history;
{
// Open a part.
SaveableMockViewPart::Pointer part = fPage->ShowView(
SaveableMockViewPart::ID).Cast<SaveableMockViewPart> ();
part->SetDirty(true);
part->SetSaveNeeded(false);
ClosePart(fPage, part);
history = part->GetCallHistory();
}
// TODO: This verifies the 3.0 disposal order. However, there may be a bug here.
// That is, it may be necessary to change this and dispose the contribution items
// after the view's dispose method in order to ensure that the site is never returning
// a disposed contribution item. See bug 94457 for details.
std::vector<std::string> callOrder;
callOrder.push_back("SetInitializationData");
callOrder.push_back("Init");
callOrder.push_back("CreatePartControl");
callOrder.push_back("SetFocus");
callOrder.push_back("IsSaveOnCloseNeeded");
callOrder.push_back("WidgetDisposed");
//callOrder.push_back("ToolbarContributionItemWidgetDisposed");
//callOrder.push_back("ToolbarContributionItemDisposed");
callOrder.push_back("PartDestructor");
assert(history->VerifyOrder(callOrder));
// TODO enable assert when saveable support is complete
//assert(history->Contains("DoSave"));
}
MockWorkbenchPart::Pointer IViewPartTest::OpenPart(IWorkbenchPage::Pointer page)
{
return page->ShowView(MockViewPart::ID).Cast<MockWorkbenchPart> ();
}
void IViewPartTest::ClosePart(IWorkbenchPage::Pointer page,
MockWorkbenchPart::Pointer part)
{
page->HideView(part.Cast<IViewPart> ());
}
}
diff --git a/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryIViewPartTest.h b/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryIViewPartTest.h
index 78505a4e44..81a153937b 100644
--- a/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryIViewPartTest.h
+++ b/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryIViewPartTest.h
@@ -1,72 +1,72 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIVIEWPARTTEST_H_
#define BERRYIVIEWPARTTEST_H_
#include "berryIWorkbenchPartTest.h"
#include <CppUnit/TestCaller.h>
namespace berry
{
/**
* This is a test for IViewPart. Since IViewPart is an
* interface this test verifies the IViewPart lifecycle rather
* than the implementation.
*/
class IViewPartTest: public IWorkbenchPartTest
{
public:
friend class CppUnit::TestCaller<IViewPartTest>;
/**
* Constructor for IViewPartTest
*/
IViewPartTest(const std::string& testName);
static CppUnit::Test* Suite();
/**
* Tests that the view is closed without saving if isSaveOnCloseNeeded()
* returns false. This also tests some disposal behaviors specific to
* views: namely, that the contribution items are disposed in the correct
* order with respect to the disposal of the view.
*
* @see ISaveablePart#isSaveOnCloseNeeded()
*/
void TestOpenAndCloseSaveNotNeeded();
protected:
/**
* @see IWorkbenchPartTest#openPart(IWorkbenchPage)
*/
MockWorkbenchPart::Pointer OpenPart(IWorkbenchPage::Pointer page);
/**
* @see IWorkbenchPartTest#closePart(IWorkbenchPage, MockWorkbenchPart)
*/
void ClosePart(IWorkbenchPage::Pointer page, MockWorkbenchPart::Pointer part);
};
}
#endif /* BERRYIVIEWPARTTEST_H_ */
diff --git a/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryIWorkbenchPartTest.cpp b/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryIWorkbenchPartTest.cpp
index 0d1167ba3a..2846bff841 100644
--- a/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryIWorkbenchPartTest.cpp
+++ b/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryIWorkbenchPartTest.cpp
@@ -1,104 +1,104 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryIWorkbenchPartTest.h"
namespace berry
{
void IWorkbenchPartTest::DoSetUp()
{
UITestCase::DoSetUp();
fWindow = OpenTestWindow();
fPage = fWindow->GetActivePage();
}
void IWorkbenchPartTest::DoTearDown()
{
fPage = 0;
fWindow = 0;
UITestCase::DoTearDown();
}
IWorkbenchPartTest::IWorkbenchPartTest(const std::string& testName) :
UITestCase(testName)
{
}
void IWorkbenchPartTest::TestOpenAndClose()
{
this->IgnoreLeakingObjects();
CallHistory::Pointer history;
std::vector<std::string> callOrder;
{
// Open a part.
MockWorkbenchPart::Pointer part = OpenPart(fPage);
assert(part->IsSiteInitialized());
history = part->GetCallHistory();
callOrder.push_back("SetInitializationData");
callOrder.push_back("Init");
callOrder.push_back("CreatePartControl");
callOrder.push_back("SetFocus");
assert(history->VerifyOrder(callOrder));
// Close the part.
ClosePart(fPage, part);
}
callOrder.push_back("WidgetDisposed");
callOrder.push_back("PartDestructor");
assert(history->VerifyOrder(callOrder));
}
void IWorkbenchPartTest::TestOpenAndWindowClose()
{
this->IgnoreLeakingObjects();
CallHistory::Pointer history;
std::vector<std::string> callOrder;
{
// Open a new window
IWorkbenchWindow::Pointer newWindow = OpenTestWindow();
// Open a part.
MockWorkbenchPart::Pointer part = OpenPart(newWindow->GetActivePage());
assert(part->IsSiteInitialized());
history = part->GetCallHistory();
callOrder.push_back("SetInitializationData");
callOrder.push_back("Init");
callOrder.push_back("CreatePartControl");
callOrder.push_back("SetFocus");
assert(history->VerifyOrder(callOrder));
// Close the window.
newWindow->Close();
}
// The Qt widget for the window is deleted
// asynchronously, so the "WidgetDisposed"
// call may come after the part destructor
//callOrder.push_back("WidgetDisposed");
callOrder.push_back("PartDestructor");
assert(history->VerifyOrder(callOrder));
}
}
diff --git a/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryIWorkbenchPartTest.h b/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryIWorkbenchPartTest.h
index 5306da3c7b..247606e246 100644
--- a/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryIWorkbenchPartTest.h
+++ b/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryIWorkbenchPartTest.h
@@ -1,69 +1,69 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYIWORKBENCHPARTTEST_H_
#define BERRYIWORKBENCHPARTTEST_H_
#include <berryUITestCase.h>
#include <berryIWorkbenchWindow.h>
#include <berryIWorkbenchPage.h>
#include "berryMockWorkbenchPart.h"
namespace berry {
/**
* This is a test for IWorkbenchPart. Since IWorkbenchPart is an
* interface this test verifies the IWorkbenchPart lifecycle rather
* than the implementation.
*/
class IWorkbenchPartTest : public UITestCase {
protected:
IWorkbenchWindow::Pointer fWindow;
IWorkbenchPage::Pointer fPage;
void DoSetUp();
void DoTearDown();
/**
* Opens a part. Subclasses should override
*/
virtual MockWorkbenchPart::Pointer OpenPart(IWorkbenchPage::Pointer page) = 0;
/**
* Closes a part. Subclasses should override
*/
virtual void ClosePart(IWorkbenchPage::Pointer page, MockWorkbenchPart::Pointer part) = 0;
public:
/**
* Constructor for IActionDelegateTest
*/
IWorkbenchPartTest(const std::string& testName);
void TestOpenAndClose();
void TestOpenAndWindowClose();
};
}
#endif /* BERRYIWORKBENCHPARTTEST_H_ */
diff --git a/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryMockSelectionProvider.cpp b/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryMockSelectionProvider.cpp
index ab7ffcb672..ef05b77d65 100644
--- a/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryMockSelectionProvider.cpp
+++ b/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryMockSelectionProvider.cpp
@@ -1,103 +1,103 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryMockSelectionProvider.h"
namespace berry
{
struct EmptyStructuredSelection : public IStructuredSelection
{
EmptyStructuredSelection()
: elements(new ContainerType())
{}
Object::Pointer GetFirstElement() const
{
return Object::Pointer(0);
}
iterator Begin() const
{
return elements->begin();
}
iterator End() const
{
return elements->end();
}
int Size() const
{
return elements->size();
}
bool IsEmpty() const
{
return true;
}
ContainerType::Pointer ToVector() const
{
return elements;
}
private:
ContainerType::Pointer elements;
};
MockSelectionProvider::MockSelectionProvider()
: emptySelection(new EmptyStructuredSelection())
{
}
void MockSelectionProvider::FireSelection()
{
SelectionChangedEvent::Pointer event(new SelectionChangedEvent(
ISelectionProvider::Pointer(this), emptySelection));
FireSelection(event);
}
void MockSelectionProvider::FireSelection(SelectionChangedEvent::Pointer event)
{
listeners.selectionChanged(event);
}
void MockSelectionProvider::AddSelectionChangedListener(
ISelectionChangedListener::Pointer listener)
{
listeners.AddListener(listener);
}
ISelection::ConstPointer MockSelectionProvider::GetSelection() const
{
return emptySelection;
}
void MockSelectionProvider::RemoveSelectionChangedListener(
ISelectionChangedListener::Pointer listener)
{
listeners.RemoveListener(listener);
}
void MockSelectionProvider::SetSelection(ISelection::Pointer /*selection*/)
{
}
}
diff --git a/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryMockSelectionProvider.h b/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryMockSelectionProvider.h
index 6fe7bb225a..790d858b77 100644
--- a/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryMockSelectionProvider.h
+++ b/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryMockSelectionProvider.h
@@ -1,74 +1,74 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYMOCKSELECTIONPROVIDER_H_
#define BERRYMOCKSELECTIONPROVIDER_H_
#include <berryISelectionProvider.h>
#include <berryIStructuredSelection.h>
namespace berry
{
class MockSelectionProvider: public ISelectionProvider
{
private:
ISelectionChangedListener::Events listeners;
IStructuredSelection::Pointer emptySelection;
public:
berryObjectMacro(MockSelectionProvider)
MockSelectionProvider();
/**
* Fires out a selection to all listeners.
*/
void FireSelection();
/**
* Fires out a selection to all listeners.
*/
void FireSelection(SelectionChangedEvent::Pointer event);
/**
* @see ISelectionProvider#addSelectionChangedListener(ISelectionChangedListener)
*/
void AddSelectionChangedListener(ISelectionChangedListener::Pointer listener);
/**
* @see ISelectionProvider#getSelection()
*/
ISelection::ConstPointer GetSelection() const;
/**
* @see ISelectionProvider#removeSelectionChangedListener(ISelectionChangedListener)
*/
void RemoveSelectionChangedListener(
ISelectionChangedListener::Pointer listener);
/**
* @see ISelectionProvider#setSelection(ISelection)
*/
void SetSelection(ISelection::Pointer /*selection*/);
};
}
#endif /* BERRYMOCKSELECTIONPROVIDER_H_ */
diff --git a/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryMockViewPart.cpp b/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryMockViewPart.cpp
index dea6186851..c08efc1eac 100644
--- a/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryMockViewPart.cpp
+++ b/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryMockViewPart.cpp
@@ -1,150 +1,150 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryMockViewPart.h"
namespace berry
{
const std::string MockViewPart::ID = "org.blueberry.ui.tests.api.MockViewPart";
const std::string MockViewPart::ID2 = MockViewPart::ID + "2";
const std::string MockViewPart::ID3 = MockViewPart::ID + "3";
const std::string MockViewPart::ID4 = MockViewPart::ID + "4";
const std::string MockViewPart::IDMULT = MockViewPart::ID + "Mult";
const std::string MockViewPart::NAME = "Mock View 1";
MockViewPart::MockViewPart()
{
}
MockViewPart::MockViewPart(const MockViewPart& other)
{
Q_UNUSED(other)
throw std::runtime_error("Copy constructor not implemented");
}
IViewSite::Pointer MockViewPart::GetViewSite()
{
return GetSite().Cast<IViewSite> ();
}
void MockViewPart::Init(IViewSite::Pointer site, IMemento::Pointer /*memento*/)
throw (PartInitException)
{
SetSite(site);
callTrace->Add("Init");
SetSiteInitialized();
//AddToolbarContributionItem();
}
void MockViewPart::CreatePartControl(void* parent)
{
MockWorkbenchPart::CreatePartControl(parent);
// Button addAction = new Button(parent, SWT.PUSH);
// addAction.setText("Add Action to Tool Bar");
// addAction.addSelectionListener(new SelectionAdapter() {
// public void widgetSelected(SelectionEvent e) {
// IActionBars bars = getViewSite().getActionBars();
// bars.getToolBarManager().add(new DummyAction());
// bars.updateActionBars();
// }
// });
//
// Button removeAction = new Button(parent, SWT.PUSH);
// removeAction.setText("Remove Action from Tool Bar");
// removeAction.addSelectionListener(new SelectionAdapter() {
// public void widgetSelected(SelectionEvent e) {
// IActionBars bars = getViewSite().getActionBars();
// IToolBarManager tbm = bars.getToolBarManager();
// IContributionItem[] items = tbm.getItems();
// if (items.length > 0) {
// IContributionItem item = items[items.length-1];
// if (item instanceof ActionContributionItem) {
// if (((ActionContributionItem) item).getAction() instanceof DummyAction) {
// tbm.remove(item);
// bars.updateActionBars();
// }
// }
// }
// }
// });
}
MockViewPart::~MockViewPart()
{
// // Test for bug 94457: The contribution items must still be in the toolbar manager at the
// // time the part is disposed. (Changing this behavior would be a breaking change for some
// // clients).
// Assert.assertTrue(
// "Contribution items should not be removed from the site until after the part is disposed",
// getViewSite().getActionBars().getToolBarManager().find(
// toolbarItem.getId()) == toolbarItem);
}
void MockViewPart::ToolbarContributionItemWidgetDisposed()
{
callTrace->Add("ToolbarContributionItemWidgetDisposed");
}
void MockViewPart::ToolbarContributionItemDisposed()
{
callTrace->Add("ToolbarContributionItemDisposed");
}
void MockViewPart::SaveState(IMemento::Pointer /*memento*/)
{
// do nothing
}
IWorkbenchPartSite::Pointer MockViewPart::GetSite() const
{
return MockWorkbenchPart::GetSite();
}
std::string MockViewPart::GetPartName() const
{
return MockWorkbenchPart::GetPartName();
}
std::string MockViewPart::GetContentDescription() const
{
return MockWorkbenchPart::GetContentDescription();
}
std::string MockViewPart::GetTitleToolTip() const
{
return MockWorkbenchPart::GetTitleToolTip();
}
std::string MockViewPart::GetPartProperty(const std::string& key) const
{
return MockWorkbenchPart::GetPartProperty(key);
}
void MockViewPart::SetPartProperty(const std::string& key,
const std::string& value)
{
MockWorkbenchPart::SetPartProperty(key, value);
}
const std::map<std::string, std::string>& MockViewPart::GetPartProperties() const
{
return MockWorkbenchPart::GetPartProperties();
}
}
diff --git a/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryMockViewPart.h b/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryMockViewPart.h
index dd84f23f68..7ab3def951 100644
--- a/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryMockViewPart.h
+++ b/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryMockViewPart.h
@@ -1,154 +1,154 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYMOCKVIEWPART_H_
#define BERRYMOCKVIEWPART_H_
#include "berryMockWorkbenchPart.h"
#include <berryIViewPart.h>
#include <berryUIException.h>
namespace berry
{
class MockViewPart: public QObject, public MockWorkbenchPart, public IViewPart
{
Q_OBJECT
Q_INTERFACES(berry::IExecutableExtension berry::IViewPart)
public:
berryObjectMacro(MockViewPart)
static const std::string ID; // = "org.blueberry.ui.tests.api.MockViewPart";
static const std::string ID2; // = ID + "2";
static const std::string ID3; // = ID + "3";
static const std::string ID4; // = ID + "4";
static const std::string IDMULT; // = ID + "Mult";
static const std::string NAME; // = "Mock View 1";
MockViewPart();
MockViewPart(const MockViewPart& other);
/**
* @see IViewPart#getViewSite()
*/
IViewSite::Pointer GetViewSite();
/**
* @see IViewPart#Init(IViewSite, IMemento)
*/
void Init(IViewSite::Pointer site, IMemento::Pointer /*memento*/)
throw (PartInitException);
/* (non-Javadoc)
* @see org.eclipse.ui.tests.api.MockWorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
void CreatePartControl(void* parent);
/* (non-Javadoc)
* @see org.eclipse.ui.tests.api.MockPart#dispose()
*/
~MockViewPart();
void ToolbarContributionItemWidgetDisposed();
void ToolbarContributionItemDisposed();
/**
* @see IViewPart#saveState(IMemento)
*/
void SaveState(IMemento::Pointer /*memento*/);
/**
* @see IWorkbenchPart#GetSite()
*/
IWorkbenchPartSite::Pointer GetSite() const;
/**
* @see IWorkbenchPart#GetTitle()
*/
std::string GetPartName() const;
std::string GetContentDescription() const;
/**
* @see IWorkbenchPart#GetTitleToolTip()
*/
std::string GetTitleToolTip() const;
std::string GetPartProperty(const std::string& key) const;
void SetPartProperty(const std::string& key, const std::string& value);
const std::map<std::string, std::string>& GetPartProperties() const;
private:
// ContributionItem toolbarItem = new ContributionItem("someId") {
//
// private DisposeListener disposeListener = new DisposeListener() {
// public void widgetDisposed(DisposeEvent e) {
// toolbarContributionItemWidgetDisposed();
// }
//
// public void fill(ToolBar parent, int index) {
// super.fill(parent, index);
//
// ToolItem item = new ToolItem(parent, index);
//
// item.addDisposeListener(disposeListener);
// item.setImage(WorkbenchImages.getImage(ISharedImages.IMG_DEF_VIEW));
// }
//
// public void dispose() {
// toolbarContributionItemDisposed();
// super.dispose();
// }
// };
//
// class DummyAction extends Action {
// public DummyAction() {
// setText("Monkey");
// setImageDescriptor(getViewSite().getWorkbenchWindow()
// .getWorkbench().getSharedImages()
// .getImageDescriptor(
// ISharedImages.IMG_TOOL_DELETE));
// }
// };
//
//
//
// void AddToolbarContributionItem() {
// getViewSite().getActionBars().getToolBarManager().add(toolbarItem);
// }
protected:
/* (non-Javadoc)
* @see org.eclipse.ui.tests.api.MockWorkbenchPart#getActionBars()
*/
// IActionBars GetActionBars() {
// return getViewSite().getActionBars();
// }
};
}
#endif /* BERRYMOCKVIEWPART_H_ */
diff --git a/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryMockWorkbenchPart.cpp b/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryMockWorkbenchPart.cpp
index fdd9ff5ac1..2e93bb467b 100644
--- a/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryMockWorkbenchPart.cpp
+++ b/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryMockWorkbenchPart.cpp
@@ -1,205 +1,205 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryMockWorkbenchPart.h"
#include <berryImageDescriptor.h>
#include <berryGuiWidgetsTweaklet.h>
#include <berryObjects.h>
#include <berryIWorkbenchPage.h>
#include <berryIWorkbenchWindow.h>
#include <berryIWorkbenchPartConstants.h>
namespace berry
{
MockWorkbenchPart::MockWorkbenchPart()
: titleImage(0), parentWidget(0),
disposeListener(new GuiTk::ControlDestroyedAdapter<MockWorkbenchPart>(this, &MockWorkbenchPart::ControlDestroyed))
, siteState(false)
{
callTrace = new CallHistory();
selectionProvider = new MockSelectionProvider();
}
void MockWorkbenchPart::SetSite(IWorkbenchPartSite::Pointer site)
{
this->site = site;
site->SetSelectionProvider(selectionProvider);
}
IWorkbenchPartSite::Pointer MockWorkbenchPart::GetSite() const
{
return site;
}
std::string MockWorkbenchPart::GetPartName() const
{
return title;
}
std::string MockWorkbenchPart::GetContentDescription() const
{
return title;
}
std::string MockWorkbenchPart::GetTitleToolTip() const
{
return title;
}
CallHistory::Pointer MockWorkbenchPart::GetCallHistory() const
{
return callTrace;
}
ISelectionProvider::Pointer MockWorkbenchPart::GetSelectionProvider()
{
return selectionProvider;
}
void MockWorkbenchPart::SetInitializationData(
IConfigurationElement::Pointer config, const std::string& /*propertyName*/,
Object::Pointer data)
{
callTrace->Add("SetInitializationData");
this->config = config;
this->data = data;
// Icon.
std::string strIcon;
if (config->GetAttribute("icon", strIcon))
{
ImageDescriptor::Pointer imageDesc = ImageDescriptor::CreateFromFile(
strIcon, config->GetContributor());
titleImage = imageDesc->CreateImage();
}
config->GetAttribute("name", title);
}
void MockWorkbenchPart::ControlDestroyed(GuiTk::ControlEvent::Pointer)
{
callTrace->Add("WidgetDisposed");
parentWidget = 0;
}
void MockWorkbenchPart::AddPropertyListener(
IPropertyChangeListener::Pointer listener)
{
propertyEvent.AddListener(listener);
}
void MockWorkbenchPart::RemovePropertyListener(
IPropertyChangeListener::Pointer listener)
{
propertyEvent.RemoveListener(listener);
}
void MockWorkbenchPart::CreatePartControl(void* parent)
{
callTrace->Add("CreatePartControl");
this->parentWidget = parent;
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->AddControlListener(parent,
disposeListener);
}
MockWorkbenchPart::~MockWorkbenchPart()
{
callTrace->Add("PartDestructor");
if (parentWidget)
{
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->RemoveControlListener(parentWidget,
disposeListener);
}
}
void* MockWorkbenchPart::GetTitleImage() const
{
return titleImage;
}
void MockWorkbenchPart::SetFocus()
{
callTrace->Add("SetFocus");
}
void MockWorkbenchPart::FireSelection()
{
selectionProvider->FireSelection();
}
bool MockWorkbenchPart::IsSiteInitialized()
{
return siteState;
}
void MockWorkbenchPart::SetSiteInitialized()
{
SetSiteInitialized(
// GetSite()->GetKeyBindingService() != 0 &&
(GetSite()->GetPage() != 0) && (GetSite()->GetSelectionProvider() != 0)
&& (GetSite()->GetWorkbenchWindow() != 0) // &&
// TestActionBars(GetActionBars())
);
}
IConfigurationElement::Pointer MockWorkbenchPart::GetConfig()
{
return config;
}
Object::Pointer MockWorkbenchPart::GetData()
{
return data;
}
void MockWorkbenchPart::FirePropertyChange(int propertyId)
{
ObjectInt::Pointer value(new ObjectInt(propertyId));
PropertyChangeEvent::Pointer event(new PropertyChangeEvent(Object::Pointer(
this), IWorkbenchPartConstants::INTEGER_PROPERTY, value, value));
propertyEvent.propertyChange(event);
}
void MockWorkbenchPart::SetSiteInitialized(bool initialized)
{
siteState = initialized;
}
std::string MockWorkbenchPart::GetPartProperty(const std::string& key) const
{
std::map<std::string, std::string>::const_iterator i = properties.find(key);
if (i != properties.end()) return i->second;
return "";
}
void MockWorkbenchPart::SetPartProperty(const std::string& key,
const std::string& value)
{
properties[key] = value;
}
const std::map<std::string, std::string>& MockWorkbenchPart::GetPartProperties() const
{
return properties;
}
}
diff --git a/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryMockWorkbenchPart.h b/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryMockWorkbenchPart.h
index 1a25a5a248..ba7f87a18b 100644
--- a/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryMockWorkbenchPart.h
+++ b/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryMockWorkbenchPart.h
@@ -1,195 +1,195 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYWORKBENCHMOCKPART_H_
#define BERRYWORKBENCHMOCKPART_H_
#include <util/berryCallHistory.h>
#include "berryMockSelectionProvider.h"
#include <berryIWorkbenchPart.h>
#include <berryIWorkbenchPartSite.h>
#include <berryIExecutableExtension.h>
#include <berryIConfigurationElement.h>
#include <berryIPropertyChangeListener.h>
#include <berryGuiTkIControlListener.h>
namespace berry
{
/**
* Base class for mock intro and workbench parts.
*
* @since 3.0
*/
class MockWorkbenchPart: public virtual IWorkbenchPart, public IExecutableExtension
{
public:
berryObjectMacro(MockWorkbenchPart)
MockWorkbenchPart();
void SetSite(IWorkbenchPartSite::Pointer site);
IWorkbenchPartSite::Pointer GetSite() const;
/**
* @see IWorkbenchPart#GetPartName()
*/
std::string GetPartName() const;
/**
* @see IWorkbenchPart#GetContentDescription()
*/
std::string GetContentDescription() const;
/**
* @see IWorkbenchPart#getTitleToolTip()
*/
std::string GetTitleToolTip() const;
CallHistory::Pointer GetCallHistory() const;
ISelectionProvider::Pointer GetSelectionProvider();
void SetInitializationData(IConfigurationElement::Pointer config,
const std::string& /*propertyName*/, Object::Pointer data);
// This isn't actually part of the part API, but we call this method from a dispose listener
// in order to mark the point in time at which the widgets are disposed
void ControlDestroyed(GuiTk::ControlEvent::Pointer e);
/**
* @see IWorkbenchPart#addPropertyListener(IPropertyListener)
*/
void AddPropertyListener(IPropertyChangeListener::Pointer listener);
/**
* @see IWorkbenchPart#removePropertyListener(IPropertyListener)
*/
void RemovePropertyListener(IPropertyChangeListener::Pointer listener);
std::string GetPartProperty(const std::string& key) const;
void SetPartProperty(const std::string& key, const std::string& value);
const std::map<std::string, std::string>& GetPartProperties() const;
/**
* @see IWorkbenchPart#createPartControl(Composite)
*/
void CreatePartControl(void* parent);
/**
* @see IWorkbenchPart#dispose()
*/
~MockWorkbenchPart();
/**
* @see IWorkbenchPart#getTitleImage()
*/
void* GetTitleImage() const;
/**
* @see IWorkbenchPart#setFocus()
*/
void SetFocus();
// /**
// * @see IAdaptable#getAdapter(Class)
// */
// Object::Pointer GetAdapter(Class arg0) {
// return null;
// }
/**
* Fires a selection out.
*/
void FireSelection();
/**
* Gets whether the site was properly initialized in the init method.
*/
bool IsSiteInitialized();
protected:
CallHistory::Pointer callTrace;
MockSelectionProvider::Pointer selectionProvider;
// IActionBars GetActionBars() = 0;
void SetSiteInitialized();
IConfigurationElement::Pointer GetConfig();
Object::Pointer GetData();
/**
* Fires a property change event.
*/
void FirePropertyChange(int propertyId);
/**
* Sets whether the site was properly initialized in the init method.
*/
void SetSiteInitialized(bool initialized);
private:
IConfigurationElement::Pointer config;
Object::Pointer data;
void* titleImage;
void* parentWidget;
IWorkbenchPartSite::Pointer site;
std::string title;
IPropertyChangeListener::Events propertyEvent;
GuiTk::IControlListener::Pointer disposeListener;
/**
* boolean to declare whether the site was properly initialized in the init method.
*/
bool siteState;
// /**
// * @param actionBars
// * @return
// */
// bool TestActionBars(IActionBars bars) {
// return bars != null && bars.getMenuManager() != null
// && bars.getToolBarManager() != null
// && bars.getStatusLineManager() != null;
//
// }
std::map<std::string, std::string> properties;
};
}
#endif /* BERRYWORKBENCHMOCKPART_H_ */
diff --git a/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berrySaveableMockViewPart.cpp b/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berrySaveableMockViewPart.cpp
index a8b4a40c89..4dcdce29ab 100644
--- a/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berrySaveableMockViewPart.cpp
+++ b/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berrySaveableMockViewPart.cpp
@@ -1,113 +1,113 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berrySaveableMockViewPart.h"
namespace berry
{
const std::string SaveableMockViewPart::ID =
"org.blueberry.ui.tests.api.SaveableMockViewPart";
SaveableMockViewPart::SaveableMockViewPart() :
isDirty(false), saveAsAllowed(false), saveNeeded(true)
{
}
SaveableMockViewPart::SaveableMockViewPart(const SaveableMockViewPart& other)
{
Q_UNUSED(other)
throw std::runtime_error("Copy constructor not implemented");
}
void SaveableMockViewPart::CreatePartControl(void* parent)
{
MockViewPart::CreatePartControl(parent);
// final Button dirtyToggle = new Button(parent, SWT.CHECK);
// dirtyToggle.setText("Dirty");
// dirtyToggle.addSelectionListener(new SelectionAdapter() {
// public void widgetSelected(SelectionEvent e) {
// setDirty(dirtyToggle.getSelection());
// }
// });
// dirtyToggle.setSelection(isDirty());
//
// final Button saveNeededToggle = new Button(parent, SWT.CHECK);
// saveNeededToggle.setText("Save on close");
// saveNeededToggle.addSelectionListener(new SelectionAdapter() {
// public void widgetSelected(SelectionEvent e) {
// setSaveNeeded(saveNeededToggle.getSelection());
// }
// });
// saveNeededToggle.setSelection(saveNeeded);
//
// final Button saveAsToggle = new Button(parent, SWT.CHECK);
// saveAsToggle.setText("Save as allowed");
// saveAsToggle.addSelectionListener(new SelectionAdapter() {
// public void widgetSelected(SelectionEvent e) {
// setSaveAsAllowed(saveAsToggle.getSelection());
// }
// });
// saveAsToggle.setSelection(saveAsAllowed);
}
void SaveableMockViewPart::DoSave(/*IProgressMonitor monitor*/)
{
callTrace->Add("DoSave");
}
void SaveableMockViewPart::DoSaveAs()
{
callTrace->Add("DoSaveAs");
}
bool SaveableMockViewPart::IsDirty() const
{
callTrace->Add("IsDirty");
return isDirty;
}
bool SaveableMockViewPart::IsSaveAsAllowed() const
{
callTrace->Add("IsSaveAsAllowed");
return saveAsAllowed;
}
bool SaveableMockViewPart::IsSaveOnCloseNeeded() const
{
callTrace->Add("IsSaveOnCloseNeeded");
return saveNeeded;
}
void SaveableMockViewPart::SetDirty(bool isDirty)
{
this->isDirty = isDirty;
FirePropertyChange(ISaveablePart::PROP_DIRTY);
}
void SaveableMockViewPart::SetSaveAsAllowed(bool isSaveAsAllowed)
{
this->saveAsAllowed = isSaveAsAllowed;
}
void SaveableMockViewPart::SetSaveNeeded(bool isSaveOnCloseNeeded)
{
this->saveNeeded = isSaveOnCloseNeeded;
}
}
diff --git a/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berrySaveableMockViewPart.h b/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berrySaveableMockViewPart.h
index c4a55a2fd5..50ae5fac99 100644
--- a/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berrySaveableMockViewPart.h
+++ b/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berrySaveableMockViewPart.h
@@ -1,92 +1,92 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYSAVEABLEMOCKVIEWPART_H_
#define BERRYSAVEABLEMOCKVIEWPART_H_
#include "berryMockViewPart.h"
#include <berryISaveablePart.h>
namespace berry
{
/**
* Mock view part that implements ISaveablePart.
* Used for testing hideView and other view lifecycle on saveable views.
*
* @since 3.0.1
*/
class SaveableMockViewPart: public MockViewPart, public ISaveablePart
{
Q_OBJECT
Q_INTERFACES(berry::ISaveablePart)
public:
berryObjectMacro(SaveableMockViewPart)
static const std::string ID; // = "org.blueberry.ui.tests.api.SaveableMockViewPart";
SaveableMockViewPart();
SaveableMockViewPart(const SaveableMockViewPart& other);
void CreatePartControl(void* parent);
/* (non-Javadoc)
* @see org.eclipse.ui.ISaveablePart#doSave(org.eclipse.core.runtime.IProgressMonitor)
*/
void DoSave(/*IProgressMonitor monitor*/);
/* (non-Javadoc)
* @see org.eclipse.ui.ISaveablePart#doSaveAs()
*/
void DoSaveAs();
/* (non-Javadoc)
* @see org.eclipse.ui.ISaveablePart#isDirty()
*/
bool IsDirty() const;
/* (non-Javadoc)
* @see org.eclipse.ui.ISaveablePart#isSaveAsAllowed()
*/
bool IsSaveAsAllowed() const;
/* (non-Javadoc)
* @see org.eclipse.ui.ISaveablePart#isSaveOnCloseNeeded()
*/
bool IsSaveOnCloseNeeded() const;
void SetDirty(bool isDirty);
void SetSaveAsAllowed(bool isSaveAsAllowed);
void SetSaveNeeded(bool isSaveOnCloseNeeded);
private:
bool isDirty;
bool saveAsAllowed;
bool saveNeeded;
};
}
#endif /* BERRYSAVEABLEMOCKVIEWPART_H_ */
diff --git a/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryUiApiTestSuite.cpp b/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryUiApiTestSuite.cpp
index b7bc32d87f..6e29e45715 100644
--- a/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryUiApiTestSuite.cpp
+++ b/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryUiApiTestSuite.cpp
@@ -1,33 +1,33 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryUiApiTestSuite.h"
#include "berryXMLMementoTest.h"
#include "berryIPageLayoutTest.h"
#include "berryIViewPartTest.h"
namespace berry {
UiApiTestSuite::UiApiTestSuite()
: CppUnit::TestSuite("UiApiTestSuite")
{
addTest(IPageLayoutTest::Suite());
addTest(IViewPartTest::Suite());
addTest(XMLMementoTest::Suite());
}
}
diff --git a/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryUiApiTestSuite.h b/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryUiApiTestSuite.h
index a3e173794f..8c65590a01 100644
--- a/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryUiApiTestSuite.h
+++ b/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryUiApiTestSuite.h
@@ -1,35 +1,35 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYUIAPITESTSUITE_H_
#define BERRYUIAPITESTSUITE_H_
#include <CppUnit/TestSuite.h>
namespace berry {
class UiApiTestSuite : public CppUnit::TestSuite
{
public:
UiApiTestSuite();
};
}
#endif /* BERRYUIAPITESTSUITE_H_ */
diff --git a/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryXMLMementoTest.cpp b/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryXMLMementoTest.cpp
index 36aa15ab37..28fab06178 100644
--- a/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryXMLMementoTest.cpp
+++ b/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryXMLMementoTest.cpp
@@ -1,753 +1,753 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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.
===================================================================*/
#define NOMINMAX
#include "berryXMLMementoTest.h"
#include <CppUnit/TestSuite.h>
#include <CppUnit/TestCaller.h>
#include <sstream>
#include <fstream>
#include <limits>
namespace berry
{
struct PutMementoChecker: public XMLMementoTest::MementoChecker
{
PutMementoChecker(XMLMementoTest* t) :
mementoTest(t)
{
}
void PrepareAndCheckBeforeSerialization(
XMLMemento::Pointer mementoToSerialize)
{
mementoToSerialize->PutTextData("unchanged text data");
mementoToSerialize->PutString("neverlost", "retained value");
IMemento::Pointer aMemento = XMLMemento::CreateWriteRoot("foo");
mementoTest->FillMemento(aMemento);
// note that this does not copy the text data:
mementoToSerialize->PutMemento(aMemento);
// do not check for text data:
mementoTest->CheckMemento(mementoToSerialize, false);
assertEqual("unchanged text data", mementoToSerialize->GetTextData());
std::string str;
mementoToSerialize->GetString("neverlost", str);
assertEqual("retained value", str);
}
void CheckAfterDeserialization(XMLMemento::Pointer deserializedMemento)
{
// do not check for text data:
mementoTest->CheckMemento(deserializedMemento, false);
assertEqual("unchanged text data", deserializedMemento
->GetTextData());
std::string str;
deserializedMemento->GetString("neverlost", str);
assertEqual("retained value", str);
}
private:
XMLMementoTest* mementoTest;
};
struct PutAndGetStringChecker: public XMLMementoTest::MementoChecker
{
PutAndGetStringChecker(const std::string& key, const std::string& value) :
key(key), value(value)
{
}
void PrepareAndCheckBeforeSerialization(
XMLMemento::Pointer mementoToSerialize)
{
std::string helper;
assertEqual(false, mementoToSerialize->GetString(key, helper));
mementoToSerialize->PutString(key, value);
mementoToSerialize->GetString(key, helper);
assertEqual(value, helper);
}
void CheckAfterDeserialization(XMLMemento::Pointer deserializedMemento)
{
std::string helper;
deserializedMemento->GetString(key, helper);
assertEqual(value, helper);
}
private:
const std::string& key;
const std::string& value;
};
struct CopyChildChecker: public XMLMementoTest::MementoChecker
{
CopyChildChecker(XMLMementoTest* t) :
mementoTest(t)
{
}
void PrepareAndCheckBeforeSerialization(
XMLMemento::Pointer mementoToSerialize)
{
IMemento::Pointer child = mementoToSerialize->CreateChild("c", "i");
mementoTest->FillMemento(child);
IMemento::Pointer copiedChild = mementoToSerialize->CopyChild(child);
assertEqual("i", copiedChild->GetID());
mementoTest->CheckMemento(copiedChild, true);
}
void CheckAfterDeserialization(XMLMemento::Pointer deserializedMemento)
{
IMemento::Pointer child = deserializedMemento->GetChild("c");
mementoTest->CheckMemento(child, true);
std::vector<IMemento::Pointer> children(deserializedMemento->GetChildren(
"c"));
assertEqual(2, (long)children.size());
assertEqual("i", children[0]->GetID());
mementoTest->CheckMemento(children[0], true);
assertEqual("i", children[1]->GetID());
mementoTest->CheckMemento(children[1], true);
}
private:
XMLMementoTest* mementoTest;
};
struct CreateAndGetChildChecker: public XMLMementoTest::MementoChecker
{
CreateAndGetChildChecker() :
type1("type1"), type2("type2"), id("id")
{
}
void PrepareAndCheckBeforeSerialization(
XMLMemento::Pointer mementoToSerialize)
{
// check that nothing is there yet
assertNullPtr(mementoToSerialize->GetChild(type1).GetPointer());
assertNullPtr(mementoToSerialize->GetChild(type2).GetPointer());
// creation without ID
IMemento::Pointer child1 = mementoToSerialize->CreateChild(type1);
assertNotNullPtr(child1.GetPointer());
assertNotNullPtr(mementoToSerialize->GetChild(type1).GetPointer());
// creation with ID
IMemento::Pointer child2 = mementoToSerialize->CreateChild(type2, id);
assertNotNullPtr(child2.GetPointer());
assertNotNullPtr(mementoToSerialize->GetChild(type2).GetPointer());
assertEqual(id, child2->GetID());
}
void CheckAfterDeserialization(XMLMemento::Pointer deserializedMemento)
{
IMemento::Pointer child1 = deserializedMemento->GetChild(type1);
assertNotNullPtr(child1.GetPointer());
IMemento::Pointer child2 = deserializedMemento->GetChild(type2);
assertNotNullPtr(child2.GetPointer());
assertEqual(id, child2->GetID());
}
private:
const std::string type1;
const std::string type2;
const std::string id;
};
struct GetChildrenChecker: public XMLMementoTest::MementoChecker
{
GetChildrenChecker() :
type("type"), id1("id"), id2("id2")
{
}
void PrepareAndCheckBeforeSerialization(
XMLMemento::Pointer mementoToSerialize)
{
// check that nothing is there yet
assertNullPtr(mementoToSerialize->GetChild(type).GetPointer());
IMemento::Pointer child1 = mementoToSerialize->CreateChild(type, id1);
assertNotNullPtr(child1.GetPointer());
assertNotNullPtr(mementoToSerialize->GetChild(type).GetPointer());
assertEqual(id1, child1->GetID());
// second child with the same type
IMemento::Pointer child2 = mementoToSerialize->CreateChild(type, id2);
assertNotNullPtr(child2.GetPointer());
assertEqual(2, (long)mementoToSerialize->GetChildren(type).size());
assertEqual(id2, child2->GetID());
}
void CheckAfterDeserialization(XMLMemento::Pointer deserializedMemento)
{
std::vector<IMemento::Pointer> children(deserializedMemento->GetChildren(
type));
assertEqual(2, (long)children.size());
// this checks that the order is maintained.
// the spec does not promise this, but clients
// may rely on the current implementation behaviour.
assertEqual(id1, children[0]->GetID());
assertEqual(id2, children[1]->GetID());
}
private:
const std::string type;
const std::string id1;
const std::string id2;
};
struct GetIDChecker: public XMLMementoTest::MementoChecker
{
GetIDChecker(const std::string& type, const std::string& id) :
type(type), id(id)
{
}
void PrepareAndCheckBeforeSerialization(
XMLMemento::Pointer mementoToSerialize)
{
assertNullPtr(mementoToSerialize->GetChild(type).GetPointer());
IMemento::Pointer child = mementoToSerialize->CreateChild(type, id);
assertEqual(id, child->GetID());
}
void CheckAfterDeserialization(XMLMemento::Pointer deserializedMemento)
{
IMemento::Pointer child = deserializedMemento->GetChild(type);
assertNotNullPtr(child.GetPointer());
assertEqual(id, child->GetID());
}
private:
const std::string type;
const std::string id;
};
struct PutAndGetFloatChecker: public XMLMementoTest::MementoChecker
{
PutAndGetFloatChecker(const std::string& key, double value) :
key(key), value(value)
{
}
void PrepareAndCheckBeforeSerialization(
XMLMemento::Pointer mementoToSerialize)
{
double v;
assertEqual(false, mementoToSerialize->GetFloat(key, v));
mementoToSerialize->PutFloat(key, value);
mementoToSerialize->GetFloat(key, v);
assertEqual(value, v);
}
void CheckAfterDeserialization(XMLMemento::Pointer deserializedMemento)
{
double v;
deserializedMemento->GetFloat(key, v);
assertEqual(value, v);
}
private:
const std::string key;
const double value;
};
struct PutAndGetIntChecker: public XMLMementoTest::MementoChecker
{
PutAndGetIntChecker(const std::string& key, const int value) :
key(key), value(value)
{
}
void PrepareAndCheckBeforeSerialization(
XMLMemento::Pointer mementoToSerialize)
{
int v;
assertEqual(false, mementoToSerialize->GetInteger(key, v));
mementoToSerialize->PutInteger(key, value);
mementoToSerialize->GetInteger(key, v);
assertEqual(value, v);
}
void CheckAfterDeserialization(XMLMemento::Pointer deserializedMemento)
{
int v;
deserializedMemento->GetInteger(key, v);
assertEqual(value, v);
}
private:
const std::string key;
const int value;
};
struct PutAndGetTextDataChecker: public XMLMementoTest::MementoChecker
{
PutAndGetTextDataChecker(const std::string& data) :
data(data)
{
}
void PrepareAndCheckBeforeSerialization(
XMLMemento::Pointer mementoToSerialize)
{
assertEqual("", mementoToSerialize->GetTextData());
mementoToSerialize->PutTextData(data);
assertEqual(data, mementoToSerialize->GetTextData());
}
void CheckAfterDeserialization(XMLMemento::Pointer deserializedMemento)
{
assertEqual(data, deserializedMemento->GetTextData());
}
private:
const std::string data;
};
struct LegalKeysChecker: public XMLMementoTest::MementoChecker
{
LegalKeysChecker(const std::string& key) :
key(key)
{
}
void PrepareAndCheckBeforeSerialization(
XMLMemento::Pointer mementoToSerialize)
{
std::string v;
assertEqual(false, mementoToSerialize->GetString(key, v));
try
{
mementoToSerialize->PutString(key, "some string");
} catch (Poco::RuntimeException& ex)
{
std::cout << "offending key: '" + key + "'" << std::endl;
ex.rethrow();
}
mementoToSerialize->GetString(key, v);
assertEqual("some string", v);
}
void CheckAfterDeserialization(XMLMemento::Pointer deserializedMemento)
{
std::string v;
deserializedMemento->GetString(key, v);
assertEqual("some string", v);
}
private:
const std::string key;
};
struct PutTextDataWithChildrenChecker: public XMLMementoTest::MementoChecker
{
PutTextDataWithChildrenChecker(const std::string& textData) :
textData(textData)
{
}
void PrepareAndCheckBeforeSerialization(
XMLMemento::Pointer mementoToSerialize)
{
mementoToSerialize->CreateChild("type", "id");
mementoToSerialize->PutTextData(textData);
mementoToSerialize->CreateChild("type", "id");
mementoToSerialize->CreateChild("type", "id");
assertEqual(textData, mementoToSerialize->GetTextData());
}
void CheckAfterDeserialization(XMLMemento::Pointer deserializedMemento)
{
assertEqual(textData, deserializedMemento->GetTextData());
}
private:
const std::string textData;
};
const std::string XMLMementoTest::TEST_STRINGS[10] =
{ "value", " value with spaces ", "value.with.many.dots",
"value_with_underscores", "value<with<lessthan", "value>with>greaterthan",
"value&with&ampersand", "value\"with\"quote", "value#with#hash", "", };
const unsigned int XMLMementoTest::TEST_STRINGS_LENGTH = 10;
/*
* the following cases are for bug 93720
*/
// "\nvalue\nwith\nnewlines\n", "\tvalue\twith\ttab\t",
// "\rvalue\rwith\rreturn\r", };
CppUnit::Test* XMLMementoTest::Suite()
{
CppUnit::TestSuite* suite = new CppUnit::TestSuite("XMLMementoTest");
CppUnit_addTest(suite, XMLMementoTest, TestPutMemento);
CppUnit_addTest(suite, XMLMementoTest, TestPutAndGetString);
CppUnit_addTest(suite, XMLMementoTest, TestCreateReadRootReaderExceptionCases);
CppUnit_addTest(suite, XMLMementoTest, TestCreateReadRootReader);
CppUnit_addTest(suite, XMLMementoTest, TestCreateWriteRoot);
CppUnit_addTest(suite, XMLMementoTest, TestSpacesInRootAreIllegal);
CppUnit_addTest(suite, XMLMementoTest, TestSpacesInKeysAreIllegal);
CppUnit_addTest(suite, XMLMementoTest, TestCopyChild);
CppUnit_addTest(suite, XMLMementoTest, TestCreateAndGetChild);
CppUnit_addTest(suite, XMLMementoTest, TestGetChildren);
CppUnit_addTest(suite, XMLMementoTest, TestGetID);
CppUnit_addTest(suite, XMLMementoTest, TestPutAndGetFloat);
CppUnit_addTest(suite, XMLMementoTest, TestPutAndGetInteger);
CppUnit_addTest(suite, XMLMementoTest, TestPutAndGetTextData);
CppUnit_addTest(suite, XMLMementoTest, TestLegalKeys);
CppUnit_addTest(suite, XMLMementoTest, TestIllegalKeys);
CppUnit_addTest(suite, XMLMementoTest, TestPutTextDataWithChildren);
CppUnit_addTest(suite, XMLMementoTest, TestMementoWithTextContent);
return suite;
}
XMLMementoTest::XMLMementoTest(const std::string& testName) :
TestCase(testName)
{
}
void XMLMementoTest::FillMemento(IMemento::Pointer memento)
{
memento->PutFloat("floatKey", 0.4f);
memento->PutInteger("integerKey", 324765);
memento->PutString("stringKey", "a string");
memento->PutTextData("some text data");
memento->CreateChild("child1");
memento->CreateChild("child2", "child2id1");
memento->CreateChild("child2", "child2id2");
}
void XMLMementoTest::TestPutAndGet(MementoChecker& mementoChecker)
throw (Poco::IOException, WorkbenchException)
{
XMLMemento::Pointer mementoToSerialize = XMLMemento::CreateWriteRoot(
"XMLMementoTest");
mementoChecker.PrepareAndCheckBeforeSerialization(mementoToSerialize);
std::stringstream writer;
mementoToSerialize->Save(writer);
writer.flush();
XMLMemento::Pointer deserializedMemento = XMLMemento::CreateReadRoot(writer);
mementoChecker.CheckAfterDeserialization(deserializedMemento);
}
void XMLMementoTest::CheckMemento(IMemento::Pointer memento,
bool checkForTextData)
{
double floatVal;
memento->GetFloat("floatKey", floatVal);
assertEqualDelta(0.4, floatVal, 0.0001);
int intVal;
memento->GetInteger("integerKey", intVal);
assertEqual(324765, intVal);
std::string strVal;
memento->GetString("stringKey", strVal);
assertEqual("a string", strVal);
if (checkForTextData)
{
assertEqual("some text data", memento->GetTextData());
}
IMemento::Pointer child1 = memento->GetChild("child1");
assertNotNullPtr(child1.GetPointer());
IMemento::Pointer child2 = memento->GetChild("child2");
assertNotNullPtr(child2.GetPointer());
assertEqual("child2id1", child2->GetID());
std::vector<IMemento::Pointer> children(memento->GetChildren("child2"));
assertEqual(2, (long)children.size());
assertEqual("child2id1", children[0]->GetID());
assertEqual("child2id2", children[1]->GetID());
}
void XMLMementoTest::TestPutMemento() throw (WorkbenchException,
Poco::IOException)
{
PutMementoChecker checker(this);
TestPutAndGet(checker);
}
void XMLMementoTest::TestPutAndGetString() throw (Poco::IOException,
WorkbenchException)
{
const std::string key = "key";
for (unsigned int i = 0; i < TEST_STRINGS_LENGTH; ++i)
{
const std::string value;
PutAndGetStringChecker checker(key, TEST_STRINGS[i]);
TestPutAndGet(checker);
}
}
void XMLMementoTest::TestCreateReadRootReaderExceptionCases()
{
try
{
std::stringstream ss("Invalid format");
XMLMemento::CreateReadRoot(ss);
failmsg("should throw WorkbenchException because of invalid format");
} catch (WorkbenchException e)
{
// expected
}
try
{
std::stringstream ss("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>");
XMLMemento::CreateReadRoot(ss);
failmsg("should throw WorkbenchException because there is no element");
} catch (WorkbenchException e)
{
// expected
}
try
{
std::ifstream file("__123thisshouldnotexist_238waer");
XMLMemento::CreateReadRoot(file);
failmsg("should throw WorkbenchException because of IOException");
} catch (WorkbenchException e)
{
// expected
}
}
void XMLMementoTest::TestCreateReadRootReader() throw (WorkbenchException)
{
std::stringstream
ss(
"<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><simple>some text data</simple>");
XMLMemento::Pointer memento = XMLMemento::CreateReadRoot(ss);
assertEqual("some text data", memento->GetTextData());
}
void XMLMementoTest::TestCreateWriteRoot()
{
std::string rootTypes[] =
{ "type", "type.with.dots", "type_with_underscores" };
for (unsigned int i = 0; i < 3; i++)
{
XMLMemento::Pointer memento = XMLMemento::CreateWriteRoot(rootTypes[i]);
assertNotNullPtr(memento.GetPointer());
}
}
void XMLMementoTest::TestSpacesInRootAreIllegal()
{
try
{
XMLMemento::CreateWriteRoot("with space");
failmsg("should fail");
} catch (std::exception& /*e*/)
{
// expected
}
}
void XMLMementoTest::TestSpacesInKeysAreIllegal()
{
XMLMemento::Pointer memento = XMLMemento::CreateWriteRoot("foo");
try
{
memento->CreateChild("with space", "bar");
failmsg("should fail");
} catch (std::exception& /*e*/)
{
// expected
}
try
{
memento->PutString("with space", "bar");
failmsg("should fail");
} catch (std::exception& /*e*/)
{
// expected
}
}
void XMLMementoTest::TestCopyChild() throw (WorkbenchException,
Poco::IOException)
{
CopyChildChecker checker(this);
TestPutAndGet(checker);
}
void XMLMementoTest::TestCreateAndGetChild() throw (WorkbenchException,
Poco::IOException)
{
CreateAndGetChildChecker checker;
TestPutAndGet(checker);
}
void XMLMementoTest::TestGetChildren() throw (WorkbenchException,
Poco::IOException)
{
GetChildrenChecker checker;
TestPutAndGet(checker);
}
void XMLMementoTest::TestGetID() throw (WorkbenchException, Poco::IOException)
{
const std::string type = "type";
const std::string ids[] =
{ "id", "", "id.with.many.dots", "id_with_underscores", "id<with<lessthan",
"id>with>greaterthan", "id&with&ampersand", "id\"with\"quote",
"id#with#hash" };
for (unsigned int i = 0; i < 9; i++)
{
GetIDChecker checker(type, ids[i]);
TestPutAndGet(checker);
}
}
void XMLMementoTest::TestPutAndGetFloat() throw (WorkbenchException,
Poco::IOException)
{
const std::string key = "key";
const double values[] =
{ -3.1415, 1, 0, 4554.45235, std::numeric_limits<double>::max(),
std::numeric_limits<double>::min(),
std::numeric_limits<double>::quiet_NaN(),
std::numeric_limits<double>::infinity() };
for (unsigned int i = 0; i < 8; i++)
{
PutAndGetFloatChecker checker(key, values[i]);
TestPutAndGet(checker);
}
}
void XMLMementoTest::TestPutAndGetInteger() throw (WorkbenchException,
Poco::IOException)
{
const std::string key = "key";
const int values[] =
{ 36254, 0, 1, -36254, std::numeric_limits<int>::max(), std::numeric_limits<
int>::min() };
for (unsigned int i = 0; i < 6; i++)
{
PutAndGetIntChecker checker(key, values[i]);
TestPutAndGet(checker);
}
}
void XMLMementoTest::TestPutAndGetTextData() throw (WorkbenchException,
Poco::IOException)
{
for (unsigned int i = 0; i < TEST_STRINGS_LENGTH; i++)
{
PutAndGetTextDataChecker checker(TEST_STRINGS[i]);
TestPutAndGet(checker);
}
}
void XMLMementoTest::TestLegalKeys() throw (WorkbenchException,
Poco::IOException)
{
const std::string legalKeys[] =
{ "value", "value.with.many.dots", "value_with_underscores" };
for (unsigned int i = 0; i < 3; i++)
{
LegalKeysChecker checker(legalKeys[i]);
TestPutAndGet(checker);
}
}
void XMLMementoTest::TestIllegalKeys() throw ()
{
const std::string illegalKeys[] =
{ "", " ", " key", "key ", "key key", "\t", "\tkey", "key\t", "key\tkey",
"\n", "\nkey", "key\n", "key\nkey", "key<with<lessthan",
"key>with>greaterthan", "key&with&ampersand", "key#with#hash",
"key\"with\"quote", "\"" };
for (unsigned int i = 0; i < 19; i++)
{
XMLMemento::Pointer memento = XMLMemento::CreateWriteRoot("foo");
try
{
memento->PutString(illegalKeys[i], "some string");
failmsg("putString with illegal key should fail");
} catch (std::exception& /*ex*/)
{
// expected
}
}
}
void XMLMementoTest::TestPutTextDataWithChildren() throw (WorkbenchException,
Poco::IOException)
{
const std::string textData =
"\n\tThis is\ntext data\n\t\twith newlines and \ttabs\t\n\t ";
PutTextDataWithChildrenChecker checker(textData);
TestPutAndGet(checker);
}
void XMLMementoTest::TestMementoWithTextContent()
{
IMemento::Pointer memento = XMLMemento::CreateWriteRoot("root");
IMemento::Pointer mementoWithChild = XMLMemento::CreateWriteRoot("root");
IMemento::Pointer child = mementoWithChild->CreateChild("child");
child->PutTextData("text");
memento->PutMemento(mementoWithChild);
IMemento::Pointer copiedChild = memento->GetChild("child");
assertEqual("text", copiedChild->GetTextData());
}
}
diff --git a/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryXMLMementoTest.h b/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryXMLMementoTest.h
index 7efdc202a2..df26a26220 100644
--- a/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryXMLMementoTest.h
+++ b/BlueBerry/Testing/org.blueberry.ui.tests/src/api/berryXMLMementoTest.h
@@ -1,133 +1,133 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYXMLMEMENTOTEST_H_
#define BERRYXMLMEMENTOTEST_H_
#include <berryTestCase.h>
#include <berryXMLMemento.h>
namespace berry
{
/**
* Testing XMLMemento
*
*/
class XMLMementoTest: public TestCase
{
private:
static const std::string TEST_STRINGS[10];
static const unsigned int TEST_STRINGS_LENGTH;
public:
static CppUnit::Test* Suite();
XMLMementoTest(const std::string& testName);
/*
* Class under test for XMLMemento createReadRoot(Reader)
*/
void TestCreateReadRootReaderExceptionCases();
void TestCreateReadRootReader() throw (WorkbenchException);
/*
* Class under test for XMLMemento createReadRoot(Reader, String)
*/
// void testCreateReadRootReaderString() {
// // TODO - I don't know how to test this. The method is not called by
// // anyone as of 2005/04/05.
// }
void TestCreateWriteRoot();
void TestSpacesInRootAreIllegal();
void TestSpacesInKeysAreIllegal();
void TestCopyChild() throw (WorkbenchException, Poco::IOException);
/**
* Helper method to fill a memento to be checked later by checkMemento.
*
* @param memento
*/
void FillMemento(IMemento::Pointer memento);
/**
* Helper method to check if the values set by fillMemento are still there.
* The boolean parameter is needed because in some cases
* (IMememento#putMemento), the text data gets lost.
*
* @param memento
* @param checkForTextData
*/
void CheckMemento(IMemento::Pointer memento, bool checkForTextData);
void TestCreateAndGetChild() throw (WorkbenchException, Poco::IOException);
void TestGetChildren() throw (WorkbenchException, Poco::IOException);
void TestGetID() throw (WorkbenchException, Poco::IOException);
void TestPutAndGetFloat() throw (WorkbenchException, Poco::IOException);
void TestPutAndGetInteger() throw (WorkbenchException, Poco::IOException);
void TestPutMemento() throw (WorkbenchException, Poco::IOException);
void TestPutAndGetString() throw (Poco::IOException, WorkbenchException);
void TestPutAndGetTextData() throw (WorkbenchException, Poco::IOException);
void TestLegalKeys() throw (WorkbenchException, Poco::IOException);
void TestIllegalKeys() throw ();
void TestPutTextDataWithChildren() throw (WorkbenchException,
Poco::IOException);
void TestMementoWithTextContent();
struct MementoChecker: public CppUnit::TestCase
{
MementoChecker() :
CppUnit::TestCase("MementoChecker")
{
}
virtual void PrepareAndCheckBeforeSerialization(
XMLMemento::Pointer mementoToSerialize) = 0;
virtual void CheckAfterDeserialization(
XMLMemento::Pointer deserializedMemento) = 0;
};
private:
void TestPutAndGet(MementoChecker& mementoChecker) throw (Poco::IOException,
WorkbenchException);
};
}
#endif /* BERRYXMLMEMENTOTEST_H_ */
diff --git a/BlueBerry/Testing/org.blueberry.ui.tests/src/berryPluginActivator.cpp b/BlueBerry/Testing/org.blueberry.ui.tests/src/berryPluginActivator.cpp
index b9c7ddc639..90d7223928 100644
--- a/BlueBerry/Testing/org.blueberry.ui.tests/src/berryPluginActivator.cpp
+++ b/BlueBerry/Testing/org.blueberry.ui.tests/src/berryPluginActivator.cpp
@@ -1,43 +1,43 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryPluginActivator.h"
#include "berryUiTestSuite.h"
#include "api/berryMockViewPart.h"
#include "api/berrySaveableMockViewPart.h"
#include <QtPlugin>
namespace berry {
void org_blueberry_ui_tests_Activator::start(ctkPluginContext* context)
{
BERRY_REGISTER_EXTENSION_CLASS(UiTestSuite, context)
BERRY_REGISTER_EXTENSION_CLASS(MockViewPart, context)
BERRY_REGISTER_EXTENSION_CLASS(SaveableMockViewPart, context)
}
void org_blueberry_ui_tests_Activator::stop(ctkPluginContext* context)
{
Q_UNUSED(context)
}
}
Q_EXPORT_PLUGIN2(org_blueberry_ui_tests, berry::org_blueberry_ui_tests_Activator)
diff --git a/BlueBerry/Testing/org.blueberry.ui.tests/src/berryPluginActivator.h b/BlueBerry/Testing/org.blueberry.ui.tests/src/berryPluginActivator.h
index 2e9c25e702..918a7d8bf1 100644
--- a/BlueBerry/Testing/org.blueberry.ui.tests/src/berryPluginActivator.h
+++ b/BlueBerry/Testing/org.blueberry.ui.tests/src/berryPluginActivator.h
@@ -1,43 +1,43 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYPLUGINACTIVATOR_H
#define BERRYPLUGINACTIVATOR_H
#include <ctkPluginActivator.h>
#include <ctkServiceRegistration.h>
namespace berry {
class org_blueberry_ui_tests_Activator :
public QObject, public ctkPluginActivator
{
Q_OBJECT
Q_INTERFACES(ctkPluginActivator)
public:
void start(ctkPluginContext* context);
void stop(ctkPluginContext* context);
};
typedef org_blueberry_ui_tests_Activator PluginActivator;
}
#endif // BERRYPLUGINACTIVATOR_H
diff --git a/BlueBerry/Testing/org.blueberry.ui.tests/src/berryUiTestSuite.cpp b/BlueBerry/Testing/org.blueberry.ui.tests/src/berryUiTestSuite.cpp
index 81c5ce1204..272718b2b6 100644
--- a/BlueBerry/Testing/org.blueberry.ui.tests/src/berryUiTestSuite.cpp
+++ b/BlueBerry/Testing/org.blueberry.ui.tests/src/berryUiTestSuite.cpp
@@ -1,37 +1,37 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 "berryUiTestSuite.h"
#include "api/berryUiApiTestSuite.h"
#include <stdexcept>
namespace berry {
UiTestSuite::UiTestSuite()
: CppUnit::TestSuite("UiTestSuite")
{
addTest(new UiApiTestSuite());
}
UiTestSuite::UiTestSuite(const UiTestSuite& other)
{
Q_UNUSED(other);
throw std::runtime_error("Copy constructor not implemented");
}
}
diff --git a/BlueBerry/Testing/org.blueberry.ui.tests/src/berryUiTestSuite.h b/BlueBerry/Testing/org.blueberry.ui.tests/src/berryUiTestSuite.h
index 23996e629e..150eaa4c7e 100644
--- a/BlueBerry/Testing/org.blueberry.ui.tests/src/berryUiTestSuite.h
+++ b/BlueBerry/Testing/org.blueberry.ui.tests/src/berryUiTestSuite.h
@@ -1,42 +1,42 @@
/*===================================================================
-The Medical Imaging Interaction Toolkit (MITK)
+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 BERRYUITESTSUITE_H_
#define BERRYUITESTSUITE_H_
#include <CppUnit/TestSuite.h>
#include <QObject>
Q_DECLARE_INTERFACE(CppUnit::Test, "CppUnit.Test")
namespace berry {
class UiTestSuite : public QObject, public CppUnit::TestSuite
{
Q_OBJECT
Q_INTERFACES(CppUnit::Test)
public:
UiTestSuite();
UiTestSuite(const UiTestSuite& other);
};
}
#endif /* BERRYUITESTSUITE_H_ */

File Metadata

Mime Type
application/octet-stream
Expires
Mon, May 20, 3:46 PM (2 d)
Storage Engine
chunks
Storage Format
Chunks
Storage Handle
sazxvOTjnumv
Default Alt Text
(4 MB)

Event Timeline