001/* An attribute for specifying that a parameter is a display only. 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; 034import ptolemy.kernel.util.Settable; 035import ptolemy.kernel.util.Workspace; 036 037/////////////////////////////////////////////////////////////////// 038//// NotEditableLineStyle 039 040/** 041 This attribute annotates user settable attributes to specify 042 a version of the line style which is fixed and not editable. 043 This style can be used with any Settable attribute. 044 045 @see ptolemy.actor.gui.EditorPaneFactory 046 @see ParameterEditorStyle 047 @see LineStyle 048 @author Steve Neuendorffer 049 @version $Id$ 050 @since Ptolemy II 1.0 051 @Pt.ProposedRating Red (eal) 052 @Pt.AcceptedRating Red (johnr) 053 */ 054public class NotEditableLineStyle extends ParameterEditorStyle { 055 /** Construct an attribute in the default workspace with an empty string 056 * as its name. 057 * The object is added to the directory of the workspace. 058 * Increment the version number of the workspace. 059 */ 060 public NotEditableLineStyle() { 061 super(); 062 } 063 064 /** Construct an attribute in the given workspace with an empty string 065 * as its name. 066 * The object is added to the directory of the workspace. 067 * Increment the version number of the workspace. 068 * @param workspace The workspace that will contain the attribute 069 * that is being constructed. 070 */ 071 public NotEditableLineStyle(Workspace workspace) { 072 // This constructor is needed for Shallow codegen to work. 073 super(workspace); 074 } 075 076 /** Construct an attribute with the specified container and name. 077 * @param container The container. 078 * @param name The name of the attribute. 079 * @exception IllegalActionException If the attribute is not of an 080 * acceptable attribute for the container, or if the container 081 * is not an instance of Settable. 082 * @exception NameDuplicationException If the name coincides with 083 * an attribute already in the container. 084 */ 085 public NotEditableLineStyle(NamedObj container, String name) 086 throws IllegalActionException, NameDuplicationException { 087 super(container, name); 088 } 089 090 /////////////////////////////////////////////////////////////////// 091 //// public methods //// 092 093 /** Return true if this style is acceptable for the given parameter. 094 * @param param The attribute that this annotates. 095 * @return True. 096 */ 097 @Override 098 public boolean acceptable(Settable param) { 099 return true; 100 } 101 102 /** Create a new type-in line 103 * entry in the given query associated with the 104 * attribute containing this style. The name of the entry is 105 * the name of the attribute. Attach the attribute to the created entry. 106 * 107 * @param query The query into which to add the entry. 108 */ 109 @Override 110 public void addEntry(PtolemyQuery query) { 111 Settable container = (Settable) getContainer(); 112 String name = container.getName(); 113 String defaultValue = ""; 114 defaultValue = container.getExpression(); 115 query.addDisplay(name, container.getDisplayName(), defaultValue); 116 query.attachParameter(container, name); 117 } 118}