1

Since Scout supports modularity in projects we decided to modularize things. Problem is when we add an Outline to a project: how to add a page to that outline, but when page is present in child project. Function that adds pages to outline lives inside the outline and the problem is we should not have parent dependent on the child since we will get cycles in dependencies.

The outline is of type AbstractExtensibleOutline and probably supports extending/extensions based on name and comment in class header, but I haven't been able to figure out yet where and how to do that.

Neikius
  • 173
  • 2
  • 9
  • Related question on the Eclipse Scout Forum: [Multi Modul - Menu Extension](https://www.eclipse.org/forums/index.php?t=msg&th=934856&goto=1554417msg_1554417) and [Add a page in extension to outline in parent?](https://www.eclipse.org/forums/index.php?t=msg&th=1002103&goto=1624537msg_1624537) – Jmini Feb 23 '15 at 08:11

2 Answers2

2

I do not doubt that your programmatically solution is working, but I like to propose another one using eclipse extension points. I think this is the intended way of using this API.

In your extension, you do not need a DesktopExtension at all.

mycore.client (Core Project)
  |
  \- Desktop
        |
        \- MyOutline

myext.client (Extended Project)
  |
  \- MyPage

If MyOutline extends AbstractExtensibleOutline, you can just add MyPage directly to the MyOutline (defined in the core) with a pageContribution (using the org.eclipse.scout.rt.extension.client.pages extension point).

Plugin Editor - Eclipse

The plugin.xml of the client extention bundle (myext.client) File is looking like that if you display the text:

<?xml version="1.0" encoding="UTF-8"?>
<plugin>
   <extension
         point="org.eclipse.scout.rt.extension.client.pages">
      <pageContribution
            active="true"
            class="myext.client.pages.MyPage"
            order="1">
         <outline
               class="mycore.client.ui.desktop.outlines.MyOutline">
         </outline>
      </pageContribution>
   </extension>
</plugin>

With the Order field, you can indicate the position in the page list (this way you can insert pages in the middle of the list).

You can also register:

  • pageModification
  • pageRemoval

... depending on your needs.

Check also this Forum Post where I have described how you can contribute a Menu the same way: Multi Module - Menu Extension


Please also notice that for Mars (starting with version 4.2) we have introduced another mechanism for extensibility. Check this wiki page to read more about it: Scout Concepts - Extensibility.

This new mechanism is more powerfull than what we had introduced with Kepler (Scout 3.9). The Mars Version supports both the new and the old extensibility pattern. On the long term, I think that only the new pattern will be supported.

Community
  • 1
  • 1
Jmini
  • 9,189
  • 2
  • 55
  • 77
0

If you extend your project, you end up with Desktop Extension instead of Desktop.

Desktop Extension is initialized after parent Desktop, so you can expect that Outline that is inside parent Desktop is already prepared.

So let say you have this kind of structure :

Core Project
        |
        -- Desktop
               |
               -- MyOutline

Extended Project
        |
        -- Desktop Extension
        |
        -- My Page

So inside Extended Project in Desktop extension you need to override init function

@Override
protected ContributionCommand execInit() throws ProcessingException {

    ContributionCommand command = super.execInit();

    for (IOutline outline : getCoreDesktop().getAvailableOutlines()) {
      List<IPage> pages = new ArrayList<IPage>();

      MyPage myPage = new MyPage();
      pages.add(myPage);

      AbstractPageWithNodes pageWithNode = (AbstractPageWithNodes) outline.getRootNode();
      pageWithNode.getTree().addChildNodes(pageWithNode, pages);
    }

    return command;
 }  

In this way MyPage will be added on all Outlines. If you want to add in on specific use instanceof function.

Marko Zadravec
  • 8,298
  • 10
  • 55
  • 97
  • In my opinion [using eclipse extension points](http://stackoverflow.com/a/28678778/91497) is the way to go if you use this API. – Jmini Feb 23 '15 at 17:02
  • Well, this solution also works, but as your solution is definitely the way to go for the sake of nice code and modularity. – Neikius Feb 27 '15 at 13:52