KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > genimen > djeneric > test > helpers > CustomEditor


1 /*
2  * Created on Sep 28, 2003
3  *
4  * To change the template for this generated file go to
5  * Window>Preferences>Java>Code Generation>Code and Comments
6  */

7 package com.genimen.djeneric.test.helpers;
8
9 import java.awt.BorderLayout JavaDoc;
10 import java.awt.Component JavaDoc;
11 import java.awt.Dimension JavaDoc;
12 import java.awt.FlowLayout JavaDoc;
13 import java.awt.event.ActionEvent JavaDoc;
14
15 import javax.swing.DefaultComboBoxModel JavaDoc;
16 import javax.swing.JButton JavaDoc;
17 import javax.swing.JComboBox JavaDoc;
18 import javax.swing.JPanel JavaDoc;
19 import javax.swing.JTextArea JavaDoc;
20
21 import com.genimen.djeneric.repository.DjList;
22 import com.genimen.djeneric.repository.exceptions.DjenericException;
23 import com.genimen.djeneric.structure.EditorDefinition;
24 import com.genimen.djeneric.structure.ExtentUsage;
25 import com.genimen.djeneric.tools.specifier.base.AbstractEditorPanel;
26 import com.genimen.djeneric.tools.specifier.interfaces.ObjectViewer;
27 import com.genimen.djeneric.util.DjLogger;
28
29 /**
30  * @author Wido
31  *
32  * To change the template for this generated type comment go to
33  * Window>Preferences>Java>Code Generation>Code and Comments
34  */

35 public class CustomEditor extends AbstractEditorPanel
36 {
37   private static final long serialVersionUID = 1L;
38
39   BorderLayout JavaDoc borderLayout1 = new BorderLayout JavaDoc();
40   JPanel JavaDoc jPanel1 = new JPanel JavaDoc();
41   JPanel JavaDoc jPanel2 = new JPanel JavaDoc();
42   JPanel JavaDoc jPanel3 = new JPanel JavaDoc();
43   BorderLayout JavaDoc borderLayout2 = new BorderLayout JavaDoc();
44   FlowLayout JavaDoc flowLayout1 = new FlowLayout JavaDoc();
45   JComboBox JavaDoc jComboBox1 = new JComboBox JavaDoc();
46   JButton JavaDoc jButton1 = new JButton JavaDoc();
47   JTextArea JavaDoc jTextArea1 = new JTextArea JavaDoc();
48   BorderLayout JavaDoc borderLayout3 = new BorderLayout JavaDoc();
49
50   protected void applyAndCloseEditor() throws Exception JavaDoc
51   {
52   }
53
54   public void registerEvent(String JavaDoc eventName, String JavaDoc eventTitle, String JavaDoc eventOption)
55   {
56     DefaultComboBoxModel JavaDoc model = (DefaultComboBoxModel JavaDoc) jComboBox1.getModel();
57     model.addElement(eventName + "," + eventOption);
58   }
59
60   public void requestFocus()
61   {
62   }
63
64   public void setSelectedIndexOfMaster(int index)
65   {
66   }
67
68   public String JavaDoc getTitle()
69   {
70     return "Some custom editor";
71   }
72
73   public void focusReceived(ObjectViewer viewer, Component JavaDoc component)
74   {
75   }
76
77   public CustomEditor()
78   {
79     try
80     {
81       jbInit();
82       DefaultComboBoxModel JavaDoc model = (DefaultComboBoxModel JavaDoc) jComboBox1.getModel();
83       model.addElement("ok,accept");
84       model.addElement("cancel,cancel");
85
86     }
87     catch (Exception JavaDoc e)
88     {
89       DjLogger.log(e);
90     }
91   }
92
93   private void jbInit() throws Exception JavaDoc
94   {
95     this.setLayout(borderLayout1);
96     jPanel2.setLayout(borderLayout2);
97     jPanel3.setLayout(flowLayout1);
98     jButton1.setText("Do");
99     jButton1.addActionListener(new CustomEditor_jButton1_actionAdapter(this));
100     jTextArea1.setText("Some simple editor");
101     jPanel1.setLayout(borderLayout3);
102     jComboBox1.setPreferredSize(new Dimension JavaDoc(160, 21));
103     this.add(jPanel1, BorderLayout.CENTER);
104     jPanel1.add(jTextArea1, BorderLayout.CENTER);
105     this.add(jPanel2, BorderLayout.SOUTH);
106     jPanel2.add(jPanel3, BorderLayout.EAST);
107     jPanel3.add(jComboBox1, null);
108     jPanel3.add(jButton1, null);
109     jComboBox1.setModel(new DefaultComboBoxModel JavaDoc());
110   }
111
112   void jButton1_actionPerformed(ActionEvent JavaDoc e)
113   {
114     String JavaDoc action = jComboBox1.getSelectedItem().toString();
115
116     fireEditorEventAndHandleOption(action);
117
118   }
119
120   public void construct(EditorDefinition editorDefinition, DjList objects) throws Exception JavaDoc
121   {
122
123   }
124
125   protected void cleanup()
126   {
127   }
128
129   public void apply()
130   {
131   }
132
133   public void initializeUsage(ExtentUsage usageDef) throws DjenericException
134   {
135
136   }
137
138   public void registerAdditionalEvent(String JavaDoc eventName, String JavaDoc eventTitle, String JavaDoc eventOption)
139   {
140   }
141
142 }
143
144 class CustomEditor_jButton1_actionAdapter implements java.awt.event.ActionListener JavaDoc
145 {
146   CustomEditor adaptee;
147
148   CustomEditor_jButton1_actionAdapter(CustomEditor adaptee)
149   {
150     this.adaptee = adaptee;
151   }
152
153   public void actionPerformed(ActionEvent JavaDoc e)
154   {
155     adaptee.jButton1_actionPerformed(e);
156   }
157 }
Popular Tags