Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » Modular Application(How to create Modular application using Eclipse Scout)
Modular Application [message #1024146] Mon, 25 March 2013 22:41 Go to next message
Yassine MILHI is currently offline Yassine MILHIFriend
Messages: 11
Registered: March 2013
Junior Member
Hello,

I'm new in the scout community . I'm working on a project using eclipse scout. I want to know how I can develop a modular application.

Is there any experience on how to design such kind of applications?

I looked at the documation published by Ivan Motsch and Stefan Mutschler
but I could not know how to use the injectDesktopExtensions function.


thank you pout your cooperation.
Re: Modular Application [message #1027071 is a reply to message #1024146] Tue, 26 March 2013 14:21 Go to previous messageGo to next message
Silvio Kohler is currently offline Silvio KohlerFriend
Messages: 5
Registered: March 2013
Junior Member
Hi Yassine

Yes, there is experience with this functionality of Scout. However, there is no Wiki Tutorial (yet).

Which documentation do you mention in your post? Is it this one? If yes: Do you plan to add functionality using an additional server-client-shared plugin triple, or are you looking for something different?

It would help if you provide more context about what you are planning to achieve.

Thanks

Silvio
Re: Modular Application [message #1028047 is a reply to message #1027071] Wed, 27 March 2013 19:20 Go to previous messageGo to next message
Yassine MILHI is currently offline Yassine MILHIFriend
Messages: 11
Registered: March 2013
Junior Member
Thanks Mr Silvio for replying,

Yes, this is exactly what I want to achieve. In fact I want to add some functionalities to my core application such as changing menus or some forms.
To do that, I've created another Scout Bundle, its Desktop class inherits from the AbstractDesktopExtension class and implements IDesktopExtension.
Consequently, I must override some methods which I do not have any idea about them.

On the other hand, after creating extensions, I need to inject them to my Core app.
I've seen this post http://www.eclipse.org/forums/index.php/mv/msg/368722/899287/#msg_899287
There is a method loadYourExtensions() which I don't know how to fill it.

Thanks,
Yassine.
Re: Modular Application [message #1028210 is a reply to message #1028047] Thu, 28 March 2013 01:00 Go to previous messageGo to next message
Lukas Huser is currently offline Lukas HuserFriend
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.



  1. 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
  2. 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).
  3. 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.
  4. make your bundles Scout bundles
    [Scout View] Use menu "Import Plugin..." on the "Scout Projects" folder and import all three extension bundles. Restart Eclipse.
  5. 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
  6. 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 :)
  7. 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:
index.php/fa/14177/0/

Simple demo with an extension outline:
index.php/fa/14178/0/


Cheers Lukas
Re: Modular Application [message #1028753 is a reply to message #1028210] Thu, 28 March 2013 17:39 Go to previous messageGo to next message
Silvio Kohler is currently offline Silvio KohlerFriend
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 #1028786 is a reply to message #1028210] Thu, 28 March 2013 18:37 Go to previous messageGo to next message
Yassine MILHI is currently offline Yassine MILHIFriend
Messages: 11
Registered: March 2013
Junior Member
Thank you very much Mr. Lukas for this considerable response.
I'm trying it out following these steps.
Feedback will be posted here as soon as possible.
Thanks,
Yassine.
Re: Modular Application [message #1028909 is a reply to message #1028786] Thu, 28 March 2013 23:01 Go to previous messageGo to next message
Yassine MILHI is currently offline Yassine MILHIFriend
Messages: 11
Registered: March 2013
Junior Member
Thank you very much Mr. Silvio for your support.
Re: Modular Application [message #1029232 is a reply to message #1024146] Fri, 29 March 2013 10:57 Go to previous messageGo to next message
Boy D'Poy is currently offline Boy D'PoyFriend
Messages: 67
Registered: October 2011
Member
I 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 Smile


Once You Go Scout, You Never Come Out!
Re: Modular Application [message #1029248 is a reply to message #1029232] Fri, 29 March 2013 11:29 Go to previous messageGo to next message
Claudio Guglielmo is currently offline Claudio GuglielmoFriend
Messages: 259
Registered: March 2010
Senior Member
Boy D'Poy wrote on Fri, 29 March 2013 06:57
I 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 Smile


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 Go to previous messageGo to next message
Boy D'Poy is currently offline Boy D'PoyFriend
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

Re: Modular Application [message #1031810 is a reply to message #1029265] Tue, 02 April 2013 08:12 Go to previous messageGo to next message
Silvio Kohler is currently offline Silvio KohlerFriend
Messages: 5
Registered: March 2013
Junior Member
Hi Boy D'Poy

Yes, you're right. Going this way, you only need the dependencies created in the tutorial. The core (base) bundles do not know the extension bundles, so you don't have any cycles.

Greets

Silvio
Re: Modular Application [message #1034562 is a reply to message #1031810] Fri, 05 April 2013 15:32 Go to previous messageGo to next message
Yassine MILHI is currently offline Yassine MILHIFriend
Messages: 11
Registered: March 2013
Junior Member
Hi,
Please I need source code of DesktopExtension Class.
If someone could help me,
Thanks.
Re: Modular Application [message #1037682 is a reply to message #1034562] Tue, 09 April 2013 22:31 Go to previous messageGo to next message
Lukas Huser is currently offline Lukas HuserFriend
Messages: 42
Registered: March 2010
Member
If you follow the steps above and create the desktop extension class yourself (in step 5), 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 {
	
}


You then can add outlines and menus to the desktop extension from the Scout SDK. This is exactly what I did in my previous post, where I quickly click-and-built a desktop extension with a sample outline and menu.
The SDK generated the following code for me:

package org.example.myapp.client.extension.ui.desktop;

import java.util.ArrayList;

import org.eclipse.scout.commons.annotations.Order;
import org.eclipse.scout.rt.client.ui.action.menu.AbstractMenu;
import org.eclipse.scout.rt.client.ui.desktop.AbstractDesktopExtension;
import org.eclipse.scout.rt.client.ui.desktop.outline.AbstractOutlineViewButton;
import org.eclipse.scout.rt.client.ui.desktop.outline.IOutline;
import org.eclipse.scout.rt.shared.TEXTS;
import org.example.myapp.client.extension.ui.desktop.outlines.ExtensionOutline;

public class DesktopExtension extends AbstractDesktopExtension {

	@SuppressWarnings("unchecked")
	@Override
	protected Class<? extends IOutline>[] getConfiguredOutlines() {
		ArrayList<Class<? extends IOutline>> outlines = new ArrayList<Class<? extends IOutline>>();
		outlines.add(ExtensionOutline.class);
		return outlines.toArray(new Class[outlines.size()]);
	}

	@Order(10.0)
	public class ExtensionMenu extends AbstractMenu {

		@Override
		protected String getConfiguredText() {
			return TEXTS.get("Extension");
		}

		@Order(10.0)
		public class LaunchExtensionMenu extends AbstractMenu {
			@Override
			protected String getConfiguredText() {
				return TEXTS.get("Extension");
			}
		}
	}

	@Order(10.0)
	public class ExtensionOutlineViewButton extends AbstractOutlineViewButton {
		public ExtensionOutlineViewButton() {
			super(getCoreDesktop(), ExtensionOutline.class);
		}

		@Override
		protected String getConfiguredText() {
			return TEXTS.get("Extension");
		}
	}
}


Hope this helps.

Lukas
Re: Modular Application [message #1041105 is a reply to message #1037682] Sun, 14 April 2013 16:28 Go to previous messageGo to next message
Yassine MILHI is currently offline Yassine MILHIFriend
Messages: 11
Registered: March 2013
Junior Member
Thanks Lukas for your help, it is very useful.

However, I still have a small problem.
I added a menu and an outline in the extension, but the associated text is not displayed correctly.

It shows me "Undefined text Extension" (see the picture below)

Thanks in Advance,
Yassine.
  • Attachment: Problem.jpg
    (Size: 49.03KB, Downloaded 254 times)

[Updated on: Mon, 15 April 2013 12:54]

Report message to a moderator

Re: Modular Application [message #1041478 is a reply to message #1041105] Mon, 15 April 2013 06:42 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
This has nothing to do with Extensions... It just means that Scout Text provider is looking for a text that does not exist.

In the code provided by Lukas there is:
@Override
protected String getConfiguredText() {
	return TEXTS.get("Extension");
}


Just change "Extension" with the text key you want to have in the OutlineViewButton.

Let me know if you need more explanations.
Re: Modular Application [message #1042897 is a reply to message #1041478] Wed, 17 April 2013 02:29 Go to previous message
Yassine MILHI is currently offline Yassine MILHIFriend
Messages: 11
Registered: March 2013
Junior Member
Thank you very much Mr. Jeremie for your explanation.
In fact the error occurred because I had not inserted a key (named Extension) in the file Texts.properties found in the Resources folder of the plugin shared.
I did that and it works very well.
Thank you once again for your help
Best regards.
Previous Topic:Update a CLOB field in a table
Next Topic:init radio buttons
Goto Forum:
  


Current Time: Thu Dec 26 17:58:25 GMT 2024

Powered by FUDForum. Page generated in 0.05685 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top