本文整理汇总了Java中org.osgi.service.prefs.Preferences.put方法的典型用法代码示例。如果您正苦于以下问题:Java Preferences.put方法的具体用法?Java Preferences.put怎么用?Java Preferences.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.osgi.service.prefs.Preferences
的用法示例。
在下文中一共展示了Preferences.put方法的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;
}
示例2: 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();
}
示例3: 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);
}
}
示例4: 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));
}
}
示例5: 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;
}
示例6: 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;
}
示例7: 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();
}
示例8: persistList
import org.osgi.service.prefs.Preferences; //导入方法依赖的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;
}
}
示例9: performOk
import org.osgi.service.prefs.Preferences; //导入方法依赖的package包/类
public boolean performOk() {
MergeFileAssociation[] currentAssociations = getMergeFileAssociations();
for (int i = 0; i < currentAssociations.length; i++) {
currentAssociations[i].remove();
}
for (int i = 0; i < mergeFileAssociations.length; i++) {
Preferences prefs = MergeFileAssociation.getParentPreferences().node(mergeFileAssociations[i].getFileType());
if (mergeFileAssociations[i].getMergeProgram() == null) prefs.put("mergeProgram", ""); //$NON-NLS-1$ //$NON-NLS-1$ //$NON-NLS-2$
else prefs.put("mergeProgram", mergeFileAssociations[i].getMergeProgram()); //$NON-NLS-1$
if (mergeFileAssociations[i].getParameters() == null)prefs.put("parameters", ""); //$NON-NLS-1$ //$NON-NLS-1$ //$NON-NLS-2$
else prefs.put("parameters", mergeFileAssociations[i].getParameters()); //$NON-NLS-1$
prefs.putInt("type", mergeFileAssociations[i].getType()); //$NON-NLS-1$
try {
prefs.flush();
} catch (BackingStoreException e) {}
}
return super.performOk();
}
示例10: resetPlatform
import org.osgi.service.prefs.Preferences; //导入方法依赖的package包/类
public void resetPlatform(String platformHome) {
try {
Preferences preferences = InstanceScope.INSTANCE.getNode("com.hybris.hyeclipse.preferences");
preferences.put("platform_home", platformHome);
preferences.flush();
}
catch (BackingStoreException e) {
logError("Failed to persist platform_home", e);
}
getTypeSystemExporter().setPlatformHome(null);
getTypeSystemExporter().nullifySystemConfig();
getTypeSystemExporter().nullifyPlatformConfig();
getTypeSystemExporter().nullifyTypeSystem();
getTypeSystemExporter().nullifyAllTypes();
getTypeSystemExporter().nullifyAllTypeNames();
}
示例11: performOk
import org.osgi.service.prefs.Preferences; //导入方法依赖的package包/类
@Override
public boolean performOk() {
Preferences preferences = ConfigurationScope.INSTANCE.getNode("org.mdpm.lng.plan.preferences");
preferences.putBoolean("sunday", sunday.getSelection());
preferences.putBoolean("monday", monday.getSelection());
preferences.putBoolean("tuesday", tuesday.getSelection());
preferences.putBoolean("wednesday", wednesday.getSelection());
preferences.putBoolean("thursday", thursday.getSelection());
preferences.putBoolean("friday", friday.getSelection());
preferences.putBoolean("saturday", saturday.getSelection());
String tmp="";
if(dates.getItemCount()>0){
for (int k=0; k<dates.getItemCount();k++){
tmp = tmp+dates.getItem(k)+",";
}
}
preferences.put("dates",tmp);
//preferences.put
try {
preferences.flush();
} catch (BackingStoreException e) {
e.printStackTrace();
}
return super.performOk();
}
示例12: cloneRepository
import org.osgi.service.prefs.Preferences; //导入方法依赖的package包/类
private void cloneRepository() throws IOException, InvalidRemoteException, TransportException, GitAPIException {
File localPath = File.createTempFile("TestGitRepository", "");
localPath.delete();
System.out.println("Cloning from " + repository_url + " to " + localPath);
Git result = Git.cloneRepository()
.setURI(repository_url)
.setDirectory(localPath)
.call();
// Note: the call() returns an opened repository already which needs to be closed to avoid file handle leaks!
System.out.println("Having repository: " + result.getRepository().getDirectory());
repositoryPath = result.getRepository().getDirectory().getAbsolutePath();
@SuppressWarnings("deprecation")
Preferences preferences = new InstanceScope().getNode(ModularityCheck.PLUGIN_ID);
preferences.put(REPOSITORY_PATH, repositoryPath);
}
示例13: showEditDialog
import org.osgi.service.prefs.Preferences; //导入方法依赖的package包/类
private void showEditDialog(Preferences currPref) throws Exception {
DefineExtractDialog dialog = new DefineExtractDialog(fAccessText.getShell(), SWT.RESIZE);
if (currPref != null) {
dialog.initDefault(currPref.name(), currPref.get("zipFile", null), currPref.get("extractDir", null));
}
if (dialog.open() == DefineExtractDialog.OK) {
String key = dialog.getName();
boolean exists = pref.nodeExists(key);
Preferences p = pref.node(key);
p.put("zipFile", dialog.getZipFile());
p.put("extractDir", dialog.getExtractDir());
if (!exists) {
addItems(key, dialog.getZipFile(), dialog.getExtractDir());
}
}
}
示例14: saveServerProfiles
import org.osgi.service.prefs.Preferences; //导入方法依赖的package包/类
public static void saveServerProfiles() {
Preferences prefs = PropertiesHelper.INSTANCE_SCOPE.getNode(JaspersoftStudioPlugin.getUniqueIdentifier());
try {
StringBuffer xml = new StringBuffer();
xml.append("<serverprofiles>\n"); //$NON-NLS-1$
for (MServerProfile desc : serverProfiles) {
xml.append(desc.toXML());
}
xml.append("</serverprofiles>"); //$NON-NLS-1$
prefs.put(PREF_TAG, xml.toString()); //$NON-NLS-1$
prefs.flush();
} catch (Exception e) {
UIUtils.showError(e);
}
}
示例15: 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);
}
}