Package org.osgi.service.prefs

Examples of org.osgi.service.prefs.Preferences


    if (create)
      // create all nodes down to the one we are interested in
      return new ProjectScope(project).getNode(JSPCORE_ID).node(preferenceKey);
    // be careful looking up for our node so not to create any nodes as
    // side effect
    Preferences node = Platform.getPreferencesService().getRootNode().node(ProjectScope.SCOPE);
    try {
      // TODO once bug 90500 is fixed, should be as simple as this:
      // String path = project.getName() + IPath.SEPARATOR +
      // ResourcesPlugin.PI_RESOURCES + IPath.SEPARATOR +
      // ENCODING_PREF_NODE;
      // return node.nodeExists(path) ? node.node(path) : null;
      // for now, take the long way
      if (!node.nodeExists(project.getName()))
        return null;
      node = node.node(project.getName());
      if (!node.nodeExists(JSPCORE_ID))
        return null;
      node = node.node(JSPCORE_ID);
      if (!node.nodeExists(preferenceKey))
        return null;
      return node.node(preferenceKey);
    }
    catch (BackingStoreException e) {
      // nodeExists failed
      Logger.log(Logger.WARNING_DEBUG, "Could not retrieve preference node", e); //$NON-NLS-1$
    }
View Full Code Here


  public static String getProperty(String key, IResource resource, boolean recurse) {
    String val = null;
    if (resource != null) {
      IProject project = resource.getProject();
      if (project != null) {
        Preferences preferences = getPreferences(project, key, false);
        if (preferences != null) {
          val = internalGetProperty(resource, recurse, preferences);
        }
      }
    }
View Full Code Here

   */
  public static void setProperty(String key, IResource resource, String value) throws CoreException {
    if (resource != null) {
      IProject project = resource.getProject();
      if (project != null) {
        Preferences preferences = getPreferences(project, key, true);
        if (value == null || value.trim().length() == 0)
          preferences.remove(getKeyFor(resource.getFullPath()));
        else
          preferences.put(getKeyFor(resource.getFullPath()), value);
        try {
          // save changes
          preferences.flush();
        }
        catch (BackingStoreException e) {
          throw new CoreException(new Status(IStatus.ERROR, JSPCORE_ID, IStatus.ERROR, "Unable to set property", e)); //$NON-NLS-1$
        }
      }
View Full Code Here

              return Status.OK_STATUS;
            try {
              // save the preferences nodes
              if (next.isAccessible()) {
                // save document type preferences
                Preferences projectPrefs = HTMLContentProperties.getPreferences(next, HTMLContentProperties.DOCUMENT_TYPE, false);
                if (projectPrefs != null)
                  projectPrefs.flush();
              }
            }
            catch (BackingStoreException e) {
              // we got an error saving
              String detailMessage = NLS.bind(HTMLCoreMessages.HTMLContentPropertiesManager_Problems_Updating, next.getFullPath());
View Full Code Here

     */
    private boolean processPreferences(IProject currentProject, String key, IResourceDelta projectDelta, Set projectsToSave) {
      boolean resourceChanges = false;

      // get the project-key preference node
      Preferences projectPrefs = HTMLContentProperties.getPreferences(currentProject, key, false);
      if (projectPrefs == null)
        // no preferences for this project-key, just bail
        return false;
      String[] affectedResources;
      try {
        affectedResources = projectPrefs.keys();
      }
      catch (BackingStoreException e) {
        // problems with the project scope... we gonna miss the
        // changes (but will log)
        Logger.log(Logger.WARNING_DEBUG, "Problem retreiving JSP Fragment preferences", e); //$NON-NLS-1$
        return false;
      }

      // go through each preference key (which is really a file name)
      for (int i = 0; i < affectedResources.length; i++) {
        // see if preference key/file name was file that was changed
        IResourceDelta memberDelta = projectDelta.findMember(new Path(affectedResources[i]));
        // no changes for the given resource
        if (memberDelta == null)
          continue;
        if (memberDelta.getKind() == IResourceDelta.REMOVED) {
          resourceChanges = true;
          // remove the setting for the original location
          String currentValue = projectPrefs.get(affectedResources[i], null);
          projectPrefs.remove(affectedResources[i]);
          if ((memberDelta.getFlags() & IResourceDelta.MOVED_TO) != 0) {
            // if moving, copy the setting for the new location
            IProject targetProject = ResourcesPlugin.getWorkspace().getRoot().getProject(memberDelta.getMovedToPath().segment(0));
            Preferences targetPrefs = HTMLContentProperties.getPreferences(targetProject, key, true);
            targetPrefs.put(HTMLContentProperties.getKeyFor(memberDelta.getMovedToPath()), currentValue);
            if (targetProject != currentProject)
              projectsToSave.add(targetProject);
          }
        }
      }
View Full Code Here

    if (create)
      // create all nodes down to the one we are interested in
      return new ProjectScope(project).getNode(HTMLCORE_ID).node(preferenceKey);
    // be careful looking up for our node so not to create any nodes as
    // side effect
    Preferences node = Platform.getPreferencesService().getRootNode().node(ProjectScope.SCOPE);
    try {
      // TODO once bug 90500 is fixed, should be as simple as this:
      // String path = project.getName() + IPath.SEPARATOR +
      // ResourcesPlugin.PI_RESOURCES + IPath.SEPARATOR +
      // ENCODING_PREF_NODE;
      // return node.nodeExists(path) ? node.node(path) : null;
      // for now, take the long way
      if (!node.nodeExists(project.getName()))
        return null;
      node = node.node(project.getName());
      if (!node.nodeExists(HTMLCORE_ID))
        return null;
      node = node.node(HTMLCORE_ID);
      if (!node.nodeExists(preferenceKey))
        return null;
      return node.node(preferenceKey);
    }
    catch (BackingStoreException e) {
      // nodeExists failed
      Logger.log(Logger.WARNING_DEBUG, "Could not retrieve preference node", e); //$NON-NLS-1$
    }
View Full Code Here

    String val = null;
    // boolean preferenceFound = false;
    if (resource != null) {
      IProject project = resource.getProject();
      if (project != null) {
        Preferences preferences = getPreferences(project, key, false);
        if (preferences != null) {
          val = internalGetProperty(resource, recurse, preferences);
          // preferenceFound = true;
        }
      }
View Full Code Here

   */
  public static void setProperty(String key, IResource resource, String value) throws CoreException {
    if (resource != null) {
      IProject project = resource.getProject();
      if (project != null) {
        Preferences preferences = getPreferences(project, key, true);
        if (value == null)
          preferences.remove(getKeyFor(resource.getFullPath()));
        else
          preferences.put(getKeyFor(resource.getFullPath()), value);
        try {
          // save changes
          preferences.flush();
        }
        catch (BackingStoreException e) {
          throw new CoreException(new Status(IStatus.ERROR, HTMLCORE_ID, IStatus.ERROR, "Unable to set property", e)); //$NON-NLS-1$
        }
      }
View Full Code Here

        assertEquals(Status.Error, exchange.getStatus());
    }

    private ServiceAssemblyImpl createServiceAssembly() {
        ServiceAssemblyDesc descriptor = DescriptorFactory.buildDescriptor(DescriptorFactory.class.getResource("serviceAssembly.xml")).getServiceAssembly();
        final Preferences prefs = createMock(Preferences.class);
        expect(prefs.get("state", State.Shutdown.name())).andReturn(State.Shutdown.name()).anyTimes();
        replay(prefs);
        final Component component = createMock(Component.class);
        replay(component);

        ComponentImpl comp = new ComponentImpl(null, null, component, prefs, false, null);
View Full Code Here

*/
public class ServiceAssemblyImplTest extends TestCase {

    public void testStartAssemblyWithStoppedComponents() throws Exception {
        ServiceAssemblyDesc descriptor = DescriptorFactory.buildDescriptor(DescriptorFactory.class.getResource("serviceAssembly.xml")).getServiceAssembly();
        final Preferences prefs = createMock(Preferences.class);
        expect(prefs.get("state", State.Shutdown.name())).andReturn(State.Shutdown.name()).anyTimes();
        replay(prefs);
        final Component component = createMock(Component.class);
        replay(component);

        ComponentImpl comp = new ComponentImpl(null, null, component, prefs, false, null);
View Full Code Here

TOP

Related Classes of org.osgi.service.prefs.Preferences

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.