/**
  * 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);
     }
   }
 }
 /**
  * enable/disable an item, its children and dependents elsewhere
  *
  * @param item
  * @param enable
  * @param gray
  */
 private void enableItem(TableTreeItem item, boolean enable, boolean gray) {
   item.setChecked(enable);
   item.setGrayed(gray);
   TableTreeItem[] children = item.getItems();
   for (TableTreeItem element2 : children) {
     element2.setChecked(enable);
     element2.setGrayed(!enable);
   }
   enableDependentMetrics((MetricDescriptor) item.getData("md"), enable);
 }