use of org.eclipse.core.runtime.preferences.IEclipsePreferences in project polymap4-core by Polymap4.
the class NavigatorActivationService method persistExtensionActivations.
/**
* Save the activation state for the given viewer.
*/
public void persistExtensionActivations() {
IEclipsePreferences prefs = NavigatorContentService.getPreferencesRoot();
synchronized (activatedExtensionsMap) {
Iterator activatedExtensionsIterator = activatedExtensionsMap.keySet().iterator();
/* ensure that the preference will be non-empty */
StringBuffer preferenceValue = new StringBuffer();
String navigatorExtensionId = null;
boolean isActive = false;
while (activatedExtensionsIterator.hasNext()) {
navigatorExtensionId = (String) activatedExtensionsIterator.next();
isActive = isNavigatorExtensionActive(navigatorExtensionId);
preferenceValue.append(navigatorExtensionId).append(EQUALS).append(isActive ? Boolean.TRUE : Boolean.FALSE).append(DELIM);
}
prefs.put(getPreferenceKey(), preferenceValue.toString());
}
NavigatorContentService.flushPreferences(prefs);
}
use of org.eclipse.core.runtime.preferences.IEclipsePreferences in project polymap4-core by Polymap4.
the class NavigatorActivationService method revertExtensionActivations.
private void revertExtensionActivations() {
IEclipsePreferences prefs = NavigatorContentService.getPreferencesRoot();
String activatedExtensionsString = prefs.get(getPreferenceKey(), null);
if (activatedExtensionsString != null && activatedExtensionsString.length() > 0) {
String[] contentExtensionIds = activatedExtensionsString.split(DELIM);
String id = null;
String booleanString = null;
int indx = 0;
for (int i = 0; i < contentExtensionIds.length; i++) {
if ((indx = contentExtensionIds[i].indexOf(EQUALS)) > -1) {
// up to but not including the equals
id = contentExtensionIds[i].substring(0, indx);
booleanString = contentExtensionIds[i].substring(indx + 1, contentExtensionIds[i].length());
activatedExtensionsMap.put(id, Boolean.valueOf(booleanString));
} else {
// IS THIS THE RIGHT WAY TO HANDLE THIS CASE?
NavigatorContentDescriptor descriptor = CONTENT_DESCRIPTOR_REGISTRY.getContentDescriptor(contentExtensionIds[i]);
if (descriptor != null)
activatedExtensionsMap.put(id, Boolean.valueOf(descriptor.isActiveByDefault()));
}
}
} else {
/*
* We add the default activation of every known extension, even
* though some may not be bound to the associated content service;
* this is because they could be bound at a later time through the
* programmatic binding mechanism in INavigatorContentService.
*/
INavigatorContentDescriptor[] contentDescriptors = CONTENT_DESCRIPTOR_REGISTRY.getAllContentDescriptors();
for (int i = 0; i < contentDescriptors.length; i++) {
if (contentDescriptors[i].isActiveByDefault()) {
activatedExtensionsMap.put(contentDescriptors[i].getId(), Boolean.TRUE);
}
}
}
}
use of org.eclipse.core.runtime.preferences.IEclipsePreferences in project polymap4-core by Polymap4.
the class NavigatorFilterService method persistFilterActivationState.
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.navigator.INavigatorFilterService#persistFilterActivationState()
*/
public void persistFilterActivationState() {
synchronized (activeFilters) {
CommonFilterDescriptorManager dm = CommonFilterDescriptorManager.getInstance();
/*
* by creating a StringBuffer with DELIM, we ensure the string is
* not empty when persisted.
*/
StringBuffer activatedFiltersPreferenceValue = new StringBuffer(DELIM);
for (Iterator activeItr = activeFilters.iterator(); activeItr.hasNext(); ) {
String id = activeItr.next().toString();
if (!dm.getFilterById(id).isVisibleInUi())
continue;
activatedFiltersPreferenceValue.append(id).append(DELIM);
}
IEclipsePreferences prefs = NavigatorContentService.getPreferencesRoot();
prefs.put(getFilterActivationPreferenceKey(), activatedFiltersPreferenceValue.toString());
NavigatorContentService.flushPreferences(prefs);
}
}
use of org.eclipse.core.runtime.preferences.IEclipsePreferences in project polymap4-core by Polymap4.
the class PasswordProviderSelector method getDisabledModules.
protected HashSet getDisabledModules() {
IEclipsePreferences node = new ConfigurationScope().getNode(AuthPlugin.PI_AUTH);
String tmp = node.get(IStorageConstants.DISABLED_PROVIDERS_KEY, null);
if (tmp == null || tmp.length() == 0)
return null;
HashSet disabledModules = new HashSet();
// $NON-NLS-1$
String[] disabledProviders = tmp.split(",");
for (int i = 0; i < disabledProviders.length; i++) {
disabledModules.add(disabledProviders[i]);
}
return disabledModules;
}
use of org.eclipse.core.runtime.preferences.IEclipsePreferences in project eclipse-integration-commons by spring-projects.
the class CorePlugin method getUUID.
public static synchronized String getUUID() {
ServiceReference ref = getDefault().getBundle().getBundleContext().getServiceReference(IPreferencesService.class.getName());
IPreferencesService prefService = (IPreferencesService) getDefault().getBundle().getBundleContext().getService(ref);
try {
IEclipsePreferences prefs = (IEclipsePreferences) prefService.getRootNode().node(InstanceScope.SCOPE);
Preferences p = prefs.node(PLUGIN_ID);
if (StringUtils.isEmpty(p.get(UUID_PROPERTY_KEY, ""))) {
p.put(UUID_PROPERTY_KEY, UUID.randomUUID().toString());
}
return p.get(UUID_PROPERTY_KEY, "");
} finally {
if (prefService != null) {
getDefault().getBundle().getBundleContext().ungetService(ref);
}
}
}
Aggregations