|
|
|
Re: Modular Application [message #1028210 is a reply to message #1028047] |
Thu, 28 March 2013 01:00 |
Lukas Huser Messages: 42 Registered: March 2010 |
Member |
|
|
Hi Yassine
Short answer: If you already have a desktop extension class, simply create a new instance of it, set the core desktop, and add it to the list of desktop extensions.
@Override
protected void injectDesktopExtensions(List<IDesktopExtension> desktopExtensions) {
DesktopExtension extension = new DesktopExtension();
extension.setCoreDesktop(this);
desktopExtensions.add(extension);
}
A somewhat more elaborate answer:
/!\ Disclaimer: The area of Scout modules and extensions is under heavy development for the upcoming Eclipse Kepler release (3.9). There will be much better support for Scout modules also in the SDK. As of now (Eclipse Juno, 3.8), there is quite some manual work involved to set-up a Scout module. There is also a risk that this answer will be outdated in a few months.
But now let's get started :) We'll start from scratch with a core Scout application and will add a Scout module to it.
- create core application
[Scout View] Create a new Scout project with name org.example.myapp and postfix core. This will create bundles with names org.example.myapp.[client|shared|server].core
- create extension bundles
[Java View] Manually create three bundles (plug-in projects) with names org.example.myapp.[client|shared|server].extension. The naming pattern is important (the postfix extension should reflect the name of your module, though).
- set-up bundle dependencies
[Java View] Open the manifest editor for all three bundles and define bundle dependencies:
org.example.myapp.client.extension depends on org.eclipse.scout.rt.client and org.example.myapp.shared.extension.
org.example.myapp.shared.extension depends on org.eclipse.scout.rt.shared. Re-export this dependency!
org.example.myapp.server.extension depends on org.eclipse.scout.rt.server and org.example.myapp.shared.extension.
- make your bundles Scout bundles
[Scout View] Use menu "Import Plugin..." on the "Scout Projects" folder and import all three extension bundles. Restart Eclipse.
- create a desktop extension
[Java View] Create a new class in the
org.example.myapp.client.extension bundle: org.example.myapp.client.extension.ui.desktop.DesktopExtension which inherits from org.eclipse.scout.rt.client.ui.desktop.AbstractDesktopExtension
- building the extension
[Scout View] The Scout SDK now displays your three extension bundles as a separate Scout module. The orange client node also contains a "Desktop-Extension" node. You can now use the Scout SDK to build your module as you would with a normal Scout application. Well, almost. There are a few further caveats: You also need to create a separate TextProviderService for your extension module (do this in the corresponding folder in the shared bundle).
Also, when adding a new outline to the desktop extension, the generated Java code did not compile in my test. You need to fix this manually: In the constructor of the generated OutlineViewButton change Desktop.this to getCoreDesktop() and you should be fine.
You might stumble over some more issues like this, but all of them can be resolved in one way or another :)
- integrate with the core application
Finally we're back to your initial question :) We now have a desktop extension class which we will integrate to the core application.
[Java View] Open the manifest editor for the client extension bundle. Export the package containing the desktop extension class (org.example.myapp.client.extension.ui.desktop).
Open the manifest editor for the client core bundle. Import the above package from the client extension bundle.
Adapt the product files for both the client and server products. Add the extension bundles to the dependencies (client and shared bundles in the client product, server and shared in the server product).
In the Desktop class of the client core bundle, override the method injectDesktopExtensions() and add an instance of the desktop extension class to the list of extensions (see above).
Scout SDK with a Scout module:
Simple demo with an extension outline:
Cheers Lukas
|
|
|
Re: Modular Application [message #1028753 is a reply to message #1028210] |
Thu, 28 March 2013 17:39 |
Silvio Kohler Messages: 5 Registered: March 2013 |
Junior Member |
|
|
Hi
@Lukas:
Thank you very much for your explanation. As discussed with you, we will use it for the Tutorial.
@Yassine:
Please note that creating modules will be supported much better by the SDK from version 3.9 (Kepler) on. Steps 2 to 7 in Lukas' explanation won't be needed to be done manually anymore.
In addition, the code of the core-plugins won't be changed anymore. The code in the Desktop class [1] will be replaced by the use of an extension point. Extending this extension point will do the job of adding a DesktopExtension to a Desktop.
This Tutorial describes how to add modules with Scout 3.9 (Eclipse 3.8/Kepler).
[1]
@Override
protected void injectDesktopExtensions(List<IDesktopExtension> desktopExtensions) {
DesktopExtension extension = new DesktopExtension();
extension.setCoreDesktop(this);
desktopExtensions.add(extension);
}
Cheers
Silvio
[Updated on: Thu, 28 March 2013 17:42] Report message to a moderator
|
|
|
|
|
|
Re: Modular Application [message #1029248 is a reply to message #1029232] |
Fri, 29 March 2013 11:29 |
|
Boy D'Poy wrote on Fri, 29 March 2013 06:57I could maybe be wrong, but in my opinion, modules bundles should be bases bundles' fragments (rather than plugins).
It would thus help avoid cycles when importing classes as it appears here:
@Override
protected void injectDesktopExtensions(List<IDesktopExtension> desktopExtensions) {
DesktopExtension extension = new DesktopExtension();
extension.setCoreDesktop(this);
desktopExtensions.add(extension);
}
furthermore make developed modules optional!
Where it's still time, the development team should take this into account dor SDK production ... if I'm somewhat right
Hi Boy D'Poy
You're right about the cycle when using this code snippet. But as Silvio already said, as of 3.9, injecting the desktop extensions will be done by extension point. The great advantage is, that you don't need a dependency from your core plugin to the extension bundle -> no cycle. You could also use a service to achieve the same.
Fragments are not necessary, better use bundles.
|
|
|
Re: Modular Application [message #1029265 is a reply to message #1024146] |
Fri, 29 March 2013 11:56 |
Boy D'Poy Messages: 67 Registered: October 2011 |
Member |
|
|
ok
So as if I follow the examplewe can still avoid cycles by simply implementing the extension point org.eclipse.scout.rt.extension.client.desktopExtensions in the plugin org.example.myapp.client.extension like this:
<extension point="org.eclipse.scout.rt.extension.client.desktopExtensions">
<desktopExtension active="true/false (i.e. optionnal)" class="org.example.myapp.client.extension.DesktopExtension">
</desktopExtension>
</extension>
There's so then no need to make the base bundle dependant of it's modules. Am I right?
Once You Go Scout, You Never Come Out!
[Updated on: Fri, 29 March 2013 11:58] Report message to a moderator
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04537 seconds