diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/files.cmake b/BlueBerry/Bundles/org.blueberry.ui.qt/files.cmake
index 781968ee59..21ce7aebab 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/files.cmake
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/files.cmake
@@ -1,460 +1,453 @@
set(SRC_CPP_FILES
berryAbstractSourceProvider.cpp
berryAbstractUICTKPlugin.cpp
berryConstants.cpp
berryDisplay.cpp
berryEditorPart.cpp
berryFileEditorInput.cpp
berryGeometry.cpp
berryIActionBars.h
berryIContextService.cpp
berryIContributionRoot.h
berryIDropTargetListener.cpp
berryIEditorDescriptor.cpp
berryIEditorInput.cpp
berryIEditorMatchingStrategy.cpp
berryIEditorPart.cpp
berryIEditorReference.cpp
berryIEditorRegistry.cpp
berryIEditorSite.cpp
berryIFileEditorMapping.cpp
berryIFolderLayout.cpp
- berryImageDescriptor.cpp
berryIMemento.cpp
berryINullSelectionListener.cpp
berryIPageLayout.cpp
berryIPartListener.cpp
berryIPageService.cpp
berryIPartService.cpp
berryIPathEditorInput.cpp
berryIPerspectiveDescriptor.cpp
berryIPerspectiveFactory.cpp
berryIPerspectiveListener.cpp
berryIPerspectiveRegistry.cpp
berryIPlaceholderFolderLayout.cpp
berryIPluginContribution.h
berryIPostSelectionProvider.cpp
berryIPreferencePage.cpp
berryIPropertyChangeListener.cpp
berryIQtPreferencePage.cpp
berryIQtStyleManager.cpp
berryIReusableEditor.cpp
berryISaveablePart.cpp
berryISaveablesLifecycleListener.cpp
berryISaveablesSource.cpp
berryISelection.cpp
berryISelectionChangedListener.cpp
berryISelectionListener.cpp
berryISelectionProvider.cpp
berryISelectionService.cpp
berryIShellListener.cpp
berryIShellProvider.cpp
berryIShowInSource.h
berryIShowInTarget.h
berryISizeProvider.cpp
berryISourceProvider.cpp
berryISourceProviderListener.cpp
berryISources.cpp
berryIStickyViewDescriptor.cpp
berryIStructuredSelection.cpp
berryIViewCategory.cpp
berryIViewDescriptor.cpp
berryIViewLayout.cpp
berryIViewPart.cpp
berryIViewReference.cpp
berryIViewRegistry.cpp
berryIViewSite.cpp
berryIWorkbenchCommandConstants.cpp
berryIWindowListener.cpp
berryIWorkbench.cpp
berryIWorkbenchListener.cpp
berryIWorkbenchPage.cpp
berryIWorkbenchPart.cpp
berryIWorkbenchPartConstants.cpp
berryIWorkbenchPartDescriptor.cpp
berryIWorkbenchPartReference.cpp
berryIWorkbenchPartSite.cpp
berryIWorkbenchSite.cpp
berryIWorkbenchWindow.cpp
berryMenuUtil.cpp
berryPlatformUI.cpp
berryPoint.cpp
berryPropertyChangeEvent.cpp
berryQModelIndexObject.cpp
berryQtEditorPart.cpp
berryQtItemSelection.cpp
berryQtIntroPart.cpp
berryQtPreferences.cpp
berryQtSelectionProvider.cpp
berryQtViewPart.cpp
berryRectangle.cpp
berrySameShellProvider.cpp
berrySaveable.cpp
berrySaveablesLifecycleEvent.cpp
berrySelectionChangedEvent.cpp
berryShell.cpp
berryShellEvent.cpp
berryShowInContext.cpp
berryUIException.cpp
berryViewPart.cpp
berryWindow.cpp
berryWorkbenchActionConstants.cpp
berryWorkbenchPart.cpp
berryWorkbenchPreferenceConstants.cpp
berryXMLMemento.cpp
#actions
actions/berryAbstractContributionFactory.cpp
actions/berryAbstractGroupMarker.cpp
actions/berryCommandContributionItem.h
actions/berryCommandContributionItem.cpp
actions/berryContributionItem.cpp
actions/berryContributionItemFactory.cpp
actions/berryContributionManager.cpp
actions/berryIContributionItem.h
actions/berryIContributionManager.h
actions/berryIContributionManagerOverrides.cpp
actions/berryIMenuManager.h
#actions/berryMenuBarManager.cpp
actions/berryMenuManager.cpp
actions/berrySeparator.cpp
actions/berrySubContributionItem.cpp
#application
application/berryActionBarAdvisor.cpp
application/berryIActionBarConfigurer.cpp
application/berryIWorkbenchConfigurer.cpp
application/berryIWorkbenchWindowConfigurer.cpp
application/berryWorkbenchAdvisor.cpp
application/berryWorkbenchWindowAdvisor.cpp
#commands
commands/berryICommandImageService.cpp
commands/berryICommandService.cpp
commands/berryIElementReference.h
commands/berryIElementUpdater.h
commands/berryIMenuService.h
commands/berryUIElement.cpp
#guitk
guitk/berryGuiTkControlEvent.cpp
guitk/berryGuiTkEvent.cpp
guitk/berryGuiTkIControlListener.cpp
guitk/berryGuiTkIMenuListener.cpp
guitk/berryGuiTkISelectionListener.cpp
guitk/berryGuiTkSelectionEvent.cpp
#handlers
handlers/berryHandlerUtil.cpp
handlers/berryIHandlerActivation.cpp
handlers/berryIHandlerService.cpp
handlers/berryRadioState.cpp
handlers/berryRegistryToggleState.cpp
handlers/berryShowViewHandler.cpp
handlers/berryToggleState.cpp
#intro
intro/berryIIntroManager.cpp
intro/berryIIntroPart.cpp
intro/berryIIntroSite.cpp
intro/berryIntroPart.cpp
#tweaklets
tweaklets/berryDnDTweaklet.cpp
tweaklets/berryGuiWidgetsTweaklet.cpp
- tweaklets/berryImageTweaklet.cpp
tweaklets/berryITracker.cpp
tweaklets/berryWorkbenchPageTweaklet.cpp
tweaklets/berryWorkbenchTweaklet.cpp
#presentations
presentations/berryIPresentablePart.cpp
presentations/berryIPresentationFactory.cpp
presentations/berryIPresentationSerializer.cpp
presentations/berryIStackPresentationSite.cpp
presentations/berryStackDropResult.cpp
presentations/berryStackPresentation.cpp
#services
services/berryIDisposable.cpp
services/berryIEvaluationReference.h
services/berryIEvaluationService.cpp
services/berryINestable.cpp
services/berryIServiceFactory.cpp
services/berryIServiceLocator.cpp
services/berryIServiceScopes.cpp
services/berryIServiceWithSources.cpp
services/berryISourceProviderService.cpp
#testing
testing/berryTestableObject.cpp
#util
util/berryISafeRunnableRunner.cpp
util/berrySafeRunnable.cpp
# application
application/berryQtWorkbenchAdvisor.cpp
)
set(INTERNAL_CPP_FILES
defaultpresentation/berryEmptyTabFolder.cpp
defaultpresentation/berryEmptyTabItem.cpp
defaultpresentation/berryNativeTabFolder.cpp
defaultpresentation/berryNativeTabItem.cpp
defaultpresentation/berryQCTabBar.cpp
defaultpresentation/berryQtWorkbenchPresentationFactory.cpp
util/berryAbstractTabFolder.cpp
util/berryAbstractTabItem.cpp
util/berryIPresentablePartList.cpp
util/berryLeftToRightTabOrder.cpp
util/berryPartInfo.cpp
util/berryPresentablePartFolder.cpp
util/berryReplaceDragHandler.cpp
util/berryTabbedStackPresentation.cpp
util/berryTabDragHandler.cpp
util/berryTabFolderEvent.cpp
util/berryTabOrder.cpp
#intro
intro/berryEditorIntroAdapterPart.cpp
intro/berryIIntroDescriptor.cpp
intro/berryIIntroRegistry.cpp
intro/berryIntroConstants.cpp
intro/berryIntroDescriptor.cpp
intro/berryIntroPartAdapterSite.cpp
intro/berryIntroRegistry.cpp
intro/berryViewIntroAdapterPart.cpp
intro/berryWorkbenchIntroManager.cpp
berryAbstractMenuAdditionCacheEntry.cpp
berryAbstractPartSelectionTracker.cpp
berryAbstractSelectionService.cpp
berryActivePartExpression.cpp
berryAlwaysEnabledExpression.cpp
berryAndExpression.cpp
berryBundleUtility.cpp
berryCommandContributionItemParameter.cpp
berryCommandParameter.cpp
berryCommandPersistence.cpp
berryCommandService.cpp
berryCommandServiceFactory.cpp
berryCommandStateProxy.cpp
berryCompositeExpression.cpp
berryContainerPlaceholder.cpp
berryContributionRoot.cpp
berryDetachedPlaceHolder.cpp
berryDefaultSaveable.cpp
berryDefaultStackPresentationSite.cpp
berryDetachedWindow.cpp
berryDragUtil.cpp
berryEditorAreaHelper.cpp
berryEditorDescriptor.cpp
berryEditorManager.cpp
berryEditorReference.cpp
berryEditorRegistry.cpp
berryEditorRegistryReader.cpp
berryEditorSashContainer.cpp
berryEditorSite.cpp
berryElementReference.cpp
berryErrorViewPart.cpp
berryEvaluationAuthority.cpp
berryEvaluationReference.cpp
berryEvaluationResultCache.cpp
berryEvaluationService.cpp
berryExpressionAuthority.cpp
berryFileEditorMapping.cpp
berryFolderLayout.cpp
berryHandlerActivation.cpp
berryHandlerAuthority.cpp
berryHandlerPersistence.cpp
berryHandlerProxy.cpp
berryHandlerService.cpp
berryHandlerServiceFactory.cpp
berryIDragOverListener.cpp
berryIDropTarget.cpp
berryIEvaluationResultCache.cpp
berryILayoutContainer.cpp
berryInternalMenuService.h
berryIServiceLocatorCreator.cpp
berryIStickyViewManager.cpp
berryIWorkbenchLocationService.cpp
berryLayoutHelper.cpp
berryLayoutPart.cpp
berryLayoutPartSash.cpp
berryLayoutTree.cpp
berryLayoutTreeNode.cpp
berryMenuServiceFactory.cpp
berryMMMenuListener.cpp
berryNestableHandlerService.cpp
berryNullEditorInput.cpp
berryPageLayout.cpp
berryPagePartSelectionTracker.cpp
berryPageSelectionService.cpp
berryParameterValueConverterProxy.cpp
berryPartList.cpp
berryPartPane.cpp
berryPartPlaceholder.cpp
berryPartSashContainer.cpp
berryPartService.cpp
berryPartSite.cpp
berryPartStack.cpp
berryPartTester.cpp
berryPersistentState.cpp
berryPerspective.cpp
berryPerspectiveDescriptor.cpp
berryPerspectiveExtensionReader.cpp
berryPerspectiveHelper.cpp
berryPerspectiveRegistry.cpp
berryPerspectiveRegistryReader.cpp
berryPlaceholderFolderLayout.cpp
berryPreferenceConstants.cpp
berryPresentablePart.cpp
berryPresentationFactoryUtil.cpp
berryPresentationSerializer.cpp
berryQtControlWidget.cpp
berryQtDnDControlWidget.cpp
berryQtDisplay.cpp
berryQtDnDTweaklet.cpp
- berryQtFileImageDescriptor.cpp
berryQtGlobalEventFilter.cpp
- berryQtIconImageDescriptor.cpp
- berryQtImageTweaklet.cpp
berryQtMainWindowControl.cpp
- berryQtMissingImageDescriptor.cpp
berryQtOpenPerspectiveAction.cpp
berryQtPerspectiveSwitcher.cpp
berryQtSafeApplication.cpp
berryQtSash.cpp
berryQtShell.cpp
berryQtShowViewAction.cpp
berryQtShowViewDialog.cpp
berryQtStyleManager.cpp
berryQtStylePreferencePage.cpp
berryQtTracker.cpp
berryQtWidgetController.cpp
berryQtWidgetsTweaklet.cpp
berryQtWidgetsTweakletImpl.cpp
berryQtWorkbenchPageTweaklet.cpp
berryQtWorkbenchTweaklet.cpp
berryRegistryPersistence.cpp
berryRegistryReader.cpp
berrySaveablesList.cpp
berryShowViewMenu.cpp
berryServiceLocator.cpp
berryServiceLocatorCreator.cpp
berryShellPool.cpp
berrySlaveCommandService.cpp
berrySlaveHandlerService.cpp
berrySlaveMenuService.cpp
berrySourceProviderService.cpp
berrySourcePriorityNameMapping.cpp
berryStatusUtil.cpp
berryStickyViewDescriptor.cpp
berryStickyViewManager.cpp
berryTweaklets.cpp
berryUtil.cpp
berryViewDescriptor.cpp
berryViewFactory.cpp
berryViewLayout.cpp
berryViewReference.cpp
berryViewRegistry.cpp
berryViewRegistryReader.cpp
berryViewSashContainer.cpp
berryViewSite.cpp
berryWorkbenchPage.cpp
berryWindowManager.cpp
berryWindowPartSelectionTracker.cpp
berryWindowSelectionService.cpp
berryWorkbench.cpp
berryWorkbenchConfigurer.cpp
berryWorkbenchConstants.cpp
berryWorkbenchLocationService.cpp
berryWorkbenchMenuService.cpp
berryWorkbenchPagePartList.cpp
berryWorkbenchPartReference.cpp
berryWorkbenchPlugin.cpp
berryWorkbenchRegistryConstants.cpp
berryWorkbenchServiceRegistry.cpp
berryWorkbenchSourceProvider.cpp
berryWorkbenchTestable.cpp
berryWorkbenchWindow.cpp
berryWorkbenchWindowConfigurer.cpp
berryWorkbenchWindowExpression.cpp
berryWWinActionBars.cpp
berryWWinPartService.cpp
)
set(MOC_H_FILES
src/berryAbstractUICTKPlugin.h
src/berryEditorPart.h
src/berryQtSelectionProvider.h
src/berryViewPart.h
src/berryWorkbenchPart.h
src/actions/berryCommandContributionItem.h
src/intro/berryIntroPart.h
src/handlers/berryShowViewHandler.h
src/internal/berryCommandServiceFactory.h
src/internal/berryHandlerServiceFactory.h
src/internal/berryMenuServiceFactory.h
src/internal/berryMMMenuListener.h
src/internal/berryQtDisplay.h
src/internal/berryQtDnDTweaklet.h
src/internal/berryQtGlobalEventFilter.h
- src/internal/berryQtImageTweaklet.h
src/internal/berryQtMainWindowControl.h
src/internal/berryQtOpenPerspectiveAction.h
src/internal/berryQtPerspectiveSwitcher.h
src/internal/berryQtSash.h
src/internal/berryQtShowViewAction.h
src/internal/berryQtStyleManager.h
src/internal/berryQtStylePreferencePage.h
src/internal/berryQtTracker.h
src/internal/berryQtWidgetsTweaklet.h
src/internal/berryQtWidgetsTweakletImpl.h
src/internal/berryQtWorkbenchTweaklet.h
src/internal/berryQtWorkbenchPageTweaklet.h
src/internal/berryWorkbenchPlugin.h
src/internal/berryWorkbenchSourceProvider.h
src/internal/defaultpresentation/berryNativeTabFolder.h
src/internal/defaultpresentation/berryNativeTabItem.h
src/internal/defaultpresentation/berryQCTabBar.h
src/internal/defaultpresentation/berryQtWorkbenchPresentationFactory.h
src/internal/intro/berryEditorIntroAdapterPart.h
)
set(UI_FILES
src/internal/berryQtShowViewDialog.ui
src/internal/berryQtStylePreferencePage.ui
src/internal/berryQtStatusPart.ui
)
set(QRC_FILES
resources/org_blueberry_ui_qt.qrc
)
set(CACHED_RESOURCE_FILES
plugin.xml
)
set(CPP_FILES )
foreach(file ${SRC_CPP_FILES})
set(CPP_FILES ${CPP_FILES} src/${file})
endforeach(file ${SRC_CPP_FILES})
foreach(file ${INTERNAL_CPP_FILES})
set(CPP_FILES ${CPP_FILES} src/internal/${file})
endforeach(file ${INTERNAL_CPP_FILES})
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/actions/berryCommandContributionItem.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/actions/berryCommandContributionItem.cpp
index 014d771451..23e76d1407 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/actions/berryCommandContributionItem.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/actions/berryCommandContributionItem.cpp
@@ -1,736 +1,735 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryCommandContributionItem.h"
#include "berryIMenuService.h"
#include "berryICommandService.h"
#include "berryICommandImageService.h"
#include "berryIContributionManager.h"
#include "berryIElementReference.h"
#include "berryIElementUpdater.h"
#include "berryUIElement.h"
#include
#include
#include
#include
#include
#include
#include
-#include "../berryImageDescriptor.h"
#include "../berryDisplay.h"
#include "../berryAsyncRunnable.h"
#include "../handlers/berryIHandlerService.h"
#include "../services/berryIServiceLocator.h"
#include "../internal/berryCommandContributionItemParameter.h"
#include "../internal/berryWorkbenchPlugin.h"
#include
#include
#include
#include
namespace berry
{
ContributionItem::Modes CommandContributionItem::modes = ContributionItem::MODE_FORCE_TEXT;
//class CommandUIElementListener : public IUIElementListener
//{
//private:
// CommandContributionItem* item;
// public:
// CommandUIElementListener(CommandContributionItem* item);
// void UIElementDisposed(UIElement* item);
//void UIElementSelected(SmartPointer item);
//};
CommandContributionItem::CommandContributionItem(
const SmartPointer& contributionParameters)
: ContributionItem(contributionParameters->id)
, action(0)
, checkedState(false)
{
this->icon = contributionParameters->icon;
this->label = contributionParameters->label;
this->mnemonic = contributionParameters->mnemonic;
this->tooltip = contributionParameters->tooltip;
this->style = contributionParameters->style;
this->helpContextId = contributionParameters->helpContextId;
this->visibleEnabled = contributionParameters->visibleEnabled;
this->mode = contributionParameters->mode;
menuService = contributionParameters->serviceLocator->GetService();
commandService = contributionParameters->serviceLocator->GetService();
handlerService = contributionParameters->serviceLocator->GetService();
// bindingService = (IBindingService) contributionParameters.serviceLocator
// .getService(IBindingService.class);
this->CreateCommand(contributionParameters->commandId,
contributionParameters->parameters);
if (command)
{
try
{
class CommandUIElement : public UIElement
{
private:
CommandContributionItem* item;
public:
CommandUIElement(CommandContributionItem* item, IServiceLocator* serviceLocator)
: UIElement(serviceLocator), item(item) {}
void SetText(const QString& text)
{
item->SetText(text);
}
void SetToolTip(const QString& text)
{
item->SetToolTip(text);
}
void SetIcon(const QIcon& icon)
{
item->SetIcon(icon);
}
void SetChecked(bool checked)
{
item->SetChecked(checked);
}
void SetDropDownId(const QString& id)
{
item->dropDownMenuOverride = id;
}
};
UIElement::Pointer callback(new CommandUIElement(this,
contributionParameters->serviceLocator));
elementRef = commandService->RegisterElementForCommand(command, callback);
command->GetCommand()->AddCommandListener(this->GetCommandListener());
this->SetImages(contributionParameters->serviceLocator,
contributionParameters->iconStyle);
if (contributionParameters->helpContextId.isEmpty())
{
try
{
this->helpContextId = commandService->GetHelpContextId(
contributionParameters->commandId);
}
catch (const NotDefinedException& /*e*/)
{
// it's OK to not have a helpContextId
}
}
// IWorkbenchLocationService::Pointer wls = contributionParameters.serviceLocator
// ->GetService(IWorkbenchLocationService::GetManifestName()).Cast();
// const IWorkbench* workbench = wls->GetWorkbench();;
// if (workbench != 0 && !helpContextId.empty()) {
// this->workbenchHelpSystem = workbench->GetHelpSystem();
// }
}
catch (const NotDefinedException& /*e*/)
{
WorkbenchPlugin::Log(QString("Unable to register menu item \"") + this->GetId()
+ "\", command \"" + contributionParameters->commandId
+ "\" not defined");
}
}
}
QAction* CommandContributionItem::Fill(QMenu* parent, QAction* before)
{
if (!command)
{
return 0;
}
if (action || parent == 0)
{
return 0;
}
// Menus don't support the pulldown style
Style tmpStyle = style;
if (tmpStyle == STYLE_PULLDOWN)
tmpStyle = STYLE_PUSH;
QAction* item = 0;
if (before)
{
item = new QAction(icon, label, parent);
parent->insertAction(before, item);
}
else
{
item = parent->addAction(icon, label);
}
item->setData(QVariant::fromValue(Object::Pointer(this)));
item->setProperty("contributionItem", QVariant::fromValue(Object::Pointer(this)));
// if (workbenchHelpSystem != null)
// {
// workbenchHelpSystem.setHelp(item, helpContextId);
// }
connect(item, SIGNAL(triggered()), this, SLOT(HandleWidgetSelection()));
action = item;
this->Update();
this->UpdateIcons();
//bindingService.addBindingManagerListener(bindingManagerListener);
return item;
}
QAction *CommandContributionItem::Fill(QToolBar *parent, QAction *before)
{
if (!command)
{
return 0;
}
if (action || parent == 0)
{
return 0;
}
QAction* item = 0;
if (before)
{
item = parent->addAction(icon, label);
}
else
{
item = new QAction(icon, label, parent);
parent->insertAction(before, item);
}
item->setData(QVariant::fromValue(Object::Pointer(this)));
item->setProperty("contributionItem", QVariant::fromValue(Object::Pointer(this)));
//item->AddListener(this->GetItemListener());
action = item;
this->Update();
this->UpdateIcons();
//bindingService.addBindingManagerListener(bindingManagerListener);
return item;
}
void CommandContributionItem::Update()
{
this->Update(QString());
}
void CommandContributionItem::Update(const QString& /*id*/)
{
if (action)
{
QWidget* parent = action->parentWidget();
if(qobject_cast(parent))
{
this->UpdateMenuItem();
}
else if (qobject_cast(parent))
{
this->UpdateMenuItem();
}
else if (qobject_cast(parent))
{
this->UpdateToolItem();
}
}
}
void CommandContributionItem::UpdateMenuItem()
{
QString text = label;
if (text.isEmpty())
{
if (command.IsNotNull())
{
try
{
text = command->GetCommand()->GetName();
}
catch (const NotDefinedException& e)
{
// StatusManager.getManager().handle(
// StatusUtil.newStatus(IStatus.ERROR,
// "Update item failed "
// + getId(), e));
BERRY_ERROR << "Update item failed " << GetId() << e.what();
}
}
}
text = UpdateMnemonic(text);
// String keyBindingText = null;
// if (command != null)
// {
// TriggerSequence binding = bindingService
// .getBestActiveBindingFor(command);
// if (binding != null)
// {
// keyBindingText = binding.format();
// }
// }
// if (text != null)
// {
// if (keyBindingText == null)
// {
// item.setText(text);
// }
// else
// {
// item.setText(text + '\t' + keyBindingText);
// }
// }
if (action->isChecked() != checkedState)
{
action->setChecked(checkedState);
}
// allow the handler update its enablement
bool shouldBeEnabled = IsEnabled();
if (action->isEnabled() != shouldBeEnabled)
{
action->setEnabled(shouldBeEnabled);
}
}
void CommandContributionItem::UpdateToolItem()
{
QString text = label;
QString tooltip = label;
if (text.isNull())
{
if (command.IsNotNull())
{
try
{
text = command->GetCommand()->GetName();
tooltip = command->GetCommand()->GetDescription();
if (tooltip.trimmed().isEmpty())
{
tooltip = text;
}
}
catch (const NotDefinedException& e)
{
// StatusManager.getManager().handle(
// StatusUtil.newStatus(IStatus.ERROR,
// "Update item failed "
// + getId(), e));
BERRY_ERROR << "Update item failed " << GetId() << e.what();
}
}
}
if ((icon.isNull() || (mode & MODE_FORCE_TEXT) == MODE_FORCE_TEXT)
&& !text.isNull())
{
action->setText(text);
}
QString toolTipText = GetToolTipText(tooltip);
action->setToolTip(toolTipText);
if (action->isChecked() != checkedState)
{
action->setChecked(checkedState);
}
// allow the handler update its enablement
bool shouldBeEnabled = IsEnabled();
if (action->isEnabled() != shouldBeEnabled)
{
action->setEnabled(shouldBeEnabled);
}
}
CommandContributionItem::~CommandContributionItem()
{
if (elementRef)
{
commandService->UnregisterElement(elementRef);
}
if (commandListener)
{
command->GetCommand()->RemoveCommandListener(commandListener.data());
}
}
bool CommandContributionItem::IsEnabled() const
{
if (command)
{
command->GetCommand()->SetEnabled(menuService->GetCurrentState());
return command->GetCommand()->IsEnabled();
}
return false;
}
bool CommandContributionItem::IsVisible() const
{
if (visibleEnabled)
{
return ContributionItem::IsVisible() && this->IsEnabled();
}
return ContributionItem::IsVisible();
}
void CommandContributionItem::SetImages(IServiceLocator* locator,
const QString& iconStyle)
{
if (icon.isNull())
{
ICommandImageService* service = locator->GetService();
if (service)
{
icon = service->GetImage(command->GetId(), iconStyle);
}
}
}
ICommandListener* CommandContributionItem::GetCommandListener()
{
if (!commandListener)
{
class MyCommandListener : public ICommandListener
{
private:
CommandContributionItem* item;
public:
MyCommandListener(CommandContributionItem* item)
: item(item)
{}
void CommandChanged(const SmartPointer& commandEvent)
{
if (commandEvent->IsHandledChanged() || commandEvent->IsEnabledChanged()
|| commandEvent->IsDefinedChanged())
{
item->UpdateCommandProperties(commandEvent);
}
}
};
commandListener.reset(new MyCommandListener(this));
}
return commandListener.data();
}
void CommandContributionItem::UpdateCommandProperties(const SmartPointer<
const CommandEvent> commandEvent)
{
if (commandEvent->IsHandledChanged())
{
dropDownMenuOverride = "";
}
if (!action)
{
return;
}
Display* display = Display::GetDefault();
typedef AsyncRunnable, CommandContributionItem > UpdateRunnable;
Poco::Runnable* update = new UpdateRunnable(this, &CommandContributionItem::UpdateCommandPropertiesInUI, commandEvent);
if (display->InDisplayThread())
{
update->run();
}
else
{
display->AsyncExec(update);
}
}
void CommandContributionItem::UpdateCommandPropertiesInUI(const SmartPointer<
const CommandEvent>& commandEvent)
{
if (commandEvent->GetCommand()->IsDefined())
{
this->Update();
}
if (commandEvent->IsEnabledChanged()
|| commandEvent->IsHandledChanged())
{
if (visibleEnabled)
{
IContributionManager* parent = this->GetParent();
if (parent)
{
parent->Update(true);
}
}
}
}
bool CommandContributionItem::ShouldRestoreAppearance(const SmartPointer& handler)
{
// if no handler or handler doesn't implement IElementUpdater,
// restore the contributed elements
if (handler.IsNull())
return true;
if (!(handler.Cast()))
return true;
// special case, if its HandlerProxy, then check the actual handler
// if (handler instanceof HandlerProxy) {
// HandlerProxy handlerProxy = (HandlerProxy) handler;
// IHandler actualHandler = handlerProxy.getHandler();
// return shouldRestoreAppearance(actualHandler);
// }
return false;
}
SmartPointer CommandContributionItem::GetCommand() const
{
return command;
}
void CommandContributionItem::CreateCommand(const QString &commandId,
const QHash ¶meters)
{
if (commandId.isEmpty())
{
// StatusManager.getManager().handle(StatusUtil.newStatus(IStatus.ERROR,
// "Unable to create menu item \"" + getId()
// + "\", no command id", null));
BERRY_ERROR << "Unable to create menu item \"" << this->GetId().toStdString()
<< "\", no command id";
return;
}
Command::Pointer cmd = commandService->GetCommand(commandId);
if (!cmd->IsDefined())
{
// StatusManager.getManager().handle(StatusUtil.newStatus(
// IStatus.ERROR, "Unable to create menu item \"" + getId()
// + "\", command \"" + commandId + "\" not defined", null));
BERRY_ERROR << "Unable to create menu item \"" << this->GetId().toStdString()
<< "\", command \"" << commandId.toStdString() << "\" not defined";
return;
}
command = ParameterizedCommand::GenerateCommand(cmd, parameters);
}
QString CommandContributionItem::GetToolTipText(const QString& text) const
{
QString tooltipText = tooltip;
if (tooltip.isNull())
{
if (!text.isNull())
{
tooltipText = text;
}
else
{
tooltipText = "";
}
}
// TriggerSequence activeBinding = bindingService
// .getBestActiveBindingFor(command);
// if (activeBinding != null && !activeBinding.isEmpty())
// {
// String acceleratorText = activeBinding.format();
// if (acceleratorText != null
// && acceleratorText.length() != 0)
// {
// tooltipText = NLS.bind(CommandMessages.Tooltip_Accelerator,
// tooltipText, acceleratorText);
// }
// }
return tooltipText;
}
QString CommandContributionItem::UpdateMnemonic(const QString &s)
{
if (mnemonic.isNull() || s.isEmpty())
{
return s;
}
int idx = s.indexOf(mnemonic);
if (idx == -1)
{
return s;
}
return s.left(idx) + '&' + s.mid(idx);
}
//SmartPointer CommandContributionItem::GetItemListener()
//{
// if (!itemListener)
// {
// itemListener = new CommandUIElementListener(this);
// }
// return itemListener;
//}
void CommandContributionItem::HandleWidgetSelection()
{
// // Special check for ToolBar dropdowns...
// if (this->OpenDropDownMenu(event))
// //return;
if ((style & STYLE_CHECK) != 0)
{
checkedState = action->isChecked();
}
try
{
handlerService->ExecuteCommand(command, UIElement::Pointer(0));
}
catch (const ExecutionException& e)
{
WorkbenchPlugin::Log("Failed to execute item " + GetId(), e);
}
catch (const NotDefinedException& e)
{
WorkbenchPlugin::Log("Failed to execute item " + GetId(), e);
}
catch (const NotEnabledException& e)
{
WorkbenchPlugin::Log("Failed to execute item " + GetId(), e);
}
catch (const NotHandledException& e)
{
WorkbenchPlugin::Log("Failed to execute item " + GetId(), e);
}
}
void CommandContributionItem::connectNotify(const char *signal)
{
qDebug() << "Connected to:" << signal;
}
void CommandContributionItem::disconnectNotify(const char *signal)
{
qDebug() << "Disconnected from:" << signal;
}
//TODO Tool item drop down menu contributions
//bool CommandContributionItem::OpenDropDownMenu(SmartPointer event)
//{
//Widget item = event.widget;
//if (item != null)
//{
// int style = item.getStyle();
// if ((style & SWT.DROP_DOWN) != 0)
// {
// if (event.detail == 4)
// { // on drop-down button
// ToolItem ti = (ToolItem) item;
//
// final MenuManager menuManager = new MenuManager();
// Menu menu = menuManager.createContextMenu(ti.getParent());
// if (workbenchHelpSystem != null)
// {
// workbenchHelpSystem.setHelp(menu, helpContextId);
// }
// menuManager.addMenuListener(new IMenuListener()
// {
// public void menuAboutToShow(IMenuManager manager)
// {
// String id = getId();
// if (dropDownMenuOverride != null)
// {
// id = dropDownMenuOverride;
// }
// menuService.populateContributionManager(
// menuManager, "menu:" + id); //$NON-NLS-1$
// }
// });
//
// // position the menu below the drop down item
// Point point = ti.getParent().toDisplay(
// new Point(event.x, event.y));
// menu.setLocation(point.x, point.y); // waiting for SWT
// // 0.42
// menu.setVisible(true);
// return true; // we don't fire the action
// }
// }
//}
//
//return false;
//}
void CommandContributionItem::SetIcon(const QIcon &icon)
{
this->icon = icon;
this->UpdateIcons();
}
void CommandContributionItem::UpdateIcons()
{
action->setIcon(icon);
}
void CommandContributionItem::SetText(const QString &text)
{
label = text;
this->Update();
}
void CommandContributionItem::SetChecked(bool checked)
{
if (checkedState == checked)
{
return;
}
checkedState = checked;
action->setChecked(checkedState);
}
void CommandContributionItem::SetToolTip(const QString &text)
{
tooltip = text;
action->setToolTip(text);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryAbstractUICTKPlugin.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryAbstractUICTKPlugin.cpp
index f856d850e6..74ba413dfe 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryAbstractUICTKPlugin.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryAbstractUICTKPlugin.cpp
@@ -1,281 +1,281 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; 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 "berryIPreferencesService.h"
#include "berryIPreferences.h"
#include
#include
namespace berry
{
const QString AbstractUICTKPlugin::FN_DIALOG_SETTINGS = "dialog_settings.xml";
AbstractUICTKPlugin::AbstractUICTKPlugin()
: preferencesService(0)
{
}
// IDialogSettings getDialogSettings() {
// if (dialogSettings == null) {
// loadDialogSettings();
// }
// return dialogSettings;
// }
// ImageRegistry getImageRegistry() {
// if (imageRegistry == null) {
// imageRegistry = createImageRegistry();
// initializeImageRegistry(imageRegistry);
// }
// return imageRegistry;
// }
IPreferencesService* AbstractUICTKPlugin::GetPreferencesService() const
{
// Create the preference store lazily.
if (preferencesService == 0)
{
ctkServiceReference serviceRef = m_Context->getServiceReference();
if (!serviceRef)
{
BERRY_ERROR << "Preferences service not available";
}
preferencesService = m_Context->getService(serviceRef);
}
return preferencesService;
}
SmartPointer AbstractUICTKPlugin::GetPreferences() const
{
IPreferencesService* prefService = this->GetPreferencesService();
if (prefService == NULL) return IPreferences::Pointer(0);
return prefService->GetSystemPreferences();
}
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)
{
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 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;
//}
Plugin::stop(context);
}
-SmartPointer AbstractUICTKPlugin::ImageDescriptorFromPlugin(
+QIcon AbstractUICTKPlugin::ImageDescriptorFromPlugin(
const QString& pluginId, const QString& imageFilePath)
{
if (pluginId.isEmpty() || imageFilePath.isEmpty())
{
throw ctkInvalidArgumentException("argument cannot be empty");
}
// if the plug-in is not ready then there is no image
QSharedPointer plugin = BundleUtility::FindPlugin(pluginId);
if (!BundleUtility::IsReady(plugin.data()))
{
- return ImageDescriptor::Pointer(0);
+ return QIcon();
}
QByteArray imgContent = plugin->getResource(imageFilePath);
QImage image = QImage::fromData(imgContent);
QPixmap pixmap = QPixmap::fromImage(image);
- QIcon* icon = new QIcon(pixmap);
- if (icon->isNull())
- return ImageDescriptor::Pointer(0);
+ return QIcon(pixmap);
+}
- return ImageDescriptor::CreateFromImage(icon);
+QIcon AbstractUICTKPlugin::GetMissingIcon()
+{
+ return QIcon(":/org.blueberry.ui.qt/icon_missing.png");
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryAbstractUICTKPlugin.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryAbstractUICTKPlugin.h
index 60ea407751..03656ca506 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryAbstractUICTKPlugin.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryAbstractUICTKPlugin.h
@@ -1,332 +1,294 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; 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
#include
namespace berry {
template class SmartPointer;
struct IPreferences;
struct IPreferencesService;
struct IWorkbench;
-struct ImageDescriptor;
-
/**
* \ingroup org_blueberry_ui_qt
*
* Abstract base class for plug-ins that integrate with the BlueBerry platform UI.
*
* Subclasses obtain the following capabilities:
*
*
* Preferences
*
*
The platform core runtime contains general support for plug-in
* preferences (org.blueberry.core.runtime.Preferences).
* This class provides appropriate conversion to the older JFace preference
* API (org.blueberry.jface.preference.IPreferenceStore).
*
The method getPreferenceStore returns the JFace preference
* store (cf. Plugin.getPluginPreferences which returns
* a core runtime preferences object.
*
Subclasses may reimplement initializeDefaultPreferences
* to set up any default values for preferences using JFace API. In this
* case, initializeDefaultPluginPreferences should not be
* overridden.
*
Subclasses may reimplement
* initializeDefaultPluginPreferences to set up any default
* values for preferences using core runtime API. In this
* case, initializeDefaultPreferences should not be
* overridden.
*
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.
*
* Dialogs
*
*
The dialog store is read the first time getDialogSettings
* is called.
*
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".
*
The dialog store is found in the file whose name is given by the
* constant FN_DIALOG_STORE. 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.
*
Plug-in code can call saveDialogSettings 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.
*
Dialog settings are also saved automatically on plug-in shutdown.
*
- * Images
- *
- *
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.
- *
*
* 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 getDefault
* method.
*
*
* See the description on {@link Plugin}.
*
*/
class BERRY_UI_QT AbstractUICTKPlugin : public Plugin
{
Q_OBJECT
private:
/**
* The name of the dialog settings file (value
* "dialog_settings.xml").
*/
static const QString FN_DIALOG_SETTINGS;
/**
* Storage for dialog and wizard data; null if not yet
* initialized.
*/
//DialogSettings dialogSettings = null;
/**
* Storage for preferences.
*/
mutable IPreferencesService* preferencesService;
- /**
- * The registry for all graphic images; null 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.
*
* Plug-in runtime classes are ctkPluginActivators 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.
*
* If an error occurs reading the dialog store, an empty one is quietly created
* and returned.
*
*
* Subclasses may override this method but are not expected to.
*
*
* @return the dialog settings
*/
// IDialogSettings getDialogSettings();
- /**
- * Returns the image registry for this UI plug-in.
- *
- * 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.
- *
- * Subclasses should reimplement initializeImageRegistry if they have
- * custom graphic images to load.
- *
- *
- * Subclasses may override this method but are not expected to.
- *
- *
- * @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.
*
* If an error occurs reading the preferences service, an empty preference service is
* quietly created, initialized with defaults, and returned.
*
*
* @return the preferences service
*/
IPreferencesService* GetPreferencesService() const;
SmartPointer GetPreferences() const;
/**
* Returns the Platform UI workbench.
*
* This method exists as a convenience for plugin implementors. The
* workbench can also be accessed by invoking PlatformUI.getWorkbench().
*
* @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.
*
* The default implementation of this method creates an empty registry.
* Subclasses may override this method if needed.
*
*
* @return ImageRegistry the resulting registry.
* @see #getImageRegistry
*/
// ImageRegistry createImageRegistry();
/**
* Initializes an image registry with images which are frequently used by the
* plugin.
*
* 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.
*
* 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.
*
* Subclasses may override this method to fill the image registry.
*
* @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.
*
* This framework method may be overridden, although this is typically
* unnecessary.
*
*/
// void loadDialogSettings();
/**
* Refreshes the actions for the plugin.
* This method is called from startup.
*
* This framework method may be overridden, although this is typically
* unnecessary.
*
*/
// void refreshPluginActions();
/**
* Saves this plug-in's dialog settings.
* Any problems which arise are silently ignored.
*/
// void saveDialogSettings();
public:
/**
* The AbstractUIPlugin implementation of this Plugin
* method refreshes the plug-in actions. Subclasses may extend this method,
* but must send super first.
*/
void start(ctkPluginContext* context);
/**
* The AbstractUIPlugin implementation of this Plugin
* 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 last. A try-finally statement should
* be used where necessary to ensure that super.shutdown() is
* always done.
*/
void stop(ctkPluginContext* context);
/**
* Creates and returns a new image descriptor for an image file located
* within the specified plug-in.
*
* 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".
*
*
* @param pluginId the id of the plug-in containing the image file;
* null 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 null if no image
* could be found
- * @since 3.0
*/
- static SmartPointer ImageDescriptorFromPlugin(
+ static QIcon ImageDescriptorFromPlugin(
const QString& pluginId, const QString& imageFilePath);
+ static QIcon GetMissingIcon();
};
} // namespace berry
#endif /*BERRYABSTRACTUICTKPLUGIN_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryEditorPart.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryEditorPart.cpp
index 753ac22d8b..bdc9c04a00 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryEditorPart.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryEditorPart.cpp
@@ -1,101 +1,100 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; 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
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 QString& description)
{
// if (compatibilityTitleListener != null)
// {
// removePropertyListener(compatibilityTitleListener);
// compatibilityTitleListener = null;
// }
WorkbenchPart::SetContentDescription(description);
}
void EditorPart::SetPartName(const QString& partName)
{
// if (compatibilityTitleListener != null)
// {
// removePropertyListener(compatibilityTitleListener);
// compatibilityTitleListener = null;
// }
WorkbenchPart::SetPartName(partName);
}
void EditorPart::CheckSite(IWorkbenchPartSite::Pointer site)
{
WorkbenchPart::CheckSite(site);
assert(!site.Cast().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();
}
QString 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.qt/src/berryIPerspectiveDescriptor.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIPerspectiveDescriptor.h
index 2ec27bd1df..f9582311c2 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIPerspectiveDescriptor.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIPerspectiveDescriptor.h
@@ -1,124 +1,122 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYIPERSPECTIVEDESCRIPTOR_H_
#define BERRYIPERSPECTIVEDESCRIPTOR_H_
#include
#include
#include
-#include "berryImageDescriptor.h"
-
namespace berry {
/**
* \ingroup org_blueberry_ui_qt
*
* A perspective descriptor describes a perspective in an
* IPerspectiveRegistry.
*
* A perspective is a template for view visibility, layout, and action visibility
* within a workbench page. There are two types of perspective: a predefined
* perspective and a custom perspective.
*
*
A predefined perspective is defined by an extension to the workbench's
* perspective extension point ("org.blueberry.ui.perspectives").
* The extension defines a id, label, and IPerspectiveFactory.
* A perspective factory is used to define the initial layout for a page.
*
*
A custom perspective is defined by the user. In this case a predefined
* perspective is modified to suit a particular task and saved as a new
* perspective. The attributes for the perspective are stored in a separate file
* in the workbench's metadata directory.
*
*
*
*
* Within a page the user can open any of the perspectives known
* to the workbench's perspective registry, typically by selecting one from the
* workbench's Open Perspective menu. When selected, the views
* and actions within the active page rearrange to reflect the perspective.
*
*
* This interface is not intended to be implemented by clients.
*
* @see IPerspectiveRegistry
* @noimplement This interface is not intended to be implemented by clients.
*/
struct BERRY_UI_QT IPerspectiveDescriptor : public Object
{
berryObjectMacro(berry::IPerspectiveDescriptor)
virtual ~IPerspectiveDescriptor();
/**
* Returns the description of this perspective.
* This is the value of its "description" attribute.
*
* @return the description
* @since 3.0
*/
virtual QString GetDescription() const = 0;
/**
* Returns this perspective's id. For perspectives declared via an extension,
* this is the value of its "id" attribute.
*
* @return the perspective id
*/
virtual QString 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;
+ virtual QIcon GetImageDescriptor() const = 0;
/**
* Returns this perspective's label. For perspectives declared via an extension,
* this is the value of its "label" attribute.
*
* @return the label
*/
virtual QString GetLabel() const = 0;
/**
* Returns true if this perspective is predefined by an
* extension.
*
* @return boolean whether this perspective is predefined by an extension
*/
virtual bool IsPredefined() const = 0;
/**
* Return the category path of this descriptor
*
* @return the category path of this descriptor
*/
virtual QStringList GetCategoryPath() const = 0;
virtual QStringList GetKeywordReferences() const = 0;
};
}
#endif /*BERRYIPERSPECTIVEDESCRIPTOR_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIViewDescriptor.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIViewDescriptor.h
index 9a99615885..3579329f94 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIViewDescriptor.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIViewDescriptor.h
@@ -1,106 +1,105 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYIVIEWDESCRIPTOR_H_
#define BERRYIVIEWDESCRIPTOR_H_
#include
#include "berryIWorkbenchPartDescriptor.h"
#include "berryIViewPart.h"
#include
#include
-#include "berryImageDescriptor.h"
namespace berry
{
/**
* \ingroup org_blueberry_ui_qt
*
* This is a view descriptor. It provides a "description" of a given
* given view so that the view can later be constructed.
*
* The view registry provides facilities to map from an extension
* to a IViewDescriptor.
*
*
* This interface is not intended to be implemented by clients.
*
*
* @see org.blueberry.ui.IViewRegistry
*/
struct BERRY_UI_QT IViewDescriptor : public IWorkbenchPartDescriptor, public IAdaptable
{
berryObjectMacro(berry::IViewDescriptor)
~IViewDescriptor();
/**
* Creates an instance of the view defined in the descriptor.
*
* @return the view part
* @throws CoreException thrown if there is a problem creating the part
*/
virtual IViewPart::Pointer CreateView() = 0;
virtual QStringList GetKeywordReferences() const = 0;
/**
* Returns an array of strings that represent
* view's category path. This array will be used
* for hierarchical presentation of the
* view in places like submenus.
* @return array of category tokens or null if not specified.
*/
virtual QStringList GetCategoryPath() const = 0;
/**
* Returns the description of this view.
*
* @return the description
*/
virtual QString GetDescription() const = 0;
/**
* Returns the descriptor for the icon to show for this view.
*/
- virtual SmartPointer GetImageDescriptor() const = 0;
+ virtual QIcon 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.qt/src/berryIWorkbenchPart.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIWorkbenchPart.h
index fb9327fe28..74a07dc062 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIWorkbenchPart.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIWorkbenchPart.h
@@ -1,270 +1,270 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; 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
#include "berryIPropertyChangeListener.h"
#include
namespace berry {
struct IWorkbenchPartSite;
/**
* \ingroup org_blueberry_ui_qt
*
* A workbench part is a visual component within a workbench page. There
* are two subtypes: view and editor, as defined by IViewPart and
* IEditorPart.
*
* 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.
*
* An editor is typically used to edit or browse a document or input object.
* The input is identified using an IEditorInput. Modifications made
* in an editor part follow an open-save-close lifecycle model.
*
* This interface may be implemented directly. For convenience, a base
* implementation is defined in WorkbenchPart.
*
* The lifecycle of a workbench part is as follows:
*
*
When a part extension is created:
*
*
instantiate the part
*
create a part site
*
call part.init(site)
*
*
When a part becomes visible in the workbench:
*
*
add part to presentation by calling
* part.createControl(parent) to create actual widgets
*
fire partOpened event to all listeners
*
*
*
When a part is activated or gets focus:
*
*
call part.setFocus()
*
fire partActivated event to all listeners
*
*
*
When a part is closed:
*
*
if save is needed, do save; if it fails or is canceled return
*
if part is active, deactivate part
*
fire partClosed event to all listeners
*
remove part from presentation; part controls are disposed as part
* of the SWT widget tree
*
call part.dispose()
*
*
*
*
*
* After createPartControl 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 IWorkbenchPart.dispose 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 SWTError will be thrown.
*
*
* The last method called on IWorkbenchPart is dispose.
* This signals the end of the part lifecycle.
*
*
* 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.
*
*
* Workbench parts implement the IAdaptable interface; extensions
* are managed by the platform's adapter manager.
*
*
* @see IViewPart
* @see IEditorPart
*/
struct BERRY_UI_QT IWorkbenchPart : public virtual Object { // public IAdaptable {
berryObjectMacro(berry::IWorkbenchPart)
virtual ~IWorkbenchPart();
/**
* The property id for getTitle, getTitleImage
* and getTitleToolTip.
*/
//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.
*
* The property ids are defined in {@link IWorkbenchPartConstants}.
*
*
* @param listener a property listener
*/
virtual void AddPropertyListener(IPropertyChangeListener* listener) = 0;
/**
* Creates the controls for this workbench part.
*
* Clients should not call this method (the workbench calls this method when
* it needs to, which may be never).
*
*
* For implementors this is a multi-step process:
*
*
Create one or more controls within the parent.
*
Set the parent layout as needed.
*
Register any global actions with the site's IActionBars.
*
Register any context menus with the site.
*
Register a selection provider with the site, to make it available to
* the workbench's ISelectionService (optional).
*
*
*
* @param parent the parent control
*/
virtual void CreatePartControl(void* parent) = 0;
/**
* Returns the site for this workbench part. The site can be
* null while the workbench part is being initialized. After
* the initialization is complete, this value must be non-null
* for the remainder of the part's life cycle.
*
* @return The part site; this value may be null if the part
* has not yet been initialized
*/
virtual SmartPointer 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 null)
*/
virtual QString 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 null)
*/
virtual QString GetContentDescription() const = 0;
/**
* Returns the title image of this workbench part. If this value changes
* the part must fire a property listener event with
* PROP_TITLE.
*
* 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 not dispose the returned image.
*
*
* @return the title image
*/
- virtual void* GetTitleImage() const = 0;
+ virtual QIcon 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
* PROP_TITLE.
*
* The tool tip text is used to populate the title bar of this part's
* visual container.
*
*
* @return the workbench part title tool tip (not null)
*/
virtual QString 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* listener) = 0;
/**
* Return the value for the arbitrary property key, or null.
*
* @param key
* the arbitrary property. Must not be null.
* @return the property value, or null.
*/
virtual QString GetPartProperty(const QString& key) const = 0;
/**
* Set an arbitrary property on the part. It is the implementor's
* responsibility to fire the corresponding PropertyChangeEvent.
*
* A default implementation has been added to WorkbenchPart.
*
*
* @param key
* the arbitrary property. Must not be null.
* @param value
* the property value. A null value will remove
* that property.
*/
virtual void SetPartProperty(const QString& key, const QString& 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 null.
*/
virtual const QHash& GetPartProperties() const = 0;
/**
* Asks this part to take focus within the workbench.
*
* Clients should not call this method (the workbench calls this method at
* appropriate times). To have the workbench activate a part, use
* IWorkbenchPage.activate(IWorkbenchPart) instead.
*
*/
virtual void SetFocus() = 0;
};
} // namespace berry
#endif /*IWORKBENCHPART_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIWorkbenchPartDescriptor.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIWorkbenchPartDescriptor.h
index cb1abba10d..46f1ba7532 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIWorkbenchPartDescriptor.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIWorkbenchPartDescriptor.h
@@ -1,71 +1,68 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; 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
#include
#include
-#include "berryImageDescriptor.h"
-
-
namespace berry
{
/**
* \ingroup org_blueberry_ui_qt
*
* Description of a workbench part. The part descriptor contains
* the information needed to create part instances.
*
* This interface is not intended to be implemented by clients.
*
*/
struct BERRY_UI_QT IWorkbenchPartDescriptor : public virtual Object
{
berryObjectMacro(berry::IWorkbenchPartDescriptor)
/**
* Returns the part id.
*
* @return the id of the part
*/
virtual QString 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 GetImageDescriptor() const = 0;
+ virtual QIcon GetImageDescriptor() const = 0;
/**
* Returns the label to show for this part.
*
* @return the part label
*/
virtual QString GetLabel() const = 0;
virtual ~IWorkbenchPartDescriptor();
};
} // namespace berry
#endif /*BERRYIWORKBENCHPARTDESCRIPTOR_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIWorkbenchPartReference.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIWorkbenchPartReference.h
index 5ac92dc8ed..bc2ab25bd3 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIWorkbenchPartReference.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIWorkbenchPartReference.h
@@ -1,152 +1,142 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; 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
#include
#include "berryIPropertyChangeListener.h"
namespace berry {
struct IWorkbenchPart;
struct IWorkbenchPage;
/**
* \ingroup org_blueberry_ui_qt
*
* 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;
*
* This interface is not intended to be implemented by clients.
*
*/
struct BERRY_UI_QT IWorkbenchPartReference : public Object
{
berryObjectMacro(berry::IWorkbenchPartReference)
~IWorkbenchPartReference();
- /**
- * Returns the IWorkbenchPart referenced by this object.
- * Returns null if the editors was not instantiated or
- * it failed to be restored. Tries to restore the editor
- * if restore is true.
- */
- virtual SmartPointer GetPart(bool restore) = 0;
-
-
- /**
- * @see IWorkbenchPart#getTitleImage
- */
- virtual void* GetTitleImage() = 0;
-
- /**
- * @see IWorkbenchPart#getTitleToolTip
- */
- virtual QString GetTitleToolTip() const = 0;
-
- /**
- * @see IWorkbenchPartSite#getId
- */
- virtual QString GetId() const = 0;
-
- /**
- * @see IWorkbenchPart#addPropertyListener
- */
- virtual void AddPropertyListener(IPropertyChangeListener* listener) = 0;
-
- /**
- * @see IWorkbenchPart#removePropertyListener
- */
- virtual void RemovePropertyListener(IPropertyChangeListener* listener) = 0;
-
- /**
- * Returns the workbench page that contains this part
- */
- virtual SmartPointer GetPage() const = 0;
-
- /**
- * Returns the name of the part, as it should be shown in tabs.
- *
- * @return the part name
- *
- * @since 3.0
- */
- virtual QString 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 QString 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 true if the part is dirty, false otherwise
- *
- * @since 3.2 (previously existed on IEditorReference)
- */
- virtual bool IsDirty() const = 0;
-
- /**
+ /**
+ * Returns the IWorkbenchPart referenced by this object.
+ * Returns null if the editors was not instantiated or
+ * it failed to be restored. Tries to restore the editor
+ * if restore is true.
+ */
+ virtual SmartPointer GetPart(bool restore) = 0;
+
+ /**
+ * @see IWorkbenchPart#getTitleImage
+ */
+ virtual QIcon GetTitleImage() const = 0;
+
+ /**
+ * @see IWorkbenchPart#getTitleToolTip
+ */
+ virtual QString GetTitleToolTip() const = 0;
+
+ /**
+ * @see IWorkbenchPartSite#getId
+ */
+ virtual QString GetId() const = 0;
+
+ /**
+ * @see IWorkbenchPart#addPropertyListener
+ */
+ virtual void AddPropertyListener(IPropertyChangeListener* listener) = 0;
+
+ /**
+ * @see IWorkbenchPart#removePropertyListener
+ */
+ virtual void RemovePropertyListener(IPropertyChangeListener* listener) = 0;
+
+ /**
+ * Returns the workbench page that contains this part
+ */
+ virtual SmartPointer GetPage() const = 0;
+
+ /**
+ * Returns the name of the part, as it should be shown in tabs.
+ *
+ * @return the part name
+ */
+ virtual QString GetPartName() const = 0;
+
+ /**
+ * Returns the content description for the part (or the empty string if none)
+ *
+ * @return the content description for the part
+ */
+ virtual QString 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 true if the part is dirty, false otherwise
+ */
+ 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 null.
*
* @param key
* The property to return. Must not be null.
* @return The String property, or null.
- * @since 3.3
*/
- virtual QString GetPartProperty(const QString& key) const = 0;
+ virtual QString GetPartProperty(const QString& key) const = 0;
- /**
+ /**
* Add a listener for changes in the arbitrary properties set.
*
* @param listener
* Must not be null.
- * @since 3.3
*/
- //virtual void addPartPropertyListener(IPropertyChangeListener listener) = 0;
+ //virtual void addPartPropertyListener(IPropertyChangeListener listener) = 0;
- /**
+ /**
* Remove a listener for changes in the arbitrary properties set.
*
* @param listener
* Must not be null.
- * @since 3.3
*/
- //virtual void removePartPropertyListener(IPropertyChangeListener listener) = 0;
+ //virtual void removePartPropertyListener(IPropertyChangeListener listener) = 0;
};
} // namespace berry
#endif /*BERRYIWORKBENCHPARTREFERENCE_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryImageDescriptor.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryImageDescriptor.cpp
deleted file mode 100644
index 1dd23c8151..0000000000
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryImageDescriptor.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-/*===================================================================
-
-BlueBerry Platform
-
-Copyright (c) German Cancer Research Center,
-Division of Medical and Biological Informatics.
-All rights reserved.
-
-This software is distributed WITHOUT ANY WARRANTY; 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 QString& filename, const QString& 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.qt/src/berryImageDescriptor.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryImageDescriptor.h
deleted file mode 100644
index 416bab4ac4..0000000000
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryImageDescriptor.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/*===================================================================
-
-BlueBerry Platform
-
-Copyright (c) German Cancer Research Center,
-Division of Medical and Biological Informatics.
-All rights reserved.
-
-This software is distributed WITHOUT ANY WARRANTY; 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
-#include
-
-#include
-
-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.
- *
- * 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.
- *
- *
- * @see org.eclipse.swt.graphics.Image
- */
-struct BERRY_UI_QT 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
- * returnMissingImageOnError is true, otherwise
- * 0 is returned.
- *
- * Note: Even if returnMissingImageOnError is true, it is
- * still possible for this method to return null in extreme
- * cases, for example if the underlying OS/GUI toolkit runs out of image handles.
- *
- *
- * @param returnMissingImageOnError
- * flag that determines if a default image is returned on error
- * @return the image or 0 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 pluginid, the
- * given filename is interpreted relative to the plugins base directory. If no pluginid
- * is given and filename 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 QString& filename, const QString& 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.qt/src/berrySaveable.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berrySaveable.h
index f2474129fa..235f7411f4 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berrySaveable.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berrySaveable.h
@@ -1,287 +1,286 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; 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
#include
#include
#include
-#include "berryImageDescriptor.h"
namespace berry {
struct IWorkbenchPage;
struct IWorkbenchPart;
/**
* A Saveable 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.
*
* Workbench parts that work in terms of saveables should implement
* {@link ISaveablesSource}.
*
*
* @see ISaveablesSource
*/
class BERRY_UI_QT Saveable : /*public InternalSaveable*/ public virtual Object, public IAdaptable
{
public:
berryObjectMacro(Saveable)
private:
//Cursor waitCursor;
//Cursor originalCursor;
public:
typedef QSet Set;
/**
* Attempts to show this saveable in the given page and returns
* true on success. The default implementation does nothing
* and returns false.
*
* @param page
* the workbench page in which to show this saveable
* @return true if this saveable is now visible to the user
* @since 3.3
*/
virtual bool Show(SmartPointer page);
/**
* Returns the name of this saveable for display purposes.
*
* @return the model's name; never null.
*/
virtual QString 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 null
*/
virtual QString GetToolTipText() const = 0;
/**
* Returns the image descriptor for this saveable.
*
* @return the image descriptor for this model; may be null
* if there is no image
*/
- virtual SmartPointer GetImageDescriptor() const = 0;
+ virtual QIcon GetImageDescriptor() const = 0;
/**
* Saves the contents of this saveable.
*
* If the save is cancelled through user action, or for any other reason,
* the part should invoke setCancelled on the
* IProgressMonitor to inform the caller.
*
*
* This method is long-running; progress and cancellation are provided by
* the given progress monitor.
*
*
* @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.
*
* Note: this method is called frequently, for example by actions to
* determine their enabled status.
*
*
* @return true if the contents have been modified and need
* saving, and false 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 Object* 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.
*
* 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:
*
*
*
* int PRIME = 31;
* int hash = ...; // compute the "normal" hash code, e.g. based on some identifier unique within the defining plug-in
* return hash * PRIME + MY_PLUGIN_ID.hashCode();
*
*
* @return a hash code
*/
virtual uint HashCode() const = 0;
/**
* 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.
*
* 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.
*
*
* If the foreground part of the save is cancelled through user action, or
* for any other reason, the part should invoke setCancelled
* on the IProgressMonitor to inform the caller. If the
* background part of the save is cancelled, the job should return a
* {@link IStatus#CANCEL} status.
*
*
* This method is long-running; progress and cancellation are provided by
* the given progress monitor.
*
*
* The default implementation of this method calls
* {@link #doSave(IProgressMonitor)} and returns null.
*
*
* @param monitor
* a progress monitor used for reporting progress and
* cancellation
* @param shellProvider
* an object that can provide a shell for parenting dialogs
* @return null 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
*
* 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 closing 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.
*
*
* The default implementation calls setEnabled(false) on the given parts'
* composites.
*
*
* @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 QList >& 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.
*
* The default implementation calls setEnabled(true) on the given parts'
* composites.
*
*
* @param parts
* the workbench parts containing this saveable
*
* @since 3.3
*/
virtual void EnableUI(QList >& parts);
protected:
/**
* This implementation of {@link IAdaptable#GetAdapterImpl(const std::type_info&)} returns
* null. 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 Object* GetAdapter(const QString& adapter);
};
}
#endif /* BERRYSAVEABLE_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryViewPart.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryViewPart.cpp
index 044c84b2e9..e19eb50797 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryViewPart.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryViewPart.cpp
@@ -1,64 +1,62 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; 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
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.
*
* 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().IsNull())
throw Poco::AssertionViolationException("The site for a view must be an IViewSite"); //$NON-NLS-1$
}
IViewSite::Pointer ViewPart::GetViewSite()
{
return this->GetSite().Cast();
}
} // namespace berry
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryWorkbenchPart.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryWorkbenchPart.cpp
index eabc3d183a..36fe6630ae 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryWorkbenchPart.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryWorkbenchPart.cpp
@@ -1,313 +1,290 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; 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 "berryIWorkbenchPartConstants.h"
-#include "berryImageDescriptor.h"
#include
#include
#include
#include "internal/berryWorkbenchPlugin.h"
#include
#include
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 QString& 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 QString& 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)
+void WorkbenchPart::SetTitleImage(const QIcon& titleImage)
{
//assert(titleImage == 0 || !titleImage.isDisposed());
//Do not send changes if they are the same
- if (this->m_TitleImage == titleImage)
+ if (this->m_TitleImage.cacheKey() == titleImage.cacheKey())
{
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 QString& 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 QString& partName)
{
InternalSetPartName(partName);
//setDefaultTitle();
}
void WorkbenchPart::SetContentDescription(const QString& description)
{
InternalSetContentDescription(description);
//setDefaultTitle();
}
void WorkbenchPart::FirePropertyChanged(const QString& key,
const QString& oldValue, const QString& 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* l)
{
partChangeEvents.AddListener(l);
}
void WorkbenchPart::RemovePropertyListener(IPropertyChangeListener* l)
{
partChangeEvents.RemoveListener(l);
}
void WorkbenchPart::SetPartProperty(const QString& key,
const QString& value)
{
QHash::iterator iter = partProperties.find(key);
QString oldValue;
if (iter != partProperties.end())
oldValue = iter.value();
if (value == "")
{
partProperties.remove(key);
}
else
{
partProperties.insert(key, value);
}
this->FirePropertyChanged(key, oldValue, value);
}
QString WorkbenchPart::GetPartProperty(const QString& key) const
{
QHash::const_iterator itr = partProperties.find(key);
if (itr == partProperties.end()) return "";
return itr.value();
}
const QHash &WorkbenchPart::GetPartProperties() const
{
return partProperties;
}
IWorkbenchPartSite::Pointer WorkbenchPart::GetSite() const
{
return this->m_PartSite;
}
QString WorkbenchPart::GetPartName() const
{
return this->m_PartName;
}
QString WorkbenchPart::GetContentDescription() const
{
return this->m_ContentDescription;
}
-void* WorkbenchPart::GetTitleImage() const
+QIcon WorkbenchPart::GetTitleImage() const
{
- if (this->m_TitleImage != 0)
- {
- return this->m_TitleImage;
- }
-
- return 0;
+ return this->m_TitleImage;
//return GetDefaultImage();
}
QString WorkbenchPart::GetTitleToolTip() const
{
return this->m_ToolTip;
}
void WorkbenchPart::SetInitializationData(const IConfigurationElement::Pointer& cfig,
const QString& /*propertyName*/, const Object::Pointer& /*data*/)
{
// Save config element.
m_ConfigElement = cfig;
// Part name and title.
m_PartName = cfig->GetAttribute("name");
m_Title = m_PartName;
// Icon.
QString strIcon = cfig->GetAttribute("icon");
if (strIcon.isEmpty())
{
return;
}
- m_ImageDescriptor = AbstractUICTKPlugin::ImageDescriptorFromPlugin(
+ m_TitleImage = AbstractUICTKPlugin::ImageDescriptorFromPlugin(
m_ConfigElement->GetContributor()->GetName(), 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.qt/src/berryWorkbenchPart.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryWorkbenchPart.h
index 3d82c13103..10b11760e0 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryWorkbenchPart.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryWorkbenchPart.h
@@ -1,257 +1,256 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; 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
#include
-#include "berryImageDescriptor.h"
+#include
namespace berry {
/**
* \ingroup org_blueberry_ui_qt
*
* Abstract base implementation of all workbench parts.
*
* This class is not intended to be subclassed by clients outside this
* package; clients should instead subclass ViewPart or
* EditorPart.
*
*
* @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_QT WorkbenchPart : public QObject,
public virtual IWorkbenchPart, public IExecutableExtension
{
Q_OBJECT
Q_INTERFACES(berry::IExecutableExtension);
public:
berryObjectMacro(WorkbenchPart)
~WorkbenchPart();
private:
QString m_Title;
- SmartPointer m_ImageDescriptor;
- void* m_TitleImage;
+ QIcon m_TitleImage;
QString m_ToolTip;
IConfigurationElement::Pointer m_ConfigElement;
IWorkbenchPartSite::Pointer m_PartSite;
QString m_PartName;
QString m_ContentDescription;
QHash partProperties;
IPropertyChangeListener::Events partChangeEvents;
void InternalSetContentDescription(const QString& description);
void InternalSetPartName(const QString& 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.
*
* Subclasses must invoke this method from IEditorPart.init
* and IViewPart.init.
*
* @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 null to clear
*/
- virtual void SetTitleImage(void* titleImage);
+ virtual void SetTitleImage(const QIcon& titleImage);
/**
* Sets or clears the title tool tip text of this part. Clients should
* call this method instead of overriding getTitleToolTip
*
* @param toolTip the new tool tip text, or null to clear
*/
virtual void SetTitleToolTip(const QString& 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 QString& 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 QString& description);
void FirePropertyChanged(const QString& key,
const QString& oldValue, const QString& newValue);
void FirePropertyChange(int propertyId);
public:
/* (non-Javadoc)
* Method declared on IWorkbenchPart.
*/
void AddPropertyListener(IPropertyChangeListener* l);
void RemovePropertyListener(IPropertyChangeListener* l);
void SetPartProperty(const QString& key, const QString& value);
/* (non-Javadoc)
* @see org.blueberry.ui.IWorkbenchPart3#getPartProperty(java.lang.String)
*/
QString GetPartProperty(const QString& key) const;
/* (non-Javadoc)
* @see org.blueberry.ui.IWorkbenchPart3#getPartProperties()
*/
const QHash& GetPartProperties() const;
/**
* {@inheritDoc}
* The WorkbenchPart implementation of this
* IExecutableExtension records the configuration element in
* and internal state variable (accessible via getConfigElement).
* 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(const IConfigurationElement::Pointer& cfig,
const QString& propertyName, const Object::Pointer& data);
/*
* Creates the controls for this workbench part.
*
* Subclasses must implement this method. For a detailed description of the
* requirements see IWorkbenchPart
*
*
* @param parent the parent control
* @see IWorkbenchPart
*/
virtual void CreatePartControl(void* parent) = 0;
/* (non-Javadoc)
* Asks this part to take focus within the workbench.
*
* Subclasses must implement this method. For a detailed description of the
* requirements see IWorkbenchPart
*
* It is considered bad practise to overload or extend this method.
* Parts should call setContentDescription to change their content description.
*
*/
QString GetContentDescription() const;
/* (non-Javadoc)
* Method declared on IWorkbenchPart.
*/
- void* GetTitleImage() const;
+ QIcon GetTitleImage() const;
/* (non-Javadoc)
* Gets the title tool tip text of this part.
*
* @return the tool tip text
*/
QString GetTitleToolTip() const;
};
} // namespace berry
#endif // __BERRY_WORKBENCH_PART_H__
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryCategory.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryCategory.h
index 6e37e62f03..0e432524de 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryCategory.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryCategory.h
@@ -1,185 +1,185 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; 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
#include
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.
*
* A category may specify its parent category in order to
* achieve hierarchy.
*
*/
template class Category : /*IWorkbenchAdapter*/public IAdaptable, public Object
{
public:
berryObjectMacro(Category)
typedef T ElementType;
/**
* Name of the miscellaneous category
*/
const static QString MISC_NAME;
/**
* Identifier of the miscellaneous category
*/
const static QString MISC_ID;
private:
QString id;
QString name;
QList parentPath;
QList elements;
IConfigurationElement::Pointer configurationElement;
public:
/**
* Creates an instance of Category as a
* miscellaneous category.
*/
Category();
/**
* Creates an instance of Category with
* an ID and label.
*
* @param id the unique identifier for the category
* @param label the presentation label for this category
*/
Category(const QString& id, const QString& label);
/**
* Creates an instance of Category using the
* information from the specified configuration element.
*
* @param configElement the IConfigurationElement containing
* the ID, label, and optional parent category path.
* @throws WorkbenchException if the ID or label is null GetImageDescriptor() const;
+ QIcon GetImageDescriptor() const;
/**
* Return the id for this category.
* @return the id
*/
const QString& GetId() const;
/**
* Return the label for this category.
*
* @return the label
*/
QString GetLabel() const;
/**
* Return the parent path for this category.
*
* @return the parent path
*/
QList GetParentPath();
/**
* Return the unparsed parent path. May be null.
*
* @return the unparsed parent path or null
*/
QString GetRawParentPath() const;
/**
* Return the root path for this category.
*
* @return the root path
*/
QString GetRootPath();
/**
* Return the elements contained in this category.
*
* @return the elements
*/
const QList& 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.
*/
Object* GetAdapter(const QString& adapter);
};
} // namespace berry
#include "berryCategory.txx"
#endif /*BERRYCATEGORY_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryDefaultSaveable.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryDefaultSaveable.cpp
index f22f2e62d5..91b5f4140f 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryDefaultSaveable.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryDefaultSaveable.cpp
@@ -1,123 +1,117 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; 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"
+
+#include
namespace berry
{
DefaultSaveable::DefaultSaveable(IWorkbenchPart::Pointer _part) :
part(_part)
{
}
void DefaultSaveable::DoSave(/*IProgressMonitor monitor*/)
{
IWorkbenchPart::Pointer _part(part);
if (_part.Cast () != 0)
{
_part.Cast ()->DoSave(/*monitor*/);
}
}
QString DefaultSaveable::GetName() const
{
return part.Lock()->GetPartName();
}
-ImageDescriptor::Pointer DefaultSaveable::GetImageDescriptor() const
+QIcon DefaultSaveable::GetImageDescriptor() const
{
- //TODO DefaultSaveable GetImageDescriptor
- // Image image = part.getTitleImage();
- // if (image == null)
- // {
- // return null;
- // }
- // return ImageDescriptor.createFromImage(image);
- return ImageDescriptor::Pointer(0);
+ return part.Lock()->GetTitleImage();
}
QString DefaultSaveable::GetToolTipText() const
{
return part.Lock()->GetTitleToolTip();
}
bool DefaultSaveable::IsDirty() const
{
IWorkbenchPart::Pointer _part(part);
if (_part.Cast () != 0)
{
return _part.Cast ()->IsDirty();
}
return false;
}
uint DefaultSaveable::HashCode() const
{
return part.Lock()->HashCode();
}
bool DefaultSaveable::operator<(const Object* obj) const
{
if (this == obj)
return false;
if (obj == 0)
return true;
const DefaultSaveable* other = dynamic_cast (obj);
if (other == NULL) return true;
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 () != 0)
{
IViewPart::Pointer viewPart = _part.Cast ();
try
{
page->ShowView(viewPart->GetViewSite()->GetId(),
viewPart->GetViewSite()->GetSecondaryId(),
IWorkbenchPage::VIEW_ACTIVATE);
} catch (const PartInitException& /*e*/)
{
return false;
}
return true;
}
return false;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryDefaultSaveable.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryDefaultSaveable.h
index 5b603210a0..25f2927d62 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryDefaultSaveable.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryDefaultSaveable.h
@@ -1,102 +1,102 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; 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 part;
public:
/**
* Creates a new DefaultSaveable.
*
* @param part
* the part represented by this model
*/
DefaultSaveable(SmartPointer 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()
*/
QString GetName() const;
/*
* (non-Javadoc)
*
* @see org.blueberry.ui.Saveable#getImageDescriptor()
*/
- SmartPointer GetImageDescriptor() const;
+ QIcon GetImageDescriptor() const;
/*
* (non-Javadoc)
*
* @see org.blueberry.ui.Saveable#getToolTipText()
*/
QString GetToolTipText() const;
/*
* (non-Javadoc)
*
* @see org.blueberry.ui.Saveable#isDirty()
*/
bool IsDirty() const;
/* (non-Javadoc)
* @see Object#HashCode()
*/
uint HashCode() const;
/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
bool operator<(const Object* obj) const;
/* (non-Javadoc)
* @see org.blueberry.ui.Saveable#show(org.blueberry.ui.IWorkbenchPage)
*/
bool Show(SmartPointer page);
};
}
#endif /* BERRYDEFAULTSAVEABLE_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryEditorDescriptor.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryEditorDescriptor.cpp
index 7ea5544777..4075bb64f5 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryEditorDescriptor.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryEditorDescriptor.cpp
@@ -1,422 +1,421 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; 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"
#include "berryIContributor.h"
namespace berry
{
const int EditorDescriptor::OPEN_INTERNAL = 0x01;
const int EditorDescriptor::OPEN_INPLACE = 0x02;
const int EditorDescriptor::OPEN_EXTERNAL = 0x04;
EditorDescriptor::EditorDescriptor(const QString& 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.
// QString className;
// if (!configurationElement->GetAttribute(IWorkbenchRegistryConstants::ATT_CONTRIBUTOR_CLASS, className))
// {
// return IEditorActionBarContributor::Pointer();
// }
//
// // Create the contributor object.
// IEditorActionBarContributor contributor;
// try
// {
// contributor = configurationElement->CreateExecutableExtension(
// IWorkbenchRegistryConstants::ATT_CONTRIBUTOR_CLASS);
// }
// catch (CoreException e)
// {
// WorkbenchPlugin::Log("Unable to create editor contributor: " + //$NON-NLS-1$
// id, e);
// }
// return contributor;
//}
QString 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 editorPart(configurationElement->CreateExecutableExtension (
WorkbenchRegistryConstants::ATT_CLASS));
return editorPart;
}
QString EditorDescriptor::GetFileName() const
{
//if (program == null)
//{
if (configurationElement.IsNull())
{
return fileName;
}
return configurationElement->GetAttribute(WorkbenchRegistryConstants::ATT_COMMAND);
//}
//return program.getName();
}
QString EditorDescriptor::GetId() const
{
//if (program == null)
//{
if (configurationElement.IsNull())
{
return id;
}
return configurationElement->GetAttribute(WorkbenchRegistryConstants::ATT_ID);
//}
//return Util.safeString(program.getName());
}
-SmartPointer EditorDescriptor::GetImageDescriptor() const
+QIcon EditorDescriptor::GetImageDescriptor() const
{
if (testImage)
{
testImage = false;
- if (!imageDesc)
+ if (imageDesc.isNull())
{
QString imageFileName(this->GetImageFilename());
QString command(this->GetFileName());
if (!imageFileName.isEmpty() && configurationElement)
{
imageDesc = AbstractUICTKPlugin::ImageDescriptorFromPlugin(
configurationElement->GetContributor()->GetName(), imageFileName);
}
else if (!command.isEmpty())
{
//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();
// }
// }
}
QString EditorDescriptor::GetImageFilename() const
{
if (!configurationElement)
{
return imageFilename;
}
return configurationElement->GetAttribute(WorkbenchRegistryConstants::ATT_ICON);
}
QString EditorDescriptor::GetLabel() const
{
//if (program == null)
//{
if (configurationElement.IsNull())
{
return editorName;
}
return configurationElement->GetAttribute(WorkbenchRegistryConstants::ATT_NAME);
//}
//return program.getName();
}
QString EditorDescriptor::GetLauncher() const
{
if (configurationElement.IsNull())
{
return launcherName;
}
return configurationElement->GetAttribute(WorkbenchRegistryConstants::ATT_LAUNCHER);
}
QString EditorDescriptor::GetPluginID() const
{
if (!configurationElement.IsNull())
{
return configurationElement->GetContributor()->GetName();
}
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 QString& newClassName)
{
className = newClassName;
}
void EditorDescriptor::SetConfigurationElement(
IConfigurationElement::Pointer newConfigurationElement)
{
configurationElement = newConfigurationElement;
}
void EditorDescriptor::SetFileName(const QString& aFileName)
{
fileName = aFileName;
}
void EditorDescriptor::SetID(const QString& anID)
{
id = anID;
}
void EditorDescriptor::SetLauncher(const QString& newLauncher)
{
launcherName = newLauncher;
}
void EditorDescriptor::SetName(const QString& newName)
{
editorName = newName;
}
void EditorDescriptor::SetOpenMode(int mode)
{
openMode = mode;
}
void EditorDescriptor::SetPluginIdentifier(const QString& anID)
{
pluginIdentifier = anID;
}
QString EditorDescriptor::ToString() const
{
return "EditorDescriptor(id=" + this->GetId() + ", label=" + this->GetLabel() + ")";
}
QString EditorDescriptor::GetLocalId() const
{
return this->GetId();
}
QString EditorDescriptor::GetPluginId() const
{
return this->GetPluginID();
}
IEditorMatchingStrategy::Pointer EditorDescriptor::GetEditorMatchingStrategy()
{
if (matchingStrategy.IsNull() && !matchingStrategyChecked)
{
matchingStrategyChecked = true;
if (/*program == null &&*/!configurationElement.IsNull())
{
QString strategy = configurationElement->GetAttribute(
WorkbenchRegistryConstants::ATT_MATCHING_STRATEGY);
if (!strategy.isEmpty())
{
try
{
matchingStrategy = configurationElement->CreateExecutableExtension<
IEditorMatchingStrategy> (
WorkbenchRegistryConstants::ATT_MATCHING_STRATEGY);
}
catch (const CoreException& e)
{
WorkbenchPlugin::Log(
"Error creating editor management policy for editor id "
+ this->GetId(), e);
}
}
}
}
return matchingStrategy;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryEditorDescriptor.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryEditorDescriptor.h
index f689c55c73..ecf2175994 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryEditorDescriptor.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryEditorDescriptor.h
@@ -1,390 +1,392 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; 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
+#include
+
namespace berry
{
struct IEditorPart;
/**
* \ingroup org_blueberry_ui_internal
*
* @see IEditorDescriptor
*/
class BERRY_UI_QT EditorDescriptor : public IEditorDescriptor
{ //, Serializable, IPluginContribution {
public:
berryObjectMacro(EditorDescriptor);
// @issue the following constants need not be public; see bug 47600
/**
* Open internal constant. Value 0x01.
*/
static const int OPEN_INTERNAL; // = 0x01;
/**
* Open in place constant. Value 0x02.
*/
static const int OPEN_INPLACE; // = 0x02;
/**
* Open external constant. Value 0x04.
*/
static const int OPEN_EXTERNAL; // = 0x04;
private:
QString editorName;
QString imageFilename;
- mutable SmartPointer imageDesc;
+ mutable QIcon imageDesc;
mutable bool testImage;
QString className;
QString launcherName;
QString fileName;
QString id;
bool matchingStrategyChecked;
IEditorMatchingStrategy::Pointer matchingStrategy;
//Program program;
//The id of the plugin which contributed this editor, null for external editors
QString 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 QString& 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 QString& 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 QString& 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 null
*/
//public: IEditorActionBarContributor::Pointer CreateActionBarContributor();
/**
* Return the editor class name.
*
* @return the class name
*/
public: QString GetEditorClassName() const;
/**
* Return the configuration element used to define this editor, or null.
*
* @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 CreateEditor();
/**
* Return the file name of the command to execute for this editor.
*
* @return the file name to execute
*/
public: QString GetFileName() const;
/**
* Return the id for this editor.
*
* @return the id
*/
public: QString GetId() const;
/**
* Return the image descriptor describing this editor.
*
* @return the image descriptor
*/
-public: SmartPointer GetImageDescriptor() const;
+public: QIcon 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: QString GetImageFilename() const;
/**
* Return the user printable label for this editor.
*
* @return the label
*/
public: QString GetLabel() const;
/**
* Returns the class name of the launcher.
*
* @return the launcher class name
*/
public: QString GetLauncher() const;
/**
* Return the contributing plugin id.
*
* @return the contributing plugin id
*/
public: QString 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 true if the values are valid, false 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 QString& 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 QString& 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 QString& 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 QString& aFileName) {
// imageFilename = aFileName;
// }
/**
* Sets the new launcher class name
*
* @param newLauncher the new launcher
*/
/* package */public: void SetLauncher(const QString& newLauncher);
/**
* The label to show for this editor.
*/
/* package */public: void SetName(const QString& 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 QString& 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: QString ToString() const;
/* (non-Javadoc)
* @see org.blueberry.ui.activities.support.IPluginContribution#getLocalId()
*/
public: QString GetLocalId() const;
/* (non-Javadoc)
* @see org.blueberry.ui.activities.support.IPluginContribution#getPluginId()
*/
public: QString 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.qt/src/internal/berryEditorReference.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryEditorReference.cpp
index c0f205d6b5..eb32bd3dc4 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryEditorReference.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryEditorReference.cpp
@@ -1,573 +1,572 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; 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/berryWorkbenchPageTweaklet.h"
#include "berryEditorReference.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 QString& id)
{
EditorDescriptor::Pointer desc;
IEditorRegistry* reg = WorkbenchPlugin::GetDefault()->GetEditorRegistry();
desc = reg->FindEditor(id).Cast ();
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);
}
QString 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 "";
}
QString EditorReference::ComputePartName() const
{
return WorkbenchPartReference::ComputePartName();
}
QString EditorReference::GetName()
{
if (part.IsNotNull())
{
return this->GetEditor(false)->GetEditorInput()->GetName();
}
return name;
}
IEditorPart::Pointer EditorReference::GetEditor(bool restore)
{
return this->GetPart(restore).Cast ();
}
void EditorReference::SetName(const QString& 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 ();
} 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(QString("Unable to create editor ID ") + this->GetId() + ": "
+ e.what());
// Pass the error to the status handling facility
//StatusManager.getManager().handle(logStatus);
EditorDescriptor::Pointer descr = this->GetDescriptor();
QString label = this->GetId();
if (descr.IsNotNull())
label = descr->GetLabel();
IEditorPart::Pointer part =
Tweaklets::Get(WorkbenchPageTweaklet::KEY)->CreateErrorEditorPart(label, e.what());
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 ();
}
}
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 ().IsNotNull())
{
IReusableEditor::Pointer editor = part.Cast ();
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 QString& string)
{
if (!reportedMalfunctioningEditor)
{
reportedMalfunctioningEditor = true;
QString 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.
QString 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 ();
// 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 ()->GetActiveEditorReference()
!= this)
{
//fireInternalPropertyChange(INTERNAL_PROPERTY_OPENED);
}
return part;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryPerspectiveDescriptor.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryPerspectiveDescriptor.cpp
index 9659589fd5..b16b321cc9 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryPerspectiveDescriptor.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryPerspectiveDescriptor.cpp
@@ -1,331 +1,333 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; 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"
#include "berryStatus.h"
#include "berryIContributor.h"
+#include
+
namespace berry
{
PerspectiveDescriptor::PerspectiveDescriptor(const QString& id,
const QString& 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 QString& id,
IConfigurationElement::Pointer configElement)
: singleton(false), fixed(false)
{
this->configElement = configElement;
this->id = id;
// Sanity check.
if ((this->GetId() == "") || (this->GetLabel() == "")
|| (this->GetFactoryClassName() == ""))
{
IStatus::Pointer status(new Status(
IStatus::ERROR_TYPE,
PlatformUI::PLUGIN_ID(),
0,
QString("Invalid extension (missing label, id or class name): ") + GetId()));
throw CoreException(status);
}
}
IPerspectiveFactory::Pointer PerspectiveDescriptor::CreateFactory()
{
// if there is an originalId, then use that descriptor instead
if (originalId != "")
{
// Get the original descriptor to create the factory. If the
// original is gone then nothing can be done.
IPerspectiveDescriptor::Pointer
target =
dynamic_cast (WorkbenchPlugin::GetDefault()->GetPerspectiveRegistry()) ->FindPerspectiveWithId(
originalId);
return target == 0 ? IPerspectiveFactory::Pointer(0) : target.Cast<
PerspectiveDescriptor> ()->CreateFactory();
}
// otherwise try to create the executable extension
if (configElement != 0)
{
try
{
IPerspectiveFactory::Pointer factory(
configElement ->CreateExecutableExtension (
WorkbenchRegistryConstants::ATT_CLASS));
return factory;
}
catch (const CoreException& /*e*/)
{
// do nothing
}
}
return IPerspectiveFactory::Pointer(0);
}
void PerspectiveDescriptor::DeleteCustomDefinition()
{
dynamic_cast (WorkbenchPlugin::GetDefault() ->GetPerspectiveRegistry())->DeleteCustomDefinition(
PerspectiveDescriptor::Pointer(this));
}
QString PerspectiveDescriptor::GetDescription() const
{
return configElement == 0 ? description : RegistryReader::GetDescription(
configElement);
}
void PerspectiveDescriptor::SetDescription(const QString& desc)
{
description = desc;
}
bool PerspectiveDescriptor::GetFixed() const
{
if (configElement == 0)
return fixed;
return configElement->GetAttribute(WorkbenchRegistryConstants::ATT_FIXED).compare("true", Qt::CaseInsensitive) == 0;
}
QStringList PerspectiveDescriptor::GetKeywordReferences() const
{
QStringList result;
if (configElement.IsNull())
{
return result;
}
auto keywordRefs = configElement->GetChildren("keywordReference");
for (auto keywordRefsIt = keywordRefs.begin();
keywordRefsIt != keywordRefs.end(); ++keywordRefsIt) // iterate over all refs
{
result.push_back((*keywordRefsIt)->GetAttribute("id"));
}
return result;
}
QString PerspectiveDescriptor::GetId() const
{
return id;
}
QString PerspectiveDescriptor::GetPluginId() const
{
return configElement == 0 ? pluginId : configElement->GetContributor()->GetName();
}
-ImageDescriptor::Pointer PerspectiveDescriptor::GetImageDescriptor() const
+QIcon PerspectiveDescriptor::GetImageDescriptor() const
{
- if (imageDescriptor)
+ if (!imageDescriptor.isNull())
return imageDescriptor;
if (configElement)
{
QString icon = configElement->GetAttribute(WorkbenchRegistryConstants::ATT_ICON);
if (!icon.isEmpty())
{
imageDescriptor = AbstractUICTKPlugin::ImageDescriptorFromPlugin(
configElement->GetContributor()->GetName(), icon);
}
}
- if (!imageDescriptor)
+ if (imageDescriptor.isNull())
{
- imageDescriptor = ImageDescriptor::GetMissingImageDescriptor();
+ imageDescriptor = AbstractUICTKPlugin::GetMissingIcon();
}
return imageDescriptor;
}
QStringList PerspectiveDescriptor::GetCategoryPath() const
{
if(!categoryPath.empty()) return categoryPath;
if (configElement.IsNotNull())
{
QString category = configElement->GetAttribute(WorkbenchRegistryConstants::TAG_CATEGORY);
categoryPath = category.split('/', QString::SkipEmptyParts);
}
return categoryPath;
}
QString PerspectiveDescriptor::GetLabel() const
{
if (configElement == 0)
return label;
return configElement->GetAttribute(WorkbenchRegistryConstants::ATT_NAME);
}
QString PerspectiveDescriptor::GetOriginalId() const
{
if (originalId == "")
{
return this->GetId();
}
return originalId;
}
bool PerspectiveDescriptor::HasCustomDefinition() const
{
return dynamic_cast (WorkbenchPlugin::GetDefault()->GetPerspectiveRegistry())->HasCustomDefinition(
PerspectiveDescriptor::ConstPointer(this));
}
bool PerspectiveDescriptor::HasDefaultFlag() const
{
if (configElement == 0)
{
return false;
}
return configElement->GetAttribute(WorkbenchRegistryConstants::ATT_DEFAULT).compare("true", Qt::CaseInsensitive) == 0;
}
bool PerspectiveDescriptor::IsPredefined() const
{
return this->GetFactoryClassName() != "" && configElement != 0;
}
bool PerspectiveDescriptor::IsSingleton() const
{
if (configElement == 0)
return singleton;
return configElement->GetAttribute(WorkbenchRegistryConstants::ATT_SINGLETON).compare("true", Qt::CaseInsensitive) == 0;
}
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.isEmpty())
{
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;
}
QString PerspectiveDescriptor::GetFactoryClassName() const
{
return configElement == 0 ? className : RegistryReader::GetClassValue(
configElement, WorkbenchRegistryConstants::ATT_CLASS);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryPerspectiveDescriptor.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryPerspectiveDescriptor.h
index 33e52434b2..7d2f0119cf 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryPerspectiveDescriptor.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryPerspectiveDescriptor.h
@@ -1,245 +1,246 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYPERSPECTIVEDESCRIPTOR_H_
#define BERRYPERSPECTIVEDESCRIPTOR_H_
#include
#include "berryIPerspectiveDescriptor.h"
#include "berryIPerspectiveFactory.h"
#include "berryIMemento.h"
#include
+#include
namespace berry {
/**
* \ingroup org_blueberry_ui_internal
*
* PerspectiveDescriptor.
*
* A PerspectiveDesciptor has 3 states:
*
*
*
It isPredefined(), in which case it was defined from an
* extension point.
*
It isPredefined() and hasCustomFile, in
* which case the user has customized a predefined perspective.
*
It hasCustomFile, in which case the user created a new
* perspective.
*
*
*/
class PerspectiveDescriptor : public IPerspectiveDescriptor {
public:
berryObjectMacro(PerspectiveDescriptor);
private:
QString id;
QString pluginId;
QString originalId;
QString label;
QString className;
QString description;
bool singleton;
bool fixed;
- mutable ImageDescriptor::Pointer imageDescriptor;
+ mutable QIcon imageDescriptor;
IConfigurationElement::Pointer configElement;
mutable QStringList categoryPath;
/**
* Create a new empty descriptor.
*
* @param id
* the id of the new descriptor
* @param label
* the label of the new descriptor
* @param originalDescriptor
* the descriptor that this descriptor is based on
*/
public: PerspectiveDescriptor(const QString& id, const QString& 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 QString& id, IConfigurationElement::Pointer configElement);
/**
* Creates a factory for a predefined perspective. If the perspective is not
* predefined return null.
*
* @return the IPerspectiveFactory or null
* @throws CoreException
* if the object could not be instantiated.
*/
public: IPerspectiveFactory::Pointer CreateFactory();
/**
* Deletes the custom definition for a perspective..
*/
public: void DeleteCustomDefinition();
/*
* (non-Javadoc)
*
* @see org.blueberry.ui.IPerspectiveDescriptor#getDescription()
*/
public: QString GetDescription() const;
public: void SetDescription(const QString& desc);
QStringList GetKeywordReferences() const;
/**
* Returns whether or not this perspective is fixed.
*
* @return whether or not this perspective is fixed
*/
public: bool GetFixed() const;
/*
* (non-Javadoc)
*
* @see org.blueberry.ui.IPerspectiveDescriptor#getId()
*/
public: QString GetId() const;
public: QString GetPluginId() const;
/*
* (non-Javadoc)
*
* @see org.blueberry.ui.IPerspectiveDescriptor#getImageDescriptor()
*/
- public: ImageDescriptor::Pointer GetImageDescriptor() const;
+ public: QIcon GetImageDescriptor() const;
/*
* (non-Javadoc)
*
* @see org.blueberry.ui.IPerspectiveDescriptor#getLabel()
*/
public: QString GetLabel() const;
/**
* Return the original id of this descriptor.
*
* @return the original id of this descriptor
*/
public: QString GetOriginalId() const;
/**
* Returns true if this perspective has a custom definition.
*
* @return whether this perspective has a custom definition
*/
public: bool HasCustomDefinition() const;
/**
* Returns true if this perspective wants to be default.
*
* @return whether this perspective wants to be default
*/
public: bool HasDefaultFlag() const;
/**
* Returns true if this perspective is predefined by an
* extension.
*
* @return boolean whether this perspective is predefined by an extension
*/
public: bool IsPredefined() const;
/**
* Returns true if this perspective is a singleton.
*
* @return whether this perspective is a singleton
*/
public: bool IsSingleton() const;
/**
* Restore the state of a perspective from a memento.
*
* @param memento
* the memento to restore from
* @return the IStatus of the operation
* @see org.blueberry.ui.IPersistableElement
*/
public: bool RestoreState(IMemento::Pointer memento);
/**
* Revert to the predefined extension template. Does nothing if this
* descriptor is user defined.
*/
public: void RevertToPredefined();
/**
* Save the state of a perspective to a memento.
*
* @param memento
* the memento to restore from
* @return the IStatus of the operation
* @see org.blueberry.ui.IPersistableElement
*/
public: bool SaveState(IMemento::Pointer memento);
/**
* Return the configuration element used to create this perspective, if one
* was used.
*
* @return the configuration element used to create this perspective
* @since 3.0
*/
public: IConfigurationElement::Pointer GetConfigElement() const;
/**
* Returns the factory class name for this descriptor.
*
* @return the factory class name for this descriptor
* @since 3.1
*/
public: QString GetFactoryClassName() const;
/**
* Return the category path of this descriptor
*
* @return the category path of this descriptor
*/
public: QStringList GetCategoryPath() const;
};
}
#endif /*BERRYPERSPECTIVEDESCRIPTOR_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryPresentablePart.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryPresentablePart.cpp
index 0c255fd5c0..be77a816cc 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryPresentablePart.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryPresentablePart.cpp
@@ -1,316 +1,316 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; 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
namespace berry
{
PresentablePart::
PropertyListenerProxy::PropertyListenerProxy(PresentablePart* p)
: part(p)
{
}
void
PresentablePart::
PropertyListenerProxy::PropertyChange(const 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* PresentablePart::GetPropertyListenerProxy()
{
if (lazyPropertyListenerProxy == 0)
{
lazyPropertyListenerProxy.reset(new PropertyListenerProxy(this));
}
return lazyPropertyListenerProxy.data();
}
WorkbenchPartReference::Pointer PresentablePart::GetPartReference() const
{
return part->GetPartReference().Cast();
}
void PresentablePart::FirePropertyChange(const 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* listener)
{
partPropertyChangeEvents.AddListener(listener);
}
void PresentablePart::RemovePropertyListener(IPropertyChangeListener* 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();
}
}
}
QString PresentablePart::GetName() const
{
if (enableOutputs)
{
return this->GetPartReference()->GetPartName();
}
return name;
}
QString PresentablePart::GetTitle() const
{
return this->GetPartReference()->GetPartName();
}
QString PresentablePart::GetTitleStatus() const
{
if (enableOutputs)
{
return this->GetPartReference()->GetContentDescription();
}
return titleStatus;
}
-void* PresentablePart::GetTitleImage()
+QIcon PresentablePart::GetTitleImage()
{
if (enableOutputs)
{
return this->GetPartReference()->GetTitleImage();
}
// return PlatformUI.getWorkbench().getSharedImages().getImage(
// ISharedImages.IMG_DEF_VIEW);
- return 0;
+ return QIcon();
}
QString 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);
}
}
QString PresentablePart::GetPartProperty(const QString& 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.qt/src/internal/berryPresentablePart.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryPresentablePart.h
index e536dcf272..9e30b854a0 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryPresentablePart.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryPresentablePart.h
@@ -1,266 +1,266 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; 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);
+ berryObjectMacro(PresentablePart)
private:
SmartPointer 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.
QScopedPointer 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)
QString name;
QString titleStatus;
bool isDirty;
bool isBusy;
bool hasViewMenu;
struct PropertyListenerProxy: public IPropertyChangeListener
{
PropertyListenerProxy(PresentablePart* part);
using IPropertyChangeListener::PropertyChange;
void PropertyChange(const PropertyChangeEvent::Pointer& e);
private:
PresentablePart* part;
};
friend struct PropertyListenerProxy;
IPropertyChangeListener* GetPropertyListenerProxy();
WorkbenchPartReference::Pointer GetPartReference() const;
protected:
void FirePropertyChange(int propId);
void FirePropertyChange(const PropertyChangeEvent::Pointer& event);
public:
/**
* Constructor
*
* @param part
*/
PresentablePart(SmartPointer part, void* parent);
SmartPointer 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* listener);
void RemovePropertyListener(IPropertyChangeListener* 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()
*/
QString GetName() const;
/* (non-Javadoc)
* @see org.blueberry.ui.presentations.IPresentablePart#getTitle()
*/
QString GetTitle() const;
/* (non-Javadoc)
* @see org.blueberry.ui.presentations.IPresentablePart#getTitleStatus()
*/
QString GetTitleStatus() const;
/*
* (non-Javadoc)
*
* @see org.blueberry.ui.presentations.IPresentablePart#getTitleImage()
*/
- void* GetTitleImage();
+ QIcon GetTitleImage();
/*
* (non-Javadoc)
*
* @see org.blueberry.ui.presentations.IPresentablePart#getTitleToolTip()
*/
QString 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)
*/
QString GetPartProperty(const QString& 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.qt/src/internal/berryQtFileImageDescriptor.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtFileImageDescriptor.cpp
deleted file mode 100755
index f7ccde3bc5..0000000000
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtFileImageDescriptor.cpp
+++ /dev/null
@@ -1,99 +0,0 @@
-/*===================================================================
-
-BlueBerry Platform
-
-Copyright (c) German Cancer Research Center,
-Division of Medical and Biological Informatics.
-All rights reserved.
-
-This software is distributed WITHOUT ANY WARRANTY; 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
-
-#include
-#include
-#include
-
-namespace berry
-{
-
-QtFileImageDescriptor::QtFileImageDescriptor(const QString& filename,
- const QString& pluginid) :
- filename(filename), pluginid(pluginid)
-{
-
-}
-
-void* QtFileImageDescriptor::CreateImage(bool returnMissingImageOnError)
-{
- if (pluginid.isEmpty())
- {
- QFile f(filename);
- if (f.open(QFile::ReadOnly))
- {
- QByteArray ba = f.readAll();
- return this->CreateFromByteArray(ba);
- }
- else
- {
- BERRY_ERROR << "Could not open file: " << filename;
- if (returnMissingImageOnError)
- return GetMissingImageDescriptor()->CreateImage();
-
- return 0;
- }
- }
- else
- {
- QSharedPointer plugin(Platform::GetCTKPlugin(pluginid));
- if (!plugin)
- {
- if (returnMissingImageOnError)
- return GetMissingImageDescriptor()->CreateImage();
-
- return 0;
- }
-
- QByteArray ba = plugin->getResource(filename);
- if (ba.isEmpty() && returnMissingImageOnError)
- return GetMissingImageDescriptor()->CreateImage();
-
- return this->CreateFromByteArray(ba);
- }
-}
-
-void QtFileImageDescriptor::DestroyImage(void* img)
-{
- const QIcon* icon = static_cast(img);
- delete icon;
-}
-
-QIcon* QtFileImageDescriptor::CreateFromByteArray(const QByteArray& ba)
-{
- QPixmap pixmap;
- pixmap.loadFromData(ba);
- QIcon* icon = new QIcon(pixmap);
- return icon;
-}
-
-bool QtFileImageDescriptor::operator ==(const Object* o) const
-{
- if (const QtFileImageDescriptor* obj = dynamic_cast(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
deleted file mode 100755
index 8411486291..0000000000
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtFileImageDescriptor.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*===================================================================
-
-BlueBerry Platform
-
-Copyright (c) German Cancer Research Center,
-Division of Medical and Biological Informatics.
-All rights reserved.
-
-This software is distributed WITHOUT ANY WARRANTY; 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
-
-class QIcon;
-
-namespace berry {
-
-class QtFileImageDescriptor : public ImageDescriptor
-{
-
-private:
-
- const QString filename;
- const QString pluginid;
-
- QIcon* CreateFromByteArray(const QByteArray& ba);
-
-public:
-
- QtFileImageDescriptor(const QString& filename, const QString& 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/berryQtIconImageDescriptor.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtIconImageDescriptor.cpp
deleted file mode 100755
index 896953d03c..0000000000
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtIconImageDescriptor.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-/*===================================================================
-
-BlueBerry Platform
-
-Copyright (c) German Cancer Research Center,
-Division of Medical and Biological Informatics.
-All rights reserved.
-
-This software is distributed WITHOUT ANY WARRANTY; 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
-
-namespace berry {
-
-QtIconImageDescriptor::QtIconImageDescriptor(void* img)
-: icon(static_cast(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(img);
- delete i;
-}
-
-bool QtIconImageDescriptor::operator ==(const Object* o) const
-{
- if (const QtIconImageDescriptor* obj = dynamic_cast(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
deleted file mode 100755
index 17df7909b0..0000000000
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtIconImageDescriptor.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*===================================================================
-
-BlueBerry Platform
-
-Copyright (c) German Cancer Research Center,
-Division of Medical and Biological Informatics.
-All rights reserved.
-
-This software is distributed WITHOUT ANY WARRANTY; 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
-
-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
deleted file mode 100755
index 99a86f9524..0000000000
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtImageTweaklet.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-/*===================================================================
-
-BlueBerry Platform
-
-Copyright (c) German Cancer Research Center,
-Division of Medical and Biological Informatics.
-All rights reserved.
-
-This software is distributed WITHOUT ANY WARRANTY; 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
-#include "berryQtFileImageDescriptor.h"
-#include "berryQtIconImageDescriptor.h"
-#include "berryQtMissingImageDescriptor.h"
-
-namespace berry {
-
-QtImageTweaklet::QtImageTweaklet()
-{
-
-}
-
-SmartPointer QtImageTweaklet::CreateFromFile(const QString& filename, const QString& pluginid)
-{
- ImageDescriptor::Pointer descriptor(new QtFileImageDescriptor(filename, pluginid));
- return descriptor;
-}
-
-SmartPointer QtImageTweaklet::CreateFromImage(void* img)
-{
- ImageDescriptor::Pointer descriptor(new QtIconImageDescriptor(img));
- return descriptor;
-}
-
-SmartPointer QtImageTweaklet::GetMissingImageDescriptor()
-{
- SmartPointer 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
deleted file mode 100755
index d47cc5c1f1..0000000000
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtImageTweaklet.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*===================================================================
-
-BlueBerry Platform
-
-Copyright (c) German Cancer Research Center,
-Division of Medical and Biological Informatics.
-All rights reserved.
-
-This software is distributed WITHOUT ANY WARRANTY; 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
-
-namespace berry {
-
-class QtImageTweaklet : public QObject, public ImageTweaklet
-{
- Q_OBJECT
- Q_INTERFACES(berry::ImageTweaklet)
-
-public:
-
- QtImageTweaklet();
-
- virtual SmartPointer CreateFromFile(const QString& filename, const QString& pluginid);
- virtual SmartPointer CreateFromImage(void* img);
- virtual SmartPointer GetMissingImageDescriptor();
-
- virtual void DestroyImage(const void* img);
-
-};
-
-}
-
-#endif /* BERRYQTIMAGETWEAKLET_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
deleted file mode 100755
index b8b9277638..0000000000
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtMissingImageDescriptor.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-/*===================================================================
-
-BlueBerry Platform
-
-Copyright (c) German Cancer Research Center,
-Division of Medical and Biological Informatics.
-All rights reserved.
-
-This software is distributed WITHOUT ANY WARRANTY; 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
-
-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(img);
- delete i;
-}
-
-bool QtMissingImageDescriptor::operator ==(const Object* o) const
-{
- return dynamic_cast(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
deleted file mode 100755
index 3975d07039..0000000000
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtMissingImageDescriptor.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*===================================================================
-
-BlueBerry Platform
-
-Copyright (c) German Cancer Research Center,
-Division of Medical and Biological Informatics.
-All rights reserved.
-
-This software is distributed WITHOUT ANY WARRANTY; 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
-
-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 e5ff98a458..aef61e1fff 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,61 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; 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
#include
#include
#include
namespace berry
{
QtOpenPerspectiveAction::QtOpenPerspectiveAction(
IWorkbenchWindow::Pointer window, IPerspectiveDescriptor::Pointer descr, QActionGroup* group) :
QAction(0),
window(window.GetPointer())
{
this->setParent(group);
this->setText(descr->GetLabel());
this->setToolTip(descr->GetLabel());
this->setCheckable(true);
this->setIconVisibleInMenu(true);
group->addAction(this);
- QIcon* icon = static_cast(descr->GetImageDescriptor()->CreateImage());
- this->setIcon(*icon);
- descr->GetImageDescriptor()->DestroyImage(icon);
+ QIcon icon = descr->GetImageDescriptor();
+ this->setIcon(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/berryQtShowViewAction.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtShowViewAction.cpp
index 19aace919f..12fe94ca27 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,59 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; 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
#include
namespace berry
{
QtShowViewAction::QtShowViewAction(IWorkbenchWindow::Pointer window,
IViewDescriptor::Pointer desc) :
QAction(0)
{
this->setParent(static_cast(window->GetShell()->GetControl()));
this->setText(desc->GetLabel());
this->setToolTip(desc->GetLabel());
this->setIconVisibleInMenu(true);
- QIcon* icon = static_cast(desc->GetImageDescriptor()->CreateImage());
- this->setIcon(*icon);
- desc->GetImageDescriptor()->DestroyImage(icon);
+ QIcon icon = desc->GetImageDescriptor();
+ this->setIcon(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 (const PartInitException& e)
{
BERRY_ERROR << "Error: " << e.what();
}
}
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryRegistryReader.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryRegistryReader.cpp
index 2079319136..0a3e3aa809 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryRegistryReader.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryRegistryReader.cpp
@@ -1,164 +1,163 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include
#include
#include
#include
#include "berryRegistryReader.h"
#include "berryWorkbenchPlugin.h"
#include "berryWorkbenchRegistryConstants.h"
-#include "berryImageDescriptor.h"
namespace {
bool CompareExtensionsByContributor(const berry::IExtension::Pointer& e1,
const berry::IExtension::Pointer& e2)
{
return e1->GetContributor()->GetName().compare(e2->GetContributor()->GetName(), Qt::CaseInsensitive) < 0;
}
}
namespace berry
{
RegistryReader::RegistryReader()
{
}
RegistryReader::~RegistryReader()
{
}
void RegistryReader::LogError(const IConfigurationElement::Pointer& element,
const QString& text)
{
IExtension::Pointer extension = element->GetDeclaringExtension();
QString buf = QString("Plugin ") + extension->GetContributor()->GetName() + ", extension "
+ extension->GetExtensionPointUniqueIdentifier();
// look for an ID if available - this should help debugging
QString id = element->GetAttribute("id");
if (!id.isEmpty())
{
buf.append(", id ");
buf.append(id);
}
buf.append(": " + text);
WorkbenchPlugin::Log(buf);
}
void RegistryReader::LogMissingAttribute(
const IConfigurationElement::Pointer& element, const QString& attributeName)
{
RegistryReader::LogError(element, "Required attribute '" + attributeName + "' not defined");
}
void RegistryReader::LogMissingElement(
const IConfigurationElement::Pointer& element, const QString& elementName)
{
RegistryReader::LogError(element, "Required sub element '" + elementName + "' not defined");
}
void RegistryReader::LogUnknownElement(
const IConfigurationElement::Pointer& element)
{
RegistryReader::LogError(element, "Unknown extension tag found: " + element->GetName());
}
QList RegistryReader::OrderExtensions(
const QList& 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.
QList sortedExtension(extensions);
qStableSort(sortedExtension.begin(), sortedExtension.end(),
CompareExtensionsByContributor);
return sortedExtension;
}
void RegistryReader::ReadElementChildren(
const IConfigurationElement::Pointer& element)
{
this->ReadElements(element->GetChildren());
}
void RegistryReader::ReadElements(
const QList& elements)
{
for (int i = 0; i < elements.size(); i++)
{
if (!this->ReadElement(elements[i]))
{
RegistryReader::LogUnknownElement(elements[i]);
}
}
}
void RegistryReader::ReadExtension(const IExtension::Pointer& extension)
{
this->ReadElements(extension->GetConfigurationElements());
}
void RegistryReader::ReadRegistry(
const QString& pluginId, const QString& extensionPoint)
{
IExtensionPoint::Pointer point = Platform::GetExtensionRegistry()->GetExtensionPoint(pluginId + "." + extensionPoint);
if (point == 0)
{
return;
}
QList extensions(point->GetExtensions());
extensions = this->OrderExtensions(extensions);
for (int i = 0; i < extensions.size(); i++)
{
this->ReadExtension(extensions[i]);
}
}
QString RegistryReader::GetDescription(const IConfigurationElement::Pointer& configElement)
{
QList children(configElement->GetChildren(WorkbenchRegistryConstants::TAG_DESCRIPTION));
if (children.size() >= 1)
{
return children[0]->GetValue();
}
return "";
}
QString RegistryReader::GetClassValue(
const IConfigurationElement::Pointer& configElement,
const QString& classAttributeName)
{
QString className = configElement->GetAttribute(classAttributeName);
if (!className.isEmpty())
{
return className;
}
QList candidateChildren(configElement->GetChildren(classAttributeName));
if (candidateChildren.isEmpty())
{
return "";
}
return candidateChildren[0]->GetAttribute(WorkbenchRegistryConstants::ATT_CLASS);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berrySaveablesList.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berrySaveablesList.cpp
index fbceea83cf..23a64826da 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berrySaveablesList.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berrySaveablesList.cpp
@@ -1,633 +1,632 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; 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(
QHash& referenceMap, Saveable::Pointer key)
{
bool result = false;
int& refCount = referenceMap[key];
if (refCount == 0)
{
result = true;
}
refCount++;
return result;
}
bool SaveablesList::DecrementRefCount(
QHash& referenceMap, Saveable::Pointer key)
{
bool result = false;
int& refCount = referenceMap[key];
poco_assert(refCount != 0);
if (refCount == 1)
{
referenceMap.remove(key);
result = true;
}
else
{
--refCount;
}
return result;
}
bool SaveablesList::RemoveModel(Object::Pointer source, Saveable::Pointer model)
{
bool result = false;
QHash