use of org.jabref.gui.EntryTypeDialog in project jabref by JabRef.
the class NewEntryAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
String thisType = type;
if (thisType == null) {
EntryTypeDialog etd = new EntryTypeDialog(jabRefFrame);
etd.setLocationRelativeTo(jabRefFrame);
etd.setVisible(true);
EntryType tp = etd.getChoice();
if (tp == null) {
return;
}
thisType = tp.getName();
}
if (jabRefFrame.getBasePanelCount() > 0) {
jabRefFrame.getCurrentBasePanel().newEntry(EntryTypes.getType(thisType, jabRefFrame.getCurrentBasePanel().getBibDatabaseContext().getMode()).get());
} else {
LOGGER.info("Action 'New entry' must be disabled when no database is open.");
}
}
use of org.jabref.gui.EntryTypeDialog in project jabref by JabRef.
the class PdfImporter method createNewEntry.
private Optional<BibEntry> createNewEntry() {
// Find out what type is desired
EntryTypeDialog etd = new EntryTypeDialog(frame);
// We want to center the dialog, to make it look nicer.
etd.setLocationRelativeTo(frame);
etd.setVisible(true);
EntryType type = etd.getChoice();
if (type != null) {
// Only if the dialog was not canceled.
final BibEntry bibEntry = new BibEntry(type.getName());
try {
panel.getDatabase().insertEntry(bibEntry);
// Set owner/timestamp if options are enabled:
List<BibEntry> list = new ArrayList<>();
list.add(bibEntry);
UpdateField.setAutomaticFields(list, true, true, Globals.prefs.getUpdateFieldPreferences());
// Create an UndoableInsertEntry object.
panel.getUndoManager().addEdit(new UndoableInsertEntry(panel.getDatabase(), bibEntry, panel));
panel.output(Localization.lang("Added new") + " '" + type.getName().toLowerCase(Locale.ROOT) + "' " + Localization.lang("entry") + ".");
// and adjustment of the splitter.
if (panel.getMode() != BasePanelMode.SHOWING_EDITOR) {
panel.setMode(BasePanelMode.WILL_SHOW_EDITOR);
}
SwingUtilities.invokeLater(() -> panel.showEntry(bibEntry));
// The database just changed.
panel.markBaseChanged();
return Optional.of(bibEntry);
} catch (KeyCollisionException ex) {
LOGGER.info("Key collision occurred", ex);
}
}
return Optional.empty();
}
Aggregations