Package com.habitsoft.kiyaa.widgets

Source Code of com.habitsoft.kiyaa.widgets.HTMLTableColumnPanel

package com.habitsoft.kiyaa.widgets;

import java.util.Iterator;

import com.google.gwt.user.client.ui.HTMLTable;
import com.google.gwt.user.client.ui.Panel;
import com.google.gwt.user.client.ui.Widget;

public class HTMLTableColumnPanel extends Panel {

  protected final HTMLTable table;
  protected final int column;
  protected int row;
 
  public HTMLTableColumnPanel(HTMLTable table, int column) {
    this.table = table;
    this.column = column;
    this.row = 0;
  }

  @Override
  public void add(Widget widget) {
    table.setWidget(row, column, widget);
    row++;
  }
 
  public Iterator iterator() {
    return new Iterator() {
      int currentRow=0;
      Widget lastResult;
      public void remove() {
        if(lastResult != null)
          table.remove(lastResult);
      }
   
      public Object next() {
        lastResult = table.getWidget(currentRow, column);
        currentRow++;
        return lastResult;
      }
   
      public boolean hasNext() {
        return currentRow < row;
      }
   
    };
  }

  @Override
  public boolean remove(Widget w) {
    return table.remove(w);
  }

  @Override
  public void clear() {
    for (Iterator i = this.iterator(); i.hasNext();) {
      Widget w = (Widget) i.next();
      w.removeFromParent();
    }
    row = 0;
  }
}
TOP

Related Classes of com.habitsoft.kiyaa.widgets.HTMLTableColumnPanel

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.