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

Fix setting of title (and simplify BasePanel to LibraryTab) #6129

Merged
merged 25 commits into from
Oct 20, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
f56e171
Fix setting of title (and remove obsolete comments)
koppor Mar 15, 2020
ffad7e8
Tab titles is determined in JabRefFrame only
koppor Mar 16, 2020
97145ba
Merge remote-tracking branch 'upstream/master' into fix-title
calixtus Sep 27, 2020
ce0e098
Fixed some small merge errors and code optimizations
calixtus Sep 27, 2020
f3dacfc
Refactored BasePanel to LibraryTab and applied some IntelliJ suggestions
calixtus Sep 28, 2020
5ef16b9
Merge remote-tracking branch 'upstream/master' into fix-title-revisited
calixtus Oct 11, 2020
f923a48
Move title logic to LibraryTab
calixtus Oct 13, 2020
f302e73
Merge remote-tracking branch 'upstream/master' into fix-title-revisited
calixtus Oct 13, 2020
ed3fc40
Refactored property methods and removed unused code
calixtus Oct 16, 2020
9d78f28
Removed BasePanelPreferences.java
calixtus Oct 16, 2020
25646f2
Removed calls to JabRefPreferences in LibraryTab.java
calixtus Oct 16, 2020
f82b09a
Merge remote-tracking branch 'upstream/master' into fix-title-revisited
calixtus Oct 17, 2020
add74ef
Reworded panel to libraryTab and suggested switch statement refactor
calixtus Oct 17, 2020
5ae3c58
Refactored setting window title
calixtus Oct 17, 2020
36dbc4b
Refactored setting window title
calixtus Oct 17, 2020
be77a2a
Refactored collectDatabaseFilePaths to stream
calixtus Oct 17, 2020
0ab5e55
Reenabled unique path parsing
calixtus Oct 18, 2020
1ad25fe
Changed getOpenTabs to getOpenDatabases in StateManager
calixtus Oct 18, 2020
85fc785
Fixed refresh of tab title on tab close and open
calixtus Oct 18, 2020
067325d
Fixed SaveDatabaseActionTest
calixtus Oct 18, 2020
5324a9f
Removed nameProperty and bound tab title to frame title
calixtus Oct 19, 2020
9c8b91b
CHANGELOG.md
calixtus Oct 19, 2020
506e8de
Changed tooltip to display multiline texts
calixtus Oct 19, 2020
45514a2
Reordered display and added comments
calixtus Oct 19, 2020
d1257a2
Merge branch 'master' into fix-title
calixtus Oct 19, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 5 additions & 41 deletions src/main/java/org/jabref/gui/BasePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ public class BasePanel extends StackPane {
private final FileAnnotationCache annotationCache;

private final JabRefFrame frame;
// The undo manager.
private final CountingUndoManager undoManager;

private final SidePaneManager sidePaneManager;
Expand All @@ -80,13 +79,10 @@ public class BasePanel extends StackPane {
private final DialogService dialogService;
private MainTable mainTable;
private BasePanelPreferences preferences;
// To contain instantiated entry editors. This is to save time
// As most enums, this must not be null
private BasePanelMode mode = BasePanelMode.SHOWING_NOTHING;
private SplitPane splitPane;
private DatabaseChangePane changePane;
private boolean saving;
// AutoCompleter used in the search bar
private PersonNameSuggestionProvider searchAutoCompleter;
private boolean baseChanged;
private boolean nonUndoableChange;
Expand Down Expand Up @@ -146,34 +142,6 @@ public SuggestionProviders getSuggestionProviders() {
return suggestionProviders;
}

public String getTabTitle() {
StringBuilder title = new StringBuilder();
DatabaseLocation databaseLocation = this.bibDatabaseContext.getLocation();
boolean isAutosaveEnabled = Globals.prefs.getBoolean(JabRefPreferences.LOCAL_AUTO_SAVE);

if (databaseLocation == DatabaseLocation.LOCAL) {
if (this.bibDatabaseContext.getDatabaseFile().isPresent()) {
// check if file is modified
String changeFlag = isModified() && !isAutosaveEnabled ? "*" : "";
title.append(this.bibDatabaseContext.getDatabaseFile().get().getName()).append(changeFlag);
} else {
title.append(Localization.lang("untitled"));

if (getDatabase().hasEntries()) {
// if the database is not empty and no file is assigned,
// the database came from an import and has to be treated somehow
// -> mark as changed
// This also happens internally at basepanel to ensure consistency line 224
title.append('*');
}
}
} else if (databaseLocation == DatabaseLocation.SHARED) {
title.append(this.bibDatabaseContext.getDBMSSynchronizer().getDBName() + " [" + Localization.lang("shared") + "]");
}

return title.toString();
}

public boolean isModified() {
return baseChanged;
}
Expand Down Expand Up @@ -539,11 +507,12 @@ public void updateEntryEditorIfShowing() {
}
}

/**
* Put an asterisk behind the filename to indicate the database has changed.
Copy link
Member

Choose a reason for hiding this comment

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

Can you please investigate if this method is still really necessary. In principle, it should be enough to add listeners to the state manager to be notified about db changes. This would also fix the strange flow of information (from the base panel to the main frame).

Copy link
Member

Choose a reason for hiding this comment

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

I intensivly investigated this issue. I believe this method or something like it is still necessary until we can bind some property to an undomanager, which can provide a dirty flag for each library file.

*/
public void markBaseChanged() {
baseChanged = true;
// Put an asterisk behind the filename to indicate the database has changed.
frame.setWindowTitle();
DefaultTaskExecutor.runInJavaFXThread(frame::updateAllTabTitles);
frame.refreshWindowAndTabTitles();
}

public void markNonUndoableBaseChanged() {
Expand All @@ -558,13 +527,8 @@ public synchronized void markChangedOrUnChanged() {
}
} else if (baseChanged && !nonUndoableChange) {
baseChanged = false;
if (getBibDatabaseContext().getDatabaseFile().isPresent()) {
frame.setTabTitle(this, getTabTitle(), getBibDatabaseContext().getDatabaseFile().get().getAbsolutePath());
} else {
frame.setTabTitle(this, Localization.lang("untitled"), null);
}
}
frame.setWindowTitle();
frame.refreshWindowAndTabTitles();
}

public BibDatabase getDatabase() {
Expand Down
Loading