001: /*
002: * The contents of this file are subject to the terms of the Common Development
003: * and Distribution License (the License). You may not use this file except in
004: * compliance with the License.
005: *
006: * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
007: * or http://www.netbeans.org/cddl.txt.
008: *
009: * When distributing Covered Code, include this CDDL Header Notice in each file
010: * and include the License file at http://www.netbeans.org/cddl.txt.
011: * If applicable, add the following below the CDDL Header, with the fields
012: * enclosed by brackets [] replaced by your own identifying information:
013: * "Portions Copyrighted [year] [name of copyright owner]"
014: *
015: * The Original Software is NetBeans. The Initial Developer of the Original
016: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
017: * Microsystems, Inc. All Rights Reserved.
018: */
019:
020: /*
021: * Created on May 13, 2005
022: *
023: * To change the template for this generated file go to
024: * Window - Preferences - Java - Code Generation - Code and Comments
025: */
026: package org.netbeans.modules.xml.wsdl.ui.api.property;
027:
028: import java.beans.PropertyEditorSupport;
029:
030: import org.openide.explorer.propertysheet.ExPropertyEditor;
031: import org.openide.explorer.propertysheet.PropertyEnv;
032:
033: /**
034: * @author radval
035: *
036: * To change the template for this generated type comment go to
037: * Window - Preferences - Java - Code Generation - Code and Comments
038: */
039: public class ComboBoxPropertyEditor extends PropertyEditorSupport
040: implements ExPropertyEditor {
041: PropertyEnv mEnv;
042:
043: /**
044: * Describe variable <code>vals</code> here.
045: *
046: */
047: private String[] vals = null;
048:
049: /**
050: * Creates a new <code>ListEditor</code> instance.
051: *
052: * @param values a <code>String[]</code> value
053: */
054: public ComboBoxPropertyEditor(String[] values) {
055: setValues(values);
056: }
057:
058: /**
059: * Describe <code>setValues</code> method here.
060: *
061: * @param values a <code>String[]</code> value
062: */
063: public void setValues(String[] values) {
064: vals = values;
065: }
066:
067: /**
068: * Returns all the values
069: *
070: * @return array of [yes, no]
071: */
072: @Override
073: public String[] getTags() {
074: return vals;
075: }
076:
077: /**
078: * The special case here is, if there is no value set, then it
079: * is a "no"
080: *
081: * @return yes or no
082: */
083: @Override
084: public String getAsText() {
085: if (getValue() == null) {
086: /* if(vals != null && vals.length != 0) {
087: return vals[0];
088: }*/
089: return "";
090: }
091: return getValue().toString();
092: }
093:
094: /**
095: * Set the value from the PropertyEditor to the object
096: *
097: * @param t a <code>String</code> value
098: */
099: @Override
100: public void setAsText(String t) {
101: setValue(t);
102: }
103:
104: /**
105: * Describe <code>supportsCustomEditor</code> method here.
106: *
107: * @return a <code>boolean</code> value
108: */
109: @Override
110: public boolean supportsCustomEditor() {
111: return false;
112: }
113:
114: /**
115: * This method is called by the IDE to pass
116: * the environment to the property editor.
117: * @param env Environment passed by the ide.
118: */
119: public void attachEnv(PropertyEnv env) {
120: mEnv = env;
121: }
122:
123: }
|