1 7 package com.genimen.djeneric.test.helpers; 8 9 import java.awt.BorderLayout ; 10 import java.awt.Component ; 11 import java.awt.Dimension ; 12 import java.awt.FlowLayout ; 13 import java.awt.event.ActionEvent ; 14 15 import javax.swing.DefaultComboBoxModel ; 16 import javax.swing.JButton ; 17 import javax.swing.JComboBox ; 18 import javax.swing.JPanel ; 19 import javax.swing.JTextArea ; 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 35 public class CustomEditor extends AbstractEditorPanel 36 { 37 private static final long serialVersionUID = 1L; 38 39 BorderLayout borderLayout1 = new BorderLayout (); 40 JPanel jPanel1 = new JPanel (); 41 JPanel jPanel2 = new JPanel (); 42 JPanel jPanel3 = new JPanel (); 43 BorderLayout borderLayout2 = new BorderLayout (); 44 FlowLayout flowLayout1 = new FlowLayout (); 45 JComboBox jComboBox1 = new JComboBox (); 46 JButton jButton1 = new JButton (); 47 JTextArea jTextArea1 = new JTextArea (); 48 BorderLayout borderLayout3 = new BorderLayout (); 49 50 protected void applyAndCloseEditor() throws Exception 51 { 52 } 53 54 public void registerEvent(String eventName, String eventTitle, String eventOption) 55 { 56 DefaultComboBoxModel model = (DefaultComboBoxModel ) 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 getTitle() 69 { 70 return "Some custom editor"; 71 } 72 73 public void focusReceived(ObjectViewer viewer, Component component) 74 { 75 } 76 77 public CustomEditor() 78 { 79 try 80 { 81 jbInit(); 82 DefaultComboBoxModel model = (DefaultComboBoxModel ) jComboBox1.getModel(); 83 model.addElement("ok,accept"); 84 model.addElement("cancel,cancel"); 85 86 } 87 catch (Exception e) 88 { 89 DjLogger.log(e); 90 } 91 } 92 93 private void jbInit() throws Exception 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 (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 ()); 110 } 111 112 void jButton1_actionPerformed(ActionEvent e) 113 { 114 String action = jComboBox1.getSelectedItem().toString(); 115 116 fireEditorEventAndHandleOption(action); 117 118 } 119 120 public void construct(EditorDefinition editorDefinition, DjList objects) throws Exception 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 eventName, String eventTitle, String eventOption) 139 { 140 } 141 142 } 143 144 class CustomEditor_jButton1_actionAdapter implements java.awt.event.ActionListener 145 { 146 CustomEditor adaptee; 147 148 CustomEditor_jButton1_actionAdapter(CustomEditor adaptee) 149 { 150 this.adaptee = adaptee; 151 } 152 153 public void actionPerformed(ActionEvent e) 154 { 155 adaptee.jButton1_actionPerformed(e); 156 } 157 } | Popular Tags |