本文整理汇总了Java中org.osgi.service.prefs.BackingStoreException类的典型用法代码示例。如果您正苦于以下问题:Java BackingStoreException类的具体用法?Java BackingStoreException怎么用?Java BackingStoreException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BackingStoreException类属于org.osgi.service.prefs包,在下文中一共展示了BackingStoreException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: saveState
import org.osgi.service.prefs.BackingStoreException; //导入依赖的package包/类
@Override
public IStatus saveState(final IProgressMonitor monitor) {
final IStatus superSaveResult = super.saveState(monitor);
if (superSaveResult.isOK()) {
final Preferences node = getPreferences();
node.put(ORDERED_FILTERS_KEY, Joiner.on(SEPARATOR).join(orderedWorkingSetFilters));
try {
node.flush();
} catch (final BackingStoreException e) {
final String message = "Error occurred while saving state to preference store.";
LOGGER.error(message, e);
return statusHelper.createError(message, e);
}
return statusHelper.OK();
}
return superSaveResult;
}
示例2: saveState
import org.osgi.service.prefs.BackingStoreException; //导入依赖的package包/类
@Override
public IStatus saveState(final IProgressMonitor monitor) {
final Preferences node = getPreferences();
// Save ordered labels.
node.put(ORDERED_IDS_KEY, Joiner.on(SEPARATOR).join(orderedWorkingSetIds));
// Save visible labels.
node.put(VISIBLE_IDS_KEY, Joiner.on(SEPARATOR).join(visibleWorkingSetIds));
try {
node.flush();
} catch (final BackingStoreException e) {
final String message = "Error occurred while saving state to preference store.";
LOGGER.error(message, e);
return statusHelper.createError(message, e);
}
return statusHelper.OK();
}
示例3: saveState
import org.osgi.service.prefs.BackingStoreException; //导入依赖的package包/类
private IStatus saveState() {
final Preferences node = getPreferences();
// Top level element.
node.putBoolean(IS_WORKINGSET_TOP_LEVEL_KEY, workingSetTopLevel.get());
// Active working set manager.
final WorkingSetManager activeManager = getActiveManager();
final String activeId = activeManager == null ? null : activeManager.getId();
node.put(ACTIVE_MANAGER_KEY, Strings.nullToEmpty(activeId));
try {
node.flush();
return OK_STATUS;
} catch (final BackingStoreException e) {
final String message = "Unexpected error when trying to persist working set broker state.";
LOGGER.error(message, e);
return statusHelper.createError(message, e);
}
}
示例4: save
import org.osgi.service.prefs.BackingStoreException; //导入依赖的package包/类
@Override
public IStatus save() {
try {
final IEclipsePreferences node = InstanceScope.INSTANCE.getNode(QUALIFIER);
for (final Entry<Binary, URI> entry : getOrCreateState().entrySet()) {
final URI path = entry.getValue();
if (null != path) {
final File file = new File(path);
if (file.isDirectory()) {
node.put(entry.getKey().getId(), file.getAbsolutePath());
}
} else {
// Set to default.
node.put(entry.getKey().getId(), "");
}
}
node.flush();
return OK_STATUS;
} catch (final BackingStoreException e) {
final String message = "Unexpected error when trying to persist binary preferences.";
LOGGER.error(message, e);
return statusHelper.createError(message, e);
}
}
示例5: removeResource
import org.osgi.service.prefs.BackingStoreException; //导入依赖的package包/类
/**
* Remove a resource (i.e. all its properties) from the builder's preferences.
*
* @param prefs the preferences
* @param resource the resource
* @throws BackingStoreException
*/
public static void removeResource(Preferences prefs, IResource resource)
throws CoreException {
try {
String[] keys = prefs.keys();
for (String key: keys) {
if (key.endsWith("//" + resource.getProjectRelativePath().toPortableString())) {
prefs.remove(key);
}
}
prefs.flush();
} catch (BackingStoreException e) {
throw new CoreException(new Status(
IStatus.ERROR, MinifyBuilder.BUILDER_ID, e.getMessage(), e));
}
}
示例6: moveResource
import org.osgi.service.prefs.BackingStoreException; //导入依赖的package包/类
/**
* Associate one resource's properties with another resource.
*
* @param fromPrefs the preferences to take the properties from
* @param fromResource the resource to take the properties from
* @param toPrefs the preferences to move the properties to
* @param toResource the resource to associated with the properties
* @throws BackingStoreException
*/
public static void moveResource(Preferences fromPrefs, IResource fromResource,
Preferences toPrefs, IResource toResource)
throws CoreException {
try {
String[] keys = fromPrefs.keys();
for (String key: keys) {
if (key.endsWith("//" + fromResource.getProjectRelativePath().toPortableString())) {
String resourcePreference = key.substring(0, key.indexOf('/'));
toPrefs.put(preferenceKey(toResource, resourcePreference), fromPrefs.get(key, ""));
fromPrefs.remove(key);
}
}
fromPrefs.flush();
toPrefs.flush();
} catch (BackingStoreException e) {
throw new CoreException(new Status(
IStatus.ERROR, MinifyBuilder.BUILDER_ID, e.getMessage(), e));
}
}
示例7: performOk
import org.osgi.service.prefs.BackingStoreException; //导入依赖的package包/类
public boolean performOk() {
try {
Preferences prefs = builderPreferences();
if (!performSpecificOk(prefs)) {
return false;
}
for (int i = 0; i < options()[0].length; i++) {
if (selection.getText().equals(options()[1][i])) {
prefs.put(preferenceKey(MinifyBuilder.MINIFIER), options()[0][i]);
}
}
if (prefs.get(preferenceKey(
MinifyBuilder.MINIFIER), MinifyBuilder.DONT_MINIFY)
.equals(MinifyBuilder.DONT_MINIFY)) {
PrefsAccess.removeResource(prefs, (IResource)getElement());
}
prefs.flush();
((IResource)getElement()).touch(null);
} catch (CoreException | BackingStoreException e) {
return false;
}
return true;
}
示例8: initVisits
import org.osgi.service.prefs.BackingStoreException; //导入依赖的package包/类
private void initVisits() {
String currentTime = String.valueOf(System.currentTimeMillis());
this.currentVisit = currentTime;
this.firstVisit = preferences.get(USAGE_REPORT_PREF.FIRST_VISIT, null);
if (firstVisit == null) {
this.firstVisit = currentTime;
preferences.put(USAGE_REPORT_PREF.FIRST_VISIT, firstVisit);
}
lastVisit = preferences.get(USAGE_REPORT_PREF.LAST_VISIT, currentTime);
visitCount = preferences.getLong(USAGE_REPORT_PREF.VISIT_COUNT, 1);
preferences.put(USAGE_REPORT_PREF.LAST_VISIT, currentTime);
preferences.putLong(USAGE_REPORT_PREF.VISIT_COUNT, visitCount+1);
try {
preferences.flush();
} catch (BackingStoreException e) {
Log.log(Log.LOG_ERROR, Messages.EclipseEnvironment_Error_SavePreferences, e);
}
}
示例9: loadPrefsFromNode
import org.osgi.service.prefs.BackingStoreException; //导入依赖的package包/类
protected void loadPrefsFromNode(Preferences preferences) {
try {
String[] keys = preferences.keys();
if (keys.length <= 0) {
return;
}
List<KeyValue> preferenceList = preferenceEntries.get(preferences.absolutePath());
if (null == preferenceList) {
preferenceList = new ArrayList<>();
preferenceEntries.put(preferences.absolutePath(), preferenceList);
}
for (String key : keys) {
String value = preferences.get(key, "*default*");
KeyValue current = new KeyValue(preferences.absolutePath(), key, value);
preferenceList.add(current);
}
} catch (org.osgi.service.prefs.BackingStoreException e) {
PrefEditorPlugin.log(e);
}
}
示例10: save
import org.osgi.service.prefs.BackingStoreException; //导入依赖的package包/类
@Override
public void save() throws BackingStoreException {
// Save Themes in the
// "${workspace_loc}/metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.tm4e.ui.prefs"
String json = PreferenceHelper.toJsonThemes(
Arrays.stream(getThemes()).filter(t -> t.getPluginId() == null).collect(Collectors.toList()));
IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(TMUIPlugin.PLUGIN_ID);
prefs.put(PreferenceConstants.THEMES, json);
// Save Theme associations in the
// "${workspace_loc}/metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.tm4e.ui.prefs"
json = PreferenceHelper.toJsonThemeAssociations(Arrays.stream(getAllThemeAssociations())
.filter(t -> t.getPluginId() == null).collect(Collectors.toList()));
prefs.put(PreferenceConstants.THEME_ASSOCIATIONS, json);
// Save preferences
prefs.flush();
}
示例11: updateConfigurationFromSettings
import org.osgi.service.prefs.BackingStoreException; //导入依赖的package包/类
private static boolean updateConfigurationFromSettings(AsciidocConfiguration configuration, IProject project) {
final IScopeContext projectScope = new ProjectScope(project);
IEclipsePreferences preferences = projectScope.getNode(Activator.PLUGIN_ID);
try {
createSettings(project, BACKEND_DEFAULT, RESOURCESPATH_DEFAULT, SOURCESPATH_DEFAULT, STYLESHEETPATH_DEFAULT, TARGETPATH_DEFAULT);
configuration.setBackend(preferences.get(BACKEND_PROPERTY, BACKEND_DEFAULT));
configuration.setResourcesPath(preferences.get(RESOURCESPATH_PROPERTY, RESOURCESPATH_DEFAULT));
configuration.setSourcesPath(preferences.get(SOURCESPATH_PROPERTY, SOURCESPATH_DEFAULT));
configuration.setStylesheetPath(preferences.get(STYLESHEETPATH_PROPERTY, STYLESHEETPATH_DEFAULT));
configuration.setTargetPath(preferences.get(TARGETPATH_PROPERTY, TARGETPATH_DEFAULT));
} catch (BackingStoreException e) {
Activator.getDefault().getLog().log(new Status(IStatus.WARNING, Activator.PLUGIN_ID, e.getMessage(), e));
return false;
}
configuration.source = AsciidocConfigurationSource.SETTINGS;
return true;
}
示例12: addSettings
import org.osgi.service.prefs.BackingStoreException; //导入依赖的package包/类
private static void addSettings(IProject project, String workspaceRoot, List<String> targets,
List<String> buildFlags) throws BackingStoreException {
IScopeContext projectScope = new ProjectScope(project);
Preferences projectNode = projectScope.getNode(Activator.PLUGIN_ID);
int i = 0;
for (String target : targets) {
projectNode.put("target" + i, target);
i++;
}
projectNode.put("workspaceRoot", workspaceRoot);
i = 0;
for (String flag : buildFlags) {
projectNode.put("buildFlag" + i, flag);
i++;
}
projectNode.flush();
}
示例13: isSourcePath
import org.osgi.service.prefs.BackingStoreException; //导入依赖的package包/类
private boolean isSourcePath(String path) throws JavaModelException, BackingStoreException {
Path pp = new File(instance.getWorkspaceRoot().toString() + File.separator + path).toPath();
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
for (IClasspathEntry entry : project.getRawClasspath()) {
if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
IResource res = root.findMember(entry.getPath());
if (res != null) {
String file = res.getLocation().toOSString();
if (!file.isEmpty() && pp.startsWith(file)) {
IPath[] inclusionPatterns = entry.getInclusionPatterns();
if (!matchPatterns(pp, entry.getExclusionPatterns()) && (inclusionPatterns == null
|| inclusionPatterns.length == 0 || matchPatterns(pp, inclusionPatterns))) {
return true;
}
}
}
}
}
return false;
}
示例14: persistList
import org.osgi.service.prefs.BackingStoreException; //导入依赖的package包/类
public boolean persistList(final List list, final String key, final Class itemType) {
try {
if (currentNode.nodeExists(key)) {
currentNode.node(key).removeNode();
}
final Preferences listNode = currentNode.node(key);
final ObjectSerializer serializer = getObjectSerializer(itemType);
for (int i = 0; i < list.size(); i++) {
final String objString = serializer.toString(list.get(i));
listNode.put(String.valueOf(i), objString);
}
return true;
} catch (final BackingStoreException ex) {
return false;
}
}
示例15: restoreList
import org.osgi.service.prefs.BackingStoreException; //导入依赖的package包/类
public List restoreList(final String key, final Class itemType) {
try {
if (!currentNode.nodeExists(key)) {
return null;
}
final List results = new ArrayList();
final Preferences listNode = currentNode.node(key);
final String[] keys = listNode.keys();
Arrays.sort(keys);
final ObjectSerializer serializer = getObjectSerializer(itemType);
for (int i = 0; i < keys.length; i++) {
final String currentKey = listNode.get(keys[i], null);
final Object object = serializer.fromString(currentKey);
if (object != null) {
results.add(object);
}
}
return results;
} catch (final BackingStoreException ex) {
return null;
}
}