Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the active part in a particular partstack in eclipse e4?

I have a button which creates parts. I need to get the active part that is currently visible in he part stack and I am storing it as a key for some value. How should I get the active part? I have used the following code but it is getting all the parts in the partstack.

            MPart graphpart = partService
                    .createPart("com.abc.xyz.project.partDescriptor.1");
            MPartStack stack = (MPartStack) modelService.find(
                    "com.abc.xyz.project.partstack.2", application);

            for (int i = 0; i < stack.getChildren().size(); i++) {
                if (stack.getChildren().get(i).isVisible()) {
                    System.out.println("values"
                            + ((MPart) stack.getChildren().get(i)).getLabel());
                    application.getTransientData().put(
                            ((MPart) stack.getChildren().get(i)).getLabel(),
                            selectedFiles);
                }
            }
like image 879
Acjb Avatar asked Feb 13 '23 19:02

Acjb


1 Answers

From a MPart you can get its container directly with:

final MElementContainer<MUIElement> container = part.getParent();

(this will be the MPartStack)

You can then get the stacks currently selected child with:

MUIElement selected = container.getSelectedElement();
like image 98
greg-449 Avatar answered Feb 15 '23 09:02

greg-449