Package com.casamind.adware.client.view

Source Code of com.casamind.adware.client.view.ResourceEditView$ResourceEditViewUiBinder

package com.casamind.adware.client.view;

import com.casamind.adware.client.Adware;
import com.casamind.adware.client.event.RPCOutEvent;
import com.casamind.adware.client.presenter.ResourceEditPresenter;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.event.shared.HasHandlers;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FileUpload;
import com.google.gwt.user.client.ui.FormPanel;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.HasValue;
import com.google.gwt.user.client.ui.HasWidgets;
import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.Widget;

public class ResourceEditView extends Composite implements HasHandlers,
    ResourceEditPresenter.Display, ValueChangeHandler<String>,
    ChangeHandler {
  @UiField
  TextBox nameField;
  @UiField
  ListBox productList, publisherList, companyList;
  @UiField
  Button cancelButton, saveButton, deleteButton, addButton;
  @UiField
  FileUpload fileUploader;
  @UiField
  FormPanel uploadForm;
  @UiField
  HTMLPanel previewPanel;
  private static ResourceEditViewUiBinder uiBinder = GWT.create(ResourceEditViewUiBinder.class);

  interface ResourceEditViewUiBinder extends
      UiBinder<Widget, ResourceEditView> {
  }

  public ResourceEditView() {
    initWidget(uiBinder.createAndBindUi(this));
    initChangeHandlers();
  }

  private void initChangeHandlers() {
    this.saveButton.setEnabled(false);
    this.nameField.addValueChangeHandler(this);
    this.productList.addChangeHandler(this);
    this.publisherList.addChangeHandler(this);
    this.companyList.addChangeHandler(this);
  }

  private void dtoStateChanged() {
    this.saveButton.setEnabled(isValideInput());
  }

  private boolean isValideInput() {
    return !"".equals(this.nameField.getValue().trim());
  }

  @UiHandler("addButton")
  void onSubmit(ClickEvent e) {
    Adware.get().getEventBus().fireEvent(new RPCOutEvent());
    uploadForm.submit();
  }

  @Override
  public HasValue<String> getName() {
    return this.nameField;
  }

  @Override
  public HasClickHandlers getSaveButton() {
    return this.saveButton;
  }

  @Override
  public HasClickHandlers getDeleteButton() {
    return this.deleteButton;
  }

  @Override
  public HasClickHandlers getCancelButton() {
    return this.cancelButton;
  }

  @Override
  public HasWidgets getPreviewPanel() {
    return this.previewPanel;
  }

  @Override
  public FileUpload getFileUpload() {
    return this.fileUploader;
  }

  @Override
  public ListBox getPublisherList() {
    return this.publisherList;
  }

  @Override
  public ListBox getCompanyList() {
    return this.companyList;
  }

  @Override
  public ListBox getProductList() {
    return this.productList;
  }

  @Override
  public void onValueChange(ValueChangeEvent<String> event) {
    this.dtoStateChanged();
  }

  @Override
  public void onChange(ChangeEvent event) {
    this.dtoStateChanged();
  }

  @Override
  public void handleEntityChanged() {
    this.dtoStateChanged();

  }

  @Override
  public HasClickHandlers getAddResourceButton() {
    return this.addButton;
  }

  @Override
  public FormPanel getFormPanel() {
    return this.uploadForm;
  }

  @Override
  public void setEnableUploadButton(boolean isEnabled) {
    this.addButton.setEnabled(isEnabled);
  }

}
TOP

Related Classes of com.casamind.adware.client.view.ResourceEditView$ResourceEditViewUiBinder

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.