Java 类org.eclipse.core.runtime.preferences.IPreferenceFilter 实例源码

项目:gama    文件:WorkspacePreferences.java   
public static IPreferenceFilter[] getPreferenceFilters() {
    final IPreferenceFilter[] transfers = new IPreferenceFilter[1];

    // For export all create a preference filter that can export
    // all nodes of the Instance and Configuration scopes
    transfers[0] = new IPreferenceFilter() {

        @Override
        public String[] getScopes() {
            return new String[] { InstanceScope.SCOPE };
        }

        @Override
        public Map getMapping(final String scope) {
            return null;
        }
    };

    return transfers;
}
项目:wsprefs-transferrer    文件:PreferencesImportStartup.java   
private IPreferenceFilter[] getPreferenceImportFilters() {
  IPreferenceFilter filter = new IPreferenceFilter() {

    /** {@inheritDoc} */
    @Override
    public String[] getScopes() {
      return new String[] {ConfigurationScope.SCOPE, InstanceScope.SCOPE};
    }

    /** {@inheritDoc} */
    @Override
    public Map<?, ?> getMapping(String scope) {
      return null;
    }
  };

  return new IPreferenceFilter[] {filter};
}
项目:workspacemechanic    文件:LastModifiedPreferencesFileTask.java   
/**
 * Applies preferences from a export file using IPreferenceFilter such that other prefs don't
 * get removed. This allows pref fragment files to do the right thing.
 */
private void transfer() {
  InputStream input = null;
  try {
    input = new BufferedInputStream(taskRef.newInputStream());
  } catch (IOException e) {
    log.logError(e);
  }

  IPreferenceFilter[] filters = new IPreferenceFilter[1];
  // Matches all prefs for both Instance and Config scope.
  filters[0] = new IPreferenceFilter() {
      public String[] getScopes() {
          return new String[] {
              InstanceScope.SCOPE,
              ConfigurationScope.SCOPE
          };
      }

      @SuppressWarnings("rawtypes") // Eclipse doesn't do generics.
      public Map getMapping(String scope) {
          return null;
      }
  };

  IPreferencesService service = Platform.getPreferencesService();
  try {
    IExportedPreferences prefs = service.readPreferences(input);
    // Apply the prefs with the filters so they're only imported and others aren't removed.
    service.applyPreferences(prefs, filters);
  } catch (CoreException ex) {
    log.log(ex.getStatus());
  }

}