Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Scout/Tutorial/3.8/Modular Application"

< Scout‎ | Tutorial‎ | 3.8
(Introduction)
Line 1: Line 1:
== Introduction ==
+
== Introduction ==
Scout applications can be built as a set of application modules extending a common core application. New modules normally consist of three additional plugins (client, shared, server). In these plugins, new functionality and GUI-components may be added to extend an existing application.
+
  
In this tutorial, a new Scout module is added to an existing Scout application. The new module provides an additional outline "Extension".
+
Scout applications can be built as a set of application modules extending a common core application. New modules normally consist of three additional plugins (client, shared, server). In these plugins, new functionality and GUI-components may be added to extend an existing application.  
  
{{warning|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.
+
In this tutorial, a new Scout module is added to an existing Scout application. The new module provides an additional outline "Extension".  
If you are already using the Kepler M6 Release, use [[3.9/Modular_Application|this tutorial]] to build new modules.}}
+
  
==Setup==
+
{{warning|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. This tutorial will be superceded by the [[3.9/Modular_Application|corresponding tutorial for Eclipse Scout 3.9]].
We'll start from scratch with a core Scout application and will add a Scout module to it.
+
If you are already using the Kepler M6 Release, you can already profit from the new features!}}
  
===Create core application===
+
== Setup ==
[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.
+
We'll start from scratch with a core Scout application and will add a Scout module to it.  
  
org.example.myapp.shared.extension depends on org.eclipse.scout.rt.shared. Re-export this dependency!
+
=== Create core application ===
  
org.example.myapp.server.extension depends on org.eclipse.scout.rt.server and org.example.myapp.shared.extension.
+
[Scout View] Create a new Scout project with name <code>org.example.myapp</code> and postfix <code>core</code>. This will create bundles with names <code>org.example.myapp.[client|shared|server].core</code>
===Make your bundles Scout bundles===
+
[Scout View] Use menu "Import Plugin..." on the "Scout Projects" folder and import all three extension bundles. Restart Eclipse.
+
  
==Adding an Extension==
+
=== Create extension bundles ===
===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 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 does not compile. You need to fix this manually: In the constructor of the generated OutlineViewButton change Desktop.this to getCoreDesktop() and you should be fine.
+
===Integrate with the core application===
+
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).
+
[Java View] Manually create three bundles (plug-in projects) with names <code>org.example.myapp.[client|shared|server].extension</code>. The naming pattern is important (the postfix extension should reflect the name of your module, though).  
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).
+
=== Set-up bundle dependencies ===
  
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.
+
[Java View] Open the manifest editor for all three bundles and define bundle dependencies:
  @Override
+
  protected void injectDesktopExtensions(List<IDesktopExtension> desktopExtensions) {
+
    DesktopExtension extension = new DesktopExtension();
+
    extension.setCoreDesktop(this);
+
    desktopExtensions.add(extension);
+
  }
+
  
Scout SDK with a Scout module:
+
<code>org.example.myapp.client.extension</code> depends on <code>org.eclipse.scout.rt.client</code> and <code>org.example.myapp.shared.extension</code>.
  
[[Image:ScoutModuleSDK.png]]
+
<code>org.example.myapp.shared.extension</code> depends on <code>org.eclipse.scout.rt.shared</code>. Re-export this dependency!
  
Simple demo with an extension outline:
+
<code>org.example.myapp.server.extension</code> depends on <code>org.eclipse.scout.rt.server</code> and <code>org.example.myapp.shared.extension</code>.
 +
 
 +
=== Make your bundles Scout bundles ===
 +
 
 +
[Scout View] Use menu "Import Plugin..." on the "Scout Projects" folder and import all three extension bundles. Restart Eclipse.
 +
 
 +
== Adding an Extension ==
 +
 
 +
=== Create a desktop extension ===
 +
 
 +
[Java View] Create a new class in the <code>org.example.myapp.client.extension</code> bundle: <code>org.example.myapp.client.extension.ui.desktop.DesktopExtension</code> which inherits from <code>org.eclipse.scout.rt.client.ui.desktop.AbstractDesktopExtension</code>.
 +
The class can really look as simple as the following:
 +
<source lang="java">
 +
package org.example.myapp.client.extension.ui.desktop;
 +
 
 +
import org.eclipse.scout.rt.client.ui.desktop.AbstractDesktopExtension;
 +
 
 +
public class DesktopExtension extends AbstractDesktopExtension {
 +
 +
}
 +
</source>
 +
 
 +
=== Building the extension ===
 +
 
 +
[Scout View] The Scout SDK now displays 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 <code>TextProviderService</code> 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 does not compile. You need to fix this manually: In the constructor of the generated <code>OutlineViewButton</code> change <code>Desktop.this</code> to <code>getCoreDesktop()</code> and you should be fine.
 +
 
 +
=== Integrate with the core application ===
 +
 
 +
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 (<code>org.example.myapp.client.extension.ui.desktop</code>). 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 <code>Desktop</code> class of the client core bundle, override the method <code>injectDesktopExtensions()</code> and add an instance of the desktop extension class to the list of extensions.
 +
 
 +
<source lang="java">
 +
    @Override
 +
  protected void injectDesktopExtensions(List<IDesktopExtension> desktopExtensions) {
 +
    DesktopExtension extension = new DesktopExtension();
 +
    extension.setCoreDesktop(this);
 +
    desktopExtensions.add(extension);
 +
  }
 +
</source>
 +
 
 +
Scout SDK with a Scout module:
 +
 
 +
[[Image:ScoutModuleSDK.png]]
 +
 
 +
Simple demo with an extension outline:  
  
 
[[Image:ScoutModuleOutline.png]]
 
[[Image:ScoutModuleOutline.png]]

Revision as of 18:55, 9 April 2013

Introduction

Scout applications can be built as a set of application modules extending a common core application. New modules normally consist of three additional plugins (client, shared, server). In these plugins, new functionality and GUI-components may be added to extend an existing application.

In this tutorial, a new Scout module is added to an existing Scout application. The new module provides an additional outline "Extension".

Warning2.png
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. This tutorial will be superceded by the corresponding tutorial for Eclipse Scout 3.9. If you are already using the Kepler M6 Release, you can already profit from the new features!


Setup

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.

Adding an Extension

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. The class can really look as simple as the following:

package org.example.myapp.client.extension.ui.desktop;
 
import org.eclipse.scout.rt.client.ui.desktop.AbstractDesktopExtension;
 
public class DesktopExtension extends AbstractDesktopExtension {
 
}

Building the extension

[Scout View] The Scout SDK now displays 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 does not compile. You need to fix this manually: In the constructor of the generated OutlineViewButton change Desktop.this to getCoreDesktop() and you should be fine.

Integrate with the core application

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.

    @Override
  protected void injectDesktopExtensions(List<IDesktopExtension> desktopExtensions) {
    DesktopExtension extension = new DesktopExtension();
    extension.setCoreDesktop(this);
    desktopExtensions.add(extension);
  }

Scout SDK with a Scout module:

ScoutModuleSDK.png

Simple demo with an extension outline:

ScoutModuleOutline.png

Back to the top