Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling of illegal values in settings views is not very intuitive but I don't know whether sth could really be done there... #58

Open
JonasSchaub opened this issue Mar 28, 2024 · 15 comments

Comments

@JonasSchaub
Copy link
Collaborator

No description provided.

@JonasSchaub
Copy link
Collaborator Author

I am specifically referring to integer and double settings. If an illegal input has been made, the user is told about it. The text field is then reset to 0 or 0.0 but actually, the settings remains in its previous value which is not displayed.

@JonasSchaub
Copy link
Collaborator Author

We could think about supplying possible values for the settings instead of having text fields. E.g. for the "nr of tasks for fragmentation" setting, this would be a nice solution.

@FelixBaensch
Copy link
Owner

What is meant by illegal values? Wrong data type or values outside a defined range?

@FelixBaensch
Copy link
Owner

We could think about supplying possible values for the settings instead of having text fields. E.g. for the "nr of tasks for fragmentation" setting, this would be a nice solution.

To stay with the example, a CPU with 64 possible cores should be offered a selection from 1 to 64?

@JonasSchaub
Copy link
Collaborator Author

What is meant by illegal values? Wrong data type or values outside a defined range?

Values outside a defined range. E.g. try to set the "nr of tasks for fragmentation" to a value higher than your available cores to see what I mean.

To stay with the example, a CPU with 64 possible cores should be offered a selection from 1 to 64?

Exactly. But for some fragmenter settings, it will not be that easy.

@FelixBaensch
Copy link
Owner

What is meant by illegal values? Wrong data type or values outside a defined range?

Values outside a defined range. E.g. try to set the "nr of tasks for fragmentation" to a value higher than your available cores to see what I mean.

How about coloring the background or the border of the text field red, adding an error tooltip and deactivating the "Apply" button?

To stay with the example, a CPU with 64 possible cores should be offered a selection from 1 to 64?

Exactly. But for some fragmenter settings, it will not be that easy.

Strange and complicated, imho.

@JonasSchaub
Copy link
Collaborator Author

The main problem here is that currently, the JavaFx property object throws an IllegalArgumentException if an illegal value was set which resets the binding but can't really be caught except by the uncaught exception handler. So at the moment, I don't know how to react in the GUI to the illegal value.

@FelixBaensch
Copy link
Owner

I could take a look, but it will take a while.

@JonasSchaub
Copy link
Collaborator Author

That would be great but I also had the idea to set a student onto this. Anyway, I don't think we should wait for this with the next release.

@FelixBaensch
Copy link
Owner

FelixBaensch commented Apr 2, 2024

That would be great but I also had the idea to set a student onto this. Anyway, I don't think we should wait for this with the next release.

If you have a capable student.

Btw. funny copy&paste error in SettingsContainer line 649:

this.recentDirectoryPathSetting = new SimpleStringProperty(this,
                "Recent directory path setting",
                SettingsContainer.RECENT_DIRECTORY_PATH_SETTING_DEFAULT) {  
            @Override
            public void set(String newValue) throws IllegalArgumentException {
                if (SettingsContainer.this.isLegalRecentDirectoryPath(newValue)) {
                    super.set(newValue);
                } else {
                    IllegalArgumentException tmpException = new IllegalArgumentException("An illegal number of tasks for fragmentation was given: " + newValue);
                    SettingsContainer.this.LOGGER.log(Level.WARNING, tmpException.toString(), tmpException);
                    //no GUI alert here because this is an internal setting
                    //re-throws the exception to properly reset the binding
                    throw tmpException;
                }
            }
        };

@JonasSchaub
Copy link
Collaborator Author

Fixed in #60 thanks for spotting this!

@FelixBaensch
Copy link
Owner

FelixBaensch commented Apr 17, 2024

This turns out to be more complex, as the validation is handled in the SettingsContainer and there is no (elegant) way to access the text field from there.

@JonasSchaub
Copy link
Collaborator Author

Precisely...

@FelixBaensch
Copy link
Owner

... a major workaround is necessary and the structure as it is now with SettingsView, -Controller and -Container cannot remain as it is. I would therefore not change it for the time being.

@JonasSchaub
Copy link
Collaborator Author

A major rework like this was not my intention "for the time being".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants