當前位置: 首頁>>代碼示例>>Java>>正文


Java BackingStoreException類代碼示例

本文整理匯總了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;
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:23,代碼來源:ProjectNameFilterAwareWorkingSetManager.java

示例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();
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:22,代碼來源:WorkingSetManagerImpl.java

示例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);
		}
	}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:21,代碼來源:WorkingSetManagerBrokerImpl.java

示例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);
	}
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:25,代碼來源:OsgiBinariesPreferenceStore.java

示例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));
	}
}
 
開發者ID:mnlipp,項目名稱:EclipseMinifyBuilder,代碼行數:23,代碼來源:PrefsAccess.java

示例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));
	}
}
 
開發者ID:mnlipp,項目名稱:EclipseMinifyBuilder,代碼行數:29,代碼來源:PrefsAccess.java

示例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;
}
 
開發者ID:mnlipp,項目名稱:EclipseMinifyBuilder,代碼行數:24,代碼來源:MinifyPropertyPage.java

示例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);
    }
}
 
開發者ID:pgcodekeeper,項目名稱:pgcodekeeper,代碼行數:20,代碼來源:EclipseEnvironment.java

示例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);
	}
}
 
開發者ID:32kda,項目名稱:com.onpositive.prefeditor,代碼行數:21,代碼來源:PlatformPreferenceProvider.java

示例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();
}
 
開發者ID:eclipse,項目名稱:tm4e,代碼行數:19,代碼來源:ThemeManager.java

示例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;
}
 
開發者ID:awltech,項目名稱:eclipse-asciidoctools,代碼行數:18,代碼來源:AsciidocConfiguration.java

示例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();
}
 
開發者ID:bazelbuild,項目名稱:eclipse,代碼行數:18,代碼來源:BazelProjectSupport.java

示例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;
}
 
開發者ID:bazelbuild,項目名稱:eclipse,代碼行數:21,代碼來源:BazelClasspathContainer.java

示例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;
    }
}
 
開發者ID:Microsoft,項目名稱:team-explorer-everywhere,代碼行數:20,代碼來源:ViewState.java

示例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;
    }
}
 
開發者ID:Microsoft,項目名稱:team-explorer-everywhere,代碼行數:26,代碼來源:ViewState.java


注:本文中的org.osgi.service.prefs.BackingStoreException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。