1) Fixed stackoverflow when clicking on entry in PHPeclipse Error Log: OverrideIndica...
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / wizards / html / TableElementCellModifier.java
index 36efe07..62e767d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: TableElementCellModifier.java,v 1.2 2005-05-06 00:57:33 stefanbjarni Exp $
+ * $Id: TableElementCellModifier.java,v 1.3 2006-10-21 23:18:43 pombredanne Exp $
  * Copyright Narushima Hironori. All rights reserved.
  */
 package net.sourceforge.phpeclipse.wizards.html;
@@ -22,6 +22,7 @@ import org.w3c.dom.Text;
 public class TableElementCellModifier implements ICellModifier {
 
        DocumentBuilderFactory builderFactory;
+
        IPropertyChangeListener listener;
 
        public TableElementCellModifier(IPropertyChangeListener listener) {
@@ -32,18 +33,18 @@ public class TableElementCellModifier implements ICellModifier {
        public boolean canModify(Object element, String property) {
                return getValue(element, property) != null;
        }
-       
+
        public Object getValue(Object trElem, String property) {
-               if(trElem instanceof Element){
-                       Element e = (Element)trElem;
-                       if( e.getNodeName().equals("tr") ){
+               if (trElem instanceof Element) {
+                       Element e = (Element) trElem;
+                       if (e.getNodeName().equals("tr")) {
                                int v = TableElementModel.toNumeric(property);
                                Element[] cells = TableElementModel.chooseCellElements(e);
-                               if(v >= 0 && v < cells.length){
+                               if (v >= 0 && v < cells.length) {
                                        NodeList nodes = cells[v].getChildNodes();
-                                       if(nodes.getLength() == 1){
+                                       if (nodes.getLength() == 1) {
                                                Node n = nodes.item(0);
-                                               if(n instanceof Text){
+                                               if (n instanceof Text) {
                                                        return n.getNodeValue();
                                                }
                                        }
@@ -57,23 +58,24 @@ public class TableElementCellModifier implements ICellModifier {
                if (element instanceof Item) {
                        element = ((Item) element).getData();
                }
-               Element trElem =  (Element)element;
+               Element trElem = (Element) element;
                int index = TableElementModel.toNumeric(property);
                Element cellElem = TableElementModel.chooseCellElements(trElem)[index];
-               
+
                NodeList nodes = cellElem.getChildNodes();
-               for(int i=0; i<nodes.getLength(); i++){
-                       cellElem.removeChild( nodes.item(i) );
+               for (int i = 0; i < nodes.getLength(); i++) {
+                       cellElem.removeChild(nodes.item(i));
                }
                Document doc = cellElem.getOwnerDocument();
-               
-               if( value instanceof String){
-                       cellElem.appendChild(doc.createTextNode((String)value));
+
+               if (value instanceof String) {
+                       cellElem.appendChild(doc.createTextNode((String) value));
                }
                // notify listener
-               if(listener != null){
+               if (listener != null) {
                        String oldValue = nodes.item(0).getNodeValue();
-                       listener.propertyChange(new PropertyChangeEvent(this, property, (String)value, oldValue));
+                       listener.propertyChange(new PropertyChangeEvent(this, property,
+                                       (String) value, oldValue));
                }
        }