Skip to content

Commit

Permalink
Set title of main window
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcin Chwedczuk committed Jan 1, 2022
1 parent 0519a5d commit dde5b16
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static MainWindow showOn(Stage window) {
Scene scene = new Scene(loader.load());
MainWindow controller = (MainWindow) loader.getController();

window.setTitle("Main Window");
window.setTitle("Elf Viewer");
window.setScene(scene);
window.setResizable(true);

Expand All @@ -61,7 +61,7 @@ public static MainWindow showOn(Stage window) {
}
}

private Window thisWindow;
private Stage thisWindow;

@FXML
private TextField filterText;
Expand Down Expand Up @@ -156,13 +156,15 @@ private void loadElfFile(File f) {

currentElfFile = null;
currentElfPath = null;
setTitle(null);

resetTreeView();
}

try {
currentElfFile = ElfReader.readElf(new FileSystemFile(f));
currentElfPath = f;
setTitle(currentElfPath);
} catch (ElfReaderException e) {
UiService.errorDialog("Cannot open ELF file.", e.getMessage());
return;
Expand All @@ -172,6 +174,14 @@ private void loadElfFile(File f) {
recentlyOpenFiles.onFileOpen(f);
}

private void setTitle(File elfFile) {
if (elfFile == null) {
thisWindow.setTitle("Elf Viewer");
} else {
thisWindow.setTitle("Elf Viewer - " + elfFile.getName());
}
}

private void resetTreeView() {
rootItem = new TreeItem<>(new RenderDataAction<>(
"No ELF file loaded",
Expand Down

0 comments on commit dde5b16

Please sign in to comment.