From: Frédéric Perrin Date: Mon, 31 Dec 2018 15:45:45 +0000 (+0000) Subject: Set main window title X-Git-Tag: v19.2.fp1^2 X-Git-Url: http://gitweb.fperrin.net/?p=GpsPrune.git;a=commitdiff_plain;h=32829d40884b042d44d7c51fcf509ac525efc374 Set main window title --- diff --git a/src/tim/prune/App.java b/src/tim/prune/App.java index 3a77858..247a133 100644 --- a/src/tim/prune/App.java +++ b/src/tim/prune/App.java @@ -51,6 +51,7 @@ public class App { // Instance variables private JFrame _frame = null; + private String _titlePrefix = null; private Track _track = null; private TrackInfo _trackInfo = null; private int _lastSavePosition = 0; @@ -79,6 +80,7 @@ public class App public App(JFrame inFrame) { _frame = inFrame; + _titlePrefix = _frame.getTitle(); _undoStack = new UndoStack(); _track = new Track(); _trackInfo = new TrackInfo(_track); @@ -759,6 +761,8 @@ public class App + " '" + inSourceInfo.getName() + "'"); // update menu _menuManager.informFileLoaded(); + // update main window title + updateTitle(); // Remove busy lock _busyLoading = false; // load next file if there's a queue @@ -1001,4 +1005,16 @@ public class App public void setCurrentMode(AppMode inMode) { _appMode = inMode; } + + /** Update main window title **/ + public void updateTitle() { + ArrayList filenames = _trackInfo.getFileInfo().getFilenames(); + if (filenames.size() > 0) { + _frame.setTitle(_titlePrefix + ": " + String.join(", ", filenames)); + } + else + { + _frame.setTitle(_titlePrefix); + } + } } diff --git a/src/tim/prune/data/FileInfo.java b/src/tim/prune/data/FileInfo.java index 41900cb..7eaac8f 100644 --- a/src/tim/prune/data/FileInfo.java +++ b/src/tim/prune/data/FileInfo.java @@ -74,6 +74,19 @@ public class FileInfo return ""; } + /** + * @return The source names + */ + public ArrayList getFilenames() + { + ArrayList filenames = new ArrayList(); + for (SourceInfo source : _sources) + { + filenames.add(source.getName()); + } + return filenames; + } + /** * @param inIndex index number, starting from zero * @return source info object diff --git a/src/tim/prune/gui/SelectorDisplay.java b/src/tim/prune/gui/SelectorDisplay.java index fa6630d..9dfc24f 100644 --- a/src/tim/prune/gui/SelectorDisplay.java +++ b/src/tim/prune/gui/SelectorDisplay.java @@ -228,8 +228,9 @@ public class SelectorDisplay extends GenericDisplay else if (numFiles > 1) { final String labelText = I18nManager.getText("details.track.numfiles") + ": " + numFiles; + final String filenameString = String.join(", ", _trackInfo.getFileInfo().getFilenames()); _filenameLabel.setText(labelText); - _filenameLabel.setToolTipText(labelText); + _filenameLabel.setToolTipText(filenameString); } else {