Using properties in Javafx to change style class on button - javafx-8

I'm trying to update the colour of a JavaFx button based on two attributes. If attribute one is true the button is magenta. If attribute one is false and attribute two is true the button is green otherwise it is red, with the text colour appropriate so that you can read the text. My question is can I do this with a property object which I bind to the button or do I just have to
if (attribute_one) {
button.setStyleClass("magenta-button");
} else if (attribute_two) {
button.setStyleClass("green-button");
} else {
button.setStyleClass("red-button");
}
In my CSS file I have the three "-button" styles defined.

Related

Is there any css for remove the view tabs text underlined in Eclipse RCP4

In my part class I removed #Focus annotation method which implemented
#Focus
public void setFocus() {
viewer.getControl().setFocus();
}
after that tab text underline not visible. But when open window with single part tab text underline is visible, if I click anywhere on window underline gone.
How to remove tab text underline?
The underline is drawn if the CTabFolder used for the part has focus. So you should always define an #Focus method for the part and set the focus to some other control in the part.
The actual drawing of the tab is done by the tab renderer which you can set in the CSS using swt-tab-renderer:
CTabFolder
{
swt-tab-renderer: url('bundleclass://org.eclipse.e4.ui.workbench.renderers.swt/org.eclipse.e4.ui.workbench.renderers.swt.CTabRendering');
}
However tab renderers are rather complex and difficult to write.
The actual code in the standard renderer for the underline is:
if (parent.isFocusControl()) {
Display display = parent.getDisplay();
if (parent.simple || parent.single) {
gc.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
gc.setForeground(display.getSystemColor(SWT.COLOR_WHITE));
gc.drawFocus(xDraw-1, textY-1, extent.x+2, extent.y+2);
} else {
gc.setForeground(display.getSystemColor(BUTTON_BORDER));
gc.drawLine(xDraw, textY+extent.y+1, xDraw+extent.x+1, textY+extent.y+1);
}
}
parent in this code is the CTabFolder (from org.eclipse.swt.custom.CTabFolderRenderer)

How to set the visibility for row drag default icon in ag-grid angular 2+

In gridColumns i am setting the rowDrag: true. This creates a default icon for all the rows having children or single rows. But i wanted to have this icon only for particular rows by setting the visibility of a drag icon as hidden.
More over if i populate rowDrag true or false conditionally, then rows for which i dont want drag icon, icon won't come but its breaking the alignment. That's why i want something explicitly where i can set the rowDrag for all rows as true and then explicitly set the visibility as hidden.
Please help me in this case. not finding any solution.
If you just want to hide the drag icon you need to override the CSS. Just assign css class to the rows you want to hide and then in the CSS file make the visibility as hidden.
Assign class as below
this.rowClassRules = {
"hide-row-drag-class": function(params) {
if (params.node.rowIndex % 2 == 0) {
return true;
}
}
};
Override CSS file
.yourTheme .yourClass .ag-row-drag{
visibility: hidden;
}
The above code assigns a CSS class to all odd rows and then will hide the row drag icon based on the CSS
https://plnkr.co/edit/dIfq96KHFmEx25BnC5ze?p=preview

Enterprise Architect: Hide only "top" labels of connectors programmatically

I want to hide the "top" part of all connector labels of a diagram. For this, I tried to set up a script, but it currently hides ALL labels (also the "bottom" labels which I want to preserve):
// Get a reference to the current diagram
var currentDiagram as EA.Diagram;
currentDiagram = Repository.GetCurrentDiagram();
if (currentDiagram != null)
{
for (var i = 0; i < currentDiagram.DiagramLinks.Count; i++)
{
var currentDiagramLink as EA.DiagramLink;
currentDiagramLink = currentDiagram.DiagramLinks.GetAt(i);
currentDiagramLink.Geometry = currentDiagramLink.Geometry
.replace(/HDN=0/g, "HDN=1")
.replace(/LLT=;/, "LLT=HDN=1;")
.replace(/LRT=;/, "LRT=HDN=1;");
if (!currentDiagramLink.Update())
{
Session.Output(currentDiagramLink.GetLastError());
}
}
}
When I hide only the top labels manually (context menu of a connector/Visibility/Set Label Visibility), the Geometry property of the DiagramLinks remains unchanged, so I guess the detailed label visibility information must be contained somewhere else in the model.
Does anyone know how to change my script?
Thanks in advance!
EDIT:
The dialog for editing the detailed label visibility looks as follows:
My goal is unchecking the "top label" checkboxes programmatically.
In the Geometry attribute you will find a partial string like
LLT=CX=36:CY=13:OX=0:OY=0:HDN=0:BLD=0:ITA=0:UND=0:CLR=-1:ALN=1:DIR=0:ROT=0;
So in between LLT and the next semi-colon you need to locate the HDN=0 and replace that with HDN=1. A simple global change like above wont work. You need a wild card like in the regex LLT=([^;]+); to work correctly.

Typo3 Easy way to add a new field to the text and images content element

Is there a easy way to just add a new form to a content element? Like I want an option selector where you can pick a color for the header.
Why not use the header_layout for that? You can customize it in the page-TSConfig
Like this:
# change labels of existing header_layouts
TCEFORM.tt_content {
header_layout.altLabels.0 = white
header_layout.altLabels.1 = red
header_layout.altLabels.2 = green
}
# add layouts
TCEFORM.tt_content{
header_layout.addItems.4 = blue
header_layout.addItems.5 = black
}
# remove layouts
TCEFORM.tt_content{
header_layout.removeItems = 3
}
That's will then set a class to the layout-number, and you can style it with css.
If you actually need a separate field, that's a bit more involved.

Gtk Button inner-border

I add a button to HBox, with expand equal to False, but I want the button to have more spacing between its label and border. I assume it is "inner-border" property, but it is read-only. How can I set it to e.g. 4px?
gtk.Label is a subclass of gtk.Misc which has the method set_padding. If you get the label out of the gtk.Button then you can just call set_padding on it.
You could do something like:
label = gtk.Label("Hello World")
button = gtk.Button()
/* Add 10 pixels border around the label */
label.set_padding(10, 10)
/* Add the label to the button */
button.add(label)
/* Show the label as the button will assume it is already shown */
label.show()
Wrong answer:
What you're looking for is called "padding". When you add your button to the container, for example by calling gtk.Box.pack_start, just set the padding parameter to a positive integer.
Update:
Seems I misread the question. In that case, my guess is that you're supposed to use gtk_widget_modify_style, as inner-border is a style property. You'll first get the style modifier you need by calling gtk_widget_get_modifier_style. You'll then be able to modify the style only for that button using the ressource styles matching rules.
you can use "inner-border" style property of gtk button.
here, small code snippets
In gtkrc file:
style "button_style"
{
GtkButton::inner-border = {10,10,10,10}
}
class "GtkButton" style "button_style"
In .py file:
gtk.rc_parse(rc_file_path + rc_file)
[Edit]
In gtkrc file:
style "button_style"
{
GtkButton::inner-border = {10,10,10,10}
}
widget "*.StyleButton" style "button_style" # apply style for specific name of widget
In .py file:
gtk.rc_parse(rc_file_path + rc_file)
#set name of button
self.style_button.set_name('StyleButton')
hope, it would be helpful.
I sometimes just add spaces in the label !
gtk.Button(" Label ")
to get some spacing.
Hope this could help you.