use of org.jabref.gui.BasePanelMode in project jabref by JabRef.
the class MainTableSelectionListener method editSignalled.
public void editSignalled(BibEntry entry) {
final BasePanelMode mode = panel.getMode();
if (mode != BasePanelMode.SHOWING_EDITOR) {
panel.showEntryEditor(panel.getEntryEditor(entry));
}
panel.getCurrentEditor().requestFocus();
}
use of org.jabref.gui.BasePanelMode in project jabref by JabRef.
the class MainTableSelectionListener method listChanged.
@Override
public void listChanged(ListEvent<BibEntry> e) {
if (!enabled) {
return;
}
EventList<BibEntry> selected = e.getSourceList();
if (selected.isEmpty()) {
return;
}
final BibEntry newSelected = selected.get(0);
if ((panel.getMode() == BasePanelMode.SHOWING_EDITOR || panel.getMode() == BasePanelMode.WILL_SHOW_EDITOR) && panel.getCurrentEditor() != null && newSelected == panel.getCurrentEditor().getEntry()) {
// entry already selected and currently editing it, do not steal the focus from the selected textfield
return;
}
if (newSelected != null) {
// What is the panel already showing?
final BasePanelMode mode = panel.getMode();
if ((mode == BasePanelMode.WILL_SHOW_EDITOR) || (mode == BasePanelMode.SHOWING_EDITOR)) {
// An entry is currently being edited.
EntryEditor oldEditor = panel.getCurrentEditor();
String visName = null;
if (oldEditor != null) {
visName = oldEditor.getVisiblePanelName();
}
// Get a new editor for the entry to edit:
EntryEditor newEditor = panel.getEntryEditor(newSelected);
// Show the new editor unless it was already visible:
if (!Objects.equals(newEditor, oldEditor) || (mode != BasePanelMode.SHOWING_EDITOR)) {
if (visName != null) {
newEditor.setVisiblePanel(visName);
}
panel.showEntryEditor(newEditor);
SwingUtilities.invokeLater(() -> table.ensureVisible(table.getSelectedRow()));
} else {
// if not used destroy the EntryEditor
newEditor.setMovingToDifferentEntry();
}
} else {
// Either nothing or a preview was shown. Update the preview.
if (previewActive) {
updatePreview(newSelected, false);
}
}
}
}
use of org.jabref.gui.BasePanelMode in project jabref by JabRef.
the class MainTableSelectionListener method updatePreview.
private void updatePreview(final BibEntry toShow, final boolean changedPreview, int repeats) {
if (workingOnPreview) {
if (repeats > 0) {
// We've already waited once. Give up on this selection.
return;
}
Timer t = new Timer(50, actionEvent -> updatePreview(toShow, changedPreview, 1));
t.setRepeats(false);
t.start();
return;
}
EventList<BibEntry> list = table.getSelected();
// Check if the entry to preview is still selected:
if ((list.size() != 1) || (list.get(0) != toShow)) {
return;
}
final BasePanelMode mode = panel.getMode();
workingOnPreview = true;
SwingUtilities.invokeLater(() -> {
preview.setEntry(toShow);
// If nothing was already shown, set the preview and move the separator:
if (changedPreview || (mode == BasePanelMode.SHOWING_NOTHING)) {
panel.showPreview(preview);
panel.adjustSplitter();
}
workingOnPreview = false;
});
}
Aggregations