1 6 7 package com.jaspersoft.jasperserver.irplugin.gui.inputcontrols.ui; 8 9 import javax.swing.JLabel ; 10 11 15 public class BasicInputControlUI extends javax.swing.JPanel implements InputControlUI { 16 17 18 public BasicInputControlUI() { 19 initComponents(); 20 } 21 22 public Object getValue() 23 { 24 return getJComboBoxValue().getSelectedItem(); 25 } 26 27 public void setValue(Object v) 28 { 29 for (int i=0; i<getJComboBoxValue().getItemCount(); ++i) 30 { 31 Object val = getJComboBoxValue().getItemAt(i); 32 if (val.equals( v)) 33 { 34 getJComboBoxValue().setSelectedIndex(i); 35 return; 36 } 37 } 38 39 getJComboBoxValue().setSelectedItem(v); 40 } 41 42 47 private void initComponents() { 49 java.awt.GridBagConstraints gridBagConstraints; 50 51 jLabelName = new javax.swing.JLabel (); 52 jComboBoxValue = new javax.swing.JComboBox (); 53 54 setLayout(new java.awt.GridBagLayout ()); 55 56 setPreferredSize(new java.awt.Dimension (250, 40)); 57 jLabelName.setText("jLabel1"); 58 gridBagConstraints = new java.awt.GridBagConstraints (); 59 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 60 gridBagConstraints.weightx = 1.0; 61 gridBagConstraints.insets = new java.awt.Insets (0, 4, 0, 4); 62 add(jLabelName, gridBagConstraints); 63 64 jComboBoxValue.setEditable(true); 65 gridBagConstraints = new java.awt.GridBagConstraints (); 66 gridBagConstraints.gridx = 0; 67 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 68 gridBagConstraints.weightx = 1.0; 69 gridBagConstraints.insets = new java.awt.Insets (0, 4, 0, 4); 70 add(jComboBoxValue, gridBagConstraints); 71 72 } 74 public void setLabel(String lbl) 75 { 76 this.jLabelName.setText(lbl); 77 } 78 79 public void setHistory(java.util.List values){ 80 81 getJComboBoxValue().removeAllItems(); 82 if (values == null) return; 83 for (int i=0; i<values.size(); ++i) 84 { 85 getJComboBoxValue().addItem( values.get(i)); 86 } 87 88 if (getJComboBoxValue().getItemCount() > 0) 89 { 90 getJComboBoxValue().setSelectedIndex(0); 91 } 92 93 getJComboBoxValue().updateUI(); 94 } 95 96 public void setComboEditable(boolean b) 97 { 98 getJComboBoxValue().setEditable(b); 99 } 100 101 public boolean getComboEditable() 102 { 103 return getJComboBoxValue().isEditable(); 104 } 105 106 private javax.swing.JComboBox jComboBoxValue; 108 private javax.swing.JLabel jLabelName; 109 111 public void setReadOnly( boolean b ) 112 { 113 jLabelName.setEnabled(!b); 114 getJComboBoxValue().setEnabled(!b); 115 } 116 117 public javax.swing.JComboBox getJComboBoxValue() { 118 return jComboBoxValue; 119 } 120 121 public void setJComboBoxValue(javax.swing.JComboBox jComboBoxValue) { 122 this.jComboBoxValue = jComboBoxValue; 123 } 124 } 125 | Popular Tags |