001/* An attribute that creates an editor to configure its container.
002
003 Copyright (c) 1998-2014 The Regents of the University of California.
004 All rights reserved.
005 Permission is hereby granted, without written agreement and without
006 license or royalty fees, to use, copy, modify, and distribute this
007 software and its documentation for any purpose, provided that the above
008 copyright notice and the following two paragraphs appear in all copies
009 of this software.
010
011 IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
012 FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
013 ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
014 THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
015 SUCH DAMAGE.
016
017 THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
018 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
019 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
020 PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
021 CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,
022 ENHANCEMENTS, OR MODIFICATIONS.
023
024 PT_COPYRIGHT_VERSION_2
025 COPYRIGHTENDKEY
026
027 */
028package ptolemy.actor.gui;
029
030import java.awt.Frame;
031
032import ptolemy.kernel.util.Attribute;
033import ptolemy.kernel.util.IllegalActionException;
034import ptolemy.kernel.util.NameDuplicationException;
035import ptolemy.kernel.util.NamedObj;
036
037///////////////////////////////////////////////////////////////////
038//// EditorFactory
039
040/**
041 This is an attribute that can create an editor for interactively
042 configuring its container. If you place an instance of this class
043 inside a Ptolemy II object, then when a user double clicks on the
044 object, instead of
045 the default behavior (which is to edit parameters), the createEditor()
046 method of this class is called.
047 <p>
048 This differs from EditorPaneFactory
049 in that it is responsible for every aspect of creating the editor.
050 Thus, it has to create a top-level window, rather than just a pane
051 to insert in a top-level window.
052 <p>
053 In this base class, the createEditor() method is abstract.
054 Derived classes must override this method to present a user
055 interface for configuring the object.
056 For example, a digital filter actor could present a filter
057 design interface.  A plotter actor could present a panel for
058 configuring a plot.  A file reader actor could present a file
059 browser.
060
061 @see EditorPaneFactory
062 @author Edward A. Lee
063 @version $Id$
064 @since Ptolemy II 2.0
065 @Pt.ProposedRating Red (eal)
066 @Pt.AcceptedRating Red (johnr)
067 */
068public abstract class EditorFactory extends Attribute implements Editable {
069    /** Construct a factory with the specified container and name.
070     *  @param container The container.
071     *  @param name The name of the factory.
072     *  @exception IllegalActionException If the factory is not of an
073     *   acceptable attribute for the container.
074     *  @exception NameDuplicationException If the name coincides with
075     *   an attribute already in the container.
076     */
077    public EditorFactory(NamedObj container, String name)
078            throws IllegalActionException, NameDuplicationException {
079        super(container, name);
080    }
081
082    ///////////////////////////////////////////////////////////////////
083    ////                         public methods                    ////
084
085    /** Create an editor for configuring the container.
086     *  This editor will have no parent window.
087     */
088    @Override
089    public void createEditor() {
090        createEditor(getContainer(), null);
091    }
092
093    /** Create an editor for configuring the specified object.
094     *  This editor will have no parent window.
095     *  @param object The object to configure.
096     */
097    @Override
098    public void createEditor(NamedObj object) {
099        createEditor(object, null);
100    }
101
102    /** Create an editor for configuring the specified object with the
103     *  specified parent window.
104     *  @param object The object to configure.
105     *  @param parent The parent window, or null if there is none.
106     */
107    @Override
108    public abstract void createEditor(NamedObj object, Frame parent);
109}