view src/econnect/wp3_3/client/widgets/table/StiTable.java @ 14:fef6080e83ad

removed unused libraries moved all elements below the mainContainer element fixed layout, so that the sti can be located anywhere an the website fixed kml loading bug in debug mode fixed misleading var names (e.g. search -> open)
author Sebastian Kruse <skruse@mpiwg-berlin.mpg.de>
date Mon, 26 Nov 2012 14:39:42 +0100
parents cf06b77a8bbd
children
line wrap: on
line source

package econnect.wp3_3.client.widgets.table;

import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.user.client.ui.TabPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.RootPanel;

import econnect.wp3_3.client.core.StiCore;

/**
 * Implementation of the table widget
*/
public class StiTable extends TabPanel {

	/**
     * An array of dynamic tables - one for each tab 
    */
	private DynamicStiTable[] dataTables;

	/**
     * The sti core component to allow interactions between the different objects
    */
	private StiCore core;
	
    /**
     * Constructor for the table widget
     *
     * @param core object to allow interaction with all components
    */
	public StiTable( StiCore core ){
		this.core = core;
		this.dataTables = new DynamicStiTable[0];
		this.setStyleName("baseTable");
		this.setVisible(false);
		//RootPanel.get("tableWindow").add(this);		
	}
	
    /**
     * method called from javascript source if selection of elements has changed
     * 
     * @param hover if there was a hover selection or not
    */
	public void updateTables(boolean hover){
		for( int i=0; i<this.dataTables.length; i++ ){
			this.dataTables[i].updateView(hover);
		}
	}
	
    /**
     * method called from javascript source if tables need to be initialized
    */
	public void initTables(){
		int sets = this.core.getDataSets().length();
		this.dataTables = new DynamicStiTable[sets];
		this.clear();
		for( int i=0; i<sets; i++ ){
			this.dataTables[i] = new DynamicStiTable(this.core, i);
			Grid tabLabel = new Grid(1,2);
			tabLabel.setWidget(0,0,new Image( "images/square"+(core.getColorId(i))+".png" ));
			tabLabel.setWidget(0,1,new Label(this.dataTables[i].getTermIdentifier()));
			String header = tabLabel.toString();			
			this.add(this.dataTables[i],header,true);
		}
		this.selectTab(sets-1);
		if( sets > 0 ){
			this.setVisible(true);		
		}
		else {
			this.setVisible(false);
		}
	}

	public void setTop(int top) {
		this.getElement().getStyle().setMarginTop(top, Unit.PX);		
	}
	
}