001/* A controller that provides binding of an attribute and a refinement model.
002 *
003 * Copyright (c) 2009-2016 The Regents of the University of California. All
004 * rights reserved. Permission is hereby granted, without written agreement and
005 * without license or royalty fees, to use, copy, modify, and distribute this
006 * software and its documentation for any purpose, provided that the above
007 * copyright notice and the following two paragraphs appear in all copies of
008 * this software.
009 *
010 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
011 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
012 * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
013 * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
014 *
015 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
016 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
017 * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN
018 * "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO PROVIDE
019 * MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
020 *
021 * PT_COPYRIGHT_VERSION_2 COPYRIGHTENDKEY
022 *
023 */
024
025package ptolemy.vergil.basic;
026
027import diva.graph.GraphController;
028import diva.graph.JGraph;
029import diva.gui.GUIUtilities;
030import ptolemy.actor.gui.Configuration;
031import ptolemy.vergil.kernel.AttributeController;
032import ptolemy.vergil.toolbox.MenuActionFactory;
033
034/**
035 * A controller that provides binding of an attribute and a refinement model.
036 *
037 * @author Dai Bui
038 * @version $Id$
039 * @since Ptolemy II 10.0
040 * @Pt.ProposedRating Red (mankit)
041 * @Pt.AcceptedRating Red (mankit)
042 */
043public class MoMLModelAttributeController extends AttributeController {
044
045    /**
046     * Create a model attribute controller associated with the specified graph
047     * controller.
048     * @param controller The specified graph controller.
049     */
050    public MoMLModelAttributeController(GraphController controller) {
051        this(controller, FULL);
052    }
053
054    /**
055     * Create a model attribute controller associated with the specified graph
056     * controller.
057     * @param controller The associated graph controller.
058     * @param access The access level.
059     */
060    public MoMLModelAttributeController(GraphController controller,
061            Access access) {
062        super(controller, access);
063
064        _menuFactory
065                .addMenuItemFactory(new MenuActionFactory(_lookInsideAction));
066
067    }
068
069    ///////////////////////////////////////////////////////////////////
070    ////                         public methods                    ////
071
072    /**
073     * Add hot keys to the look inside action in the given JGraph. It would be
074     * better that this method was added higher in the hierarchy.
075     * @param jgraph The JGraph to which hot keys are to be added.
076     */
077    @Override
078    public void addHotKeys(JGraph jgraph) {
079        super.addHotKeys(jgraph);
080        GUIUtilities.addHotKey(jgraph, _lookInsideAction);
081    }
082
083    /** Set the configuration for MoMLModelAttributeController. This includes
084     *  setting the configuration for its _lookinsideAction menu object.
085     *  @param configuration The given configuration object to be used to
086     *   set the configuration.
087     */
088    @Override
089    public void setConfiguration(Configuration configuration) {
090        super.setConfiguration(configuration);
091        _lookInsideAction.setConfiguration(configuration);
092    }
093
094    ///////////////////////////////////////////////////////////////////
095    ////                         protected variables               ////
096
097    /** The action that handles opening an actor. This is accessed by by
098     *  ActorViewerController to create a hot key for the editor. The name
099     *  "lookInside" is historical and preserved to keep backward compatibility
100     *  with subclasses.
101     */
102    private LookInsideAction _lookInsideAction = new LookInsideAction(
103            "Open Model");
104}