<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://download.osbee.org/documentation/index.php?action=history&amp;feed=atom&amp;title=Strategy_DSL</id>
		<title>Strategy DSL - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://download.osbee.org/documentation/index.php?action=history&amp;feed=atom&amp;title=Strategy_DSL"/>
		<link rel="alternate" type="text/html" href="https://download.osbee.org/documentation/index.php?title=Strategy_DSL&amp;action=history"/>
		<updated>2026-04-10T23:38:49Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.26.2</generator>

	<entry>
		<id>https://download.osbee.org/documentation/index.php?title=Strategy_DSL&amp;diff=2262&amp;oldid=prev</id>
		<title>Cmollik: Created page with &quot;==Introduction==  ===ECView===  ECView is an osgi framework that allows you to automatically render form-based user interfaces based on an EMF (Eclipse Modeling Framework)-bas...&quot;</title>
		<link rel="alternate" type="text/html" href="https://download.osbee.org/documentation/index.php?title=Strategy_DSL&amp;diff=2262&amp;oldid=prev"/>
				<updated>2017-09-04T17:41:27Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;==Introduction==  ===ECView===  ECView is an osgi framework that allows you to automatically render form-based user interfaces based on an EMF (Eclipse Modeling Framework)-bas...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
===ECView===&lt;br /&gt;
&lt;br /&gt;
ECView is an osgi framework that allows you to automatically render form-based user interfaces based on an EMF (Eclipse Modeling Framework)-based UI model. Business data in the form of JPA (Java Persistence Appication Programming Interface) Entities or DTOs (Data Transfer Objects) can be automatically linked to the UI elements. ECView has been designed with extremely careful attention to modularity, extensibility and independence from the Concrete UI technology. It consists of an API (Appication Programming Interface) layer, an EMF model layer, a controller layer and a presenter layer. Exclusively the presenter layer has dependencies to the used UI framework, such as Vaadin. The use of other frameworks requires only the integration of other presenters. The integration of ECView into the system gives us the possibility to provide business forms &amp;quot;out of the box&amp;quot; without code generation or without manual writing of UI code and connect to a database. &lt;br /&gt;
&lt;br /&gt;
===1.2	Vaadin Layout Components===&lt;br /&gt;
&lt;br /&gt;
Vaadin dialog provieds a few Layout Components, we will use some of them in our DSL:&lt;br /&gt;
&lt;br /&gt;
* FormLayout lays the components and their captions out in two columns, with optional indicators for required fields and errors that can be shown for each field. &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[File:StrategyDSL01.png]]&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
* GridLayout container lays components out on a grid consisting of rows and columns. &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[File:StrategyDSL02.png]]&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
* VerticalLayout is ordered layouts for laying components out vertically.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[File:StrategyDSL03.png]]&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
*  HorizontalLayout is ordered layouts for laying components out horizontally.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[File:StrategyDSL04.png]]&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
* CSSLayout allows strong control over styling of the components contained inside the layout.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[File:StrategyDSL05.png]]&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==StrategyDSL==&lt;br /&gt;
&lt;br /&gt;
The StrategyDSL works for Os.bee models; it defines the display strategies of dialog model. &lt;br /&gt;
&lt;br /&gt;
It defines not only the layout strategy, but also the focusing strategy.&lt;br /&gt;
&lt;br /&gt;
User can select the predefined Strategy for the dialog view:&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[File:StrategyDSL06.png]]&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The main semantic elements of the StrategyDSL are:&lt;br /&gt;
* “package” - the root element that contains all the other elements. A model can contain multiple packages. &lt;br /&gt;
* “strategy” - define the strategy rules for dialog. &lt;br /&gt;
* “targets” - define the strategy details, including layouting strategy, focusing strategy and focusing enhancer.&lt;br /&gt;
* “default” - define the default strategy including layouting and focusing.&lt;br /&gt;
&lt;br /&gt;
===Syntax===&lt;br /&gt;
&lt;br /&gt;
====package definition====&lt;br /&gt;
&lt;br /&gt;
► '''Syntax''':&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
package &amp;lt;package name&amp;gt; &lt;br /&gt;
[{  &lt;br /&gt;
strategy { &lt;br /&gt;
targets [{ &lt;br /&gt;
layoutingStrategy . . .&lt;br /&gt;
. . . &lt;br /&gt;
focusingStrategy . . .&lt;br /&gt;
. . .&lt;br /&gt;
focusingEnhancer . . .&lt;br /&gt;
. . .&lt;br /&gt;
}]&lt;br /&gt;
&lt;br /&gt;
default { &lt;br /&gt;
. . .&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
► '''Example''':&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
package net.osbee.sample.foodmart.strategies { &lt;br /&gt;
	strategy {&lt;br /&gt;
		targets {&lt;br /&gt;
			layoutingStrategy Form2Columns layout= Form2&lt;br /&gt;
			layoutingStrategy Form3Colums layout= Form3&lt;br /&gt;
			layoutingStrategy ^Horizontal layout= Horizontal&lt;br /&gt;
			layoutingStrategy ^Vertical layout= Vertical&lt;br /&gt;
			layoutingStrategy ^Grid layout= Grid&lt;br /&gt;
			layoutingStrategy ^Css layout= Css&lt;br /&gt;
			focusingStrategy GenAltEnter &lt;br /&gt;
ecviewFocusingId= cxAltEnterForward &lt;br /&gt;
focus= Forward &lt;br /&gt;
keyStrokeDefinition {&lt;br /&gt;
					keyCode= ENTER modifierKeys {&lt;br /&gt;
						ALT&lt;br /&gt;
					}&lt;br /&gt;
				} &lt;br /&gt;
			focusingStrategy GenEnter &lt;br /&gt;
ecviewFocusingId= cxEnterForward &lt;br /&gt;
focus= Forward &lt;br /&gt;
keyStrokeDefinition {&lt;br /&gt;
					keyCode= ENTER&lt;br /&gt;
				}&lt;br /&gt;
			focusingStrategy GenTab &lt;br /&gt;
ecviewFocusingId= cxEnTabForward &lt;br /&gt;
focus= Forward &lt;br /&gt;
keyStrokeDefinition {&lt;br /&gt;
					keyCode= TAB&lt;br /&gt;
				}	&lt;br /&gt;
			focusingEnhancer GenEnterTab {&lt;br /&gt;
				GenEnter GenTab&lt;br /&gt;
			}&lt;br /&gt;
		}&lt;br /&gt;
		default {&lt;br /&gt;
			defaultLayouting= Form2Columns defaultFocusing= GenEnterTab&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====targets====&lt;br /&gt;
&lt;br /&gt;
Keyword &amp;lt;code&amp;gt;targets&amp;lt;/code&amp;gt; is used to define the target strategy and enhancer. There are 3 types of target to be defined, they are '''layoutingStrategy, focusingStrategy''' and '''focusingEnhancer'''. One or more '''layoutingStrategy, focusingStrategy''' and '''focusingEnhancer''' can be defined in the same targets.&lt;br /&gt;
&lt;br /&gt;
► '''Syntax''':&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
targets [{ &lt;br /&gt;
layoutingStrategy &amp;lt;layoutingStrategy name&amp;gt; &lt;br /&gt;
layout=LayoutingType&lt;br /&gt;
. . .&lt;br /&gt;
&lt;br /&gt;
focusingStrategy &amp;lt;focusingStrategy name&amp;gt; ecviewFocusingId= &amp;lt;ecviewFocusingId&amp;gt; focus=FocusingType &lt;br /&gt;
[keyStrokeDefinition { &lt;br /&gt;
keyCode= &amp;lt;keyCode ID&amp;gt; &lt;br /&gt;
[modifierKeys { &amp;lt;modifierKeys ID&amp;gt;. . .}] &lt;br /&gt;
}]&lt;br /&gt;
. . .&lt;br /&gt;
&lt;br /&gt;
focusingEnhancer &amp;lt;enhancer name&amp;gt; { &lt;br /&gt;
&amp;lt;focusingStrategy name&amp;gt;&lt;br /&gt;
. . .&lt;br /&gt;
}&lt;br /&gt;
. . .&lt;br /&gt;
}]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====layoutingStrategy=====&lt;br /&gt;
&lt;br /&gt;
For &amp;lt;code&amp;gt;layoutingStrategy&amp;lt;/code&amp;gt;, strategy name and layout type must be defined. &lt;br /&gt;
* One or more &amp;lt;code&amp;gt;layoutingStrategy&amp;lt;/code&amp;gt; can be defined in the same targets.&lt;br /&gt;
* &amp;lt;code&amp;gt;LayoutingType can be &amp;lt;code&amp;gt;Horizontal, Vertical, Grid, Form2, Form3 or Css&amp;lt;/code&amp;gt;. They are all predefined layouting type.&lt;br /&gt;
* 2 java files will be generated for each layouting strategy in folder &amp;lt;code&amp;gt;./src-gen/&amp;lt;package name&amp;gt;/:&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;strategy name&amp;gt;+LayoutingStrategy.java&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;strategy name&amp;gt;+LayoutingStrategy+Provider.java&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
► '''Example''':&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
targets {&lt;br /&gt;
   		layoutingStrategy GenForm2 layout=Form2&lt;br /&gt;
   		layoutingStrategy GenForm3 layout=Form3&lt;br /&gt;
   		layoutingStrategy GenHorizontal layout=Horizontal&lt;br /&gt;
   		layoutingStrategy GenVertical layout=Vertical&lt;br /&gt;
   		layoutingStrategy GenGrid layout=Grid&lt;br /&gt;
   		layoutingStrategy GenCss layout=Css&lt;br /&gt;
		. . .&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this example, 6 '''layoutingStrategy''' are defined in '''targets'''. From the following picture, you could see the place where the defined strategies can be selected. &lt;br /&gt;
&lt;br /&gt;
If you select '''layoutingStrategy''' “GenForm3”, then the dialog will have 3 columns:&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[File:StrategyDSL07.png]]&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[File:StrategyDSL08.png]]&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====focusingStartegy=====&lt;br /&gt;
&lt;br /&gt;
For '''focusingStrategy''', strategy name, ecview focusing id and focus type must be defined. &lt;br /&gt;
* One or more '''focusingStrategy''' can be defined in the same '''targets'''.&lt;br /&gt;
* FocusingType can be '''Forward''' or '''Backward'''. They are all predefined focusing type.&lt;br /&gt;
* Keyword '''keyStrokeDefinition''' is optional. One '''keyCode''' should be defined here. '''modifierKeys'''  is optional. One or more modifier keys id could be defined in the same '''modifierKeys''' part.&lt;br /&gt;
* 2 java files will be generated for each focusing strategy in folder &amp;lt;code&amp;gt;./src-gen/&amp;lt;package name&amp;gt;/:&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;strategy name&amp;gt; + &amp;lt;focusing type&amp;gt; + FocusingStrategy.java&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;strategy name&amp;gt; + &amp;lt;focusing type&amp;gt;+ FocusingStrategy + Provider.java&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
► '''Example''':&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
targets {&lt;br /&gt;
		. . .&lt;br /&gt;
		focusingStrategy GenAltEnter &lt;br /&gt;
ecviewFocusingId= cxAltEnterForward &lt;br /&gt;
focus= Forward &lt;br /&gt;
keyStrokeDefinition {&lt;br /&gt;
				keyCode= ENTER modifierKeys {&lt;br /&gt;
					ALT&lt;br /&gt;
				}&lt;br /&gt;
			} 	&lt;br /&gt;
		. . .&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this example, a '''focusingStrategy''' '''''GenAltEnter''''' is defined in '''targets'''. &lt;br /&gt;
The ecviewFocusingId must be defined for the ECView. The following code will be generated in &lt;br /&gt;
GenAltEnterForwardFocusingStrategyProvider.java file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
@Component(immediate = true, service = IFocusingStrategyProvider.class, property = &amp;quot;ecview.focusing.id=cxAltEnterForward&amp;quot;)&lt;br /&gt;
@SuppressWarnings(&amp;quot;all&amp;quot;)&lt;br /&gt;
public class GenAltEnterForwardFocusingStrategyProvider implements IFocusingStrategyProvider {&lt;br /&gt;
  private final static String ID = &amp;quot;cxAltEnterForward&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
  @Override&lt;br /&gt;
  public IFocusingStrategy getStrategy() {&lt;br /&gt;
    return new GenAltEnterForwardFocusingStrategy();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the '''keyStrokeDefinition''' part, '''keyCode''' is defined as ENTER and the '''modifierKeys''' is ALT.&lt;br /&gt;
&lt;br /&gt;
The following code will be generated in GenAltEnterForwardFocusingStrategy.java file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
@Override&lt;br /&gt;
public KeyStrokeDefinition getKeyStrokeDefinition() {&lt;br /&gt;
    int[] modifierKeys = new int[1];&lt;br /&gt;
    modifierKeys[0] = ModifierKey.ALT;&lt;br /&gt;
    KeyStrokeDefinition def = new KeyStrokeDefinition(&amp;quot;&amp;quot;, KeyCode.ENTER, modifierKeys);&lt;br /&gt;
    return def;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====focusingEnhancer=====&lt;br /&gt;
&lt;br /&gt;
For '''focusingEnhancer''', enhancer name must be defined. &lt;br /&gt;
* One or more and predefined focusing strategy name should be listed. &lt;br /&gt;
* Only 1 java file will be generated in folder ./src-gen/&amp;lt;package name&amp;gt;/, its name is &amp;lt;enhancer name&amp;gt;+FocusingEnhancer.java. &lt;br /&gt;
&lt;br /&gt;
Following code will be generated in &amp;lt;enhancer name&amp;gt;+FocusingEnhancer.java file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
@Component(property=&amp;quot;ecview.focusing.enhancer.id=&amp;lt;enhancerName&amp;gt;FocusingEnhancer&amp;quot;)&lt;br /&gt;
@SuppressWarnings(&amp;quot;all&amp;quot;)&lt;br /&gt;
public class &amp;lt;enhancer name&amp;gt;FocusingEnhancer implements IFocusingEnhancer {&lt;br /&gt;
  @Override&lt;br /&gt;
  public void enhanceFocusing(final YStrategyLayout yLayout) {&lt;br /&gt;
    yLayout.getFocusingStrategies().clear();&lt;br /&gt;
//from here is one loop for every listed focusingStrategy  &lt;br /&gt;
    YDelegatingFocusingStrategy yStgy&amp;lt;number from 1 to n&amp;gt; = YECviewFactory.eINSTANCE.createYDelegatingFocusingStrategy();&lt;br /&gt;
    yStgy&amp;lt;number from 1 to n&amp;gt;.setDelegateStrategyId(&amp;quot;&amp;lt;ecviewFocusingId of focusingStrategy&amp;gt;&amp;quot;);&lt;br /&gt;
    yLayout.getFocusingStrategies().add(yStgy&amp;lt;number from 1 to n&amp;gt;);&lt;br /&gt;
//loop end&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
► '''Example''':&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
targets {&lt;br /&gt;
		. . .&lt;br /&gt;
		focusingEnhancer GenEnterTab {&lt;br /&gt;
			GenEnter GenTab&lt;br /&gt;
		}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====default====&lt;br /&gt;
&lt;br /&gt;
Keyword default is used to define the default strategy. &lt;br /&gt;
* There are 2 types of default strategy to be defined, they are '''defaultLayouting''' and '''defaultFocusing'''. You must to define one and only one '''defaultLayouting''' and '''defaultFocusing''' for your strategy.&lt;br /&gt;
* For the default part, 3 .java files will be generated, they are DefaultFocusingEnhancer.java, DefaultLayoutingStrategy,java and  DefaultLayoutingStrategyProvider.java. All the .java files are generated in folder ./src-gen/&amp;lt;package name&amp;gt;/. &lt;br /&gt;
&lt;br /&gt;
► '''Syntax''':&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
default {&lt;br /&gt;
&lt;br /&gt;
defaultLayouting=&amp;lt;layoutingStrategy name&amp;gt;&lt;br /&gt;
&lt;br /&gt;
defaultFocusing=&amp;lt;focusingStrategy name&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
► '''Example''':&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
default {&lt;br /&gt;
		defaultLayouting=GenForm2 defaultFocusing=GenEnterTab&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the examples, '''focusingStrategy''' '''''GenEnterTab''''' is defined to be used as '''defaultFocusing''' in Dialog; '''layoutingStrategy''' '''''GenForm2''''' is defined to be used as '''''defaultLayouting''''' in Dialog. Standard strategy is the ''defaultLayouting'' “GenForm2”, which have 2 columns:&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[File:StrategyDSL09.png]]&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;[[File:StrategyDSL10.png]]&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Cmollik</name></author>	</entry>

	</feed>