Skip to Content

In the continued spirit of collaborating with Karol Kalisz, I wanted to see if I could add some additional utility to his new Design Studio SDK: Array Util Component.  This was born out of a need to do things you’d want to do with arrays such as How to get “Top X” our of resultset, for example.

Next up is that I wanted to get back a for loop in BIAL.  We have a forEach loop but for loops are not yet allowed.  Karol also added me as a co-author to his GitHub repository (KarolKalisz/DesignStudioSdkPack · GitHub) so I figured I’d see how easy or hard it is to use GitHub as intended as a code check-in and collaboration tool versus just a sharing code site.

So, I’ve enhanced DesignStudioSdkPack/contribution.ztl at master · KarolKalisz/DesignStudioSdkPack · GitHub with a new method called ‘eaches’ — This also is an example of how you can markup your ZTL code with some JavaDoc information for your BIAL scripters to know what things do.

The code:


/**
  Generates an array of integers for use in BIAL forEach statement in order to emulate a traditional for loop.
  <example>
  Fill a list box with 10 values:
  <code>ARRAY_1.eachesAsString(0, 9, 1).forEach(function(element, index) {<br>
  LISTBOX_1.addItem(element, "Item " + (element + "") );<br>
  });</code>
  This would be equivalent to a loop in JavaScript:
  <code>
  for(var element = 0;element<=9;element++){<br>
  Your code here.<br>
  }
  </code>
  </example>
  */
  Array eaches(/*Starting int*/ int start, /* Ending int */ int finish, /* Interval increment */int interval) {*
  var a = [];
  for(var i=start;i<=finish;i+=interval){
  a.push(i);
  }
  return a;
  *}

That’s it!  What’s it do?  The code documentation is shown above, but it’s a bit easier to read during BIAL scripting time:

/wp-content/uploads/2014/09/eaches_542232.png

As we can see here, a little effort in documenting will help out your BIAL scripters know what the method does, so as we see in this tooltip, it does (or should do) what I mentioned, which is a for loop.  Let’s click the Button and see what the results are at runtime:

/wp-content/uploads/2014/09/eaches2_542233.png

Looks like it’s working!  🙂

As far as my experience with pulling down Karol’s repository, that’s easy.  I suggest using ‘GitHub for Windows’ unless you are a big PowerShell fan, the GUI version is very easy to use.  Here’s the main interface, with some of my own repos aas well as Karol’s:

/wp-content/uploads/2014/09/eaches3_542243.png

I right-clicked his repository, and cloned it to a location on my hard drive.  Next, I switched to my Eclipse SDK and went to File -> Import… and browsed to the location and chose the subfolder containing the project I wanted to import.  In this case, it was ‘org.kalisz.karol.scn.pack’.  I unchecked ‘Copy projects into workspace’ since I wanted it to stick with the Git repo clone location.  Below is an example of what an Eclipse project looks like when it senses there is a Git repo associated with it.

/wp-content/uploads/2014/09/eaches4_542286.png

I then made modifications mentioned at the beginning of the blog to the contribution.ztl file.

Once I was done coding and testing on my local repo, I wanted to commit the changes back to Github.  After fumbling around, I found the context menu path to do so:

/wp-content/uploads/2014/09/eaches5_542288.png

I was then prompted to describe my change, which I said “Added ‘eaches’ method to Karol’s Array component.” and then clicked ‘Commit and Push’.

When switching back to my GitHub for windows, I could see the changes in the history, as well on on the web.  Success!

/wp-content/uploads/2014/09/eaches6_542289.png

I’m sure for GitHub veterans, this is child’s play but for me this was easier than I expected.  There’s a bunch of other stuff I’m sure GitHub is good at doing indicated in the context menu screenshot, but this was good for now 🙂

To report this post you need to login first.

5 Comments

You must be Logged on to comment or reply to a post.

  1. Dirk Mayrock

    Hi Michael,

    good to see you and Karol working together now…. I’m very excited to see the results of this co-work in future. Many cool new SDK components 🙂

    Dirk

    (0) 
  2. Karol Kalisz

    great job Michael,

    I have now created the version 1.0.9 with this content.

    Release Improvement in Colleaction & Array, KPI View Component · KarolKalisz/DesignStudioSdkPack · GitHub

    Also, valid point to the documentation – I documented all methods in COLLECTION and ARRAY.

    last, I have created a bundle where we can externalize all “SCN” defined objects, like the array or some enum – just to assure long term exchange between objects..

    what next on your side? I will make a KPI tile on UI5 basis as response to Problem regional formats setting

    (0) 
    1. Mike Howles Post author

      I’ll probably be pretty dormant until next week, however I’d like to do some sort of data visualization collaboration using an SVG or Canvas library or even just raw Canvas/SVG JS.  Not sure what form it would be, something besides a chart.  A trip to the  bar is in order to get creative thoughts going…  😀

      (0) 
  3. Elias Mistler

    Hi there,

    I have been looking into your utilities, mainly the Array Util.

    I understand that you cannot use Arrays directly in sdk properties. I also understand how you use a String to store your array data, just like a CSV file (clever workaround, by the way). Analyzing your utility, I learned that it is possible to use more data types in contribution.ztl file than in contribution.xml (e.g. StringArray).

    However, one question remains: Where is org.scn.pack.StringArray defined? I can’t seem to find it and my DesignStudio installation details and PlugIn folder say nothing about org.scn.pack. But you use it in your Array Util and it works…

    I have installed:

    – org.kalisz.karol.* (5 packages)

    – com.sample.utilities

    – my own package, which is still in development

    Could you help me by telling me, where this is defined?

    By the way: GitHub really looks very comfortable to use. However, I recently found out a different way to share the code with my colleagues, which might interest you:

    Use NetWeaver Platform as a Code Repository for Design Studio SDK

    (0) 
    1. Karol Kalisz

      Hi,

      yes, you can use any object types which are defined. you just to need assure the content is matching the type.

      the org.scn.pack.StringArray is in the package: org.scn.pack (and this is in bundle org.kalisz.karol.scn.constants)

      DesignStudioSdkPack/contribution.ztl at master · KarolKalisz/DesignStudioSdkPack · GitHub

      if you want to write component which is compatible to ours implementation, you should use the same, but then you would have dependency to this bundle (which is delivered in my feature).

      Karol

      (0) 

Leave a Reply