1 19 package org.openharmonise.him.metadata.range.swing.range; 20 21 import java.awt.*; 22 import java.awt.event.*; 23 24 import javax.swing.*; 25 26 31 public class RangeTypeChoice extends JPanel implements LayoutManager, ActionListener { 32 33 private RangeRangeDisplay m_display = null; 34 35 private JComboBox m_comboBox = null; 36 37 private boolean m_bInitialChoice = true; 38 39 42 public RangeTypeChoice(RangeRangeDisplay display) { 43 super(); 44 this.m_display = display; 45 this.setup(); 46 } 47 48 private void setup() { 49 this.setLayout(this); 50 51 String [] aOptions = new String []{"Text","Number","Date","Boolean","Vocabularies","Compound Property","Relationship"}; 52 53 this.m_comboBox = new JComboBox(aOptions); 54 m_comboBox.addActionListener(this); 55 this.add(this.m_comboBox); 56 57 } 58 59 62 private RangeTypeChoice(boolean arg0) { 63 super(arg0); 64 } 65 66 69 private RangeTypeChoice(LayoutManager arg0) { 70 super(arg0); 71 } 72 73 77 private RangeTypeChoice(LayoutManager arg0, boolean arg1) { 78 super(arg0, arg1); 79 } 80 81 84 public void removeLayoutComponent(Component arg0) { 85 } 86 87 90 public void layoutContainer(Container arg0) { 91 int nHeight = 0; 92 int nSpacing = 40; 93 94 m_comboBox.setSize(m_comboBox.getPreferredSize()); 95 m_comboBox.setLocation(0,nHeight); 96 nHeight = nHeight+nSpacing; 97 } 98 99 public Dimension getPreferredSize() { 100 return new Dimension(this.m_comboBox.getPreferredSize().width, this.m_comboBox.getPreferredSize().height); 101 } 102 103 106 public void addLayoutComponent(String arg0, Component arg1) { 107 } 108 109 112 public Dimension minimumLayoutSize(Container arg0) { 113 return this.getPreferredSize(); 114 } 115 116 119 public Dimension preferredLayoutSize(Container arg0) { 120 return this.getPreferredSize(); 121 } 122 123 126 public void actionPerformed(ActionEvent ae) { 127 String sSelectedItem = (String ) this.m_comboBox.getSelectedItem(); 128 if(sSelectedItem!=null && sSelectedItem.length()>0 && !m_bInitialChoice) { 129 this.m_display.typeSelected(sSelectedItem); 130 } 131 if(m_bInitialChoice) { 132 m_bInitialChoice = false; 133 } 134 } 135 136 protected void selectChoice(String sTemp) { 137 System.out.println(sTemp); 138 if(sTemp!=null && sTemp.length()>0) { 139 this.m_comboBox.setSelectedItem(sTemp); 140 } 141 } 142 143 } 144 | Popular Tags |