Here I cust collect for you building blocks for SDK components, which can be used "copy&paste" with "search&replace" afterwords.
There are always 3 parts:
This blog is just a start. I will try to extend this as soon I have more.
Create New SAPUI5 Component (in this example, we start with Absolute Layout)
<component
id="%YourComponentId%"
title="%Your Component Id Title%"
icon="res/%your subfolder%/%YourComponentId%.png"
handlerType="sapui5"
group="%YourComponentGroupId%">
<jsInclude>res/%your subfolder%/%YourComponentId%.js</jsInclude>
<cssInclude>res/%your subfolder%/%YourComponentId%.css</cssInclude>
... here will be more content - delete for now this line ...
</component>
Important: your component is located in some package, you have to sync the package on all places!
here: %your.sdk.package% == org.kalisz.karol.scn.pack
/**
* Class for MenuButton
*/
class %your.sdk.package%.%YourComponentId% extends Component {
... here will be more content - delete for now this line ...
}
sap.ui.commons.layout.AbsoluteLayout.extend("%your.sdk.package%.%YourComponentId%", {
/** here we will insert all parameters later */
metadata: {
properties: {
... here properties extensions - delete for now ...
}
},
/** this method is used later for init*/
initDesignStudio: function() {
},
renderer: {},
/** this method is requried for content update */
afterDesignStudioUpdate : function() {
},
});
Add Simple Property (Sting, Boolean)
instead of this line:
... here will be more content - delete for now this line ...
insert...
<property
id="dText"
type="String"
title="Text Value"
tooltip="Button text displayed at runtime"
group="Display"
visible="true"/>
<property
id="dEnabled"
title="Enabled"
tooltip="Switches enabled state of the control"
type="boolean"
group="Display"
visible="true"/>
instead of this line:
... here will be more content - delete for now this line ...
insert...
/** some documentation */
String getText () {*
return this.dText;
*}
/** some documentation */
void setText (String value) {*
this.dText= value;
*}
/** some documentation */
String getEnabled () {*
return this.dEnabled;
*}
/** some documentation */
void setEnabled (boolean value) {*
this.dEnabled= value;
*}
sap.ui.commons.layout.AbsoluteLayout.extend("%your.sdk.package%.%YourComponentId%", {
/** here we will insert all parameters later */
metadata: {
properties: {
"dText": {type: "string"},
"dEnabled": {type: "boolean"},
}
},
/** this method is used later for init*/
initDesignStudio: function() {
},
renderer: {},
/** this method is requried for content update */
afterDesignStudioUpdate : function() {
// access the properties
var oText = this.getDText();
var oEnabled = this.getDEnabled();
},
});
Add Array Property
<property
id="dElementsContent"
type="String"
title="Property For Elements"
group="Display"
visible="false"/>
/** remove all elements */
void removeAllElements () {*
var elementsArray = [];
this.dElementsContent= JSON.stringify(elementsArray);
*}
void addElement (
/**Element Key (must be unique)*/ String elementKey,
/**Element Text*/ String elementText,
/**Some Optional Boolean*/ optional boolean isActive) {*
// default
if(isActive== undefined) {
isActive= true;
}
var itemDef = {
"key": elementKey,
"text": elementText,
"active": isActive
};
if (this.elementsContent === undefined || this.elementsContent === "" || this.elementsContent === "<delete>"){
this.elementsContent = "[]";
}
var elementsJson = JSON.parse(this.dElementsContent);
var alreadyFound = false;
for (var i = 0; i < elementsJson.length ; i++){
if (elementsJson[i].key == elementKey) {
alreadyFound = true;
break;
}
}
if(!alreadyFound) {
elementsJson.push(itemDef);
}
this.dElementsContent= JSON.stringify(elementsJson);
*}
metadata: {
properties: {
"dElementsContent": {type: "string"},
}
},
/** this method is requried for content update */
afterDesignStudioUpdate : function() {
var lElementsToRender = this.getDElementsContent();
if(lElementsToRender != null && lElementsToRender != undefined && lElementsToRender != ""){
var lElementsToRenderArray = JSON.parse(lElementsToRender);
// distribute content
for (var i = 0; i < lElementsToRenderArray.length; i++) {
var element = lElementsToRenderArray[i];
var lNewElement = this._createElement(i, element.key, element.text, element.active);
}
}
},
Special Area: Initialization / Default Values
at the place of this line.
... here will be more content - delete for now this line ...
<initialization>
<defaultValue property="WIDTH">400</defaultValue>
<defaultValue property="HEIGHT">40</defaultValue>
<defaultValue property="TOP_MARGIN">0</defaultValue>
<defaultValue property="LEFT_MARGIN">0</defaultValue>
<defaultValue property="RIGHT_MARGIN">auto</defaultValue>
<defaultValue property="BOTTOM_MARGIN">auto</defaultValue>
<defaultValue property="dEnabled">true</defaultValue>
<defaultValue property="dText">Some Text</defaultValue>
</initialization>
The examples above are quite basic, you can see such examples in my components. Of course, there are many ways to acieve the same.
With this you can simply prepare your own SDK component and this will be rendered as empty Absolute Layout...
If someone wants to try out and you get any troubles, please comment - I will fix and update
If you have another snippet which can be used, just post it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
40 | |
25 | |
17 | |
13 | |
8 | |
7 | |
7 | |
7 | |
6 | |
6 |