package com.jlsites.demo.classroom.client.ui;

import gwtupload.client.IUploader;
import gwtupload.client.SingleUploader;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Anchor;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Image;

public class MenuPanel extends Composite implements HasMenus {

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

	interface MenuPanelUiBinder extends UiBinder<HTMLPanel, MenuPanel> {
	}

	@UiField
	Anchor homeAnchor;
	@UiField
	Anchor homeworkAnchor;
	@UiField
	Anchor assessmentsAnchor;
	@UiField
	Anchor clickTeacherAnchor;
	@UiField
	Anchor announcementsAnchor;
	@UiField
	Anchor calendarAnchor;
	@UiField
	Anchor readingListAnchor;
	@UiField
	Anchor usefulLinksAnchor;
	@UiField
	Anchor photosAnchor;
	@UiField
	Anchor formsAndDocsAnchor;
	@UiField
	Anchor currentPollAnchor;
	@UiField
	Anchor uploadFilesAnchor;

	@UiField
	SingleUploader updateTeacherPhoto;
	@UiField
	Image teacherImage;

	public MenuPanel() {
		initWidget(uiBinder.createAndBindUi(this));
	}

	@Override
	public IUploader getUpdateTeacherPhoto() {
		return updateTeacherPhoto;
	}

	@Override
	public void updateTeacher(String updatedImageName) {
		// TODO is it safe?
		teacherImage.setUrl("/uploads/" + updatedImageName);
	}

	@Override
	public HasClickHandlers getHome() {
		return homeAnchor;
	}

	@Override
	public HasClickHandlers getHomework() {
		return homeworkAnchor;
	}

	@Override
	public HasClickHandlers getAssessments() {
		return assessmentsAnchor;
	}

	@Override
	public HasClickHandlers getMoreAboutTeacher() {
		return clickTeacherAnchor;
	}

	@Override
	public HasClickHandlers getUploadFiles() {
		return uploadFilesAnchor;
	}

}

@@ -448,16 +448,62 @@
 LPanel;%0A
+import com.google.gwt.user.client.ui.HasText;%0A
 import c
@@ -1340,16 +1340,81 @@
 (this));
+%0A%0A%09%09updateTeacherPhoto.getFileInput().setText(%22Change Photo...%22);
 %0A%09%7D%0A%0A%09@O
@@ -1572,12 +1572,13 @@
 %09// 
-TODO
+FIXME
  is 

update the teacher photo with uploader