diff --git a/BlueBerry/Bundles/org.blueberry.ui/files.cmake b/BlueBerry/Bundles/org.blueberry.ui/files.cmake
index 433eb9869e..ef7feb71b7 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/files.cmake
+++ b/BlueBerry/Bundles/org.blueberry.ui/files.cmake
@@ -1,305 +1,302 @@
set(MOC_H_FILES
src/internal/berryWorkbenchPlugin.h
src/internal/intro/berryEditorIntroAdapterPart.h
src/berryWorkbenchPart.h
src/berryEditorPart.h
src/berryViewPart.h
src/intro/berryIntroPart.h
)
set(CACHED_RESOURCE_FILES
plugin.xml
)
set(SRC_CPP_FILES
berryAbstractSourceProvider.cpp
berryAbstractUIPlugin.cpp
berryAbstractUICTKPlugin.cpp
berryConstants.cpp
berryDisplay.cpp
berryEditorPart.cpp
berryFileEditorInput.cpp
berryGeometry.cpp
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
berryIPostSelectionProvider.cpp
berryIPreferencePage.cpp
berryIPropertyChangeListener.cpp
berryIReusableEditor.cpp
berryISaveablePart.cpp
berryISaveablesLifecycleListener.cpp
berryISaveablesSource.cpp
berryISelection.cpp
berryISelectionChangedListener.cpp
berryISelectionListener.cpp
berryISelectionProvider.cpp
berryISelectionService.cpp
berryIShellListener.cpp
berryIShellProvider.cpp
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
berryIWindowListener.cpp
berryIWorkbench.cpp
berryIWorkbenchListener.cpp
berryIWorkbenchPage.cpp
berryIWorkbenchPart.cpp
berryIWorkbenchPartConstants.cpp
berryIWorkbenchPartDescriptor.cpp
berryIWorkbenchPartReference.cpp
berryIWorkbenchPartSite.cpp
berryIWorkbenchSite.cpp
berryIWorkbenchWindow.cpp
berryPlatformUI.cpp
berryPoint.cpp
berryPropertyChangeEvent.cpp
berryRectangle.cpp
berrySameShellProvider.cpp
berrySaveable.cpp
berrySaveablesLifecycleEvent.cpp
berrySelectionChangedEvent.cpp
berryShell.cpp
berryShellEvent.cpp
berryUIException.cpp
berryViewPart.cpp
berryWindow.cpp
berryWorkbenchPart.cpp
berryWorkbenchPreferenceConstants.cpp
berryXMLMemento.cpp
#application
application/berryActionBarAdvisor.cpp
application/berryIActionBarConfigurer.cpp
application/berryIWorkbenchConfigurer.cpp
application/berryIWorkbenchWindowConfigurer.cpp
application/berryWorkbenchAdvisor.cpp
application/berryWorkbenchWindowAdvisor.cpp
#commands
#commands/berryAbstractContributionFactory.cpp
#commands/berryCommandContributionItem.cpp
#commands/berryCommandContributionItemParameter.cpp
#commands/berryContributionItem.cpp
#commands/berryContributionManager.cpp
#commands/berryICommandImageService.cpp
#commands/berryICommandService.cpp
#commands/berryIContributionManagerOverrides.cpp
#commands/berryIMenuItem.cpp
#commands/berryIMenuItemListener.cpp
#commands/berryIMenuListener.cpp
#commands/berryIToolItemListener.cpp
#commands/berryIUIElementListener.cpp
#commands/berryMenuManager.cpp
#commands/berrySubContributionItem.cpp
#commands/berryUIElement.cpp
#dialogs
dialogs/berryIDialog.cpp
dialogs/berryIShowViewDialog.cpp
dialogs/berryMessageDialog.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/berryShowViewHandler.cpp
#src
intro/berryIIntroManager.cpp
intro/berryIntroPart.cpp
intro/berryIIntroPart.cpp
intro/berryIIntroSite.cpp
#services
services/berryIDisposable.cpp
services/berryINestable.cpp
services/berryIServiceFactory.cpp
services/berryIServiceLocator.cpp
services/berryIServiceWithSources.cpp
#tweaklets
tweaklets/berryDnDTweaklet.cpp
tweaklets/berryGuiWidgetsTweaklet.cpp
tweaklets/berryImageTweaklet.cpp
tweaklets/berryMessageDialogTweaklet.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
#testing
testing/berryTestableObject.cpp
#util
util/berryISafeRunnableRunner.cpp
util/berrySafeRunnable.cpp
)
set(INTERNAL_CPP_FILES
#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
berryAbstractPartSelectionTracker.cpp
berryAbstractSelectionService.cpp
berryBundleUtility.cpp
berryContainerPlaceholder.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
berryErrorViewPart.cpp
berryFileEditorMapping.cpp
berryFolderLayout.cpp
berryIDragOverListener.cpp
berryIDropTarget.cpp
berryIEvaluationResultCache.cpp
berryIEvaluationResultCache.cpp
berryILayoutContainer.cpp
- berryILayoutContainer.cpp
berryIServiceLocatorCreator.cpp
- berryIStackableContainer.cpp
berryIStickyViewManager.cpp
berryIWorkbenchLocationService.cpp
berryIWorkbenchLocationService.cpp
berryLayoutHelper.cpp
berryLayoutPart.cpp
berryLayoutPartSash.cpp
berryLayoutTree.cpp
berryLayoutTreeNode.cpp
berryNullEditorInput.cpp
berryPageLayout.cpp
berryPagePartSelectionTracker.cpp
berryPageSelectionService.cpp
berryPartList.cpp
berryPartPane.cpp
berryPartPlaceholder.cpp
berryPartSashContainer.cpp
berryPartService.cpp
berryPartSite.cpp
berryPartStack.cpp
berryPartTester.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
berryQtWidgetController.cpp
berryRegistryReader.cpp
berrySaveablesList.cpp
berryServiceLocator.cpp
berryServiceLocatorCreator.cpp
berryShellPool.cpp
berrySourcePriorityNameMapping.cpp
- berryStackablePart.cpp
berryStickyViewDescriptor.cpp
berryStickyViewManager.cpp
berryTweaklets.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
berryWorkbenchPagePartList.cpp
berryWorkbenchPartReference.cpp
berryWorkbenchPlugin.cpp
berryWorkbenchRegistryConstants.cpp
berryWorkbenchServiceRegistry.cpp
berryWorkbenchTestable.cpp
berryWorkbenchWindow.cpp
berryWorkbenchWindowConfigurer.cpp
berryWWinPartService.cpp
)
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/src/internal/berryContainerPlaceholder.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryContainerPlaceholder.cpp
index 3974e0e32d..fbe8abdb95 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryContainerPlaceholder.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryContainerPlaceholder.cpp
@@ -1,142 +1,132 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryContainerPlaceholder.h"
#include "berryPartPlaceholder.h"
#include "berryILayoutContainer.h"
namespace berry
{
int ContainerPlaceholder::nextId = 0;
ContainerPlaceholder::ContainerPlaceholder(const std::string& id) :
- LayoutPart(id == "" ? "Container Placeholder " + nextId++ : id)
+ PartPlaceholder(id == "" ? "Container Placeholder " + nextId++ : id)
{
}
-void ContainerPlaceholder::CreateControl(void* /*parent*/)
-{
-
-}
-
-void* ContainerPlaceholder::GetControl()
-{
- return 0;
-}
-
-void ContainerPlaceholder::Add(StackablePart::Pointer child)
+void ContainerPlaceholder::Add(LayoutPart::Pointer child)
{
if (child.Cast() == 0)
{
return;
}
realContainer->Add(child);
}
-bool ContainerPlaceholder::AllowsAdd(StackablePart::Pointer /*toAdd*/)
+bool ContainerPlaceholder::AllowsAdd(LayoutPart::Pointer /*toAdd*/)
{
return false;
}
-std::list ContainerPlaceholder::GetChildren() const
+std::list ContainerPlaceholder::GetChildren() const
{
return realContainer->GetChildren();
}
std::string ContainerPlaceholder::GetID() const
{
return LayoutPart::GetID();
}
-IStackableContainer::Pointer ContainerPlaceholder::GetRealContainer()
+LayoutPart::Pointer ContainerPlaceholder::GetRealContainer()
{
- return realContainer;
+ return realContainer.Cast();
}
-void ContainerPlaceholder::Remove(StackablePart::Pointer child)
+void ContainerPlaceholder::Remove(LayoutPart::Pointer child)
{
if (child.Cast () == 0)
{
return;
}
realContainer->Remove(child);
}
-void ContainerPlaceholder::Replace(StackablePart::Pointer oldChild,
- StackablePart::Pointer newChild)
+void ContainerPlaceholder::Replace(LayoutPart::Pointer oldChild,
+ LayoutPart::Pointer newChild)
{
if (oldChild.Cast() == 0 && newChild.Cast()
== 0)
{
return;
}
realContainer->Replace(oldChild, newChild);
}
void ContainerPlaceholder::SetRealContainer(
- IStackableContainer::Pointer container)
+ ILayoutContainer::Pointer container)
{
if (container == 0)
{
// set the parent container of the children back to the real container
if (realContainer != 0)
{
- std::list children = realContainer->GetChildren();
- for (std::list::iterator iter = children.begin(); iter
+ std::list children = realContainer->GetChildren();
+ for (std::list::iterator iter = children.begin(); iter
!= children.end(); ++iter)
{
(*iter)->SetContainer(realContainer);
}
}
}
else
{
// replace the real container with this place holder
- std::list children = container->GetChildren();
- for (std::list::iterator iter = children.begin(); iter
+ std::list children = container->GetChildren();
+ for (std::list::iterator iter = children.begin(); iter
!= children.end(); ++iter)
{
- (*iter)->SetContainer(IStackableContainer::Pointer(this));
+ (*iter)->SetContainer(ILayoutContainer::Pointer(this));
}
}
this->realContainer = container;
}
-void ContainerPlaceholder::FindSashes(PartPane::Sashes& sashes)
+void ContainerPlaceholder::FindSashes(LayoutPart::Pointer /*part*/, PartPane::Sashes& sashes)
{
ILayoutContainer::Pointer container = this->GetContainer();
if (container != 0) {
container->FindSashes(LayoutPart::Pointer(this), sashes);
}
}
-void ContainerPlaceholder::ResizeChild(StackablePart::Pointer /*childThatChanged*/)
+void ContainerPlaceholder::ResizeChild(LayoutPart::Pointer /*childThatChanged*/)
{
}
bool ContainerPlaceholder::AllowsAutoFocus()
{
return false;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryContainerPlaceholder.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryContainerPlaceholder.h
index 849a6149fd..d8cad3d9b4 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryContainerPlaceholder.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryContainerPlaceholder.h
@@ -1,112 +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 BERRYCONTAINERPLACEHOLDER_H_
#define BERRYCONTAINERPLACEHOLDER_H_
-#include "berryIStackableContainer.h"
-#include "berryLayoutPart.h"
+#include "berryILayoutContainer.h"
+#include "berryPartPlaceholder.h"
#include
#include
namespace berry {
/**
* \ingroup org_blueberry_ui_internal
*
*/
-class ContainerPlaceholder : public LayoutPart, public IStackableContainer {
+class ContainerPlaceholder : public PartPlaceholder, public ILayoutContainer {
private:
static int nextId;
- IStackableContainer::Pointer realContainer;
+ ILayoutContainer::Pointer realContainer;
public:
berryObjectMacro(ContainerPlaceholder);
/**
* ContainerPlaceholder constructor comment.
* @param id java.lang.String
* @param label java.lang.String
*/
ContainerPlaceholder(const std::string& id);
- /**
- * Creates the SWT control
- */
- void CreateControl(void* parent);
-
- /**
- * Get the part control. This method may return null.
- */
- void* GetControl();
-
/**
* add method comment.
*/
- void Add(StackablePart::Pointer child);
+ void Add(LayoutPart::Pointer child);
- bool AllowsAdd(StackablePart::Pointer toAdd);
+ bool AllowsAdd(LayoutPart::Pointer toAdd);
/**
* getChildren method comment.
*/
- std::list GetChildren() const;
+ std::list GetChildren() const;
std::string GetID() const;
/**
* getFocus method comment.
*/
- IStackableContainer::Pointer GetRealContainer();
+ LayoutPart::Pointer GetRealContainer();
/**
* remove method comment.
*/
- void Remove(StackablePart::Pointer child);
+ void Remove(LayoutPart::Pointer child);
/**
* replace method comment.
*/
- void Replace(StackablePart::Pointer oldChild, StackablePart::Pointer newChild);
+ void Replace(LayoutPart::Pointer oldChild, LayoutPart::Pointer newChild);
- void SetRealContainer(IStackableContainer::Pointer container);
+ void SetRealContainer(ILayoutContainer::Pointer container);
- void FindSashes(PartPane::Sashes& sashes);
+ void FindSashes(LayoutPart::Pointer part, PartPane::Sashes& sashes);
- void ResizeChild(StackablePart::Pointer childThatChanged);
+ void ResizeChild(LayoutPart::Pointer childThatChanged);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.ILayoutContainer#allowsAutoFocus()
*/
bool AllowsAutoFocus();
/* (non-Javadoc)
* @see org.blueberry.ui.internal.ILayoutContainer#isZoomed(org.blueberry.ui.internal.LayoutPart)
*/
// bool childIsZoomed(LayoutPart toTest) {
// return false;
// }
};
}
#endif /*BERRYCONTAINERPLACEHOLDER_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryDetachedPlaceHolder.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryDetachedPlaceHolder.cpp
index 82cc1a3e7c..61a96847a1 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryDetachedPlaceHolder.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryDetachedPlaceHolder.cpp
@@ -1,124 +1,144 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryDetachedPlaceHolder.h"
#include "berryILayoutContainer.h"
#include "berryPartPlaceholder.h"
#include "berryWorkbenchConstants.h"
namespace berry
{
DetachedPlaceHolder::DetachedPlaceHolder(const std::string& id,
const Rectangle& b) :
- ContainerPlaceholder(id), bounds(b)
+ PartPlaceholder(id), bounds(b)
{
}
-void DetachedPlaceHolder::Add(StackablePart::Pointer newPart)
+void DetachedPlaceHolder::Add(LayoutPart::Pointer newPart)
{
if (newPart.Cast () == 0)
{
return;
}
children.push_back(newPart);
}
bool DetachedPlaceHolder::AllowsBorder()
{
return false;
}
+bool DetachedPlaceHolder::AllowsAdd(LayoutPart::Pointer toAdd)
+{
+ return PartPlaceholder::AllowsAdd(toAdd);
+}
+
+bool DetachedPlaceHolder::AllowsAutoFocus()
+{
+ return PartPlaceholder::AllowsAutoFocus();
+}
+
Rectangle DetachedPlaceHolder::GetBounds()
{
return bounds;
}
-std::list DetachedPlaceHolder::GetChildren()
+std::list DetachedPlaceHolder::GetChildren()
{
return children;
}
-void DetachedPlaceHolder::Remove(StackablePart::Pointer part)
+void DetachedPlaceHolder::Remove(LayoutPart::Pointer part)
{
children.remove(part);
}
-void DetachedPlaceHolder::Replace(StackablePart::Pointer oldPart,
- StackablePart::Pointer newPart)
+void DetachedPlaceHolder::Replace(LayoutPart::Pointer oldPart,
+ LayoutPart::Pointer newPart)
{
this->Remove(oldPart);
this->Add(newPart);
}
void DetachedPlaceHolder::RestoreState(IMemento::Pointer memento)
{
// Read the bounds.
int x = 0;
memento->GetInteger(WorkbenchConstants::TAG_X, x);
int y = 0;
memento->GetInteger(WorkbenchConstants::TAG_Y, y);
int width = 0;
memento->GetInteger(WorkbenchConstants::TAG_WIDTH, width);
int height = 0;
memento->GetInteger(WorkbenchConstants::TAG_HEIGHT, height);
bounds = Rectangle(x, y, width, height);
// Restore the placeholders.
std::vector childrenMem(memento
->GetChildren(WorkbenchConstants::TAG_VIEW));
for (std::size_t i = 0; i < childrenMem.size(); i++) {
std::string id;
childrenMem[i]->GetString(WorkbenchConstants::TAG_ID, id);
PartPlaceholder::Pointer holder(new PartPlaceholder(id));
- holder->SetContainer(IStackableContainer::Pointer(this));
+ holder->SetContainer(ILayoutContainer::Pointer(this));
children.push_back(holder);
}
}
void DetachedPlaceHolder::SaveState(IMemento::Pointer memento)
{
// Save the bounds.
memento->PutInteger(WorkbenchConstants::TAG_X, bounds.x);
memento->PutInteger(WorkbenchConstants::TAG_Y, bounds.y);
memento->PutInteger(WorkbenchConstants::TAG_WIDTH, bounds.width);
memento->PutInteger(WorkbenchConstants::TAG_HEIGHT, bounds.height);
// Save the views.
- for (std::list::iterator i = children.begin();
+ for (std::list::iterator i = children.begin();
i != children.end(); ++i) {
IMemento::Pointer childMem = memento
->CreateChild(WorkbenchConstants::TAG_VIEW);
- childMem->PutString(WorkbenchConstants::TAG_ID, (*i)->GetId());
+ childMem->PutString(WorkbenchConstants::TAG_ID, (*i)->GetID());
}
}
void DetachedPlaceHolder::FindSashes(LayoutPart::Pointer /*part*/,
PartPane::Sashes& sashes)
{
ILayoutContainer::Pointer container = this->GetContainer();
if (container != 0)
{
container->FindSashes(LayoutPart::Pointer(this), sashes);
}
}
+ILayoutContainer::ChildrenType DetachedPlaceHolder::GetChildren() const
+{
+ return children;
+}
+
+void DetachedPlaceHolder::ResizeChild(LayoutPart::Pointer childThatChanged)
+{
+ PartPlaceholder::ResizeChild(childThatChanged);
+}
+
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryDetachedPlaceHolder.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryDetachedPlaceHolder.h
index ce3672ce89..df67faceb0 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryDetachedPlaceHolder.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryDetachedPlaceHolder.h
@@ -1,103 +1,112 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYDETACHEDPLACEHOLDER_H_
#define BERRYDETACHEDPLACEHOLDER_H_
-#include "berryContainerPlaceholder.h"
+#include "berryPartPlaceholder.h"
+#include "berryILayoutContainer.h"
#include "berryIMemento.h"
#include "berryRectangle.h"
#include
namespace berry {
/**
* DetachedPlaceHolder is the placeholder for detached views.
*
*/
-class DetachedPlaceHolder : public ContainerPlaceholder
+class DetachedPlaceHolder : public PartPlaceholder, public ILayoutContainer
{
private:
- std::list children;
+ std::list children;
Rectangle bounds;
public:
berryObjectMacro(DetachedPlaceHolder);
/**
* DetachedPlaceHolder constructor comment.
* @param id java.lang.String
* @param bounds the size of the placeholder
*/
DetachedPlaceHolder(const std::string& id, const Rectangle& b);
/**
* Add a child to the container.
*/
- void Add(StackablePart::Pointer newPart);
+ void Add(LayoutPart::Pointer newPart);
/**
* Return true if the container allows its
* parts to show a border if they choose to,
* else false if the container does not want
* its parts to show a border.
* @return boolean
*/
bool AllowsBorder();
+ bool AllowsAdd(LayoutPart::Pointer toAdd);
+
+ bool AllowsAutoFocus();
+
Rectangle GetBounds();
/**
* Returns a list of layout children.
*/
- std::list GetChildren();
+ std::list GetChildren();
/**
* Remove a child from the container.
*/
- void Remove(StackablePart::Pointer part);
+ void Remove(LayoutPart::Pointer part);
/**
* Replace one child with another
*/
- void Replace(StackablePart::Pointer oldPart, StackablePart::Pointer newPart);
+ void Replace(LayoutPart::Pointer oldPart, LayoutPart::Pointer newPart);
/**
* Restore the state from the memento.
* @param memento
*/
void RestoreState(IMemento::Pointer memento);
/**
* Save state to the memento.
* @param memento
*/
void SaveState(IMemento::Pointer memento);
void FindSashes(LayoutPart::Pointer part, PartPane::Sashes& sashes);
+ ILayoutContainer::ChildrenType GetChildren() const;
+
+ void ResizeChild(LayoutPart::Pointer childThatChanged);
+
};
}
#endif /* BERRYDETACHEDPLACEHOLDER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryDetachedWindow.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryDetachedWindow.cpp
index f55c3c36c1..8b6cf975f0 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryDetachedWindow.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryDetachedWindow.cpp
@@ -1,544 +1,544 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryDetachedWindow.h"
#include "berryIWorkbenchPartConstants.h"
#include "berryISaveablePart.h"
#include "berryWorkbenchWindow.h"
#include "tweaklets/berryGuiWidgetsTweaklet.h"
#include "berryWorkbenchConstants.h"
#include "berryEditorManager.h"
#include "berryDragUtil.h"
namespace berry
{
DetachedWindow::ShellListener::ShellListener(DetachedWindow* wnd) :
window(wnd)
{
}
void DetachedWindow::ShellListener::ShellClosed(ShellEvent::Pointer e)
{
// hold on to a reference of the DetachedWindow instance
// (otherwise, wnd->HandleClose() woulde delete the DetachedWindow
// instance too early, trying to write to members afterwards)
DetachedWindow::Pointer wnd(window);
// only continue to close if the handleClose
// wasn't canceled
e->doit = wnd->HandleClose();
}
DetachedWindow::ShellControlListener::ShellControlListener(DetachedWindow* wnd) :
window(wnd)
{
}
GuiTk::IControlListener::Events::Types DetachedWindow::ShellControlListener::GetEventTypes() const
{
return Events::RESIZED;
}
void DetachedWindow::ShellControlListener::ControlResized(
GuiTk::ControlEvent::Pointer e)
{
window->folder->SetBounds(
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetClientArea(e->item));
}
DetachedWindow::DetachedWindow(WorkbenchPage* workbenchPage)
{
shellListener = new ShellListener(this);
resizeListener = new ShellControlListener(this);
this->page = workbenchPage;
hideViewsOnClose = true;
folder = new PartStack(page, false);
}
void DetachedWindow::PropertyChange(Object::Pointer /*source*/, int propId)
{
if (propId == IWorkbenchPartConstants::PROP_TITLE)
{
this->UpdateTitle();
}
else if (propId == PartStack::PROP_SELECTION)
{
this->ActivePartChanged(this->GetPartReference(folder->GetSelection()));
}
}
Shell::Pointer DetachedWindow::GetShell()
{
return windowShell;
}
void DetachedWindow::Create()
{
folder->AddListener(IPropertyChangeListener::Pointer(this));
windowShell
= page->GetWorkbenchWindow().Cast () ->GetDetachedWindowPool()->AllocateShell(
shellListener);
windowShell->SetData(Object::Pointer(this));
windowShell->SetText(""); //$NON-NLS-1$
DragUtil::AddDragTarget(windowShell->GetControl(),
IDragOverListener::Pointer(this));
hideViewsOnClose = true;
if (bounds.IsEmpty())
{
Rectangle windowRect = page->GetWorkbenchWindow()->GetShell()->GetBounds();
Point center(windowRect.x + windowRect.width / 2, windowRect.y
- windowRect.height / 2);
bounds = Rectangle(center.x - 150, center.y + 100, 300, 200);
}
// Force the rect into the current display
Rectangle dispBounds =
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetAvailableScreenSize();
if (bounds.width > dispBounds.width)
bounds.width = dispBounds.width;
if (bounds.height > dispBounds.height)
bounds.height = dispBounds.height;
if (bounds.x + bounds.width > dispBounds.width)
bounds.x = dispBounds.width - bounds.width;
if (bounds.y + bounds.height > dispBounds.height)
bounds.y = dispBounds.height - bounds.height;
this->GetShell()->SetBounds(bounds);
this->ConfigureShell(windowShell);
this->CreateContents(windowShell->GetControl());
//windowShell->Layout(true);
//folder->SetBounds(Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetClientArea(windowShell->GetControl()));
}
-void DetachedWindow::Add(StackablePart::Pointer part)
+void DetachedWindow::Add(LayoutPart::Pointer part)
{
Shell::Pointer shell = this->GetShell();
if (shell != 0)
{
part->Reparent(shell->GetControl());
}
folder->Add(part);
this->UpdateMinimumSize();
}
bool DetachedWindow::BelongsToWorkbenchPage(
IWorkbenchPage::Pointer workbenchPage)
{
return (workbenchPage == this->page);
}
bool DetachedWindow::Close()
{
hideViewsOnClose = false;
Shell::Pointer shell = this->GetShell();
if (shell != 0)
{
shell->Close();
}
return true;
}
IDropTarget::Pointer DetachedWindow::Drag(void* /*currentControl*/,
Object::Pointer draggedObject, const Point& position, const Rectangle& /*dragRectangle*/)
{
if (draggedObject.Cast () == 0)
{
return IDropTarget::Pointer(0);
}
PartPane::Pointer sourcePart = draggedObject.Cast ();
if (sourcePart->GetWorkbenchWindow() != page->GetWorkbenchWindow())
{
return IDropTarget::Pointer(0);
}
// Only handle the event if the source part is acceptable to the particular PartStack
IDropTarget::Pointer target;
if (folder->AllowsDrop(sourcePart))
{
target = folder->GetDropTarget(draggedObject, position);
if (target == 0)
{
Rectangle displayBounds =
DragUtil::GetDisplayBounds(folder->GetControl());
if (displayBounds.Contains(position))
{
StackDropResult::Pointer stackDropResult(new StackDropResult(
displayBounds, Object::Pointer(0)));
target = folder->CreateDropTarget(sourcePart, stackDropResult);
}
else
{
return IDropTarget::Pointer(0);
}
}
}
return target;
}
-IStackableContainer::ChildrenType DetachedWindow::GetChildren() const
+ILayoutContainer::ChildrenType DetachedWindow::GetChildren() const
{
return folder->GetChildren();
}
WorkbenchPage::Pointer DetachedWindow::GetWorkbenchPage()
{
return WorkbenchPage::Pointer(this->page);
}
void DetachedWindow::RestoreState(IMemento::Pointer memento)
{
// Read the bounds.
int x = 0;
memento->GetInteger(WorkbenchConstants::TAG_X, x);
int y = 0;
memento->GetInteger(WorkbenchConstants::TAG_Y, y);
int width = 0;
memento->GetInteger(WorkbenchConstants::TAG_WIDTH, width);
int height = 0;
memento->GetInteger(WorkbenchConstants::TAG_HEIGHT, height);
// memento->GetInteger(WorkbenchConstants::TAG_FLOAT);
// Set the bounds.
bounds = Rectangle(x, y, width, height);
if (GetShell())
{
GetShell()->SetBounds(bounds);
}
// Create the folder.
IMemento::Pointer childMem =
memento->GetChild(WorkbenchConstants::TAG_FOLDER);
if (childMem)
{
folder->RestoreState(childMem);
}
}
void DetachedWindow::SaveState(IMemento::Pointer memento)
{
if (GetShell())
{
bounds = GetShell()->GetBounds();
}
// Save the bounds.
memento->PutInteger(WorkbenchConstants::TAG_X, bounds.x);
memento->PutInteger(WorkbenchConstants::TAG_Y, bounds.y);
memento->PutInteger(WorkbenchConstants::TAG_WIDTH, bounds.width);
memento->PutInteger(WorkbenchConstants::TAG_HEIGHT, bounds.height);
// Save the views.
IMemento::Pointer childMem = memento->CreateChild(
WorkbenchConstants::TAG_FOLDER);
folder->SaveState(childMem);
}
void* DetachedWindow::GetControl()
{
return folder->GetControl();
}
int DetachedWindow::Open()
{
if (this->GetShell() == 0)
{
this->Create();
}
Rectangle bounds = this->GetShell()->GetBounds();
if (!(bounds == this->GetShell()->GetBounds()))
{
this->GetShell()->SetBounds(bounds);
}
this->GetShell()->SetVisible(true);
folder->SetBounds(Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetClientArea(this->GetShell()->GetControl()));
return 0;
}
void DetachedWindow::ActivePartChanged(
IWorkbenchPartReference::Pointer partReference)
{
if (activePart == partReference)
{
return;
}
if (activePart != 0)
{
activePart->RemovePropertyListener(IPropertyChangeListener::Pointer(this));
}
activePart = partReference;
if (partReference != 0)
{
partReference->AddPropertyListener(IPropertyChangeListener::Pointer(this));
}
this->UpdateTitle();
}
void DetachedWindow::ConfigureShell(Shell::Pointer shell)
{
this->UpdateTitle();
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->AddControlListener(
shell->GetControl(), resizeListener);
//shell.addListener(SWT.Activate, activationListener);
//shell.addListener(SWT.Deactivate, activationListener);
//TODO DetachedWindow key bindings
// // Register this detached view as a window (for key bindings).
// IContextService contextService = (IContextService) getWorkbenchPage()
// .getWorkbenchWindow().getWorkbench().getService(IContextService.class);
// contextService.registerShell(shell, IContextService.TYPE_WINDOW);
//
// page.getWorkbenchWindow().getWorkbench().getHelpSystem().setHelp(shell,
// IWorkbenchHelpContextIds.DETACHED_WINDOW);
}
void* DetachedWindow::CreateContents(void* parent)
{
// Create the tab folder.
folder->CreateControl(parent);
// Reparent each view in the tab folder.
std::list detachedChildren;
this->CollectViewPanes(detachedChildren, this->GetChildren());
for (std::list::iterator itr = detachedChildren.begin(); itr
!= detachedChildren.end(); ++itr)
{
PartPane::Pointer part = *itr;
part->Reparent(parent);
}
//TODO DetachedWindow listen to folder events (update size?)
// if (folder->GetPresentation()
// instanceof TabbedStackPresentation)
// {
// TabbedStackPresentation stack = (TabbedStackPresentation) folder.getPresentation();
// AbstractTabFolder tabFolder = stack.getTabFolder();
// tabFolder.addListener(new TabFolderListener()
// {
// public void handleEvent(TabFolderEvent e)
// {
// switch (e.type)
// {
// case TabFolderEvent.EVENT_CLOSE:
// {
// updateMinimumSize();
// break;
// }
// case TabFolderEvent.EVENT_PREFERRED_SIZE:
// {
// updateMinimumSize();
// break;
// }
// }
// }
// });
// }
// Return tab folder control.
return folder->GetControl();
}
void DetachedWindow::UpdateTitle()
{
if (activePart != 0)
{
// Uncomment to set the shell title to match the title of the active part
// String text = activePart.getTitle();
//
// if (!text.equals(s.getText())) {
// s.setText(text);
// }
}
}
void DetachedWindow::UpdateMinimumSize()
{
// // We can only do this for 'Tabbed' stacked presentations.
// if (folder.getPresentation().Cast() != 0)
// {
// TabbedStackPresentation stack = (TabbedStackPresentation) folder.getPresentation();
//
// if (stack->GetPartList().size() == 1)
// {
// // Get the minimum space required for the part
// int width = stack->ComputePreferredSize(true, Constants::INF, Constants::INF, 0);
// int height = stack->ComputePreferredSize(false, Constants::INF, Constants::INF, 0);
//
// // Take the current shell 'trim' into account
// int shellHeight = windowShell->GetBounds().height - windowShell->GetClientArea().height;
// int shellWidth = windowShell->GetBounds().width - windowShell->GetClientArea().width;
//
// windowShell->SetMinimumSize(width + shellWidth, height + shellHeight);
// }
// }
}
IWorkbenchPartReference::Pointer DetachedWindow::GetPartReference(
- StackablePart::Pointer pane)
+ LayoutPart::Pointer pane)
{
if (pane == 0 || pane.Cast () == 0)
{
return IWorkbenchPartReference::Pointer(0);
}
return pane.Cast ()->GetPartReference();
}
bool DetachedWindow::HandleClose()
{
if (hideViewsOnClose)
{
std::list views;
this->CollectViewPanes(views, this->GetChildren());
// Save any dirty views
if (!this->HandleSaves(views))
{
return false; // User canceled the save
}
// OK, go on with the closing
for (std::list::iterator itr = views.begin(); itr
!= views.end(); ++itr)
{
PartPane::Pointer child = *itr;
// Only close if closable...
if (child->IsCloseable())
{
page->HideView(child->GetPartReference().Cast ());
// Was the close cancelled?
if (child->GetContainer() != 0)
return false;
}
else
{
page->AttachView(child->GetPartReference().Cast ());
}
}
}
if (folder != 0)
{
folder->Dispose();
}
if (windowShell != 0)
{
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->RemoveControlListener(
windowShell->GetControl(), resizeListener);
// windowShell.removeListener(SWT.Activate, activationListener);
// windowShell.removeListener(SWT.Deactivate, activationListener);
DragUtil::RemoveDragTarget(windowShell->GetControl(),
IDragOverListener::Pointer(this));
bounds = windowShell->GetBounds();
//TODO DetachedWindow unregister key bindings
// // Unregister this detached view as a window (for key bindings).
// final IContextService contextService = (IContextService) getWorkbenchPage().getWorkbenchWindow().getWorkbench().getService(IContextService.class);
// contextService.unregisterShell(windowShell);
windowShell->SetData(Object::Pointer(0));
windowShell = 0;
}
return true;
}
bool DetachedWindow::HandleSaves(std::list views)
{
std::vector dirtyViews;
for (std::list::iterator iterator = views.begin(); iterator
!= views.end(); ++iterator)
{
PartPane::Pointer pane = *iterator;
IViewReference::Pointer ref =
pane->GetPartReference().Cast ();
IViewPart::Pointer part = ref->GetView(false);
if (part.Cast () != 0)
{
ISaveablePart::Pointer saveable = part.Cast ();
if (saveable->IsDirty() && saveable->IsSaveOnCloseNeeded())
{
dirtyViews.push_back(part);
}
}
}
// If there are any prompt to save -before- any closing happens
// FIXME: This code will result in a double prompt if the user
// decides not to save a particular view at this stage they'll
// get a second one from the 'hideView' call...
if (dirtyViews.size() > 0)
{
IWorkbenchWindow::Pointer window = page->GetWorkbenchWindow();
bool success =
EditorManager::SaveAll(dirtyViews, true, true, false, window);
if (!success)
{
return false; // the user canceled.
}
}
return true;
}
void DetachedWindow::CollectViewPanes(std::list& result,
- const std::list& parts)
+ const std::list& parts)
{
- for (std::list::const_iterator iter = parts.begin(); iter
+ for (std::list::const_iterator iter = parts.begin(); iter
!= parts.end(); ++iter)
{
- StackablePart::Pointer part = *iter;
+ LayoutPart::Pointer part = *iter;
if (part.Cast () != 0)
{
result.push_back(part.Cast ());
}
}
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryDetachedWindow.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryDetachedWindow.h
index 99000dd580..5e9e15c7b3 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryDetachedWindow.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryDetachedWindow.h
@@ -1,198 +1,198 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYDETACHEDWINDOW_H_
#define BERRYDETACHEDWINDOW_H_
#include "berryPartStack.h"
#include "berryWorkbenchPage.h"
#include "berryLayoutPart.h"
#include "berryIDragOverListener.h"
#include "berryIShellListener.h"
#include "guitk/berryGuiTkIControlListener.h"
#include "berryRectangle.h"
#include "berryShell.h"
namespace berry
{
/**
* TODO: Drag from detached to fast view bar back to detached causes NPE
*
* @since 3.1
*/
class DetachedWindow: public IPropertyChangeListener,
public IDragOverListener
{
public:
berryObjectMacro(DetachedWindow);
private:
PartStack::Pointer folder;
WorkbenchPage* page;
Rectangle bounds;
Shell::Pointer windowShell;
bool hideViewsOnClose;
struct ShellListener: public IShellListener
{
ShellListener(DetachedWindow* wnd);
void ShellClosed(ShellEvent::Pointer e);
private:
DetachedWindow* window;
};
IShellListener::Pointer shellListener;
struct ShellControlListener: public GuiTk::IControlListener
{
ShellControlListener(DetachedWindow* wnd);
Events::Types GetEventTypes() const;
void ControlResized(GuiTk::ControlEvent::Pointer e);
private:
DetachedWindow* window;
};
GuiTk::IControlListener::Pointer resizeListener;
// Listener activationListener = new Listener() {
// public void handleEvent(Event event) {
// switch (event.type) {
// case SWT.Activate:
// page.window.liftRestrictions();
// break;
// case SWT.Deactivate:
// page.window.imposeRestrictions();
// break;
// }
// }
// };
IWorkbenchPartReference::Pointer activePart;
public:
/**
* Create a new FloatingWindow.
*/
DetachedWindow(WorkbenchPage* workbenchPage);
void PropertyChange(Object::Pointer source, int propId);
Shell::Pointer GetShell();
void Create();
/**
* Adds a visual part to this window.
* Supports reparenting.
*/
- void Add(StackablePart::Pointer part);
+ void Add(LayoutPart::Pointer part);
bool BelongsToWorkbenchPage(IWorkbenchPage::Pointer workbenchPage);
bool Close();
/*
* @see org.blueberry.ui.internal.IDragOverListener#Drag(void*, Object::Pointer, const Point&, const Rectangle& )
*/
IDropTarget::Pointer Drag(void* currentControl,
Object::Pointer draggedObject, const Point& position,
const Rectangle& dragRectangle);
- IStackableContainer::ChildrenType GetChildren() const;
+ ILayoutContainer::ChildrenType GetChildren() const;
WorkbenchPage::Pointer GetWorkbenchPage();
/**
* @see IPersistablePart
*/
void RestoreState(IMemento::Pointer memento);
/**
* @see IPersistablePart
*/
void SaveState(IMemento::Pointer memento);
void* GetControl();
/**
* Opens the detached window.
*/
int Open();
protected:
void ActivePartChanged(IWorkbenchPartReference::Pointer partReference);
/**
* This method will be called to initialize the given Shell's layout
*/
void ConfigureShell(Shell::Pointer shell);
/**
* Override this method to create the widget tree that is used as the window's contents.
*/
void* CreateContents(void* parent);
private:
void UpdateTitle();
/**
* Ensure that the shell's minimum size is equal to the minimum size
* of the first part added to the shell.
*/
void UpdateMinimumSize();
static IWorkbenchPartReference::Pointer GetPartReference(
- StackablePart::Pointer pane);
+ LayoutPart::Pointer pane);
/**
* Closes this window and disposes its shell.
*/
bool HandleClose();
/**
* Prompts for and handles the saving of dirty, saveable views
* @param views The list of ViewPanes
* @return true
unless the user cancels the save(s)
*/
bool HandleSaves(std::list views);
/**
* Answer a list of the view panes.
*/
void CollectViewPanes(std::list& result,
- const std::list& parts);
+ const std::list& parts);
};
}
#endif /* BERRYDETACHEDWINDOW_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorAreaHelper.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorAreaHelper.cpp
index 2ce24cbfaa..94c46c3410 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorAreaHelper.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorAreaHelper.cpp
@@ -1,267 +1,267 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryEditorAreaHelper.h"
#include "berryEditorSashContainer.h"
#include "berryPartSite.h"
#include "berryIPageLayout.h"
#include "berryPartPane.h"
namespace berry
{
void EditorAreaHelper::CloseEditor(PartPane::Pointer pane)
{
if (pane != 0)
{
editorArea->RemoveEditor(pane);
}
}
void EditorAreaHelper::AddToLayout(PartPane::Pointer pane,
PartStack::Pointer stack)
{
//EditorStack stack = editorArea.getActiveWorkbook();
pane->SetContainer(stack);
editorArea->AddEditor(pane, stack);
}
EditorAreaHelper::EditorAreaHelper(WorkbenchPage* page)
{
this->editorArea
= new EditorSashContainer(IPageLayout::ID_EDITOR_AREA, page, page->GetClientComposite());
this->editorArea->CreateControl(page->GetClientComposite());
this->editorArea->SetActive(true);
}
void EditorAreaHelper::DisplayEditorList()
{
PartStack::Pointer activeWorkbook = editorArea->GetActiveWorkbook();
if (activeWorkbook != 0)
{
activeWorkbook->ShowPartList();
}
}
void EditorAreaHelper::CloseEditor(IEditorReference::Pointer ref)
{
PartPane::Pointer pane = ref.Cast()->GetPane();
this->CloseEditor(pane);
}
void EditorAreaHelper::CloseEditor(IEditorPart::Pointer part)
{
PartPane::Pointer pane = part->GetSite().Cast()->GetPane();
this->CloseEditor(pane);
}
-void EditorAreaHelper::DerefPart(StackablePart::Pointer part)
+void EditorAreaHelper::DerefPart(LayoutPart::Pointer part)
{
// Get vital part stats before reparenting.
- IStackableContainer::Pointer oldContainer = part->GetContainer();
+ ILayoutContainer::Pointer oldContainer = part->GetContainer();
// Reparent the part back to the main window
//part.reparent(editorArea.getParent());
// Update container.
if (oldContainer == 0)
{
return;
}
oldContainer->Remove(part);
- std::list children = oldContainer->GetChildren();
+ std::list children = oldContainer->GetChildren();
if (children.empty())
{
// There are no more children in this container, so get rid of it
if (oldContainer.Cast())
{
LayoutPart::Pointer parent = oldContainer.Cast();
ILayoutContainer::Pointer parentContainer = parent->GetContainer();
if (parentContainer != 0)
{
parentContainer->Remove(parent);
parent->Dispose();
}
}
}
}
EditorAreaHelper::~EditorAreaHelper()
{
if (editorArea != 0)
{
editorArea->SetActive(false);
editorArea->Dispose();
}
}
std::string EditorAreaHelper::GetActiveEditorWorkbookID()
{
return editorArea->GetActiveWorkbookID();
}
PartStack::Pointer EditorAreaHelper::GetActiveWorkbook()
{
return editorArea->GetActiveWorkbook();
}
LayoutPart::Pointer EditorAreaHelper::GetLayoutPart()
{
LayoutPart::Pointer layoutPart = editorArea.Cast();
return layoutPart;
}
IEditorReference::Pointer EditorAreaHelper::GetVisibleEditor()
{
PartStack::Pointer activeWorkbook = editorArea->GetActiveWorkbook();
PartPane::Pointer pane = activeWorkbook->GetSelection().Cast();
if (pane != 0)
{
IEditorReference::Pointer result = pane->GetPartReference().Cast();
return result;
}
return IEditorReference::Pointer(0);
}
void EditorAreaHelper::MoveEditor(IEditorPart::Pointer /*part*/, int /*position*/)
{
///*EditorPane pane = (EditorPane)*/((EditorSite) part.getSite()).getPane();
//TODO commented this out during presentations works
//pane.getWorkbook().reorderTab(pane, position);
}
void EditorAreaHelper::AddEditor(EditorReference::Pointer ref,
const std::string& workbookId)
{
std::list refs = editorArea->GetPage()->GetEditorReferences();
for (std::list::iterator iter = refs.begin();
iter != refs.end(); ++iter)
{
if (ref == (*iter))
{
return;
}
}
PartStack::Pointer stack = this->GetWorkbookFromID(workbookId);
if (stack == 0)
{
stack = this->GetActiveWorkbook();
}
this->AddToLayout(ref->GetPane(), stack);
editorArea->GetPage()->PartAdded(ref);
}
bool EditorAreaHelper::RestoreState(IMemento::Pointer memento)
{
// Restore the editor area workbooks layout/relationship
return editorArea->RestoreState(memento);
}
bool EditorAreaHelper::RestorePresentationState(IMemento::Pointer areaMem)
{
return editorArea->RestorePresentationState(areaMem);
}
bool EditorAreaHelper::SaveState(IMemento::Pointer memento)
{
// Save the editor area workbooks layout/relationship
return editorArea->SaveState(memento);
}
void EditorAreaHelper::SetActiveEditorWorkbookFromID(const std::string& id)
{
editorArea->SetActiveWorkbookFromID(id);
}
void EditorAreaHelper::SetActiveWorkbook(PartStack::Pointer workbook, bool hasFocus)
{
editorArea->SetActiveWorkbook(workbook, hasFocus);
}
bool EditorAreaHelper::SetVisibleEditor(IEditorReference::Pointer ref, bool setFocus)
{
IEditorReference::Pointer visibleEditor = this->GetVisibleEditor();
if (ref != visibleEditor)
{
IWorkbenchPart::Pointer part = ref->GetPart(true);
PartPane::Pointer pane;
if (part != 0)
{
pane = part->GetSite().Cast()->GetPane();
}
if (pane != 0)
{
pane->GetContainer().Cast()->SetSelection(pane);
if (setFocus)
{
part->SetFocus();
}
return true;
}
}
return false;
}
std::list EditorAreaHelper::GetWorkbooks()
{
return editorArea->GetEditorWorkbooks();
}
std::list EditorAreaHelper::GetEditors()
{
std::list result;
std::list workbooks = editorArea->GetEditorWorkbooks();
for (std::list::iterator iter = workbooks.begin();
iter != workbooks.end(); ++iter)
{
PartStack::Pointer stack = *iter;
- std::list children = stack->GetChildren();
+ std::list children = stack->GetChildren();
- for (std::list::iterator childIter = children.begin();
+ for (std::list::iterator childIter = children.begin();
childIter != children.end(); ++childIter)
{
- StackablePart::Pointer part = *childIter;
+ LayoutPart::Pointer part = *childIter;
result.push_back(part.Cast()->GetPartReference().Cast());
}
}
return result;
}
PartStack::Pointer EditorAreaHelper::GetWorkbookFromID(const std::string& workbookId)
{
return editorArea->GetWorkbookFromID(workbookId);
}
void EditorAreaHelper::UpdateStackButtons()
{
editorArea->UpdateStackButtons();
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorAreaHelper.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorAreaHelper.h
index d4fb5ee0d6..c8893db2d1 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorAreaHelper.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorAreaHelper.h
@@ -1,175 +1,175 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYEDITORAREAHELPER_H_
#define BERRYEDITORAREAHELPER_H_
#include "berryLayoutPart.h"
-#include "berryStackablePart.h"
+#include "berryLayoutPart.h"
#include "berryEditorReference.h"
#include
#include
namespace berry {
class EditorSashContainer;
class WorkbenchPage;
class PartPane;
class PartStack;
/**
* EditorAreaHelper is a wrapper for PartTabworkbook.
*/
class EditorAreaHelper {
//private ArrayList editorTable = new ArrayList(4);
private:
SmartPointer editorArea;
/**
* Closes an editor.
*
* @param part the editor to close
*/
void CloseEditor(SmartPointer pane);
void AddToLayout(SmartPointer pane, SmartPointer stack);
public:
/**
* Creates a new EditorAreaHelper.
*/
EditorAreaHelper(WorkbenchPage* page);
/**
* Displays a list of open editors
*/
void DisplayEditorList();
/**
* Closes an editor.
*
* @param part the editor to close
*/
void CloseEditor(IEditorReference::Pointer ref);
/**
* Closes an editor.
*
* @param part the editor to close
*/
void CloseEditor(IEditorPart::Pointer part);
/**
* Deref a given part. Deconstruct its container as required.
* Do not remove drag listeners.
*/
- static void DerefPart(StackablePart::Pointer part);
+ static void DerefPart(LayoutPart::Pointer part);
/**
* Dispose of the editor presentation.
*/
~EditorAreaHelper();
/**
* @see IEditorPresentation
*/
std::string GetActiveEditorWorkbookID();
SmartPointer GetActiveWorkbook();
/**
* Returns the editor area.
*/
LayoutPart::Pointer GetLayoutPart();
/**
* Returns the active editor in this perspective. If the editors appear
* in a workbook this will be the visible editor. If the editors are
* scattered around the workbench this will be the most recent editor
* to hold focus.
*
* @return the active editor, or null
if no editor is active
*/
IEditorReference::Pointer GetVisibleEditor();
void MoveEditor(IEditorPart::Pointer part, int position);
/**
* Main entry point for adding an editor. Adds the editor to the layout in the given
* stack, and notifies the workbench page when done.
*
* @param ref editor to add
* @param workbookId workbook that will contain the editor (or null if the editor
* should be added to the default workbook)
*/
void AddEditor(EditorReference::Pointer ref, const std::string& workbookId);
/**
* @see IPersistablePart
*/
bool RestoreState(IMemento::Pointer memento);
/**
* Restore the presentation
* @param areaMem
* @return
*/
bool RestorePresentationState(IMemento::Pointer areaMem);
/**
* @see IPersistablePart
*/
bool SaveState(IMemento::Pointer memento);
/**
* @see IEditorPresentation
*/
void SetActiveEditorWorkbookFromID(const std::string& id);
void SetActiveWorkbook(SmartPointer workbook, bool hasFocus);
/**
* Brings an editor to the front and optionally gives it focus.
*
* @param part the editor to make visible
* @param setFocus whether to give the editor focus
* @return true if the visible editor was changed, false if not.
*/
bool SetVisibleEditor(IEditorReference::Pointer ref, bool setFocus);
/**
* Method getWorkbooks.
* @return ArrayList
*/
std::list > GetWorkbooks();
std::list GetEditors();
SmartPointer GetWorkbookFromID(const std::string& workbookId);
void UpdateStackButtons();
};
}
#endif /* BERRYEDITORAREAHELPER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorManager.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorManager.cpp
index 0711758e21..fe07e209bc 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorManager.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorManager.cpp
@@ -1,1295 +1,1295 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryEditorManager.h"
#include "berryIWorkbenchPart.h"
#include "berryIWorkbenchWindow.h"
#include "berryIEditorRegistry.h"
#include "berryUIException.h"
#include "berryWorkbenchWindow.h"
#include "berryWorkbenchPage.h"
#include "berryEditorSite.h"
#include "berryEditorReference.h"
#include "berryWorkbenchPlugin.h"
#include "berryWorkbenchConstants.h"
#include "berryNullEditorInput.h"
#include "berryEditorAreaHelper.h"
#include "berryPartStack.h"
#include
namespace berry
{
const std::string EditorManager::PIN_EDITOR_KEY = "PIN_EDITOR";
const std::string EditorManager::RESOURCES_TO_SAVE_MESSAGE = "Select resources to save:";
const std::string EditorManager::SAVE_RESOURCES_TITLE = "Save Resources";
EditorManager::EditorManager(WorkbenchWindow::Pointer wind,
WorkbenchPage::Pointer workbenchPage,
EditorAreaHelper* pres)
: editorPresentation(pres), window(wind.GetPointer()), page(workbenchPage.GetPointer()) {
poco_check_ptr(editorPresentation);
poco_assert(window != 0);
poco_assert(page != 0);
//page.getExtensionTracker().registerHandler(this, null);
}
void EditorManager::CheckDeleteEditorResources()
{
// // get the current number of editors
// IEditorReference[] editors = page.getEditorReferences();
// // If there are no editors
// if (editors.length == 0)
// {
// if (editorPropChangeListnener != null)
// {
// // remove property change listener for editors
// IPreferenceStore prefStore = WorkbenchPlugin.getDefault()
// .getPreferenceStore();
// prefStore
// .removePropertyChangeListener(editorPropChangeListnener);
// editorPropChangeListnener = null;
// }
// if (pinEditorHandlerActivation != null)
// {
// // remove pin editor keyboard shortcut handler
// final IHandlerService handlerService = (IHandlerService) window.getWorkbench().getService(IHandlerService.class);
// handlerService.deactivateHandler(pinEditorHandlerActivation);
// pinEditorHandlerActivation = null;
// }
// }
}
//void EditorManager::CheckCreateEditorPropListener()
//{
// if (editorPropChangeListnener == null)
// {
// // Add a property change listener for closing editors automatically
// // preference
// // Add or remove the pin icon accordingly
// editorPropChangeListnener = new IPropertyChangeListener()
// {
// public void propertyChange(PropertyChangeEvent event)
// {
// if (event.getProperty().equals(
// IPreferenceConstants.REUSE_EDITORS_BOOLEAN))
// {
// IEditorReference[] editors = getEditors();
// for (int i = 0; i < editors.length; i++)
// {
// ((EditorReference) editors[i]).pinStatusUpdated();
// }
// }
// }
// };
// WorkbenchPlugin.getDefault().getPreferenceStore()
// .addPropertyChangeListener(editorPropChangeListnener);
// }
//}
//void EditorManager::CheckCreatePinEditorShortcutKeyHandler()
//{
// if (pinEditorHandlerActivation == null)
// {
// final Shell shell = window.getShell();
// final IHandler pinEditorHandler = new AbstractHandler()
// {
// public final Object execute(final ExecutionEvent event)
// {
// // check if the "Close editors automatically" preference is
// // set
// IPreferenceStore store = WorkbenchPlugin.getDefault().getPreferenceStore();
// if (store
// .getBoolean(IPreferenceConstants.REUSE_EDITORS_BOOLEAN)
// || ((TabBehaviour)Tweaklets.get(TabBehaviour.KEY)).alwaysShowPinAction())
// {
//
// IWorkbenchPartReference ref = editorPresentation
// .getVisibleEditor();
// if (ref instanceof WorkbenchPartReference)
// {
// WorkbenchPartReference concreteRef = (WorkbenchPartReference) ref;
//
// concreteRef.setPinned(concreteRef.isPinned());
// }
// }
// return null;
// }
// };
//
// // Assign the handler for the pin editor keyboard shortcut.
// final IHandlerService handlerService = (IHandlerService) window.getWorkbench().getService(IHandlerService.class);
// pinEditorHandlerActivation = handlerService.activateHandler(
// "org.blueberry.ui.window.pinEditor", pinEditorHandler, //$NON-NLS-1$
// new ActiveShellExpression(shell));
// }
//}
std::vector EditorManager::CollectDirtyEditors()
{
std::vector result;
std::list editors(page->GetEditorReferences());
for (std::list::iterator i = editors.begin();
i != editors.end(); ++i)
{
IEditorPart::Pointer part = (*i)->GetPart(false).Cast();
if (part.IsNotNull() && part->IsDirty())
{
result.push_back(part);
}
}
return result;
}
bool EditorManager::ContainsEditor(IEditorReference::Pointer ref)
{
std::list editors(page->GetEditorReferences());
return std::find(editors.begin(), editors.end(), ref) != editors.end();
}
//EditorActionBars* EditorManager::CreateEditorActionBars(
// EditorDescriptor::Pointer desc, IEditorSite::Pointer site)
//{
// // Get the editor type.
// String type = desc.getId();
//
// // If an action bar already exists for this editor type return it.
// EditorActionBars actionBars = (EditorActionBars) actionCache.get(type);
// if (actionBars != null)
// {
// actionBars.addRef();
// return actionBars;
// }
//
// // Create a new action bar set.
// actionBars = new EditorActionBars(page, site.getWorkbenchWindow(), type);
// actionBars.addRef();
// actionCache.put(type, actionBars);
//
// // Read base contributor.
// IEditorActionBarContributor contr = desc.createActionBarContributor();
// if (contr != null)
// {
// actionBars.setEditorContributor(contr);
// contr.init(actionBars, page);
// }
//
// // Read action extensions.
// EditorActionBuilder builder = new EditorActionBuilder();
// contr = builder.readActionExtensions(desc);
// if (contr != null)
// {
// actionBars.setExtensionContributor(contr);
// contr.init(actionBars, page);
// }
//
// // Return action bars.
// return actionBars;
//}
//EditorActionBars* EditorManager::CreateEmptyEditorActionBars(
// IEditorSite::Pointer site)
//{
// // Get the editor type.
// String type = String.valueOf(System.currentTimeMillis());
//
// // Create a new action bar set.
// // Note: It is an empty set.
// EditorActionBars actionBars = new EditorActionBars(page, site.getWorkbenchWindow(), type);
// actionBars.addRef();
// actionCache.put(type, actionBars);
//
// // Return action bars.
// return actionBars;
//}
//void EditorManager::DisposeEditorActionBars(EditorActionBars* actionBars)
//{
// actionBars.removeRef();
// if (actionBars.getRef() <= 0)
// {
// String type = actionBars.getEditorType();
// actionCache.remove(type);
// // refresh the cool bar manager before disposing of a cool item
// ICoolBarManager2 coolBar = (ICoolBarManager2) window.getCoolBarManager2();
// if (coolBar != null)
// {
// coolBar.refresh();
// }
// actionBars.dispose();
// }
//}
IEditorPart::Pointer EditorManager::FindEditor(IEditorInput::Pointer input)
{
return this->FindEditor("", input, IWorkbenchPage::MATCH_INPUT);
}
IEditorPart::Pointer EditorManager::FindEditor(const std::string& editorId,
IEditorInput::Pointer input, int matchFlags)
{
std::vector refs(this->FindEditors(input, editorId, matchFlags));
if (refs.size() == 0)
{
return IEditorPart::Pointer();
}
return refs[0]->GetEditor(true);
}
std::vector EditorManager::FindEditors(
IEditorInput::Pointer input, const std::string& editorId, int matchFlags)
{
if (matchFlags == IWorkbenchPage::MATCH_NONE)
{
return std::vector();
}
std::vector result;
std::list othersList(page->GetEditorReferences());
if (!othersList.empty())
{
IEditorReference::Pointer active = page->GetActiveEditorReference();
if (active.IsNotNull())
{
othersList.remove(active);
std::list activeList;
activeList.push_back(active);
this->FindEditors(activeList, input, editorId, matchFlags, result);
}
this->FindEditors(othersList, input, editorId, matchFlags, result);
}
return result;
}
void EditorManager::FindEditors(
std::list& editorList,
IEditorInput::Pointer input, const std::string& editorId, int matchFlags,
std::vector& result)
{
if (matchFlags == IWorkbenchPage::MATCH_NONE)
{
return;
}
// Phase 0: Remove editors whose ids don't match (if matching by id)
if (((matchFlags & IWorkbenchPage::MATCH_ID) != 0) && !editorId.empty())
{
for (std::list::iterator i = editorList.begin();
i != editorList.end();)
{
if (editorId != (*i)->GetId())
{
i = editorList.erase(i);
continue;
}
++i;
}
}
// If not matching on editor input, just return the remaining editors.
// In practice, this case is never used.
if ((matchFlags & IWorkbenchPage::MATCH_INPUT) == 0)
{
result.insert(result.end(), editorList.begin(), editorList.end());
return;
}
// Phase 1: check editors that have their own matching strategy
for (std::list::iterator i = editorList.begin();
i != editorList.end();)
{
EditorReference::Pointer editor = i->Cast();
IEditorDescriptor::Pointer desc = editor->GetDescriptor();
if (desc.IsNotNull())
{
IEditorMatchingStrategy::Pointer matchingStrategy = desc
->GetEditorMatchingStrategy();
if (matchingStrategy.IsNotNull())
{
i = editorList.erase(i); // We're handling this one here, so remove it
// from the list.
if (matchingStrategy->Matches(editor, input))
{
result.push_back(editor);
}
continue;
}
}
++i;
}
// Phase 2: check materialized editors (without their own matching
// strategy)
for (std::list::iterator i = editorList.begin();
i != editorList.end();)
{
EditorReference::Pointer editor = i->Cast();
IEditorPart::Pointer part = editor->GetPart(false).Cast();
if (part.IsNotNull())
{
i = editorList.erase(i); // We're handling this one here, so remove it from
// the list.
if (part->GetEditorInput().IsNotNull() && part->GetEditorInput() == input)
{
result.push_back(editor);
}
}
else ++i;
}
// Phase 3: check unmaterialized editors for input equality,
// delaying plug-in activation further by only restoring the editor
// input
// if the editor reference's factory id and name match.
// std::string name = input->GetName();
// IPersistableElement persistable = input.getPersistable();
// if (name == null || persistable == null)
// {
// return;
// }
// String id = persistable.getFactoryId();
// if (id == null)
// {
// return;
// }
// for (Iterator i = editorList.iterator(); i.hasNext();)
// {
// EditorReference editor = (EditorReference) i.next();
// if (name.equals(editor.getName()) && id.equals(editor.getFactoryId()))
// {
// IEditorInput restoredInput;
// try
// {
// restoredInput = editor.getEditorInput();
// if (Util.equals(restoredInput, input))
// {
// result.add(editor);
// }
// }
// catch (PartInitException e1)
// {
// WorkbenchPlugin.log(e1);
// }
// }
// }
}
std::size_t EditorManager::GetEditorCount()
{
return page->GetEditorReferences().size();
}
IEditorRegistry* EditorManager::GetEditorRegistry()
{
return WorkbenchPlugin::GetDefault()->GetEditorRegistry();
}
std::vector EditorManager::GetDirtyEditors()
{
return this->CollectDirtyEditors();
}
std::list EditorManager::GetEditors()
{
return page->GetEditorReferences();
}
IEditorPart::Pointer EditorManager::GetVisibleEditor()
{
IEditorReference::Pointer ref = editorPresentation->GetVisibleEditor();
if (ref.IsNull())
{
return IEditorPart::Pointer(0);
}
return ref->GetPart(true).Cast();
}
bool EditorManager::IsSaveAllNeeded()
{
std::list editors(page->GetEditorReferences());
for (std::list::iterator i = editors.begin();
i != editors.end(); ++i)
{
if ((*i)->IsDirty())
{
return true;
}
}
return false;
}
IEditorReference::Pointer EditorManager::FindReusableEditor(
EditorDescriptor::Pointer /*desc*/)
{
//return ((TabBehaviour)Tweaklets.get(TabBehaviour.KEY)).findReusableEditor(page);
return IEditorReference::Pointer(0);
}
IEditorReference::Pointer EditorManager::OpenEditor(
const std::string& editorId, IEditorInput::Pointer input, bool /*setVisible*/,
IMemento::Pointer editorState)
{
if (input.IsNull())
{
throw Poco::InvalidArgumentException();
}
IEditorRegistry* reg = this->GetEditorRegistry();
EditorDescriptor::Pointer desc = reg->FindEditor(editorId).Cast();
if (desc.IsNull())
{
throw PartInitException("Unable to open editor, unknown editor id", editorId);
}
return this->OpenEditorFromDescriptor(desc, input, editorState);
}
IEditorReference::Pointer EditorManager::OpenEditorFromDescriptor(
EditorDescriptor::Pointer desc, IEditorInput::Pointer input,
IMemento::Pointer editorState)
{
IEditorReference::Pointer result;
if (desc->IsInternal())
{
result = this->ReuseInternalEditor(desc, input);
if (result.IsNull())
{
result = new EditorReference(this, input, desc, editorState);
}
}
// else if (desc->GetId() == IEditorRegistry::SYSTEM_INPLACE_EDITOR_ID)
// {
// if (ComponentSupport.inPlaceEditorSupported())
// {
// result = new EditorReference(this, input, desc);
// }
// }
// else if (desc->GetId() == IEditorRegistry::SYSTEM_EXTERNAL_EDITOR_ID)
// {
// IPathEditorInput pathInput = getPathEditorInput(input);
// if (pathInput != null)
// {
// result = openSystemExternalEditor(pathInput.getPath());
// }
// else
// {
// throw new PartInitException(
// WorkbenchMessages.EditorManager_systemEditorError);
// }
// }
// else if (desc->IsOpenExternal())
// {
// result = openExternalEditor(desc, input);
// }
else
{
// this should never happen
throw PartInitException("Invalid editor descriptor for id", desc->GetId());
}
if (result.IsNotNull())
{
this->CreateEditorTab(result.Cast(), ""); //$NON-NLS-1$
}
// Workbench wb = (Workbench) window.getWorkbench();
// wb.getEditorHistory().add(input, desc);
return result;
}
//IEditorReference::Pointer EditorManager::OpenExternalEditor(
// EditorDescriptor::Pointer desc, IEditorInput::Pointer input)
//{
// final CoreException ex[] = new CoreException[1];
//
// final IPathEditorInput pathInput = getPathEditorInput(input);
// if (pathInput != null && pathInput.getPath() != null)
// {
// BusyIndicator.showWhile(getDisplay(), new Runnable()
// {
// public void run()
// {
// try
// {
// if (desc.getLauncher() != null)
// {
// // open using launcher
// Object launcher = WorkbenchPlugin.createExtension(
// desc.getConfigurationElement(), "launcher"); //$NON-NLS-1$
// ((IEditorLauncher) launcher).open(pathInput
// .getPath());
// }
// else
// {
// // open using command
// ExternalEditor oEditor = new ExternalEditor(
// pathInput.getPath(), desc);
// oEditor.open();
// }
// }
// catch (CoreException e)
// {
// ex[0] = e;
// }
// }
// }
// );
// }
// else
// {
// throw new PartInitException(NLS.bind(
// WorkbenchMessages.EditorManager_errorOpeningExternalEditor,
// desc.getFileName(), desc.getId()));
// }
//
// if (ex[0] != null)
// {
// throw new PartInitException(NLS.bind(
// WorkbenchMessages.EditorManager_errorOpeningExternalEditor,
// desc.getFileName(), desc.getId()), ex[0]);
// }
//
// // we do not have an editor part for external editors
// return null;
//}
void EditorManager::CreateEditorTab(EditorReference::Pointer ref, const std::string& workbookId)
{
editorPresentation->AddEditor(ref, workbookId);
}
EditorSite::Pointer EditorManager::CreateSite(IEditorReference::Pointer ref,
IEditorPart::Pointer part, EditorDescriptor::Pointer desc,
IEditorInput::Pointer input) const
{
EditorSite::Pointer site(new EditorSite(ref, part, page, desc));
if (desc.IsNotNull())
{
//site.setActionBars(createEditorActionBars(desc, site));
}
else
{
//site.setActionBars(createEmptyEditorActionBars(site));
}
const std::string label = part->GetPartName(); // debugging only
try
{
part->Init(site, input);
// Sanity-check the site
if (!(part->GetSite() == site) || !(part->GetEditorSite() == site))
{
throw PartInitException("Editor initialization failed: " + desc->GetId() + ". Site is incorrect.");
}
}
catch (PartInitException e)
{
throw e;
}
catch (std::exception e)
{
throw PartInitException("An exception was thrown during initialization", e.what());
}
return site;
}
IEditorReference::Pointer EditorManager::ReuseInternalEditor(
EditorDescriptor::Pointer /*desc*/, IEditorInput::Pointer /*input*/)
{
// poco_assert(desc.IsNotNull()); // "descriptor must not be null"); //$NON-NLS-1$
// poco_assert(input.IsNotNull()); // "input must not be null"); //$NON-NLS-1$
//
// IEditorReference::Pointer reusableEditorRef = this->FindReusableEditor(desc);
// if (reusableEditorRef.IsNotNull())
// {
// return this->ReuseInternalEditor(page, this, editorPresentation, desc, input,
// reusableEditorRef);
// }
return IEditorReference::Pointer(0);
}
IEditorPart::Pointer EditorManager::CreatePart(EditorDescriptor::Pointer desc) const
{
// try
// {
IEditorPart::Pointer result = desc->CreateEditor();
// IConfigurationElement element = desc.getConfigurationElement();
// if (element != null)
// {
// page.getExtensionTracker().registerObject(
// element.getDeclaringExtension(), result,
// IExtensionTracker.REF_WEAK);
// }
return result;
// }
// catch (CoreException e)
// {
// throw PartInitException(StatusUtil.newStatus(
// desc.getPluginID(),
// WorkbenchMessages.EditorManager_instantiationError, e));
// }
}
//IEditorReference::Pointer EditorManager::OpenSystemExternalEditor(
// Poco::Path location)
//{
// if (location == null)
// {
// throw new IllegalArgumentException();
// }
//
// final boolean result[] =
// { false};
// BusyIndicator.showWhile(getDisplay(), new Runnable()
// {
// public void run()
// {
// if (location != null)
// {
// result[0] = Program.launch(location.toOSString());
// }
// }
// }
// );
//
// if (!result[0])
// {
// throw new PartInitException(NLS.bind(
// WorkbenchMessages.EditorManager_unableToOpenExternalEditor,
// location));
// }
//
// // We do not have an editor part for external editors
// return null;
// }
// ImageDescriptor EditorManager::FindImage(EditorDescriptor::Pointer desc,
// Poco::Path path)
// {
// if (desc == null)
// {
// // @issue what should be the default image?
// return ImageDescriptor.getMissingImageDescriptor();
// }
//
// if (desc.isOpenExternal() && path != null)
// {
// return PlatformUI.getWorkbench().getEditorRegistry()
// .getImageDescriptor(path.toOSString());
// }
//
// return desc.getImageDescriptor();
// }
bool EditorManager::RestoreState(IMemento::Pointer memento)
{
// Restore the editor area workbooks layout/relationship
// MultiStatus result = new MultiStatus(PlatformUI.PLUGIN_ID,
// IStatus.OK,
// WorkbenchMessages.EditorManager_problemsRestoringEditors, null);
bool result = true;
std::string activeWorkbookID;
std::vector visibleEditors;
std::vector activeEditor;
IMemento::Pointer areaMem = memento->GetChild(WorkbenchConstants::TAG_AREA);
if (areaMem)
{
//result.add(editorPresentation.restoreState(areaMem));
editorPresentation->RestoreState(areaMem);
areaMem->GetString(WorkbenchConstants::TAG_ACTIVE_WORKBOOK, activeWorkbookID);
}
// Loop through the editors.
std::vector editorMems(memento->GetChildren(WorkbenchConstants::TAG_EDITOR));
for (std::size_t x = 0; x < editorMems.size(); x++)
{
// for dynamic UI - call restoreEditorState to replace code which is
// commented out
RestoreEditorState(editorMems[x], visibleEditors, activeEditor); //, result);
}
// restore the presentation
if (areaMem)
{
//result.add(editorPresentation.restorePresentationState(areaMem));
result &= editorPresentation->RestorePresentationState(areaMem);
}
try
{
// StartupThreading.runWithThrowable(new StartupRunnable()
// {
//
// public void runWithException() throws Throwable
// {
// Update each workbook with its visible editor.
for (std::size_t i = 0; i < visibleEditors.size(); i++)
{
SetVisibleEditor(visibleEditors[i], false);
}
// Update the active workbook
if (!activeWorkbookID.empty())
{
editorPresentation->SetActiveEditorWorkbookFromID(activeWorkbookID);
}
if (!activeEditor.empty() && activeEditor[0])
{
IWorkbenchPart::Pointer editor = activeEditor[0]->GetPart(true);
if (editor)
{
page->Activate(editor);
}
}
// }});
}
catch (...)
{
// The exception is already logged.
// result
// .add(new Status(
// IStatus.ERR,
// PlatformUI.PLUGIN_ID,
// 0,
// WorkbenchMessages.EditorManager_exceptionRestoringEditor,
// t));
result &= false;
}
return result;
}
bool EditorManager::SaveAll(bool confirm, bool closing,
bool addNonPartSources)
{
// Get the list of dirty editors and views. If it is
// empty just return.
std::vector parts(page->GetDirtyParts());
if (parts.empty())
{
return true;
}
std::vector wbParts;
for (std::vector::const_iterator i = parts.begin();
i != parts.end(); ++i)
{
if (IWorkbenchPart::Pointer part = i->Cast())
{
wbParts.push_back(part);
}
}
// If confirmation is required ..
return this->SaveAll(wbParts, confirm, closing, addNonPartSources, IWorkbenchWindow::Pointer(window));
}
bool EditorManager::SaveAll(
const std::vector& /*dirtyParts*/, bool /*confirm*/,
bool /*closing*/, bool /*addNonPartSources*/, SmartPointer /*window*/)
{
// // clone the input list
// dirtyParts = new ArrayList(dirtyParts);
// List modelsToSave;
// if (confirm) {
// boolean saveable2Processed = false;
// // Process all parts that implement ISaveablePart2.
// // These parts are removed from the list after saving
// // them. We then need to restore the workbench to
// // its previous state, for now this is just last
// // active perspective.
// // Note that the given parts may come from multiple
// // windows, pages and perspectives.
// ListIterator listIterator = dirtyParts.listIterator();
//
// WorkbenchPage currentPage = null;
// Perspective currentPageOriginalPerspective = null;
// while (listIterator.hasNext()) {
// IWorkbenchPart part = (IWorkbenchPart) listIterator.next();
// if (part instanceof ISaveablePart2) {
// WorkbenchPage page = (WorkbenchPage) part.getSite()
// .getPage();
// if (!Util.equals(currentPage, page)) {
// if (currentPage != null
// && currentPageOriginalPerspective != null) {
// if (!currentPageOriginalPerspective
// .equals(currentPage.getActivePerspective())) {
// currentPage
// .setPerspective(currentPageOriginalPerspective
// .getDesc());
// }
// }
// currentPage = page;
// currentPageOriginalPerspective = page
// .getActivePerspective();
// }
// if (confirm) {
// if (part instanceof IViewPart) {
// Perspective perspective = page
// .getFirstPerspectiveWithView((IViewPart) part);
// if (perspective != null) {
// page.setPerspective(perspective.getDesc());
// }
// }
// // show the window containing the page?
// IWorkbenchWindow partsWindow = page
// .getWorkbenchWindow();
// if (partsWindow != partsWindow.getWorkbench()
// .getActiveWorkbenchWindow()) {
// Shell shell = partsWindow.getShell();
// if (shell.getMinimized()) {
// shell.setMinimized(false);
// }
// shell.setActive();
// }
// page.bringToTop(part);
// }
// // try to save the part
// int choice = SaveableHelper.savePart((ISaveablePart2) part,
// page.getWorkbenchWindow(), confirm);
// if (choice == ISaveablePart2.CANCEL) {
// // If the user cancels, don't restore the previous
// // workbench state, as that will
// // be an unexpected switch from the current state.
// return false;
// } else if (choice != ISaveablePart2.DEFAULT) {
// saveable2Processed = true;
// listIterator.remove();
// }
// }
// }
//
// // try to restore the workbench to its previous state
// if (currentPage != null && currentPageOriginalPerspective != null) {
// if (!currentPageOriginalPerspective.equals(currentPage
// .getActivePerspective())) {
// currentPage.setPerspective(currentPageOriginalPerspective
// .getDesc());
// }
// }
//
// // if processing a ISaveablePart2 caused other parts to be
// // saved, remove them from the list presented to the user.
// if (saveable2Processed) {
// listIterator = dirtyParts.listIterator();
// while (listIterator.hasNext()) {
// ISaveablePart part = (ISaveablePart) listIterator.next();
// if (!part.isDirty()) {
// listIterator.remove();
// }
// }
// }
//
// modelsToSave = convertToSaveables(dirtyParts, closing, addNonPartSources);
//
// // If nothing to save, return.
// if (modelsToSave.isEmpty()) {
// return true;
// }
// boolean canceled = SaveableHelper.waitForBackgroundSaveJobs(modelsToSave);
// if (canceled) {
// return false;
// }
// // Use a simpler dialog if there's only one
// if (modelsToSave.size() == 1) {
// Saveable model = (Saveable) modelsToSave.get(0);
// String message = NLS.bind(WorkbenchMessages.EditorManager_saveChangesQuestion, model.getName());
// // Show a dialog.
// String[] buttons = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL };
// MessageDialog d = new MessageDialog(
// shellProvider.getShell(), WorkbenchMessages.Save_Resource,
// null, message, MessageDialog.QUESTION, buttons, 0);
//
// int choice = SaveableHelper.testGetAutomatedResponse();
// if (SaveableHelper.testGetAutomatedResponse() == SaveableHelper.USER_RESPONSE) {
// choice = d.open();
// }
//
// // Branch on the user choice.
// // The choice id is based on the order of button labels
// // above.
// switch (choice) {
// case ISaveablePart2.YES: // yes
// break;
// case ISaveablePart2.NO: // no
// return true;
// default:
// case ISaveablePart2.CANCEL: // cancel
// return false;
// }
// }
// else {
// ListSelectionDialog dlg = new ListSelectionDialog(
// shellProvider.getShell(), modelsToSave,
// new ArrayContentProvider(),
// new WorkbenchPartLabelProvider(), RESOURCES_TO_SAVE_MESSAGE);
// dlg.setInitialSelections(modelsToSave.toArray());
// dlg.setTitle(SAVE_RESOURCES_TITLE);
//
// // this "if" statement aids in testing.
// if (SaveableHelper.testGetAutomatedResponse()==SaveableHelper.USER_RESPONSE) {
// int result = dlg.open();
// //Just return false to prevent the operation continuing
// if (result == IDialogConstants.CANCEL_ID) {
// return false;
// }
//
// modelsToSave = Arrays.asList(dlg.getResult());
// }
// }
// }
// else {
// modelsToSave = convertToSaveables(dirtyParts, closing, addNonPartSources);
// }
//
// // If the editor list is empty return.
// if (modelsToSave.isEmpty()) {
// return true;
// }
//
// // Create save block.
// final List finalModels = modelsToSave;
// IRunnableWithProgress progressOp = new IRunnableWithProgress() {
// public void run(IProgressMonitor monitor) {
// IProgressMonitor monitorWrap = new EventLoopProgressMonitor(
// monitor);
// monitorWrap.beginTask("", finalModels.size()); //$NON-NLS-1$
// for (Iterator i = finalModels.iterator(); i.hasNext();) {
// Saveable model = (Saveable) i.next();
// // handle case where this model got saved as a result of saving another
// if (!model.isDirty()) {
// monitor.worked(1);
// continue;
// }
// SaveableHelper.doSaveModel(model, new SubProgressMonitor(monitorWrap, 1), shellProvider, closing || confirm);
// if (monitorWrap.isCanceled()) {
// break;
// }
// }
// monitorWrap.done();
// }
// };
//
// // Do the save.
// return SaveableHelper.runProgressMonitorOperation(
// WorkbenchMessages.Save_All, progressOp, runnableContext, shellProvider);
return true;
}
bool EditorManager::SavePart(ISaveablePart::Pointer /*saveable*/, IWorkbenchPart::Pointer /*part*/, bool /*confirm*/)
{
//TODO EditorManager save part (SaveableHelper)
//return SaveableHelper.savePart(saveable, part, window, confirm);
return true;
}
bool EditorManager::SaveState(const IMemento::Pointer memento)
{
// final MultiStatus result = new MultiStatus(PlatformUI.PLUGIN_ID,
// IStatus.OK,
// WorkbenchMessages.EditorManager_problemsSavingEditors, null);
bool result = true;
// Save the editor area workbooks layout/relationship
IMemento::Pointer editorAreaMem = memento->CreateChild(WorkbenchConstants::TAG_AREA);
//result.add(editorPresentation.saveState(editorAreaMem));
result &= editorPresentation->SaveState(editorAreaMem);
// Save the active workbook id
editorAreaMem->PutString(WorkbenchConstants::TAG_ACTIVE_WORKBOOK,
editorPresentation->GetActiveEditorWorkbookID());
// Get each workbook
std::list workbooks(editorPresentation->GetWorkbooks());
for (std::list::iterator iter = workbooks.begin();
iter != workbooks.end(); ++iter)
{
PartStack::Pointer workbook = *iter;
// Use the list of editors found in EditorStack; fix for 24091
- std::list editorPanes(workbook->GetChildren());
+ std::list editorPanes(workbook->GetChildren());
- for (std::list::iterator i = editorPanes.begin();
+ for (std::list::iterator i = editorPanes.begin();
i != editorPanes.end(); ++i)
{
// Save each open editor.
EditorReference::Pointer editorReference = i->Cast()->GetPartReference().Cast();
IEditorPart::Pointer editor = editorReference->GetEditor(false);
if (!editor)
{
if (editorReference->GetMemento())
{
IMemento::Pointer editorMem = memento
->CreateChild(WorkbenchConstants::TAG_EDITOR);
editorMem->PutMemento(editorReference->GetMemento());
}
continue;
}
// for dynamic UI - add the next line to replace the subsequent
// code which is commented out
SaveEditorState(memento, editorReference); //, result);
}
}
return result;
}
bool EditorManager::SetVisibleEditor(IEditorReference::Pointer newEd,
bool setFocus)
{
return editorPresentation->SetVisibleEditor(newEd, setFocus);
}
IPathEditorInput::Pointer EditorManager::GetPathEditorInput(
IEditorInput::Pointer input)
{
if (input.Cast().IsNotNull())
{
return input.Cast();
}
// return (IPathEditorInput)
// Util.getAdapter(input, IPathEditorInput.class);
return IPathEditorInput::Pointer(0);
}
void EditorManager::RestoreEditorState(IMemento::Pointer /*editorMem*/,
std::vector& /*visibleEditors*/,
std::vector& /*activeEditor*/)
{
// MultiStatus result) {
//TODO Restore editor state
// String strFocus = editorMem.getString(IWorkbenchConstants.TAG_FOCUS);
// boolean visibleEditor = "true".equals(strFocus); //$NON-NLS-1$
// EditorReference::Pointer e = new EditorReference(this, editorMem);
//
// try
// {
// StartupThreading.runWithPartInitExceptions(new StartupRunnable ()
// {
//
// public void runWithException() throws Throwable
// {
// createEditorTab(e, workbookID);
// }});
//
// }
// catch (PartInitException ex)
// {
// result.add(ex.getStatus());
// }
//
// String strActivePart = editorMem
// .getString(IWorkbenchConstants.TAG_ACTIVE_PART);
// if ("true".equals(strActivePart))
// { //$NON-NLS-1$
// activeEditor[0] = e;
// }
//
// String strFocus = editorMem.getString(IWorkbenchConstants.TAG_FOCUS);
// boolean visibleEditor = "true".equals(strFocus); //$NON-NLS-1$
// if (visibleEditor)
// {
// visibleEditors.add(e);
// }
}
void EditorManager::SaveEditorState(IMemento::Pointer /*mem*/,
IEditorReference::Pointer /*ed*/)
{
//TODO Save editor state
// final EditorReference editorRef = (EditorReference) ed;
// final IEditorPart editor = ed.getEditor(false);
// final IMemento memento = mem;
// final MultiStatus result = res;
// if (!(editor.getEditorSite() instanceof EditorSite))
// {
// return;
// }
// final EditorSite site = (EditorSite) editor.getEditorSite();
// if (site.getPane() instanceof MultiEditorInnerPane)
// {
// return;
// }
//
// SafeRunner.run(new SafeRunnable()
// {
// public void run()
// {
// // Get the input.
// IEditorInput input = editor.getEditorInput();
// if (!input.exists())
// {
// return;
// }
// IPersistableElement persistable = input.getPersistable();
// if (persistable == null)
// {
// return;
// }
//
// // Save editor.
// IMemento editorMem = memento
// .createChild(IWorkbenchConstants.TAG_EDITOR);
// editorMem.putString(IWorkbenchConstants.TAG_TITLE, editorRef
// .getTitle());
// editorMem.putString(IWorkbenchConstants.TAG_NAME, editorRef
// .getName());
// editorMem.putString(IWorkbenchConstants.TAG_ID, editorRef
// .getId());
// editorMem.putString(IWorkbenchConstants.TAG_TOOLTIP, editorRef
// .getTitleToolTip());
//
// editorMem.putString(IWorkbenchConstants.TAG_PART_NAME,
// editorRef.getPartName());
//
// if (editor instanceof IWorkbenchPart3)
// {
// Map properties = ((IWorkbenchPart3) editor)
// .getPartProperties();
// if (!properties.isEmpty())
// {
// IMemento propBag = editorMem
// .createChild(IWorkbenchConstants.TAG_PROPERTIES);
// Iterator i = properties.entrySet().iterator();
// while (i.hasNext())
// {
// Map.Entry entry = (Map.Entry) i.next();
// IMemento p = propBag.createChild(
// IWorkbenchConstants.TAG_PROPERTY,
// (String) entry.getKey());
// p.putTextData((String) entry.getValue());
// }
// }
// }
//
// if (editorRef.isPinned())
// {
// editorMem.putString(IWorkbenchConstants.TAG_PINNED, "true"); //$NON-NLS-1$
// }
//
// EditorPane editorPane = (EditorPane) ((EditorSite) editor
// .getEditorSite()).getPane();
// editorMem.putString(IWorkbenchConstants.TAG_WORKBOOK,
// editorPane.getWorkbook().getID());
//
// if (editor == page.getActivePart())
// {
// editorMem.putString(IWorkbenchConstants.TAG_ACTIVE_PART,
// "true"); //$NON-NLS-1$
// }
//
// if (editorPane == editorPane.getWorkbook().getSelection())
// {
// editorMem.putString(IWorkbenchConstants.TAG_FOCUS, "true"); //$NON-NLS-1$
// }
//
// if (input instanceof IPathEditorInput)
// {
// IPath path = ((IPathEditorInput) input).getPath();
// if (path != null)
// {
// editorMem.putString(IWorkbenchConstants.TAG_PATH, path
// .toString());
// }
// }
//
// // Save input.
// IMemento inputMem = editorMem
// .createChild(IWorkbenchConstants.TAG_INPUT);
// inputMem.putString(IWorkbenchConstants.TAG_FACTORY_ID,
// persistable.getFactoryId());
// persistable.saveState(inputMem);
//
// // any editors that want to persist state
// if (editor instanceof IPersistableEditor)
// {
// IMemento editorState = editorMem
// .createChild(IWorkbenchConstants.TAG_EDITOR_STATE);
// ((IPersistableEditor) editor).saveState(editorState);
// }
// }
//
// public void handleException(Throwable e)
// {
// result
// .add(new Status(
// IStatus.ERR,
// PlatformUI.PLUGIN_ID,
// 0,
// NLS
// .bind(
// WorkbenchMessages.EditorManager_unableToSaveEditor,
// editorRef.getTitle()), e));
// }
// }
// );
}
IMemento::Pointer EditorManager::GetMemento(IEditorReference::Pointer e)
{
if (e.Cast().IsNotNull())
{
return e.Cast()->GetMemento();
}
return IMemento::Pointer(0);
}
IEditorReference::Pointer EditorManager::OpenEmptyTab()
{
IEditorInput::Pointer input(new NullEditorInput());
EditorDescriptor::Pointer desc = (dynamic_cast(this->GetEditorRegistry()))
->FindEditor(EditorRegistry::EMPTY_EDITOR_ID).Cast();
EditorReference::Pointer result(new EditorReference(this, input, desc));
try
{
this->CreateEditorTab(result, ""); //$NON-NLS-1$
return result;
}
catch (PartInitException e)
{
// StatusManager.getManager().handle(
// StatusUtil.newStatus(WorkbenchPlugin.PI_WORKBENCH, e));
BERRY_ERROR << e.displayText() << std::endl;
}
return IEditorReference::Pointer(0);
}
bool EditorManager::UseIPersistableEditor()
{
// IPreferenceStore store = WorkbenchPlugin.getDefault()
// .getPreferenceStore();
// return store.getBoolean(IPreferenceConstants.USE_IPERSISTABLE_EDITORS);
return false;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorSashContainer.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorSashContainer.cpp
index e1fd834cad..1c37f950d3 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorSashContainer.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorSashContainer.cpp
@@ -1,609 +1,609 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryEditorSashContainer.h"
#include "berryPresentationSerializer.h"
#include "berryWorkbenchConstants.h"
#include "berryWorkbenchPlugin.h"
#include "berryLayoutTree.h"
#include "berryWorkbenchWindowConfigurer.h"
#include "berryWorkbenchWindow.h"
#include "berryQtDnDControlWidget.h"
#include "tweaklets/berryGuiWidgetsTweaklet.h"
#include
#include
namespace berry
{
const std::string EditorSashContainer::DEFAULT_WORKBOOK_ID =
"DefaultEditorWorkbook";
void EditorSashContainer::AddChild(const RelationshipInfo& info)
{
PartSashContainer::AddChild(info);
this->UpdateStackButtons();
}
void EditorSashContainer::ChildAdded(LayoutPart::Pointer child)
{
PartSashContainer::ChildAdded(child);
if (child.Cast () != 0)
{
editorWorkbooks.push_back(child.Cast ());
}
}
void EditorSashContainer::ChildRemoved(LayoutPart::Pointer child)
{
PartSashContainer::ChildRemoved(child);
if (child.Cast () != 0)
{
editorWorkbooks.remove(child.Cast());
if (activeEditorWorkbook == child)
{
this->SetActiveWorkbook(PartStack::Pointer(0), false);
}
this->UpdateStackButtons();
}
}
PartStack::Pointer EditorSashContainer::CreateDefaultWorkbook()
{
PartStack::Pointer newWorkbook = this->NewEditorWorkbook();
newWorkbook->SetID(DEFAULT_WORKBOOK_ID);
this->Add(newWorkbook);
return newWorkbook;
}
void EditorSashContainer::AddDropSupport()
{
WorkbenchWindowConfigurer::Pointer winConfigurer = page->GetWorkbenchWindow().Cast()->GetWindowConfigurer();
QtDnDControlWidget* dropWidget = static_cast(GetParent());
dropWidget->SetTransferTypes(winConfigurer->GetTransfers());
dropWidget->AddDropListener(winConfigurer->GetDropTargetListener().GetPointer());
}
PartStack::Pointer EditorSashContainer::NewEditorWorkbook()
{
PartStack::Pointer newWorkbook(new PartStack(page, true, PresentationFactoryUtil::ROLE_EDITOR));
std::stringstream buf;
buf << newWorkbook->GetClassName() << newWorkbook.GetPointer();
newWorkbook->SetID(buf.str());
return newWorkbook;
}
void* EditorSashContainer::CreateParent(void* parentWidget)
{
//return Tweaklets::Get(GuiWidgetsTweaklet::KEY)->CreateComposite(parentWidget);
return new QtDnDControlWidget(static_cast(parentWidget));
}
void EditorSashContainer::DisposeParent()
{
this->parent = 0;
}
bool EditorSashContainer::IsActiveWorkbook(PartStack::Pointer workbook)
{
return activeEditorWorkbook == workbook;
}
PartStack::Pointer EditorSashContainer::CreateStack()
{
return this->NewEditorWorkbook();
}
void EditorSashContainer::SetVisiblePart(
- IStackableContainer::Pointer container, PartPane::Pointer visiblePart)
+ ILayoutContainer::Pointer container, PartPane::Pointer visiblePart)
{
PartStack::Pointer stack = container.Cast();
if (stack == 0) return;
stack->GetContainer().Cast()->SetActiveWorkbook(stack, true);
stack->SetSelection(visiblePart);
}
-StackablePart::Pointer EditorSashContainer::GetVisiblePart(
- IStackableContainer::Pointer container)
+LayoutPart::Pointer EditorSashContainer::GetVisiblePart(
+ ILayoutContainer::Pointer container)
{
PartStack::Pointer refPart = container.Cast();
return refPart->GetSelection();
}
EditorSashContainer::EditorSashContainer(const std::string& editorId,
WorkbenchPage* page, void* parent)
: PartSashContainer(editorId, page, parent)
{
this->CreateDefaultWorkbook();
}
bool EditorSashContainer::AllowsAdd(LayoutPart::Pointer layoutPart)
{
return LayoutPart::AllowsAdd(layoutPart);
}
void EditorSashContainer::AddEditor(PartPane::Pointer pane,
PartStack::Pointer stack)
{
//EditorStack workbook = getActiveWorkbook();
stack->Add(pane);
}
void EditorSashContainer::UpdateStackButtons()
{
// // This is applicable only when the new
// // min/max behaviour is being used
// Perspective persp = getPage().getActivePerspective();
// if (!Perspective.useNewMinMax(persp))
// return;
//
// // Find the upper Right editor stack
// LayoutPart[] stacks = getChildren();
// EditorStack winner = getUpperRightEditorStack(stacks);
//
// // Now hide the buttons for all but the upper right stack
// for (int i = 0; i < stacks.length; i++)
// {
// if (!(stacks[i] instanceof EditorStack)
// )
// continue;
// ((EditorStack) stacks[i]).showMinMax(stacks[i] == winner);
// }
//
// // Force the stack's presentation state to match its perspective
// persp.refreshEditorAreaVisibility();
}
PartStack::Pointer EditorSashContainer::GetUpperRightEditorStack()
{
return this->GetUpperRightEditorStack(this->GetChildren());
}
PartStack::Pointer EditorSashContainer::GetUpperRightEditorStack(
const ILayoutContainer::ChildrenType& stacks)
{
// Find the upper Right editor stack
PartStack::Pointer winner;
Rectangle winnerRect;
for (ILayoutContainer::ChildrenType::const_iterator iter = stacks.begin();
iter != stacks.end(); ++iter)
{
LayoutPart::Pointer part = *iter;
if (part.Cast() == 0)
continue;
PartStack::Pointer stack = part.Cast();
Rectangle bb = stack->GetBounds();
if (iter == stacks.begin() || bb.y < winnerRect.y || (bb.y == winnerRect.y && bb.x
> winnerRect.x))
{
winner = stack;
winnerRect = bb;
}
}
return winner;
}
PartStack::Pointer EditorSashContainer::GetActiveWorkbook()
{
if (activeEditorWorkbook == 0)
{
if (editorWorkbooks.size() < 1)
{
this->SetActiveWorkbook(this->CreateDefaultWorkbook(), false);
}
else
{
this->SetActiveWorkbook(editorWorkbooks.front(), false);
}
}
return activeEditorWorkbook;
}
std::string EditorSashContainer::GetActiveWorkbookID()
{
return this->GetActiveWorkbook()->GetID();
}
std::list EditorSashContainer::GetEditorWorkbooks()
{
return editorWorkbooks;
}
std::size_t EditorSashContainer::GetEditorWorkbookCount()
{
return editorWorkbooks.size();
}
void EditorSashContainer::FindSashes(LayoutPart::Pointer pane,
PartPane::Sashes& sashes)
{
//Find the sashes around the current editor and
//then the sashes around the editor area.
PartSashContainer::FindSashes(pane, sashes);
ILayoutContainer::Pointer container = this->GetContainer();
if (container != 0)
{
container->FindSashes(LayoutPart::Pointer(this), sashes);
}
}
void EditorSashContainer::RemoveAllEditors()
{
PartStack::Pointer currentWorkbook = this->GetActiveWorkbook();
// Iterate over a copy so the original can be modified.
std::list workbooks(editorWorkbooks);
for (std::list::iterator iter = workbooks.begin();
iter != workbooks.end(); ++iter)
{
PartStack::Pointer workbook = *iter;
- std::list children = workbook->GetChildren();
- for (std::list::iterator childIter = children.begin();
+ std::list children = workbook->GetChildren();
+ for (std::list::iterator childIter = children.begin();
childIter != children.end(); ++childIter)
{
workbook->Remove(*childIter);
}
if (workbook != currentWorkbook)
{
this->Remove(workbook);
workbook->Dispose();
}
}
}
void EditorSashContainer::RemoveEditor(PartPane::Pointer pane)
{
PartStack::Pointer workbook = pane->GetContainer().Cast();
if (workbook == 0)
{
return;
}
workbook->Remove(pane);
// remove the editor workbook if empty
if (workbook->GetItemCount() < 1 /* && editorWorkbooks.size() > 1*/)
{
// // If the user closes the last editor and the editor area
// // is maximized, restore it
// Perspective persp = getPage().getActivePerspective();
// if (Perspective.useNewMinMax(persp))
// {
// if (persp.getPresentation().getMaximizedStack() instanceof EditorStack)
// persp.getPresentation().getMaximizedStack().
// setState(IStackPresentationSite.STATE_RESTORED);
// }
this->Remove(workbook);
workbook->Dispose();
}
}
bool EditorSashContainer::RestoreState(IMemento::Pointer memento)
{
//TODO EditorSashContainer restore state
// MultiStatus
// result =
// new MultiStatus(PlatformUI.PLUGIN_ID, IStatus.OK, WorkbenchMessages.RootLayoutContainer_problemsRestoringPerspective, 0);
bool result = true;
// Remove the default editor workbook that is
// initialy created with the editor area.
// StartupThreading.runWithoutExceptions(new StartupRunnable()
// {
//
// public void runWithException() throws Throwable
// {
PartStack::Pointer defaultWorkbook;
for (ILayoutContainer::ChildrenType::iterator i = children.begin();
i != children.end(); ++i)
{
LayoutPart::Pointer child = *i;
if (child->GetID() == DEFAULT_WORKBOOK_ID)
{
defaultWorkbook = child.Cast();
if (defaultWorkbook->GetItemCount() > 0)
{
defaultWorkbook = 0;
}
}
}
if (defaultWorkbook)
{
Remove(defaultWorkbook);
}
// }}
// );
// Restore the relationship/layout
std::vector infos(memento->GetChildren(WorkbenchConstants::TAG_INFO));
Poco::HashMap mapIDtoPart(infos.size());
for (std::size_t i = 0; i < infos.size(); i++)
{
// Get the info details.
IMemento::Pointer childMem = infos[i];
std::string partID; childMem->GetString(WorkbenchConstants::TAG_PART, partID);
std::string relativeID; childMem->GetString(WorkbenchConstants::TAG_RELATIVE, relativeID);
int relationship = 0;
int left = 0, right = 0;
if (!relativeID.empty())
{
childMem->GetInteger(WorkbenchConstants::TAG_RELATIONSHIP, relationship);
childMem->GetInteger(WorkbenchConstants::TAG_RATIO_LEFT, left);
childMem->GetInteger(WorkbenchConstants::TAG_RATIO_RIGHT, right);
}
PartStack::Pointer workbook;
// StartupThreading.runWithoutExceptions(new StartupRunnable()
// {
//
// public void runWithException() throws Throwable
// {
// Create the part.
workbook = NewEditorWorkbook();
workbook->SetID(partID);
// 1FUN70C: ITPUI:WIN - Shouldn't set Container when not active
workbook->SetContainer(ILayoutContainer::Pointer(this));
// }}
// );
IMemento::Pointer workbookMemento = childMem->GetChild(
WorkbenchConstants::TAG_FOLDER);
if (workbookMemento)
{
//result.add(workbook[0].restoreState(workbookMemento));
result &= workbook->RestoreState(workbookMemento);
}
const int myLeft = left, myRight = right, myRelationship = relationship;
// StartupThreading.runWithoutExceptions(new StartupRunnable()
// {
//
// public void runWithException() throws Throwable
// {
// Add the part to the layout
if (relativeID.empty())
{
Add(workbook);
}
else
{
LayoutPart::Pointer refPart = mapIDtoPart[relativeID];
if (refPart)
{
Add(workbook, myRelationship, myLeft, myRight, refPart);
}
else
{
WorkbenchPlugin::Log("Unable to find part for ID: " + relativeID);
}
}
// }}
// );
mapIDtoPart[partID] = workbook;
}
return result;
}
bool EditorSashContainer::SaveState(IMemento::Pointer memento)
{
std::vector relationships(ComputeRelation());
// MultiStatus
// result =
// new MultiStatus(PlatformUI.PLUGIN_ID, IStatus.OK, WorkbenchMessages.RootLayoutContainer_problemsSavingPerspective, 0);
bool result = true;
for (std::size_t i = 0; i < relationships.size(); i++)
{
// Save the relationship info ..
// private LayoutPart part;
// private int relationship;
// private float ratio;
// private LayoutPart relative;
const RelationshipInfo& info = relationships[i];
IMemento::Pointer childMem = memento->CreateChild(
WorkbenchConstants::TAG_INFO);
childMem->PutString(WorkbenchConstants::TAG_PART, info.part->GetID());
PartStack::Pointer stack = info.part.Cast();
if (stack)
{
IMemento::Pointer folderMem = childMem->CreateChild(
WorkbenchConstants::TAG_FOLDER);
//result.add(stack.saveState(folderMem));
result &= stack->SaveState(folderMem);
}
if (info.relative != 0)
{
childMem->PutString(WorkbenchConstants::TAG_RELATIVE, info.relative->GetID());
childMem->PutInteger(WorkbenchConstants::TAG_RELATIONSHIP, info.relationship);
childMem->PutInteger(WorkbenchConstants::TAG_RATIO_LEFT, info.left);
childMem->PutInteger(WorkbenchConstants::TAG_RATIO_RIGHT, info.right);
}
}
return result;
}
void EditorSashContainer::SetActiveWorkbook(PartStack::Pointer newWorkbook,
bool hasFocus)
{
if (newWorkbook != 0)
{
if (std::find(editorWorkbooks.begin(), editorWorkbooks.end(), newWorkbook) == editorWorkbooks.end())
{
return;
}
}
PartStack::Pointer oldWorkbook = activeEditorWorkbook;
activeEditorWorkbook = newWorkbook;
if (oldWorkbook != 0 && oldWorkbook != newWorkbook)
{
oldWorkbook->SetActive(StackPresentation::AS_INACTIVE);
}
if (newWorkbook != 0)
{
if (hasFocus)
{
newWorkbook->SetActive(StackPresentation::AS_ACTIVE_FOCUS);
}
else
{
newWorkbook->SetActive(StackPresentation::AS_ACTIVE_NOFOCUS);
}
}
this->UpdateTabList();
}
void EditorSashContainer::SetActiveWorkbookFromID(const std::string& id)
{
for (std::list::iterator iter = editorWorkbooks.begin();
iter != editorWorkbooks.end(); ++iter)
{
PartStack::Pointer workbook = *iter;
if (workbook->GetID() == id)
{
this->SetActiveWorkbook(workbook, false);
}
}
}
PartStack::Pointer EditorSashContainer::GetWorkbookFromID(const std::string& id)
{
for (std::list::iterator iter = editorWorkbooks.begin();
iter != editorWorkbooks.end(); ++iter)
{
PartStack::Pointer workbook = *iter;
if (workbook->GetID() == id)
{
return workbook;
}
}
return PartStack::Pointer(0);
}
void EditorSashContainer::UpdateTabList()
{
void* parent = this->GetParent();
if (parent != 0)
{ // parent may be 0 on startup
PartStack::Pointer wb(this->GetActiveWorkbook());
//TODO EditorSashContainer update tab list
// if (wb == 0)
// {
// parent.setTabList(new Control[0]);
// }
// else
// {
// parent.setTabList(wb.getTabList());
// }
}
}
void EditorSashContainer::CreateControl(void* parent)
{
PartSashContainer::CreateControl(parent);
///let the user drop files/editor input on the editor area
this->AddDropSupport();
}
bool EditorSashContainer::IsCompressible()
{
//Added for bug 19524
return true;
}
-bool EditorSashContainer::IsStackType(IStackableContainer::Pointer toTest)
+bool EditorSashContainer::IsStackType(ILayoutContainer::Pointer toTest)
{
if (toTest.Cast() == 0)
return false;
return (toTest.Cast ()->GetAppearance()
== PresentationFactoryUtil::ROLE_EDITOR);
}
-bool EditorSashContainer::IsPaneType(StackablePart::Pointer toTest)
+bool EditorSashContainer::IsPaneType(LayoutPart::Pointer toTest)
{
if (toTest.Cast() == 0)
return false;
return (toTest.Cast ()->GetPartReference().Cast ()
!= 0);
}
bool EditorSashContainer::RestorePresentationState(IMemento::Pointer /*areaMem*/)
{
std::list workbooks = this->GetEditorWorkbooks();
for (std::list::iterator iter = workbooks.begin();
iter != workbooks.end(); ++iter)
{
PartStack::Pointer workbook = *iter;
IMemento::Pointer memento = workbook->GetSavedPresentationState();
if (memento == 0)
{
continue;
}
std::list listParts = workbook->GetPresentableParts();
std::vector parts(listParts.begin(), listParts.end());
PresentationSerializer serializer(parts);
//StartupThreading.runWithoutExceptions(new StartupRunnable()
// {
// public void runWithException() throws Throwable
// {
workbook->GetPresentation()->RestoreState(&serializer, memento);
// }}
// );
}
//return new Status(IStatus.OK, PlatformUI.PLUGIN_ID, 0, "", 0); //$NON-NLS-1$
return true;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorSashContainer.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorSashContainer.h
index adffa13e59..dc39a87545 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorSashContainer.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorSashContainer.h
@@ -1,253 +1,253 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYEDITORSASHCONTAINER_H_
#define BERRYEDITORSASHCONTAINER_H_
#include "berryPartSashContainer.h"
#include "berryPartStack.h"
#include
namespace berry
{
/**
* Represents the area set aside for editor workbooks.
* This container only accepts editor stacks (PartStack) and PartSash
* as layout parts.
*
* Note no views are allowed within this container.
*/
class EditorSashContainer: public PartSashContainer
{
public:
berryObjectMacro(EditorSashContainer);
private:
std::list editorWorkbooks;
PartStack::Pointer activeEditorWorkbook;
// DropTarget dropTarget;
void AddDropSupport();
PartStack::Pointer NewEditorWorkbook();
protected:
/* (non-Javadoc)
* @see org.blueberry.ui.internal.PartSashContainer#addChild(org.blueberry.ui.internal.PartSashContainer.RelationshipInfo)
*/
void AddChild(const RelationshipInfo& info);
/**
* Notification that a child layout part has been
* added to the container. Subclasses may override
* this method to perform any container specific
* work.
*/
void ChildAdded(LayoutPart::Pointer child);
/**
* Notification that a child layout part has been
* removed from the container. Subclasses may override
* this method to perform any container specific
* work.
*/
void ChildRemoved(LayoutPart::Pointer child);
PartStack::Pointer CreateDefaultWorkbook();
/**
* Subclasses override this method to specify
* the composite to use to parent all children
* layout parts it contains.
*/
void* CreateParent(void* parentWidget);
/**
* Subclasses override this method to dispose
* of any swt resources created during createParent.
*/
void DisposeParent();
/**
* Return true is the workbook specified
* is the active one.
*/
bool IsActiveWorkbook(PartStack::Pointer workbook);
//TODO DND
// /* package */DropTarget getDropTarget() {
// return dropTarget;
// }
/* (non-Javadoc)
* @see org.blueberry.ui.internal.PartSashContainer#createStack(org.blueberry.ui.internal.LayoutPart)
*/
PartStack::Pointer CreateStack();
/* (non-Javadoc)
* @see org.blueberry.ui.internal.PartSashContainer#setVisiblePart(org.blueberry.ui.internal.ILayoutContainer, org.blueberry.ui.internal.LayoutPart)
*/
- void SetVisiblePart(IStackableContainer::Pointer container,
+ void SetVisiblePart(ILayoutContainer::Pointer container,
PartPane::Pointer visiblePart);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.PartSashContainer#getVisiblePart(org.blueberry.ui.internal.ILayoutContainer)
*/
- StackablePart::Pointer GetVisiblePart(IStackableContainer::Pointer container);
+ LayoutPart::Pointer GetVisiblePart(ILayoutContainer::Pointer container);
public:
static const std::string DEFAULT_WORKBOOK_ID;
EditorSashContainer(const std::string& editorId, WorkbenchPage* page,
void* parent);
bool AllowsAdd(LayoutPart::Pointer layoutPart);
/**
* Add an editor to the active workbook.
*/
void AddEditor(PartPane::Pointer pane, PartStack::Pointer stack);
/**
* Hides the min/max buttons for all editor stacks
* -except- for the upper/left one.
*/
void UpdateStackButtons();
/**
* @param stacks
* @return the EditorStack in the upper right position
*/
PartStack::Pointer GetUpperRightEditorStack();
/**
* @param stacks
* @return the EditorStack in the upper right position
*/
PartStack::Pointer GetUpperRightEditorStack(
const ILayoutContainer::ChildrenType& stacks);
/**
* Return the editor workbook which is active.
*/
PartStack::Pointer GetActiveWorkbook();
/**
* Return the editor workbook id which is active.
*/
std::string GetActiveWorkbookID();
/**
* Return the all the editor workbooks.
*/
std::list GetEditorWorkbooks();
/**
* Return the all the editor workbooks.
*/
std::size_t GetEditorWorkbookCount();
/**
* Find the sashes around the specified part.
*/
void FindSashes(LayoutPart::Pointer pane, PartPane::Sashes& sashes);
/**
* Remove all the editors
*/
void RemoveAllEditors();
/**
* Remove an editor from its' workbook.
*/
void RemoveEditor(PartPane::Pointer pane);
/**
* @see IPersistablePart
*/
bool RestoreState(IMemento::Pointer memento);
/**
* @see IPersistablePart
*/
bool SaveState(IMemento::Pointer memento);
/**
* Set the editor workbook which is active.
*/
void SetActiveWorkbook(PartStack::Pointer newWorkbook, bool hasFocus);
/**
* Set the editor workbook which is active.
*/
void SetActiveWorkbookFromID(const std::string& id);
PartStack::Pointer GetWorkbookFromID(const std::string& id);
/**
* Updates the editor area's tab list to include the active
* editor and its tab.
*/
void UpdateTabList();
/**
* @see org.blueberry.ui.internal.LayoutPart#createControl(org.blueberry.swt.widgets.Composite)
*/
void CreateControl(void* parent);
/**
* @see org.blueberry.ui.internal.LayoutPart#getImportance()
*/
bool IsCompressible();
/* (non-Javadoc)
* @see org.blueberry.ui.internal.PartSashContainer#isStackType(org.blueberry.ui.internal.LayoutPart)
*/
- bool IsStackType(IStackableContainer::Pointer toTest);
+ bool IsStackType(ILayoutContainer::Pointer toTest);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.PartSashContainer#isPaneType(org.blueberry.ui.internal.LayoutPart)
*/
- bool IsPaneType(StackablePart::Pointer toTest);
+ bool IsPaneType(LayoutPart::Pointer toTest);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.PartSashContainer#pickPartToZoom()
*/
// LayoutPart pickPartToZoom() {
// return getActiveWorkbook();
// }
/**
* Restore the presentation state. Loop over the workbooks, create the appropriate serializer and pass to the presentation.
*
* @param areaMem the memento containing presentation
* @return the restoration status
*/
bool RestorePresentationState(IMemento::Pointer areaMem);
};
}
#endif /* BERRYEDITORSASHCONTAINER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryFolderLayout.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryFolderLayout.cpp
index 0511d7ac95..ba037886e6 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryFolderLayout.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryFolderLayout.cpp
@@ -1,97 +1,97 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryFolderLayout.h"
#include "berryPartPlaceholder.h"
#include "berryWorkbenchPlugin.h"
#include "berryPageLayout.h"
#include "berryLayoutHelper.h"
#include "berryUIException.h"
namespace berry
{
FolderLayout::FolderLayout(PageLayout::Pointer pageLayout, PartStack::Pointer folder,
ViewFactory* viewFactory)
{
this->folder = folder;
this->viewFactory = viewFactory;
this->pageLayout = pageLayout;
}
void FolderLayout::AddPlaceholder(const std::string& viewId)
{
if (!pageLayout->CheckValidPlaceholderId(viewId))
{
return;
}
// Create the placeholder.
- StackablePart::Pointer newPart(new PartPlaceholder(viewId));
+ LayoutPart::Pointer newPart(new PartPlaceholder(viewId));
this->LinkPartToPageLayout(viewId, newPart);
// Add it to the folder layout.
folder->Add(newPart);
}
void FolderLayout::AddView(const std::string& viewId)
{
if (pageLayout->CheckPartInLayout(viewId))
{
return;
}
try
{
IViewDescriptor::Pointer descriptor = viewFactory->GetViewRegistry()->Find(
ViewFactory::ExtractPrimaryId(viewId));
if (descriptor == 0)
{
throw PartInitException("View descriptor not found: " + viewId); //$NON-NLS-1$
}
PartPane::Pointer newPart = LayoutHelper::CreateView(pageLayout->GetViewFactory(), viewId);
this->LinkPartToPageLayout(viewId, newPart);
folder->Add(newPart);
}
catch (PartInitException& e)
{
// cannot safely open the dialog so log the problem
WorkbenchPlugin::Log(this->GetClassName(), "AddView(const std::string&)", e); //$NON-NLS-1$
}
}
std::string FolderLayout::GetProperty(const std::string& id)
{
return folder->GetProperty(id);
}
void FolderLayout::SetProperty(const std::string& id, const std::string& value)
{
folder->SetProperty(id, value);
}
void FolderLayout::LinkPartToPageLayout(const std::string& viewId,
- StackablePart::Pointer newPart)
+ LayoutPart::Pointer newPart)
{
pageLayout->SetRefPart(viewId, newPart);
pageLayout->SetFolderPart(viewId, folder);
// force creation of the view layout rec
pageLayout->GetViewLayoutRec(viewId, true);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryFolderLayout.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryFolderLayout.h
index bd2d64ca06..f94bdf9a25 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryFolderLayout.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryFolderLayout.h
@@ -1,96 +1,96 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYFOLDERLAYOUT_H_
#define BERRYFOLDERLAYOUT_H_
#include "berryIFolderLayout.h"
#include "berryPartStack.h"
#include "berryViewFactory.h"
namespace berry {
class PageLayout;
/**
* \ingroup org_blueberry_ui_internal
*
* This layout is used to define the initial set of views and placeholders
* in a folder.
*
* Views are added to the folder by ID. This id is used to identify
* a view descriptor in the view registry, and this descriptor is used to
* instantiate the IViewPart
.
*
*/
class FolderLayout : public IFolderLayout {
public: berryObjectMacro(FolderLayout)
private:
PartStack::Pointer folder;
SmartPointer pageLayout;
ViewFactory* viewFactory;
public:
/**
* Create an instance of a FolderLayout
belonging to a
* PageLayout
.
*/
FolderLayout(SmartPointer pageLayout, PartStack::Pointer folder,
ViewFactory* viewFactory);
/* (non-Javadoc)
* @see org.blueberry.ui.IPlaceholderFolderLayout#addPlaceholder(java.lang.String)
*/
void AddPlaceholder(const std::string& viewId);
/* (non-Javadoc)
* @see org.blueberry.ui.IFolderLayout#addView(java.lang.String)
*/
void AddView(const std::string& viewId);
/* (non-Javadoc)
* @see org.blueberry.ui.IPlaceholderFolderLayout#getProperty(java.lang.String)
*/
std::string GetProperty(const std::string& id);
/* (non-Javadoc)
* @see org.blueberry.ui.IPlaceholderFolderLayout#setProperty(java.lang.String, java.lang.String)
*/
void SetProperty(const std::string& id, const std::string& value);
private:
/**
* Inform the page layout of the new part created
* and the folder the part belongs to.
*/
- void LinkPartToPageLayout(const std::string& viewId, StackablePart::Pointer newPart);
+ void LinkPartToPageLayout(const std::string& viewId, LayoutPart::Pointer newPart);
};
}
#endif /*BERRYFOLDERLAYOUT_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryILayoutContainer.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryILayoutContainer.h
index 4f270c567f..5d0b6161d6 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryILayoutContainer.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryILayoutContainer.h
@@ -1,122 +1,122 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYILAYOUTCONTAINER_H_
#define BERRYILAYOUTCONTAINER_H_
#include "berryLayoutPart.h"
#include "berryPartPane.h"
#include
namespace berry {
/**
* \ingroup org_blueberry_ui_internal
*
*/
struct BERRY_UI ILayoutContainer : virtual public Object {
berryObjectMacro(ILayoutContainer);
~ILayoutContainer();
typedef std::list ChildrenType;
virtual bool AllowsAdd(LayoutPart::Pointer toAdd) = 0;
/**
* Add a child to the container.
*/
virtual void Add(LayoutPart::Pointer newPart) = 0;
/**
* Returns a list of layout children.
*/
- virtual ChildrenType GetChildren() = 0;
+ virtual ChildrenType GetChildren() const = 0;
/**
* Remove a child from the container.
*/
virtual void Remove(LayoutPart::Pointer part) = 0;
/**
* Replace one child with another
*/
virtual void Replace(LayoutPart::Pointer oldPart, LayoutPart::Pointer newPart) = 0;
virtual void FindSashes(LayoutPart::Pointer toFind, PartPane::Sashes& result) = 0;
/**
* When a layout part closes, focus will return to the previously active part.
* This method determines whether the parts in this container should participate
* in this behavior. If this method returns true, its parts may automatically be
* given focus when another part is closed.
*
* @return true iff the parts in this container may be given focus when the active
* part is closed
*/
virtual bool AllowsAutoFocus() = 0;
/**
* Called by child parts to request a zoom in, given an immediate child
*
* @param toZoom
* @since 3.1
*/
//public void childRequestZoomIn(LayoutPart toZoom);
/**
* Called by child parts to request a zoom out
*
* @since 3.1
*/
//public void childRequestZoomOut();
/**
* Returns true iff the given child is obscured due to the fact that the container is zoomed into
* another part.
*
* @param toTest
* @return
* @since 3.1
*/
//public boolean childObscuredByZoom(LayoutPart toTest);
/**
* Returns true iff we are zoomed into the given part, given an immediate child of this container.
*
* @param toTest
* @return
* @since 3.1
*/
//public boolean childIsZoomed(LayoutPart toTest);
/**
* Called when the preferred size of the given child has changed, requiring a
* layout to be triggered.
*
* @param childThatChanged the child that triggered the new layout
*/
virtual void ResizeChild(LayoutPart::Pointer childThatChanged) = 0;
};
}
#endif /*BERRYILAYOUTCONTAINER_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryIStackableContainer.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryIStackableContainer.cpp
deleted file mode 100644
index 96f6705e08..0000000000
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryIStackableContainer.cpp
+++ /dev/null
@@ -1,26 +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 "berryIStackableContainer.h"
-
-
-namespace berry {
-
-IStackableContainer::~IStackableContainer()
-{
-}
-
-}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryIStackableContainer.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryIStackableContainer.h
deleted file mode 100755
index 08d78f52a8..0000000000
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryIStackableContainer.h
+++ /dev/null
@@ -1,127 +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 BERRYISTACKABLECONTAINER_H_
-#define BERRYISTACKABLECONTAINER_H_
-
-#include "berryStackablePart.h"
-
-#include "berryPartPane.h"
-
-#include
-
-namespace berry {
-
-/**
- * \ingroup org_blueberry_ui_internal
- *
- */
-struct BERRY_UI IStackableContainer : virtual public Object {
-
- berryObjectMacro(IStackableContainer);
-
- typedef std::list ChildrenType;
-
- ~IStackableContainer();
-
- virtual bool AllowsAdd(StackablePart::Pointer toAdd) = 0;
-
- /**
- * Add a child to the container.
- */
- virtual void Add(StackablePart::Pointer newPart) = 0;
-
- /**
- * Returnd the id for this stackable container
- */
- virtual std::string GetID() const = 0;
-
- /**
- * Returns a list of layout children.
- */
- virtual ChildrenType GetChildren() const = 0;
-
- /**
- * Remove a child from the container.
- */
- virtual void Remove(StackablePart::Pointer part) = 0;
-
- /**
- * Replace one child with another
- */
- virtual void Replace(StackablePart::Pointer oldPart, StackablePart::Pointer newPart) = 0;
-
- virtual void FindSashes(PartPane::Sashes& result) = 0;
-
- /**
- * When a layout part closes, focus will return to the previously active part.
- * This method determines whether the parts in this container should participate
- * in this behavior. If this method returns true, its parts may automatically be
- * given focus when another part is closed.
- *
- * @return true iff the parts in this container may be given focus when the active
- * part is closed
- */
- virtual bool AllowsAutoFocus() = 0;
-
- /**
- * Called by child parts to request a zoom in, given an immediate child
- *
- * @param toZoom
- * @since 3.1
- */
- //public void childRequestZoomIn(LayoutPart toZoom);
-
- /**
- * Called by child parts to request a zoom out
- *
- * @since 3.1
- */
- //public void childRequestZoomOut();
-
- /**
- * Returns true iff the given child is obscured due to the fact that the container is zoomed into
- * another part.
- *
- * @param toTest
- * @return
- * @since 3.1
- */
- //public boolean childObscuredByZoom(LayoutPart toTest);
-
- /**
- * Returns true iff we are zoomed into the given part, given an immediate child of this container.
- *
- * @param toTest
- * @return
- * @since 3.1
- */
- //public boolean childIsZoomed(LayoutPart toTest);
-
- /**
- * Called when the preferred size of the given child has changed, requiring a
- * layout to be triggered.
- *
- * @param childThatChanged the child that triggered the new layout
- */
- virtual void ResizeChild(StackablePart::Pointer childThatChanged) = 0;
-
-};
-
-}
-
-#endif /* BERRYISTACKABLECONTAINER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryLayoutPart.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryLayoutPart.cpp
index f0b6116ff8..610da95b7e 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryLayoutPart.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryLayoutPart.cpp
@@ -1,337 +1,346 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryLayoutPart.h"
#include "berryILayoutContainer.h"
#include "berryDetachedWindow.h"
#include "tweaklets/berryGuiWidgetsTweaklet.h"
#include "berryIWorkbenchWindow.h"
#include "berryConstants.h"
namespace berry
{
const std::string LayoutPart::PROP_VISIBILITY = "PROP_VISIBILITY"; //$NON-NLS-1$
LayoutPart::LayoutPart(const std::string& id_) :
id(id_), deferCount(0)
{
}
LayoutPart::~LayoutPart()
{
}
bool LayoutPart::AllowsAutoFocus()
{
if (container != 0)
{
return container->AllowsAutoFocus();
}
return true;
}
void LayoutPart::Dispose()
{
}
Rectangle LayoutPart::GetBounds()
{
if (this->GetControl() == 0)
return Rectangle();
return Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetBounds(this->GetControl());
}
ILayoutContainer::Pointer LayoutPart::GetContainer()
{
return container;
}
+bool LayoutPart::IsPlaceHolder() const
+{
+ return false;
+}
+
std::string LayoutPart::GetID() const
{
return id;
}
bool LayoutPart::IsCompressible()
{
return false;
}
Point LayoutPart::GetSize()
{
Rectangle r = this->GetBounds();
Point ptSize(r.width, r.height);
return ptSize;
}
int LayoutPart::GetSizeFlags(bool /*horizontal*/)
{
return Constants::MIN;
}
int LayoutPart::ComputePreferredSize(bool /*width*/, int /*availableParallel*/,
int /*availablePerpendicular*/, int preferredParallel)
{
return preferredParallel;
}
IDropTarget::Pointer LayoutPart::GetDropTarget(Object::Pointer /*draggedObject*/, const Point& /*displayCoordinates*/)
{
return IDropTarget::Pointer(0);
}
bool LayoutPart::IsDocked()
{
Shell::Pointer s = this->GetShell();
if (s == 0) {
return false;
}
return s->GetData().Cast() != 0;
}
Shell::Pointer LayoutPart::GetShell()
{
void* ctrl = this->GetControl();
if (ctrl)
{
return Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetShell(ctrl);
}
return Shell::Pointer(0);
}
IWorkbenchWindow::Pointer LayoutPart::GetWorkbenchWindow()
{
Shell::Pointer s = this->GetShell();
if (s == 0)
{
return IWorkbenchWindow::Pointer(0);
}
Object::Pointer data = s->GetData();
if (data.Cast() != 0)
{
return data.Cast();
}
else if (data.Cast() != 0)
{
return data.Cast()->GetWorkbenchPage()->GetWorkbenchWindow();
}
return IWorkbenchWindow::Pointer(0);
}
void LayoutPart::MoveAbove(void* /*refControl*/)
{
}
void LayoutPart::Reparent(void* newParent)
{
void* control = this->GetControl();
GuiWidgetsTweaklet* guiTweaklet = Tweaklets::Get(GuiWidgetsTweaklet::KEY);
if ((control == 0) || (guiTweaklet->GetParent(control) == newParent))
{
return;
}
if (guiTweaklet->IsReparentable(control))
{
// make control small in case it is not resized with other controls
//control.setBounds(0, 0, 0, 0);
// By setting the control to disabled before moving it,
// we ensure that the focus goes away from the control and its children
// and moves somewhere else
bool enabled = guiTweaklet->GetEnabled(control);
guiTweaklet->SetEnabled(control, false);
guiTweaklet->SetParent(control, newParent);
guiTweaklet->SetEnabled(control, enabled);
guiTweaklet->MoveAbove(control, 0);
}
}
bool LayoutPart::GetVisible()
{
void* ctrl = this->GetControl();
if (ctrl)
{
return Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetVisible(ctrl);
}
return false;
}
bool LayoutPart::IsVisible()
{
void* ctrl = this->GetControl();
if (ctrl)
{
return Tweaklets::Get(GuiWidgetsTweaklet::KEY)->IsVisible(ctrl);
}
return false;
}
void LayoutPart::SetVisible(bool makeVisible)
{
void* ctrl = this->GetControl();
if (ctrl != 0)
{
if (makeVisible == Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetVisible(ctrl))
{
return;
}
// if (!makeVisible && this->IsFocusAncestor(ctrl))
// {
// // Workaround for Bug 60970 [EditorMgmt] setActive() called on an editor when it does not have focus.
// // Force focus on the shell so that when ctrl is hidden,
// // SWT does not try to send focus elsewhere, which may cause
// // some other part to be activated, which affects the part
// // activation order and can cause flicker.
// ctrl.getShell().forceFocus();
// }
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->SetVisible(ctrl, makeVisible);
}
}
bool LayoutPart::IsFocusAncestor(void* /*ctrl*/)
{
// Control f = ctrl.getDisplay().getFocusControl();
// while (f != null && f != ctrl)
// {
// f = f.getParent();
// }
// return f == ctrl;
return false;
}
void LayoutPart::SetBounds(const Rectangle& r)
{
void* ctrl = this->GetControl();
if (ctrl)
{
return Tweaklets::Get(GuiWidgetsTweaklet::KEY)->SetBounds(ctrl, r);
}
}
void LayoutPart::SetContainer(ILayoutContainer::Pointer container)
{
this->container = container;
//TODO Zoom
// if (container != 0)
// {
// setZoomed(container.childIsZoomed(this));
-// }
+ // }
+}
+
+void LayoutPart::SetFocus()
+{
}
void LayoutPart::SetID(const std::string& str)
{
id = str;
}
LayoutPart::Pointer LayoutPart::GetPart()
{
return LayoutPart::Pointer(this);
}
void LayoutPart::DeferUpdates(bool shouldDefer)
{
if (shouldDefer)
{
if (deferCount == 0)
{
this->StartDeferringEvents();
}
deferCount++;
}
else
{
if (deferCount> 0)
{
deferCount--;
if (deferCount == 0)
{
this->HandleDeferredEvents();
}
}
}
}
void LayoutPart::StartDeferringEvents()
{
}
void LayoutPart::HandleDeferredEvents()
{
}
bool LayoutPart::IsDeferred()
{
return deferCount> 0;
}
void LayoutPart::DescribeLayout(std::string& /*buf*/) const
{
}
std::string LayoutPart::GetPlaceHolderId()
{
return this->GetID();
}
void LayoutPart::ResizeChild(LayoutPart::Pointer /*childThatChanged*/)
{
}
void LayoutPart::FlushLayout()
{
ILayoutContainer::Pointer container = this->GetContainer();
if (container != 0)
{
container->ResizeChild(LayoutPart::Pointer(this));
}
}
bool LayoutPart::AllowsAdd(LayoutPart::Pointer /*toAdd*/)
{
return false;
}
std::string LayoutPart::ToString()
{
return "";
}
void LayoutPart::TestInvariants()
{
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryLayoutPart.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryLayoutPart.h
index 6ba840a7be..c2e4d0268e 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryLayoutPart.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryLayoutPart.h
@@ -1,297 +1,305 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYLAYOUTPART_H_
#define BERRYLAYOUTPART_H_
#include
#include "berryIDropTarget.h"
#include "berryISizeProvider.h"
#include "berryRectangle.h"
#include "berryPoint.h"
#include "berryShell.h"
namespace berry {
struct ILayoutContainer;
struct IWorkbenchWindow;
/**
* \ingroup org_blueberry_ui_internal
*
* A presentation part is used to build the presentation for the
* workbench. Common subclasses are pane and folder.
*/
-class LayoutPart : virtual public Object { //, public ISizeProvider {
+class LayoutPart : virtual public Object, public virtual ISizeProvider
+{
public:
berryObjectMacro(LayoutPart);
protected: SmartPointer container;
protected: std::string id;
public: static const std::string PROP_VISIBILITY;// = "PROP_VISIBILITY"; //$NON-NLS-1$
/**
* Number of times deferUpdates(true) has been called without a corresponding
* deferUpdates(false)
*/
private: int deferCount;
/**
* PresentationPart constructor comment.
*/
public: LayoutPart(const std::string& id);
public: virtual ~LayoutPart();
/**
* When a layout part closes, focus will return to a previously active part.
* This method determines whether this part should be considered for activation
* when another part closes. If a group of parts are all closing at the same time,
* they will all return false from this method while closing to ensure that the
* parent does not activate a part that is in the process of closing. Parts will
* also return false from this method if they are minimized, closed fast views,
* obscured by zoom, etc.
*
* @return true iff the parts in this container may be given focus when the active
* part is closed
*/
public: virtual bool AllowsAutoFocus();
/**
* Creates the GUI control
*/
public: virtual void CreateControl(void* parent) = 0;
/**
* Disposes the GUI control
*
* This can be used to execute cleanup code or notify listeners
* when a LayoutPart is no longer used, but is still referenced
* by a SmartPointer (instead of putting the code in the LayoutPart
* destructor).
*/
public: virtual void Dispose();
/**
* Gets the presentation bounds.
*/
public: Rectangle GetBounds();
/**
* Gets the parent for this part.
*
* In general, this is non-null if the object has been added to a container and the
* container's widgetry exists. The exception to this rule is PartPlaceholders
* created when restoring a ViewStack using restoreState, which point to the
* ViewStack even if its widgetry doesn't exist yet. Returns null in the remaining
* cases.
*
*
* TODO: change the semantics of this method to always point to the parent container,
* regardless of whether its widgetry exists. Locate and refactor code that is currently
* depending on the special cases.
*
*/
public: virtual SmartPointer GetContainer();
/**
* Get the part control. This method may return null.
*/
public: virtual void* GetControl() = 0;
+ public: virtual bool IsPlaceHolder() const;
+
/**
* Gets the ID for this part.
*/
public: virtual std::string GetID() const;
public: virtual bool IsCompressible();
/**
* Gets the presentation size.
*/
public: virtual Point GetSize();
/**
* @see org.blueberry.ui.presentations.StackPresentation#getSizeFlags(boolean)
*
* @since 3.1
*/
public: virtual int GetSizeFlags(bool horizontal);
/**
* @see org.blueberry.ui.presentations.StackPresentation#computePreferredSize(boolean, int, int, int)
*
* @since 3.1
*/
public: virtual int ComputePreferredSize(bool width, int availableParallel, int availablePerpendicular, int preferredParallel);
public: virtual IDropTarget::Pointer GetDropTarget(Object::Pointer draggedObject, const Point& displayCoordinates);
public: bool IsDocked();
public: virtual Shell::Pointer GetShell();
/**
* Returns the workbench window window for a part.
*
* @return the workbench window, or null
if there's no window
* associated with this part.
*/
public: virtual SmartPointer GetWorkbenchWindow();
/**
* Move the control over another one.
*/
public: virtual void MoveAbove(void* refControl);
/**
* Reparent a part.
*/
public: virtual void Reparent(void* newParent);
/**
* Returns true if this part was set visible. This returns whatever was last passed into
* setVisible, but does not necessarily indicate that the part can be seen (ie: one of its
* ancestors may be invisible)
*/
public: virtual bool GetVisible();
/**
* Returns true if this part can be seen. Returns false if the part or any of its ancestors
* are invisible.
*/
public: virtual bool IsVisible();
/**
* Shows the receiver if visible
is true otherwise hide it.
*/
public: virtual void SetVisible(bool makeVisible);
/**
* Returns true
if the given control or any of its descendents has focus.
*/
private: virtual bool IsFocusAncestor(void* ctrl);
/**
* Sets the presentation bounds.
*/
public: virtual void SetBounds(const Rectangle& r);
/**
* Sets the parent for this part.
*/
public: virtual void SetContainer(SmartPointer container);
+ /**
+ * Sets focus to this part.
+ */
+ public: virtual void SetFocus();
+
/**
* Sets the part ID.
*/
public: virtual void SetID(const std::string& str);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.IWorkbenchDragDropPart#getPart()
*/
public: virtual LayoutPart::Pointer GetPart();
/**
* deferUpdates(true) disables widget updates until a corresponding call to
* deferUpdates(false). Exactly what gets deferred is the decision
* of each LayoutPart, however the part may only defer operations in a manner
* that does not affect the final result.
* That is, the state of the receiver after the final call to deferUpdates(false)
* must be exactly the same as it would have been if nothing had been deferred.
*
* @param shouldDefer true iff events should be deferred
*/
public: void DeferUpdates(bool shouldDefer);
/**
* This is called when deferUpdates(true) causes UI events for this
* part to be deferred. Subclasses can overload to initialize any data
* structures that they will use to collect deferred events.
*/
protected: virtual void StartDeferringEvents();
/**
* Immediately processes all UI events which were deferred due to a call to
* deferUpdates(true). This is called when the last call is made to
* deferUpdates(false). Subclasses should overload this method if they
* defer some or all UI processing during deferUpdates.
*/
protected: virtual void HandleDeferredEvents();
/**
* Subclasses can call this method to determine whether UI updates should
* be deferred. Returns true iff there have been any calls to deferUpdates(true)
* without a corresponding call to deferUpdates(false). Any operation which is
* deferred based on the result of this method should be performed later within
* handleDeferredEvents().
*
* @return true iff updates should be deferred.
*/
protected: bool IsDeferred();
/**
* Writes a description of the layout to the given string buffer.
* This is used for drag-drop test suites to determine if two layouts are the
* same. Like a hash code, the description should compare as equal iff the
* layouts are the same. However, it should be user-readable in order to
* help debug failed tests. Although these are english readable strings,
* they do not need to be translated.
*
* @param buf
*/
public: virtual void DescribeLayout(std::string& buf) const;
/**
* Returns an id representing this part, suitable for use in a placeholder.
*
* @since 3.0
*/
public: virtual std::string GetPlaceHolderId();
public: virtual void ResizeChild(LayoutPart::Pointer childThatChanged);
public: void FlushLayout();
/**
* Returns true iff the given part can be added to this ILayoutContainer
* @param toAdd
* @return
* @since 3.1
*/
public: virtual bool AllowsAdd(LayoutPart::Pointer toAdd);
/**
* Tests the integrity of this object. Throws an exception if the object's state
* is not internally consistent. For use in test suites.
*/
public: virtual void TestInvariants();
public: virtual std::string ToString();
};
}
#endif /*BERRYLAYOUTPART_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryLayoutTree.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryLayoutTree.cpp
index 884f982829..0fb669f6af 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryLayoutTree.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryLayoutTree.cpp
@@ -1,481 +1,480 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryLayoutTree.h"
#include "berryLayoutTreeNode.h"
#include "berryLayoutPartSash.h"
-#include "berryContainerPlaceholder.h"
#include "berryConstants.h"
namespace berry
{
int LayoutTree::minCacheHits = 0;
int LayoutTree::minCacheMisses = 0;
int LayoutTree::maxCacheHits = 0;
int LayoutTree::maxCacheMisses = 0;
LayoutTree::LayoutTree(LayoutPart::Pointer part)
: parent(0),
cachedMinimumWidthHint(Constants::DEFAULT),
cachedMinimumWidth(Constants::DEFAULT),
cachedMinimumHeightHint(Constants::DEFAULT),
cachedMinimumHeight(Constants::DEFAULT),
cachedMaximumWidthHint(Constants::DEFAULT),
cachedMaximumWidth(Constants::DEFAULT),
cachedMaximumHeightHint(Constants::DEFAULT),
cachedMaximumHeight(Constants::DEFAULT),
forceLayout(true),
sizeFlagsDirty(true),
widthSizeFlags(0),
heightSizeFlags(0)
{
this->part = part;
}
LayoutPart::Pointer LayoutTree::ComputeRelation(
std::list& /*relations*/)
{
return part;
}
LayoutPart::Pointer LayoutTree::FindPart(const Point& /*toFind*/)
{
return part;
}
void LayoutTree::DisposeSashes()
{
}
LayoutTree::Pointer LayoutTree::Find(LayoutPart::Pointer child)
{
if (part != child)
{
return LayoutTree::Pointer(0);
}
return LayoutTree::Pointer(this);
}
void LayoutTree::FindSashes(PartPane::Sashes sashes)
{
if (this->GetParent() == 0)
{
return;
}
this->GetParent()->FindSashes(LayoutTree::Pointer(this), sashes);
}
LayoutPart::Pointer LayoutTree::FindBottomRight()
{
return part;
}
LayoutTreeNode::Pointer LayoutTree::FindSash(LayoutPartSash::Pointer /*sash*/)
{
return LayoutTreeNode::Pointer(0);
}
Rectangle LayoutTree::GetBounds()
{
return currentBounds;
}
int LayoutTree::Subtract(int a, int b)
{
poco_assert(b >= 0 && b < INF);
return Add(a, -b);
}
int LayoutTree::Add(int a, int b)
{
if (a == INF || b == INF)
{
return INF;
}
return a + b;
}
void LayoutTree::AssertValidSize(int toCheck)
{
poco_assert(toCheck >= 0 && (toCheck == INF || toCheck < INF / 2));
}
int LayoutTree::ComputePreferredSize(bool width, int availableParallel,
int availablePerpendicular, int preferredParallel)
{
this->AssertValidSize(availableParallel);
this->AssertValidSize(availablePerpendicular);
this->AssertValidSize(preferredParallel);
if (!this->IsVisible())
{
return 0;
}
if (availableParallel == 0)
{
return 0;
}
if (preferredParallel == 0)
{
return std::min(availableParallel, this->ComputeMinimumSize(width,
availablePerpendicular));
}
else if (preferredParallel == INF && availableParallel == INF)
{
return this->ComputeMaximumSize(width, availablePerpendicular);
}
// Optimization: if this subtree doesn't have any size preferences beyond its minimum and maximum
// size, simply return the preferred size
if (!this->HasSizeFlag(width, Constants::FILL))
{
return preferredParallel;
}
int result = this->DoComputePreferredSize(width, availableParallel,
availablePerpendicular, preferredParallel);
return result;
}
int LayoutTree::DoGetSizeFlags(bool width)
{
return part->GetSizeFlags(width);
}
int LayoutTree::DoComputePreferredSize(bool width, int availableParallel,
int availablePerpendicular, int preferredParallel)
{
int result = std::min(availableParallel, part->ComputePreferredSize(width,
availableParallel, availablePerpendicular, preferredParallel));
this->AssertValidSize(result);
return result;
}
int LayoutTree::ComputeMinimumSize(bool width, int availablePerpendicular)
{
this->AssertValidSize(availablePerpendicular);
// Optimization: if this subtree has no minimum size, then always return 0 as its
// minimum size.
if (!this->HasSizeFlag(width, Constants::MIN))
{
return 0;
}
// If this subtree doesn't contain any wrapping controls (ie: they don't care
// about their perpendicular size) then force the perpendicular
// size to be INF. This ensures that we will get a cache hit
// every time for non-wrapping controls.
if (!this->HasSizeFlag(width, Constants::WRAP))
{
availablePerpendicular = INF;
}
if (width)
{
// Check if we have a cached width measurement (we can only return a cached
// value if we computed it for the same height)
if (cachedMinimumWidthHint == availablePerpendicular)
{
minCacheHits++;
return cachedMinimumWidth;
}
// Recompute the minimum width and store it in the cache
minCacheMisses++;
int result = this->DoComputeMinimumSize(width, availablePerpendicular);
cachedMinimumWidth = result;
cachedMinimumWidthHint = availablePerpendicular;
return result;
}
else
{
// Check if we have a cached height measurement (we can only return a cached
// value if we computed it for the same width)
if (cachedMinimumHeightHint == availablePerpendicular)
{
minCacheHits++;
return cachedMinimumHeight;
}
// Recompute the minimum width and store it in the cache
minCacheMisses++;
int result = this->DoComputeMinimumSize(width, availablePerpendicular);
cachedMinimumHeight = result;
cachedMinimumHeightHint = availablePerpendicular;
return result;
}
}
void LayoutTree::PrintCacheStatistics()
{
BERRY_INFO << "minimize cache " << minCacheHits << " / " << (minCacheHits
+ minCacheMisses) << " hits " <<
(minCacheHits * 100 / (minCacheHits + minCacheMisses)) << "%\n";
BERRY_INFO << "maximize cache " << maxCacheHits << " / " << (maxCacheHits
+ maxCacheMisses) << " hits" <<
(maxCacheHits * 100 / (maxCacheHits + maxCacheMisses)) << "%\n";
}
int LayoutTree::DoComputeMinimumSize(bool width, int availablePerpendicular)
{
int result = this->DoComputePreferredSize(width, INF, availablePerpendicular,
0);
this->AssertValidSize(result);
return result;
}
int LayoutTree::ComputeMaximumSize(bool width, int availablePerpendicular)
{
this->AssertValidSize(availablePerpendicular);
// Optimization: if this subtree has no maximum size, then always return INF as its
// maximum size.
if (!this->HasSizeFlag(width, Constants::MAX))
{
return INF;
}
// If this subtree doesn't contain any wrapping controls (ie: they don't care
// about their perpendicular size) then force the perpendicular
// size to be INF. This ensures that we will get a cache hit
// every time.
if (!this->HasSizeFlag(width, Constants::WRAP))
{
availablePerpendicular = INF;
}
if (width)
{
// Check if we have a cached width measurement (we can only return a cached
// value if we computed it for the same height)
if (cachedMaximumWidthHint == availablePerpendicular)
{
maxCacheHits++;
return cachedMaximumWidth;
}
maxCacheMisses++;
// Recompute the maximum width and store it in the cache
int result = this->DoComputeMaximumSize(width, availablePerpendicular);
cachedMaximumWidth = result;
cachedMaximumWidthHint = availablePerpendicular;
return result;
}
else
{
// Check if we have a cached height measurement
if (cachedMaximumHeightHint == availablePerpendicular)
{
maxCacheHits++;
return cachedMaximumHeight;
}
maxCacheMisses++;
// Recompute the maximum height and store it in the cache
int result = this->DoComputeMaximumSize(width, availablePerpendicular);
cachedMaximumHeight = result;
cachedMaximumHeightHint = availablePerpendicular;
return result;
}
}
int LayoutTree::DoComputeMaximumSize(bool width, int availablePerpendicular)
{
return this->DoComputePreferredSize(width, INF, availablePerpendicular,
INF);
}
void LayoutTree::FlushNode()
{
// Clear cached sizes
cachedMinimumWidthHint = Constants::DEFAULT;
cachedMinimumWidth = Constants::DEFAULT;
cachedMinimumHeightHint = Constants::DEFAULT;
cachedMinimumHeight = Constants::DEFAULT;
cachedMaximumWidthHint = Constants::DEFAULT;
cachedMaximumWidth = Constants::DEFAULT;
cachedMaximumHeightHint = Constants::DEFAULT;
cachedMaximumHeight = Constants::DEFAULT;
// Flags may have changed. Ensure that they are recomputed the next time around
sizeFlagsDirty = true;
// The next setBounds call should trigger a layout even if set to the same bounds since
// one of the children has changed.
forceLayout = true;
}
void LayoutTree::FlushChildren()
{
this->FlushNode();
}
void LayoutTree::FlushCache()
{
this->FlushNode();
if (parent != 0)
{
parent->FlushCache();
}
}
int LayoutTree::GetSizeFlags(bool width)
{
if (sizeFlagsDirty)
{
widthSizeFlags = this->DoGetSizeFlags(true);
heightSizeFlags = this->DoGetSizeFlags(false);
sizeFlagsDirty = false;
}
return width ? widthSizeFlags : heightSizeFlags;
}
LayoutTreeNode* LayoutTree::GetParent() const
{
return parent;
}
LayoutTree::Pointer LayoutTree::Insert(LayoutPart::Pointer child, bool left,
LayoutPartSash::Pointer sash, LayoutPart::Pointer relative)
{
LayoutTree::Pointer relativeChild = this->Find(relative);
LayoutTreeNode::Pointer node(new LayoutTreeNode(sash));
if (relativeChild == 0)
{
//Did not find the relative part. Insert beside the root.
node->SetChild(left, child);
node->SetChild(!left, LayoutTree::Pointer(this));
return node;
}
else
{
LayoutTreeNode* oldParent = relativeChild->GetParent();
node->SetChild(left, child);
node->SetChild(!left, relativeChild);
if (oldParent == 0)
{
//It was the root. Return a new root.
return node;
}
oldParent->ReplaceChild(relativeChild, node);
return LayoutTree::Pointer(this);
}
}
bool LayoutTree::IsCompressible()
{
//Added for bug 19524
return part->IsCompressible();
}
bool LayoutTree::IsVisible()
{
- return part.Cast().IsNull();
+ return !part->IsPlaceHolder();
}
void LayoutTree::RecomputeRatio()
{
}
LayoutTree::Pointer LayoutTree::Remove(LayoutPart::Pointer child)
{
LayoutTree::Pointer tree = this->Find(child);
if (tree == 0)
{
return LayoutTree::Pointer(this);
}
LayoutTreeNode::Pointer oldParent(tree->GetParent());
if (oldParent == 0)
{
//It was the root and the only child of this tree
return LayoutTree::Pointer(0);
}
if (oldParent->GetParent() == 0)
{
return oldParent->Remove(tree);
}
oldParent->Remove(tree);
return LayoutTree::Pointer(this);
}
void LayoutTree::SetBounds(const Rectangle& bounds)
{
if (!(bounds == currentBounds) || forceLayout)
{
currentBounds = bounds;
this->DoSetBounds(currentBounds);
forceLayout = false;
}
}
void LayoutTree::DoSetBounds(const Rectangle& bounds)
{
part->SetBounds(bounds);
}
void LayoutTree::SetParent(LayoutTreeNode* parent)
{
this->parent = parent;
}
void LayoutTree::SetPart(LayoutPart::Pointer part)
{
this->part = part;
this->FlushCache();
}
std::string LayoutTree::ToString()
{
return "(" + part->ToString() + ")";//$NON-NLS-2$//$NON-NLS-1$
}
void LayoutTree::CreateControl(void* /*parent*/)
{
}
void LayoutTree::DescribeLayout(std::string& buf) const
{
part->DescribeLayout(buf);
}
bool LayoutTree::HasSizeFlag(bool width, int flag)
{
return (this->GetSizeFlags(width) & flag) != 0;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPageLayout.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPageLayout.cpp
index 61c087d3c4..8e5f61d28d 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPageLayout.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPageLayout.cpp
@@ -1,689 +1,673 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryPageLayout.h"
#include "berryWorkbenchPlugin.h"
#include "berryLayoutHelper.h"
#include "berryViewLayout.h"
#include "berryPresentationFactoryUtil.h"
#include "berryFolderLayout.h"
#include "berryPlaceholderFolderLayout.h"
#include "berryUIException.h"
#include "berryConstants.h"
namespace berry
{
PageLayout::PageLayout()
: editorVisible(true)
{
//no-op
}
PageLayout::PageLayout(ViewSashContainer::Pointer container,
ViewFactory* viewFactory, LayoutPart::Pointer editorFolder,
IPerspectiveDescriptor::Pointer descriptor)
: editorVisible(true)
{
this->viewFactory = viewFactory;
this->rootLayoutContainer = container;
this->editorFolder = editorFolder;
this->descriptor = descriptor;
this->Prefill();
}
void PageLayout::AddEditorArea()
{
try
{
// Create the part.
-// StackablePart::Pointer newPart = this->CreateView(ID_EDITOR_AREA);
-// if (newPart == 0)
-// {
-// // this should never happen as long as newID is the editor ID.
-// return;
-// }
-//
- // this->SetFolderPart(ID_EDITOR_AREA, editorFolder.Cast());
+ LayoutPart::Pointer newPart = this->CreateView(ID_EDITOR_AREA);
+ if (newPart == 0)
+ {
+ // this should never happen as long as newID is the editor ID.
+ return;
+ }
+
+ this->SetRefPart(ID_EDITOR_AREA, newPart);
// Add it to the layout.
- rootLayoutContainer->Add(editorFolder);
+ rootLayoutContainer->Add(newPart);
}
catch (PartInitException& e)
{
WorkbenchPlugin::Log(this->GetClassName(), "AddEditorArea()", e); //$NON-NLS-1$
}
}
ViewLayoutRec::Pointer PageLayout::GetViewLayoutRec(const std::string& id, bool create)
{
ViewLayoutRec::Pointer rec = mapIDtoViewLayoutRec[id];
if (rec == 0 && create)
{
rec = new ViewLayoutRec();
// set up the view layout appropriately if the page layout is fixed
if (this->IsFixed())
{
rec->isCloseable = false;
rec->isMoveable = false;
}
mapIDtoViewLayoutRec[id] = rec;
}
return rec;
}
-void PageLayout::AddStack(IStackableContainer::Pointer newPart,
+void PageLayout::AddPart(LayoutPart::Pointer newPart,
const std::string& partId, int relationship, float ratio,
const std::string& refId)
{
- //this->SetRefPart(partId, newPart);
- this->SetFolderPart(partId, newPart);
+ this->SetRefPart(partId, newPart);
// If the referenced part is inside a folder,
// then use the folder as the reference part.
- IStackableContainer::Pointer refPart = this->GetFolderPart(refId);
-
- // if (refPart == 0)
-// {
-// refPart = this->GetRefPart(refId);
-// }
+ LayoutPart::Pointer refPart = this->GetFolderPart(refId);
+ if (refPart == 0)
+ {
+ refPart = this->GetRefPart(refId);
+ }
// Add it to the layout.
if (refPart != 0)
{
ratio = this->NormalizeRatio(ratio);
- rootLayoutContainer->Add(newPart.Cast(), this->GetPartSashConst(relationship), ratio,
- refPart.Cast());
- }
- else if (refId == ID_EDITOR_AREA)
- {
- ratio = this->NormalizeRatio(ratio);
- rootLayoutContainer->Add(newPart.Cast(), this->GetPartSashConst(relationship), ratio,
- this->editorFolder.Cast());
+ rootLayoutContainer->Add(newPart, this->GetPartSashConst(relationship), ratio, refPart);
}
else
{
WorkbenchPlugin::Log("Reference part does not exist yet: " + refId);
- rootLayoutContainer->Add(newPart.Cast());
+ rootLayoutContainer->Add(newPart);
}
}
void PageLayout::AddPerspectiveShortcut(const std::string& id)
{
if (std::find(perspectiveShortcuts.begin(),
perspectiveShortcuts.end(), id) == perspectiveShortcuts.end())
{
perspectiveShortcuts.push_back(id);
}
}
void PageLayout::AddPlaceholder(const std::string& viewId, int relationship,
float ratio, const std::string& refId)
{
if (!this->CheckValidPlaceholderId(viewId))
{
return;
}
- // Create a folder.
- ContainerPlaceholder::Pointer folder(new ContainerPlaceholder(viewId));
- folder->SetContainer(rootLayoutContainer);
- folder->SetRealContainer(PartStack::Pointer(new PartStack(rootLayoutContainer->page)));
- //folder->SetId(folderId);
// Create the placeholder.
PartPlaceholder::Pointer newPart(new PartPlaceholder(viewId));
- folder->Add(newPart);
- this->AddStack(folder, viewId, relationship, ratio, refId);
+ this->AddPart(newPart, viewId, relationship, ratio, refId);
// force creation of the view layout rec
this->GetViewLayoutRec(viewId, true);
}
bool PageLayout::CheckValidPlaceholderId(const std::string& id)
{
// Check that view is not already in layout.
// This check is done even if the id has a wildcard, since it's incorrect to create
// multiple placeholders with the same id, wildcard or not.
if (this->CheckPartInLayout(id))
{
return false;
}
// check that primary view id is valid, but only if it has no wildcard
std::string primaryId = ViewFactory::ExtractPrimaryId(id);
if (!ViewFactory::HasWildcard(primaryId))
{
IViewRegistry* reg = WorkbenchPlugin::GetDefault()->GetViewRegistry();
IViewDescriptor::Pointer desc = reg->Find(primaryId);
if (desc == 0)
{
// cannot safely open the dialog so log the problem
WorkbenchPlugin::Log("Unable to find view with id: " + primaryId
+ ", when creating perspective " + this->GetDescriptor()->GetId()); //$NON-NLS-1$ //$NON-NLS-2$
return false;
}
}
return true;
}
void PageLayout::AddShowInPart(const std::string& id)
{
if (std::find(showInPartIds.begin(), showInPartIds.end(), id) == showInPartIds.end())
{
showInPartIds.push_back(id);
}
}
void PageLayout::AddShowViewShortcut(const std::string& id)
{
if (std::find(showViewShortcuts.begin(), showViewShortcuts.end(), id) == showInPartIds.end())
{
showViewShortcuts.push_back(id);
}
}
void PageLayout::AddView(const std::string& viewId, int relationship,
float ratio, const std::string& refId)
{
this->AddView(viewId, relationship, ratio, refId, false, false, true);
}
void PageLayout::AddView(const std::string& viewId, int relationship,
float ratio, const std::string& refId, bool minimized)
{
this->AddView(viewId, relationship, ratio, refId, minimized, false, true);
}
void PageLayout::AddView(const std::string& viewId, int relationship,
float ratio, const std::string& refId, bool /*minimized*/, bool standalone,
bool showTitle)
{
if (this->CheckPartInLayout(viewId))
{
return;
}
try
{
// Create the part.
- StackablePart::Pointer newPart = this->CreateView(viewId);
+ LayoutPart::Pointer newPart = this->CreateView(viewId);
if (newPart == 0)
{
this->AddPlaceholder(viewId, relationship, ratio, refId);
- //TODO ViewActivator for IIdentifier
- //LayoutHelper::AddViewActivator(this, viewId);
+ LayoutHelper::AddViewActivator(PageLayout::Pointer(this), viewId);
}
else
{
int appearance = PresentationFactoryUtil::ROLE_VIEW;
if (standalone)
{
if (showTitle)
{
appearance = PresentationFactoryUtil::ROLE_STANDALONE;
}
else
{
appearance = PresentationFactoryUtil::ROLE_STANDALONE_NOTITLE;
}
}
// PartStack for views
PartStack::Pointer newFolder(new PartStack(rootLayoutContainer->page,
true, appearance, 0));
newFolder->Add(newPart);
this->SetFolderPart(viewId, newFolder);
- this->AddStack(newFolder, viewId, relationship, ratio, refId);
+ this->AddPart(newFolder, viewId, relationship, ratio, refId);
// force creation of the view layout rec
this->GetViewLayoutRec(viewId, true);
// Capture any minimized stacks
// if (minimized)
// {
// // Remember the minimized stacks so we can
// // move them to the trim when the Perspective
// // activates...
// minimizedStacks.add(newFolder);
// }
}
}
catch (PartInitException& e)
{
WorkbenchPlugin::Log(this->GetClassName(), "AddView()", e); //$NON-NLS-1$
}
}
// List getMinimizedStacks() {
// return minimizedStacks;
// }
bool PageLayout::CheckPartInLayout(const std::string& partId)
{
if (partId == ID_EDITOR_AREA) return true;
if (this->GetRefPart(partId) != 0) // || this->IsFastViewId(partId))
{
WorkbenchPlugin::Log("Part already exists in page layout: " + partId);
return true;
}
if (this->GetFolderPart(partId) != 0) // || this->IsFastViewId(partId))
{
WorkbenchPlugin::Log("Part already exists in page layout: " + partId);
return true;
}
return false;
}
IFolderLayout::Pointer PageLayout::CreateFolder(const std::string& folderId,
int relationship, float ratio, const std::string& refId)
{
if (this->CheckPartInLayout(folderId))
{
- IStackableContainer::Pointer folder = this->GetFolderPart(folderId);
+ ILayoutContainer::Pointer folder = this->GetFolderPart(folderId);
return mapFolderToFolderLayout[folder].Cast();
}
// Create the folder.
PartStack::Pointer folder(new PartStack(rootLayoutContainer->page));
folder->SetID(folderId);
- this->AddStack(folder, folderId, relationship, ratio, refId);
+ this->AddPart(folder, folderId, relationship, ratio, refId);
// Create a wrapper.
FolderLayout::Pointer layout(new FolderLayout(PageLayout::Pointer(this), folder, viewFactory));
mapFolderToFolderLayout.insert(std::make_pair(folder, layout));
return layout;
}
IPlaceholderFolderLayout::Pointer PageLayout::CreatePlaceholderFolder(
const std::string& folderId, int relationship, float ratio, const std::string& refId)
{
if (this->CheckPartInLayout(folderId))
{
ContainerPlaceholder::Pointer folder = this->GetRefPart(folderId).Cast();
return mapFolderToFolderLayout[folder];
}
// Create the folder.
ContainerPlaceholder::Pointer folder(new ContainerPlaceholder(""));
folder->SetContainer(rootLayoutContainer);
- folder->SetRealContainer(IStackableContainer::Pointer(new PartStack(rootLayoutContainer->page)));
+ folder->SetRealContainer(ILayoutContainer::Pointer(new PartStack(rootLayoutContainer->page)));
folder->SetID(folderId);
- this->AddStack(folder, folderId, relationship, ratio, refId);
+ this->AddPart(folder, folderId, relationship, ratio, refId);
// Create a wrapper.
IPlaceholderFolderLayout::Pointer layout(new PlaceholderFolderLayout(PageLayout::Pointer(this), folder));
mapFolderToFolderLayout.insert(std::make_pair(folder, layout));
return layout;
}
-StackablePart::Pointer PageLayout::CreateView(const std::string& partID)
+LayoutPart::Pointer PageLayout::CreateView(const std::string& partID)
{
-// if (partID == ID_EDITOR_AREA)
-// {
-// return editorFolder;
-// }
+ if (partID == ID_EDITOR_AREA)
+ {
+ return editorFolder;
+ }
- IViewDescriptor::Pointer viewDescriptor = viewFactory->GetViewRegistry()
- ->Find(ViewFactory::ExtractPrimaryId(partID));
+// IViewDescriptor::Pointer viewDescriptor = viewFactory->GetViewRegistry()
+// ->Find(ViewFactory::ExtractPrimaryId(partID));
// if (WorkbenchActivityHelper.filterItem(viewDescriptor))
// {
// return null;
// }
return LayoutHelper::CreateView(this->GetViewFactory(), partID);
}
IPerspectiveDescriptor::Pointer PageLayout::GetDescriptor()
{
return descriptor;
}
std::string PageLayout::GetEditorArea()
{
return ID_EDITOR_AREA;
}
-IStackableContainer::Pointer PageLayout::GetFolderPart(const std::string& viewId)
+PartStack::Pointer PageLayout::GetFolderPart(const std::string& viewId)
{
- return mapIDtoFolder[viewId];
+ return mapIDtoFolder[viewId].Cast();
}
int PageLayout::GetPartSashConst(int nRelationship)
{
return nRelationship;
}
std::vector PageLayout::GetPerspectiveShortcuts()
{
return perspectiveShortcuts;
}
-StackablePart::Pointer PageLayout::GetRefPart(const std::string& partID)
+LayoutPart::Pointer PageLayout::GetRefPart(const std::string& partID)
{
return mapIDtoPart[partID];
}
PartSashContainer::Pointer PageLayout::GetRootLayoutContainer()
{
return rootLayoutContainer;
}
std::vector PageLayout::GetShowInPartIds()
{
return showInPartIds;
}
std::vector PageLayout::GetShowViewShortcuts()
{
return showViewShortcuts;
}
ViewFactory* PageLayout::GetViewFactory()
{
return viewFactory;
}
bool PageLayout::IsEditorAreaVisible()
{
return editorVisible;
}
float PageLayout::NormalizeRatio(float in)
{
if (in < RATIO_MIN)
{
in = RATIO_MIN;
}
if (in > RATIO_MAX)
{
in = RATIO_MAX;
}
return in;
}
void PageLayout::Prefill()
{
this->AddEditorArea();
//TODO action sets
// Add default action sets.
// ActionSetRegistry reg = WorkbenchPlugin.getDefault()
// .getActionSetRegistry();
// IActionSetDescriptor[] array = reg.getActionSets();
// int count = array.length;
// for (int nX = 0; nX < count; nX++)
// {
// IActionSetDescriptor desc = array[nX];
// if (desc.isInitiallyVisible())
// {
// addActionSet(desc.getId());
// }
// }
}
void PageLayout::SetEditorAreaVisible(bool showEditorArea)
{
editorVisible = showEditorArea;
}
void PageLayout::SetFixed(bool fixed)
{
this->fixed = fixed;
}
bool PageLayout::IsFixed()
{
return fixed;
}
void PageLayout::SetFolderPart(const std::string& viewId,
ContainerPlaceholder::Pointer container)
{
- IStackableContainer::Pointer tabFolder = container->GetRealContainer();
- mapIDtoFolder[viewId] = tabFolder;
+ LayoutPart::Pointer tabFolder = container->GetRealContainer();
+ mapIDtoFolder[viewId] = tabFolder.Cast();
}
void PageLayout::SetFolderPart(const std::string& viewId,
PartStack::Pointer folder)
{
- mapIDtoFolder[viewId] = folder.Cast();
+ mapIDtoFolder[viewId] = folder.Cast();
}
void PageLayout::SetFolderPart(const std::string& viewId,
- IStackableContainer::Pointer folder)
+ ILayoutContainer::Pointer folder)
{
mapIDtoFolder[viewId] = folder;
}
-void PageLayout::SetRefPart(const std::string& partID, StackablePart::Pointer part)
+void PageLayout::SetRefPart(const std::string& partID, LayoutPart::Pointer part)
{
mapIDtoPart[partID] = part;
}
-void PageLayout::StackPart(StackablePart::Pointer newPart,
+void PageLayout::StackPart(LayoutPart::Pointer newPart,
const std::string& viewId, const std::string& refId)
{
this->SetRefPart(viewId, newPart);
// force creation of the view layout rec
this->GetViewLayoutRec(viewId, true);
// If ref part is in a folder than just add the
// new view to that folder.
PartStack::Pointer folder = this->GetFolderPart(refId).Cast();
if (folder != 0)
{
folder->Add(newPart);
this->SetFolderPart(viewId, folder);
return;
}
// parts are now always contained in folders
// // If the ref part is in the page layout then create
// // a new folder and add the new view.
-// StackablePart::Pointer refPart = this->GetRefPart(refId);
+// LayoutPart::Pointer refPart = this->GetRefPart(refId);
// if (refPart != 0) // && (refPart instanceof PartPane || refPart instanceof PartPlaceholder))
// {
// PartStack::Pointer newFolder(new PartStack(rootLayoutContainer->page));
// rootLayoutContainer->Replace(refPart, newFolder);
// newFolder->Add(refPart);
// newFolder->Add(newPart);
// this->SetFolderPart(refId, newFolder);
// this->SetFolderPart(viewId, newFolder);
// return;
// }
// If ref part is not found then just do add.
WorkbenchPlugin::Log("Referenced part does not exist yet: " + refId);
PartStack::Pointer newFolder(new PartStack(rootLayoutContainer->page));
newFolder->Add(newPart);
this->SetFolderPart(viewId, newFolder);
rootLayoutContainer->Add(newFolder);
}
void PageLayout::StackPlaceholder(const std::string& viewId,
const std::string& refId)
{
if (this->CheckPartInLayout(viewId))
{
return;
}
// Create the placeholder.
PartPlaceholder::Pointer newPart(new PartPlaceholder(viewId));
- StackablePart::Pointer refPart = this->GetRefPart(refId);
+ LayoutPart::Pointer refPart = this->GetRefPart(refId);
if (refPart != 0)
{
newPart->SetContainer(refPart->GetContainer());
}
this->StackPart(newPart, viewId, refId);
}
void PageLayout::StackView(const std::string& viewId, const std::string& refId)
{
if (this->CheckPartInLayout(viewId))
{
return;
}
// Create the new part.
try
{
- StackablePart::Pointer newPart = this->CreateView(viewId);
+ LayoutPart::Pointer newPart = this->CreateView(viewId);
if (newPart == 0)
{
this->StackPlaceholder(viewId, refId);
LayoutHelper::AddViewActivator(PageLayout::Pointer(this), viewId);
}
else
{
this->StackPart(newPart, viewId, refId);
}
}
catch (PartInitException& e)
{
WorkbenchPlugin::Log(this->GetClassName(), "StackView", e); //$NON-NLS-1$
}
}
int PageLayout::ConstantToLayoutPosition(int constant) {
if (constant == Constants::TOP)
return IPageLayout::TOP;
if (constant == Constants::BOTTOM)
return IPageLayout::BOTTOM;
if (constant == Constants::RIGHT)
return IPageLayout::RIGHT;
if (constant == Constants::LEFT)
return IPageLayout::LEFT;
return -1;
}
void PageLayout::AddStandaloneView(const std::string& viewId, bool showTitle,
int relationship, float ratio, const std::string& refId)
{
this->AddView(viewId, relationship, ratio, refId, false, true, showTitle);
ViewLayoutRec::Pointer rec = this->GetViewLayoutRec(viewId, true);
rec->isStandalone = true;
rec->showTitle = showTitle;
}
void PageLayout::AddStandaloneViewPlaceholder(const std::string& viewId,
int relationship, float ratio, const std::string& refId, bool showTitle)
{
std::string stackId = viewId + ".standalonefolder"; //$NON-NLS-1$
// Check to see if the view is already in the layout
if (!this->CheckValidPlaceholderId(viewId))
{
return;
}
// Create the folder.
ContainerPlaceholder::Pointer folder(new ContainerPlaceholder(""));
folder->SetContainer(rootLayoutContainer);
int appearance = PresentationFactoryUtil::ROLE_STANDALONE;
if (!showTitle)
{
appearance = PresentationFactoryUtil::ROLE_STANDALONE_NOTITLE;
}
- folder->SetRealContainer(IStackableContainer::Pointer(new PartStack(rootLayoutContainer->page, true,
+ folder->SetRealContainer(ILayoutContainer::Pointer(new PartStack(rootLayoutContainer->page, true,
appearance, 0)));
folder->SetID(stackId);
- this->AddStack(folder, stackId, relationship, ratio, refId);
+ this->AddPart(folder, stackId, relationship, ratio, refId);
// Create a wrapper.
PlaceholderFolderLayout::Pointer placeHolder(new PlaceholderFolderLayout(PageLayout::Pointer(this),
folder));
// Add the standalone view immediately
placeHolder->AddPlaceholder(viewId);
ViewLayoutRec::Pointer rec = this->GetViewLayoutRec(viewId, true);
rec->isStandalone = true;
rec->showTitle = showTitle;
}
IViewLayout::Pointer PageLayout::GetViewLayout(const std::string& viewId)
{
ViewLayoutRec::Pointer rec = this->GetViewLayoutRec(viewId, true);
if (rec == 0)
{
return IViewLayout::Pointer(0);
}
return IViewLayout::Pointer(new ViewLayout(PageLayout::Pointer(this), rec));
}
std::map PageLayout::GetIDtoViewLayoutRecMap()
{
return mapIDtoViewLayoutRec;
}
void PageLayout::RemovePlaceholder(const std::string& id)
{
- StackablePart::Pointer part = this->GetRefPart(id);
+ LayoutPart::Pointer part = this->GetRefPart(id);
if (part->IsPlaceHolder())
{
- IStackableContainer::Pointer stack = this->GetFolderPart(id);
+ ILayoutContainer::Pointer stack = this->GetFolderPart(id);
if (stack != 0)
{
stack->Remove(part);
}
else
{
//rootLayoutContainer->Remove(part);
WorkbenchPlugin::Log("Not removing placeholder: Folder for placeholder " + id + " not found");
}
mapIDtoPart.erase(id);
mapIDtoFolder.erase(id);
mapIDtoViewLayoutRec.erase(id);
}
}
IPlaceholderFolderLayout::Pointer PageLayout::GetFolderForView(
const std::string& viewId)
{
if (mapIDtoFolder[viewId] == 0)
return IPlaceholderFolderLayout::Pointer(0);
- IStackableContainer::Pointer folder = mapIDtoFolder[viewId];
+ ILayoutContainer::Pointer folder = mapIDtoFolder[viewId];
IPlaceholderFolderLayout::Pointer layout;
if (mapFolderToFolderLayout[folder] == 0)
{
layout = new FolderLayout(PageLayout::Pointer(this), folder.Cast(), viewFactory);
mapFolderToFolderLayout[folder] = layout;
}
else
{
layout = mapFolderToFolderLayout[folder];
}
return layout;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPageLayout.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPageLayout.h
index 8a62c39cec..75a2004c33 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPageLayout.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPageLayout.h
@@ -1,586 +1,586 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYPAGELAYOUT_H_
#define BERRYPAGELAYOUT_H_
#include "berryIPageLayout.h"
#include "berryViewLayoutRec.h"
#include "berryContainerPlaceholder.h"
#include "berryViewSashContainer.h"
#include "berryPartStack.h"
namespace berry
{
/**
* \ingroup org_blueberry_ui_internal
*
* This factory is used to define the initial layout of a part sash container.
*
* Design notes: The design of IPageLayout
is a reflection of
* three requirements:
*
* - A mechanism is required to define the initial layout for a page.
* - The views and editors within a page will be persisted between
* sessions.
* - The view and editor lifecycle for (1) and (2) should be identical.
*
*
*
* In reflection of these requirements, the following strategy has been
* implemented for layout definition.
*
* - A view extension is added to the workbench registry for the view.
* This extension defines the extension id and extension class.
* - A view is added to a page by invoking one of the add methods
* in
IPageLayout
. The type of view is passed as an
* extension id, rather than a handle. The page layout will map
* the extension id to a view class, create an instance of the class,
* and then add the view to the page.
*
*
*/
class PageLayout : public IPageLayout
{
public:
berryObjectMacro(PageLayout);
private:
//ArrayList actionSets = new ArrayList(3);
IPerspectiveDescriptor::Pointer descriptor;
LayoutPart::Pointer editorFolder;
bool editorVisible;
bool fixed;
- typedef std::map IDToFolderMap;
+ typedef std::map IDToFolderMap;
IDToFolderMap mapIDtoFolder;
- typedef std::map IDToPartMap;
+ typedef std::map IDToPartMap;
IDToPartMap mapIDtoPart;
typedef std::map IDToViewLayoutRecMap;
IDToViewLayoutRecMap mapIDtoViewLayoutRec;
- typedef std::map FolderToFolderLayoutMap;
+ typedef std::map FolderToFolderLayoutMap;
FolderToFolderLayoutMap mapFolderToFolderLayout;
std::vector perspectiveShortcuts;
ViewSashContainer::Pointer rootLayoutContainer;
std::vector showInPartIds;
std::vector showViewShortcuts;
ViewFactory* viewFactory;
/**
* Constructs a new PageLayout for other purposes.
*/
public:
PageLayout();
/**
* Constructs a new PageLayout for the normal case of creating a new
* perspective.
*/
public:
PageLayout(ViewSashContainer::Pointer container, ViewFactory* viewFactory,
LayoutPart::Pointer editorFolder,
IPerspectiveDescriptor::Pointer descriptor);
/**
* Adds the editor to a layout.
*/
private:
void AddEditorArea();
/**
* Adds an action set to the page.
*
* @param actionSetID Identifies the action set extension to use. It must
* exist within the workbench registry.
*/
// public: void addActionSet(String actionSetID) {
// if (!actionSets.contains(actionSetID)) {
// actionSets.add(actionSetID);
// }
// }
/* (non-Javadoc)
* @see org.blueberry.ui.IPageLayout#addFastView(java.lang.String)
*/
// public: void addFastView(String id) {
// addFastView(id, INVALID_RATIO);
// }
/* (non-Javadoc)
* @see org.blueberry.ui.IPageLayout#addFastView(java.lang.String, float)
*/
// public: void addFastView(String id, float ratio) {
// if (checkPartInLayout(id)) {
// return;
// }
// if (id != null) {
// try {
// IViewDescriptor viewDescriptor = viewFactory.getViewRegistry()
// .find(ViewFactory.extractPrimaryId(id));
// if (!WorkbenchActivityHelper.filterItem(viewDescriptor)) {
// IViewReference ref = viewFactory.createView(ViewFactory
// .extractPrimaryId(id), ViewFactory
// .extractSecondaryId(id));
// fastViews.add(ref);
//
// // force creation of the view layout rec
// ViewLayoutRec rec = getViewLayoutRec(id, true);
//
// // remember the ratio, if valid
// if (ratio >= IPageLayout.RATIO_MIN
// && ratio <= IPageLayout.RATIO_MAX) {
// rec.fastViewWidthRatio = ratio;
// }
// }
// } catch (PartInitException e) {
// WorkbenchPlugin.log(getClass(), "addFastView", e); //$NON-NLS-1$
// }
// }
// }
/**
* Check to see if the partId represents a fast view's id.
*
* @param partId
* The part's id.
* @return true if the partId is a fast view id.
*/
// private: boolean isFastViewId(String partId) {
// for (int i = 0; i < fastViews.size(); i++) {
// IViewReference ref = (IViewReference) fastViews.get(i);
// String secondaryId = ref.getSecondaryId();
// String refId = (secondaryId == null ? ref.getId() : ref.getId()
// + ":" + secondaryId); //$NON-NLS-1$
// if (refId.equals(partId)) {
// return true;
// }
// }
// return false;
// }
/**
* Returns the view layout record for the given view id, or null if not
* found. If create is true, the record is created if it doesn't already
* exist.
*
* @since 3.0
*/
public:
ViewLayoutRec::Pointer GetViewLayoutRec(const std::string& id, bool create);
/**
* Adds a creation wizard to the File New menu.
* The id must name a new wizard extension contributed to the
* workbench's extension point (named "org.blueberry.ui.newWizards"
).
*
* @param id the wizard id
*/
// public: void addNewWizardShortcut(String id) {
// if (!newWizardShortcuts.contains(id)) {
// newWizardShortcuts.add(id);
// }
// }
/**
* Add the layout part to the page's layout
*/
private:
- void AddStack(IStackableContainer::Pointer newPart, const std::string& partId,
- int relationship, float ratio, const std::string& refId);
+ void AddPart(LayoutPart::Pointer newPart, const std::string& partId,
+ int relationship, float ratio, const std::string& refId);
/**
* Adds a perspective shortcut to the Perspective menu.
* The id must name a perspective extension contributed to the
* workbench's extension point (named "org.blueberry.ui.perspectives"
).
*
* @param id the perspective id
*/
public:
void AddPerspectiveShortcut(const std::string& id);
/* (non-Javadoc)
* @see org.blueberry.ui.IPageLayout#addPlaceholder(java.lang.String, int, float, java.lang.String)
*/
public:
void AddPlaceholder(const std::string& viewId, int relationship, float ratio,
const std::string& refId);
/**
* Checks whether the given id is a valid placeholder id.
* A placeholder id may be simple or compound, and can optionally contain a wildcard.
*
* @param id the placeholder id
* @return true
if the given id is a valid placeholder id, false
otherwise
*/
bool CheckValidPlaceholderId(const std::string& id);
/* (non-Javadoc)
* @see org.blueberry.ui.IPageLayout#addShowInPart(java.lang.String)
*/
public:
void AddShowInPart(const std::string& id);
/**
* Adds a view to the Show View menu. The id must name a view extension
* contributed to the workbench's extension point (named "org.blueberry.ui.views"
).
*
* @param id the view id
*/
public:
void AddShowViewShortcut(const std::string& id);
/* (non-Javadoc)
* @see org.blueberry.ui.IPageLayout#addView(java.lang.String, int, float, java.lang.String)
*/
public:
void AddView(const std::string& viewId, int relationship, float ratio,
const std::string& refId);
/**
* Convenience method to allow setting the initial minimized
* state if a new stack is created. Used by the 'perspectiveExtension'
* reader.
*
* @since 3.3
*/
public:
void AddView(const std::string& viewId, int relationship, float ratio,
const std::string& refId, bool minimized);
/* (non-Javadoc)
* @see org.blueberry.ui.IPageLayout#addView(java.lang.String, int, float, java.lang.String)
*/
private:
void
AddView(const std::string& viewId, int relationship, float ratio,
const std::string& refId, bool minimized, bool standalone,
bool showTitle);
// public: List getMinimizedStacks() {
// return minimizedStacks;
// }
/**
* Verify that the part is already present in the layout
* and cannot be added again. Log a warning message.
*/
public:
bool CheckPartInLayout(const std::string& partId);
/* (non-Javadoc)
* @see org.blueberry.ui.IPageLayout#createFolder(java.lang.String, int, float, java.lang.String)
*/
public:
IFolderLayout::Pointer CreateFolder(const std::string& folderId,
int relationship, float ratio, const std::string& refId);
/* (non-Javadoc)
* @see org.blueberry.ui.IPageLayout#createPlaceholderFolder(java.lang.String, int, float, java.lang.String)
*/
public:
IPlaceholderFolderLayout::Pointer CreatePlaceholderFolder(
const std::string& folderId, int relationship, float ratio,
const std::string& refId);
/**
* Create a new LayoutPart
.
*
* @param partID the id of the part to create.
* @return the LayoutPart
, or null
if it should not be
* created because of activity filtering.
* @throws PartInitException thrown if there is a problem creating the part.
*/
private:
- StackablePart::Pointer CreateView(const std::string& partID);
+ LayoutPart::Pointer CreateView(const std::string& partID);
/**
* @return the action set list for the page. This is List
of
* String
s.
*/
// public: ArrayList getActionSets() {
// return actionSets;
// }
/* (non-Javadoc)
* @see org.blueberry.ui.IPageLayout#getDescriptor()
*/
public:
IPerspectiveDescriptor::Pointer GetDescriptor();
/**
* @return an identifier for the editor area. The editor area is
* automatically added to each layout before any other part. It should be
* used as a reference part for other views.
*/
public:
std::string GetEditorArea();
/* (non-Javadoc)
* @see org.blueberry.ui.IPageLayout#getEditorReuseThreshold()
*/
// public: int getEditorReuseThreshold() {
// return -1;
// }
/**
* @return ArrayList
*/
// public: ArrayList getFastViews() {
// return fastViews;
// }
/**
* @return the folder part containing the given view ID or null
* if none (i.e. part of the page layout instead of a folder layout).
*/
private:
- IStackableContainer::Pointer GetFolderPart(const std::string& viewId);
+ PartStack::Pointer GetFolderPart(const std::string& viewId);
/**
* @return the new wizard shortcuts associated with the page. This is a List
of
* String
s.
*/
// public: ArrayList getNewWizardShortcuts() {
// return newWizardShortcuts;
// }
/**
* @return the part sash container const for a layout value.
*/
private:
int GetPartSashConst(int nRelationship);
/**
* @return the perspective shortcuts associated with the page. This is a List
of
* String
s.
*/
public:
std::vector GetPerspectiveShortcuts();
/**
* @return the part for a given ID.
*/
/*package*/
- StackablePart::Pointer GetRefPart(const std::string& partID);
+ LayoutPart::Pointer GetRefPart(const std::string& partID);
/**
* @return the top level layout container.
*/
public:
PartSashContainer::Pointer GetRootLayoutContainer();
/**
* @return the ids of the parts to list in the Show In... prompter. This is
* a List
of String
s.
*/
public:
std::vector GetShowInPartIds();
/**
* @return the show view shortcuts associated with the page. This is a List
of
* String
s.
*/
public:
std::vector GetShowViewShortcuts();
/**
* @return the ViewFactory
for this PageLayout
.
* @since 3.0
*/
/* package */
ViewFactory* GetViewFactory();
/* (non-Javadoc)
* @see org.blueberry.ui.IPageLayout#isEditorAreaVisible()
*/
public:
bool IsEditorAreaVisible();
/**
* Trim the ratio so that direct manipulation of parts is easy.
*
* @param in the initial ratio.
* @return the normalized ratio.
*/
private:
float NormalizeRatio(float in);
/**
* Prefill the layout with required parts.
*/
private:
void Prefill();
/* (non-Javadoc)
* @see org.blueberry.ui.IPageLayout#setEditorAreaVisible(boolean)
*/
public:
void SetEditorAreaVisible(bool showEditorArea);
/* (non-Javadoc)
* @see org.blueberry.ui.IPageLayout#setEditorReuseThreshold(int)
*/
// public: void setEditorReuseThreshold(int openEditors) {
// //no-op
// }
/* (non-Javadoc)
* @see org.blueberry.ui.IPageLayout#setFixed(boolean)
*/
public:
void SetFixed(bool fixed);
/* (non-Javadoc)
* @see org.blueberry.ui.IPageLayout#getFixed()
*/
public:
bool IsFixed();
/**
* Map the folder part containing the given view ID.
*
* @param viewId the part ID.
* @param container the ContainerPlaceholder
.
*/
/*package*/
void SetFolderPart(const std::string& viewId,
- ContainerPlaceholder::Pointer container);
+ ContainerPlaceholder::Pointer container);
/**
* Map the folder part containing the given view ID.
*
* @param viewId the part ID.
* @param folder the ViewStack
.
*/
/*package*/
void SetFolderPart(const std::string& viewId, PartStack::Pointer folder);
- void SetFolderPart(const std::string& viewId, IStackableContainer::Pointer folder);
+ void SetFolderPart(const std::string& viewId, ILayoutContainer::Pointer folder);
/**
* Map an ID to a part.
*
* @param partId the part ID.
* @param part the LayoutPart
.
*/
/*package*/
- void SetRefPart(const std::string& partID, StackablePart::Pointer part);
+ void SetRefPart(const std::string& partID, LayoutPart::Pointer part);
/**
* Stack a part on top of another.
*
* @param newPart the new part.
* @param viewId the view ID.
* @param refId the reference ID.
*/
private:
- void StackPart(StackablePart::Pointer newPart, const std::string& viewId,
+ void StackPart(LayoutPart::Pointer newPart, const std::string& viewId,
const std::string& refId);
/**
* Stack a placeholder on top of another.
*
* @param viewId the view ID.
* @param refId the reference ID.
*/
public:
void StackPlaceholder(const std::string& viewId, const std::string& refId);
// stackView(String, String) modified by dan_rubel@instantiations.com
/**
* Stack one view on top of another.
*
* @param viewId the view ID.
* @param refId the reference ID.
*/
public:
void StackView(const std::string& viewId, const std::string& refId);
/**
* Converts common position constants into layout position constants.
*
* @param one of Constants::TOP, Constants::BOTTOM, Constants::LEFT, or Constants::RIGHT
* @return one of IPageLayout::TOP, IPageLayout::BOTTOM, IPageLayout::LEFT, IPageLayout::RIGHT, or -1 indicating an
* invalid input
*
* @since 3.0
*/
public: static int ConstantToLayoutPosition(int constant);
/* (non-Javadoc)
* @see org.blueberry.ui.IPageLayout#addStandaloneView(java.lang.String, boolean, int, float, java.lang.String)
* @since 3.0
*/
public:
void AddStandaloneView(const std::string& viewId, bool showTitle,
int relationship, float ratio, const std::string& refId);
/* (non-Javadoc)
* @see org.blueberry.ui.IPageLayout#addStandaloneViewPlaceholder(java.lang.String, int, float, java.lang.String, boolean)
*/
public:
void AddStandaloneViewPlaceholder(const std::string& viewId,
int relationship, float ratio, const std::string& refId, bool showTitle);
/*
* (non-Javadoc)
*
* @see org.blueberry.ui.IPageLayout#getViewLayout(java.lang.String)
* @since 3.0
*/
public:
IViewLayout::Pointer GetViewLayout(const std::string& viewId);
/**
* @since 3.0
*/
public:
std::map GetIDtoViewLayoutRecMap();
/**
* Removes any existing placeholder with the given id.
*
* @param id the id for the placeholder
* @since 3.1
*/
public:
void RemovePlaceholder(const std::string& id);
/* (non-Javadoc)
* @see org.blueberry.ui.IPageLayout#getFolderForView(java.lang.String)
*/
public:
IPlaceholderFolderLayout::Pointer GetFolderForView(const std::string& viewId);
};
}
#endif /*BERRYPAGELAYOUT_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartList.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartList.cpp
index 65a7419a8f..569f70f7ca 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartList.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartList.cpp
@@ -1,367 +1,367 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryPartList.h"
#include "berrySaveablesList.h"
#include "berryPartPane.h"
#include "berryIWorkbenchPartConstants.h"
#include "berryIWorkbenchPartSite.h"
#include
namespace berry
{
void PartList::PropertyChange(Object::Pointer source, int propId)
{
WorkbenchPartReference::Pointer ref = source.Cast<
WorkbenchPartReference> ();
if (propId == IWorkbenchPartConstants::PROP_OPENED)
{
this->PartOpened(ref);
}
else if (propId == IWorkbenchPartConstants::PROP_CLOSED)
{
this->PartClosed(ref);
}
else if (propId == IWorkbenchPartConstants::PROP_VISIBLE)
{
if (ref->GetVisible())
{
this->PartVisible(ref);
}
else
{
this->PartHidden(ref);
}
}
else if (propId == IWorkbenchPartConstants::PROP_INPUT)
{
this->PartInputChanged(ref);
}
}
IWorkbenchPartReference::Pointer PartList::GetActivePartReference()
{
return activePartReference.Lock();
}
IEditorReference::Pointer PartList::GetActiveEditorReference()
{
return activeEditorReference.Lock();
}
IEditorPart::Pointer PartList::GetActiveEditor()
{
return activeEditorReference.Expired() ? IEditorPart::Pointer(0) : activeEditorReference.Lock()->GetEditor(
false);
}
IWorkbenchPart::Pointer PartList::GetActivePart()
{
return activePartReference.Expired() ? IWorkbenchPart::Pointer(0) : activePartReference.Lock()->GetPart(false);
}
//std::vector PartList::GetEditors()
//{
// std::vector result;
// for (std::deque::iterator iter =
// parts.begin(); iter != parts.end(); ++iter)
// {
// if (iter->Cast () != 0)
// result.push_back(iter->Cast ());
// }
//
// return result;
//}
void PartList::AddPart(WorkbenchPartReference::Pointer ref)
{
poco_assert(ref.IsNotNull());
ref->AddPropertyListener(IPropertyChangeListener::Pointer(this));
// if (!this->Contains(ref))
// {
// parts.push_back(ref);
// }
// parts.add(ref);
this->FirePartAdded(ref);
// If this part is already open, fire the "part opened" event
// immediately
if (ref->GetPart(false).IsNotNull())
{
this->PartOpened(ref);
}
// If this part is already visible, fire the visibility event
// immediately
if (ref->GetVisible())
{
this->PartVisible(ref);
}
}
void PartList::SetActivePart(IWorkbenchPartReference::Pointer ref)
{
if (activePartReference.Lock() == ref)
{
return;
}
IWorkbenchPartReference::Pointer oldPart = activePartReference.Lock();
// A part can't be activated until it is added
//poco_assert(ref == 0 || this->Contains(ref));
//std::remove(parts.begin(), parts.end(), ref);
//parts.push_front(ref);
activePartReference = ref;
this->FireActivePartChanged(oldPart, ref);
}
void PartList::SetActiveEditor(IEditorReference::Pointer ref)
{
if (activeEditorReference.Lock() == ref)
{
return;
}
// A part can't be activated until it is added
//poco_assert(ref == 0 || this->Contains(ref));
activeEditorReference = ref;
//std::remove(parts.begin(), parts.end(), ref);
//parts.push_front(ref);
this->FireActiveEditorChanged(ref);
}
void PartList::RemovePart(WorkbenchPartReference::Pointer ref)
{
poco_assert(ref.IsNotNull());
// It is an error to remove a part that isn't in the list
//poco_assert(this->Contains(ref));
// We're not allowed to remove the active part. We must deactivate it
// first.
poco_assert(activePartReference.Lock() != ref);
// We're not allowed to remove the active editor. We must deactivate it
// first.
if (ref.Cast())
{
poco_assert(activeEditorReference.Lock() != ref.Cast());
}
if (ref->GetVisible())
{
ref->SetVisible(false);
}
// If this part is currently open, fire the "part closed" event before
// removal
if (ref->GetPart(false).IsNotNull())
{
this->PartClosed(ref);
}
//std::remove(parts.begin(), parts.end(), ref);
ref->RemovePropertyListener(IPropertyChangeListener::Pointer(this));
this->FirePartRemoved(ref);
}
//int PartList::IndexOf(const IWorkbenchPartReference::Pointer ref) const
//{
// std::deque::const_iterator result = std::find(parts.begin(), parts.end(), ref);
// if (result == parts.end()) return -1;
// else return result - parts.begin();
//}
//void PartList::BringToTop(IWorkbenchPartReference::Pointer ref)
//{
-// IStackableContainer::Pointer targetContainer;
+// ILayoutContainer::Pointer targetContainer;
// if (ref != 0)
// {
// PartPane::Pointer pane = ref.Cast()->GetPane();
// if (pane != 0)
// {
// targetContainer = pane->GetContainer();
// }
// }
//
// std::deque::iterator newIndex = this->LastIndexOfContainer(targetContainer);
//
// // //New index can be -1 if there is no last index
// // if (newIndex >= 0 && ref == parts.get(newIndex))
// // return;
//
// std::remove(parts.begin(), parts.end(), ref);
// if(newIndex != parts.end())
// {
// parts.insert(newIndex, ref);
// }
// else
// parts.push_front(ref);
//}
//std::vector
//PartList::GetParts(const std::vector& views)
//{
// std::vector resultList;
// for (std::deque::iterator partIter = parts.begin();
// partIter != parts.end(); ++partIter)
// {
// IWorkbenchPartReference::Pointer ref = *partIter;
// if (ref.Cast() != 0)
// {
// //Filter views from other perspectives
// for (unsigned int i = 0; i < views.size(); i++)
// {
// if (ref == views[i])
// {
// resultList.push_back(ref);
// break;
// }
// }
// }
// else
// {
// resultList.push_back(ref);
// }
// }
// return resultList;
//}
//std::deque::iterator
-//PartList::LastIndexOfContainer(IStackableContainer::Pointer container)
+//PartList::LastIndexOfContainer(ILayoutContainer::Pointer container)
//{
// for (std::deque::iterator iter = parts.begin();
// iter != parts.end(); ++iter)
// {
// IWorkbenchPartReference::Pointer ref = *iter;
//
-// IStackableContainer::Pointer cnt;
+// ILayoutContainer::Pointer cnt;
// PartPane::Pointer pane = ref.Cast()->GetPane();
// if (pane != 0)
// {
// cnt = pane->GetContainer();
// }
// if (cnt == container)
// {
// return iter;
// }
// }
//
// return parts.end();
//}
//bool PartList::Contains(IWorkbenchPartReference::Pointer ref)
//{
// return std::find(parts.begin(), parts.end(), ref) != parts.end();
//}
void PartList::PartInputChanged(WorkbenchPartReference::Pointer ref)
{
this->FirePartInputChanged(ref);
}
void PartList::PartHidden(WorkbenchPartReference::Pointer ref)
{
// Part should not be null
poco_assert(ref.IsNotNull());
// This event should only be fired if the part is actually visible
poco_assert(!ref->GetVisible());
// We shouldn't be receiving events from parts until they are in the
// list
//poco_assert(this->Contains(ref));
this->FirePartHidden(ref);
}
void PartList::PartOpened(WorkbenchPartReference::Pointer ref)
{
poco_assert(ref.IsNotNull());
IWorkbenchPart::Pointer actualPart = ref->GetPart(false);
// We're firing the event that says "the part was just created"... so
// there better be a part there.
poco_assert(actualPart.IsNotNull());
// Must be called after the part is inserted into the part list
//poco_assert(this->Contains(ref));
// The active part must be opened before it is activated, so we should
// never get an open event for a part that is already active.
// (This either indicates that a redundant
// open event was fired or that a closed part was somehow activated)
poco_assert(activePartReference.Lock() != ref);
// The active editor must be opened before it is activated, so we should
// never get an open event for an editor that is already active.
// (This either indicates that a redundant
// open event was fired or that a closed editor was somehow activated)
poco_assert((void*)activeEditorReference.Lock().GetPointer() != (void*)ref.GetPointer());
SaveablesList::Pointer modelManager = actualPart
->GetSite()->GetService(ISaveablesLifecycleListener::GetManifestName()).Cast();
modelManager->PostOpen(actualPart);
// Fire the "part opened" event
this->FirePartOpened(ref);
}
void PartList::PartClosed(WorkbenchPartReference::Pointer ref)
{
poco_assert(ref.IsNotNull());
IWorkbenchPart::Pointer actualPart = ref->GetPart(false);
// Called before the part is disposed, so the part should still be
// there.
poco_assert(actualPart.IsNotNull());
// Must be called before the part is actually removed from the part list
// poco_assert(this->Contains(ref));
// Not allowed to close the active part. The part must be deactivated
// before it may be closed.
poco_assert(activePartReference.Lock() != ref);
// Not allowed to close the active editor. The editor must be
// deactivated before it may be closed.
if (ref.Cast())
{
poco_assert(activeEditorReference.Lock() != ref.Cast());
}
this->FirePartClosed(ref);
}
void PartList::PartVisible(WorkbenchPartReference::Pointer ref)
{
// Part should not be null
poco_assert(ref.IsNotNull());
// This event should only be fired if the part is actually visible
poco_assert(ref->GetVisible());
// We shouldn't be receiving events from parts until they are in the
// list
//poco_assert(this->Contains(ref));
// Part must be open before it can be made visible
poco_assert(ref->GetPart(false).IsNotNull());
this->FirePartVisible(ref);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartList.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartList.h
index 81dc477dcc..2610cde6dc 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartList.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartList.h
@@ -1,189 +1,189 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYPARTLIST_H_
#define BERRYPARTLIST_H_
#include "berryWorkbenchPartReference.h"
-#include "berryIStackableContainer.h"
+#include "berryILayoutContainer.h"
#include "berryIEditorReference.h"
#include "berryIViewReference.h"
#include
namespace berry
{
class PartList : public IPropertyChangeListener {
private:
// list of parts in the activation order (oldest last)
//std::deque parts;
IWorkbenchPartReference::WeakPtr activePartReference;
IEditorReference::WeakPtr activeEditorReference;
public:
void PropertyChange(Object::Pointer source, int propId);
IWorkbenchPartReference::Pointer GetActivePartReference();
IEditorReference::Pointer GetActiveEditorReference();
IEditorPart::Pointer GetActiveEditor();
IWorkbenchPart::Pointer GetActivePart();
//std::vector GetEditors();
void AddPart(WorkbenchPartReference::Pointer ref);
/**
* Sets the active part.
*
* @param ref
*/
void SetActivePart(IWorkbenchPartReference::Pointer ref);
void SetActiveEditor(IEditorReference::Pointer ref);
/**
* In order to remove a part, it must first be deactivated.
*/
void RemovePart(WorkbenchPartReference::Pointer ref);
//int IndexOf(const IWorkbenchPartReference::Pointer ref) const;
/*
* Ensures that the given part appears AFTER any other part in the same
* container.
*/
//void BringToTop(IWorkbenchPartReference::Pointer ref);
/*
* Return a list with all parts (editors and views).
*/
//std::vector GetParts(const std::vector& views);
private:
/*
* Returns the last (most recent) index of the given container in the activation list, or returns
* -1 if the given container does not appear in the activation list.
*/
//std::deque::iterator
- // LastIndexOfContainer(IStackableContainer::Pointer container);
+ // LastIndexOfContainer(ILayoutContainer::Pointer container);
void PartInputChanged(WorkbenchPartReference::Pointer ref);
void PartHidden(WorkbenchPartReference::Pointer ref);
void PartOpened(WorkbenchPartReference::Pointer ref);
/**
* Called when a concrete part is about to be destroyed. This is called
* BEFORE disposal happens, so the part should still be accessable from the
* part reference.
*
* @param ref
*/
void PartClosed(WorkbenchPartReference::Pointer ref);
void PartVisible(WorkbenchPartReference::Pointer ref);
//bool Contains(IWorkbenchPartReference::Pointer ref);
protected:
/**
* Fire the event indicating that a part reference was just realized. That
* is, the concrete IWorkbenchPart has been attached to the part reference.
*
* @param part
* the reference that was create
*/
virtual void FirePartOpened(IWorkbenchPartReference::Pointer part) = 0;
/**
* Fire the event indicating that a part reference was just realized. That
* is, the concrete IWorkbenchPart has been attached to the part reference.
*
* @param part
* the reference that was create
*/
virtual void FirePartClosed(IWorkbenchPartReference::Pointer part) = 0;
/**
* Indicates that a new part reference was added to the list.
*
* @param part
*/
virtual void FirePartAdded(IWorkbenchPartReference::Pointer part) = 0;
/**
* Indicates that a part reference was removed from the list
*
* @param part
*/
virtual void FirePartRemoved(IWorkbenchPartReference::Pointer part) = 0;
/**
* Indicates that the active editor changed
*
* @param part
* active part reference or null if none
*/
virtual void FireActiveEditorChanged(IWorkbenchPartReference::Pointer ref) = 0;
/**
* Indicates that the active part has changed
*
* @param part
* active part reference or null if none
*/
virtual void FireActivePartChanged(
IWorkbenchPartReference::Pointer oldPart, IWorkbenchPartReference::Pointer newPart) = 0;
/**
* Indicates that the part has been made visible
*
* @param ref
*/
virtual void FirePartVisible(IWorkbenchPartReference::Pointer ref) = 0;
/**
* Indicates that the part has been hidden
*
* @param ref
*/
virtual void FirePartHidden(IWorkbenchPartReference::Pointer ref) = 0;
/**
* Indicates that the part input has changed
*
* @param ref
*/
virtual void FirePartInputChanged(IWorkbenchPartReference::Pointer ref) = 0;
virtual void FirePartBroughtToTop(IWorkbenchPartReference::Pointer ref) = 0;
};
}
#endif /*BERRYPARTLIST_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartPane.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartPane.cpp
index cea52b7fba..53e0d48699 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartPane.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartPane.cpp
@@ -1,466 +1,461 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryPartPane.h"
#include "tweaklets/berryGuiWidgetsTweaklet.h"
#include "tweaklets/berryWorkbenchPageTweaklet.h"
#include "berryWorkbenchPage.h"
#include "berryPartStack.h"
#include "berryEditorAreaHelper.h"
#include "berryPerspective.h"
#include "berryPartStack.h"
#include "berryDragUtil.h"
namespace berry
{
PartPane::Sashes::Sashes() :
left(0), right(0), top(0), bottom(0)
{
}
PartPane::PartPane(IWorkbenchPartReference::Pointer partReference,
WorkbenchPage* workbenchPage)
- : StackablePart(partReference->GetId()),
+ : LayoutPart(partReference->GetId()),
control(0), inLayout(true), busy(false), hasFocus(false)
{
//super(partReference.getId());
this->partReference = partReference;
this->page = workbenchPage;
}
void PartPane::CreateControl(void* parent) {
if (this->GetControl() != 0)
{
return;
}
partReference.Lock()->AddPropertyListener(IPropertyChangeListener::Pointer(this));
// Create view form.
control = Tweaklets::Get(WorkbenchPageTweaklet::KEY)->CreatePaneControl(parent);
// the part should never be visible by default. It will be made visible
// by activation. This allows us to have views appear in tabs without
// becoming active by default.
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->SetVisible(control, false);
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->MoveAbove(control, 0);
// Create a title bar.
//this->CreateTitleBar();
// When the pane or any child gains focus, notify the workbench.
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->AddControlListener(control, GuiTk::IControlListener::Pointer(this));
//control.addTraverseListener(traverseListener);
}
-bool PartPane::IsPlaceHolder()
-{
- return false;
-}
-
PartPane::~PartPane()
{
// super.dispose();
//
this->Register();
if (control != 0)
{
BERRY_DEBUG << "Deleting PartPane control";
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->RemoveControlListener(control, GuiTk::IControlListener::Pointer(this));
// control.removeTraverseListener(traverseListener);
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->Dispose(control);
control = 0;
}
// if ((paneMenuManager != null))
// {
// paneMenuManager.dispose();
// paneMenuManager = null;
// }
//
if (!partReference.Expired())
{
partReference.Lock()->RemovePropertyListener(IPropertyChangeListener::Pointer(this));
}
// partReference.removePartPropertyListener(this);
this->UnRegister(false);
}
void PartPane::DoHide()
{
if (partReference.Lock().Cast() != 0)
{
this->GetPage()->HideView(partReference.Lock().Cast());
}
else if (partReference.Lock().Cast() != 0)
{
this->GetPage()->CloseEditor(partReference.Lock().Cast(), true);
}
}
Rectangle PartPane::GetParentBounds()
{
void* ctrl = this->GetControl();
if (this->GetContainer() != 0 && this->GetContainer().Cast() != 0) {
LayoutPart::Pointer part = this->GetContainer().Cast();
if (part->GetControl() != 0) {
ctrl = part->GetControl();
}
}
return DragUtil::GetDisplayBounds(ctrl);
}
void* PartPane::GetControl()
{
return control;
}
IWorkbenchPartReference::Pointer PartPane::GetPartReference() const
{
return partReference.Lock();
}
void PartPane::ControlActivated(GuiTk::ControlEvent::Pointer /*e*/)
{
if (inLayout)
{
this->RequestActivation();
}
}
GuiTk::IControlListener::Events::Types PartPane::GetEventTypes() const
{
return GuiTk::IControlListener::Events::ACTIVATED;
}
void PartPane::MoveAbove(void* refControl)
{
if (this->GetControl() != 0)
{
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->MoveAbove(this->GetControl(), refControl);
}
}
void PartPane::RequestActivation()
{
IWorkbenchPart::Pointer part = partReference.Lock()->GetPart(true);
this->page->RequestActivation(part);
}
//PartStack::Pointer PartPane::GetStack()
//{
// return partStack;
//}
PartPane::Sashes PartPane::FindSashes()
{
Sashes result;
- IStackableContainer::Pointer container = this->GetContainer();
+ ILayoutContainer::Pointer container = this->GetContainer();
if (container == 0) {
return result;
}
- container->FindSashes(result);
+ container->FindSashes(LayoutPart::Pointer(this), result);
return result;
}
WorkbenchPage::Pointer PartPane::GetPage()
{
return WorkbenchPage::Pointer(page);
}
-void PartPane::SetContainer(IStackableContainer::Pointer container)
+void PartPane::SetContainer(ILayoutContainer::Pointer container)
{
if (hasFocus)
{
- IStackableContainer::Pointer oldContainer = this->GetContainer();
+ ILayoutContainer::Pointer oldContainer = this->GetContainer();
if (PartStack::Pointer oldStack = oldContainer.Cast())
{
oldStack->SetActive(StackPresentation::AS_INACTIVE);
}
if (PartStack::Pointer newContainer = container.Cast())
{
newContainer->SetActive(StackPresentation::AS_ACTIVE_FOCUS);
}
}
void* containerControl = container == 0 ? 0 : container.Cast()->GetControl();
if (containerControl != 0)
{
void* control = this->GetControl();
void* newParent = Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetParent(containerControl);
if (control != 0 && newParent != Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetParent(control))
{
this->Reparent(newParent);
}
}
- StackablePart::SetContainer(container);
+ LayoutPart::SetContainer(container);
}
void PartPane::Reparent(void* newParent)
{
void* control = this->GetControl();
GuiWidgetsTweaklet* guiTweaklet = Tweaklets::Get(GuiWidgetsTweaklet::KEY);
if ((control == 0) || (guiTweaklet->GetParent(control) == newParent))
{
return;
}
if (guiTweaklet->IsReparentable(control))
{
// make control small in case it is not resized with other controls
//control.setBounds(0, 0, 0, 0);
// By setting the control to disabled before moving it,
// we ensure that the focus goes away from the control and its children
// and moves somewhere else
bool enabled = guiTweaklet->GetEnabled(control);
guiTweaklet->SetEnabled(control, false);
guiTweaklet->SetParent(control, newParent);
guiTweaklet->SetEnabled(control, enabled);
guiTweaklet->MoveAbove(control, 0);
}
}
void PartPane::ShowFocus(bool inFocus)
{
if (partReference.Lock().Cast() != 0)
{
hasFocus = inFocus;
}
if (PartStack::Pointer stack = this->GetContainer().Cast())
{
if (partReference.Lock().Cast() != 0)
{
stack->SetActive(inFocus ? StackPresentation::AS_ACTIVE_FOCUS
: StackPresentation::AS_INACTIVE);
}
else if (partReference.Lock().Cast() != 0)
{
if (inFocus)
{
page->GetEditorPresentation()->SetActiveWorkbook(stack, true);
}
else
{
stack->SetActive(page->GetEditorPresentation()->GetActiveWorkbook() == stack ?
StackPresentation::AS_ACTIVE_NOFOCUS : StackPresentation::AS_INACTIVE);
}
}
}
}
PartStack::Pointer PartPane::GetStack()
{
- IStackableContainer::Pointer container = this->GetContainer();
+ ILayoutContainer::Pointer container = this->GetContainer();
return container.Cast();
}
void PartPane::SetVisible(bool makeVisible)
{
// Avoid redundant visibility changes
if (makeVisible == this->GetVisible())
{
return;
}
if (makeVisible)
{
partReference.Lock()->GetPart(true);
}
if (this->GetControl() != 0)
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->SetVisible(this->GetControl(), makeVisible);
partReference.Lock().Cast()->FireVisibilityChange();
}
bool PartPane::GetVisible()
{
if (this->GetControl() != 0)
return Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetVisible(this->GetControl());
return false;
}
void PartPane::SetFocus()
{
this->RequestActivation();
IWorkbenchPart::Pointer part = partReference.Lock()->GetPart(true);
if (part.IsNotNull())
{
// Control control = getControl();
// if (!SwtUtil.isFocusAncestor(control))
// {
// First try to call part.setFocus
part->SetFocus();
//}
}
}
void PartPane::SetWorkbenchPage(WorkbenchPage::Pointer workbenchPage)
{
this->page = workbenchPage.GetPointer();
}
void PartPane::DoDock()
{
// do nothing
}
void PartPane::SetBusy(bool isBusy)
{
if (isBusy != busy)
{
busy = isBusy;
//firePropertyChange(IPresentablePart.PROP_BUSY);
}
}
void PartPane::ShowHighlight()
{
//No nothing by default
}
void* PartPane::GetToolBar()
{
return 0;
}
bool PartPane::HasViewMenu()
{
return false;
}
bool PartPane::IsBusy()
{
return busy;
}
void PartPane::DescribeLayout(std::string& buf) const
{
IWorkbenchPartReference::Pointer part = this->GetPartReference();
if (part.IsNotNull())
{
buf.append(part->GetPartName());
return;
}
}
bool PartPane::IsCloseable()
{
if (partReference.Lock().Cast() != 0)
{
Perspective::Pointer perspective = page->GetActivePerspective();
if (perspective == 0) {
// Shouldn't happen -- can't have a ViewStack without a
// perspective
return true;
}
return perspective->IsCloseable(partReference.Lock().Cast());
}
return true;
}
void PartPane::SetInLayout(bool inLayout)
{
this->inLayout = inLayout;
}
bool PartPane::GetInLayout()
{
return inLayout;
}
bool PartPane::AllowsAutoFocus()
{
if (!inLayout)
{
return false;
}
//return super.allowsAutoFocus();
return true;
}
void PartPane::RemoveContributions()
{
}
void PartPane::AddPropertyListener(IPropertyChangeListener::Pointer listener)
{
propertyChangeEvents.AddListener(listener);
}
void PartPane::RemovePropertyListener(IPropertyChangeListener::Pointer listener)
{
propertyChangeEvents.RemoveListener(listener);
}
void PartPane::FirePropertyChange(PropertyChangeEvent::Pointer event)
{
propertyChangeEvents.propertyChange(event);
}
void PartPane::PropertyChange(PropertyChangeEvent::Pointer event)
{
this->FirePropertyChange(event);
}
int PartPane::ComputePreferredSize(bool width, int availableParallel,
int availablePerpendicular, int preferredParallel)
{
return partReference.Lock().Cast()->ComputePreferredSize(width,
availableParallel, availablePerpendicular, preferredParallel);
}
int PartPane::GetSizeFlags(bool horizontal)
{
return partReference.Lock().Cast()->GetSizeFlags(horizontal);
}
void PartPane::ShellActivated()
{
}
void PartPane::ShellDeactivated()
{
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartPane.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartPane.h
index e0a0c5b30b..67eaf6583e 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartPane.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartPane.h
@@ -1,436 +1,434 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYPARTPANE_H_
#define BERRYPARTPANE_H_
#include "berryWorkbenchPartReference.h"
-#include "berryStackablePart.h"
+#include "berryLayoutPart.h"
#include "berryRectangle.h"
#include "berryIPropertyChangeListener.h"
#include "guitk/berryGuiTkIControlListener.h"
namespace berry {
class WorkbenchPage;
class PartStack;
-struct IStackableContainer;
+struct ILayoutContainer;
/**
* Provides the common behavior for both views
* and editor panes.
*
*/
-class PartPane : public StackablePart,
+class PartPane : public LayoutPart,
public IPropertyChangeListener,
public GuiTk::IControlListener
{
public:
berryObjectMacro(PartPane);
friend class PartSashContainer;
friend class EditorSashContainer;
friend class WorkbenchPage;
- friend struct IStackableContainer;
friend struct ILayoutContainer;
friend class PartStack;
friend class ContainerPlaceholder;
friend class LayoutTree;
friend class LayoutTreeNode;
friend class DetachedPlaceHolder;
friend class PerspectiveHelper;
// private: MenuManager paneMenuManager;
// private: ListenerList listeners = new ListenerList();
// private: ListenerList partListeners = new ListenerList();
private: IPropertyChangeListener::Events propertyChangeEvents;
protected: IWorkbenchPartReference::WeakPtr partReference;
protected: WorkbenchPage* page;
protected: void* control;
private: bool inLayout;
// private: TraverseListener traverseListener = new TraverseListener() {
// /* (non-Javadoc)
// * @see org.blueberry.swt.events.TraverseListener#keyTraversed(org.blueberry.swt.events.TraverseEvent)
// */
// public: void keyTraversed(TraverseEvent e) {
// // Hack: Currently, SWT sets focus whenever we call Control.traverse. This doesn't
// // cause too much of a problem for ctrl-pgup and ctrl-pgdn, but it is seriously unexpected
// // for other traversal events. When (and if) it becomes possible to call traverse() without
// // forcing a focus change, this if statement should be removed and ALL events should be
// // forwarded to the container.
// if (e.detail == SWT.TRAVERSE_PAGE_NEXT
// || e.detail == SWT.TRAVERSE_PAGE_PREVIOUS) {
// ILayoutContainer container = getContainer();
// if (container != null && container instanceof LayoutPart) {
// LayoutPart parent = (LayoutPart) container;
// Control parentControl = parent.getControl();
// if (parentControl != null && !parentControl.isDisposed()) {
// e.doit = parentControl.traverse(e.detail);
// if (e.doit) {
// e.detail = SWT.TRAVERSE_NONE;
// }
// }
// }
// }
// }
//
// };
private: bool busy;
private: bool hasFocus;
//private: SmartPointer partStack;
protected:
/*static*/ class Sashes {
public:
Sashes();
/*Sash*/ void* left;
/*Sash*/ void* right;
/*Sash*/ void* top;
/*Sash*/ void* bottom;
};
/**
* Construct a pane for a part.
*/
public: PartPane(IWorkbenchPartReference::Pointer partReference,
WorkbenchPage* workbenchPage);
// public: void addSizeMenuItem(Menu menu, int index) {
// //Add size menu
// MenuItem item = new MenuItem(menu, SWT.CASCADE, index);
// item.setText(WorkbenchMessages.PartPane_size);
// Menu sizeMenu = new Menu(menu);
// item.setMenu(sizeMenu);
// addSizeItems(sizeMenu);
// }
/**
*
* Creates the GUI-dependent container control
* for the part widgets. This is passed to
* IWorkbenchPart::CreatePartControl(void*)
*/
public: virtual void CreateControl(void* parent);
//public: virtual void SetControlEnabled(bool enabled) = 0;
/**
* Create a title bar for the pane if required.
*/
// protected: virtual void CreateTitleBar() = 0;
- public: bool IsPlaceHolder();
/**
* @private:
*/
public: virtual ~PartPane();
/**
* User has requested to close the pane.
* Take appropriate action depending on type.
*/
public: void DoHide();
protected: Rectangle GetParentBounds();
/**
* Get the control.
*/
public: void* GetControl();
/**
* Answer the part child.
*/
public: IWorkbenchPartReference::Pointer GetPartReference() const;
/**
* @see GuiTk::IControlListener
*/
public: void ControlActivated(GuiTk::ControlEvent::Pointer e);
/**
* @see GuiTk::IControlListener
*/
public: GuiTk::IControlListener::Events::Types GetEventTypes() const;
/**
* Move the control over another one.
*/
public: void MoveAbove(void* refControl);
/**
* Notify the workbook page that the part pane has
* been activated by the user.
*/
public: void RequestActivation();
/**
* Shows the receiver if visible
is true otherwise hide it.
*/
public: void SetVisible(bool makeVisible);
public: virtual bool GetVisible();
/**
* Sets focus to this part.
*/
public: void SetFocus();
/**
* Sets the workbench page of the view.
*/
public: void SetWorkbenchPage(SmartPointer workbenchPage);
public: void Reparent(void* newParent);
/**
* Indicate focus in part.
*/
public: void ShowFocus(bool inFocus);
/**
* @see IPartDropTarget::targetPartFor
*/
// public: LayoutPart targetPartFor(LayoutPart dragSource) {
// return this;
// }
/**
* Returns the PartStack that contains this PartPane, or null if none.
*
* @return
*/
public: SmartPointer GetStack();
- public: void SetContainer(SmartPointer stack);
+ public: void SetContainer(SmartPointer stack);
/**
* Show a title label menu for this pane.
*/
// public: void ShowPaneMenu() {
// PartStack folder = getStack();
//
// if (folder != null) {
// folder.showPaneMenu();
// }
// }
/**
* Show the context menu for this part.
*/
// public: void showSystemMenu() {
// PartStack folder = getStack();
//
// if (folder != null) {
// folder.showSystemMenu();
// }
// }
/**
* Finds and return the sashes around this part.
*/
protected: Sashes FindSashes();
/**
* Enable the user to resize this part using
* the keyboard to move the specified sash
*/
// protected: void moveSash(final Sash sash) {
// moveSash(sash, this);
// }
// public: static void moveSash(final Sash sash,
// final LayoutPart toGetFocusWhenDone) {
// final KeyListener listener = new KeyAdapter() {
// public: void keyPressed(KeyEvent e) {
// if (e.character == SWT.ESC || e.character == '\r') {
// if (toGetFocusWhenDone != null) {
// toGetFocusWhenDone.setFocus();
// }
// }
// }
// };
// sash.addFocusListener(new FocusAdapter() {
// public: void focusGained(FocusEvent e) {
// sash.setBackground(sash.getDisplay().getSystemColor(
// SWT.COLOR_LIST_SELECTION));
// sash.addKeyListener(listener);
// }
//
// public: void focusLost(FocusEvent e) {
// sash.setBackground(null);
// sash.removeKeyListener(listener);
// }
// });
// sash.setFocus();
//
// }
/**
* Add a menu item to the Size Menu
*/
// protected: void addSizeItem(Menu sizeMenu, String labelMessage,
// final Sash sash) {
// MenuItem item = new MenuItem(sizeMenu, SWT.NONE);
// item.setText(labelMessage);
// item.addSelectionListener(new SelectionAdapter() {
// public: void widgetSelected(SelectionEvent e) {
// moveSash(sash);
// }
// });
// item.setEnabled(!isZoomed() && sash != null);
// }
/**
* Returns the workbench page of this pane.
*/
public: SmartPointer GetPage();
/**
* Add the Left,Right,Up,Botton menu items to the Size menu.
*/
// protected: void addSizeItems(Menu sizeMenu) {
// Sashes sashes = findSashes();
// addSizeItem(sizeMenu,
// WorkbenchMessages.PartPane_sizeLeft, sashes.left);
// addSizeItem(sizeMenu,
// WorkbenchMessages.PartPane_sizeRight, sashes.right);
// addSizeItem(sizeMenu,
// WorkbenchMessages.PartPane_sizeTop, sashes.top);
// addSizeItem(sizeMenu, WorkbenchMessages.PartPane_sizeBottom, sashes.bottom);
// }
/**
* Pin this part.
*/
protected: virtual void DoDock();
/**
* Set the busy state of the pane.
*/
public: virtual void SetBusy(bool isBusy);
/**
* Show a highlight for the receiver if it is
* not currently the part in the front of its
* presentation.
*
*/
public: virtual void ShowHighlight();
/**
* @return
*/
public: virtual void* GetToolBar();
/**
* @return
*/
public: bool HasViewMenu();
/**
* @param location
*/
// public: void ShowViewMenu(Point location) {
//
// }
public: bool IsBusy();
/**
* Writes a description of the layout to the given string buffer.
* This is used for drag-drop test suites to determine if two layouts are the
* same. Like a hash code, the description should compare as equal iff the
* layouts are the same. However, it should be user-readable in order to
* help debug failed tests. Although these are english readable strings,
* they do not need to be translated.
*
* @param buf
*/
public: void DescribeLayout(std::string& buf) const;
/**
* @return
* @since 3.1
*/
public: bool IsCloseable();
public: void SetInLayout(bool inLayout);
public: bool GetInLayout();
public: bool AllowsAutoFocus();
/**
* Clears all contribution items from the contribution managers (this is done separately
* from dispose() since it is done after the part is disposed). This is a bit of a hack.
* Really, the contribution managers should be part of the site, not the PartPane. If these
* were moved elsewhere, then disposal of the PartPane would be atomic and this method could
* be removed.
*/
public: virtual void RemoveContributions();
public: void AddPropertyListener(IPropertyChangeListener::Pointer listener);
public: void RemovePropertyListener(IPropertyChangeListener::Pointer listener);
public: void FirePropertyChange(PropertyChangeEvent::Pointer event);
/* (non-Javadoc)
* @see IPropertyChangeListener#PropertyChange(PropertyChangeEvent::Pointer)
*/
public: void PropertyChange(PropertyChangeEvent::Pointer event);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.LayoutPart#computePreferredSize(boolean, int, int, int)
*/
public: int ComputePreferredSize(bool width, int availableParallel,
int availablePerpendicular, int preferredParallel);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.LayoutPart#getSizeFlags(boolean)
*/
public: int GetSizeFlags(bool horizontal);
/**
* Informs the pane that it's window shell has
* been activated.
*/
public: virtual void ShellActivated();
/**
* Informs the pane that it's window shell has
* been deactivated.
*/
public: virtual void ShellDeactivated();
};
}
#endif /*BERRYPARTPANE_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartPlaceholder.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartPlaceholder.cpp
index 7232eef7b9..216279d6c5 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartPlaceholder.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartPlaceholder.cpp
@@ -1,52 +1,52 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryPartPlaceholder.h"
#include "berryPartStack.h"
namespace berry
{
const std::string PartPlaceholder::WILD_CARD = "*"; //$NON-NLS-1$
PartPlaceholder::PartPlaceholder(const std::string& id) :
- StackablePart(id)
+ LayoutPart(id)
{
}
void PartPlaceholder::CreateControl(void* /*parent*/)
{
// do nothing
}
void* PartPlaceholder::GetControl()
{
return 0;
}
bool PartPlaceholder::HasWildCard()
{
- return this->GetId().find_first_of(WILD_CARD) != std::string::npos;
+ return this->GetID().find_first_of(WILD_CARD) != std::string::npos;
}
bool PartPlaceholder::IsPlaceHolder() const
{
return true;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartPlaceholder.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartPlaceholder.h
index ce57dd9abc..c4ebd79dd1 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartPlaceholder.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartPlaceholder.h
@@ -1,66 +1,66 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYPARTPLACEHOLDER_H_
#define BERRYPARTPLACEHOLDER_H_
-#include "berryStackablePart.h"
+#include "berryLayoutPart.h"
namespace berry {
/**
* \ingroup org_blueberry_ui_internal
*
* A PlaceHolder is a non-visible stand-in for a layout part.
*/
-class PartPlaceholder : public StackablePart {
+class PartPlaceholder : public LayoutPart {
public:
berryObjectMacro(PartPlaceholder);
/**
* Placeholder ids may contain wildcards. This is the wildcard string.
*
* @since 3.0
*/
static const std::string WILD_CARD; // = "*"; //$NON-NLS-1$
PartPlaceholder(const std::string& id);
/**
* Creates the SWT control
*/
void CreateControl(void* parent);
/**
* Get the part control. This method may return null.
*/
void* GetControl();
/**
* Returns whether this placeholder has a wildcard.
*
* @since 3.0
*/
bool HasWildCard();
bool IsPlaceHolder() const;
};
}
#endif /*BERRYPARTPLACEHOLDER_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartSashContainer.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartSashContainer.cpp
index 355af00612..e6b21d6a7c 100755
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartSashContainer.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartSashContainer.cpp
@@ -1,1282 +1,1270 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryPartSashContainer.h"
#include "berryLayoutTree.h"
#include "berryLayoutTreeNode.h"
#include "berryPartStack.h"
#include "berryPageLayout.h"
#include "berryPerspective.h"
#include "berryPerspectiveHelper.h"
#include "berryDragUtil.h"
#include "berryWorkbenchPlugin.h"
#include "berryWorkbenchPreferenceConstants.h"
#include "berryGeometry.h"
#include "berryPartPane.h"
#include "tweaklets/berryGuiWidgetsTweaklet.h"
#include "berryConstants.h"
namespace berry
{
bool PartSashContainer::leftToRight = true;
PartSashContainer::ControlListener::ControlListener(
PartSashContainer* container) :
partSashContainer(container)
{
}
GuiTk::IControlListener::Events::Types PartSashContainer::ControlListener::GetEventTypes() const
{
return Events::RESIZED;
}
void PartSashContainer::ControlListener::ControlResized(
GuiTk::ControlEvent::Pointer /*e*/)
{
partSashContainer->ResizeSashes();
}
PartSashContainer::SashContainerDropTarget::SashContainerDropTarget(
PartSashContainer* partSashContainer, Object::Pointer sourcePart, int side,
int cursor, Object::Pointer targetPart) :
partSashContainer(partSashContainer)
{
this->SetTarget(sourcePart, side, cursor, targetPart);
}
void PartSashContainer::SashContainerDropTarget::SetTarget(
Object::Pointer sourcePart, int side, int cursor,
Object::Pointer targetPart)
{
this->side = side;
this->targetPart = targetPart;
this->sourcePart = sourcePart;
this->cursor = cursor;
}
void PartSashContainer::SashContainerDropTarget::Drop()
{
if (side != Constants::NONE)
{
- StackablePart::Pointer visiblePart = sourcePart.Cast ();
+ LayoutPart::Pointer visiblePart = sourcePart.Cast ();
- if (sourcePart.Cast () != 0)
+ if (sourcePart.Cast () != 0)
{
visiblePart = partSashContainer->GetVisiblePart(sourcePart.Cast<
- IStackableContainer> ());
+ ILayoutContainer> ());
}
partSashContainer->DropObject(
partSashContainer->GetVisibleParts(sourcePart), visiblePart,
targetPart, side);
}
}
void PartSashContainer::DropObject(const std::vector& toDrop,
- StackablePart::Pointer visiblePart, Object::Pointer targetPart, int side)
+ LayoutPart::Pointer visiblePart, Object::Pointer targetPart, int side)
{
//getControl().setRedraw(false);
// Targetpart is null if there isn't a part under the cursor (all the parts are
// hidden or the container is empty). In this case, the actual side doesn't really
// since we'll be the only visible container and will fill the entire space. However,
// we can't leave it as Constants::CENTER since we can't stack if we don't have something
// to stack on. In this case, we pick Constants::BOTTOM -- this will insert the new pane
// below any currently-hidden parts.
if (targetPart == 0 && side == Constants::CENTER)
{
side = Constants::BOTTOM;
}
PartStack::Pointer targetStack = targetPart.Cast ();
if (targetStack == 0 && targetPart.Cast() != 0)
{
targetStack = targetPart.Cast ()->GetStack();
}
LayoutPart::Pointer targetLayoutPart = targetStack;
// if targetLayoutPart == 0 then we normally got a EditorSashContainer
if (targetLayoutPart == 0)
targetLayoutPart = targetPart.Cast();
if (side == Constants::CENTER)
{
if (this->IsStackType(targetStack))
{
for (unsigned int idx = 0; idx < toDrop.size(); idx++)
{
- StackablePart::Pointer next = toDrop[idx];
+ LayoutPart::Pointer next = toDrop[idx];
this->Stack(next, targetStack);
}
}
}
else
{
PartStack::Pointer newPart = this->CreateStack();
// if the toDrop array has 1 item propagate the stack
// appearance
if (toDrop.size() == 1 && toDrop[0]->GetStack() != 0)
{
toDrop[0]->GetStack()->CopyAppearanceProperties(newPart);
}
for (unsigned int idx = 0; idx < toDrop.size(); idx++)
{
- StackablePart::Pointer next = toDrop[idx];
+ LayoutPart::Pointer next = toDrop[idx];
this->Stack(next, newPart);
}
this->AddEnhanced(newPart, side, this->GetDockingRatio(newPart, targetStack),
targetLayoutPart);
}
if (visiblePart != 0)
{
this->SetVisiblePart(visiblePart->GetContainer(),
visiblePart.Cast ());
}
//getControl().setRedraw(true);
if (visiblePart != 0)
{
visiblePart->SetFocus();
}
}
DnDTweaklet::CursorType PartSashContainer::SashContainerDropTarget::GetCursor()
{
return DnDTweaklet::PositionToCursorType(cursor);
}
Rectangle PartSashContainer::SashContainerDropTarget::GetSnapRectangle()
{
Rectangle targetBounds;
if (targetPart.Cast () != 0)
{
targetBounds = DragUtil::GetDisplayBounds(
targetPart.Cast ()->GetControl());
}
- else if (targetPart.Cast () != 0)
+ else if (targetPart.Cast () != 0)
{
targetBounds = DragUtil::GetDisplayBounds(
- targetPart.Cast ()->GetControl());
+ targetPart.Cast ()->GetControl());
}
else
{
targetBounds = DragUtil::GetDisplayBounds(partSashContainer->GetParent());
}
if (side == Constants::CENTER || side == Constants::NONE)
{
return targetBounds;
}
int distance = Geometry::GetDimension(targetBounds, !Geometry::IsHorizontal(
side));
- IStackableContainer::Pointer stack = targetPart.Cast ();
- if (stack == 0 && targetPart.Cast () != 0)
+ ILayoutContainer::Pointer stack = targetPart.Cast ();
+ if (stack == 0 && targetPart.Cast () != 0)
{
- stack = targetPart.Cast ()->GetContainer();
+ stack = targetPart.Cast ()->GetContainer();
}
return Geometry::GetExtrudedEdge(targetBounds, (int) (distance
* partSashContainer->GetDockingRatio(sourcePart, stack)), side);
}
PartSashContainer::PartSashContainer(const std::string& id,
WorkbenchPage* _page, void* _parentWidget) :
LayoutPart(id), parentWidget(_parentWidget), parent(0), page(_page), active(
false), layoutDirty(false)
{
resizeListener = new ControlListener(this);
std::string layout = WorkbenchPlugin::GetDefault()->GetPreferencesService()->
GetSystemPreferences()->Get(WorkbenchPreferenceConstants::PREFERRED_SASH_LAYOUT,
WorkbenchPreferenceConstants::LEFT);
if (layout == WorkbenchPreferenceConstants::RIGHT)
{
leftToRight = false;
}
}
std::vector PartSashContainer::GetVisibleParts(
Object::Pointer pane)
{
std::vector parts;
if (pane.Cast ().IsNotNull())
{
parts.push_back(pane.Cast ());
}
else if (pane.Cast ().IsNotNull())
{
PartStack::Pointer stack = pane.Cast ();
- std::list children = stack->GetChildren();
- for (std::list::iterator iter = children.begin(); iter
+ std::list children = stack->GetChildren();
+ for (std::list::iterator iter = children.begin(); iter
!= children.end(); ++iter)
{
if (iter->Cast () != 0)
{
parts.push_back(iter->Cast ());
}
}
}
return parts;
}
PartSashContainer::~PartSashContainer()
{
}
void PartSashContainer::FindSashes(LayoutPart::Pointer pane,
PartPane::Sashes& sashes)
{
if (root == 0)
{
return;
}
LayoutTree::Pointer part = root->Find(pane);
if (part == 0)
{
return;
}
part->FindSashes(sashes);
}
void PartSashContainer::Add(LayoutPart::Pointer child)
{
if (child.IsNull())
{
return;
}
this->AddEnhanced(child, Constants::RIGHT, 0.5f, this->FindBottomRight());
}
-void PartSashContainer::AddPart(StackablePart::Pointer child)
+void PartSashContainer::AddPart(LayoutPart::Pointer child)
{
if (child.IsNull())
{
return;
}
PartStack::Pointer newFolder = this->CreateStack();
newFolder->Add(child);
this->AddEnhanced(newFolder, Constants::RIGHT, 0.5f, this->FindBottomRight());
}
void PartSashContainer::AddEnhanced(LayoutPart::Pointer child,
int directionConstant, float ratioForNewPart, LayoutPart::Pointer relative)
{
int relativePosition =
PageLayout::ConstantToLayoutPosition(directionConstant);
float ratioForUpperLeftPart;
if (relativePosition == IPageLayout::RIGHT || relativePosition
== IPageLayout::BOTTOM)
{
ratioForUpperLeftPart = 1.0f - ratioForNewPart;
}
else
{
ratioForUpperLeftPart = ratioForNewPart;
}
this->Add(child, relativePosition, ratioForUpperLeftPart, relative);
}
void PartSashContainer::Add(LayoutPart::Pointer child, int relationship,
float ratio, LayoutPart::Pointer relative)
{
bool isHorizontal = (relationship == IPageLayout::LEFT || relationship
== IPageLayout::RIGHT);
LayoutTree::Pointer node;
if (root != 0 && relative != 0)
{
node = root->Find(relative);
}
Rectangle bounds;
if (this->GetParent() == 0)
{
void* control = this->GetPage()->GetClientComposite();
if (control != 0)
{
bounds = Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetBounds(control);
}
else
{
bounds = Rectangle(0, 0, 800, 600);
}
bounds.x = 0;
bounds.y = 0;
}
else
{
bounds = this->GetBounds();
}
int totalSize = this->MeasureTree(bounds, node, isHorizontal);
int left = (int) (totalSize * ratio);
int right = totalSize - left;
this->Add(child, relationship, left, right, relative);
}
int PartSashContainer::MeasureTree(const Rectangle& outerBounds,
LayoutTree::ConstPointer toMeasure, bool horizontal)
{
if (toMeasure == 0)
{
return outerBounds.GetDimension(horizontal);
}
LayoutTreeNode* parent = toMeasure->GetParent();
if (parent == 0)
{
return outerBounds.GetDimension(horizontal);
}
if (parent->GetSash()->IsHorizontal() == horizontal)
{
return MeasureTree(outerBounds, LayoutTree::ConstPointer(parent), horizontal);
}
bool isLeft = parent->IsLeftChild(toMeasure);
LayoutTree::Pointer otherChild = parent->GetChild(!isLeft);
if (otherChild->IsVisible())
{
int left = parent->GetSash()->GetLeft();
int right = parent->GetSash()->GetRight();
int childSize = isLeft ? left : right;
int bias = parent->GetCompressionBias();
// Normalize bias: 1 = we're fixed, -1 = other child is fixed
if (isLeft)
{
bias = -bias;
}
if (bias == 1)
{
// If we're fixed, return the fixed size
return childSize;
}
else if (bias == -1)
{
// If the other child is fixed, return the size of the parent minus the fixed size of the
// other child
return MeasureTree(outerBounds, LayoutTree::ConstPointer(parent), horizontal) - (left + right
- childSize);
}
// Else return the size of the parent, scaled appropriately
return MeasureTree(outerBounds, LayoutTree::ConstPointer(parent), horizontal) * childSize / (left
+ right);
}
return MeasureTree(outerBounds, LayoutTree::ConstPointer(parent), horizontal);
}
void PartSashContainer::AddChild(const RelationshipInfo& info)
{
LayoutPart::Pointer child = info.part;
children.push_back(child);
if (root == 0)
{
root = new LayoutTree(child);
}
else
{
//Add the part to the tree.
int vertical = (info.relationship == IPageLayout::LEFT || info.relationship
== IPageLayout::RIGHT) ? Constants::VERTICAL : Constants::HORIZONTAL;
bool left = info.relationship == IPageLayout::LEFT || info.relationship
== IPageLayout::TOP;
LayoutPartSash::Pointer sash(new LayoutPartSash(this, vertical));
sash->SetSizes(info.left, info.right);
if ((parent != 0) && child.Cast ().IsNull())
{
sash->CreateControl(parent);
}
LayoutTree::Pointer newroot =
root->Insert(child, left, sash, info.relative);
root = newroot;
}
this->ChildAdded(child);
if (active)
{
child->CreateControl(parent);
child->SetVisible(true);
child->SetContainer(ILayoutContainer::Pointer(this));
this->ResizeChild(child);
}
}
void PartSashContainer::AddChildForPlaceholder(LayoutPart::Pointer child,
LayoutPart::Pointer placeholder)
{
RelationshipInfo newRelationshipInfo;
newRelationshipInfo.part = child;
if (root != 0)
{
newRelationshipInfo.relationship = IPageLayout::RIGHT;
newRelationshipInfo.relative = root->FindBottomRight();
newRelationshipInfo.left = 200;
newRelationshipInfo.right = 200;
}
// find the relationship info for the placeholder
std::vector relationships = this->ComputeRelation();
for (unsigned int i = 0; i < relationships.size(); i++)
{
RelationshipInfo info = relationships[i];
if (info.part == placeholder)
{
newRelationshipInfo.left = info.left;
newRelationshipInfo.right = info.right;
newRelationshipInfo.relationship = info.relationship;
newRelationshipInfo.relative = info.relative;
}
}
this->AddChild(newRelationshipInfo);
this->FlushLayout();
}
bool PartSashContainer::AllowsBorder()
{
return true;
}
void PartSashContainer::ChildAdded(LayoutPart::Pointer child)
{
if (this->IsDeferred())
{
child->DeferUpdates(true);
}
}
void PartSashContainer::ChildRemoved(LayoutPart::Pointer child)
{
if (this->IsDeferred())
{
child->DeferUpdates(false);
}
}
std::vector PartSashContainer::ComputeRelation()
{
LayoutTree::Pointer treeRoot = root;
std::list list;
if (treeRoot == 0)
{
return std::vector();
}
RelationshipInfo r;
r.part = treeRoot->ComputeRelation(list);
list.push_front(r);
std::vector result(list.begin(), list.end());
return result;
}
void PartSashContainer::SetActive(bool isActive)
{
if (isActive == active)
{
return;
}
active = isActive;
ILayoutContainer::ChildrenType children = this->children;
for (ILayoutContainer::ChildrenType::iterator childIter = children.begin(); childIter
!= children.end(); ++childIter)
{
if (childIter->Cast ().IsNotNull())
{
PartStack::Pointer stack = childIter->Cast ();
stack->SetActive(isActive);
}
}
if (isActive)
{
this->CreateControl(parentWidget);
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->AddControlListener(parent,
resizeListener);
DragUtil::AddDragTarget(parent, IDragOverListener::Pointer(this));
DragUtil::AddDragTarget(Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetShell(parent)->GetControl(), IDragOverListener::Pointer(this));
ILayoutContainer::ChildrenType children = this->children;
for (ILayoutContainer::ChildrenType::iterator childIter = children.begin(); childIter
!= children.end(); ++childIter)
{
LayoutPart::Pointer child = *childIter;
child->SetContainer(ILayoutContainer::Pointer(this));
child->SetVisible(true); //zoomedPart == null || child == zoomedPart);
if (child.Cast ().IsNull())
{
if (root != 0)
{
LayoutTree::Pointer node = root->Find(child);
if (node != 0)
{
node->FlushCache();
}
}
}
}
if (root != 0)
{
//root.flushChildren();
//if (!isZoomed())
{
root->CreateControl(parent);
}
}
this->ResizeSashes();
}
else
{
DragUtil::RemoveDragTarget(parent, IDragOverListener::Pointer(this));
DragUtil::RemoveDragTarget(Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetShell(parent)->GetControl(), IDragOverListener::Pointer(this));
// remove all Listeners
if (resizeListener != 0 && parent != 0)
{
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->RemoveControlListener(parent,
resizeListener);
}
for (ILayoutContainer::ChildrenType::iterator iter = children.begin(); iter
!= children.end(); ++iter)
{
LayoutPart::Pointer child = *iter;
child->SetContainer(ILayoutContainer::Pointer(0));
if (child.Cast ().IsNotNull())
{
child->SetVisible(false);
}
}
this->DisposeSashes();
//dispose();
}
}
void PartSashContainer::CreateControl(void* parentWidget)
{
if (this->parent != 0)
{
return;
}
parent = this->CreateParent(parentWidget);
ILayoutContainer::ChildrenType children = this->children;
for (ILayoutContainer::ChildrenType::iterator childIter = children.begin(); childIter
!= children.end(); ++childIter)
{
(*childIter)->CreateControl(parent);
}
}
void PartSashContainer::Dispose()
{
if (parent == 0)
{
return;
}
for (ILayoutContainer::ChildrenType::iterator iter = children.begin();
iter != children.end(); ++iter)
{
// In PartSashContainer dispose really means deactivate, so we
// only dispose PartTabFolders.
if (iter->Cast() != 0)
{
(*iter)->Dispose();
}
}
this->DisposeParent();
this->parent = 0;
}
void PartSashContainer::DisposeSashes()
{
if (root != 0)
{
root->DisposeSashes();
}
}
void PartSashContainer::SetVisible(bool makeVisible)
{
if (makeVisible == this->GetVisible())
{
return;
}
//if (!SwtUtil.isDisposed(this.parent))
//{
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->SetEnabled(this->parent, makeVisible);
//}
LayoutPart::SetVisible(makeVisible);
ILayoutContainer::ChildrenType children = this->children;
for (ILayoutContainer::ChildrenType::iterator childIter = children.begin(); childIter
!= children.end(); ++childIter)
{
(*childIter)->SetVisible(makeVisible); // && (zoomedPart == null || child == zoomedPart));
}
}
LayoutPart::Pointer PartSashContainer::FindBottomRight()
{
if (root == 0)
{
return LayoutPart::Pointer(0);
}
return root->FindBottomRight();
}
Rectangle PartSashContainer::GetBounds()
{
return Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetBounds(this->parent);
}
-ILayoutContainer::ChildrenType PartSashContainer::GetChildren()
+ILayoutContainer::ChildrenType PartSashContainer::GetChildren() const
{
return children;
}
void* PartSashContainer::GetControl()
{
return this->parent;
}
LayoutTree::Pointer PartSashContainer::GetLayoutTree()
{
return root;
}
WorkbenchPage::Pointer PartSashContainer::GetPage()
{
return WorkbenchPage::Pointer(page);
}
void* PartSashContainer::GetParent()
{
return parent;
}
bool PartSashContainer::IsChild(LayoutPart::Pointer part)
{
return std::find(children.begin(), children.end(), part) != children.end();
}
void PartSashContainer::ResizeChild(LayoutPart::Pointer childThatChanged)
{
if (root != 0)
{
LayoutTree::Pointer tree = root->Find(childThatChanged);
if (tree != 0)
{
tree->FlushCache();
}
}
this->FlushLayout();
}
void PartSashContainer::Remove(LayoutPart::Pointer child)
{
// if (child == getZoomedPart())
// {
// childRequestZoomOut();
// }
if (!this->IsChild(child))
{
return;
}
children.remove(child);
if (root != 0)
{
root = root->Remove(child);
}
this->ChildRemoved(child);
if (active)
{
child->SetVisible(false);
child->SetContainer(ILayoutContainer::Pointer(0));
this->FlushLayout();
}
}
void PartSashContainer::FlushLayout()
{
layoutDirty = true;
LayoutPart::FlushLayout();
if (layoutDirty)
{
this->ResizeSashes();
}
}
void PartSashContainer::Replace(LayoutPart::Pointer oldChild,
- LayoutPart::Pointer newChild)
+ LayoutPart::Pointer newChild)
{
if (!this->IsChild(oldChild))
{
return;
}
// if (oldChild == getZoomedPart())
// {
// if (newChild.Cast ().IsNotNull())
// {
// childRequestZoomOut();
// }
// else
// {
// zoomedPart.setZoomed(false);
// zoomedPart = newChild;
// zoomedPart.setZoomed(true);
// }
// }
children.erase(std::find(children.begin(), children.end(), oldChild));
children.push_back(newChild);
this->ChildAdded(newChild);
if (root != 0)
{
LayoutTree::Pointer leaf;
leaf = root->Find(oldChild);
if (leaf != 0)
{
leaf->SetPart(newChild);
}
}
this->ChildRemoved(oldChild);
if (active)
{
oldChild->SetVisible(false);
oldChild->SetContainer(ILayoutContainer::Pointer(0));
newChild->CreateControl(parent);
newChild->SetContainer(ILayoutContainer::Pointer(this));
newChild->SetVisible(true); //zoomedPart == null || zoomedPart == newChild);
this->ResizeChild(newChild);
}
}
void PartSashContainer::ResizeSashes()
{
layoutDirty = false;
if (!active)
{
return;
}
// if (isZoomed())
// {
// getZoomedPart().setBounds(parent.getClientArea());
// }
// else
{
if (root != 0)
{
root->SetBounds(Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetClientArea(
parent));
}
}
}
int PartSashContainer::ComputePreferredSize(bool width, int availableParallel,
int availablePerpendicular, int preferredParallel)
{
// if (isZoomed())
// {
// return getZoomedPart().computePreferredSize(width, availableParallel,
// availablePerpendicular, preferredParallel);
// }
if (root != 0)
{
return root->ComputePreferredSize(width, availableParallel,
availablePerpendicular, preferredParallel);
}
return preferredParallel;
}
int PartSashContainer::GetSizeFlags(bool width)
{
// if (isZoomed())
// {
// return getZoomedPart().getSizeFlags(width);
// }
if (root != 0)
{
return root->GetSizeFlags(width);
}
return 0;
}
void PartSashContainer::SetBounds(const Rectangle& r)
{
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->SetBounds(this->parent, r);
}
IDropTarget::Pointer PartSashContainer::Drag(void* /*currentControl*/,
Object::Pointer draggedObject, const Point& position,
const Rectangle& /*dragRectangle*/)
{
if (!(draggedObject.Cast () != 0
|| draggedObject.Cast () != 0))
{
return IDropTarget::Pointer(0);
}
PartPane::Pointer sourcePart = draggedObject.Cast ();
PartStack::Pointer sourceContainer = draggedObject.Cast ();
if (sourceContainer == 0)
{
sourceContainer = sourcePart->GetStack();
}
if (!this->IsStackType(sourceContainer) && !this->IsPaneType(sourcePart))
{
return IDropTarget::Pointer(0);
}
IWorkbenchWindow::Pointer window = sourcePart ? sourcePart->GetWorkbenchWindow() : sourceContainer->GetWorkbenchWindow();
bool differentWindows = window
!= this->GetWorkbenchWindow();
bool editorDropOK = ((sourceContainer->GetAppearance()
== PresentationFactoryUtil::ROLE_EDITOR)
&& window->GetWorkbench()
== this->GetWorkbenchWindow()->GetWorkbench());
if (differentWindows && !editorDropOK)
{
return IDropTarget::Pointer(0);
}
Rectangle containerBounds = DragUtil::GetDisplayBounds(parent);
LayoutPart::Pointer targetPart;
// If this container has no visible children
if (this->GetVisibleChildrenCount(ILayoutContainer::Pointer(this)) == 0)
{
return this->CreateDropTarget(draggedObject, Constants::CENTER,
Constants::CENTER, Object::Pointer(0));
}
if (containerBounds.Contains(position))
{
if (root != 0)
{
targetPart = root->FindPart(
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->ToControl(parent, position));
}
if (targetPart != 0)
{
void* targetControl = targetPart->GetControl();
Rectangle targetBounds = DragUtil::GetDisplayBounds(targetControl);
int side = Geometry::GetClosestSide(targetBounds, position);
int distance =
Geometry::GetDistanceFromEdge(targetBounds, position, side);
// is the source coming from a standalone part
bool standalone = (this->IsStackType(sourceContainer)
&& sourceContainer->IsStandalone()) || (this->IsPaneType(sourcePart)
&& sourcePart->GetStack()->IsStandalone());
// Only allow dropping onto an existing stack from different windows
if (differentWindows && targetPart.Cast () != 0
&& targetPart.Cast ()->GetAppearance()
== PresentationFactoryUtil::ROLE_EDITOR)
{
IDropTarget::Pointer target = targetPart->GetDropTarget(draggedObject,
position);
return target;
}
// Reserve the 5 pixels around the edge of the part for the drop-on-edge cursor
if (distance >= 5 && !standalone)
{
// Otherwise, ask the part if it has any special meaning for this drop location
IDropTarget::Pointer target = targetPart->GetDropTarget(draggedObject,
position);
if (target != 0)
{
return target;
}
}
if (distance > 30 && this->IsStackType(targetPart.Cast ())
&& !standalone)
{
PartStack::Pointer targetContainer = targetPart.Cast ();
if (targetContainer->AllowsAdd(sourcePart))
{
side = Constants::CENTER;
}
}
// If the part doesn't want to override this drop location then drop on the edge
// A "pointless drop" would be one that will put the dragged object back where it started.
// Note that it should be perfectly valid to drag an object back to where it came from -- however,
// the drop should be ignored.
bool pointlessDrop = false; // = isZoomed();
if (!sourcePart && sourceContainer == targetPart)
{
pointlessDrop = true;
}
if ((sourceContainer != 0) && (sourceContainer == targetPart)
- && this->GetVisibleChildrenCount(sourceContainer.Cast()) <= 1)
+ && this->GetVisibleChildrenCount(sourceContainer.Cast()) <= 1)
{
pointlessDrop = true;
}
if (side == Constants::CENTER && sourceContainer == targetPart)
{
pointlessDrop = true;
}
int cursor = side;
if (pointlessDrop)
{
side = Constants::NONE;
cursor = Constants::CENTER;
}
if (sourcePart)
return this->CreateDropTarget(sourcePart, side, cursor, targetPart);
else
return this->CreateDropTarget(sourceContainer, side, cursor, targetPart);
}
}
else
{
// We only allow dropping into a stack, not creating one
if (differentWindows)
return IDropTarget::Pointer(0);
int side = Geometry::GetClosestSide(containerBounds, position);
bool pointlessDrop = false; // = isZoomed();
if (/*(this->IsStackType(sourceContainer) && sourceContainer == this)
||*/ (this->IsPaneType(sourcePart) && this->GetVisibleChildrenCount(
- sourceContainer.Cast()) <= 1) && sourceContainer->GetContainer() == this)
+ sourceContainer.Cast()) <= 1) && sourceContainer->GetContainer() == this)
{
if (root == 0 || this->GetVisibleChildrenCount(ILayoutContainer::Pointer(this)) <= 1)
{
pointlessDrop = true;
}
}
int cursor = Geometry::GetOppositeSide(side);
if (pointlessDrop)
{
side = Constants::NONE;
}
if (sourcePart)
return this->CreateDropTarget(sourcePart, side, cursor, Object::Pointer(0));
else
return this->CreateDropTarget(sourceContainer, side, cursor, Object::Pointer(0));
}
return IDropTarget::Pointer(0);
}
PartSashContainer::SashContainerDropTarget::Pointer
PartSashContainer::CreateDropTarget(
Object::Pointer sourcePart, int side, int cursor,
Object::Pointer targetPart)
{
if (dropTarget == 0)
{
dropTarget
= new SashContainerDropTarget(this, sourcePart, side, cursor, targetPart);
}
else
{
dropTarget->SetTarget(sourcePart, side, cursor, targetPart);
}
return dropTarget;
}
-void PartSashContainer::Stack(StackablePart::Pointer newPart,
- IStackableContainer::Pointer container)
+void PartSashContainer::Stack(LayoutPart::Pointer newPart,
+ ILayoutContainer::Pointer container)
{
//this->GetControl().setRedraw(false);
// Only deref the part if it is being referenced in -this- perspective
Perspective::Pointer persp = page->GetActivePerspective();
PerspectiveHelper* pres = (persp != 0) ? persp->GetPresentation() : 0;
if (pres != 0 && container.Cast()->GetAppearance() != PresentationFactoryUtil::ROLE_EDITOR)
{
IWorkbenchPartReference::Pointer newPartRef =
newPart.Cast ()->GetPartReference();
IViewReference::Pointer vRef = newPartRef.Cast ();
if (vRef != 0)
{
- StackablePart::Pointer fpp = pres->FindPart(vRef->GetId(),
+ LayoutPart::Pointer fpp = pres->FindPart(vRef->GetId(),
vRef->GetSecondaryId());
if (fpp != 0)
{
// Remove the part from old container.
this->DerefPart(newPart);
}
}
}
else
{
// Remove the part from old container.
this->DerefPart(newPart);
}
// Reparent part and add it to the workbook
newPart->Reparent(this->GetParent());
container->Add(newPart);
//getControl().setRedraw(true);
}
-void PartSashContainer::DerefPart(StackablePart::Pointer sourcePart)
+void PartSashContainer::DerefPart(LayoutPart::Pointer sourcePart)
{
- IStackableContainer::Pointer container = sourcePart->GetContainer();
+ ILayoutContainer::Pointer container = sourcePart->GetContainer();
if (container != 0)
{
container->Remove(sourcePart);
if (this->IsStackType(container) && container.Cast () != 0)
{
if (container->GetChildren().size() == 0)
{
LayoutPart::Pointer stack = container.Cast ();
this->Remove(stack);
stack->Dispose();
}
}
}
}
std::size_t PartSashContainer::GetVisibleChildrenCount(
- IStackableContainer::Pointer container)
+ ILayoutContainer::Pointer container)
{
// Treat null as an empty container
if (container == 0)
{
return 0;
}
- IStackableContainer::ChildrenType children = container->GetChildren();
+ ILayoutContainer::ChildrenType children = container->GetChildren();
std::size_t count = 0;
- for (IStackableContainer::ChildrenType::iterator iter = children.begin(); iter
+ for (ILayoutContainer::ChildrenType::iterator iter = children.begin(); iter
!= children.end(); ++iter)
{
if (!(*iter)->IsPlaceHolder())
{
count++;
}
}
return count;
}
-std::size_t PartSashContainer::GetVisibleChildrenCount(
- ILayoutContainer::Pointer container)
-{
- // Treat null as an empty container
- if (container == 0)
- {
- return 0;
- }
-
- return container->GetChildren().size();
-}
-
float PartSashContainer::GetDockingRatio(Object::Pointer /*dragged*/,
- IStackableContainer::Pointer /*target*/)
+ ILayoutContainer::Pointer /*target*/)
{
return 0.5f;
}
void PartSashContainer::DescribeLayout(std::string& buf) const
{
if (root == 0)
{
return;
}
// if (isZoomed())
// {
// buf.append("zoomed "); //$NON-NLS-1$
// root.describeLayout(buf);
// }
// else
{
buf.append("layout "); //$NON-NLS-1$
root->DescribeLayout(buf);
}
}
void PartSashContainer::Add(LayoutPart::Pointer child, int relationship,
int left, int right, LayoutPart::Pointer relative)
{
if (child == 0)
{
return;
}
if (relative != 0 && !this->IsChild(relative))
{
return;
}
if (relationship < IPageLayout::LEFT || relationship > IPageLayout::BOTTOM)
{
relationship = IPageLayout::LEFT;
}
// store info about relative positions
RelationshipInfo info;
info.part = child;
info.relationship = relationship;
info.left = left;
info.right = right;
info.relative = relative;
this->AddChild(info);
}
bool PartSashContainer::AllowsAutoFocus()
{
return true;
}
void PartSashContainer::StartDeferringEvents()
{
LayoutPart::StartDeferringEvents();
ILayoutContainer::ChildrenType deferredChildren = children;
for (ILayoutContainer::ChildrenType::iterator iter = deferredChildren.begin(); iter
!= deferredChildren.end(); ++iter)
{
(*iter)->DeferUpdates(true);
}
}
void PartSashContainer::HandleDeferredEvents()
{
LayoutPart::HandleDeferredEvents();
ILayoutContainer::ChildrenType deferredChildren = children;
for (ILayoutContainer::ChildrenType::iterator iter = deferredChildren.begin(); iter
!= deferredChildren.end(); ++iter)
{
(*iter)->DeferUpdates(false);
}
}
void PartSashContainer::TestInvariants()
{
LayoutPart::TestInvariants();
// If we have a parent container, ensure that we are displaying the zoomed appearance iff
// our parent is zoomed in on us
// if (this->GetContainer() != 0)
// {
// Assert.isTrue((getZoomedPart() != null) == (getContainer().childIsZoomed(
// this)));
// }
ILayoutContainer::ChildrenType childArray = this->GetChildren();
for (ILayoutContainer::ChildrenType::iterator iter = childArray.begin(); iter
!= childArray.end(); ++iter)
{
(*iter)->TestInvariants();
}
// If we're zoomed, ensure that we're actually zoomed into one of our children
// if (isZoomed())
// {
// Assert.isTrue(children.contains(zoomedPart));
// }
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartSashContainer.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartSashContainer.h
index f3ce56c941..7a09ac9ea5 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartSashContainer.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartSashContainer.h
@@ -1,703 +1,702 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYPARTSASHCONTAINER_H_
#define BERRYPARTSASHCONTAINER_H_
#include "berryLayoutPart.h"
#include "berryILayoutContainer.h"
-#include "berryIStackableContainer.h"
+#include "berryILayoutContainer.h"
#include "berryIDragOverListener.h"
#include "berryAbstractDropTarget.h"
#include "tweaklets/berryDnDTweaklet.h"
#include "berryRectangle.h"
#include "guitk/berryGuiTkIControlListener.h"
namespace berry
{
class WorkbenchPage;
class PartPane;
class LayoutTree;
class PartStack;
/**
* \ingroup org_blueberry_ui_internal
*
* Abstract container that groups various layout
* parts (possibly other containers) together as
* a unit. Manages the placement and size of these
* layout parts based on the location of sashes within
* the container.
*
* GUI specializations must override the following methods
* (read their documentation for implementation details):
*
*
* - PartSashContainer
*/
class PartSashContainer: public LayoutPart, public ILayoutContainer, public IDragOverListener {
public:
berryObjectMacro(PartSashContainer);
friend class LayoutTree;
friend class LayoutTreeNode;
friend class PageLayout;
private:
void* parentWidget;
//LayoutPart::Pointer zoomedPart;
/* Indicates if the children of a sash container should be aligned from left to right
* or the other way around. This is important if one child does
* not occupy all of the available space. Then the empty space
* is either on the left, or on the right side.
*/
bool static leftToRight;
protected:
struct ControlListener : public GuiTk::IControlListener
{
ControlListener(PartSashContainer* partSashContainer);
Events::Types GetEventTypes() const;
void ControlResized(GuiTk::ControlEvent::Pointer e);
private: PartSashContainer* partSashContainer;
};
void* parent;
GuiTk::IControlListener::Pointer resizeListener;
SmartPointer root;
WorkbenchPage* page;
bool active;
bool layoutDirty;
/* Array of LayoutPart */
ILayoutContainer::ChildrenType children;
protected:
struct RelationshipInfo
{
LayoutPart::Pointer part;
LayoutPart::Pointer relative;
int relationship;
/**
* Preferred size for the left child (this would be the size, in pixels of the child
* at the time the sash was last moved)
*/
int left;
/**
* Preferred size for the right child (this would be the size, in pixels of the child
* at the time the sash was last moved)
*/
int right;
};
private:
class SashContainerDropTarget : public AbstractDropTarget {
private:
int side;
int cursor;
- // This is a IStackablePart or IStackableContainer
+ // This is a ILayoutPart or ILayoutContainer
Object::Pointer targetPart;
- // This is a IStackablePart or IStackableContainer
+ // This is a ILayoutPart or ILayoutContainer
Object::Pointer sourcePart;
PartSashContainer* partSashContainer;
public:
berryObjectMacro(SashContainerDropTarget);
SashContainerDropTarget(PartSashContainer* partSashContainer, Object::Pointer sourcePart,
int side, int cursor, Object::Pointer targetPart);
void SetTarget(Object::Pointer sourcePart, int side, int cursor, Object::Pointer targetPart);
void Drop();
DnDTweaklet::CursorType GetCursor();
Rectangle GetSnapRectangle();
};
SashContainerDropTarget::Pointer dropTarget;
public:
/**
* Constructs a PartSashContainer with the given id under the given page
* and parentWidget.
*
* GUI specializations must hook
*/
PartSashContainer(const std::string& id, WorkbenchPage* page,
void* parentWidget);
~PartSashContainer();
/* (non-Javadoc)
* @see org.blueberry.ui.internal.ILayoutContainer#obscuredByZoom(org.blueberry.ui.internal.LayoutPart)
*/
// public: bool childObscuredByZoom(LayoutPart toTest) {
// LayoutPart zoomPart = getZoomedPart();
//
// if (zoomPart != null && toTest != zoomPart) {
// return true;
// }
// return isObscuredByZoom();
// }
/**
* Given an object associated with a drag (a PartPane or PartStack), this returns
* the actual PartPanes being dragged.
*
* @param pane
* @return
*/
private:
std::vector > GetVisibleParts(Object::Pointer pane);
/**
* Find the sashs around the specified part.
*/
public:
void FindSashes(LayoutPart::Pointer pane, PartPane::Sashes& sashes);
public:
/**
* Add a part.
*/
virtual void Add(LayoutPart::Pointer child);
- virtual void AddPart(StackablePart::Pointer child);
+ virtual void AddPart(LayoutPart::Pointer child);
/**
* Add a part relative to another. For compatibility only. New code should use
* addEnhanced, above.
*
* @param child the new part to add
* @param relationship one of PageLayout.TOP, PageLayout.BOTTOM, PageLayout.LEFT, or PageLayout.RIGHT
* @param ratio a value between 0.0 and 1.0, indicating how much space will be allocated to the UPPER-LEFT pane
* @param relative part where the new part will be attached
*/
virtual void Add(LayoutPart::Pointer child, int relationship, float ratio,
LayoutPart::Pointer relative);
protected:
virtual void DropObject(const std::vector& toDrop,
- StackablePart::Pointer visiblePart,
+ LayoutPart::Pointer visiblePart,
Object::Pointer targetPart, int side);
/**
* Add a new part relative to another. This should be used in place of
add
.
* It differs as follows:
*
* - relationships are specified using SWT direction constants
* - the ratio applies to the newly added child -- not the upper-left child
*
*
* @param child new part to add to the layout
* @param swtDirectionConstant one of SWT.TOP, SWT.BOTTOM, SWT.LEFT, or SWT.RIGHT
* @param ratioForNewPart a value between 0.0 and 1.0 specifying how much space will be allocated for the newly added part
* @param relative existing part indicating where the new child should be attached
* @since 3.0
*/
protected:
virtual void AddEnhanced(LayoutPart::Pointer child, int swtDirectionConstant,
float ratioForNewPart, LayoutPart::Pointer relative);
protected:
static int MeasureTree(const Rectangle& outerBounds,
SmartPointer toMeasure, bool horizontal);
protected:
virtual void AddChild(const RelationshipInfo& info);
/**
* Adds the child using ratio and position attributes
* from the specified placeholder without replacing
* the placeholder
*
* FIXME: I believe there is a bug in computeRelation()
* when a part is positioned relative to the editorarea.
* We end up with a null relative and 0.0 for a ratio.
*/
-protected:
+public:
virtual void AddChildForPlaceholder(LayoutPart::Pointer child,
LayoutPart::Pointer placeholder);
/**
* See ILayoutContainer#allowBorder
*/
public:
virtual bool AllowsBorder();
/**
* Notification that a child layout part has been
* added to the container. Subclasses may override
* this method to perform any container specific
* work.
*/
protected:
virtual void ChildAdded(LayoutPart::Pointer child);
/**
* Notification that a child layout part has been
* removed from the container. Subclasses may override
* this method to perform any container specific
* work.
*/
protected:
virtual void ChildRemoved(LayoutPart::Pointer child);
/**
* Returns an array with all the relation ship between the
* parts.
*/
public:
virtual std::vector ComputeRelation();
public:
virtual void SetActive(bool isActive);
/**
* @see LayoutPart#getControl
*/
public:
void CreateControl(void* parentWidget);
/**
* Subclasses override this method to specify
* the composite to use to parent all children
* layout parts it contains.
*/
protected:
virtual void* CreateParent(void* parentWidget) = 0;
/**
* @see LayoutPart#dispose
*/
public:
virtual void Dispose();
/**
* Subclasses override this method to dispose
* of any swt resources created during createParent.
*/
protected:
virtual void DisposeParent() = 0;
/**
* Dispose all sashs used in this perspective.
*/
public:
virtual void DisposeSashes();
/* (non-Javadoc)
* @see org.blueberry.ui.internal.LayoutPart#setVisible(boolean)
*/
public:
void SetVisible(bool makeVisible);
/**
* Return the most bottom right part or null if none.
*/
public:
virtual LayoutPart::Pointer FindBottomRight();
/**
* @see LayoutPart#getBounds
*/
public:
Rectangle GetBounds();
/**
* @see ILayoutContainer#getChildren
*/
public:
- ChildrenType GetChildren();
+ ChildrenType GetChildren() const;
/**
* @see LayoutPart#getControl
*/
public:
void* GetControl();
public:
virtual SmartPointer GetLayoutTree();
/**
* For themes.
*
* @return the current WorkbenchPage.
*/
public:
virtual SmartPointer GetPage();
/**
* Returns the composite used to parent all the
* layout parts contained within.
*/
public:
virtual void* GetParent();
protected:
virtual bool IsChild(LayoutPart::Pointer part);
/**
* Returns whether this container is zoomed.
*/
// public: bool IsZoomed() {
// return (zoomedPart != null);
// }
/* (non-Javadoc)
* @see org.blueberry.ui.internal.LayoutPart#forceLayout(org.blueberry.ui.internal.LayoutPart)
*/
public:
void ResizeChild(LayoutPart::Pointer childThatChanged);
/**
* Remove a part.
*/
public:
void Remove(LayoutPart::Pointer child);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.LayoutPart#forceLayout()
*/
public:
void FlushLayout();
/**
* Replace one part with another.
*/
public:
void Replace(LayoutPart::Pointer oldChild, LayoutPart::Pointer newChild);
private:
void ResizeSashes();
/**
* Returns the maximum size that can be utilized by this part if the given width and
* height are available. Parts can overload this if they have a quantized set of preferred
* sizes.
*
* @param width available horizontal space (pixels)
* @return returns a new point where point.x is <= availableWidth and point.y is <= availableHeight
*/
public:
virtual int ComputePreferredSize(bool width, int availableParallel,
int availablePerpendicular, int preferredParallel);
public:
int GetSizeFlags(bool width);
/**
* @see LayoutPart#setBounds
*/
public:
void SetBounds(const Rectangle& r);
/**
* Zoom in on a particular layout part.
*
* The implementation of zoom is quite simple. When zoom occurs we create
* a zoom root which only contains the zoom part. We store the old
* root in unzoomRoot and then active the zoom root. When unzoom occurs
* we restore the unzoomRoot and dispose the zoom root.
*
* Note: Method assumes we are active.
*/
// private: void zoomIn(LayoutPart part) {
// // Sanity check.
// if (isZoomed()) {
// return;
// }
//
// // Hide the sashes
// root.disposeSashes();
//
// // Make all parts invisible except for the zoomed part
// LayoutPart[] children = getChildren();
// for (int i = 0; i < children.length; i++) {
// LayoutPart child = children[i];
// child.setVisible(child == part);
// }
//
// zoomedPart = part;
//
// // Notify the part that it has been zoomed
// part.setZoomed(true);
//
// // Remember that we need to trigger a layout
// layoutDirty = true;
// }
/**
* Returns the currently zoomed part or null if none
*
* @return the currently zoomed part or null if none
* @since 3.1
*/
// public: LayoutPart getZoomedPart() {
// return zoomedPart;
// }
// public: void childRequestZoomIn(LayoutPart toZoom) {
// if (!SwtUtil.isDisposed(this.parent)) {
// this.parent.setRedraw(false);
// }
// try {
// zoomIn(toZoom);
//
// requestZoomIn();
//
// if (layoutDirty) {
// resizeSashes();
// }
// } finally {
// if (!SwtUtil.isDisposed(this.parent)) {
// this.parent.setRedraw(true);
// }
// }
// }
// public: void childRequestZoomOut() {
// if (!SwtUtil.isDisposed(this.parent)) {
// this.parent.setRedraw(false);
// }
// try {
// zoomOut();
//
// requestZoomOut();
//
// if (layoutDirty) {
// resizeSashes();
// }
// } finally {
// if (!SwtUtil.isDisposed(this.parent)) {
// this.parent.setRedraw(true);
// }
// }
// }
/* (non-Javadoc)
* @see org.blueberry.ui.internal.LayoutPart#setZoomed(boolean)
*/
// public: void setZoomed(boolean isZoomed) {
// if (!isZoomed) {
// zoomOut();
// } else {
// if (!isZoomed()) {
// LayoutPart toZoom = pickPartToZoom();
//
// if (toZoom != null) {
// zoomIn(toZoom);
// }
// }
// }
// super.setZoomed(isZoomed);
// }
// public: LayoutPart pickPartToZoom() {
// return findBottomRight();
// }
/**
* Zoom out.
*
* See zoomIn for implementation details.
*
* Note: Method assumes we are active.
*/
// private: void zoomOut() {
// // Sanity check.
// if (!isZoomed()) {
// return;
// }
//
// LayoutPart zoomedPart = this.zoomedPart;
// this.zoomedPart = null;
// // Inform the part that it is no longer zoomed
// zoomedPart.setZoomed(false);
//
// // Make all children visible
// LayoutPart[] children = getChildren();
// for (int i = 0; i < children.length; i++) {
// LayoutPart child = children[i];
//
// child.setVisible(true);
// }
//
// // Recreate the sashes
// root.createControl(getParent());
//
// // Ensure that the part being un-zoomed will have its size refreshed.
// LayoutTree node = root.find(zoomedPart);
// node.flushCache();
//
// layoutDirty = true;
// }
/* (non-Javadoc)
* @see org.blueberry.ui.internal.dnd.IDragOverListener#drag(org.blueberry.swt.widgets.Control, java.lang.Object, org.blueberry.swt.graphics.Point, org.blueberry.swt.graphics.Rectangle)
*/
public:
IDropTarget::Pointer Drag(void* currentControl, Object::Pointer draggedObject,
const Point& position, const Rectangle& dragRectangle);
/**
* @param sourcePart
* @param targetPart
* @param side
* @param cursor
* @return
* @since 3.1
*/
private:
SashContainerDropTarget::Pointer CreateDropTarget(Object::Pointer sourcePart, int side, int cursor, Object::Pointer targetPart);
/**
* Returns true iff this PartSashContainer allows its parts to be stacked onto the given
* container.
*
* @param container
* @return
*/
public:
- virtual bool IsStackType(IStackableContainer::Pointer toTest) = 0;
+ virtual bool IsStackType(ILayoutContainer::Pointer toTest) = 0;
public:
- virtual bool IsPaneType(StackablePart::Pointer toTest) = 0;
+ virtual bool IsPaneType(LayoutPart::Pointer toTest) = 0;
protected:
virtual SmartPointer CreateStack() = 0;
public:
- virtual void Stack(StackablePart::Pointer newPart, SmartPointer container);
+ virtual void Stack(LayoutPart::Pointer newPart, SmartPointer container);
/**
* @param container
* @param visiblePart
*/
protected:
- virtual void SetVisiblePart(IStackableContainer::Pointer container,
+ virtual void SetVisiblePart(ILayoutContainer::Pointer container,
SmartPointer visiblePart) = 0;
/**
* @param container
* @return
*/
protected:
- virtual StackablePart::Pointer GetVisiblePart(
- IStackableContainer::Pointer container) = 0;
+ virtual LayoutPart::Pointer GetVisiblePart(
+ ILayoutContainer::Pointer container) = 0;
/**
* @param sourcePart
*/
protected:
- virtual void DerefPart(StackablePart::Pointer sourcePart);
+ virtual void DerefPart(LayoutPart::Pointer sourcePart);
protected:
- virtual std::size_t GetVisibleChildrenCount(IStackableContainer::Pointer container);
virtual std::size_t GetVisibleChildrenCount(ILayoutContainer::Pointer container);
protected:
virtual float
- GetDockingRatio(Object::Pointer dragged, IStackableContainer::Pointer target);
+ GetDockingRatio(Object::Pointer dragged, ILayoutContainer::Pointer target);
/**
* Writes a description of the layout to the given string buffer.
* This is used for drag-drop test suites to determine if two layouts are the
* same. Like a hash code, the description should compare as equal iff the
* layouts are the same. However, it should be user-readable in order to
* help debug failed tests. Although these are english readable strings,
* they should not be translated or equality tests will fail.
*
* @param buf
*/
public:
void DescribeLayout(std::string& buf) const;
/**
* Adds a new child to the container relative to some part
*
* @param child
* @param relationship
* @param left preferred pixel size of the left/top child
* @param right preferred pixel size of the right/bottom child
* @param relative relative part
*/
protected:
virtual void Add(LayoutPart::Pointer child, int relationship, int left, int right,
LayoutPart::Pointer relative);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.ILayoutContainer#isZoomed(org.blueberry.ui.internal.LayoutPart)
*/
// public: bool childIsZoomed(LayoutPart toTest) {
// return toTest == getZoomedPart();
// }
/* (non-Javadoc)
* @see org.blueberry.ui.internal.ILayoutContainer#allowsAutoFocus()
*/
public:
bool AllowsAutoFocus();
/* (non-Javadoc)
* @see org.blueberry.ui.internal.LayoutPart#startDeferringEvents()
*/
protected:
void StartDeferringEvents();
/* (non-Javadoc)
* @see org.blueberry.ui.internal.LayoutPart#handleDeferredEvents()
*/
protected:
void HandleDeferredEvents();
/* (non-Javadoc)
* @see org.blueberry.ui.internal.LayoutPart#testInvariants()
*/
public:
void TestInvariants();
};
}
#endif /*BERRYPARTSASHCONTAINER_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartStack.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartStack.cpp
index 79682ce230..672cfca4ea 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartStack.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartStack.cpp
@@ -1,1607 +1,1610 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryPartStack.h"
#include "berryPerspective.h"
#include "berryPresentationFactoryUtil.h"
#include "berryWorkbenchPlugin.h"
#include "berryPresentationSerializer.h"
#include "berryDragUtil.h"
#include "berryEditorAreaHelper.h"
#include "berryPerspectiveHelper.h"
#include "berryWorkbenchConstants.h"
#include "berryXMLMemento.h"
#include "berryIWorkbenchPartConstants.h"
#include "berryGeometry.h"
#include "tweaklets/berryGuiWidgetsTweaklet.h"
#include
#include
namespace berry
{
const int PartStack::PROP_SELECTION = 0x42;
PartStack::PartStackDropResult::Pointer PartStack::dropResult(
new PartStack::PartStackDropResult());
void PartStack::PartStackDropResult::SetTarget(PartStack::Pointer stack,
PartPane::Pointer pane, StackDropResult::Pointer result)
{
this->pane = pane;
this->dropResult = result;
this->stack = stack;
}
void PartStack::PartStackDropResult::Drop()
{
// If we're dragging a pane over itself do nothing
//if (dropResult.getInsertionPoint() == pane.getPresentablePart()) { return; };
Object::Pointer cookie;
if (dropResult != 0)
{
cookie = dropResult->GetCookie();
}
PartPane::Pointer pane(this->pane);
PartStack::Pointer stack(this->stack);
// Handle cross window drops by opening a new editor
if (pane->GetPartReference().Cast () != 0)
{
IEditorReference::Pointer editorRef = pane->GetPartReference().Cast<
IEditorReference> ();
if (pane->GetWorkbenchWindow() != stack->GetWorkbenchWindow())
{
try
{
IEditorInput::Pointer input = editorRef->GetEditorInput();
// Close the old editor and capture the actual closed state incase of a 'cancel'
bool editorClosed = pane->GetPage()->CloseEditor(editorRef, true);
// Only open open the new editor if the old one closed
if (editorClosed)
stack->GetPage()->OpenEditor(input, editorRef->GetId());
return;
} catch (PartInitException& e)
{
//e.printStackTrace();
BERRY_ERROR << e.displayText();
}
}
}
if (pane->GetContainer() != stack)
{
// Moving from another stack
stack->DerefPart(pane);
pane->Reparent(stack->GetParent());
stack->Add(pane, cookie);
stack->SetSelection(pane);
pane->SetFocus();
}
else if (cookie != 0)
{
// Rearranging within this stack
stack->GetPresentation()->MovePart(stack->GetPresentablePart(pane), cookie);
}
}
DnDTweaklet::CursorType PartStack::PartStackDropResult::GetCursor()
{
return DnDTweaklet::CURSOR_CENTER;
}
Rectangle PartStack::PartStackDropResult::GetSnapRectangle()
{
if (dropResult == 0)
{
return DragUtil::GetDisplayBounds(stack.Lock()->GetControl());
}
return dropResult->GetSnapRectangle();
}
PartStack::MyStackPresentationSite::MyStackPresentationSite(PartStack* stack) :
partStack(stack)
{
}
void PartStack::MyStackPresentationSite::Close(IPresentablePart::Pointer part)
{
partStack->Close(part);
}
void PartStack::MyStackPresentationSite::Close(const std::vector<
IPresentablePart::Pointer>& parts)
{
partStack->Close(parts);
}
void PartStack::MyStackPresentationSite::DragStart(
IPresentablePart::Pointer beingDragged, Point& initialLocation,
bool keyboard)
{
partStack->DragStart(beingDragged, initialLocation, keyboard);
}
void PartStack::MyStackPresentationSite::DragStart(Point& initialLocation,
bool keyboard)
{
partStack->DragStart(IPresentablePart::Pointer(0), initialLocation, keyboard);
}
bool PartStack::MyStackPresentationSite::IsPartMoveable(
IPresentablePart::Pointer part)
{
return partStack->IsMoveable(part);
}
void PartStack::MyStackPresentationSite::SelectPart(
IPresentablePart::Pointer toSelect)
{
partStack->PresentationSelectionChanged(toSelect);
}
bool PartStack::MyStackPresentationSite::SupportsState(int state)
{
return partStack->SupportsState(state);
}
void PartStack::MyStackPresentationSite::SetState(int newState)
{
partStack->SetState(newState);
}
IPresentablePart::Pointer PartStack::MyStackPresentationSite::GetSelectedPart()
{
return partStack->GetSelectedPart();
}
// void AddSystemActions(IMenuManager menuManager) {
// PartStack.this.addSystemActions(menuManager);
// }
bool PartStack::MyStackPresentationSite::IsStackMoveable()
{
return partStack->CanMoveFolder();
}
void PartStack::MyStackPresentationSite::FlushLayout()
{
partStack->FlushLayout();
}
PartStack::PresentableVector PartStack::MyStackPresentationSite::GetPartList()
{
return partStack->GetPresentableParts();
}
std::string PartStack::MyStackPresentationSite::GetProperty(
const std::string& id)
{
return partStack->GetProperty(id);
}
PartStack::PartStack(WorkbenchPage* p, bool allowsStateChanges,
int appear, IPresentationFactory* fac) :
LayoutPart("PartStack"), page(p), isActive(true), allowStateChanges(
allowsStateChanges), appearance(appear), ignoreSelectionChanges(false),
factory(fac)
{
std::stringstream buf;
buf << "PartStack@" << this;
this->SetID(buf.str());
presentationSite = new MyStackPresentationSite(this);
}
bool PartStack::IsMoveable(IPresentablePart::Pointer part)
{
PartPane::Pointer pane = this->GetPaneFor(part);
Perspective::Pointer perspective = this->GetPage()->GetActivePerspective();
if (perspective == 0)
{
// Shouldn't happen -- can't have a ViewStack without a
// perspective
return true;
}
IWorkbenchPartReference::Pointer partRef = pane->GetPartReference();
if (partRef.Cast () != 0)
return perspective->IsMoveable(partRef.Cast ());
return true;
}
bool PartStack::SupportsState(int /*newState*/)
{
if (page->IsFixedLayout())
{
return false;
}
return allowStateChanges;
}
bool PartStack::CanMoveFolder()
{
if (appearance == PresentationFactoryUtil::ROLE_EDITOR)
return true;
Perspective::Pointer perspective = this->GetPage()->GetActivePerspective();
if (perspective == 0)
{
// Shouldn't happen -- can't have a ViewStack without a
// perspective
return false;
}
// We need to search if one of the presentations is not moveable
// if that's the case the whole folder should not be moveable
IStackPresentationSite::Pointer presenationSite;
if ((presenationSite = this->GetPresentationSite()) != 0)
{
std::list parts = presenationSite->GetPartList();
for (std::list::iterator iter = parts.begin(); iter
!= parts.end(); ++iter)
{
if (!presenationSite->IsPartMoveable(*iter))
{
return false;
}
}
}
return !perspective->IsFixedLayout();
}
-void PartStack::DerefPart(StackablePart::Pointer toDeref)
+void PartStack::DerefPart(LayoutPart::Pointer toDeref)
{
if (appearance == PresentationFactoryUtil::ROLE_EDITOR)
EditorAreaHelper::DerefPart(toDeref);
else
this->GetPage()->GetActivePerspective()->GetPresentation()->DerefPart(
toDeref);
}
bool PartStack::AllowsDrop(PartPane::Pointer part)
{
PartStack::Pointer stack = part->GetContainer().Cast ();
if (stack != 0)
{
if (stack->appearance == this->appearance)
return true;
}
return false;
}
void PartStack::AddListener(IPropertyChangeListener::Pointer listener)
{
propEvents.AddListener(listener);
}
void PartStack::RemoveListener(IPropertyChangeListener::Pointer listener)
{
propEvents.RemoveListener(listener);
}
int PartStack::GetAppearance() const
{
return appearance;
}
std::string PartStack::GetID() const
{
return LayoutPart::GetID();
}
bool PartStack::IsStandalone()
{
return (appearance == PresentationFactoryUtil::ROLE_STANDALONE || appearance
== PresentationFactoryUtil::ROLE_STANDALONE_NOTITLE);
}
IPresentablePart::Pointer PartStack::GetSelectedPart()
{
return presentationCurrent.Cast ();
}
IStackPresentationSite::Pointer PartStack::GetPresentationSite()
{
return presentationSite;
}
void PartStack::TestInvariants()
{
void* focusControl =
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetFocusControl();
bool currentFound = false;
ChildVector children = this->GetChildren();
for (ChildVector::iterator iter = children.begin(); iter != children.end(); ++iter)
{
- StackablePart::Pointer child = *iter;
+ LayoutPart::Pointer child = *iter;
// No 0 children allowed
poco_assert(child != 0)
; // "0 children are not allowed in PartStack"
// Ensure that all the PartPanes have an associated presentable part
IPresentablePart::Pointer part = this->GetPresentablePart(child);
if (!child->IsPlaceHolder())
{
poco_assert(part != 0); // "All PartPanes must have a non-0 IPresentablePart"
}
// Ensure that the child's backpointer points to this stack
- IStackableContainer::Pointer childContainer = child->GetContainer();
+ ILayoutContainer::Pointer childContainer = child->GetContainer();
// Disable tests for placeholders -- PartPlaceholder backpointers don't
// obey the usual rules -- they sometimes point to a container placeholder
// for this stack instead of the real stack.
if (!child->IsPlaceHolder())
{
// If the widgetry exists, the child's backpointer must point to us
poco_assert(childContainer.GetPointer() == this); // "PartStack has a child that thinks it has a different parent"
// If this child has focus, then ensure that it is selected and that we have
// the active appearance.
if (focusControl && Tweaklets::Get(GuiWidgetsTweaklet::KEY)->IsChild(child->GetControl(), focusControl))
{
poco_assert(child == current); // "The part with focus is not the selected part"
// focus check commented out since it fails when focus workaround in LayoutPart.setVisible is not present
// Assert.isTrue(getActive() == StackPresentation.AS_ACTIVE_FOCUS);
}
}
// Ensure that "current" points to a valid child
if (child == current)
{
currentFound = true;
}
// Test the child's internal state
child->TestInvariants();
}
// If we have at least one child, ensure that the "current" pointer points to one of them
if (this->GetPresentableParts().size()> 0)
{
poco_assert(currentFound);
StackPresentation::Pointer presentation = this->GetPresentation();
// If the presentation controls have focus, ensure that we have the active appearance
if (focusControl && Tweaklets::Get(GuiWidgetsTweaklet::KEY)->IsChild(presentation->GetControl(), focusControl))
{
poco_assert(this->GetActive() == StackPresentation::AS_ACTIVE_FOCUS);
// "The presentation has focus but does not have the active appearance"
}
}
// Check to that we're displaying the zoomed icon iff we're actually maximized
//poco_assert((this->GetState() == IStackPresentationSite::STATE_MAXIMIZED)
// == (this->GetContainer() != 0 && this->GetContainer()->ChildIsZoomed(this)));
}
void PartStack::DescribeLayout(std::string& buf) const
{
int activeState = this->GetActive();
if (activeState == StackPresentation::AS_ACTIVE_FOCUS)
{
buf.append("active "); //$NON-NLS-1$
}
else if (activeState == StackPresentation::AS_ACTIVE_NOFOCUS)
{
buf.append("active_nofocus "); //$NON-NLS-1$
}
buf.append("("); //$NON-NLS-1$
ChildVector children = this->GetChildren();
int visibleChildren = 0;
for (ChildVector::iterator iter = children.begin(); iter != children.end(); ++iter)
{
- StackablePart::Pointer next = *iter;
+ LayoutPart::Pointer next = *iter;
if (!next->IsPlaceHolder())
{
if (iter != children.begin())
{
buf.append(", "); //$NON-NLS-1$
}
if (next == requestedCurrent)
{
buf.append("*"); //$NON-NLS-1$
}
next->DescribeLayout(buf);
visibleChildren++;
}
}
buf.append(")"); //$NON-NLS-1$
}
-void PartStack::Add(StackablePart::Pointer child)
+void PartStack::Add(LayoutPart::Pointer child)
{
this->Add(child, Object::Pointer(0));
}
-void PartStack::Add(StackablePart::Pointer newChild, Object::Pointer cookie)
+void PartStack::Add(LayoutPart::Pointer newChild, Object::Pointer cookie)
{
children.push_back(newChild);
// Fix for bug 78470:
if(newChild->GetContainer().Cast() == 0)
{
- newChild->SetContainer(IStackableContainer::Pointer(this));
+ newChild->SetContainer(ILayoutContainer::Pointer(this));
}
this->ShowPart(newChild, cookie);
}
-bool PartStack::AllowsAdd(StackablePart::Pointer /*toAdd*/)
+bool PartStack::AllowsAdd(LayoutPart::Pointer /*toAdd*/)
{
return !this->IsStandalone();
}
bool PartStack::AllowsAutoFocus()
{
if (presentationSite->GetState() == IStackPresentationSite::STATE_MINIMIZED)
{
return false;
}
return LayoutPart::AllowsAutoFocus();
}
void PartStack::Close(const std::vector& parts)
{
for (unsigned int idx = 0; idx < parts.size(); idx++)
{
IPresentablePart::Pointer part = parts[idx];
this->Close(part);
}
}
void PartStack::Close(IPresentablePart::Pointer part)
{
if (!presentationSite->IsCloseable(part))
{
return;
}
PartPane::Pointer pane = this->GetPaneFor(part);
if (pane != 0)
{
pane->DoHide();
}
}
IPresentationFactory* PartStack::GetFactory()
{
if (factory != 0)
{
return factory;
}
return WorkbenchPlugin::GetDefault()->GetPresentationFactory();
}
void PartStack::CreateControl(void* parent)
{
if (this->GetPresentation() != 0)
{
return;
}
IPresentationFactory* factory = this->GetFactory();
PresentableVector partList = this->GetPresentableParts();
std::vector partVec(partList.begin(), partList.end());
PresentationSerializer serializer(partVec);
StackPresentation::Pointer presentation = PresentationFactoryUtil
::CreatePresentation(factory, appearance, parent,
presentationSite, &serializer, savedPresentationState);
this->CreateControl(parent, presentation);
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->MoveBelow(this->GetControl(), 0);
}
IDropTarget::Pointer PartStack::GetDropTarget(Object::Pointer draggedObject, const Point& position)
{
if (draggedObject.Cast() == 0)
{
return IDropTarget::Pointer(0);
}
PartPane::Pointer pane = draggedObject.Cast();
if (this->IsStandalone()
|| !this->AllowsDrop(pane))
{
return IDropTarget::Pointer(0);
}
// Don't allow views to be dragged between windows
bool differentWindows = pane->GetWorkbenchWindow() != this->GetWorkbenchWindow();
bool editorDropOK = ((pane->GetPartReference().Cast() != 0) &&
pane->GetWorkbenchWindow()->GetWorkbench() ==
this->GetWorkbenchWindow()->GetWorkbench());
if (differentWindows && !editorDropOK)
{
return IDropTarget::Pointer(0);
}
StackDropResult::Pointer dropResult = this->GetPresentation()->DragOver(
this->GetControl(), position);
if (dropResult == 0)
{
return IDropTarget::Pointer(0);
}
return this->CreateDropTarget(pane, dropResult);
}
void PartStack::SetBounds(const Rectangle& r)
{
if (this->GetPresentation() != 0)
{
this->GetPresentation()->SetBounds(r);
}
}
IDropTarget::Pointer PartStack::CreateDropTarget(PartPane::Pointer pane, StackDropResult::Pointer result)
{
dropResult->SetTarget(PartStack::Pointer(this), pane, result);
return dropResult;
}
void PartStack::SetActive(bool isActive)
{
this->isActive = isActive;
// Add all visible children to the presentation
for(ChildVector::iterator iter = children.begin(); iter != children.end(); ++iter)
{
- (*iter)->SetContainer(isActive ? IStackableContainer::Pointer(this) : IStackableContainer::Pointer(0));
+ (*iter)->SetContainer(isActive ? ILayoutContainer::Pointer(this) : ILayoutContainer::Pointer(0));
}
for (PresentableVector::iterator iter = presentableParts.begin();
iter != presentableParts.end(); ++iter)
{
PresentablePart::Pointer next = iter->Cast();
next->EnableInputs(isActive);
next->EnableOutputs(isActive);
}
}
void PartStack::CreateControl(void* /*parent*/, StackPresentation::Pointer presentation)
{
poco_assert(this->GetPresentation() == 0);
if (presentationSite->GetPresentation() != 0)
{
return;
}
presentationSite->SetPresentation(presentation);
// Add all visible children to the presentation
// Use a copy of the current set of children to avoid a ConcurrentModificationException
// if a part is added to the same stack while iterating over the children (bug 78470)
ChildVector childParts(children);
for (ChildVector::iterator iter = childParts.begin(); iter != childParts.end(); ++iter)
{
this->ShowPart(*iter, Object::Pointer(0));
}
if (savedPresentationState != 0)
{
PresentableVector partList = this->GetPresentableParts();
std::vector partVec(partList.begin(), partList.end());
PresentationSerializer serializer(partVec);
presentation->RestoreState(&serializer, savedPresentationState);
}
//void* ctrl = this->GetPresentation()->GetControl();
//TODO control setData ?
//ctrl.setData(this);
// We should not have a placeholder selected once we've created the widgetry
if (requestedCurrent != 0 && requestedCurrent->IsPlaceHolder())
{
requestedCurrent = 0;
this->UpdateContainerVisibleTab();
}
this->RefreshPresentationSelection();
}
void PartStack::SavePresentationState()
{
if (this->GetPresentation() == 0)
{
return;
}
{// Save the presentation's state before disposing it
XMLMemento::Pointer memento = XMLMemento
::CreateWriteRoot(WorkbenchConstants::TAG_PRESENTATION);
memento->PutString(WorkbenchConstants::TAG_ID, this->GetFactory()->GetId());
std::list parts(this->GetPresentableParts());
PresentationSerializer serializer(std::vector(parts.begin(), parts.end()));
this->GetPresentation()->SaveState(&serializer, memento);
// Store the memento in savedPresentationState
savedPresentationState = memento;
}
}
PartStack::~PartStack()
{
//BERRY_INFO << "DELETING PARTSTACK";
}
void PartStack::Dispose()
{
if (this->GetPresentation() == 0)
{
return;
}
this->SavePresentationState();
// for (PresentableVector::iterator iter = presentableParts.begin();
// iter != presentableParts.end(); ++iter)
// {
// iter->Cast()->Dispose();
// }
presentableParts.clear();
presentationCurrent = 0;
current = 0;
this->FireInternalPropertyChange(PROP_SELECTION);
}
-void PartStack::FindSashes(PartPane::Sashes& sashes)
+void PartStack::FindSashes(LayoutPart::Pointer /*toFind*/, PartPane::Sashes& sashes)
{
ILayoutContainer::Pointer container = this->GetContainer();
if (container != 0)
{
container->FindSashes(LayoutPart::Pointer(this), sashes);
}
}
Rectangle PartStack::GetBounds()
{
if (this->GetPresentation() == 0)
{
return Rectangle(0, 0, 0, 0);
}
return Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetBounds(this->GetPresentation()->GetControl());
}
-std::list PartStack::GetChildren() const
+std::list PartStack::GetChildren() const
{
return children;
}
void* PartStack::GetControl()
{
StackPresentation::Pointer presentation = this->GetPresentation();
if (presentation == 0)
{
return 0;
}
return presentation->GetControl();
}
/**
* Answer the number of children.
*/
PartStack::ChildVector::size_type PartStack::GetItemCount()
{
if (this->GetPresentation() == 0)
{
return children.size();
}
return this->GetPresentableParts().size();
}
PartPane::Pointer PartStack::GetPaneFor(IPresentablePart::Pointer part)
{
if (part == 0 || part.Cast() == 0)
{
return PartPane::Pointer(0);
}
return part.Cast()->GetPane();
}
void* PartStack::GetParent()
{
return Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetParent(this->GetControl());
}
PartStack::PresentableVector PartStack::GetPresentableParts()
{
return presentableParts;
}
-PresentablePart::Pointer PartStack::GetPresentablePart(StackablePart::Pointer pane)
+PresentablePart::Pointer PartStack::GetPresentablePart(LayoutPart::Pointer pane)
{
for (PresentableVector::iterator iter = presentableParts.begin(); iter != presentableParts.end(); ++iter)
{
PresentablePart::Pointer part = iter->Cast();
if (part->GetPane() == pane)
{
return part;
}
}
return PresentablePart::Pointer(0);
}
StackPresentation::Pointer PartStack::GetPresentation()
{
return presentationSite->GetPresentation();
}
-StackablePart::Pointer PartStack::GetSelection()
+PartPane::Pointer PartStack::GetSelection()
{
- return current;
+ if (PartPane::Pointer partPane = current.Cast())
+ {
+ return partPane;
+ }
+ return PartPane::Pointer(0);
}
void PartStack::PresentationSelectionChanged(IPresentablePart::Pointer newSelection)
{
// Ignore selection changes that occur as a result of removing a part
if (ignoreSelectionChanges)
{
return;
}
PartPane::Pointer newPart = this->GetPaneFor(newSelection);
// This method should only be called on objects that are already in the layout
poco_assert(newPart != 0);
if (newPart == requestedCurrent)
{
return;
}
this->SetSelection(newPart);
if (newPart != 0)
{
newPart->SetFocus();
}
}
-void PartStack::Remove(StackablePart::Pointer child)
+void PartStack::Remove(LayoutPart::Pointer child)
{
IPresentablePart::Pointer presentablePart = this->GetPresentablePart(child);
// Need to remove it from the list of children before notifying the presentation
// since it may setVisible(false) on the part, leading to a partHidden notification,
// during which findView must not find the view being removed. See bug 60039.
children.remove(child);
StackPresentation::Pointer presentation = this->GetPresentation();
if (presentablePart != 0 && presentation != 0)
{
ignoreSelectionChanges = true;
presentableParts.remove(presentablePart);
presentation->RemovePart(presentablePart);
presentablePart = 0;
ignoreSelectionChanges = false;
}
if (this->GetPresentation() != 0)
{
- child->SetContainer(IStackableContainer::Pointer(0));
+ child->SetContainer(ILayoutContainer::Pointer(0));
}
if (child == requestedCurrent)
{
this->UpdateContainerVisibleTab();
}
}
void PartStack::Reparent(void* newParent)
{
void* control = this->GetControl();
GuiWidgetsTweaklet* tweaklet = Tweaklets::Get(GuiWidgetsTweaklet::KEY);
if ((control == 0) || (tweaklet->GetParent(control) == newParent)
|| !tweaklet->IsReparentable(control))
{
return;
}
LayoutPart::Reparent(newParent);
for(ChildVector::iterator iter = children.begin();
iter != children.end(); ++iter)
{
(*iter)->Reparent(newParent);
}
}
-void PartStack::Replace(StackablePart::Pointer oldChild, StackablePart::Pointer newChild)
+void PartStack::Replace(LayoutPart::Pointer oldChild, LayoutPart::Pointer newChild)
{
ChildVector::iterator loc = std::find(children.begin(), children.end(), oldChild);
int idx = 0;
int numPlaceholders = 0;
//subtract the number of placeholders still existing in the list
//before this one - they wont have parts.
for (ChildVector::iterator iter = children.begin(); iter != loc; ++iter, ++idx)
{
if ((*iter)->IsPlaceHolder())
{
numPlaceholders++;
}
}
ObjectInt::Pointer cookie(new ObjectInt(idx - numPlaceholders));
children.insert(loc, newChild);
this->ShowPart(newChild, cookie);
if (oldChild == requestedCurrent && newChild.Cast() != 0)
{
this->SetSelection(newChild.Cast());
}
this->Remove(oldChild);
}
int PartStack::ComputePreferredSize(bool width, int availableParallel,
int availablePerpendicular, int preferredParallel)
{
return this->GetPresentation()->ComputePreferredSize(width, availableParallel,
availablePerpendicular, preferredParallel);
}
int PartStack::GetSizeFlags(bool horizontal)
{
StackPresentation::Pointer presentation = this->GetPresentation();
if (presentation != 0)
{
return presentation->GetSizeFlags(horizontal);
}
return 0;
}
bool PartStack::RestoreState(IMemento::Pointer memento)
{
// Read the active tab.
std::string activeTabID; memento->GetString(WorkbenchConstants::TAG_ACTIVE_PAGE_ID, activeTabID);
// Read the page elements.
std::vector children = memento->GetChildren(WorkbenchConstants::TAG_PAGE);
// Loop through the page elements.
for (std::size_t i = 0; i < children.size(); i++)
{
// Get the info details.
IMemento::Pointer childMem = children[i];
std::string partID; childMem->GetString(WorkbenchConstants::TAG_CONTENT, partID);
// Create the part.
- StackablePart::Pointer part(new PartPlaceholder(partID));
- part->SetContainer(IStackableContainer::Pointer(this));
+ LayoutPart::Pointer part(new PartPlaceholder(partID));
+ part->SetContainer(ILayoutContainer::Pointer(this));
this->Add(part);
//1FUN70C: ITPUI:WIN - Shouldn't set Container when not active
//part.setContainer(this);
if (partID == activeTabID)
{
this->SetSelection(part);
// Mark this as the active part.
//current = part;
}
}
//IPreferenceStore preferenceStore = PrefUtil.getAPIPreferenceStore();
//boolean useNewMinMax = preferenceStore.getBoolean(IWorkbenchPreferenceConstants.ENABLE_NEW_MIN_MAX);
int expanded;
if (memento->GetInteger(WorkbenchConstants::TAG_EXPANDED, expanded))
{
//StartupThreading.runWithoutExceptions(new StartupRunnable()
// {
// void runWithException() throws Throwable
// {
SetState(expanded != IStackPresentationSite::STATE_MINIMIZED ? IStackPresentationSite::STATE_RESTORED
: IStackPresentationSite::STATE_MINIMIZED);
// }
// });
}
else
{
SetState(IStackPresentationSite::STATE_RESTORED);
}
int appearance;
if (memento->GetInteger(WorkbenchConstants::TAG_APPEARANCE, appearance))
{
this->appearance = appearance;
}
// Determine if the presentation has saved any info here
savedPresentationState = 0;
std::vector presentationMementos(memento
->GetChildren(WorkbenchConstants::TAG_PRESENTATION));
for (std::size_t idx = 0; idx < presentationMementos.size(); idx++)
{
IMemento::Pointer child = presentationMementos[idx];
std::string id; child->GetString(WorkbenchConstants::TAG_ID, id);
if (id == GetFactory()->GetId())
{
savedPresentationState = child;
break;
}
}
IMemento::Pointer propertiesState = memento->GetChild(WorkbenchConstants::TAG_PROPERTIES);
if (propertiesState)
{
std::vector props(propertiesState->GetChildren(WorkbenchConstants::TAG_PROPERTY));
for (std::size_t i = 0; i < props.size(); i++)
{
std::string id = props[i]->GetID();
properties.insert(std::make_pair(id, props[i]->GetTextData()));
}
}
//return new Status(IStatus.OK, PlatformUI.PLUGIN_ID, 0, "", 0); //$NON-NLS-1$
return true;
}
void PartStack::SetVisible(bool makeVisible)
{
void* ctrl = this->GetControl();
bool useShortcut = makeVisible || !isActive;
if (ctrl != 0 && useShortcut)
{
if (makeVisible == Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetVisible(ctrl))
{
return;
}
}
if (makeVisible)
{
for (PresentableVector::iterator iter = presentableParts.begin();
iter != presentableParts.end(); ++iter)
{
PresentablePart::Pointer next = iter->Cast();
next->EnableInputs(isActive);
next->EnableOutputs(isActive);
}
}
LayoutPart::SetVisible(makeVisible);
StackPresentation::Pointer presentation = this->GetPresentation();
if (presentation != 0)
{
presentation->SetVisible(makeVisible);
}
if (!makeVisible)
{
for (PresentableVector::iterator iter = presentableParts.begin();
iter != presentableParts.end(); ++iter)
{
PresentablePart::Pointer next = iter->Cast();
next->EnableInputs(false);
}
}
}
bool PartStack::SaveState(IMemento::Pointer memento)
{
if (GetAppearance() != PresentationFactoryUtil::ROLE_EDITOR)
{
// Save the active tab.
if (requestedCurrent)
{
- memento->PutString(WorkbenchConstants::TAG_ACTIVE_PAGE_ID, requestedCurrent
- ->GetCompoundId());
+ memento->PutString(WorkbenchConstants::TAG_ACTIVE_PAGE_ID, requestedCurrent->GetID());
}
// Write out the presentable parts (in order)
Poco::HashSet cachedIds;
PartStack::PresentableVector pparts(GetPresentableParts());
for (PartStack::PresentableVector::iterator ppIter = pparts.begin();
ppIter != pparts.end(); ++ppIter)
{
PresentablePart::Pointer presPart = ppIter->Cast();
IMemento::Pointer childMem = memento->CreateChild(WorkbenchConstants::TAG_PAGE);
PartPane::Pointer part = presPart->GetPane();
std::string tabText = part->GetPartReference()->GetPartName();
childMem->PutString(WorkbenchConstants::TAG_LABEL, tabText);
childMem->PutString(WorkbenchConstants::TAG_CONTENT, presPart->GetPane()->GetPlaceHolderId());
// Cache the id so we don't write it out later
cachedIds.insert(presPart->GetPane()->GetPlaceHolderId());
}
for (ChildVector::iterator iter = children.begin();
iter != children.end(); ++iter)
{
- StackablePart::Pointer next = *iter;
+ LayoutPart::Pointer next = *iter;
PartPane::Pointer part;
if (part = next.Cast())
{
// Have we already written it out?
if (cachedIds.find(part->GetPlaceHolderId()) != cachedIds.end())
continue;
}
IMemento::Pointer childMem = memento
->CreateChild(WorkbenchConstants::TAG_PAGE);
std::string tabText = "LabelNotFound";
if (part)
{
tabText = part->GetPartReference()->GetPartName();
}
childMem->PutString(WorkbenchConstants::TAG_LABEL, tabText);
- childMem->PutString(WorkbenchConstants::TAG_CONTENT, next->GetId());
+ childMem->PutString(WorkbenchConstants::TAG_CONTENT, next->GetID());
}
}
// IPreferenceStore preferenceStore = PrefUtil.getAPIPreferenceStore();
// boolean useNewMinMax = preferenceStore.getBoolean(IWorkbenchPreferenceConstants.ENABLE_NEW_MIN_MAX);
// if (useNewMinMax)
// {
memento->PutInteger(WorkbenchConstants::TAG_EXPANDED, presentationSite->GetState());
// }
// else
// {
// memento
// .putInteger(
// IWorkbenchConstants.TAG_EXPANDED,
// (presentationSite.getState() == IStackPresentationSite.STATE_MINIMIZED) ? IStackPresentationSite.STATE_MINIMIZED
// : IStackPresentationSite.STATE_RESTORED);
// }
memento->PutInteger(WorkbenchConstants::TAG_APPEARANCE, appearance);
this->SavePresentationState();
if (savedPresentationState)
{
IMemento::Pointer presentationState = memento
->CreateChild(WorkbenchConstants::TAG_PRESENTATION);
presentationState->PutMemento(savedPresentationState);
}
if (!properties.empty())
{
IMemento::Pointer propertiesState = memento->CreateChild(WorkbenchConstants::TAG_PROPERTIES);
for (std::map::iterator iterator = properties.begin();
iterator != properties.end(); ++iterator)
{
if (iterator->second.empty()) continue;
IMemento::Pointer prop = propertiesState->CreateChild(WorkbenchConstants::TAG_PROPERTY, iterator->first);
prop->PutTextData(iterator->second);
}
}
//return new Status(IStatus.OK, PlatformUI.PLUGIN_ID, 0, "", 0);
return true;
}
WorkbenchPage::Pointer PartStack::GetPage()
{
// WorkbenchWindow::Pointer window = this->GetWorkbenchWindow().Cast();
//
// if (window == 0)
// {
// return 0;
// }
//
// return window->GetActivePage().Cast();
return WorkbenchPage::Pointer(page);
}
void PartStack::SetActive(int activeState)
{
// if (activeState == StackPresentation::AS_ACTIVE_FOCUS && isMinimized)
// {
// setMinimized(false);
// }
presentationSite->SetActive(activeState);
}
int PartStack::GetActive() const
{
return presentationSite->GetActive();
}
-void PartStack::SetSelection(StackablePart::Pointer part)
+void PartStack::SetSelection(LayoutPart::Pointer part)
{
if (part == requestedCurrent)
{
return;
}
requestedCurrent = part;
this->RefreshPresentationSelection();
}
void PartStack::UpdateActions(PresentablePart::Pointer /*current*/)
{
}
void PartStack::HandleDeferredEvents()
{
LayoutPart::HandleDeferredEvents();
this->RefreshPresentationSelection();
}
void PartStack::RefreshPresentationSelection()
{
// If deferring UI updates, exit.
if (this->IsDeferred())
{
return;
}
// If the presentation is already displaying the desired part, then there's nothing
// to do.
if (current == requestedCurrent)
{
return;
}
StackPresentation::Pointer presentation = this->GetPresentation();
if (presentation != 0)
{
presentationCurrent = this->GetPresentablePart(requestedCurrent);
// this->UupdateActions(presentationCurrent);
if (presentationCurrent != 0 && presentation != 0)
{
requestedCurrent->CreateControl(this->GetParent());
GuiWidgetsTweaklet* tweaklet = Tweaklets::Get(GuiWidgetsTweaklet::KEY);
if (tweaklet->GetParent(requestedCurrent->GetControl()) !=
tweaklet->GetParent(this->GetControl()))
{
requestedCurrent->Reparent(tweaklet->GetParent(this->GetControl()));
}
presentation->SelectPart(presentationCurrent);
}
// Update the return value of getVisiblePart
current = requestedCurrent;
this->FireInternalPropertyChange(PROP_SELECTION);
}
}
int PartStack::GetState()
{
return presentationSite->GetState();
}
void PartStack::SetState(const int newState)
{
int oldState = presentationSite->GetState();
if (!this->SupportsState(newState) || newState == oldState)
{
return;
}
// WorkbenchWindow::Pointer wbw = this->GetPage()->GetWorkbenchWindow().Cast();
// if (wbw == 0 || wbw->GetShell() == 0 || wbw->GetActivePage() == 0)
// return;
//
// WorkbenchPage::Pointer page = wbw->GetActivePage();
//
// bool useNewMinMax = Perspective::UseNewMinMax(page->GetActivePerspective());
//
// // we have to fiddle with the zoom behavior to satisfy Intro req's
// // by usning the old zoom behavior for its stack
// if (newState == IStackPresentationSite::STATE_MAXIMIZED)
// useNewMinMax = useNewMinMax; // && !this->IsIntroInStack();
// else if (newState == IStackPresentationSite::STATE_RESTORED)
// {
// PartStack::Pointer maxStack = page->GetActivePerspective()->GetPresentation()->GetMaximizedStack();
// useNewMinMax = useNewMinMax && maxStack == this;
// }
//
// if (useNewMinMax)
// {
// //StartupThreading.runWithoutExceptions(new StartupRunnable()
// // {
// // void runWithException() throws Throwable
// // {
// wbw->GetPageComposite()->SetRedraw(false);
// try
// {
// if (newState == IStackPresentationSite::STATE_MAXIMIZED)
// {
// smartZoom();
// }
// else if (oldState == IStackPresentationSite::STATE_MAXIMIZED)
// {
// smartUnzoom();
// }
//
// if (newState == IStackPresentationSite::STATE_MINIMIZED)
// {
// setMinimized(true);
// }
//
// wbw.getPageComposite().setRedraw(true);
//
// // Force a redraw (fixes Mac refresh)
// wbw.getShell().redraw();
//
// }
// catch (...)
// {
// wbw.getPageComposite().setRedraw(true);
//
// // Force a redraw (fixes Mac refresh)
// wbw.getShell().redraw();
// }
//
// this->SetPresentationState(newState);
// // }
// // });
// }
// else
// {
//// bool minimized = (newState == IStackPresentationSite::STATE_MINIMIZED);
//// this->SetMinimized(minimized);
////
//// if (newState == IStackPresentationSite::STATE_MAXIMIZED)
//// {
//// requestZoomIn();
//// }
//// else if (oldState == IStackPresentationSite::STATE_MAXIMIZED)
//// {
//// requestZoomOut();
////
//// if (newState == IStackPresentationSite::STATE_MINIMIZED)
//// setMinimized(true);
//// }
// }
}
-void PartStack::ShowPart(StackablePart::Pointer part, Object::Pointer cookie)
+void PartStack::ShowPart(LayoutPart::Pointer part, Object::Pointer cookie)
{
if (this->GetPresentation() == 0)
{
return;
}
if (part->IsPlaceHolder())
{
- part->SetContainer(IStackableContainer::Pointer(this));
+ part->SetContainer(ILayoutContainer::Pointer(this));
return;
}
if (part.Cast() == 0)
{
- WorkbenchPlugin::Log("Incorrect part " + part->GetId() + "contained in a part stack");
+ WorkbenchPlugin::Log("Incorrect part " + part->GetID() + "contained in a part stack");
return;
}
PartPane::Pointer pane = part.Cast();
PresentablePart::Pointer presentablePart(new PresentablePart(pane, Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetParent(this->GetControl())));
presentableParts.push_back(presentablePart);
if (isActive)
{
- part->SetContainer(IStackableContainer::Pointer(this));
+ part->SetContainer(ILayoutContainer::Pointer(this));
// The active part should always be enabled
if (part->GetControl() != 0)
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->SetEnabled(part->GetControl(), true);
}
presentationSite->GetPresentation()->AddPart(presentablePart, cookie);
if (requestedCurrent == 0)
{
this->SetSelection(pane);
}
// if (childObscuredByZoom(part))
// {
// presentablePart.enableInputs(false);
// }
}
void PartStack::UpdateContainerVisibleTab()
{
ChildVector parts = this->GetChildren();
if (parts.size() < 1)
{
- this->SetSelection(StackablePart::Pointer(0));
+ this->SetSelection(LayoutPart::Pointer(0));
return;
}
PartPane::Pointer selPart;
int topIndex = 0;
WorkbenchPage::Pointer page = this->GetPage();
if (page != 0)
{
std::vector sortedParts = page->GetSortedParts();
for (ChildVector::iterator partIter = parts.begin();
partIter != parts.end(); ++partIter)
{
if (partIter->Cast() != 0)
{
IWorkbenchPartReference::Pointer part = partIter->Cast()
->GetPartReference();
int index = static_cast(std::find(sortedParts.begin(), sortedParts.end(), part) - sortedParts.begin());
if (index >= topIndex)
{
topIndex = index;
selPart = partIter->Cast();
}
}
}
}
if (selPart == 0)
{
PresentableVector presentableParts = this->GetPresentableParts();
if (presentableParts.size() != 0)
{
IPresentablePart::Pointer part = presentableParts.front();
selPart = this->GetPaneFor(part);
}
}
this->SetSelection(selPart);
}
void PartStack::ShowSystemMenu()
{
//this->GetPresentation()->ShowSystemMenu();
}
void PartStack::ShowPaneMenu()
{
//this->GetPresentation()->ShowPaneMenu();
}
void PartStack::ShowPartList()
{
this->GetPresentation()->ShowPartList();
}
-std::vector PartStack::GetTabList(StackablePart::Pointer part)
+std::vector PartStack::GetTabList(LayoutPart::Pointer part)
{
if (part != 0)
{
IPresentablePart::Pointer presentablePart = this->GetPresentablePart(part);
StackPresentation::Pointer presentation = this->GetPresentation();
if (presentablePart != 0 && presentation != 0)
{
return presentation->GetTabList(presentablePart);
}
}
return std::vector();
}
void PartStack::DragStart(IPresentablePart::Pointer beingDragged, Point& initialLocation,
bool keyboard)
{
if (beingDragged == 0)
{
this->PaneDragStart(PartPane::Pointer(0), initialLocation, keyboard);
}
else
{
if (presentationSite->IsPartMoveable(beingDragged))
{
PartPane::Pointer pane = this->GetPaneFor(beingDragged);
if (pane != 0)
{
this->PaneDragStart(pane, initialLocation, keyboard);
}
}
}
}
void PartStack::PaneDragStart(PartPane::Pointer pane, Point& initialLocation,
bool keyboard)
{
if (pane == 0)
{
if (this->CanMoveFolder())
{
if (presentationSite->GetState() == IStackPresentationSite::STATE_MAXIMIZED)
{
// Calculate where the initial location was BEFORE the 'restore'...as a percentage
Rectangle bounds = Geometry::ToDisplay(this->GetParent(),
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetBounds(this->GetPresentation()->GetControl()));
float xpct = (initialLocation.x - bounds.x) / (float)(bounds.width);
float ypct = (initialLocation.y - bounds.y) / (float)(bounds.height);
// Only restore if we're dragging views/view stacks
if (this->GetAppearance() != PresentationFactoryUtil::ROLE_EDITOR)
this->SetState(IStackPresentationSite::STATE_RESTORED);
// Now, adjust the initial location to be within the bounds of the restored rect
bounds = Geometry::ToDisplay(this->GetParent(),
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetBounds(this->GetPresentation()->GetControl()));
initialLocation.x = (int) (bounds.x + (xpct * bounds.width));
initialLocation.y = (int) (bounds.y + (ypct * bounds.height));
}
DragUtil::PerformDrag(Object::Pointer(this), Geometry::ToDisplay(this->GetParent(),
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetBounds(this->GetPresentation()->GetControl())),
initialLocation, !keyboard);
}
}
else
{
if (presentationSite->GetState() == IStackPresentationSite::STATE_MAXIMIZED)
{
// Calculate where the initial location was BEFORE the 'restore'...as a percentage
Rectangle bounds = Geometry::ToDisplay(this->GetParent(),
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetBounds(this->GetPresentation()->GetControl()));
float xpct = (initialLocation.x - bounds.x) / (float)(bounds.width);
float ypct = (initialLocation.y - bounds.y) / (float)(bounds.height);
// Only restore if we're dragging views/view stacks
if (this->GetAppearance() != PresentationFactoryUtil::ROLE_EDITOR)
this->SetState(IStackPresentationSite::STATE_RESTORED);
// Now, adjust the initial location to be within the bounds of the restored rect
// See bug 100908
bounds = Geometry::ToDisplay(this->GetParent(),
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetBounds(this->GetPresentation()->GetControl()));
initialLocation.x = (int) (bounds.x + (xpct * bounds.width));
initialLocation.y = (int) (bounds.y + (ypct * bounds.height));
}
DragUtil::PerformDrag(pane, Geometry::ToDisplay(this->GetParent(),
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetBounds(this->GetPresentation()->GetControl())),
initialLocation, !keyboard);
}
}
IMemento::Pointer PartStack::GetSavedPresentationState()
{
return savedPresentationState;
}
void PartStack::FireInternalPropertyChange(int id)
{
ObjectInt::Pointer val(new ObjectInt(id));
Object::Pointer source(this);
PropertyChangeEvent::Pointer event(new PropertyChangeEvent(source,
IWorkbenchPartConstants::INTEGER_PROPERTY, val, val));
propEvents.propertyChange(event);
}
std::string PartStack::GetProperty(const std::string& id)
{
return properties[id];
}
void PartStack::SetProperty(const std::string& id, const std::string& value)
{
if (value == "")
{
properties.erase(id);
}
else
{
properties.insert(std::make_pair(id, value));
}
}
void PartStack::CopyAppearanceProperties(PartStack::Pointer copyTo)
{
copyTo->appearance = this->appearance;
if (!properties.empty())
{
for (std::map::iterator iter = properties.begin();
iter != properties.end(); ++iter)
{
copyTo->SetProperty(iter->first, iter->second);
}
}
}
-void PartStack::ResizeChild(StackablePart::Pointer /*childThatChanged*/)
+void PartStack::ResizeChild(LayoutPart::Pointer /*childThatChanged*/)
{
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartStack.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartStack.h
index 5683ffbc8b..5c46551ba1 100644
--- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartStack.h
+++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPartStack.h
@@ -1,762 +1,762 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYPARTSTACK_H_
#define BERRYPARTSTACK_H_
#include "berryLayoutPart.h"
-#include "berryIStackableContainer.h"
+#include "berryILayoutContainer.h"
#include "berryWorkbenchPage.h"
#include "berryPresentablePart.h"
#include "berryPartPlaceholder.h"
#include "berryDefaultStackPresentationSite.h"
#include "berryPresentationFactoryUtil.h"
#include "berryAbstractDropTarget.h"
#include "berryPartPane.h"
#include "berryIMemento.h"
#include "presentations/berryIPresentationFactory.h"
#include
#include
#include