MCPcopy Index your code
hub / github.com/edvin/tornadofx-controls

github.com/edvin/tornadofx-controls @v1.0.6

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.0.6 ↗ · + Follow
332 symbols 943 edges 33 files 28 documented · 8% updated 5y agov1.0.6 · 2017-10-26★ 1094 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Tornado FXControls

CSS Stylable Controls for JavaFX

Maven Central

DatePickerTableCell

TableCell that supports editing of LocalDate properties with a DatePicker.

DateTimePicker

An extension to the JavaFX DatePicker control that lets you input the the time and date in with a configurable format and operate on a LocalDateTime value.

ListMenu

A menu that behaves and looks like a typical ul/li based HTML5 menu.

ListMenuDemo

  • Configurable orientation and iconPosition.
  • Track user selection with active observable property
  • Pseudo state active for CSS styling
  • Custom css property -fx-graphic-fixed-size to align icons of different sizes, which are often the case for font based icons.
  • FXML compatible
  • ListMenuDemo source code
  • [Custom CSS Example] (https://github.com/edvin/tornadofx-controls/blob/master/src/test/resources/custom.css)

NaviSelect

A chooser with a navigate-to button that lets you select an entry and also edit it. The select mechanism must be implemented manually, for example by opening a dialog with a search field and a list view.

Typical use case can be selecting a customer, but the complete customer list cannot be loaded into the dropdown, so you need to open a dialog to choose. The navigate-to button would take you to a customer edit screen.

Customer customer = customerService.getCustomer(42);
NaviSelect<Customer> navi = new NaviSelect<>();
navi.setValue(customer);
navi.setOnEdit(event -> {
    // Show dialog to search for customers, when done, set the new value into the navi
    navi.setValue(newlySelectedCustomer);
});

To override how the customer is rendered in the dropdown you can configure the visual converter:

navi.setVisualConverter(Customer::getName);

Create programatically

ListMenu menu = new ListMenu(
    new ListItem("Contacts", icon(FontAwesomeIcon.USER)),
    new ListItem("Projects", icon(FontAwesomeIcon.SUITCASE)),
    new ListItem("Settings", icon(FontAwesomeIcon.COG))
);

// Listen for selection
menu.activeProperty().addListener((observable, oldValue, newValue) -> {
    // Navigate based on ListItem 'newValue'
});

Create with FXML

<ListMenu orientation="VERTICAL" iconPosition="LEFT">
    <ListItem active="true" text="Contacts">
        <graphic>
            <FontAwesomeIconView glyphName="USER"/>
        </graphic>
    </ListItem>
    <ListItem text="Projects">
        <graphic>
            <FontAwesomeIconView glyphName="SUITCASE"/>
        </graphic>
    </ListItem>
    <ListItem text="Settings">
        <graphic>
            <FontAwesomeIconView glyphName="COG"/>
        </graphic>
    </ListItem>
</ListMenu>

Form layout

Form

A CSS stylable Form layout that is very convenient to use both with FXML and in code.

FXML Example

<Form>
    <Fieldset text="Contact Information" inputGrow="SOMETIMES">
        <Field text="Id">
            <TextField />
        </Field>
        <Field text="Username">
            <TextField />
        </Field>
        <Field text="Zip/City">
            <TextField minWidth="80" maxWidth="80" />
            <TextField />
        </Field>
        <Field>
            <Button text="Save"/>
        </Field>
    </Fieldset>
</Form> 

Java Example

Form form = new Form();

Fieldset contactInfo = form.fieldset("Contact Information");

contactInfo.field("Id", new TextField());
contactInfo.field("Username", new TextField());

TextField zipInput = new TextField();
zipInput.setMinWidth(80);
zipInput.setMaxWidth(80);
contactInfo.field("Zip/City", zipInput, new TextField());

contactInfo.field(new Button("Save"));

Responsive layout

A fieldset can lay out it's labels on the same line as the inputs (orientation=HORIZONTAL) or the labels can be laid out above the inputs (orientation=VERTICAL).

By changing the wrapWidth property on a fieldset you can make a fieldset switch from HORIZONTAL to VERTICAL automatically when the form is resized to a smaller width than wrapWidth.

Legends

A fieldset can have an optional icon specified for it's legend by setting the icon property to any node.

CSS

Use the default CSS Stylesheet as a starting point. The substructure of a Form is described below.

Substructure

  • form - VBox
    • fieldset - VBox
      • legend - Label
      • field - Field
        • label-container - HBox
          • label - Label
        • input-container - HBox
          • arbitrary input components

UnitConverter for TextField (kMGTPE)

Bind a Long property to a TextField with UnitConverter and you can write 2G instead of 2147483648.

TextField storageInput = new TextField()
storageInput.textProperty().bindBidirectional(product.sizeProperty(), new UnitConverter())

Optionally configure binary (true/false) and separator (default "").

DirtyState Tracker

Track dirty states for a collection of properties, with undo feature to rollback changes.

// Track all properties in customer
DirtyState dirtyState = new DirtyState(customer);

// Track only username and password
DirtyStateTracker dirtyState = new DirtyStateTracker(customer,
    customer.usernameProperty(), customer.passwordProperty());

// Disable save button until anything is changed
saveButton.disableProperty().bind(dirtyState.not())

// Undo changes
undoButton.setOnAction(event -> dirtyState.undo());

// Show undo button when changes are performed
undoButton.visibleProperty().bind(dirtyState);

See the JavaDoc for more information and options.

LeanPropertyValueFactory

Fancy having public fields for your JavaFX properties instead of public methods in your model objects? This PropertyValueFactory allows you to use these fields with a TableView:

public class Customer {
    public field idProperty = SimpleObjectProperty<Integer>();
    public field nameProperty = SimpleObjectProperty<String>();
    // Getters and setters if you want :)
}
<TableView>
    <columns>
        <TableColumn text="Id">
            <cellValueFactory>
                <LeanPropertyValueFactory property="id"/>
            </cellValueFactory>
        </TableColumn>
        <TableColumn text="Name">
            <cellValueFactory>
                <LeanPropertyValueFactory property="name"/>
            </cellValueFactory>
        </TableColumn>
    </columns>
</TableView>

Installation

Maven

<dependency>
    <groupId>no.tornado</groupId>
    <artifactId>tornadofx-controls</artifactId>
    <version>1.0.4</version>
</dependency>

Gradle

compile 'no.tornado:tornadofx-controls:1.0.4'

Core symbols most depended-on inside this repo

getChildren
called by 52
src/main/java/tornadofx/control/ListMenu.java
add
called by 50
src/main/java/tornadofx/control/Form.java
getValue
called by 21
src/main/java/tornadofx/control/NaviSelect.java
set
called by 19
src/main/java/tornadofx/control/ListMenu.java
setValue
called by 16
src/main/java/tornadofx/control/NaviSelect.java
setGraphic
called by 12
src/main/java/tornadofx/control/ListItem.java
getGraphic
called by 11
src/main/java/tornadofx/control/ListItem.java
field
called by 10
src/main/java/tornadofx/control/Fieldset.java

Shape

Method 289
Class 43

Languages

Java100%

Modules by API surface

src/main/java/tornadofx/control/MultiSelect.java29 symbols
src/main/java/tornadofx/control/Fieldset.java28 symbols
src/main/java/tornadofx/control/AbstractField.java22 symbols
src/main/java/tornadofx/control/TableRowExpanderColumn.java21 symbols
src/test/java/tornadofx/control/test/Customer.java20 symbols
src/main/java/tornadofx/control/ListMenu.java18 symbols
src/main/java/tornadofx/control/NaviSelect.java16 symbols
src/main/java/tornadofx/control/DatePickerTableCell.java16 symbols
src/main/java/tornadofx/control/DateTimePicker.java14 symbols
src/main/java/tornadofx/control/skin/ListItemSkin.java13 symbols
src/main/java/tornadofx/control/Field.java13 symbols
src/main/java/tornadofx/control/ListItem.java12 symbols

For agents

$ claude mcp add tornadofx-controls \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact