本文整理匯總了Java中org.osgi.service.prefs.Preferences.flush方法的典型用法代碼示例。如果您正苦於以下問題:Java Preferences.flush方法的具體用法?Java Preferences.flush怎麽用?Java Preferences.flush使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.osgi.service.prefs.Preferences
的用法示例。
在下文中一共展示了Preferences.flush方法的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: 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));
}
}
示例5: 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));
}
}
示例6: 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;
}
示例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: persist
import org.osgi.service.prefs.Preferences; //導入方法依賴的package包/類
/**
* Persists table column widths. Users of this class should have already
* added some mappings before calling this method.
*/
public void persist() {
final Preferences node = getPreferencesNode(key);
for (final Iterator it = mappings.keySet().iterator(); it.hasNext();) {
final String columnKey = (String) it.next();
final int ix = getIndexForKey(columnKey);
if (ix == -1) {
continue;
}
final int width = tableColumnWidths[ix];
if (width > 0) {
node.putInt(columnKey, width);
}
}
try {
node.flush();
} catch (final BackingStoreException e) {
log.warn("can't flush prefs node", e); //$NON-NLS-1$
return;
}
}
示例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: 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);
}
}
示例13: 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);
}
}
示例14: setExpertModeEnabled
import org.osgi.service.prefs.Preferences; //導入方法依賴的package包/類
/**
* Set the expert view enabled state for the given project and tries to save
* the settings.
*
* @param projectName
* The name of the project
* @param enabled
* <code>true</code> for enabled, otherwise <code>false</code>
* @return <code>true</code> on success, otherwise <code>false</code>
*/
public static boolean setExpertModeEnabled(String projectName, boolean enabled) {
Preferences prefs = getProjectPreferences(projectName);
boolean oldValue = isExpertViewEnabled(projectName);
prefs.putBoolean(KEY_EXPERT_VIEW_ENABLED, enabled);
// force save
try {
prefs.flush();
return true;
} catch (BackingStoreException e) {
LOGGER.error("Saving expert mode enabled state failed.", e);
// restore old value
prefs.putBoolean(KEY_EXPERT_VIEW_ENABLED, oldValue);
DialogUtils.openWarning("Could not change the expert mode due to an error!");
return false;
}
}
示例15: setProperty
import org.osgi.service.prefs.Preferences; //導入方法依賴的package包/類
/**
* Set the property of a preference store
* @param id
* @param value
* @return
*/
@Override
public boolean setProperty( IJp2pPropertySource<IJp2pProperties> source, IJp2pProperties id, String value ){
ManagedProperty<IJp2pProperties, Object> mp = source.getManagedProperty(id);
if( !ManagedProperty.isPersisted(mp))
return false;
Preferences pref1 = scope.getNode( AbstractJp2pPropertySource.getBundleId(source) + "." + AbstractJp2pPropertySource.getIdentifier(source));
pref1.put( id.toString(), value.toString());
try {
pref1.flush();
return true;
} catch (BackingStoreException e) {
e.printStackTrace();
}
return false;
}