Subversion Repositories SmartDukaan

Rev

Rev 585 | Rev 587 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

package in.shop2020.hotspot.dashbaord.client.inbox;

import java.util.Date;
import java.util.GregorianCalendar;

import in.shop2020.hotspot.dashbaord.shared.actions.Item;

import org.enunes.gwt.mvp.client.EventBus;

import com.google.gwt.core.client.GWT;
import com.google.gwt.resources.client.CssResource;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.ResizeComposite;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;

public class ItemDetails extends ResizeComposite {

        private static ItemDetailsUiBinder uiBinder = GWT.create(ItemDetailsUiBinder.class);

        interface ItemDetailsUiBinder extends UiBinder<Widget, ItemDetails> {
        }

        interface SelectionStyle extends CssResource{
                String blueLabel();
                String greenLabel();
        }
        
        private final EventBus eventbus;
        private final Item item;

        @UiField Label itemId, brand, modelNumber, modelName;
        @UiField Label category, comments;
        @UiField Label catalogItemId, vendorItemId;
        @UiField Label mrp, mop, sellingPrice, weight;
        private long addedOn;
        private long startDate;
        private long retireDate;

        public ItemDetails(EventBus eventbus, Item item){
                this.eventbus = eventbus;
                this.item = item;
                initWidget(uiBinder.createAndBindUi(this));
                initItemDetails(this.item);
        }
        
        private void initItemDetails(Item item){
                itemId.setText(item.getId()+"");
                brand.setText(item.getManufacturerName());
                modelNumber.setText(item.getModelNumber());
                modelName.setText(item.getModelName());
                
                category.setText(item.getCategory());
                comments.setText(item.getComments());
                catalogItemId.setText(item.getCatalogItemId() + "");
                vendorItemId.setText(item.getVendorItemId()+"");
                
                mrp.setText(item.getMrp()+"");
                mop.setText(item.getMop()+"");
                sellingPrice.setText(item.getSellingPrice()+"");
                weight.setText(item.getWeight()+"");
        }
        
        //TODO: This code is duplicated between here and OrderList. Move it to a Utility class.
        private String getDisplayableDate(Date date){
                GregorianCalendar cal = new GregorianCalendar();
                //cal.setTimeInMillis(millis);

                String dateString = date.toString();
                dateString = dateString.substring(0, dateString.lastIndexOf(" "));
                dateString = dateString.substring(0, dateString.lastIndexOf(" "));
                return dateString;              
        }
}