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
Searchbar across all bib files instead each having its own #1549
Changes from 18 commits
2df64c8
5db880d
579c529
a9ec1d6
47c0c71
67adc90
1041b74
1a069d8
becb549
c0a49d2
a474d17
f85a729
686edfd
d44aab3
5f1b356
46d74e4
409a043
cd718de
b9a620f
d395395
3c17a09
bce1bf5
d8f7a81
c21ab8e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
import java.awt.Component; | ||
import java.awt.Container; | ||
import java.awt.Cursor; | ||
import java.awt.FlowLayout; | ||
import java.awt.Font; | ||
import java.awt.Frame; | ||
import java.awt.GraphicsEnvironment; | ||
|
@@ -103,6 +104,7 @@ | |
import net.sf.jabref.gui.protectedterms.ProtectedTermsDialog; | ||
import net.sf.jabref.gui.push.PushToApplicationButton; | ||
import net.sf.jabref.gui.push.PushToApplications; | ||
import net.sf.jabref.gui.search.GlobalSearchBar; | ||
import net.sf.jabref.gui.util.FocusRequester; | ||
import net.sf.jabref.gui.util.WindowLocation; | ||
import net.sf.jabref.gui.worker.MarkEntriesAction; | ||
|
@@ -112,6 +114,7 @@ | |
import net.sf.jabref.logic.importer.ParserResult; | ||
import net.sf.jabref.logic.l10n.Localization; | ||
import net.sf.jabref.logic.logging.GuiAppender; | ||
import net.sf.jabref.logic.search.SearchQuery; | ||
import net.sf.jabref.logic.undo.AddUndoableActionEvent; | ||
import net.sf.jabref.logic.undo.UndoChangeEvent; | ||
import net.sf.jabref.logic.undo.UndoRedoEvent; | ||
|
@@ -125,6 +128,7 @@ | |
import net.sf.jabref.preferences.HighlightMatchingGroupPreferences; | ||
import net.sf.jabref.preferences.JabRefPreferences; | ||
import net.sf.jabref.preferences.LastFocusedTabPreferences; | ||
import net.sf.jabref.preferences.SearchPreferences; | ||
import net.sf.jabref.specialfields.Printed; | ||
import net.sf.jabref.specialfields.Priority; | ||
import net.sf.jabref.specialfields.Quality; | ||
|
@@ -166,6 +170,7 @@ public class JabRefFrame extends JFrame implements OutputPrinter { | |
private final IntegrityCheckAction checkIntegrity = new IntegrityCheckAction(this); | ||
|
||
private final ToolBar tlb = new ToolBar(); | ||
private final GlobalSearchBar globalSearchBar = new GlobalSearchBar(this); | ||
|
||
private final JMenuBar mb = new JMenuBar(); | ||
|
||
|
@@ -305,6 +310,11 @@ public class JabRefFrame extends JFrame implements OutputPrinter { | |
Localization.menuTitle("Manage content selectors")); | ||
private final AbstractAction normalSearch = new GeneralAction(Actions.SEARCH, Localization.menuTitle("Search"), | ||
Localization.lang("Search"), Globals.getKeyPrefs().getKey(KeyBinding.SEARCH), IconTheme.JabRefIcon.SEARCH.getIcon()); | ||
private final AbstractAction globalSearch = new GeneralAction(Actions.GLOBAL_SEARCH, | ||
Localization.menuTitle("Global Search"), | ||
Localization.lang("Search globally"), | ||
Globals.getKeyPrefs().getKey(KeyBinding.GLOBAL_SEARCH), | ||
IconTheme.JabRefIcon.SEARCH.getIcon()); | ||
|
||
private final AbstractAction copyKey = new GeneralAction(Actions.COPY_KEY, Localization.menuTitle("Copy BibTeX key"), | ||
Globals.getKeyPrefs().getKey(KeyBinding.COPY_BIBTEX_KEY)); | ||
|
@@ -633,23 +643,34 @@ public void windowClosing(WindowEvent e) { | |
tabbedPane.addChangeListener(e -> { | ||
markActiveBasePanel(); | ||
|
||
BasePanel bp = getCurrentBasePanel(); | ||
if (bp == null) { | ||
BasePanel currentBasePanel = getCurrentBasePanel(); | ||
if (currentBasePanel == null) { | ||
return; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This only disables the global search bar when the last database will be closed. But the search bar will be shown when one is starting jabref with no open database. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good catch, I'll fix it quickly |
||
|
||
if (new SearchPreferences(Globals.prefs).isGlobalSearch()) { | ||
globalSearchBar.performSearch(); | ||
} else { | ||
String content = ""; | ||
SearchQuery currentSearchQuery = currentBasePanel.getCurrentSearchQuery(); | ||
if (currentSearchQuery != null && !currentSearchQuery.getQuery().trim().isEmpty()) { | ||
content = currentSearchQuery.getQuery(); | ||
} | ||
globalSearchBar.setSearchTerm(content, true); | ||
} | ||
|
||
groupToggle.setSelected(sidePaneManager.isComponentVisible("groups")); | ||
previewToggle.setSelected(Globals.prefs.getBoolean(JabRefPreferences.PREVIEW_ENABLED)); | ||
fetcherToggle.setSelected(sidePaneManager.isComponentVisible(generalFetcher.getTitle())); | ||
Globals.getFocusListener().setFocused(bp.getMainTable()); | ||
Globals.getFocusListener().setFocused(currentBasePanel.getMainTable()); | ||
setWindowTitle(); | ||
editModeAction.initName(); | ||
// Update search autocompleter with information for the correct database: | ||
bp.updateSearchManager(); | ||
currentBasePanel.updateSearchManager(); | ||
// Set correct enabled state for Back and Forward actions: | ||
bp.setBackAndForwardEnabledState(); | ||
bp.getUndoManager().postUndoRedoEvent(); | ||
new FocusRequester(bp.getMainTable()); | ||
currentBasePanel.setBackAndForwardEnabledState(); | ||
currentBasePanel.getUndoManager().postUndoRedoEvent(); | ||
new FocusRequester(currentBasePanel.getMainTable()); | ||
}); | ||
|
||
//Note: The registration of Apple event is at the end of initialization, because | ||
|
@@ -894,9 +915,12 @@ private void initLayout() { | |
//getContentPane().add(mb); | ||
setJMenuBar(mb); | ||
con.anchor = GridBagConstraints.NORTH; | ||
//con.gridwidth = 1;//GridBagConstraints.REMAINDER;; | ||
gbl.setConstraints(tlb, con); | ||
getContentPane().add(tlb); | ||
|
||
JPanel toolbarPanel = new JPanel(new WrapLayout(FlowLayout.LEFT)); | ||
toolbarPanel.add(tlb); | ||
toolbarPanel.add(globalSearchBar); | ||
gbl.setConstraints(toolbarPanel, con); | ||
getContentPane().add(toolbarPanel); | ||
|
||
Component lim = Box.createGlue(); | ||
gbl.setConstraints(lim, con); | ||
|
@@ -1479,13 +1503,13 @@ private void createToolBar() { | |
tlb.addSeparator(); | ||
|
||
fetcherToggle = new JToggleButton(generalFetcher.getAction()); | ||
tlb.addJToogleButton(fetcherToggle); | ||
tlb.addJToggleButton(fetcherToggle); | ||
|
||
previewToggle = new JToggleButton(togglePreview); | ||
tlb.addJToogleButton(previewToggle); | ||
tlb.addJToggleButton(previewToggle); | ||
|
||
groupToggle = new JToggleButton(toggleGroups); | ||
tlb.addJToogleButton(groupToggle); | ||
tlb.addJToggleButton(groupToggle); | ||
|
||
tlb.addSeparator(); | ||
|
||
|
@@ -1509,7 +1533,7 @@ public void output(final String s) { | |
|
||
private void initActions() { | ||
openDatabaseOnlyActions.clear(); | ||
openDatabaseOnlyActions.addAll(Arrays.asList(manageSelectors, mergeDatabaseAction, newSubDatabaseAction, save, | ||
openDatabaseOnlyActions.addAll(Arrays.asList(manageSelectors, mergeDatabaseAction, newSubDatabaseAction, save, globalSearch, | ||
saveAs, saveSelectedAs, saveSelectedAsPlain, editModeAction, undo, redo, cut, deleteEntry, copy, paste, mark, markSpecific, unmark, | ||
unmarkAll, rankSubMenu, editEntry, selectAll, copyKey, copyCiteKey, copyKeyAndTitle, editPreamble, editStrings, | ||
toggleGroups, makeKeyAction, normalSearch, generalFetcher.getAction(), mergeEntries, cleanupEntries, exportToClipboard, replaceAll, | ||
|
@@ -2280,7 +2304,7 @@ public void addAction(Action a) { | |
add(b); | ||
} | ||
|
||
public void addJToogleButton(JToggleButton button) { | ||
public void addJToggleButton(JToggleButton button) { | ||
button.setText(null); | ||
if (!OS.OS_X) { | ||
button.setMargin(marg); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix typos
user
,maintable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keyboard shortcuts should be rendered consistenly without space before and after
+
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed