当前位置: 首页>>代码示例>>Java>>正文


Java Preferences类代码示例

本文整理汇总了Java中org.osgi.service.prefs.Preferences的典型用法代码示例。如果您正苦于以下问题:Java Preferences类的具体用法?Java Preferences怎么用?Java Preferences使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Preferences类属于org.osgi.service.prefs包,在下文中一共展示了Preferences类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: saveState

import org.osgi.service.prefs.Preferences; //导入依赖的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: restoreState

import org.osgi.service.prefs.Preferences; //导入依赖的package包/类
@Override
public IStatus restoreState(final IProgressMonitor monitor) {
	final IStatus superRestoreResult = super.restoreState(monitor);

	if (superRestoreResult.isOK()) {

		final Preferences node = getPreferences();
		final String orderedFilters = node.get(ORDERED_FILTERS_KEY, EMPTY_STRING);
		if (!Strings.isNullOrEmpty(orderedFilters)) {
			orderedWorkingSetFilters.clear();
			orderedWorkingSetFilters.addAll(Arrays.asList(orderedFilters.split(SEPARATOR)));
		}

		discardWorkingSetCaches();
		return statusHelper.OK();

	}

	return superRestoreResult;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:21,代码来源:ProjectNameFilterAwareWorkingSetManager.java

示例3: saveState

import org.osgi.service.prefs.Preferences; //导入依赖的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

示例4: restoreState

import org.osgi.service.prefs.Preferences; //导入依赖的package包/类
@Override
public IStatus restoreState(final IProgressMonitor monitor) {

	final Preferences node = getPreferences();

	// Restore ordered labels.
	final String orderedLabels = node.get(ORDERED_IDS_KEY, EMPTY_STRING);
	if (!Strings.isNullOrEmpty(orderedLabels)) {
		orderedWorkingSetIds.clear();
		orderedWorkingSetIds.addAll(Arrays.asList(orderedLabels.split(SEPARATOR)));
	}

	// Restore visible labels.
	final String visibleLabels = node.get(VISIBLE_IDS_KEY, EMPTY_STRING);
	if (!Strings.isNullOrEmpty(visibleLabels)) {
		visibleWorkingSetIds.clear();
		visibleWorkingSetIds.addAll(Arrays.asList(visibleLabels.split(SEPARATOR)));
	}

	discardWorkingSetCaches();

	return statusHelper.OK();
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:24,代码来源:WorkingSetManagerImpl.java

示例5: saveState

import org.osgi.service.prefs.Preferences; //导入依赖的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

示例6: restoreState

import org.osgi.service.prefs.Preferences; //导入依赖的package包/类
private IStatus restoreState() {

		final Preferences node = getPreferences();
		// Top level element.
		workingSetTopLevel.set(node.getBoolean(IS_WORKINGSET_TOP_LEVEL_KEY, false));

		// Active working set manager.
		final String value = node.get(ACTIVE_MANAGER_KEY, "");
		WorkingSetManager workingSetManager = contributions.get().get(value);
		if (workingSetManager == null) {
			if (!contributions.get().isEmpty()) {
				workingSetManager = contributions.get().values().iterator().next();
			}
		}
		if (workingSetManager != null) {
			setActiveManager(workingSetManager);
		}

		return Status.OK_STATUS;
	}
 
开发者ID:eclipse,项目名称:n4js,代码行数:21,代码来源:WorkingSetManagerBrokerImpl.java

示例7: removeResource

import org.osgi.service.prefs.Preferences; //导入依赖的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

示例8: moveResource

import org.osgi.service.prefs.Preferences; //导入依赖的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

示例9: createContents

import org.osgi.service.prefs.Preferences; //导入依赖的package包/类
/**
 * @see PreferencePage#createContents(Composite)
 */
protected Control createContents(Composite parent) {
	Composite composite = new Composite(parent, SWT.NONE);
	GridLayout layout = new GridLayout();
	composite.setLayout(layout);
	GridData data = new GridData(GridData.FILL);
	data.grabExcessHorizontalSpace = true;
	composite.setLayoutData(data);

	Preferences prefs = builderPreferences();
	
	addFirstSection(composite);
	addSeparator(composite);
	addSecondSection(composite, prefs);
	addSpecificSection(composite, prefs);
	
	return composite;
}
 
开发者ID:mnlipp,项目名称:EclipseMinifyBuilder,代码行数:21,代码来源:MinifyPropertyPage.java

示例10: performOk

import org.osgi.service.prefs.Preferences; //导入依赖的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

示例11: performSpecificOk

import org.osgi.service.prefs.Preferences; //导入依赖的package包/类
@Override
protected boolean performSpecificOk(Preferences prefs) throws CoreException {
	prefs.remove(preferenceKey(MinifyBuilder.YUI_PRESERVE_SEMICOLONS));
	prefs.remove(preferenceKey(MinifyBuilder.YUI_DISABLE_OPTIMIZATIONS));
	prefs.remove(preferenceKey(MinifyBuilder.GCC_OPTIMIZATION));
	if (selection().getText().equals(OPTIONS[1][1])) {
		prefs.putBoolean(preferenceKey(MinifyBuilder.YUI_PRESERVE_SEMICOLONS),
				preserveSemicolons.getSelection());
		prefs.putBoolean(preferenceKey(MinifyBuilder.YUI_DISABLE_OPTIMIZATIONS),
				disableOptimizations.getSelection());
	} else if (selection().getText().equals(OPTIONS[1][2])) {
		for (int i = 0; i < optimizations[0].length; i++) {
			if (gccOptimization.getText().equals(optimizations[1][i])) {
				prefs.put(preferenceKey(MinifyBuilder.GCC_OPTIMIZATION), optimizations[0][i]);
				break;
			}
		}
	}
		
	return true;
}
 
开发者ID:mnlipp,项目名称:EclipseMinifyBuilder,代码行数:22,代码来源:MinifyJsPropertyPage.java

示例12: loadPrefsFromNode

import org.osgi.service.prefs.Preferences; //导入依赖的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

示例13: logContextualInfo

import org.osgi.service.prefs.Preferences; //导入依赖的package包/类
private void logContextualInfo() {
	Preferences preferences = InstanceScope.INSTANCE.getNode(TermSuiteUI.PLUGIN_ID);

	logger.info("Current directory: " + Paths.get(".").toAbsolutePath().normalize().toString());
	logger.info("Workspace location: " + Platform.getInstanceLocation().getURL().toString());
	logger.info("Output directory is " + preferences.get(TermSuiteUIPreferences.OUTPUT_DIRECTORY, ""));
	logger.info("Install location: " + Platform.getInstallLocation().getURL().toString());
	for(String p:LOGGED_PROPS)
		logger.info(p + ": " + System.getProperty(p));
	logger.info("eclipse.commands: " + System.getProperty("eclipse.commands").replaceAll("[\n\r]+", " "));
	logger.info("Command line args: " + Joiner.on(" ").join(Platform.getCommandLineArgs()));
	logger.info("Application args: " + Joiner.on(" ").join(Platform.getApplicationArgs()));
	
	BundleContext bundleContext = Platform.getBundle(TermSuiteUI.PLUGIN_ID).getBundleContext();
	
	for(Bundle bundle:bundleContext.getBundles()) {
		if(bundle.getSymbolicName().startsWith("fr.univnantes.termsuite"))
			logger.info("Found bundle " +bundle.getSymbolicName() + ":" + bundle.getVersion());
	}
}
 
开发者ID:termsuite,项目名称:termsuite-ui,代码行数:21,代码来源:LifeCycleManager.java

示例14: loadDictionaries

import org.osgi.service.prefs.Preferences; //导入依赖的package包/类
@PostConstruct
private void loadDictionaries() {
	targetDictionaries = HashMultimap.create();
	sourceDictionaries = HashMultimap.create();
	
	Preferences preferences = InstanceScope.INSTANCE
			  .getNode(TermSuiteUI.PLUGIN_ID);

	String dictionaryDirectory = preferences.get(TermSuiteUIPreferences.BILINGUAL_DICTIONARY_DIRECTORY, null);
	
	dictionaries = dictionaryDirectory == null ? 
			Lists.newArrayList() : 
				findDictionaries(Paths.get(dictionaryDirectory));
		
	for(EBilingualDictionary dico:dictionaries) {
		sourceDictionaries.put(dico.getSourceLang(), dico);
		targetDictionaries.put(dico.getTargetLang(), dico);
	}
}
 
开发者ID:termsuite,项目名称:termsuite-ui,代码行数:20,代码来源:AlignmentServiceImpl.java

示例15: addSettings

import org.osgi.service.prefs.Preferences; //导入依赖的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


注:本文中的org.osgi.service.prefs.Preferences类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。