Daytron / SimpleDialogFX

Lightweight dialog API for JavaFX.
https://daytron.github.io/SimpleDialogFX/
MIT License
21 stars 2 forks source link

Make Dialog inheritable #11

Closed rohitvvv closed 9 years ago

rohitvvv commented 9 years ago

Can you make Dialog non-final? I would like to use it for a project and extend it further. It should be helpful and foster reusability.

rohitvvv commented 9 years ago

...some more on the question.I can encapsulate the Dialog api and expose a common object in my project. However I would end up wrapping every method on dialog if at all I am using all dialog types. Otherwise if I don't warp and have my own dialog then I will end up having heterogeneous implementations of dialog. Thanks

Daytron commented 9 years ago

I been thinking about it for awhile. How would you implement it, if you're able to extend it? What feature will you implement? Overloading the constructor would be the best way to do it for customizing the stage.

I'm thinking to modify some of the methods to final to preserve their implementation. Ofcourse you can always create your own methods.

rohitvvv commented 9 years ago

My requirement is to have Dialogues but with more functionalities. Like additional text input fields and buttons. Most of the dialog are carved in stone in Fxml.java. Writing code to create additional buttons and adding them to a HBox/VBox etc leads to lots of placement issues in the dialog window.

My idea is to extend Dialog which is a Stage type object. Have my own custom Dialog FXML's with some more overloaded constructors . This way I benefit from your library for basic dialogs and also my own Dialogs with the extended class.

Daytron commented 9 years ago

Great. I'll add this to the next release. I can't release it yet with this small change, until I have solid update. If you're in a hurry, I can release a SNAPSHOT version on Sonatype and you can use that until the next release or a jar file on Release section. Although it will be continuously updated as I prepare for the release.

Daytron commented 9 years ago

Fixed with commit f987f46def43800bfdd3d2971753117f1c208ef2

rohitvvv commented 9 years ago

Excellent. Please release a SNAPSHOT. Also update the entry for the pom.xml. I hope 2.0.0-SNAPSHOT will be the version and .m2/settings.xml should pointing to sonatype repository.

Daytron commented 9 years ago

V2.0.0 is already been released. I am working with v2.1.0, so it will be 2.1.0-SNAPSHOT. This version will also allow you to replace color style gradients between dialogs and more pre-built styles to choose from. See issue #12 .

I'll let you know as soon I uploaded the snapshot. For the main release, there's no definite timeline yet, I'm afraid.

Daytron commented 9 years ago

It's now live. https://oss.sonatype.org/content/repositories/snapshots/com/github/daytron/SimpleDialogFX/2.1.0-SNAPSHOT/ You can add this to your pom file:

   <repositories>
        <repository>
            <id>maven-central-repo</id>
            <url>http://repo1.maven.org/maven2</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
        <repository>
            <id>sonatype-snapshots-repo</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>com.github.daytron</groupId>
            <artifactId>SimpleDialogFX</artifactId>
            <version>2.1.0-SNAPSHOT</version>
            <type>jar</type>
        </dependency>
    </dependencies>

Please if you find any bug, feel free to raise an issue ticket. Thanks.

Daytron commented 9 years ago

Few updates with this snapshot:

More to follow:

rajmahendra commented 9 years ago

@rohitvvv @Daytron Thats awesome :+1: :100:

Daytron commented 9 years ago

@rajmahendra Thanks

I have updated the snapshot with 33 more background color styles. You can try and test them out.

Daytron commented 9 years ago

A couple more of updates for the snapshot:

rohitvvv commented 9 years ago

@Daytron Thanks for the new snapshot. The way I could put your library to use is by using a facade design pattern on top of your library. Could not extend and use it because of the following 1) getResponse is final method in Dialog and DialogResponse is a enum. No way for me to extend and have custom responses for new buttons or dialogs I add to existing. 2) setResponse is private. So cannot override it. Also DialogResponse been a enum is final can cannot be updated.

Appreciate your agility in making Dialog class non-final. I understand its a library and has lots of generic usage. You may revert the change if required.

Thanks, Rohit Vaidya

Daytron commented 9 years ago

If that is the case you can either:

I'll still leave the class inheritable, so anyone can encapsulate their own customization of the dialog in their subclass, e.g. adding their own CSS style or simply changing the font, instead of applying it on every Dialog object created (cumbersome).

rohitvvv commented 9 years ago

@Daytron @rajmahendra Thank you for the suggestion. ControlFX is a good however the Dialog API appears deprecated and the author has indicated here not to use the api and take time off to transition into OpenJFX or use official dialogs due to be available in Java 8 Update 40 March 15. Trying early access for dialogs. Thanks again for the suggestions.

Daytron commented 9 years ago

Yep, I think you better wait for the Java 8u40. This is why I created this api to make it as simple as possible as an alternative to ControlsFX.

No problem at all. Feel free to open up another issue if you have any other question or feedback. Thanks.