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


Java Preferences.keys方法代碼示例

本文整理匯總了Java中org.osgi.service.prefs.Preferences.keys方法的典型用法代碼示例。如果您正苦於以下問題:Java Preferences.keys方法的具體用法?Java Preferences.keys怎麽用?Java Preferences.keys使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.osgi.service.prefs.Preferences的用法示例。


在下文中一共展示了Preferences.keys方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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

示例2: 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

示例3: 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

示例4: restoreList

import org.osgi.service.prefs.Preferences; //導入方法依賴的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

示例5: migratePreferences

import org.osgi.service.prefs.Preferences; //導入方法依賴的package包/類
public static void migratePreferences() {

		Preferences pref = new ProfileScope(getDefaultAgentLocation(), IProfileRegistry.SELF).getNode(P2_Activator.PLUGIN_ID);

		try {
			if (pref.keys().length == 0) {
				// migrate preferences from instance scope to profile scope
				Preferences oldPref = new InstanceScope().getNode(P2_Activator.PLUGIN_ID);
				// don't migrate everything.  Some of the preferences moved to
				// another bundle.
				pref.put(PreferenceConstants.PREF_OPEN_WIZARD_ON_ERROR_PLAN, oldPref.get(PreferenceConstants.PREF_OPEN_WIZARD_ON_ERROR_PLAN, MessageDialogWithToggle.PROMPT));
				pref.putBoolean(PreferenceConstants.PREF_SHOW_LATEST_VERSION, oldPref.getBoolean(PreferenceConstants.PREF_SHOW_LATEST_VERSION, true));
				pref.flush();
			}
		} catch (BackingStoreException e) {
			StatusManager.getManager().handle(new Status(IStatus.ERROR, P2_Activator.PLUGIN_ID, 0, ProvSDKMessages.PreferenceInitializer_Error, e), StatusManager.LOG);
		}
	}
 
開發者ID:wolfgang-ch,項目名稱:mytourbook,代碼行數:19,代碼來源:PreferenceInitializer.java

示例6: load

import org.osgi.service.prefs.Preferences; //導入方法依賴的package包/類
public void load() throws BackingStoreException {
    preferences.sync();
    enabled = preferences.getBoolean(ENABLED, true);
    mainClass = preferences.get(MAIN_CLASS, "");
    targetDirectory = preferences.get(TARGET_DIRECTORY, "");
    targetFileName = preferences.get(TARGET_FILE_NAME, "");
    runtimeMode = TeaVMRuntimeMode.valueOf(preferences.get(RUNTIME, TeaVMRuntimeMode.SEPARATE.name()));
    incremental = preferences.getBoolean(INCREMENTAL, false);
    cacheDirectory = preferences.get(CACHE_DIRECTORY, "");
    sourceMapsGenerated = preferences.getBoolean(SOURCE_MAPS, true);
    debugInformationGenerated = preferences.getBoolean(DEBUG_INFORMATION, true);
    sourceFilesCopied = preferences.getBoolean(COPY_SOURCES, true);
    Preferences propertiesPrefs = preferences.node(PROPERTIES);
    propertiesPrefs.sync();
    properties = new Properties();
    for (String key : propertiesPrefs.keys()) {
        properties.setProperty(key, propertiesPrefs.get(key, ""));
    }
    Preferences transformersPrefs = preferences.node(TRANSFORMERS);
    transformersPrefs.sync();
    transformers = transformersPrefs.keys();
    classesToPreserve.addAll(Arrays.asList(preferences.get(CLASSES, "").split(" ")));
    externalToolId = preferences.get(EXTERNAL_TOOL_ID, "");
}
 
開發者ID:konsoletyper,項目名稱:teavm,代碼行數:25,代碼來源:PreferencesBasedTeaVMProjectSettings.java

示例7: getTargets

import org.osgi.service.prefs.Preferences; //導入方法依賴的package包/類
/**
 * List targets configure for <code>project</code>. Each project configured for Bazel is
 * configured to track certain targets and this function fetch this list from the project
 * preferences.
 */
public static List<String> getTargets(IProject project) throws BackingStoreException {
  // Get the list of targets from the preferences
  IScopeContext projectScope = new ProjectScope(project);
  Preferences projectNode = projectScope.getNode(Activator.PLUGIN_ID);
  ImmutableList.Builder<String> builder = ImmutableList.builder();
  for (String s : projectNode.keys()) {
    if (s.startsWith("target")) {
      builder.add(projectNode.get(s, ""));
    }
  }
  return builder.build();
}
 
開發者ID:bazelbuild,項目名稱:eclipse,代碼行數:18,代碼來源:BazelProjectSupport.java

示例8: getBuildFlags

import org.osgi.service.prefs.Preferences; //導入方法依賴的package包/類
/**
 * List of build flags for <code>project</code>, taken from the project configuration
 */
public static List<String> getBuildFlags(IProject project) throws BackingStoreException {
  // Get the list of targets from the preferences
  IScopeContext projectScope = new ProjectScope(project);
  Preferences projectNode = projectScope.getNode(Activator.PLUGIN_ID);
  ImmutableList.Builder<String> builder = ImmutableList.builder();
  for (String s : projectNode.keys()) {
    if (s.startsWith("buildArgs")) {
      builder.add(projectNode.get(s, ""));
    }
  }
  return builder.build();
}
 
開發者ID:bazelbuild,項目名稱:eclipse,代碼行數:16,代碼來源:BazelProjectSupport.java

示例9: getProjectView

import org.osgi.service.prefs.Preferences; //導入方法依賴的package包/類
/**
 * Convert an Eclipse JDT project into an IntelliJ project view
 */
public static ProjectView getProjectView(IProject project)
    throws BackingStoreException, JavaModelException {
  com.google.devtools.bazel.e4b.projectviews.Builder builder = ProjectView.builder();
  IScopeContext projectScope = new ProjectScope(project);
  Preferences projectNode = projectScope.getNode(Activator.PLUGIN_ID);
  for (String s : projectNode.keys()) {
    if (s.startsWith("buildArgs")) {
      builder.addBuildFlag(projectNode.get(s, ""));
    } else if (s.startsWith("target")) {
      builder.addTarget(projectNode.get(s, ""));
    }
  }

  IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
  for (IClasspathEntry entry : ((IJavaProject) project).getRawClasspath()) {
    switch (entry.getEntryKind()) {
      case IClasspathEntry.CPE_SOURCE:
        IResource res = root.findMember(entry.getPath());
        if (res != null) {
          builder.addDirectory(res.getProjectRelativePath().removeFirstSegments(1).toOSString());
        }
        break;
      case IClasspathEntry.CPE_CONTAINER:
        String path = entry.getPath().toOSString();
        if (path.startsWith(STANDARD_VM_CONTAINER_PREFIX)) {
          builder.setJavaLanguageLevel(
              Integer.parseInt(path.substring(STANDARD_VM_CONTAINER_PREFIX.length())));
        }
        break;
    }
  }
  return builder.build();
}
 
開發者ID:bazelbuild,項目名稱:eclipse,代碼行數:37,代碼來源:BazelProjectSupport.java

示例10: getThemeNames

import org.osgi.service.prefs.Preferences; //導入方法依賴的package包/類
/**
 * laziliy init the set of theme names.
 */
public synchronized Set<String> getThemeNames()
{
	if (fThemeNames == null)
	{
		fThemeNames = new HashSet<String>();
		// Add names of themes from builtins...
		fThemeNames.addAll(getBuiltinThemeNames());

		// Look in prefs to see what user themes are stored there, garb their names
		IScopeContext[] scopes = new IScopeContext[] { EclipseUtil.instanceScope(), EclipseUtil.defaultScope() };
		for (IScopeContext scope : scopes)
		{
			IEclipsePreferences prefs = scope.getNode(ThemePlugin.PLUGIN_ID);
			Preferences preferences = prefs.node(ThemeManager.THEMES_NODE);
			try
			{
				String[] themeNames = preferences.keys();
				fThemeNames.addAll(Arrays.asList(themeNames));
			}
			catch (BackingStoreException e)
			{
				IdeLog.logError(ThemePlugin.getDefault(), e);
			}
		}
	}
	return fThemeNames;
}
 
開發者ID:apicloudcom,項目名稱:APICloud-Studio,代碼行數:31,代碼來源:ThemeManager.java

示例11: cleanJavaCore

import org.osgi.service.prefs.Preferences; //導入方法依賴的package包/類
/**
 * Clean imported preferences from obsolete keys.
 *
 * @param preferences JavaCore preferences.
 */
void cleanJavaCore(Preferences preferences) {
	try {
		String[] keys = preferences.keys();
		for (int k = 0, kl= keys.length; k<kl; k++) {
			String key = keys[k];
			if (key.startsWith(JavaModelManager.CP_CONTAINER_PREFERENCES_PREFIX) && !isJavaProjectAccessible(key)) {
				preferences.remove(key);
			}
		}
	} catch (BackingStoreException e) {
		// do nothing
	}
}
 
開發者ID:trylimits,項目名稱:Eclipse-Postfix-Code-Completion,代碼行數:19,代碼來源:JavaCorePreferenceModifyListener.java


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