code: public static IPath toFilterPath(String filePath, IProject project) {
          IPath path = new Path(filePath);
          IPath commonPath;
          if (project != null) {
              commonPath = project.getLocation();
              IPath relativePath = getRelativePath(path, commonPath);
              if (!relativePath.equals(path)) {
                  return relativePath;
              }
          }
          commonPath = ResourcesPlugin.getWorkspace().getRoot().getLocation();
          return getRelativePath(path, commonPath);
      }
docs: Checks the given absolute path and convert it to relative path if it is
  relative to the given project or workspace. This representation can be
  used to store filter paths in user preferences file
  
  @param filePath
  absolute OS file path
  @param project
  might be null
  @return filter file path as stored in preferences which matches given
  path