I have a report that will require chunks of text (that will be created dynamically) to be embedded from a Java program that runs the report.
Is there a way I can put a text object into the design and then somehow get hold that of that object in my Java program. If this is possible I assume I would be able to insert text into that text object.
Is this the best way to do this?
A code snippet would be gratefully accepted.
Thanks in advance.
You can easily do this by using Java Event Handlers. Any event in the generation process can be modified either by JavaScript (stored on the report design itself) or via a POJO when more complex processing is needed.
Add a TextItem to your report. This will be the intended destination for your block of text. You can add other types of controls and interact with them the same way, TextItem just seems to make sense for this particular question. Add anything you want to the text item, we are going to over-ride the value from the POJO anyway.
Now create a POJO that implements the TextItemEventAdapter interface (this should be in your BIRT distribution). You can then choose what event to bind your POJO to. onCreate probably makes the most sense. To do that, implement the onCreate method from the interface.
/* (non-Javadoc)
* #see org.eclipse.birt.report.engine.api.script.eventadapter.TextItemEventAdapter#onCreate(org.eclipse.birt.report.engine.api.script.instance.ITextItemInstance, org.eclipse.birt.report.engine.api.script.IReportContext)
*/
#Override
public void onCreate(ITextItemInstance text, IReportContext reportContext) {
super.onCreate(text, reportContext);
text.setText(getText());
}
In the above snippet, the getText() method is another method on your class that builds your text block. Implement your business logic here.
Once you have built the class, you need to bind it to the report's text item control. On the report, select the text item. Under "Properties" look for "Event Handler". Here you can add your POJO as the event handler for the control. When the control is rendered, your POJO will now supply the text.
To ease development, have your Java Project and your BIRT project in the same workspace. This will allow the report and the POJO to see each other enabling testing and debugging inside Eclipse.
Here is a lot more background about report events and event handling: http://www.eclipse.org/birt/phoenix/deploy/reportScripting.php
Good Luck!
Related
In my Vaadin (v.23.2.6) application I am creating a bean of class Book. This bean has set of tags.
Tags are retrieved from the database and contain two properties - tagName and tagDescription.
In my UI form I specified MultiSelectComboBox for Tags.
this.tagsField = new MultiSelectComboBox<>("Tags");
this.tagsField.setAllowCustomValue(true);
this.tagsField.setAutoOpen(false);
this.tagsField.setItemLabelGenerator(Tag::getTagName);
It is working, but I do want to display value of tagDescription when cursor is hovering over the tagName in the selection list.
What kind of event listener I can use for that purpose? Shall I use Notification or there is something else that can help me with this implementation?
Please advise.
While it's technically possible, you don't want to listen to hover (mouseover) events on the server. That's overkill and will lead to a lot of unnecessary network traffic. Instead, you can take care of it in the client with a Renderer. For example, using the standard HTML title attribute:
tagsField.setRenderer(LitRenderer.<Tag>of(
"<span title='${item.description}'>${item.name}</span>")
.withProperty("description", Tag::getTagDescription)
.withProperty("name", Tag::getTagName)
);
I have a sap.m.TabContainer control with multiple sap.m.TabContainerItem controls. Each of the TabContainerItem controls have a number of their own controls on them. I have created a custom control (DBPanel) with a label and text field. It also has an enabled property for which I have overridden the setEnabled(boolean) method to enable/disable the internal text field within DBPanel. There are five (5) of these DBPanel controls on a specific TabContainerItem. When I call setEnabled(true) on each of these DBPanels, only three of the five become enabled. When I switch to another TabContainerItem and then back to this one, the final two DBPanels are also enabled. It is almost as if the TabContainerItem needs to be re-rendered. But I have read elsewhere that if rerender or invalidate need to be specifically called then there is something wrong with the code.
Any help would be appreciated.
Thank you
At your overridden method, you can try to call the original method that is extended. If you don't need extra logic rather than disabling or enabling it, you don't need to extend that method but I guess you have some.
First check whether superclass implements the method and then call the
method with the original arguments
if (DBPanel.prototype.setEnabled)
DBPanel.prototype.setEnabled.apply(this, arguments);
The documentation just shows that an xml configuration property exists for visibility, but doesn't show how to use it. The documentation for the command line equivalent shows:
–visibility[=”...”]
Provide a comma-separated list of visibility scopes to parse.
This parameter may be used to tell phpDocumentor to only parse public properties and methods, or public and protected.
There are private properties that are showing up in my documentation and I'd like to hide them. I've tried <visibility>public</visibility> but it appears to have no effect.
Update
I'm currently using the default template. It both lists the private methods and shows a "Private Methods" section on the template.
If that --visibility flag is not working, it must be a bug. Then again, it's possible that some output templates display the three visibility view toggles even if the document generation execution was run with only "public" being enabled.
In the resulting docs you've generated with a particular template, are you still seeing all three visibility buttons showing? If so, enable the private and protected buttons, then see if any private/protected properties/methods actually do become visible. It might be that you are getting only public things documented, but just still seeing the private/protected toggle buttons in the view.
This works for me --visibility="public"
The visibility element works. Put inside
<parser>
<visibility>public</visibility>
<target>docs/api</target>
</parser>
Totally new to custom control creation in Silverlight.
I'm wanting a custom control that inherits from a TextBox control. I've found plenty of tutorials but they all do something like watermarked text or other attached properties. My goal is only to manipulate text at time of entry using the KeyUp event, so visually my TextBox is no different from a standard TextBox.
I created a class file and inherited from TextBox, but at run-time the textbox doesn't display. From what I can gather I need a themes/generic.xaml file, but all of samples I've seen include styles for the additional properties, and in my ignorance I don't know what to change and/or remove.
I'm hoping someone can point me to a generic plain-jane TextBox style definition or a tutorial of such.
What you described should work, I just tried the following and the TextBoxEx renders just fine:
public class TextBoxEx : TextBox
{
protected override void OnKeyUp(KeyEventArgs e)
{
base.OnKeyUp(e);
}
}
You do not need to add a generic.xaml file. This file is used to provide a template which defines the look of your control. You specify the default look of your control by setting the following property:
DefaultStyleKey = typeof(MyControl);
However, as the above TextBoxEx does not set this property, it uses the value inherited from TextBox and hence it inherits the same template (i.e look).
I am currently writing unit tests for a ViewModel in my project that uses Prism and the MVVM pattern.
My view mainly consists of an ItemsControl that reacts to different mouse events (LeftMouseButtonDown, LeftMouseButtonUp etc.). When such a mouse event happens the EventArgs and some other glue info is handed to the ViewModel and an appropriate method is called (MouseMove event --> OnMouseMove method).
This way I implemented a way to drag items that were formerly added to the ItemsControl around. That happens through setting two member variables "movingObject" and "gripPoint" in the OnMouseLeftButtonDown method and setting the variables to null in the OnMouseLeftButtonUp method.
The question that now arises is if I should unit test these functions (LeftButtonUp, LeftButtonDown). In theory they are accessed by the "outer" world (--> not by the ViewModel itself) and therefore deserve a test but how should I test the change of an private variable that (in my opinion) doesn't deserve a public accessor (for the low level purpose it exists)?
Thanks in advance!
Creating accessors could work for you. Please see the links below:
http://msdn.microsoft.com/en-us/library/ms184807(VS.80).aspx
http://www.xheo.com/Blog/post/Manually-creating-a-Visual-Studio-accessor-file.aspx