How do I style Text and Hyperlinks within a TextFlow in JavaFX? - javafx

I've tried all kinds of different selectors, but no matter what I use, my style seems to be ignored. Any idea what I'm doing wrong?
My css is:
.hint {
-fx-fill: red;
-fx-text-fill: red;
-fx-font-size: 10.0;
}
My FXML is:
<TextFlow fx:id="flowPortForwarding" GridPane.columnSpan="2147483647" GridPane.rowIndex="5">
<children>
<Text styleClass="hint" text="Port will be shown in tooltip after connecting to a" />
<Hyperlink onAction="#helpPortForwarding" styleClass="hyperlink" text="portforwarding" />
<Text styleClass="hint" text="gateway." />
</children>
</TextFlow>
A complete listing of my sources are here:
https://dl.dropboxusercontent.com/u/45205679/Settings.fxml
https://dl.dropboxusercontent.com/u/45205679/settings-style.css

Looks like I already had a selector ".hyperlink, .hint", so my introduction of a new selector ".hint" was being ingored.

Related

sap.m.Select ignores sapUiSizeCozy in headerContent of ObjectPageLayout

Edit:
Bug report Bug Report on github
Situation:
I am writing an app with the ObjectPageLayout.
In the header content I have a sap.m.Select and a sap.m.MultiComboBox with a reset button each.
I want to have them in the header, since they filter all Diagramms and Tabels of the diffrent tabs.
I set my css class as it is discribed in the Workthrough.
When the style is set to compact mode due to the device type everything is fine.
Problem:
When the css class is cozy the select still has the compact style.
The MultiComboBox and buttons and everything else take the cozy style.
--> it looks really bad
Does anyone have an idea, why the select doesn't have the cozy style aswell?
I even tryed hard setting the css style in the XML, but it doesn't work.
If I change the css class of the MultiComboBox or the buttons it works,
but I dont want to always have everything on compact just because the select cannot go on cozy...
To replicate the problem you can just create a new project (UI5 Version 1.71) in the webide and replace the view with mine:
<mvc:View
xmlns:mvc="sap.ui.core.mvc"
xmlns:core="sap.ui.core"
xmlns="sap.uxap"
xmlns:layout="sap.ui.layout"
xmlns:m="sap.m"
xmlns:f="sap.f"
controllerName="TEST.TestingSelects.controller.Home"
height="100%"
>
<ObjectPageLayout
id="ObjectPageLayout"
enableLazyLoading="true"
useIconTabBar="true"
showTitleInHeaderContent="false"
>
<headerTitle>
<ObjectPageHeader
id="headerForTest"
objectTitle="{i18n>home.title}"
>
</ObjectPageHeader>
</headerTitle>
<headerContent>
<m:VBox>
<m:HBox>
<m:Select
id="idStoreSelect"
selectedKey="{homeModel>/storeSelectKey}"
change="onStoreSelectChange"
items=""
>
<core:Item
key=""
text=""
/>
</m:Select>
<m:Button
icon="sap-icon://redo"
press="onResetStoreButtonPress"
tooltip="{i18n>home.store.redo.tooltip}"
type="Transparent"
/>
</m:HBox>
<m:HBox>
<m:MultiComboBox
id="idCatMCB"
selectedKeys=""
selectionChange="onCatMBCChange"
items=""
>
<core:Item
key=""
text=""
/>
</m:MultiComboBox>
<m:Button
icon="sap-icon://redo"
press="onResetCatButtonPress"
tooltip="{i18n>home.cat.redo.tooltip}"
type="Transparent"
/>
</m:HBox>
</m:VBox>
</headerContent>
<sections>
<ObjectPageSection title="2014 Goals Plan">
<subSections>
<ObjectPageSubSection title=" ">
<blocks>
<m:Button
icon="sap-icon://redo"
press="onResetCatButtonPress"
tooltip="{i18n>home.cat.redo.tooltip}"
type="Transparent"
/>
</blocks>
</ObjectPageSubSection>
</subSections>
</ObjectPageSection>
<ObjectPageSection title="Personal">
<subSections>
<ObjectPageSubSection title="Connect">
<blocks>
<m:Button
icon="sap-icon://redo"
press="onResetCatButtonPress"
tooltip="{i18n>home.cat.redo.tooltip}"
type="Transparent"
/>
</blocks>
</ObjectPageSubSection>
<ObjectPageSubSection id="paymentSubSection" title="Payment information">
<blocks>
<m:Button
icon="sap-icon://redo"
press="onResetCatButtonPress"
tooltip="{i18n>home.cat.redo.tooltip}"
type="Transparent"
/>
</blocks>
</ObjectPageSubSection>
</subSections>
</ObjectPageSection>
</sections>
</ObjectPageLayout>
</mvc:View>
Code of select when hard setting css style:
<m:Select
id="idStoreSelect"
class="sapUiSizeCozy"
selectedKey="{homeModel>/storeSelectKey}"
change="onStoreSelectChange"
items=""
>
<core:Item
key=""
text=""
/>
</m:Select>
SAP fixed the UI5 bug with the version 1.95 (commit 4c7fffe).
Here you can see, that the sap.m.Select no longer has its own height set in the ObjectPageHeaderContent but applies the height according to the density class:
UI5 ≥ 1.95
UI5 ≤ 1.94
Screenshots from: https://plnkr.co/edit/gTxIx9BvTChZovBZ?preview
To fix the width of the Select you can add the aggregation layoutData
<m:layoutData>
<m:FlexItemData growFactor="1" />
</m:layoutData>
To fix the height of the Button you need to set the content density (as described in the official Walkthrough (Step 37)).
Basically you provide a method in your Component.js which returns the correct density (and don't forget to import "sap/ui/Device" at the top!)
getContentDensityClass : function () {
if (!this._sContentDensityClass) {
if (!Device.support.touch) {
this._sContentDensityClass = "sapUiSizeCompact";
} else {
this._sContentDensityClass = "sapUiSizeCozy";
}
}
return this._sContentDensityClass;
}
Then in the controller of your root view (defined in manifest.json > sap.ui5 > rootView) you can call this method
onInit: function() {
this.getView().addStyleClass(
this.getOwnerComponent().getContentDensityClass()
);
}
I put together a small sample:
https://plnkr.co/edit/h1JZiyYrWLmuck46

Remove border in bottom of the react-native Picker

I have a problem trying to remove the bottom border from the default Picker in react-native.
My code:
<Picker
style={styles.pickerStyle}
selectedValue={this.state.registerType}
onValueChange={(item) => this.setState({registerType:item})}>
<Picker.Item label="Vælg emne" value="choose" />
{registerTypes}
</Picker>
On the image below you can see what I want to remove:
I have tried to use the underlineColorAndroid='transparent' properties as you will do in the TextInput tag, but it diden't work. Any suggestions?
Maybe it's not the best way ever, but I found a fast solution that worked fine in my project.
Define a height for <View> and <Picker>, and the container element must be 1px bigger.
Set overflow: "hidden" para o container.
<View style={styles.container}>
<Picker style={styles.picker}>
<Picker.Item value="1" label="Yes" />
<Picker.Item value="2" label="No" />
</Picker>
<View>
container: {
overflow: "hidden",
height: 51
},
picker: {
height: 50
}
I know it was an easy fix, but a part of my design was to change the background color in the Picker and then the border is hidden behind I guess.

Lookup style of POJO object in CSS

A helper Label that doesn't really fit in fxml, so it is created (as a POJO) and attached at initialize() step.
This is straightforward in fxml:
stylesheet.css: .my-label { -fx-font-size: 12px; }
my_view.fxml: <Label fx:id="label" styleClass="my-label" />
Or in POJO locally: label.setStyle("-fx-font-size: 12px;");
What is the right way to define Label in POJO, but move style to css?
All you need to do is add the style class:
label.getStyleClass().add("my-label");
and then use the same CSS you have for your FXML example.

Accessing treechildren in xul for styling

I have this code in xul:
<treechildren id = "mainTree_treechildren">
<treeitem container="true" open="true">
<treerow>
<treecell label="&tree.actions;" />
</treerow>
<treechildren id="tree_actions_treechildren" >
<treeitem container="true" open="true">
<treerow>
<treecell label="&tree.actions.warnings;" />
</treerow>
</treeitem>
</treechildren>
</treeitem>
</treechildren>
and i have problem styling it. I need to have to different text colors for treecell in mainTree_treechildren and different text color for treecell in his child treechildren with id tree_actions_treechildren.
At the moment I have this css code
#mainTree #mainTree_treechildren::-moz-tree-cell-text { color: #000000; }
#mainTree #tree_actions_treechildren::-moz-tree-cell-text { color: #FFFFFF; }
But it doesn't work. I only get black color for every element inside mainTree_treechildren including tree_actions_treechildren.
The <treechildren> elements aren't actually being displayed - they are merely the data source for the tree widget (other data sources are also possible, e.g. RDF or XML files). Consequently, their contents cannot be styled directly. If you want to style individual tree cells differently you should use the properties attribute. Something like this should work:
<treechildren id="mainTree_treechildren">
<treeitem container="true" open="true">
<treerow>
<treecell label="&tree.actions;" />
</treerow>
<treeitem container="true" open="true">
<treerow>
<treecell label="&tree.actions.warnings;" properties="warning" />
</treerow>
</treeitem>
</treeitem>
</treechildren>
And the corresponding styles:
#mainTree_treechildren::-moz-tree-cell-text { color: #000000; }
#mainTree_treechildren::-moz-tree-cell-text(warning) { color: #FF0000; }
Note that using CSS selectors like #foo #bar isn't recommended - an ID is always unique so specifying more than one in a selector will only slow things down.

mx:Legend fontSize not working

I have a PieChart... now that I'm moving to support tablets as well, I need to make the fontSize of the legend larger. However, the following has no effect:
<mx:Legend dataProvider="{industryChart}"
height="110" bottom="40"
height.groupTablets="220" bottom.groupTablets="80"
fontSize="8" fontSize.groupTablets="16"
markerHeight="10" markerHeight.groupTablets="20"
verticalGap="3"
/>
I know that the state is correct because the other attributes change.
I've also tried adding a style section:
<fx:Style>
.legend {
fontSize:24;
}
</fx:Style>
<mx:Legend dataProvider="{industryChart}"
height="110" bottom="40"
height.groupTablets="220" bottom.groupTablets="80"
markerHeight="10" markerHeight.groupTablets="20"
verticalGap="3"
styleName="legend"
/>
No change. Nor does it work if I move the style to Main.css.
Using this gives a warning: CSS type selectors are not supported in components: 'mx.charts.LegendItem':
<fx:Style>
#namespace mx "library://ns.adobe.com/flex/mx";
mx|LegendItem {
fontSize:24;
}
</fx:Style>
But if I put the same in Main.css, it does work:
#namespace mx "library://ns.adobe.com/flex/mx";
mx|LegendItem {
fontSize:24;
}
The problem I have with that is that I have to be able to make the font larger when in the tablet state, and not just for all states, or the font will be too large on a phone.
Pseudo-selectors don't appear to work:
mx|LegendItem:groupTablets {
fontSize:24;
}
IDs do not work, in either Main.cc or fx:Style:
#pieLegend {
fontSize:24;
}
<mx:Legend id="pieLegend"
dataProvider="{industryChart}"
height="110" bottom="40"
height.groupTablets="220" bottom.groupTablets="80"
markerHeight="10" markerHeight.groupTablets="20"
verticalGap="3"
/>
However, even if that approach worked it would have difficulties when the code behind the mxml needs to reference a particular component by id.
I even got frustrated and tried this in the code:
pieLegend.setStyle("fontSize", 24);
Nope. Grrrr.
Any ideas?
Caught the same issue. Here's from the adobe forum, might have to wait for apache flex for a real fix:
The problem is based on a bug that was deferred ( http://bugs.adobe.com/jira/browse/FLEXDMV-1656). There are several workarounds, but the simplest is to set the fontSize on the LegendItem type selector, like this:
<mx:Style>
LegendItem {
fontSize:24;
}
</mx:Style>

Resources