diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryParameterizedCommand.cpp b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryParameterizedCommand.cpp
index 0921784929..5b8928b3a5 100755
--- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryParameterizedCommand.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryParameterizedCommand.cpp
@@ -1,449 +1,444 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; 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 "berryIParameterValues.h"
#include "berryCommand.h"
#include "berryParameterization.h"
#include "berryExecutionEvent.h"
#include "berryCommandManager.h"
#include "berryCommandCategory.h"
#include "berryState.h"
#include "berryIHandler.h"
#include "internal/berryCommandUtils.h"
#include
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 uint ParameterizedCommand::HASH_CODE_NOT_COMPUTED = 0;
const uint ParameterizedCommand::HASH_FACTOR = 89;
const uint ParameterizedCommand::HASH_INITIAL = qHash("berry::ParameterizedCommand");
ParameterizedCommand::ParameterizedCommand(const SmartPointer& command,
const QList& params)
: command(command), hashCode(HASH_CODE_NOT_COMPUTED)
{
if (!command)
{
throw Poco::NullPointerException(
"A parameterized command cannot have a null command");
}
QList parameters;
try
{
parameters = command->GetParameters();
} catch (const NotDefinedException* /*e*/)
{
// This should not happen.
}
if (!params.empty() && !parameters.empty())
{
for (int j = 0; j < parameters.size(); j++)
{
for (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(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(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::Pointer& applicationContext)
{
ExecutionEvent::Pointer excEvent(new ExecutionEvent(command,
this->GetParameterMap(), trigger, applicationContext));
return command->ExecuteWithChecks(excEvent);
}
SmartPointer ParameterizedCommand::GetCommand() const
{
return command;
}
QString ParameterizedCommand::GetId() const
{
return command->GetId();
}
QString ParameterizedCommand::GetName() const
{
if (name.isEmpty())
{
QTextStream nameBuffer(&name);
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 << ")";
}
}
return name;
}
QHash ParameterizedCommand::GetParameterMap() const
{
QHash parameterMap;
for (int i = 0; i < parameterizations.size(); i++)
{
const Parameterization& parameterization = parameterizations[i];
parameterMap.insert(parameterization.GetParameter()->GetId(),
parameterization.GetValue());
}
return parameterMap;
}
uint ParameterizedCommand::HashCode() const
{
if (hashCode == HASH_CODE_NOT_COMPUTED)
{
hashCode = HASH_INITIAL * HASH_FACTOR + (command ? command->HashCode() : 0);
hashCode = hashCode * HASH_FACTOR;
for (int i = 0; i < parameterizations.size(); i++)
{
hashCode += parameterizations[i].HashCode();
}
if (hashCode == HASH_CODE_NOT_COMPUTED)
{
hashCode++;
}
}
return hashCode;
}
QString ParameterizedCommand::Serialize()
{
const QString escapedId(this->Escape(this->GetId()));
if (parameterizations.empty())
{
return escapedId;
}
QString str;
QTextStream buffer(&str);
buffer << CommandManager::PARAMETER_START_CHAR;
for (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 QString parameterId(parameterization.GetParameter()->GetId());
const QString escapedParameterId(this->Escape(parameterId));
buffer << escapedParameterId;
const QString parameterValue(parameterization.GetValue());
if (!parameterValue.isEmpty())
{
const QString escapedParameterValue(this->Escape(parameterValue));
buffer << CommandManager::ID_VALUE_CHAR
<< escapedParameterValue;
}
}
buffer << CommandManager::PARAMETER_END_CHAR;
return str;
}
QString ParameterizedCommand::ToString() const
{
QString str;
QTextStream buffer(&str);
buffer << "ParameterizedCommand(" << command->ToString() << ","
<< CommandUtils::ToString(parameterizations) << ")";
return str;
}
QList
ParameterizedCommand::GenerateCombinations(const SmartPointer command)
{
QList parameters(command->GetParameters());
typedef QList > ExpandedParamsType;
const ExpandedParamsType expansion(ExpandParameters(0, parameters));
QList combinations;
for (ExpandedParamsType::const_iterator expansionItr = expansion.begin();
expansionItr != expansion.end(); ++expansionItr)
{
QList combination(*expansionItr);
QList parameterizations(combination);
ParameterizedCommand::Pointer pCmd(new ParameterizedCommand(command,
parameterizations));
combinations.push_back(pCmd);
}
return combinations;
}
ParameterizedCommand::Pointer ParameterizedCommand::GenerateCommand(const SmartPointer command,
const QHash& parameters)
{
// no parameters
if (parameters.empty())
{
ParameterizedCommand::Pointer pCmd(new ParameterizedCommand(command, QList()));
return pCmd;
}
try
{
QList parms;
// iterate over given parameters
for (QHash::const_iterator i = parameters.begin();
i != parameters.end(); ++i)
{
QString key(i.key());
// 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)
{
QString val = i.value()->ToString();
parms.push_back(Parameterization(parameter, val));
}
else
{
IParameterValueConverter* valueConverter(parameterType->GetValueConverter());
if (valueConverter)
{
QString val(valueConverter->ConvertToString(i.value()));
parms.push_back(Parameterization(parameter, val));
}
else
{
QString val = i.value()->ToString();
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);
}
QString ParameterizedCommand::Escape(const QString& rawText)
{
QString buffer;
for (QString::const_iterator i = rawText.begin();
i != rawText.end(); ++i)
{
QString::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.isEmpty())
{
return rawText;
}
return buffer;
}
QList > ParameterizedCommand::ExpandParameters(
unsigned int startIndex, const QList& parameters)
{
typedef QList > ReturnType;
const int nextIndex = startIndex + 1;
const bool noMoreParameters = (nextIndex >= parameters.size());
const IParameter::Pointer parameter(parameters[startIndex]);
ReturnType parameterizations;
if (parameter->IsOptional())
{
parameterizations.push_back(QList());
}
IParameterValues* values = NULL;
try
{
values = parameter->GetValues();
}
catch (const ParameterValuesException& /*e*/)
{
if (noMoreParameters)
{
return parameterizations;
}
// Make recursive call
return ExpandParameters(nextIndex, parameters);
}
const QHash parameterValues = values->GetParameterValues();
for (IParameter::ParameterValues::const_iterator parameterValueItr =
parameterValues.begin(); parameterValueItr != parameterValues.end(); ++parameterValueItr)
{
QList combination;
combination.push_back(
Parameterization(parameter, parameterValueItr.value()));
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)
{
QList newCombination(*combinationItr);
newCombination.append(*suffixItr);
returnValue.push_back(newCombination);
}
}
return returnValue;
}
}
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 5e767e3061..102216e58c 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryTestExpression.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/src/internal/berryTestExpression.cpp
@@ -1,189 +1,189 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; 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 "berryExpressionStatus.h"
#include "berryPlatform.h"
#include "berryCoreException.h"
#include
#include
namespace berry {
const QChar TestExpression::PROP_SEP = '.';
const QString TestExpression::ATT_PROPERTY = "property";
const QString TestExpression::ATT_ARGS = "args";
const QString TestExpression::ATT_FORCE_PLUGIN_ACTIVATION = "forcePluginActivation";
const uint TestExpression::HASH_INITIAL= qHash("berry::TextExpression");
TypeExtensionManager& TestExpression::GetTypeExtensionManager()
{
static TypeExtensionManager mgr("propertyTesters");
return mgr;
}
TestExpression::TestExpression(const IConfigurationElement::Pointer& element)
{
QString property = element->GetAttribute(ATT_PROPERTY);
int pos = property.lastIndexOf(PROP_SEP);
if (pos == -1)
{
IStatus::Pointer status(new ExpressionStatus(
ExpressionStatus::NO_NAMESPACE_PROVIDED,
"The property attribute of the test expression must be qualified by a name space.",
BERRY_STATUS_LOC));
throw CoreException(status);
}
fNamespace = property.left(pos);
fProperty = property.mid(pos + 1);
fArgs = Expressions::GetArguments(element, ATT_ARGS);
fExpectedValue = Expressions::ConvertArgument(element->GetAttribute(ATT_VALUE));
fForcePluginActivation = Expressions::GetOptionalBooleanAttribute(element, ATT_FORCE_PLUGIN_ACTIVATION);
}
TestExpression::TestExpression(Poco::XML::Element* element)
{
QString property= QString::fromStdString(element->getAttribute(ATT_PROPERTY.toStdString()));
int pos = property.lastIndexOf(PROP_SEP);
if (pos == -1)
{
IStatus::Pointer status(new ExpressionStatus(
ExpressionStatus::NO_NAMESPACE_PROVIDED,
"The property attribute of the test expression must be qualified by a name space.",
BERRY_STATUS_LOC));
throw CoreException(status);
}
fNamespace = property.left(pos);
fProperty = property.mid(pos + 1);
fArgs = Expressions::GetArguments(element, ATT_ARGS);
std::string value = element->getAttribute(ATT_VALUE.toStdString());
fExpectedValue = Expressions::ConvertArgument(value.size() > 0 ? QString::fromStdString(value) : QString());
fForcePluginActivation = Expressions::GetOptionalBooleanAttribute(element, ATT_FORCE_PLUGIN_ACTIVATION);
}
TestExpression::TestExpression(const QString& namespaze, const QString& property,
const QList& args, Object::Pointer expectedValue)
: fNamespace(namespaze), fProperty(property), fArgs(args),
fExpectedValue(expectedValue), fForcePluginActivation(false)
{
}
TestExpression::TestExpression(const QString &namespaze, const QString &property, const QList& args,
Object::Pointer expectedValue, bool forcePluginActivation)
: fNamespace(namespaze), fProperty(property), fArgs(args),
fExpectedValue(expectedValue), fForcePluginActivation(forcePluginActivation)
{
}
EvaluationResult::ConstPointer
TestExpression::Evaluate(IEvaluationContext* context) const
{
Object::ConstPointer element(context->GetDefaultVariable());
if (typeid(Platform) == typeid(element.GetPointer()))
{
QString str = Platform::GetProperty(fProperty);
if (str.isEmpty())
{
return EvaluationResult::FALSE_EVAL;
}
return EvaluationResult::ValueOf(str == fArgs[0]->ToString());
}
Property::Pointer property= GetTypeExtensionManager().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) const
{
info->MarkDefaultVariableAccessed();
info->AddAccessedPropertyName(fNamespace + PROP_SEP + fProperty);
}
bool
TestExpression::operator==(const Object* object) const
{
if (const TestExpression* that = dynamic_cast(object))
{
return this->fNamespace == that->fNamespace &&
this->fProperty == that->fProperty &&
this->fForcePluginActivation == that->fForcePluginActivation &&
this->Equals(this->fArgs, that->fArgs) &&
this->fExpectedValue == that->fExpectedValue;
}
return false;
}
uint TestExpression::ComputeHashCode() const
{
return HASH_INITIAL * HASH_FACTOR + this->HashCode(fArgs)
- * HASH_FACTOR + fExpectedValue.IsNull() ? 0 : fExpectedValue->HashCode()
+ * HASH_FACTOR + (fExpectedValue.IsNull() ? 0 : fExpectedValue->HashCode())
* HASH_FACTOR + qHash(fNamespace)
* HASH_FACTOR + qHash(fProperty)
* HASH_FACTOR + (fForcePluginActivation ? 1 : 0);
}
QString
TestExpression::ToString() const
{
QString args("");
for (int i= 0; i < fArgs.size(); i++)
{
Object::Pointer arg= fArgs[i];
ObjectString::Pointer strarg = arg.Cast();
if (strarg)
{
args.append('\'');
args.append(static_cast(*strarg));
args.append('\'');
}
else
{
args.append(arg->ToString());
}
if (i < fArgs.size() - 1)
args.append(", ");
}
return "ToString() + "\"" : "\"") +
" plug-in activation: " + (fForcePluginActivation ? "eager" : "lazy") + "/>";
}
//---- testing ---------------------------------------------------
bool
TestExpression::TestGetForcePluginActivation()
{
return fForcePluginActivation;
}
TypeExtensionManager&
TestExpression::TestGetTypeExtensionManager()
{
return GetTypeExtensionManager();
}
}
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 a80f9e9311..e9e3a49d0f 100644
--- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryJobListeners.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryJobListeners.cpp
@@ -1,164 +1,164 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; 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 "berryOperationCanceledException.h"
#include "berryLog.h"
#include
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 ()->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 (e);
- return;
+ if(dynamic_cast (e))
+ return;
}
catch (const std::bad_cast&)
{
// TODO get bundle id (find a C++ way)
//std::string pluginId = JobOSGiUtils.getDefault().getBundleId(listener);
QString pluginId;
if (pluginId.isEmpty())
pluginId = JobManager::PI_JOBS();
QString message = "Problems occurred when invoking code from plug-in: "
+ pluginId;
BERRY_ERROR << message;
// 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/berryWorker.cpp b/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryWorker.cpp
index ceb943a222..16d46672d5 100644
--- a/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryWorker.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.jobs/src/internal/berryWorker.cpp
@@ -1,134 +1,134 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; 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 "berryJobManager.h"
#include "berryLog.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(BERRY_STATUS_LOC);
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);
BERRY_ERROR << " 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)
{
QString msg = "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, msg, ctkException(exception.what()), BERRY_STATUS_LOC));
return sptr_errorStatus ;
}
/************************* end of nested JobRunnable class definition ****************************/
Worker::Worker(WeakPointer myPool) :
- Poco::Thread("Worker-" + m_nextWorkerNumber++), m_Runnable(this), m_wpPool(
+ Poco::Thread("Worker-" + std::to_string(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.ui.qt/src/application/berryWorkbenchAdvisor.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/application/berryWorkbenchAdvisor.h
index 46acbf3c1f..b11c68ab0e 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/application/berryWorkbenchAdvisor.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/application/berryWorkbenchAdvisor.h
@@ -1,410 +1,410 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; 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
#include "berryIMemento.h"
#include
#include "berryWorkbenchWindowAdvisor.h"
#include "berryIWorkbenchConfigurer.h"
namespace berry {
/**
* public: base class for configuring the workbench.
*
* 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, PlatformUI#GetWorkbench()
is guaranteed to have been
* properly initialized.
*
*
* Example of creating and running a workbench (in an
* berry#IApplication
):
*
*
*
* 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;
* }
* };
*
*
*
*
*
* An application should declare a subclass of berry::WorkbenchAdvisor
* and override methods to configure the workbench to suit the needs of the
* particular application.
*
*
* The following advisor methods are called at strategic points in the
* workbench's lifecycle (all occur within the dynamic scope of the call to
* PlatformUI#CreateAndRunWorkbench()
):
*
* - Initialize() - called first; before any windows; use to
* register things
* - PreStartup() - called second; after initialize but before
* first window is opened; use to temporarily disable things during startup or
* restore
* - PostStartup() - called third; after first window is opened;
* use to reenable things temporarily disabled in previous step
* - 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)
* - 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)
* - PreShutdown() - called immediately prior to workbench
* shutdown before any windows have been closed; allows the advisor to veto the
* shutdown
* - PostShutdown() - called last; after event loop has
* terminated and all windows have been closed; use to deregister things
* registered during initialize
*
*
*
*/
class BERRY_UI_QT WorkbenchAdvisor {
/**
* The workbench configurer.
*/
private: IWorkbenchConfigurer::Pointer workbenchConfigurer;
/*
* The workbench error handler.
*/
//private: AbstractStatusHandler workbenchErrorHandler;
- private: bool introOpened;
+ //private: bool introOpened;
/**
* Creates and initializes a new workbench advisor instance.
*/
protected: WorkbenchAdvisor();
virtual ~WorkbenchAdvisor();
/**
* Remembers the configurer and calls Initialize()
.
*
* For internal use by the workbench only.
*
*
* @param configurer
* an object for configuring the workbench
*/
public: void InternalBasicInitialize(IWorkbenchConfigurer::Pointer configurer);
/**
* Performs arbitrary initialization before the workbench starts running.
*
* 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 GetWorkbenchConfigurer()
.
*
*
* @param configurer
* an object for configuring the workbench
*/
public: virtual void Initialize(IWorkbenchConfigurer::Pointer configurer);
/**
* Returns the workbench configurer for the advisor. Can be
* null
if the advisor is not initialized yet.
*
* @return the workbench configurer, or null
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).
*
* 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.
*
*/
public: virtual void PreStartup();
/**
* Performs arbitrary actions after the workbench windows have been opened
* (or restored), but before the main event loop is run.
*
* 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 IWorkbench#Close()
from this method.
*
*/
public: virtual void PostStartup();
/**
* Performs arbitrary finalization before the workbench is about to shut
* down.
*
* 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
* true
. Subclasses may override.
*
*
* The advisor may veto a regular shutdown by returning false
,
* although this will be ignored if the workbench is being forced to shut
* down.
*
*
* @return true
to allow the workbench to proceed with
* shutdown, false
to veto a non-forced shutdown
*/
public: virtual bool PreShutdown();
/**
* Performs arbitrary finalization after the workbench stops running.
*
* 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.
*
*/
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).
*
* 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.
*
*
* 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.
*
*
* @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.
*
* This method is called when there are currently no more events on the
* queue to be processed at the moment.
*
*
* 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
* IWorkbench.close()
from this method.
*
*
* @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.
*
* The default implementation returns null
. Subclasses may
* override.
*
*
* @return the default input for a new workbench window page, or
* null
if none
*
* @see #CreateWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer::Pointer)
*/
public: virtual IAdaptable* GetDefaultPageInput();
/**
* Returns the id of the perspective to use for the initial workbench
* window, or null
if no initial perspective should be shown
* in the initial workbench window.
*
* This method is called during startup when the workbench is creating the
* first new window. Subclasses must implement.
*
*
* If the WorkbenchPreferenceConstants#DEFAULT_PERSPECTIVE_ID
* preference is specified, it supercedes the perspective specified here.
*
*
* @return the id of the perspective for the initial window, or
* null
if no initial perspective should be shown
*/
public: virtual QString GetInitialWindowPerspectiveId() = 0;
/**
* Returns the id of the preference page that should be presented most
* prominently.
*
* The default implementation returns null
. Subclasses may
* override.
*
*
* @return the id of the preference page, or null
if none
*/
public: virtual QString GetMainPreferencePageId();
/**
* Opens the workbench windows on startup. The default implementation tries
* to restore the previously saved workbench state using
* IWorkbenchConfigurer#RestoreState()
. If there
* was no previously saved state, or if the restore failed, then a
* first-time window is opened using
* IWorkbenchConfigurer#OpenFirstTimeWindow().
*
* @return true
to proceed with workbench startup, or
* false
to exit
*/
public: virtual bool OpenWindows();
/**
* Saves arbitrary application-specific state information for this workbench
* advisor.
*
* The default implementation simply returns an OK status. Subclasses may
* extend or override.
*
*
* @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.
*
* The default implementation simply returns an OK status. Subclasses may
* extend or override.
*
*
* @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 null
* @see IContributionService#GetComparatorFor(const QString&)
*/
// public: ContributionComparator getComparatorFor(String contributionType) {
// return new ContributionComparator();
// }
};
}
#endif /*BERRYWORKBENCHADVISOR_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryCategory.txx b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryCategory.txx
index 29140301f1..24a032e2fc 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryCategory.txx
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryCategory.txx
@@ -1,194 +1,194 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; 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
#include
#include
namespace berry
{
template
const QString Category::MISC_NAME = "Other";
template
const QString Category::MISC_ID =
"org.blueberry.ui.internal.otherCategory";
template Category::Category()
{
this->id = MISC_ID;
this->name = MISC_NAME;
this->pluginId = MISC_ID;
}
template Category::Category(const QString& ID,
const QString& label)
: id(ID), name(label)
{
}
template
Category::Category(IConfigurationElement::Pointer configElement)
: configurationElement(configElement) {
id = configElement->GetAttribute(WorkbenchRegistryConstants::ATT_ID);
if (id.isEmpty() || GetLabel().isEmpty())
{
throw WorkbenchException(QString("Invalid category: ") + id);
}
}
template
void Category::AddElement(ElementType element)
{
elements.push_back(element);
}
template
Object* Category::GetAdapter(const QString& adapter) const
{
if (adapter == qobject_interface_iid())
{
return configurationElement.GetPointer();
}
else
{
return NULL;
}
}
//template
//ImageDescriptor Category::GetImageDescriptor()
//{
// return WorkbenchImages.getImageDescriptor(ISharedImages.IMG_OBJ_FOLDER);
//}
template
const QString& Category::GetId() const
{
return id;
}
template
QString Category::GetLabel() const
{
if (configurationElement.IsNull())
return name;
return configurationElement->GetAttribute(WorkbenchRegistryConstants::ATT_NAME);
}
template
QList Category::GetParentPath()
{
if (parentPath.size() > 0)
{
return parentPath;
}
QString unparsedPath(this->GetRawParentPath());
foreach(QString token, unparsedPath.split('/', QString::SkipEmptyParts))
{
parentPath.push_back(token.trimmed());
}
return parentPath;
}
template
QString Category::GetRawParentPath() const
{
if (configurationElement.IsNull())
return QString();
return configurationElement->GetAttribute(WorkbenchRegistryConstants::ATT_PARENT_CATEGORY);
}
template
QString Category::GetRootPath()
{
if (this->GetParentPath().size() > 0)
{
return GetParentPath()[0];
}
return id;
}
template
const QList& Category::GetElements() const
{
return elements;
}
template
bool Category::HasElement(const ElementType& o) const
{
if (elements.empty())
{
return false;
}
for (typename QList::const_iterator iter = elements.begin(); iter != elements.end(); ++iter)
{
if (*iter == o) return true;
}
return false;
}
template
bool Category::HasElements() const
{
return !elements.empty();
}
template
-T* Category::GetParent(const ElementType& o)
+T* Category::GetParent(const ElementType& /*o*/)
{
return 0;
}
template
QString Category::GetLocalId() const
{
return id;
}
template
QString Category::GetPluginId() const
{
return configurationElement.IsNull() ?
pluginId : configurationElement->GetContributor()->GetName();
}
template
void Category::Clear()
{
elements.clear();
}
} // namespace berry
#endif // __BERRY_CATEGORY_TXX__
diff --git a/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatObjectEditorInput.cpp b/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatObjectEditorInput.cpp
index 3ca9e92bca..855702f4d1 100644
--- a/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatObjectEditorInput.cpp
+++ b/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatObjectEditorInput.cpp
@@ -1,63 +1,81 @@
/*===================================================================
The Medical Imaging Interaction Toolkit (MITK)
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "QmitkXnatObjectEditorInput.h"
+#include
+
QmitkXnatObjectEditorInput::QmitkXnatObjectEditorInput(ctkXnatObject* object)
: m_Object(object)
{
}
QmitkXnatObjectEditorInput::~QmitkXnatObjectEditorInput()
{
}
ctkXnatObject* QmitkXnatObjectEditorInput::GetXnatObject() const
{
return m_Object;
}
bool QmitkXnatObjectEditorInput::Exists() const
{
return m_Object->exists();
}
QString QmitkXnatObjectEditorInput::GetName() const
{
return m_Object->id();
}
QString QmitkXnatObjectEditorInput::GetToolTipText() const
{
return m_Object->description();
}
bool QmitkXnatObjectEditorInput::operator==(const berry::Object* o) const
{
if ( const QmitkXnatObjectEditorInput* other = dynamic_cast(o) )
{
if ( other->GetXnatObject()->parent() )
{
return (other->GetName() == this->GetName()) &&
(other->GetXnatObject()->parent()->id() == this->GetXnatObject()->parent()->id());
}
else
{
return (other->GetName() == this->GetName());
}
}
return false;
}
+
+
+QIcon QmitkXnatObjectEditorInput::GetIcon() const
+{
+ return QIcon();
+}
+
+const berry::IPersistableElement* QmitkXnatObjectEditorInput::GetPersistable() const
+{
+ return nullptr;
+}
+
+berry::Object* QmitkXnatObjectEditorInput::GetAdapter(const QString& /*adapterType*/) const
+{
+ return nullptr;
+}
diff --git a/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatObjectEditorInput.h b/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatObjectEditorInput.h
index a21eaa697d..7c94873b59 100644
--- a/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatObjectEditorInput.h
+++ b/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatObjectEditorInput.h
@@ -1,44 +1,48 @@
/*===================================================================
The Medical Imaging Interaction Toolkit (MITK)
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef QMITKXNATOBJECTEDITORINPUT_H_
#define QMITKXNATOBJECTEDITORINPUT_H_
#include "berryIEditorInput.h"
#include "ctkXnatObject.h"
class QmitkXnatObjectEditorInput : public berry::IEditorInput {
public:
berryObjectMacro(QmitkXnatObjectEditorInput);
QmitkXnatObjectEditorInput(ctkXnatObject* object);
~QmitkXnatObjectEditorInput();
/// \brief Returns the kept ctkXnatObject.
ctkXnatObject* GetXnatObject() const;
virtual bool Exists() const;
virtual QString GetName() const;
virtual QString GetToolTipText() const;
+ QIcon GetIcon() const;
+ const berry::IPersistableElement* GetPersistable() const;
+ berry::Object* GetAdapter(const QString& adapterType) const;
+
virtual bool operator==(const berry::Object* o) const;
private:
ctkXnatObject* m_Object;
};
#endif /*QMITKXNATOBJECTEDITORINPUT_H_*/