Search code examples
eclipse-rcpe4perspective

MPart is not user after switch perspective


I have an issue related to switching perspectives in E4. The two perspectives shares the same MPart. After switching to a new perspective the new MPart will be used. After swithing back to the original perspective the second MPart will still be used instead of the first one.

enter image description here

In the image you can find the application structure and both of the Perspectives has Outline screen on it. When opening perspective one, the Outline works for that perspective. Then if we switch to perspective two (that has different other screen) the second Outline will be activated and works correct. When switching back to the first perspective the second Outline will be still active and the first Outline will not respond to any requests.

After switching to perspective I active all the MPart back with:

List<MPart> part = service.findElements(perspective, null, MPart.class, null);
    List<MPartStack> mainPartStack = service.findElements(perspective, "partstack.shared", MPartStack.class, null);

    if (!mainPartStack.isEmpty()) {
      for (int i = part.size() - 1; i >= 0; i--) {

        List<MPart> children = service.findElements(mainPartStack.get(0), part.get(i).getElementId(), MPart.class,
          null);

        if (!children.contains(part.get(i))) {

          this.partService.activate(part.get(i));
        }
      }
    }

How can I activate the first Outline back so that it will respond to new request from the first perspective?


Solution

  • Created a shared Outline part and use a placeholder to reuse the Outline. With this solution I changed the perspective switch implementation. So that if a user go back to the first perspective that the data of the outline is the same when he was switching to the second.