當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。