# QueryExpressionEditorSimple.java Sample

This topic inludes the source code for the QueryExpressionEditorSimple.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

`001 package jcxCreate.ide; 002 003 import com.bea.ide.control.EditorSupport; 004 import java.awt.Component; 005 import java.awt.GridBagConstraints; 006 import java.awt.Insets; 007 import javax.swing.JFormattedTextField; 008 import com.bea.ide.control.AttributeEditorSimple; 009 import com.bea.control.Issue; 010 011 /* 012 * Represent a dialog for editing the expression attribute. This 013 * dialog is displayed when the control's user clicks the ... corresponding 014 * to the attribute in the Property Editor, or double-clicks a method 015 * in the JCX file. 016 */ 017 public class QueryExpressionEditorSimple extends javax.swing.JPanel 018 implements AttributeEditorSimple 019 { 020 021 javax.swing.JEditorPane edpQueryExpression = new javax.swing.JEditorPane(); 022 javax.swing.JLabel lblXQuery = new javax.swing.JLabel(); 023 javax.swing.JTextArea txtDescription = new javax.swing.JTextArea(); 024 025 /* 026 * Call the initComponents method to assemble the dialog's 027 * pieces. Receive the expression attribute original value 028 * to display in the dialog. 029 */ 030 public QueryExpressionEditorSimple(String origValue) 031 { 032 super(); 033 this.initComponents(origValue); 034 } 035 036 public JFormattedTextField.AbstractFormatter getFormatter() 037 { 038 return null; 039 } 040 041 /* 042 * Provides a way for WebLogic Workshop to retrieve the dialog's 043 * components for display. 044 */ 045 public Component getEditorComponent() 046 { 047 return this; 048 } 049 050 /* 051 * Used by WebLogic Workshop to retrieve the new expression attribute 052 * value. edpQueryExpression is the JEditorPane in the dialog box 053 * that contains the expression as entered by the control's user. 054 */ 055 public String getNewAttributeValue() 056 { 057 return edpQueryExpression.getText(); 058 } 059 060 /* 061 * Provides a place for code that should execute when the control's 062 * user clicks OK in the expression editor dialog. 063 */ 064 public Issue[] onFinish() 065 { 066 return null; 067 } 068 069 /* 070 * Assembles components of the dialog. 071 */ 072 public void initComponents(String value) { 073 java.awt.GridBagConstraints gridBagConstraints; 074 setLayout(new java.awt.GridBagLayout()); 075 setEnabled(true); 076 077 txtDescription.setText("Editing your XQuery expression in the box below."); 078 txtDescription.setLineWrap(true); 079 txtDescription.setBackground(null); 080 txtDescription.setEditable(false); 081 gridBagConstraints = new java.awt.GridBagConstraints( 082 0, 0, 4, 1, 1, 0, 083 GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, 084 new Insets(5, 5, 5, 5), 0, 0); 085 add(txtDescription, gridBagConstraints); 086 087 lblXQuery.setText("XQuery expression:"); 088 lblXQuery.setHorizontalAlignment(javax.swing.JLabel.RIGHT); 089 gridBagConstraints = new GridBagConstraints( 090 0, 1, 1, 1, 0, 0, 091 GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, 092 new Insets(5, 5, 5, 5), 0, 0); 093 add(lblXQuery, gridBagConstraints); 094 095 edpQueryExpression.setText(value); 096 gridBagConstraints = new GridBagConstraints( 097 0, 2, 3, 1, 1, 1, 098 GridBagConstraints.NORTH, GridBagConstraints.BOTH, 099 new Insets(5, 0, 5, 5), 0, 0); 100 add(edpQueryExpression, gridBagConstraints); 101 } 102 }`