use of org.jabref.model.database.BibDatabaseMode in project jabref by JabRef.
the class BibtexKeyPatternPanel method buildGUI.
private void buildGUI() {
JPanel pan = new JPanel();
JScrollPane sp = new JScrollPane(pan);
sp.setPreferredSize(new Dimension(100, 100));
sp.setBorder(BorderFactory.createEmptyBorder());
pan.setLayout(gbl);
setLayout(gbl);
// The header - can be removed
JLabel lblEntryType = new JLabel(Localization.lang("Entry type"));
Font f = new Font("plain", Font.BOLD, 12);
lblEntryType.setFont(f);
con.gridx = 0;
con.gridy = 0;
con.gridwidth = 1;
con.gridheight = 1;
con.fill = GridBagConstraints.VERTICAL;
con.anchor = GridBagConstraints.WEST;
con.insets = new Insets(5, 5, 10, 0);
gbl.setConstraints(lblEntryType, con);
pan.add(lblEntryType);
JLabel lblKeyPattern = new JLabel(Localization.lang("Key pattern"));
lblKeyPattern.setFont(f);
con.gridx = 1;
con.gridy = 0;
con.gridheight = 1;
con.fill = GridBagConstraints.HORIZONTAL;
con.anchor = GridBagConstraints.WEST;
con.insets = new Insets(5, 5, 10, 5);
gbl.setConstraints(lblKeyPattern, con);
pan.add(lblKeyPattern);
con.gridy = 1;
con.gridx = 0;
JLabel lab = new JLabel(Localization.lang("Default pattern"));
gbl.setConstraints(lab, con);
pan.add(lab);
con.gridx = 1;
gbl.setConstraints(defaultPat, con);
pan.add(defaultPat);
con.insets = new Insets(5, 5, 10, 5);
JButton btnDefault = new JButton(Localization.lang("Default"));
btnDefault.addActionListener(e -> defaultPat.setText((String) Globals.prefs.defaults.get(JabRefPreferences.DEFAULT_BIBTEX_KEY_PATTERN)));
con.gridx = 2;
int y = 2;
gbl.setConstraints(btnDefault, con);
pan.add(btnDefault);
BibDatabaseMode mode;
// check mode of currently used DB
if (panel != null) {
mode = panel.getBibDatabaseContext().getMode();
} else {
// use preferences value if no DB is open
mode = Globals.prefs.getDefaultBibDatabaseMode();
}
for (EntryType type : EntryTypes.getAllValues(mode)) {
textFields.put(type.getName().toLowerCase(Locale.ROOT), addEntryType(pan, type, y));
y++;
}
con.fill = GridBagConstraints.BOTH;
con.gridx = 0;
con.gridy = 1;
con.gridwidth = 3;
con.weightx = 1;
con.weighty = 1;
gbl.setConstraints(sp, con);
add(sp);
// A help button
con.gridwidth = 1;
con.gridx = 1;
con.gridy = 2;
con.fill = GridBagConstraints.HORIZONTAL;
//
con.weightx = 0;
con.weighty = 0;
con.anchor = GridBagConstraints.SOUTHEAST;
con.insets = new Insets(0, 5, 0, 5);
JButton hlb = new JButton(IconTheme.JabRefIcon.HELP.getSmallIcon());
hlb.setToolTipText(Localization.lang("Help on key patterns"));
gbl.setConstraints(hlb, con);
add(hlb);
hlb.addActionListener(help);
// And finally a button to reset everything
JButton btnDefaultAll = new JButton(Localization.lang("Reset all"));
con.gridx = 2;
con.gridy = 2;
con.weightx = 1;
con.weighty = 0;
con.anchor = GridBagConstraints.SOUTHEAST;
con.insets = new Insets(20, 5, 0, 5);
gbl.setConstraints(btnDefaultAll, con);
btnDefaultAll.addActionListener(e -> {
for (JTextField field : textFields.values()) {
field.setText("");
}
defaultPat.setText((String) Globals.prefs.defaults.get(JabRefPreferences.DEFAULT_BIBTEX_KEY_PATTERN));
});
add(btnDefaultAll);
}
use of org.jabref.model.database.BibDatabaseMode in project jabref by JabRef.
the class SharedDatabaseUIManager method openNewSharedDatabaseTab.
/**
* Opens a new shared database tab with the given {@link DBMSConnectionProperties}.
*
* @param dbmsConnectionProperties Connection data
* @param raiseTab If <code>true</code> the new tab gets selected.
* @return BasePanel which also used by {@link SaveDatabaseAction}
*/
public BasePanel openNewSharedDatabaseTab(DBMSConnectionProperties dbmsConnectionProperties) throws SQLException, DatabaseNotSupportedException, InvalidDBMSConnectionPropertiesException {
JabRefFrame frame = JabRefGUI.getMainFrame();
BibDatabaseMode selectedMode = Globals.prefs.getDefaultBibDatabaseMode();
BibDatabaseContext bibDatabaseContext = new BibDatabaseContext(new Defaults(selectedMode), DatabaseLocation.SHARED, Globals.prefs.getKeywordDelimiter(), Globals.prefs.getKeyPattern());
dbmsSynchronizer = bibDatabaseContext.getDBMSSynchronizer();
dbmsSynchronizer.openSharedDatabase(dbmsConnectionProperties);
dbmsSynchronizer.registerListener(this);
frame.output(Localization.lang("Connection_to_%0_server_established.", dbmsConnectionProperties.getType().toString()));
return frame.addTab(bibDatabaseContext, true);
}
use of org.jabref.model.database.BibDatabaseMode in project jabref by JabRef.
the class BibtexParserTest method integrationTestBiblatexMode.
@Test
public void integrationTestBiblatexMode() throws IOException {
ParserResult result = parser.parse(new StringReader("@comment{jabref-meta: databaseType:biblatex;}"));
Optional<BibDatabaseMode> mode = result.getMetaData().getMode();
assertEquals(BibDatabaseMode.BIBLATEX, mode.get());
}
use of org.jabref.model.database.BibDatabaseMode in project jabref by JabRef.
the class EntryCustomizationDialog method updateEntriesForChangedTypes.
private void updateEntriesForChangedTypes(List<String> actuallyChangedTypes) {
for (BasePanel bp : frame.getBasePanelList()) {
// get all affected entries
List<BibEntry> filtered = bp.getDatabase().getEntries().stream().filter(entry -> actuallyChangedTypes.contains(entry.getType().toLowerCase(Locale.ENGLISH))).collect(Collectors.toList());
// update all affected entries with new type
filtered.forEach(entry -> EntryTypes.getType(entry.getType(), bibDatabaseMode).ifPresent(entry::setType));
}
}
use of org.jabref.model.database.BibDatabaseMode in project jabref by JabRef.
the class CheckForNewEntryTypesAction method performAction.
@Override
public void performAction(BasePanel panel, ParserResult parserResult) {
BibDatabaseMode mode = getBibDatabaseModeFromParserResult(parserResult);
List<EntryType> typesToStore = determineEntryTypesToSave(panel, getListOfUnknownAndUnequalCustomizations(parserResult), mode);
if (!typesToStore.isEmpty()) {
typesToStore.forEach(type -> EntryTypes.addOrModifyCustomEntryType((CustomEntryType) type, mode));
CustomEntryTypesManager.saveCustomEntryTypes(Globals.prefs);
}
}
Aggregations