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

Request JavaScript/ECMAscript JMRI scripting users contact us #13201

Merged
merged 7 commits into from
Jun 20, 2024

Conversation

bobjacobsen
Copy link
Member

When JavaScript/ECMAscript scripts are first run, a warning is posted to the log that requests the user get in touch on the jmriusers list. Hopefully this will help locate a few sample .js scripts for us...

After 5.10 is out, this might be upgraded to a dialog box warning to bring more attention to this.

@bobjacobsen bobjacobsen added this to the 5.9.1 milestone Jun 19, 2024
@mergeable mergeable bot added the New PR Newly created PR that is less than 1 day old label Jun 19, 2024
@devel-bobm
Copy link
Contributor

If users come forward with JavaScript examples, will it be necessary to add a dialog box later? I hope not...

But if a dialog box is added in the future, be sure to allow users to disable that dialog box!

danielb987
danielb987 previously approved these changes Jun 19, 2024
Comment on lines 40 to 43
if (engine.getLanguageName().equals(ECMA_SCRIPT)) {
log.warn("*** Scripting with JavaScript/ECMAscript is being deprecated.***");
log.warn("*** Please contact us on the jmriusers group for assistance. ***");
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me as a developer, it's very clear what this is about. But for a user, it might be confusing or seem to be irrelevant. I suggest adding: and is about to be removed.

*** Scripting with JavaScript/ECMAscript is being deprecated and is about to be removed.***

@danielb987
Copy link
Contributor

After 5.10 is out, this might be upgraded to a dialog box warning to bring more attention to this.

I think it would be good to have the dialog box already in 5.9.x. I'm a developer and I never looks in the log unless I have a very specific reason to do so...

I agree with @devel-bobm that the dialog box needs the ability to disable it.

@KenC57
Copy link
Contributor

KenC57 commented Jun 19, 2024 via email

@danielb987
Copy link
Contributor

I might say 'and will be removed if nobody is using this' or something like that to make it clear they need to respond or it will go away later.

I agree. Thanks.

@bobjacobsen bobjacobsen changed the title Request JavaScript/ECMAscript JMRI scripting users contact us WIP: Request JavaScript/ECMAscript JMRI scripting users contact us Jun 20, 2024
@bobjacobsen
Copy link
Member Author

I've added a dialog box and changed the language to

Scripting with JavaScript/ECMAscript is being deprecated and may soon be removed. If you are using this, please contact us on the jmriusers group for assistance.

Can somebody please point me to an example of a dialog box that can be disabled? I know I've seen one of those, but I don't remember where. Thanks in advance.

@devel-bobm
Copy link
Contributor

Can somebody please point me to an example of a dialog box that can be disabled?

Sure. See class DeleteBeanWorker in jmri.jmrit.beantable.BeanTableDataModel. Specifically, see :

            if (getDisplayDeleteMsg() == 0x02 && message.toString().isEmpty()) {
                doDelete(bean);
            } else {
                JPanel container = new JPanel();
                container.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
                container.setLayout(new BoxLayout(container, BoxLayout.Y_AXIS));
                if (count > 0)
...

The 'if()' checks if the delete warning has been disabled, and simply does the delete. The 'else' deals with the dialog box and manages the warning disable state.

@bobjacobsen
Copy link
Member Author

I've updated this so that the dialog box is shown when a JavaScript/ECMAscript script is first executed, then it's silent until the next run of the program. It does not remember that it's been shown from one run to another. The idea is to really, really encourage people to get in touch to learn how to turn that off.

To turn the warning off, there's a new script that can be run at startup.

Normally, handling options using startup-scripts is inconvenient, but I'm OK with that inconvenience because AFAIK nobody is ever going to encounter it.

@bobjacobsen bobjacobsen changed the title WIP: Request JavaScript/ECMAscript JMRI scripting users contact us Request JavaScript/ECMAscript JMRI scripting users contact us Jun 20, 2024
@mergeable mergeable bot removed the New PR Newly created PR that is less than 1 day old label Jun 20, 2024
@bobjacobsen
Copy link
Member Author

In an earlier version of this PR, I was using that method to identify whether the warning should be triggered or not. This version of the PR works at a lower level to make the detection happen when the actual execution of a script takes place, not when it's first selected. Since I'd already written this method, I just left it in place in case it's useful later on.

@danielb987 danielb987 merged commit 29b18d6 into JMRI:master Jun 20, 2024
10 checks passed
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

Successfully merging this pull request may close these issues.

None yet

4 participants