How to implement copy and paste tree of graphic items - object

I am working in graphical application that uses objects and groups. So, items can be grouped in a group. A group can contain other groups and items.
To copy the items and groups I produce an XML describing such items and groups and send the information to the clipboard, for example:
<!DOCTYPE tnkClpObjData>
<tnkItems>
<tnkGroup id="003">
<tnkItem>
<PluginName>Ellipse</PluginName>
</tnkItem>
<tnkItem>
<PluginName>Rectangle</PluginName>
</tnkItem>
<tnkGroup id="002">
<tnkItem>
<PluginName>Rectangle</PluginName>
</tnkItem>
<tnkGroup id="001">
<tnkItem>
<PluginName>LineEdit</PluginName>
</tnkItem>
<tnkItem>
<PluginName>Label</PluginName>
</tnkItem>
</tnkGroup>
</tnkGroup>
</tnkGroup>
</tnkItems>
For pasting the items I know I need to use the XML but what would be the best way to implement it? Do I first create the items and then the group? or do I need to navigate the tree from the deepest item up to the first?
Thanks,
Carlos.

I used recursive functions for this.

Related

WebPart cleanly render a list of n items

I am attempting to create a WebPart in Kentico 11 that supports handling an n-length list of items. I found that creating a WebPart with property fields is pretty straightforward in Kentico, but I am having trouble finding documentation on how to best set up a WebPart that can lookup & output multiple model objects.
I've tried the following approach, but it has some drawbacks that I'm not entirely comfortable with:
Set up a Container page type to place instances of data objects inside. I restricted it to ensure that only my custom Page Type data object is available as a child of it.
Place a Pages DataSource in the template zone and direct it to the Container page.
Hook up a Repeater element to it and apply a transformation & content before+after to the Repeater.
While this works, it feels a little cludgey. Content editors have to be wise enough to know how to set up DataSources & Repeaters, plus how to bind them together and apply transforms, and additionally remember to fill in the content before and content after fields with the appropriate wrapping HTML markup.
This is not something that I expect a content editor should need to remember.
Is there a cleaner way to put lists of items inside of a template zone without needing to drag & configure a datasource and container page?
I did not see any way to set up a Page Type field in such a way that it would essentially model a one-to-many relationship with another Page Type. Did I miss something there? If I could do that, then I could write a transformation to handle the wrapping HTML markup, and the looping of children. Haven't been able to find a way to make this work though.
The best way to accomplish what you are asking is with a custom form control. In your case, the form control should be able to let users select multiple items.
You can actually use 'Sortable multiple object selector' marketplace item for this purpose. This form control will enable you to select multiple items based on a certain type (that you need to configure in code) and editors would simply use the select dialog to choose the items.

Select a single document from Multiple Document Selector Kentico

I am using a Multiple Document Selector field on one of my document types, so the user can select many documents they like.
Now I would like to loop through each of those documents and apply some HTML tags, my current solution applies the same rule to all of those documents, what I need to be able to do is find the second document that has been selected on the multiple document selector and apply a different rule!
Does anyone know how I can find the second element or any single element from the multiple document selector control.
Hope someone can help me.
Thank you
The Multiple Document Selector is not a standard Kentico control so I don't know how the value is stored but I guess it's something like comma-separated list of NodeAliasPaths. E.g.:
/News/News-1, /Products/Phones, /Services
In that case you can use K# macro:
Documents["/Page"].MutipleDocumentField.Split(",")[0]
// Selects the first document in MultipleDocumentField on page with NodeAliasPath == "/Page"
or
CMSContext.CurrentDocument.MutipleDocumentField.Split(",")[1]
// Selects the second document in MultipleDocumentField on the current page
Macros can also use loops and have lots of built-in methods. See the documentation or the following example:
{% foreach (x in Documents["/Home"].SubmitText.Split(",")) {""+x+""} %}
In my case it generates the following HTML:
/Partners
/News
/Services
You can use macros in all web part fields. Try inserting the code e.g. to static text web part.

RescorerProvider filter element by tag

Is it possible to create a RescorerProvider to filter out elements which are associated with a specific tag? Or should I implement an own model with relevant data as in the book "mahout in action" on page 79?
Route: /recommend/?rescorerParams=sports
Push score of elements which are associated with tag sports
For this you would have to separately track which items are associated to which tags. This information is not queryable within the server itself. But you can periodically cache this info from an external source and then apply whatever logic you like based on tags. Yes, it is kind of like what's in Mahout in Action.

how to render custom layout of the projection of known content items

I have defined my own projection by a query which returns a set of content items of known content type. I would like to take pick up certain content parts of these content items and display them in the list. Using shape tracing tool I have found the view template where to write my custom layout:
/Views/Parts.ProjectionPart.cshtml
but from the Model variable in the template I can not get the data I want because it is way too high above from the content parts data.
a good example of what I want: let's say I want to render product catalog as defined in this tutorial:
http://skywalkersoftwaredevelopment.net/blog/writing-an-orchard-webshop-module-from-scratch-part-5
but I want only to render a list which consists from items:
name of the owner who created the product
name of the product.
publish date of the product
and I need to render it at one place, i.e., not separately in their own part views.
Have you tried adding a layout in the projector module? There is a properties mode option that lets you select which fields/data to show. If the data you want is not there, you should be able to implement an IPropertyProvider. There are examples of this in the Projections module code.

Modify sharepoint view to group recursively (subgroup)

When creating a view and setting group by value some field, it groups only 1 level deep, like this
A
--A.1
--A.2
A.2
--A.2.1
--A.2.2
B
--B.1
However i would like to group it to make a tree, a hierarchy.
A
--A.1
--A.2
----A.2.1
----A.2.2
B
--B.1
A flawless solution would be if i could just make my custom views to view a recursively grouped items.
Any ideas how to achieve that?
It should look something like this:
alt text http://img6.imageshack.us/img6/1958/ss20090703135209.png
You would need to build your own ListView Webpart. However, there is already a third party product that does this, the Bamboo Solutions tree View WebPart
You will need to get the data from maybe a content query web part and format it with your own XSLT.
XSL is not the easist to do this with as it has no "stack" structure for easily nesting a linear list.

Resources