Hi Joe,

the code you are using uses a lot of BlueBerry internal classes. All the classes you mention in point 1) are *not* part of the BlueBerry API and their implementation could change anytime (and break your code). We cannot support the usage of internal classes - if you have to include a header file starting with "internal/..." you should think twice if you can achieve your goals in another way. Additionally, this approach only works on Linux, since internal class symbols are not exported on Windows (you would get linker errors).

Please post more details about the problem you are trying to solve, so we might be able to figure out a "supported" way of doing it.


Best,
Sascha

P.S.: If you really want to rely on internal classes, try using workbenchPage->GetActiveEditor(); instead of workbenchPage->GetActivePart(); in the second line of your method. The result of "GetActivePart" could be a view *or* editor. If it is a view, it is contained in a ViewSashContainer. The EditorSashContainer contains the editor parts, but is itself contained in the "root" ViewSashContainer (which you probably got).


On 04/01/2011 08:21 PM, Joe wrote:

Hi Mitk Users,

I found some code that does exactly what I needed - in order to split the editors on different Part Stacks after I add a new editor. Part of the problem is that the code I found is from Eclipse and is written in Java.

I was able to convert this code to run in MITK, however, the behavior is not correct as I expected (this was probably due to guessing code substitutions).

1) In order to use this code correctly I need to understand the relations between:

WorkbenchPage, WorkbenchPart, WorkbenchPartSite, PartPane, LayoutPart, LayoutContainer, EditorSashContainer, and PartStack

Please send any documentation showing how to access the EditorSashContainer moving through the other classes.

2) Here is the Eclipse Java code:

/**

 * Split the editor area if there is at least two editors in it.

 */

private void splitEditorArea() {

IWorkbenchPage workbenchPage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();

            IWorkbenchPart part = workbenchPage.getActivePart();

            PartPane partPane = ((PartSite) part.getSite()).getPane();

*            LayoutPart layoutPart = partPane.getPart();*

IEditorReference[] editorReferences = workbenchPage.getEditorReferences();

            // Do it only if we have more that one editor

            if (editorReferences.length > 1) {

// Get PartPane that correspond to the active editor

PartPane currentEditorPartPane = ((PartSite) workbenchPage.getActiveEditor().getSite()).getPane();

                        EditorSashContainer editorSashContainer = null;

ILayoutContainer rootLayoutContainer = layoutPart.getContainer();

                        if (rootLayoutContainer instanceof LayoutPart) {

ILayoutContainer cont = ((LayoutPart) rootLayoutContainer).getContainer();

if (cont instanceof EditorSashContainer) {

editorSashContainer = ((EditorSashContainer) cont);

                                    }

                        }

                        /*

* Create a new part stack (i.e. a workbook) to home the

* currentEditorPartPane which hold the active editor

                         */

PartStack newPart = createStack(editorSashContainer);

editorSashContainer.stack(currentEditorPartPane, newPart);

                        if (rootLayoutContainer instanceof LayoutPart) {

ILayoutContainer cont = ((LayoutPart) rootLayoutContainer).getContainer();

if (cont instanceof PartSashContainer) {

// "Split" the editor area by adding the new part

((PartSashContainer) cont).add(newPart);

                                    }

                        }

            }

}

3) Here is my converted code that compiles and runs:

void FusionFileOpenAction::splitEditorArea()

{

berry::IWorkbenchPage::Pointer workbenchPage = m_Window->GetActivePage();

berry::IWorkbenchPart::Pointer part = workbenchPage->GetActivePart();

            berry::IWorkbenchPartSite::Pointer partSite = part->GetSite();

berry::PartPane::Pointer partPane = partSite.Cast<berry::PartSite>()->GetPane();

* berry::LayoutPart::Pointer layoutPart = partPane->GetContainer().Cast<berry::LayoutPart>();*

std::list<berry::IEditorReference::Pointer> editorReferences = workbenchPage->GetEditorReferences();

            // Do it only if we have more that one editor

            if ( editorReferences.size() > 1 )

            {

// Get PartPane that correspond to the active editor

partSite = workbenchPage->GetActiveEditor()->GetSite();

berry::PartPane::Pointer currentEditorPartPane = partSite.Cast<berry::PartSite>()->GetPane();

berry::EditorSashContainer::Pointer editorSashContainer;

berry::ILayoutContainer::Pointer rootLayoutContainer = layoutPart->GetContainer();

if ( rootLayoutContainer.Cast<berry::LayoutPart>().IsNotNull() )

                        {

berry::ILayoutContainer::Pointer cont = rootLayoutContainer.Cast<berry::LayoutPart>()->GetContainer();

* if ( cont.Cast<berry::EditorSashContainer>().IsNotNull() ) // ViewSashContainer?*

                                    {

editorSashContainer = cont.Cast<berry::EditorSashContainer>();

                                    }

                        }

                        /*

* Create a new part stack (i.e. a workbook) to home the

* currentEditorPartPane which hold the active editor

                         */

berry::PartStack::Pointer newPart = editorSashContainer->CreateStack();

editorSashContainer->Stack(currentEditorPartPane, newPart);

if ( rootLayoutContainer.Cast<berry::LayoutPart>().IsNotNull() )

                        {

berry::ILayoutContainer::Pointer cont = rootLayoutContainer.Cast<berry::LayoutPart>()->GetContainer();

if ( cont.Cast<berry::PartSashContainer>().IsNotNull() )

                                    {

// "Split" the editor area by adding the new part

cont.Cast<berry::PartSashContainer>()->Add(newPart);

                                    }

                        }

            }

}

5) In order to make the code compile, I had to change a getPart() to GetContainer() (see first 2 bolded lines). The problem actually occurs in the 3^rd bolded line. Instead of acquiring an object of type EditorSashContainer, I end up with an object of ViewSashContainer.

Please help provide general information as well as specific solutions. If I can understand the architecture better, I can solve my own problems.

Sincerely,

Joe Giacomini


  **


------------------------------------------------------------------------------
Xperia(TM) PLAY
It's a major breakthrough. An authentic gaming
smartphone on the nation's most reliable network.
And it wants your games.
http://p.sf.net/sfu/verizon-sfdev
_______________________________________________
mitk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mitk-users

Reply via email to