javafx new "screen" in same tab - javafx-2

I have a piece of code like this :
<Tab text="A" fx:controller="myController" xmlns:fx="http://javafx.com/fxml">
<content>
<VBox>
<children>
<fx:include fx:id="topTab" source="../top-tab.fxml"/>
<AnchorPane prefHeight="600" VBox.vgrow="ALWAYS">
<!-- insert code here -->
</AnchorPane>
<AnchorPane id="bottom_anchor" prefHeight="250" />
<fx:include fx:id="bottomTab" source="../bottom-tab.fxml"/>
</children>
</VBox>
</content>
</Tab>
Right now, the 'insert code here' part has a list of links to youtube videos. The idea is, when the user clicks on one of these links, to show IN THE SAME AnchorPane the video and the list disappears. It would be like another screen (with a nice transition if possible) that appears while the list disappears, all inside this AnchorPane as I need to stay there.
I have thought about using a StackPane and making things visible or invisible as needed, but that seems... strange.
As I am new to JavaFX, any answer explained as to a 9-year-old would be appreciated
Thank you all !

Easiest way I think is to add 2 AnchorPanes inside the AnchorPane you already have. Let's call them pList and pContent. Then play with the visible property of them.
To make a nice transition you can do something like this:
FadeTransition showTransition = new FadeTransition(Duration.seconds(.1), pList);
showTransition.setFromValue(0.0f);
showTransition.setToValue(1.0f);
showTransition.play();
Do it the other way for pContent.

Related

Xamarin.Forms styles causing WeakReference leak

I've been spending a lot of time trying to track down memory leaks in our Xamarin.Forms app on Android. After a lot of blind alleys and false dawns, I think I may have come across something which is causing the problem.
Using Xamarin Profiler, I can see that as soon as I create a Style and apply it to a control (or in fact just an implicit style), we get Multiple WeakReferences remaining 'Live' - i.e. not garbage collected.
Note that I assume that the objects to which they refer have been GC'd (because the reference to the object is weak), but the WeakReferences themselves are remaining.
Now of course WeakReferences are small I know - but when you have hundreds created on every iteration of a page push/pop, then the memory adds up and we have a significant leak.
Here are the details.
Using Xamarin.Forms 2.3.4.270 (we haven't upgraded because we want to keep with known issues!)
Running on Android - physical device.
App.xaml:
<?xml version="1.0" encoding="utf-8"?>
<Application xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:ProfiledFormsApp2;assembly=ProfiledFormsApp2"
x:Class="ProfiledFormsApp2.App">
<Application.Resources>
<ResourceDictionary>
<Style TargetType="Label">
<Setter Property="FontSize" Value="Large" />
<Setter Property="TextColor" Value="Blue" />
</Style>
</ResourceDictionary>
</Application.Resources>
</Application>
Page XAML:
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage Title="Plain Page" xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="ProfiledFormsApp2.PlainPage">
<ContentPage.Content>
<StackLayout>
<StackLayout Orientation="Horizontal">
<Label Text="Core Navigation"/>
<Label Text="Number of items:" />
<Label Text="{Binding ItemsCount}" />
</StackLayout>
</StackLayout>
</ContentPage.Content>
</ContentPage>
When I navigate to the above page and back 3 times, we have the following WeakReference (and related) classes created - the screenshot below is from a Profiler snapshot.
Note we have 55 WeakReferences. Drilling into these shows:
What is interesting is that these WeakReferences seem to be created as part of Behavior and Trigger attaching. Looking at the call tree for the top one gives:
So it appears that the WeakReference was created as part of setting a BindableObject's value and the subsequent setting of the Style.
And it also appears that the WeakReference is still in memory and being referenced by something - the Behavior collection?
Using Profiler, I'm can see that we don't have Labels remaining un GC'd. It seems to be something in the Theme/Behavior/Trigger processing.
I haven't looked at the Xamarin.Forms code on GitHub yet - that might have to be my next action.
Has anyone observed this or got a solution?
I am not sure about the implicit styles to the controls but for the explicit styles you can remove them while page is out of scope OR disappearing.
Example, we applied an explicit style to button
<Button x:Name="btnSave" Style="{StaticResource SaveButtonStyle}" Content="Save"/>
protected override void OnDisappearing()
{
btnSave.Style = null;
base.OnDisappearing();
}
Same can be done with Triggers and Behaviors as well (You can clear them).
I think for the implicit styles, there is something within the code of framework only. We can not identify how default style of control is attached with control as default.

Problems making JavaFX TextField and TextArea editable

I have a JavaFX Application which opens an auxiliary Stage. The Stage itself contains a TextArea and a TextField, both marked as editable in Scene Builder, and neither of them with any bindings for the TextProperty (as far as I know). Even so, I am unable to type anything into these fields.
What might be blocking the editing?
The relevant FXML is as follows:
<HBox prefHeight="100.0" prefWidth="200.0">
<children>
<Label prefHeight="26.0" prefWidth="89.0" text="Query name:" textAlignment="RIGHT" />
<TextField fx:id="queryNameTextField" prefHeight="26.0" prefWidth="518.0" />
</children>
</HBox>
With some further tinkering I have noticed that the new window I open does not always have focus, even when the TextField itself does! I say this because the title of the window is greyed out.

Richfaces: menu key binding

I got a richface issue that rather looks very easy, but i can't find the answer.
I want to acces a (dropdown)menu with keybindings. Once the menu has focus i can use the arrow buttons without a problem. I just cant get the 'focus' on my menu with a hotkey
XHTML:
<rich:dropDownMenu
binding="#{menuBarBean.menuBar}"
id="main-menu"
showEvent="mouseup"
onclick="showMenu();"
/>
<rich:hotKey enabledInInput="true" key="ctrl+M" onkeyup="displayMenu()" preventDefault="true" />
JavaScript:
function displayMenu(){
#{rich:component('main-menu')}.show();
**// Do something that sets focus on the richface menu component**
}
In short:
How to get the focus on
#{rich:component('main-menu')}
with:
<rich:hotKey />
jQuery has a .focus() method that focuses things:
#{rich:component('main-menu')}.element.focus();

XPages: Add a button to a data view custom control

I'm using the Extension Library for creating XPages and I want to use a view, where i can use some inline buttons (buttons in every row of the view) and I also want to use the functionality of the data view where I can expand the content of the current row.
I want to use one of those inline buttons, to expand the content of this row, because before the functionality of this button can be executed, the user has to enter some data in an inputText-field.
So the questions are?
- How can I add inline buttons (using SSJS) to a data view?
- Do you know any other way to solve my problem?
Thanks!
In the Extlib database the expansion with a custom form was done using a link. I would stick to the links -> gives you the most options (client side, server side). Stick to those. If you really need that "buttony" look (which does IMHO not look very much like a web application), use CSS to style the link to look like a button. The OneUI has instructions for that (or steal them from Twitter bootstrap).
The OneUI is worth another look suggesting a different visual clue for expand/collapse.
You should be able to do this within the confines of a dataView by adding a facet for "detail" and using collapsible detail.
For the dataView, set collapsibleDetail="true", add in a panel to the detail facet, then put the elements you want to display when they click to expand in that panel.
<xe:dataView id="dataView1" collapsibleDetail="true" detailsOnClient="true">
<xp:this.facets>
<xp:panel xp:key="detail">
<xp:button id="Mybutton" value="My button"></xp:button>
<xp:label value="This is the label" id="label1" for="Mybutton"></xp:label>
</xp:panel>
</xp:this.facets>
<xe:this.summaryColumn>
<xe:viewSummaryColumn columnName="lastname"></xe:viewSummaryColumn>
</xe:this.summaryColumn>
<xe:this.extraColumns>
<xe:viewExtraColumn columnName="city"></xe:viewExtraColumn>
<xe:viewExtraColumn columnName="state"></xe:viewExtraColumn>
<xe:viewExtraColumn columnName="zip"></xe:viewExtraColumn>
</xe:this.extraColumns>
<xe:this.data>
<xp:dominoView var="view2" viewName="ByName-First"></xp:dominoView>
</xe:this.data>
</xe:dataView>
Now, I'm not positive on how to bind it to the contents of the documents displayed, but I'm sure there's a way. I know how to access the document in a repeat, but not in a dataView, so I would probably do it in a repeat (unless you figure it out and post it to us here!)
Hopefully, that moves you in the right direction.

How to set <aui:button> icon in Liferay without using Javascript?

I'm trying to set icon to <aui:button> like on this tutorial.
But solution described there doesn't work well in my case, because I have a table and on each row I have a button with different resourceUrl. Like this:
<portlet:resourceURL id="saveReport" var="saveReportURL">
<portlet:param name="reportId" value="${report.reportId}" />
</portlet:resourceURL>
<aui:button onclick="location.href = '${saveReportURL}'">
Is it possible to set icon in <aui:button> without using JavaScript as described in tutorial?
Thanks
You can write this below code for setting icon in liferay alloy button
<aui:button type="cancel" cssClass="btn-info" icon="icon-upload-alt" iconAlign="right" value="upload" />
you need to use the icon attribute for this setting "Icon glyphs"
you need to use cssClass for adding extra design button class for the designing
you need to set iconAlign attribute for left or right side of the button text value
You should be able to add an icon to a button without using JavaScript by adding one of these Icon CSS classes to your button. For example, if you wanted to create a button with a calendar icon, your code should look something like this:
<aui:button class="icon-calendar" ... />

Resources