/**
  * Write all state to persistent properties in the given project
  *
  * @param p
  */
 public void persistState() {
   TableTreeItem[] items = getItems();
   for (TableTreeItem item : items) {
     String id = (String) item.getData("id");
     String val = (item.getChecked()) ? "true" : "false";
     String mPatterns = item.getText(1);
     try {
       project.setPersistentProperty(
           new QualifiedName(Constants.PLUGIN_ID, id + ".enabled"), val);
       project.setPersistentProperty(
           new QualifiedName(Constants.PLUGIN_ID, id + ".patterns"), mPatterns);
       TableTreeItem[] folders = item.getItems();
       for (TableTreeItem folder : folders) {
         IPackageFragmentRoot f = (IPackageFragmentRoot) folder.getData("element");
         String handle = f.getHandleIdentifier();
         String fVal = (folder.getChecked()) ? "true" : "false";
         String fPatterns = folder.getText(1);
         project.setPersistentProperty(
             new QualifiedName(Constants.PLUGIN_ID, id + "_" + handle + ".enabled"), fVal);
         project.setPersistentProperty(
             new QualifiedName(Constants.PLUGIN_ID, id + "_" + handle + ".patterns"), fPatterns);
       }
     } catch (CoreException e) {
       Log.logError("Could not persist property", e);
     }
   }
 }
 public void addRoot(IPackageFragmentRoot root) {
   if (root != null) {
     String handleIdentifier = root.getHandleIdentifier();
     Map<String, IPackageFragmentRoot> roots = associatedRoots;
     if (!root.equals(roots.get(handleIdentifier))) {
       Map<String, IPackageFragmentRoot> copy = newLinkedHashMap(roots);
       copy.put(handleIdentifier, root);
       associatedRoots = copy;
     }
   }
 }
  PackageReorgChange(IPackageFragment pack, IPackageFragmentRoot dest, INewNameQuery nameQuery) {
    fPackageHandle = pack.getHandleIdentifier();
    fDestinationHandle = dest.getHandleIdentifier();
    fNameQuery = nameQuery;

    // it is enough to check the package only since package reorg changes
    // are not undoable. Don't check for read only here since
    // we already ask for user confirmation and moving a read
    // only package doesn't go thorugh validate edit (no
    // file content is modified).
    setValidationMethod(VALIDATE_DEFAULT);
  }
 /**
  * Checks persisted project property
  *
  * @param id metric to be checked
  * @param folder source folder to be checked
  * @return true if project properties indicate it is enabled or if such property does not exist
  */
 private boolean isEnabled(String id, IPackageFragmentRoot folder) {
   boolean mEnabled = isEnabled(id);
   if (!mEnabled) {
     return false;
   }
   String handle = folder.getHandleIdentifier();
   try {
     String val =
         project.getPersistentProperty(
             new QualifiedName(Constants.PLUGIN_ID, id + "_" + handle + ".enabled"));
     if (val == null) {
       return true;
     }
     return val.equals("true");
   } catch (CoreException e) {
     return true;
   }
 }
 /**
  * Get the stored exclusion patterns for the given metric and source folder
  *
  * @param id metric-id
  */
 private String[] getExclusionPatterns(String id, IPackageFragmentRoot folder) {
   String handle = folder.getHandleIdentifier();
   return getExclusionPatterns(
       new QualifiedName(Constants.PLUGIN_ID, id + "_" + handle + ".patterns"));
 }