001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.xml.wsdl.ui.spi;
043:
044: import java.util.Collection;
045:
046: import javax.xml.namespace.QName;
047:
048: import org.netbeans.modules.xml.wsdl.model.ExtensibilityElement;
049: import org.openide.nodes.Node;
050:
051: /**
052: * This is a SPI for WSDL extensibility elements provider to implement in order to configure the way
053: * wsdl editor behaves with the extensibility elements.
054: *
055: * @author skini
056: *
057: */
058:
059: public abstract class ExtensibilityElementConfigurator {
060:
061: /**
062: * Should return the qname of the element(s) supported by this configurator.
063: *
064: * @return collection of QName(s)
065: */
066: public abstract Collection<QName> getSupportedQNames();
067:
068: /**
069: * Return the Node.Property for the attribute name to be shown on the property sheet in wsdl editor.
070: * The Property.setName() should be done if a different name is to be shown.
071: * Setting value of extensibility element may result in exception if already in transaction in this method.
072: *
073: * By default, name is set as value of attributeName and the description set to the documentation provided
074: * in the schema or as the qname of the element.
075: * If both have not been provided, then it should be set on the Node.Property before returning it.
076: *
077: * @param extensibilityElement the extensibility element
078: * @param qname the qname of the element interested in
079: * @param attributeName the name of the attribute
080: * @return Node.Property instance for this attribute
081: */
082: public abstract Node.Property getProperty(
083: ExtensibilityElement extensibilityElement, QName qname,
084: String attributeName);
085:
086: /**
087: * Specifies whether this attribute should be hidden (in the property sheet).
088: * If returns true, then the attribute is not shown on the property sheet.
089: *
090: * This method can be used to hide attributes and create a Property editor for multiple properties.
091: * For e.g. Part can have element or type but not both, so set type as hidden and create a node.property
092: * for element with name as "Element or Type" and appropriately change the setValue or getValue to set appropriate
093: * attribute.
094: *
095: * @param qname qname of the element
096: * @param attributeName name of the attribute
097: * @return true if to be hidden
098: */
099: public boolean isHidden(ExtensibilityElement extensibilityElement,
100: QName qname, String attributeName) {
101: return false;
102: }
103:
104: /**
105: * Specifies the name of the attribute, the value of which will be as the display name for this element.
106: *
107: * @param extensibilityElement
108: * @param qname
109: * @return the attribute name.
110: */
111: public abstract String getDisplayAttributeName(
112: ExtensibilityElement extensibilityElement, QName qname);
113:
114: /**
115: * Returns a initial value for this attribute. return a value which will be used as a prefix and
116: * unique names generated by wsdl editor. prefix1, prefix2 etc..
117: *
118: *
119: * @param qname
120: * @param attributeName
121: * @return String either default value(if boolean or enumerated), otherwise prefix
122: */
123:
124: public abstract String getAttributeUniqueValuePrefix(
125: ExtensibilityElement extensibilityElement, QName qname,
126: String attributeName);
127:
128: /**
129: * Gives a default value for the attribute.
130: *
131: *
132: * @param qname
133: * @param attributeName
134: * @return
135: */
136: public abstract String getDefaultValue(
137: ExtensibilityElement extensibilityElement, QName qname,
138: String attributeName);
139:
140: public abstract String getTypeDisplayName(
141: ExtensibilityElement extensibilityElement, QName qname);
142:
143: public String getHtmlDisplayNameDecoration(
144: ExtensibilityElement construct, QName name) {
145: return null;
146: }
147:
148: }
|