XQueryEditorSupport.java Sample

This topic inludes the source code for the XQueryEditorSupport.java Sample.

Sample Location

This sample is located in the following directory in your WebLogic Workshop installation:

BEA_HOME/weblogic81/samples/workshop/ExtensionDevKit/ControlDevKit/ControlFeatures/jcxCreate/ide/

Sample Source Code


01 package jcxCreate.ide; 
02 
03 import com.bea.ide.control.ControlAttribute;
04 import com.bea.ide.control.EditorSupport;
05 import com.bea.ide.control.ControlMethod;
06 import com.bea.ide.control.ControlBehaviorContext;
07 import com.bea.ide.control.DefaultEditorSupport;
08 
09 /*
10  * Represents IDE support for XQuery controls added to a project.
11  * An "editor support" class specifies various "behaviors" within the IDE.
12  * These include what to do when the user double-clicks on control methods, 
13  * when the user attempts to add or edit methods and callbacks, and what icon 
14  * to display on a method.
15  */
16 public class XQueryEditorSupport extends DefaultEditorSupport
17 
18     /*
19      * Provides a way for WebLogic Workshop to retrieve the behavior associated
20      * with specified actions in the IDE. Each action has a corresponding 
21      * constant in the EditorSupport interface, which is implemented by the 
22      * DefaultEditorSupport class this class extends. A ControlBehaviorContext
23      * argument specifies whether the context of the action is a method, attribute,
24      * interface, instance, and so on.
25      */
26     public Object getBehavior(String behavior, ControlBehaviorContext context)
27     {
28         /*
29          * If the user asks to edit a JCX method, return true.
30          */
31         if (behavior.equals(EditorSupport.BEHAVIOR_EDIT_METHOD))
32         {
33             return Boolean.TRUE;
34         }
35         /*
36          * If the user asks to edit a callback, return false. XQuery JCX files do
37          * not support callbacks.
38          */
39         else if (behavior.equals(EditorSupport.BEHAVIOR_EDIT_CALLBACK))
40         {
41             return Boolean.FALSE;
42         }
43        /*
44          * If the user clicks an edit ... in the Property Editor, and if the attribute
45          * corresponding to the ... is expression, return an instance of the expression
46          * edit dialog box.
47          */
48         else if (behavior.equals(EditorSupport.BEHAVIOR_ATTRIBUTE_EDITOR))
49         {
50             if (context instanceof ControlAttribute && ((ControlAttribute)context).getName().equals("expression"))
51             {
52                 return new QueryExpressionEditorSimple(((ControlAttribute)context).getValue());
53             }            
54         }
55         return super.getBehavior(behavior, context);
56     }
57