use of java.util.prefs.BackingStoreException in project jabref by JabRef.
the class JabRefPreferences method putKeyPattern.
/**
* Adds the given key pattern to the preferences
*
* @param pattern the pattern to store
*/
public void putKeyPattern(GlobalBibtexKeyPattern pattern) {
keyPattern = pattern;
// Store overridden definitions to Preferences.
Preferences pre = Preferences.userNodeForPackage(PREFS_BASE_CLASS).node(BIBTEX_KEY_PATTERNS_NODE);
try {
// We remove all old entries.
pre.clear();
} catch (BackingStoreException ex) {
LOGGER.info("BackingStoreException in JabRefPreferences.putKeyPattern", ex);
}
Set<String> allKeys = pattern.getAllKeys();
for (String key : allKeys) {
if (!pattern.isDefaultValue(key)) {
// no default value
// the first entry in the array is the full pattern
// see org.jabref.logic.labelPattern.BibtexKeyPatternUtil.split(String)
pre.put(key, pattern.getValue(key).get(0));
}
}
}
use of java.util.prefs.BackingStoreException in project JMRI by JMRI.
the class ProgrammerConfigManager method savePreferences.
@Override
public void savePreferences(Profile profile) {
Preferences preferences = ProfileUtils.getPreferences(profile, this.getClass(), true);
if (this.defaultFile != null) {
preferences.put(DEFAULT_FILE, this.defaultFile);
} else {
preferences.remove(DEFAULT_FILE);
}
preferences.putBoolean(SHOW_EMPTY_PANES, this.showEmptyPanes);
preferences.putBoolean(SHOW_CV_NUMBERS, this.showCvNumbers);
preferences.putBoolean(CAN_CACHE_DEFAULT, this.canCacheDefault);
preferences.putBoolean(DO_CONFIRM_READ, this.doConfirmRead);
try {
preferences.sync();
} catch (BackingStoreException ex) {
log.error("Unable to save preferences.", ex);
}
}
use of java.util.prefs.BackingStoreException in project cayenne by apache.
the class CayenneModelerController method changePathInLastProjListAction.
public void changePathInLastProjListAction(File oldFile, File newFile) {
Preferences frefLastProjFiles = ModelerPreferences.getLastProjFilesPref();
List<File> arr = ModelerPreferences.getLastProjFiles();
// Add proj path to the preferences
arr.remove(oldFile);
arr.remove(newFile);
arr.add(0, newFile);
while (arr.size() > ModelerPreferences.LAST_PROJ_FILES_SIZE) {
arr.remove(arr.size() - 1);
}
try {
frefLastProjFiles.clear();
} catch (BackingStoreException e) {
// ignore exception
}
int size = arr.size();
for (int i = 0; i < size; i++) {
frefLastProjFiles.put(String.valueOf(i), arr.get(i).getAbsolutePath());
}
getLastDirectory().setDirectory(newFile);
frame.fireRecentFileListChanged();
}
use of java.util.prefs.BackingStoreException in project BoofCV by lessthanoptimal.
the class OpenWebcamDialog method savePreferences.
public void savePreferences() {
if (selectedCamera == null)
return;
Preferences prefs = Preferences.userRoot().node(getClass().getSimpleName());
prefs.put("camera", selectedCamera.getName());
prefs.putInt("width", width);
prefs.putInt("height", height);
try {
prefs.flush();
} catch (BackingStoreException ignore) {
}
}
use of java.util.prefs.BackingStoreException in project blue by kunstmusik.
the class InfoDialog method showInformationDialog.
public static final synchronized void showInformationDialog(Component parent, String information, String title) {
if (infoText == null) {
try {
if (SwingUtilities.isEventDispatchThread()) {
infoText = new MimeTypeEditorComponent("text/plain");
} else {
SwingUtilities.invokeAndWait(() -> infoText = new MimeTypeEditorComponent("text/plain"));
}
} catch (InterruptedException ex) {
Exceptions.printStackTrace(ex);
} catch (InvocationTargetException ex) {
Exceptions.printStackTrace(ex);
}
}
infoText.setText(information);
infoText.getJEditorPane().getCaret().setDot(0);
final JDialog dlg = new JDialog(SwingUtilities.getWindowAncestor(parent));
dlg.getContentPane().add(infoText);
dlg.setModal(true);
dlg.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
dlg.setTitle(title);
final Preferences prefs = NbPreferences.forModule(InfoDialog.class);
int w = prefs.getInt("infoDialogWidth", 760);
int h = prefs.getInt("infoDialogHeight", 400);
dlg.setSize(new Dimension(w, h));
dlg.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
final Preferences prefs = NbPreferences.forModule(InfoDialog.class);
prefs.putInt("infoDialogWidth", dlg.getWidth());
prefs.putInt("infoDialogHeight", dlg.getHeight());
prefs.putInt("infoDialogX", dlg.getX());
prefs.putInt("infoDialogY", dlg.getY());
try {
prefs.sync();
} catch (BackingStoreException ex) {
Exceptions.printStackTrace(ex);
}
}
});
int x = prefs.getInt("infoDialogX", -1);
int y = prefs.getInt("infoDialogY", -1);
if (x > 0 && y > 0) {
dlg.setLocation(x, y);
} else {
GUI.centerOnScreen(dlg);
}
dlg.setVisible(true);
infoText.setText("");
}
Aggregations