Пример #1
0
 protected static String getLineDelimiterPreference(IFile file) {
   IScopeContext[] scopeContext;
   if (file != null && file.getProject() != null) {
     // project preference
     scopeContext = new IScopeContext[] {new ProjectScope(file.getProject())};
     String lineDelimiter =
         Platform.getPreferencesService()
             .getString(Platform.PI_RUNTIME, Platform.PREF_LINE_SEPARATOR, null, scopeContext);
     if (lineDelimiter != null) return lineDelimiter;
   }
   // workspace preference
   scopeContext = new IScopeContext[] {InstanceScope.INSTANCE};
   return Platform.getPreferencesService()
       .getString(Platform.PI_RUNTIME, Platform.PREF_LINE_SEPARATOR, null, scopeContext);
 }
Пример #2
0
 private boolean isDerivedEncodingStoredSeparately(IProject project) {
   // 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;
     //			return node.nodeExists(path) ?
     // node.node(path).getBoolean(ResourcesPlugin.PREF_SEPARATE_DERIVED_ENCODINGS, false) : false;
     // for now, take the long way
     if (!node.nodeExists(project.getName()))
       return ResourcesPlugin.DEFAULT_PREF_SEPARATE_DERIVED_ENCODINGS;
     node = node.node(project.getName());
     if (!node.nodeExists(ResourcesPlugin.PI_RESOURCES))
       return ResourcesPlugin.DEFAULT_PREF_SEPARATE_DERIVED_ENCODINGS;
     node = node.node(ResourcesPlugin.PI_RESOURCES);
     return node.getBoolean(
         ResourcesPlugin.PREF_SEPARATE_DERIVED_ENCODINGS,
         ResourcesPlugin.DEFAULT_PREF_SEPARATE_DERIVED_ENCODINGS);
   } catch (BackingStoreException e) {
     // nodeExists failed
     String message = Messages.resources_readingEncoding;
     Policy.log(
         new ResourceStatus(
             IResourceStatus.FAILED_GETTING_CHARSET, project.getFullPath(), message, e));
     return ResourcesPlugin.DEFAULT_PREF_SEPARATE_DERIVED_ENCODINGS;
   }
 }
Пример #3
0
 Preferences getPreferences(
     IProject project,
     boolean create,
     boolean isDerived,
     boolean isDerivedEncodingStoredSeparately) {
   boolean localIsDerived = isDerivedEncodingStoredSeparately ? isDerived : false;
   String qualifier =
       localIsDerived
           ? ProjectPreferences.PREFS_DERIVED_QUALIFIER
           : ProjectPreferences.PREFS_REGULAR_QUALIFIER;
   if (create)
     // create all nodes down to the one we are interested in
     return new ProjectScope(project).getNode(qualifier).node(ResourcesPlugin.PREF_ENCODING);
   // 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(qualifier)) return null;
     node = node.node(qualifier);
     if (!node.nodeExists(ResourcesPlugin.PREF_ENCODING)) return null;
     return node.node(ResourcesPlugin.PREF_ENCODING);
   } catch (BackingStoreException e) {
     // nodeExists failed
     String message = Messages.resources_readingEncoding;
     Policy.log(
         new ResourceStatus(
             IResourceStatus.FAILED_GETTING_CHARSET, project.getFullPath(), message, e));
   }
   return null;
 }