public void store(final IDialogSettings settings) {
   settings.put("pattern", pattern); // $NON-NLS-1$
   settings.put("scope", scope); // $NON-NLS-1$
   settings.put("limitTo", limitTo.toString()); // $NON-NLS-1$
   settings.put("searchFor", searchFor.toString()); // $NON-NLS-1$
   settings.put("includeMask", getIncludeMask()); // $NON-NLS-1$
   if (workingSets != null) {
     final String[] wsIds = new String[workingSets.length];
     for (int i = 0; i < workingSets.length; i++) {
       wsIds[i] = workingSets[i].getName();
     }
     settings.put("workingSets", wsIds);
   } else {
     settings.put("workingSets", new String[0]);
   }
 }
    public static SearchPatternData create(final IDialogSettings settings) {
      final String pattern = settings.get("pattern");
      if (pattern.length() == 0) {
        return null;
      }
      final String[] wsIds = settings.getArray("workingSets");

      IWorkingSet[] workingSets = null;
      if (wsIds != null && wsIds.length > 0) {
        final IWorkingSetManager workingSetManager =
            PlatformUI.getWorkbench().getWorkingSetManager();
        workingSets = new IWorkingSet[wsIds.length];
        for (int i = 0; workingSets != null && i < wsIds.length; i++) {
          workingSets[i] = workingSetManager.getWorkingSet(wsIds[i]);
          if (workingSets[i] == null) {
            workingSets = null;
          }
        }
      }

      try {
        final int scope = settings.getInt("scope"); // $NON-NLS-1$
        LimitTo limitTo;
        try {
          limitTo = LimitTo.valueOf(settings.get("limitTo")); // //$NON-NLS-1$
        } catch (final IllegalArgumentException e) {
          limitTo = LimitTo.REFERENCES;
        }
        SearchFor searchFor;
        try {
          searchFor = SearchFor.valueOf(settings.get("searchFor")); // //$NON-NLS-1$
        } catch (final IllegalArgumentException e) {
          searchFor = SearchFor.FUNCTION;
        }
        final int includeMask = settings.getInt("includeMask"); // $NON-NLS-1$
        return new SearchPatternData(pattern, scope, limitTo, searchFor, workingSets, includeMask);

      } catch (final NumberFormatException e) {
      }
      return null;
    }