Package gwtgaetools.client.ui

Source Code of gwtgaetools.client.ui.PropertiesGrid

package gwtgaetools.client.ui;

import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.InlineLabel;
import com.google.gwt.user.client.ui.Widget;

public class PropertiesGrid extends Grid {

  public PropertiesGrid(int width) {
    super(0, 2);
    getColumnFormatter().getElement(0).getStyle().setWidth(width, Unit.PX);

  }

  public int addProperty(String name, Widget w) {
    if (name.length() > 0)
      name = name + ":";
    InlineLabel label = new InlineLabel(name);
    return addProperty(label, w);
  }

  public int addProperty(Widget label,
      Widget w) {
    return addProperty(label, w, getRowCount());
  }

  public int addProperty(Widget label, Widget w, int row) {
    insertRow(row);
    setWidget(row, 0, label);
    setWidget(row, 1, w);
    return row;
  }
 
  public void setRowVisible(int row, boolean b) {
    getWidget(row, 0).setVisible(b);
    getWidget(row, 1).setVisible(b);   
  }

  public boolean removeProperty(Widget w) {
    for (int i=0; i<numRows; i++) {
      if (getWidget(i, 1).equals(w)) {
        removeRow(i);
        return true;
      }
    }
    return false;
  }
}
TOP

Related Classes of gwtgaetools.client.ui.PropertiesGrid

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.