use of org.osgi.service.prefs.BackingStoreException in project azure-tools-for-java by Microsoft.
the class PreferenceUtil method savePreference.
public static void savePreference(String name, String value) {
try {
Preferences prefs = PluginUtil.getPrefs(com.microsoft.azuretools.core.utils.Messages.prefFileName);
prefs.put(name, value);
prefs.flush();
} catch (BackingStoreException e) {
Activator.getDefault().log("Error", e);
}
}
use of org.osgi.service.prefs.BackingStoreException in project azure-tools-for-java by Microsoft.
the class PreferenceUtil method getPreferenceKeys.
public static String[] getPreferenceKeys() {
String[] keys = null;
try {
Preferences prefs = PluginUtil.getPrefs(com.microsoft.azuretools.core.utils.Messages.prefFileName);
keys = prefs.keys();
} catch (BackingStoreException e) {
Activator.getDefault().log("Error", e);
}
return keys;
}
use of org.osgi.service.prefs.BackingStoreException in project azure-tools-for-java by Microsoft.
the class PreferenceUtil method savePreferences.
public static void savePreferences(String name, String[] values) {
Preferences prefs = PluginUtil.getPrefs(com.microsoft.azuretools.core.utils.Messages.prefFileName);
prefs.put(name, convertToPreference(values));
try {
prefs.flush();
} catch (BackingStoreException e) {
Activator.getDefault().log("Error", e);
}
}
use of org.osgi.service.prefs.BackingStoreException in project tdi-studio-se by Talend.
the class Log4jPrefsSettingManager method saveLog4jNodeIntoPref.
public void saveLog4jNodeIntoPref(final String prefNode, final String value) {
try {
Preferences log4jSettings = null;
if (!isLog4jPrefsExist()) {
// if not exist,create it
log4jSettings = getLog4jPreferences(prefNode, true);
} else {
log4jSettings = getLog4jPreferences(prefNode, false);
}
if (log4jSettings != null) {
log4jSettings.put(prefNode, value);
// save log4j activate to prefs
log4jSettings.flush();
}
} catch (BackingStoreException e) {
ExceptionHandler.process(e);
}
}
use of org.osgi.service.prefs.BackingStoreException in project cubrid-manager by CUBRID.
the class SelectWorkspaceDialog method okPressed.
/**
* Press ok
*/
protected void okPressed() {
String workspacePath = workspacePathCombo.getText();
if (workspacePath.length() == 0) {
setErrorMessage(Messages.errNoSelectWorkspace);
return;
}
if (isSwitchWorkspace && workspacePath.equals(getLastSetWorkspaceDirectory())) {
setErrorMessage(Messages.errWorkspaceUsed);
return;
}
//now create
String error = checkWorkspaceDirectory(workspacePath, true, productName, productVersion);
if (error != null) {
setErrorMessage(error);
return;
}
if (!isSwitchWorkspace) {
boolean isOk = false;
try {
Location instanceLoc = Platform.getInstanceLocation();
isOk = instanceLoc.set(new URL("file", null, workspacePath), true);
} catch (IllegalStateException e) {
isOk = false;
} catch (MalformedURLException e) {
isOk = false;
} catch (IOException e) {
isOk = false;
}
if (!isOk) {
setErrorMessage(Messages.errWorkspaceUsed);
return;
}
}
recentUsedWorkspaces.remove(workspacePath);
if (!recentUsedWorkspaces.contains(workspacePath)) {
recentUsedWorkspaces.add(0, workspacePath);
}
// deal with the max history
if (recentUsedWorkspaces.size() > MAX_HISTORY) {
List<String> remove = new ArrayList<String>();
for (int i = MAX_HISTORY; i < recentUsedWorkspaces.size(); i++) {
remove.add(recentUsedWorkspaces.get(i));
}
recentUsedWorkspaces.removeAll(remove);
}
// create a string concatenation of all our last used workspaces
StringBuffer buf = new StringBuffer();
for (int i = 0; i < recentUsedWorkspaces.size(); i++) {
buf.append(recentUsedWorkspaces.get(i));
if (i != recentUsedWorkspaces.size() - 1) {
buf.append(WORKSPACE_SPLIT_CHAR);
}
}
// save them into our preferences
PREFERENCES.putBoolean(KEY_NOT_SHOW_WORKSPACE_SELECTION_DIALOG, rememberWorkspaceButton.getSelection());
PREFERENCES.put(KEY_RECENT_WORKSPACES, buf.toString());
PREFERENCES.put(KEY_LAST_WORKSPACE, workspacePath);
try {
PREFERENCES.flush();
} catch (BackingStoreException e) {
//NOPMD
//ignore
}
super.okPressed();
}
Aggregations