001/* An interface for factories that create menu items. 002 003 Copyright (c) 2000-2016 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.vergil.toolbox; 029 030import javax.swing.JMenuItem; 031 032import diva.gui.toolbox.JContextMenu; 033import ptolemy.kernel.util.NamedObj; 034 035////////////////////////////////////////////////////////////////////////// 036//// MenuItemFactory 037 038/** 039 This is an interface for factories that create menu items. 040 Objects that implement this interface can be used in conjunction 041 with a MenuCreator to implement context menu items. 042 043 @author Steve Neuendorffer and Edward A. Lee 044 @version $Id$ 045 @since Ptolemy II 1.0 046 @Pt.ProposedRating Red (cxh) 047 @Pt.AcceptedRating Red (cxh) 048 */ 049public interface MenuItemFactory { 050 /** Add an item to the given context menu that will operate on 051 * specified target, and return the menu item. Return null to 052 * decline to add a menu item for the specified target. 053 * @param menu The context menu to add to. 054 * @param target The object that the menu item command will operate on. 055 * @return A menu item, or null to decline to provide a menu item. 056 */ 057 public abstract JMenuItem create(JContextMenu menu, NamedObj target); 058}