openlcb / OpenLCB_Java

A git-managed copy of the SVN-based Java prototype implementation of OpenLCB. This implementation operates inside JMRI.
6 stars 9 forks source link

Update default backup filename to id-name-softversion-date-time #214

Closed bobjacobsen closed 1 year ago

bobjacobsen commented 1 year ago

Changes the default filename when doing a backup from the CDI pane. The new form is id-name-softwareversion-date-time, e.g.

config.02.01.57.00.04.8B-East_test_board-rev-C7b-2023-02-24-10:06:21.txt
bobjacobsen commented 1 year ago

See discussion at https://groups.io/g/layoutcommandcontrol/topic/97184619

balazsracz commented 1 year ago

On Wed, Mar 1, 2023 at 5:36 AM Bob Jacobsen @.***> wrote:

@.**** commented on this pull request.

In src/org/openlcb/cdi/swing/CdiPanel.java https://github.com/openlcb/OpenLCB_Java/pull/214#discussion_r1121740613:

 public void runRestore() {

// First select a file to save to. fci.setDialogTitle("Open configuration restore file"); fci.rescanCurrentDirectory();

  • fci.setSelectedFile(new File("config." + rep.getRemoteNodeAsString() + ".txt"));
  • fci.setSelectedFile(new File(generateFileName()));

You're right that this won't end up selecting a file. This goes to the saved directory (if any), but doesn't select a file.

Unfortunately, no, there's no glob capability in the JFileChooser. Coding one is possible, but it's a non-trivial amount of work.

Another approach might be to present the last filename used by a Save (in the same session) and select that.

This sounds like an ok behavior. If there wasn't anything in the current session, then just show the directory with *.txt in the chooser.

Message ID: @.***>

bobjacobsen commented 1 year ago

Thanks. Changes made.