XNotifier.java :  » XML-UI » xui32 » com » xoetrope » carousel » survey » Java Open Source

Java Open Source » XML UI » xui32 
xui32 » com » xoetrope » carousel » survey » XNotifier.java
package com.xoetrope.carousel.survey;

import java.util.Observable;
import net.xoetrope.editor.project.XEditorProject;

/**
 *
 * <p> Copyright (c) Xoetrope Ltd., 2001-2006, This software is licensed under
 * the GNU Public License (GPL), please see license.txt for more details. If
 * you make commercial use of this software you must purchase a commercial
 * license from Xoetrope.</p>
 * <p> $Revision: 1.5 $</p>
 */
public class XNotifier extends Observable
{     
    private XEditorProject project;
    private boolean mark;
    
    /**
     * Creates a new instance of XNotifier
     * @param project the current project
     * @param markAsMofied indicates whether the project specified
     * project should be marked as modified after the observers of this object
     * are notified.
     */
    public XNotifier( XEditorProject currentProject, boolean markAsModified )
    {
      super();
      project = currentProject;
      mark = ( markAsModified && ( project != null ));
    }
    
    /**
     * Gets whether this notifier marks the current project
     * as modified after notifying its observers.
     * @return true if project is should be marked as modified,
     * false otherwise
     */
    public boolean markAsModified()
    {
      return mark;
    }

    /**
     * Speicified whether this notifier should mark the 
     * project as modified after notifying its observers.
     * @param markAsModified true if the project should be mark
     * as modified, false otherwise.
     */
    public void markAsModified( boolean markAsModified )
    {
      mark = markAsModified;
    }
    
    /**
     * Notifies all registered observers.
     * @param o the object to be passed the observers
     * @param markAsModifies indicates whether the current project
     * should be marked as modified
     */
    public void notifyObservers( Object o, boolean markAsModified )
    {
      setChanged();
      super.notifyObservers( o );
      if ( markAsModified && ( project != null ))
        project.setModified( true );
    }
    
    /**
     * Notifies all registered observers
     * @parma o the object to be passed to the observers
     */
    public void notifyObservers( Object o ) 
    {
      setChanged();      
      super.notifyObservers( o );
      if ( mark )
        project.setModified( true );
    }  
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.