Package net.ajiaojr.spadger.client.desktop.view

Source Code of net.ajiaojr.spadger.client.desktop.view.SettingsViewImpl$SettingsViewUiBinder

/*
* Spadger - an open source discussion forum system.
*
* Copyright (C) 2010 The Spadger Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
*
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
package net.ajiaojr.spadger.client.desktop.view;

import javax.inject.Singleton;

import net.ajiaojr.spadger.client.HotKeysManager;
import net.ajiaojr.spadger.client.view.SettingsView;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.BlurEvent;
import com.google.gwt.event.dom.client.FocusEvent;
import com.google.gwt.i18n.client.DateTimeFormat;
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.uibinder.client.UiTemplate;
import com.google.gwt.user.client.ui.ResizeComposite;
import com.google.gwt.user.client.ui.TabLayoutPanel;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.user.datepicker.client.DateBox;
import com.google.gwt.user.datepicker.client.DateBox.DefaultFormat;

/**
* Implementation of the settings view.
*
* @author The Spadger Team
* @see SettingsView
*/
@Singleton
public class SettingsViewImpl extends ResizeComposite implements SettingsView {

  /**
   * UiBinder interface.
   *
   * @author The Spadger Team
   */
  @UiTemplate("SettingsView.ui.xml")
  interface SettingsViewUiBinder extends
      UiBinder<TabLayoutPanel, SettingsViewImpl> {
  }

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

  /**
   * Date box for user's birthday.
   */
  @UiField
  DateBox birthday;

  private Presenter presenter;

  /**
   * Creates a new instance.
   */
  public SettingsViewImpl() {
    initWidget(uiBinder.createAndBindUi(this));
    birthday
        .setFormat(new DefaultFormat(DateTimeFormat.getFormat("yyyy-MM-dd")));
  }

  /**
   * Handles the blur event of input fields and active the hot keys.
   *
   * @param event
   *          the blur event.
   */
  @UiHandler(value = { "nickname", "signature" })
  public void activateHotKeys(BlurEvent event) {
    HotKeysManager.activateHotKeys();
  }

  /*
   * (non-Javadoc)
   *
   * @see net.ajiaojr.spadger.client.view.SettingsView#asWidget()
   */
  @Override
  public Widget asWidget() {
    return this;
  }

  /**
   * Handles the focus event of the input fields and deactivates the hot keys.
   *
   * @param event
   *          the focus event.
   */
  @UiHandler(value = { "nickname", "signature" })
  public void deactivateHotKeys(FocusEvent event) {
    HotKeysManager.deactivateHotKeys();
  }

  @Override
  public void setPresenter(Presenter presenter) {
    this.presenter = presenter;
  }
}
TOP

Related Classes of net.ajiaojr.spadger.client.desktop.view.SettingsViewImpl$SettingsViewUiBinder

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.