Coder Social home page Coder Social logo

Comments (7)

jidesoft avatar jidesoft commented on September 2, 2024

You may take a look and see if it is possible to make it FXML friendly. I thought about it too but I felt it is not that critical. I can still design the panel using FXML. When I add the FXML designed panel to its parent using code, I can then wrap it in a DecorationPane. I know it is not perfect but probably enough to cover most cases.

from jidefx-oss.

aalmiray avatar aalmiray commented on September 2, 2024

Indeed. The design of DecorationPanel feels that it was made with programmatic usage in mind. And though I like direct API usages I've come to appreciate the easiness of FXML to quickly setup an UI. Take the following FXML for example

<?xml version="1.0" encoding="UTF-8"?>
<?import griffon.javafx.scene.layout.MigLayoutPane?>
<?import griffon.javafx.support.fontawesome.FontAwesomeIcon?>
<?import javafx.scene.control.ListView?>
<?import javafx.scene.control.TitledPane?>
<?import org.example.DecorationPane?>
<MigLayoutPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity"
               xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"
               layout="fill" cols="[][grow 2][]"
               fx:controller="org.example.SampleController">
    <TitledPane collapsible="false" text="People">
        <graphic>
            <FontAwesomeIcon fontAwesome="fa_users"/>
        </graphic>
        <ListView fx:id="peopleView" prefWidth="200.0" prefHeight="190.0"/>
    </TitledPane>
    <TitledPane collapsible="false" text="Details">
        <graphic>
            <FontAwesomeIcon fontAwesome="fa_user"/>
        </graphic>
        <DecorationPane>
            <MigLayoutPane fx:id="formPanel" layout="fill" cols="[::80][]" prefHeight="190.0"/>
        </DecorationPane>
    </TitledPane>
    <TitledPane collapsible="false" text="Actions">
        <graphic>
            <FontAwesomeIcon fontAwesome="fa_star"/>
        </graphic>
        <MigLayoutPane fx:id="actionsPanel" layout="fill" prefHeight="190.0"/>
    </TitledPane>
</MigLayoutPane>

The two innermost MigLayoutPane instances will have their children set using the Java API as their content is dynamic. The DecorationPane used here simply removes the default no-arg constructor to make a quick test. If the constructor is left in place then the class doing the FXML loading has to have references to the TitledPane instances, create the MigLayoutPanes and wrap them with DecoratorPane. Not much of a change given that the loading class performs direct Java API usage anyway. But what if the contents of the MigLayoutPanes were static? Then everything could be defined in the FXML.

from jidefx-oss.

jidesoft avatar jidesoft commented on September 2, 2024

I see. What exactly need to be done? A default constructor and being able to set the content on fly?

from jidefx-oss.

aalmiray avatar aalmiray commented on September 2, 2024

Yes. The current constructor defines lifecycle methods that must be called when content is added. I believe the following measures are needed to make DecorationPane be FXML friendly:

  • remove explicit constructor
  • add setContent() method that applies content Node and runs the lifecycle. This method must make sure previous content is disposed gracefully -> additional lifecycle methods are needed to deregister listeners on old content.
  • override getChildren() to force a single element on the list. This is to prevent someone from calling decorationPane.getChildren.add(someRandomControl). If this is too troublesome then an entry on the javadoc should be added specifying this pane assumes a single child element and makes no guarantees if additional children are added.

from jidefx-oss.

jidesoft avatar jidesoft commented on September 2, 2024

Thanks for the explanation. It'd be possible although needs some work. Let me see if I can find time for it next week.

from jidefx-oss.

aalmiray avatar aalmiray commented on September 2, 2024

Actually the current constructor must stay in place, otherwise it breaks compatibility. The no-args constructor must be added; then rhe content wiring/unwiring. Next week there is a 2 day @hackergarten at Javaland. I hope to get some people interested in jidefx and improvs 😄

from jidefx-oss.

jidesoft avatar jidesoft commented on September 2, 2024

Cool!

from jidefx-oss.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.