001    /*
002     * The contents of this file are subject to the Mozilla Public License
003     * Version 1.1 (the "License");  you may not use this file except in 
004     * compliance with the License.  You may obtain a copy of the License at
005     * http://www.mozilla.org/MPL/
006     *
007     * Software distributed under the License is distributed on an "AS IS" basis,
008     * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
009     * the specific language governing rights and limitations under the License.
010     *
011     * The Original Code is Protege-2000.
012     *
013     * The Initial Developer of the Original Code is Stanford University. Portions
014     * created by Stanford University are Copyright (C) 2007.  All Rights Reserved.
015     *
016     * Protege was developed by Stanford Medical Informatics
017     * (http://www.smi.stanford.edu) at the Stanford University School of Medicine
018     * with support from the National Library of Medicine, the National Science
019     * Foundation, and the Defense Advanced Research Projects Agency.  Current
020     * information about Protege can be obtained at http://protege.stanford.edu.
021     *
022     */
023    
024    package edu.stanford.smi.protegex.owl.model;
025    
026    /**
027     * An interface for objects that can manage the status and cancellation of
028     * a longish operation on an OWLModel.  The use contract of this is
029     * <p/>
030     * <OL>
031     * <LI>run()</LI>
032     * <LI>( set...() | isCancelled() )*</LI>
033     * <LI>end()</LI>
034     * </OL>
035     * <p/>
036     * A typical implementation of this interface would display a status dialog
037     * with a status text, perhaps an icon, and perhaps a status bar showing progress
038     * from left to right.
039     *
040     * @author Holger Knublauch  <holger@knublauch.com>
041     */
042    public interface ProgressManager {
043    
044        /**
045         * Notifies the manager that a new modal process is about to start.
046         * Calling this method is only valid if no other process is currently
047         * managed by this instance.
048         *
049         * @param title an (optional) title that could be displayed in a dialog etc.
050         */
051        void begin(String title, boolean canBeCancelled);
052    
053    
054        /**
055         * Notifies the manager that the recently started process has ended.
056         * This method must <B>always</B> be called after a process was terminated
057         * so that the manager can close windows, etc.
058         */
059        void end();
060    
061    
062        /**
063         * Checks if the user has cancelled the current process.
064         * The process can call this method occasionally to interrupt itself,
065         * and then invoke <CODE>endProcess()</CODE) to close dialogs etc.
066         *
067         * @return true  if the user wants to cancel
068         */
069        boolean isCancelled();
070    
071    
072        /**
073         * Sets an (optional) value for progress bars.  The caller
074         * typically makes sure that the values increase continuously
075         * from 0 to 1
076         *
077         * @param progress the progress value between 0 and 1
078         */
079        void setProgress(double progress);
080    
081    
082        /**
083         * Specifies an (optional) icon that can be displayed alongside with
084         * the status text.
085         *
086         * @param iconBaseClass the Class that the icon is relative to
087         * @param iconName      the file name relative to the base class
088         */
089        void setIcon(Class iconBaseClass, String iconName);
090    
091    
092        /**
093         * Changes the status text that is being displayed.
094         *
095         * @param text the new text
096         */
097        void setText(String text);
098    }
099