I'm trying to access the
<chart:guide>
value property from the screen controller, but I can't find any getter to reach it. The xml block is like this:
<chart:valueAxes>
<chart:axis position="LEFT"
stackType="REGULAR"
title="Graph Title">
<chart:guides>
<chart:guide
value="0"
inside="true"
lineAlpha="1"
/>
</chart:guides>
</chart:axis>
</chart:valueAxes>
I need to set the value of the guide at runtime. Any suggestion?
Let's say we have the following SerialChart:
<chart:serialChart id="serialChart"
caption="Serial chart"
height="100%"
width="100%"
categoryField="x">
<chart:graphs>
<chart:graph valueField="y"/>
</chart:graphs>
<chart:valueAxes>
<chart:axis position="LEFT">
<chart:guides>
<chart:guide value="12"
inside="true"
lineAlpha="1"/>
</chart:guides>
</chart:axis>
</chart:valueAxes>
<chart:data>
<chart:item>
<chart:property name="x" value="10"/>
<chart:property name="y" value="12"/>
</chart:item>
<chart:item>
<chart:property name="x" value="11"/>
<chart:property name="y" value="2"/>
</chart:item>
<chart:item>
<chart:property name="x" value="12"/>
<chart:property name="y" value="120"/>
</chart:item>
<chart:item>
<chart:property name="x" value="13"/>
<chart:property name="y" value="16"/>
</chart:item>
</chart:data>
</chart:serialChart>
You can simply get ValueAxis and then get Guide object by index or iterate collection and find by id (optional attribute of Guide):
#Inject
private SerialChart serialChart;
ValueAxis valueAxis = serialChart.getValueAxes().get(0);
Guide guide = valueAxis.getGuides().get(0);
guide.setValue(15);
serialChart.repaint();
Note, if we want to change already displayed chart configuration then we have to call repaint() method.
If you use CUBA 6.4 or older, you have to obtain Configuration object first using getConfiguration() method and cast it to appropriate chart type as shown here: https://doc.cuba-platform.com/charts-6.4/cdp_screen_controller.html
Related
I am using log4net and I am trying to figure out the best way, or if there is anyway, to bind custom fields to the LoggingEvent object, that is used in the Append override method of the AppenderSkeleton.
For example, this could be a guid property to add to the other properties such as level, renderedMessage, etc.
However, I am planning on using the Log4net.Appenders.Fluentd with the log4net.Ext.Json, so the appender in the xml would look something like this:
<appender name="Fluentd" type="Log4net.Appenders.Fluentd.FluentdAppender, Log4net.Appenders.Fluentd">
<Host>127.0.0.1</Host>
<Port>24224</Port>
<Tag>YourTagHere</Tag>
<NoDelay>false</NoDelay>
<ReceiveBufferSize>8192</ReceiveBufferSize>
<SendBufferSize>8192</SendBufferSize>
<SendTimeout>1000</SendTimeout>
<ReceiveTimeout>1000</ReceiveTimeout>
<LingerEnabled>true</LingerEnabled>
<LingerTime>1000</LingerTime>
<EmitStackTraceWhenAvailable>true</EmitStackTraceWhenAvailable>
<IncludeAllProperties>false</IncludeAllProperties>
<!--json formatted log4net logging-->
<layout type="log4net.Layout.SerializedLayout, log4net.Ext.Json">
<decorator type="log4net.Layout.Decorators.StandardTypesDecorator, log4net.Ext.Json" />
<member value="date:date" />
<member value="level:level" />
<member value="message:messageObject" />
</layout>
</appender>
I was hoping there would be something like this in the end:
<!--json formatted log4net logging-->
<layout type="log4net.Layout.SerializedLayout, log4net.Ext.Json">
<decorator type="log4net.Layout.Decorators.StandardTypesDecorator, log4net.Ext.Json" />
<member value="date:date" />
<member value="level:level" />
<member value="message:messageObject" />
<member value="guid:guid" />
</layout>
Is this something I would have to some how carry out in the Log4net.Appenders.Fluentd source code?
You can use the ThreadContext to add a custom property to the LoggingEvent object that is passed into the Append override method of the AppenderSkeleton and the Format override method of the LayoutSkeleton.
Set it:
ThreadContext.Properties["my_custom_prop"] = "my custom property"
Then retrieve it:
var prop = evt.GetProperties()["my_custom_prop"].ToString();
I oftentimes need to create builder methods in my code. These methods are similar to getters, but they return this and they use with instead of get.
To be faster with that task I'd like to create a live-template in IDEA.
This how far I got:
(in ~/.IntelliJIdea14/config/templates/user.xml this looks like this:)
<template name="builderMethod" value="public $CLASS_NAME$ with$VAR_GET$(final $TYPE$ $PARAM_NAME$) {
this.$VAR$ = $PARAM_NAME$;
return this;
}" description="create a builder method" toReformat="true" toShortenFQNames="true">
<variable name="CLASS_NAME" expression="className()" defaultValue="" alwaysStopAt="true" />
<variable name="VAR" expression="complete()" defaultValue="" alwaysStopAt="true" />
<variable name="PARAM_NAME" expression="VAR" defaultValue="" alwaysStopAt="true" />
<variable name="TYPE" expression="typeOfVariable("this." + VAR)" defaultValue="" alwaysStopAt="true" />
<variable name="VAR_GET" expression="capitalize(VAR)" defaultValue="" alwaysStopAt="true" />
<context>
<option name="JAVA_EXPRESSION" value="false" />
<option name="JAVA_DECLARATION" value="true" />
</context>
</template>
This nearly works, except for typeOfVariable("this." + VAR) which does not. I just guessed how to call this method, because I could not find any documentation on the syntax used in the expressions except for this page which does not even mention a script language name or something that would make googling for easier.
How do I fix the call to typeOfVariable?
Bonus question: How can I get complete() for VAR to only show fields?
Similar question but not does not even have a start: Live Template for Fluent-API Builder in IntelliJ
Replace typeOfVariable("this." + VAR) with typeOfVariable(VAR).
Edit:
Another way to generate builder methods is to use an appropriate setter template (instead of live template).
https://www.jetbrains.com/help/idea/2016.1/generate-setter-dialog.html
There is already a built-in setter template named "Builder" which generates setters such as:
public Foo setBar(int bar) {
this.bar = bar;
return this;
}
You can create your own template (e.g by copying it) and change it so that the method prefix is with.
And to make the generated method parameter final go to settings:
Editor | Code Style | Java
Select the Code Generation tab
Tick Make generated parameters final
IntelliJ IDEA add final to auto-generated setters
Width this code i can define content:
<flux:flexform.section name="columns">
<flux:flexform.object name="column" label="column">
<flux:flexform.field.input name="demo" label="Demo field" />
</flux:flexform.object>
</flux:flexform.section>
<flux:flexform.grid>
<flux:flexform.grid.row>
<f:for each="{columns}" as="sectionObject" iteration="iteration">
<flux:flexform.grid.column>
<flux:flexform.content name="column{iteration.cycle}" label="Column {iteration.cycle}" />
</flux:flexform.grid.column>
</f:for>
</flux:flexform.grid.row>
</flux:flexform.grid>
This is flexible. I can Add new "Content Areas" through the section. But this is not what I want. I Want to define a very fixed two-column and a three-column FCE. My editor should not have to decide how many columns to use.
I am missing something like:
<flux:flexform.field.contentArea name="col1" label="Column 1" />
<flux:flexform.field.contentArea name="col2" label="Column 2" />
<flux:flexform.grid>
<flux:flexform.grid.row>
<flux:flexform.grid.column>
<flux:flexform.content name="col1" />
</flux:flexform.grid.column>
<flux:flexform.grid.column>
<flux:flexform.content name="col2" />
</flux:flexform.grid.column>
</flux:flexform.grid>
</flux:flexform.grid.row>
Thank you for your hint to the right direction.
You are very close to the solution with the code you already have. In this example I will use the new ViewHelper names - but you can get the same result using the old names as in your example. Which is which, should be easy to spot (note: you had a typo in your code example which I edited, rgid used instead of grid - such a typo would cause Flux to error out):
<flux:grid>
<flux:grid.row>
<flux:grid.column>
<flux:content name="col1" label="Nice name for column 1" />
</flux:grid.column>
<flux:grid.column>
<flux:content name="col2" label="Column 2" />
</flux:grid.column>
</flux:grid>
</flux:grid.row>
And remove the flux:form.section with object inside it - you don't need this when you make a statically defined grid.
Then to render this grid:
<flux:content.render area="col1" /> and so on.
There is an example on Adobe livedocs for using states:
<!-- Define one view state, in addition to the base state.-->
<mx:states>
<mx:State name="Register">
<mx:AddChild relativeTo="{loginForm}" position="lastChild">
<mx:target>
<mx:FormItem id="confirm" label="Confirm:">
<mx:TextInput/>
</mx:FormItem>
</mx:target>
</mx:AddChild>
<mx:SetProperty target="{loginPanel}" name="title" value="Register"/>
<mx:SetProperty target="{loginButton}" name="label" value="Register"/>
<mx:SetStyle target="{loginButton}"
name="color" value="blue"/>
<mx:RemoveChild target="{registerLink}"/>
<mx:AddChild relativeTo="{spacer1}" position="before">
<mx:target>
<mx:LinkButton id="loginLink" label="Return to Login" click="currentState=''"/>
</mx:target>
</mx:AddChild>
</mx:State>
</mx:states>
I haven't been able to find the purpose of mx:target in
<mx:AddChild relativeTo="{spacer1}" position="before">
<mx:target>
<mx:LinkButton id="loginLink" label="Return to Login" click="currentState=''"/>
</mx:target>
</mx:AddChild>
Does anyone know what that does and if it is necessary? It seems to be unnecessary.
Looks like I over-thought this one a bit. Turns out target is just the target child you are adding and that is just another way to define it as opposed to defining it as an inline attribute to the AddChild tag.
I have a sequence of SetProperty actions which rely on each other. Here is a simplified example:
<SetProperty Id="A" Before="AppSearch" Value="Hello" />
<SetProperty Id="B" Before="AppSearch" Value="[A] world!" />
Property A needs to be set before property B in this case, so that the value of B becomes "Hello world!".
Since WiX doesn't define an attribute to set the custom action name in this case, I don't have a name to use in the Before or After attributes.
I did notice that the execution order of these actions matches the alphabetical order of the property names, but that feels like an implementation detail that I should not rely on.
How do I cleanly enforce the order of SetProperty custom actions?
You can also use the “Action” attribute of the SetProperty element to nail down the name of the custom action. This becomes essential if you wish to set the same property in two distinct SetProperty actions as it removes ambiguous “SetXXX” action names.
For example:
<SetProperty Id="A" Action="MyFirstAction" Before="AppSearch" Value="Hello" />
<SetProperty Id="B" Action="MySecondAction" After="MyFirstAction" Value="[A] world!" />
<SetProperty Id="A" Action="MyThirdAction" After ="MySecondAction" Value="Goodbye cruel world!" />
I used orca to discover the names generated for the custom actions. They turn out to be SetA and SetB. The following does what I want:
<SetProperty Id="A" Before="AppSearch" Value="Hello" />
<SetProperty Id="B" After="SetA" Value="[A] world!" />