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 com.sun.rave.designtime;
043:
044: /**
045: * <p>These are the common constants used in several places within the Creator Design-Time API.
046: * These constants are separated into different sub-interfaces to better associate them with where
047: * they are used in the API. See the separate sub-interfaces for detailed documentation.</p>
048: *
049: * @author Joe Nuxoll
050: * @version 1.0
051: */
052: public interface Constants {
053:
054: /**
055: * These constants are used as attribute keys for the BeanDescriptor. Use the 'setValue' method
056: * on the BeanDescriptor to set these values, and the 'getValue' method to retrieve them.
057: *
058: * @see java.beans.BeanDescriptor#setValue(String, Object)
059: * @see java.beans.BeanDescriptor#getValue(String)
060: */
061: public interface BeanDescriptor {
062:
063: /**
064: * This String attribute defines which JSP tag represents this component in the markup. For
065: * example HtmlCommandButton defines "command_button" in it's tagName attribute. If no
066: * tagName is defined, the component is assumed to be a non-visual, and will not be diplayed
067: * on the visual design surface.
068: */
069: public static final String TAG_NAME = "tagName"; // NOI18N
070:
071: /**
072: * This String attribute defines which JSP taglib contains this component.
073: */
074: public static final String TAGLIB_URI = "taglibUri"; // NOI18N
075:
076: /**
077: * This String attribute defines the suggested JSP taglib prefix (if not already added to
078: * the JSP file)
079: */
080: public static final String TAGLIB_PREFIX = "taglibPrefix"; // NOI18N
081:
082: /**
083: * This String[] attribute specifies an array of properties that are "inline editable"
084: * as text. The format of each String is as follows:
085: * <ul>
086: * <li> An initial "*" which indicates that this is the default property and should
087: * be used to inline edit this property when the component is first dropped.
088: * <li> The name of the property
089: * <li> Optionally, a colon followed by an XPath expression pointing to the node
090: * containing the text in the rendered markup. Currently, only a very limited
091: * subset of XPath is supported; this will be improved over time.
092: * This xpath expression can in turn be followed by another comma, and another xpath
093: * expression, repeated as many times as necessary. These supply additional
094: * xpath possibilities for the component renderer. The designer will try each of
095: * these expressions in order until it finds a match in the rendered output from
096: * a component. This is useful for example when a component may render different
097: * output based on its properties, and you want to be able to support inline editing
098: * in all these scenarios.
099: * </ul>
100: * As an example, you might have a String like this:
101: * <pre>
102: * "*value://span[@class='FooBar']"
103: * </pre>
104: * This tells the designer to initiate inline editing whe <span> found in
105: * the markup that has a class attribute set to FooBar.
106: */
107: public static final String INLINE_EDITABLE_PROPERTIES = "inlineEditable";
108:
109: /**
110: * This String attribute defines the base instance name to use for new components of this
111: * type. This base instance name will be auto-numbered for subsequent instances of the
112: * component on the form. For example, HtmlCommandButton defines "button" in it's
113: * instanceName attribute, so the first HtmlCommandButton dropped on a form is called
114: * "button1", and the second "button2", etc. If no instanceName is defined, the class name
115: * will be used (with the initial letter lower-cased), like "htmlCommandButton1".
116: */
117: public static final String INSTANCE_NAME = "instanceName"; // NOI18N
118:
119: /**
120: * This Boolean attribute specifies if this component should have its instance name
121: * prepended with the instance name of its parent when it is created. This is used for
122: * related containership situations, like a table component and its columns. Setting this
123: * attribute to Boolean.TRUE allows a table called "itemTable" to have columns automatically
124: * named "itemTableColumn1", "itemTableColumn2", etc. If this attribute is not set, it is
125: * treated as Boolean.FALSE, and the parent instance name will not be prepended.
126: */
127: public static final String PREPEND_PARENT_INSTANCE_NAME = "prependParentInstanceName"; // NOI18N
128:
129: /**
130: * This Boolean attribute defines whether this component should be treated as a container in
131: * the designer or not. If not defined, all JSF components are treated as containers,
132: * because the UIComponent base-class has parent/child symantics. The HtmlCommandButton, for
133: * example, defines this attribute to Boolean.FALSE so that the designer does not show it as
134: * a component that can have children.
135: */
136: public static final String IS_CONTAINER = "isContainer"; // NOI18N
137:
138: /**
139: * This String[] attribute defines the set of preferred childrens' class names. This
140: * tells Creator which children types to place in a right-click "Add >" context item for
141: * this bean. If this is not set, no "Add >" context item will be present.
142: */
143: public static final String PREFERRED_CHILD_TYPES = "preferredChildTypes"; //NOI18N
144:
145: /**
146: * This Boolean attribute (Boolean.TRUE or Boolean.FALSE) defines wether this component
147: * should be shown in the tray. The default setting is Boolean.FALSE for BeanDescriptors
148: * that do not include this attribute. Typically, this is only used for database-related
149: * components, and the occasional non-painting visual component like HtmlInputHidden.
150: * @deprecated
151: */
152: public static final String TRAY_COMPONENT = "trayComponent"; // NOI18N
153:
154: /**
155: * This Boolean attribute specifies that the MarkupDesignInfo class for this markup bean
156: * will do the rendering at design-time via the customizeRender(...) method. If this
157: * attribute is set to Boolean.TRUE, the markup component will not be invoked to render
158: * itself at design-time, and the associated MarkupDesignInfo class will be required to
159: * provide the rendered content. If this is attribute is set to Boolean.FALSE, or not set,
160: * or there is no associated MarkupDesignInfo for this markup bean, the component rendering
161: * will be invoked.
162: */
163: public static final String SKIP_COMPONENT_RENDER = "skipComponentRender"; // NOI18N
164:
165: /**
166: * This String attribute defines a method on the component that should be called when the
167: * host is cleaning up to allow this bean to cleanup resources, etc. This method should be
168: * called at both design-time and runtime, and must have zero arguments.
169: */
170: public static final String CLEANUP_METHOD = "cleanupMethod"; // NOI18N
171:
172: /**
173: * This attribute (of type FacetDescriptor[]) defines the facets that this JSF component
174: * surfaces.
175: *
176: * @see com.sun.rave.designtime.faces.FacetDescriptor
177: */
178: public static final String FACET_DESCRIPTORS = "facetDescriptors"; // NOI18N
179:
180: /**
181: * This attribute (of type PropertyCategory[]) defines the set of property categories that
182: * this component's property set should be organized in. This is used to control the
183: * display order of the categories, as individual PropertyDescriptor classes will define
184: * which category a property belongs in.
185: *
186: * @see PropertyCategory
187: */
188: public static final String PROPERTY_CATEGORIES = "propertyCategories"; // NOI18N
189:
190: /**
191: * This String attribute defines the section of markup that a particular component has an
192: * 'affinity' for - meaning what part of the document does it need to be parented by. For
193: * example, the Stylesheet component defines it's markupSection as "head", to get rendered
194: * into the head section of the document. "body" and/or "form" is assumed if nothing is set.
195: */
196: public static final String MARKUP_SECTION = "markupSection"; // NOI18N
197:
198: /**
199: * This String attribute defines the help key that resolves to the appropriate help contents
200: * for this component. This will be shown when the user presses F1 when a component is
201: * selected on the palette - or if a dynamic help window is showing.
202: */
203: public static final String HELP_KEY = "helpKey"; // NOI18N
204:
205: /**
206: * This String attribute defines the help key that resolves to the appropriate help contents
207: * for this component. This will be shown when the user presses F1 when a component is
208: * selected on the palette - or if a dynamic help window is showing.
209: */
210: public static final String PROPERTIES_HELP_KEY = "propertiesHelpKey"; // NOI18N
211:
212: /**
213: * This attribute (of type Integer) defines the bitmask of constraints (from
214: * ResizeConstraints interface) that dictates how a user can resize this component
215: *
216: * @see Constants.ResizeConstraints
217: */
218: public static final String RESIZE_CONSTRAINTS = "resizeConstraints"; // NOI18N
219: }
220:
221: /**
222: * The component may or may not be resizable on the design surface. This bitmask (stored in the
223: * Constants.BeanDescriptor.RESIZE_CONSTRAINTS attribute on the BeanDescriptor) defines how the
224: * selection 'nibs' will appear in a visual designer.
225: *
226: * @see Constants.BeanDescriptor.RESIZE_CONSTRAINTS
227: */
228: public interface ResizeConstraints {
229: /** The top edge of the component can be manipulated to resize */
230: public static final int TOP = 0x1;
231: /** The left edge of the component can be manipulated to resize */
232: public static final int LEFT = 0x2;
233: /** The bottom edge of the component can be manipulated to resize */
234: public static final int BOTTOM = 0x4;
235: /** The right edge of the component can be manipulated to resize */
236: public static final int RIGHT = 0x8;
237: /** If resizable, the component should maintain its aspect ratio while it is resized */
238: public static final int MAINTAIN_ASPECT_RATIO = 0x10;
239: /** The component can be resized vertically - the top and bottom edges can be manipulated to resize */
240: public static final int VERTICAL = TOP | BOTTOM;
241: /** The component can be resized horizontally - the left and right edges can be manipulated to resize */
242: public static final int HORIZONTAL = LEFT | RIGHT;
243: /** The component can be resized in any way - the top, bottom, left, and right edges can be manipulated to resize */
244: public static final int ANY = VERTICAL | HORIZONTAL;
245: /** The component can not be resized */
246: public static final int NONE = 0;
247: }
248:
249: /**
250: * These constants are used as attribute keys for the PropertyDescriptor. Use the 'setValue'
251: * method on the PropertyDescriptor to set these values, and the 'getValue' method to retrieve
252: * them.
253: *
254: * @see java.beans.PropertyDescriptor#setValue(String, Object)
255: * @see java.beans.PropertyDescriptor#getValue(String)
256: */
257: public interface PropertyDescriptor {
258:
259: /**
260: * This attribute (of type PropertyCategory) defines the category for a particular
261: * PropertyDescriptor.
262: *
263: * @see java.beans.PropertyDescriptor
264: */
265: public static final String CATEGORY = "category"; // NOI18N
266:
267: /**
268: * This String attribute defines the help key that resolves to the appropriate help contents
269: * for this specific property. This will be shown when the user presses F1 when a property
270: * is selected in the property inspector - or if a dynamic help window is showing when a
271: * property is selected.
272: */
273: public static final String HELP_KEY = "helpKey"; // NOI18N
274:
275: /**
276: * This attribute (of type AttributeDescriptor) defines the markup attribute that this
277: * property corresponds to. Any property settings in the designer that have a corresponding
278: * AttributeDescriptor here will generate the property setting code in the JSP file as a
279: * markup attribute.
280: *
281: * @see com.sun.rave.designtime.markup.AttributeDescriptor
282: */
283: public static final String ATTRIBUTE_DESCRIPTOR = "attributeDescriptor"; // NOI18N
284: }
285:
286: /**
287: * These constants are used as attribute keys for the EventSetDescriptor. Use the 'setValue'
288: * method on the EventSetDescriptor to set these values, and the 'getValue' method to retrieve
289: * them.
290: *
291: * @see java.beans.EventSetDescriptor#setValue(String, Object)
292: * @see java.beans.EventSetDescriptor#getValue(String)
293: */
294: public interface EventSetDescriptor {
295:
296: /**
297: * This attribute (of type EventDescriptor[]) defines the set of events
298: * included in this EventSet. EventDescriptor objects are used to define
299: * additional metadata for particular events.
300: */
301: public static final String EVENT_DESCRIPTORS = "eventDescriptors";
302:
303: /**
304: * This attribute (of type PropertyDescriptor) defines the property that is used to bind
305: * this event set. This is used when a JSF component surfaces a property of type
306: * MethodBinding that is used to define an event.
307: *
308: * @todo Remove me! Use EventDescriptor.BINDING_PROPERTY instead! Left here
309: * to avoid having to update references for now.
310: * @see java.beans.PropertyDescriptor
311: */
312: public static final String BINDING_PROPERTY = "bindingProperty"; // NOI18N
313: }
314:
315: /**
316: * These constants are used as attribute keys for the EventDescriptor. Use the 'setValue'
317: * method on the EventDescriptor to set these values, and the 'getValue' method to retrieve
318: * them.
319: *
320: * @see EventDescriptor#setValue(String, Object)
321: * @see EventDescriptor#getValue(String)
322: */
323: public interface EventDescriptor {
324: /**
325: * This attribute (of type PropertyDescriptor) defines the property that is used to bind
326: * this event set. This is used when a JSF component surfaces a property of type
327: * MethodBinding that is used to define an event.
328: *
329: * @see java.beans.PropertyDescriptor
330: */
331: public static final String BINDING_PROPERTY = "bindingProperty"; // NOI18N
332:
333: /**
334: * This attribute (of type String) defines a default method body (expressed
335: * as formatted Java Source) for the event handler when it is first created.
336: * The body starts immediately after the opening brace, so normally it would
337: * need to start with a newline, then 8 spaces for indentation to cover the
338: * four spaces to the method inset and another 4 for the code itself
339: */
340: public static final String DEFAULT_EVENT_BODY = "defaultEventBody"; // NOI18N
341:
342: /**
343: * This attribute (of type String[]) defines a list of classes that must
344: * be imported when an event handler is created for this event. The sample
345: * code (see DEFAULT_EVENT_BODY) may require it, or common usage in the code
346: * may require it (for example, a validate event may typically want a
347: * ValidatorException to be pre imported.
348: */
349: public static final String REQUIRED_IMPORTS = "requiredImports"; // NOI18N
350:
351: /**
352: * This attribute (of type String[]) defines an array of parameter names to
353: * be used when constructing an event handler in the Java source code for
354: * this event. The array should have at least as many items as there are
355: * parameters.
356: */
357: public static final String PARAMETER_NAMES = "parameterNames"; // NOI18N
358: }
359:
360: /**
361: * These constants are used as pre-defined keys for the DesignContext.getContextData(String)
362: * method.
363: *
364: * @see DesignContext#getContextData(String)
365: */
366: public interface ContextData {
367:
368: /**
369: * Returns an array of StyleClassDescriptor objects (StyleClassDescriptor[]) representing
370: * the CSS style classes currently in scope for this context.
371: *
372: * @see com.sun.rave.designtime.markup.StyleClassDescriptor
373: */
374: public static final String CSS_STYLE_CLASS_DESCRIPTORS = "css-style-class-descriptors"; // NOI18N
375:
376: /**
377: * Returns a comma-separated list of datasource names as a String
378: */
379: public static final String DATASOURCE_NAMES = "datasource-names"; // NOI18N
380:
381: /**
382: * Returns a String representing the scope of the context, like "request", "session", or
383: * "application"
384: */
385: public static final String SCOPE = "scope"; // NOI18N
386:
387: /**
388: * Returns the fully qualified class name (String) of the context
389: */
390: public static final String CLASS_NAME = "className"; // NOI18N
391:
392: /**
393: * Returns a Class object representing the base class of the context
394: */
395: public static final String BASE_CLASS = "baseClass"; // NOI18N
396:
397: /**
398: * Returns a URI object representing the project resource for the JSP page (if any)
399: * represented by this context. If there is no page associated with this context, this
400: * constant returns <code>null</code>.
401: */
402: public static final String PAGE_RESOURCE_URI = "pageResourceUri"; // NOI18N
403:
404: /**
405: * Returns a URI object representing the project resource for the Java source file
406: * represented by this context.
407: */
408: public static final String JAVA_RESOURCE_URI = "javaResourceUri"; // NOI18N
409:
410: /**
411: * Returns a {@link ContextMethod} object representing the <code>init()</code> method from
412: * the Java source file represented by this context, or <code>null</null> if there is no
413: * <code>init</code> method defined by this context.
414: */
415: public static final String INIT_METHOD = "initMethod"; // NOI18N
416:
417: /**
418: * Returns a {@link ContextMethod} object representing the <code>preprocess()</code> method
419: * from the Java source file represented by this context, or <code>null</null> if there is
420: * no <code>preprocess()</code> method defined by this context.
421: */
422: public static final String PREPROCESS_METHOD = "preprocessMethod"; // NOI18N
423:
424: /**
425: * Returns a {@link ContextMethod} object representing the <code>prerender()</code> method
426: * from the Java source file represented by this context, or <code>null</null> if there is
427: * no <code>prerender()</code> method defined by this context.
428: */
429: public static final String PRERENDER_METHOD = "prerenderMethod"; // NOI18N
430:
431: /**
432: * Returns a {@link ContextMethod} object representing the <code>destroy()</code> method
433: * from the Java source file represented by this context, or <code>null</null> if there is
434: * no <code>destroy()</code> method defined by this context.
435: */
436: public static final String DESTROY_METHOD = "destroyMethod"; // NOI18N
437: }
438: }
|