Access node's properties/children from inline template - mps

I have a template switch where, based on the node's concept, I want to create runtime objects using that node's properties and/or children. The right-hand side of each case is an inline template. How do I access node's properties/children from that inline template? More specifically, in the screenshot below, the arguments to the line() and rectangle() methods need to be extracted from the corresponding LineCommand and Rectangle nodes.
Note that the Alt+Enter menu doesn't offer to "Add a Property Macro".
I am using MPS 2018.1.5.

In order to extract an argument from the node's children you need to add the template argument (e.g. "null") and then put the macro on it. Then in the process of generation, the template argument (null) will be replaced with the generation target of the node's children.
If you want to use the node's property, then you should add a more specific argument (e.g. empty string) and put the caret to the property cell (between the quotes) and then you will see the "Add Property Macro" intention
template argument
template argument with the property
add property macro

Add a dummy argument first and then use Alt+Enter on the argument to add a macro to replace it with something from the node.

Related

How to add a new method in Pharo?

In the Nautilus System Browser (Pharo 6) there's a right-click command to Add package... as well as Add class... and even Add protocol..., but I can't find anywhere a way to Add method....
Where is that command?
In Pharo, adding a method is not as explicit as the other elements. To add a new method:
Select the protocol for the method, and you should see a template in the editor pane:
messageSelectorAndArgumentNames
"comment stating purpose of message"
| temporary variable names |
statements
Edit this template to make a new method,
Save (Right-click Accept) it using Ctrl-S.
In fact, any time you change a method's definition (e.g., messageSelectorAndArgumentNames) and save it in the editor (Right-click Accept or Ctrl-S), it will create a new method.
For more details, see the section 1.3 of Developing a simple counter document (emphasis is mine):
Create a method
Now let us create the accessor methods for the instance variable count. Start
by selecting the class Counter in a browser, and make sure the you are editing the instance side of the class (i.e., we define methods that will be sent to
instances) by deselecting the Class side radio button.
Create a new protocol by bringing the menu of methods protocol list. Select
the newly created protocol. Then in the bottom pane, the edit field displays
a method template laying out the default structure of a method. As a general
hint, double click at the end of or beginning of the text and start typing your
method. Replace the template with the following method definition:
count
"return the current value of the value instance variable"
^ count
This defines a method called count, taking no arguments, having a method
comment and returning the instance variable count. Then choose accept in
the menu to compile the method.

How do I completely remove the label or the label's spacing in angular-formly form?

Using angular-formly, I'm trying to build a form, where if the label is removed in fields json, there is no padding or spacing given to the that label in the rendered html.
Here is an example of the actual form and my 'desired' form:
JS Bin
The best solution would require a pull request to the template library's label wrapper template which would use an ng-if to hide the label if one is not provided.
If you don't want to deal with that, then you can choose from one of these options:
Set wrapper to null for the field. But you lose the other wrappers as well (like the one that adds has-error)
Create your own type that allows you to specify your own wrappers.
Both of these are demonstrated here:
https://jsbin.com/quceqi/edit?html,js,output

Passing variables to menu

Is there a way to pass a variable set on a page to a menu that is displayed on that page?
For example, if I have a template that sets a variable to true or false, for instance, and that page includes a header, which in turn displays a menu, is there any way for me to use that variable in the menu?
Thank you in advance!
Hopefully this should help.
The menu helper function takes three parameters.
1. The menu name
2. The menu template to use
3. An array of parameters that get passed to the template.
Ordinarily you will use {{menu('main-nav')}} but you can also use {{menu('main-nav', '_sub_menu.twig', {'varname':'varval'})}}
That will now make the varname variable available in the menu template.

How do you use the Selected property of the navigator?

I've spent days trying to figure this out and I give up.
I am a LotusScript programmer and have been trying to learn XPages. All of the examples and sample programs I've studied only touch on pieces of this.
Can someone explain to me step by step how to use the Selected property of the Extension Library Navigator control?
I have created my own custom control based on the layout control from the Extension Library and created a custom property called navigationPath. I also created a navigator custom control that has 5 Page Link Nodes. In the "Selected" property of each Page Link Node, I put the following SSJS:
if(compositeData.navigationPath == "/Home/ApplicationPool"){
return true
}else{
return false
}
/Home/ApplicationPool corresponds to the value I put in the "Selection" property of the particular Page Link Node.
In each layout custom control, I set the "navigationPath" property to compositeData.navigationPath.
What did I miss?
there is a selected and selection property and they mean very different things and can't be used at the same time. In the code example in your question above you are using the selected property which is the wrong one in this case.
Your treeNodes in the navigator should be setup to use the selection property, this is a RegEx value that is used to see if it matches the value passed into the application layout via the custom property.
<xe:navigator id="navigator1" expandable="true" expandEffect="wipe">
<xe:this.treeNodes>
<xe:pageTreeNode label="nodeName" page="/page.xsp" selection="/Home/ApplicationPool" />
</xe:this.treeNodes>
</xe:navigator>
As you can see you don't need to use any SSJS to evaluate a true/false outcome. Just match the value in the treeNode to the one in the XPage's applicationLayout control.
If your using tabs in the layout titleBar then you can set a selection property there also that uses the format /Home/.* which will make that tab highlighted for every XPage that have /Home/ at the start of it's navigationpath custom property. Don;t forget it is RegEx so any valid RegEx statement can be used here adding more power to this particular property.
For the tree nodes in the navigator control you define the name of the xpage to open and then the related selection. Example:
<xe:pageTreeNode page="/text.xsp" selection="/Home/Test" label="Test page">
</xe:pageTreeNode>
For the individual xpages using the applicationLayout you define a value for navigationPath. If this value matches an entry in one of the tree nodes the naviagor control, then the corresponding menu item will be highlighted in the browser. The best way to define the value of the navigationPath is by using a custom property (as you are using). Here's an example of that:
<xe:applicationLayout id="applicationLayout1">
<xe:this.configuration>
<xe:oneuiApplication navigationPath="${javascript:compositeData.navigationPath}" ...
You can see examples of using all this in the Extension Library Teamroom and Discussion templates.
Based on my explanation on how to use it, I can see that you are not using the selection property on the navigation control correct. You just need to define a unique value for each tree node (which then will be used if it matches navigationPath on the individual xpages).
So for your specific example change your selection property to just return: "/Home/ApplicationPool"

Replacing Views2 base field handler

I want to add some rendering options to Views2 field handler (similar to 'Output this field as link' or 'Rewrite the output of this field') for a greater control over rendering of HTML markup (I need to add some extra attributes to tags). I want this additional options to be available for all (or at least most of the fields). Is it possible to replace default Views2 field handler (i.e. views_handler_field class) with my own field handler? There is a hook for submitting own handlers (hook_views_handlers) and there is a hook to tell other modules what handler should be used for given field (hook_views_data_alter). I also don't see a way to override default inheritance pattern for view_handler_field and its descendants. And extending every single field handler provided by other modules with my own classes seems to be pointless. Am I right saying that this cannot be the right way to solve this problem?
If I am right, what is another way to (1) extend field options form with some inputs and (2) alter rendering of this field based on inputs. I guess (1) could be achieved by altering form by default Drupal hook, but render method belongs to given field handler and I don't see a way to intercept its call and output altered markup.
In theory you could use a non-existant hook_views_handlers_alter to change the path of a class which is somewhere

Resources