001/* An attribute for specifying that a parameter is edited with a combo menu. 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.style; 029 030import ptolemy.actor.gui.PtolemyQuery; 031import ptolemy.kernel.util.IllegalActionException; 032import ptolemy.kernel.util.NameDuplicationException; 033import ptolemy.kernel.util.NamedObj; 034 035////////////////////////////////////////////////////////////////////////// 036//// EditableChoiceStyle 037 038/** 039 This attribute annotates user settable attributes to specify 040 an editable combobox style for configuring the containing attribute. 041 An editable combobox allows an arbitrary value to be entered in the 042 combobox. 043 For an uneditable combobox, use ChoiceStyle instead. 044 The choices that are presented in the combobox 045 are given by a set of attributes implementing the Settable interface, 046 such as StringAttribute, contained by this style. 047 <p> 048 This class extends ChoiceStyle only for the purpose of eliminating code 049 duplication. 050 051 @see ChoiceStyle 052 @see ptolemy.actor.gui.EditorPaneFactory 053 @see ParameterEditorStyle 054 @see ptolemy.kernel.util.StringAttribute 055 @author Steve Neuendorffer 056 @version $Id$ 057 @since Ptolemy II 1.0 058 @Pt.ProposedRating Green (neuendor) 059 @Pt.AcceptedRating Yellow (neuendor) 060 */ 061public class EditableChoiceStyle extends ChoiceStyle { 062 /** Construct an attribute in the default workspace with an empty string 063 * as its name. 064 * The object is added to the directory of the workspace. 065 * Increment the version number of the workspace. 066 */ 067 public EditableChoiceStyle() { 068 super(); 069 _isEditable = true; 070 } 071 072 /** Construct an attribute with the specified container and name. 073 * @param container The container. 074 * @param name The name of the attribute. 075 * @exception IllegalActionException If the attribute is not of an 076 * acceptable attribute for the container, or if the container 077 * is not an instance of Settable. 078 * @exception NameDuplicationException If the name coincides with 079 * an attribute already in the container. 080 */ 081 public EditableChoiceStyle(NamedObj container, String name) 082 throws IllegalActionException, NameDuplicationException { 083 super(container, name); 084 _isEditable = true; 085 } 086 087 /** Create a new editable 088 * combo box entry in the given query associated with the 089 * attribute containing this style. The name of the entry is 090 * the name of the attribute. Attach the attribute to the created entry. 091 * 092 * @param query The query into which to add the entry. 093 * @exception IllegalActionException If the containing attribute 094 * has a value that cannot be edited using this style. 095 */ 096 @Override 097 public void addEntry(PtolemyQuery query) throws IllegalActionException { 098 super.addEntry(query); 099 _isEditable = true; 100 } 101}