package experimentalcode.remigius.gui.runnables;

import org.w3c.dom.Element;

/**
 * Runnable wrapper for modifying XML-Attributes. 
 * 
 * @author Remigius Wojdanowski
 *
 */
public class AttributeModifier implements Runnable {
  
  /**
   * Provides the attribute to be modified.
   */
  private Element e;
  
  /**
   * The name of the attribute to be modified.
   */
  private String attribute;
  
  /**
   * The new value of the attribute.
   */
  private String newValue;
  
  /**
   * Trivial constructor.
   * 
   * @param e provides the attribute to be modified.
   * @param attribute the name of the attribute to be modified.
   * @param newValue the new value of the attribute.
   */
  public AttributeModifier(Element e, String attribute, String newValue){
    this.e = e;
    this.attribute = attribute;
    this.newValue = newValue;
  }
  
  @Override
  public void run() {
    e.setAttribute(attribute, newValue);
  }
}

@@ -125,18 +125,17 @@
 ributes.
- 
 %0A
+
  * %0A * @
@@ -164,16 +164,17 @@
 owski%0A *
+ 
 %0A */%0Apub
@@ -223,19 +223,17 @@
 nable %7B%0A
-  
 %0A
+
   /**%0A  
@@ -301,19 +301,17 @@
 ment e;%0A
-  
 %0A
+
   /**%0A  
@@ -389,19 +389,17 @@
 ribute;%0A
-  
 %0A
+
   /**%0A  
@@ -466,19 +466,17 @@
 wValue;%0A
-  
 %0A
+
   /**%0A  
@@ -753,16 +753,17 @@
 ewValue)
+ 
 %7B%0A    th
@@ -842,11 +842,9 @@
   %7D%0A
-  
 %0A
+
   @O
@@ -869,24 +869,53 @@
 oid run() %7B%0A
+    if(newValue != null) %7B%0A  
     e.setAtt
@@ -943,14 +943,73 @@
 Value);%0A
+    %7D%0A    else %7B%0A      e.removeAttribute(attribute);%0A    %7D%0A
   %7D%0A%7D%0A

Allow removing attributes