Package kameleon.gui.view

Source Code of kameleon.gui.view.ViewMessage

/*
* Copyright (c) 2012, Fromentin Xavier, Schnell Michaël, Dervin Cyrielle, Brabant Quentin
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*      * Redistributions of source code must retain the above copyright
*       notice, this list of conditions and the following disclaimer.
*      * Redistributions in binary form must reproduce the above copyright
*       notice, this list of conditions and the following disclaimer in the
*       documentation and/or other materials provided with the distribution.
*      * The names of its contributors may not be used to endorse or promote products
*       derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL Fromentin Xavier, Schnell Michaël, Dervin Cyrielle OR Brabant Quentin
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package kameleon.gui.view;

import javax.swing.JPanel;

import kameleon.exception.KameleonException;
import kameleon.gui.model.Message;
import kameleon.gui.model.Model;
import kameleon.gui.model.Observer;

/**
* Root class for the graphical components displaying messages. There are different
* types of messages (information, generation, error, ...).
*
* @author    Schnell Michaël
* @version    1.0
*/
public abstract class ViewMessage extends JPanel
implements Observer {
 
  /**
   * Needed to serialize this class.
   *
   * @see    java.io.Serializable
   */
  private static final long serialVersionUID = -7981082465163438260L;

  /**
   * Model for this view.
   */
  protected Model model ;
 
  /**
   * Model backing the data for the displayed message.
   */
  protected Message message ;
 
  /**
   * Builds an instance with the given values.
   *
   * @param   model
   *       model for this view
   *
   * @param   message
   *       model backing the data for the displayed message
   */
  protected ViewMessage(Model model, Message message) {
    super() ;
    this.model = model ;
    this.message = message ;
  }// ViewMessage(Model, Message)
 
  /**
   * Updates the content of this view using the new message for this
   * view. Replaces the old messages with the given one.
   *
   * @param   newMessage
   *       new message displayed by this view
   *
   * @throws   KameleonException
   *       If an error occurred while refreshing the content of the view
   */
  public abstract void updateMessage(Message newMessage) throws KameleonException ;
 
  /** {@inheritDoc} */
  @Override
  public abstract void reloadLanguage() throws KameleonException ;
 
  /** {@inheritDoc} */
  @Override
  public abstract void update() throws KameleonException ;
 
  /**
   * Indicates whether another object is "equal to" this one.
   * Another object is considered to be equal if they display the same
   * message.
   *
   * @param  obj
   *       object compared to this one
   *
   * @see    Message#equals(Object)
   */
  @Override
  public boolean equals(Object obj) {
    if (obj instanceof Message) {
      Message otherMessage = (Message) obj ;
      return this.message.equals(otherMessage) ;
    }// if
    return super.equals(obj) ;
  }// equals(Object)
 
  /** {@inheritDoc} */
  @Override
  public int hashCode() {
    return this.message.hashCode() ;
  }// hasCode()

}// class ViewMessage
TOP

Related Classes of kameleon.gui.view.ViewMessage

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.