1 24 25 package org.objectweb.cjdbc.console.wizard.tab; 26 27 import java.awt.GridBagConstraints ; 28 import java.awt.GridBagLayout ; 29 import java.awt.event.ItemEvent ; 30 import java.awt.event.ItemListener ; 31 32 import javax.swing.BorderFactory ; 33 import javax.swing.JCheckBox ; 34 import javax.swing.JComboBox ; 35 import javax.swing.JComponent ; 36 import javax.swing.JLabel ; 37 import javax.swing.JPanel ; 38 import javax.swing.JSlider ; 39 import javax.swing.JTextField ; 40 41 import org.objectweb.cjdbc.common.i18n.WizardTranslate; 42 import org.objectweb.cjdbc.console.wizard.WizardConstants; 43 import org.objectweb.cjdbc.console.wizard.WizardTab; 44 import org.objectweb.cjdbc.console.wizard.WizardTabs; 45 46 53 public class VirtualDatabaseTab extends WizardTab implements ItemListener 54 { 55 56 public JSlider minNbOfThreads; 57 58 public JSlider maxNbOfThreads; 59 60 public JSlider maxThreadIdleTime; 61 62 public JSlider sqlDumpLength; 63 64 public JCheckBox distributed; 65 66 public JComboBox blob; 67 68 public JCheckBox pool; 69 70 public JSlider maxNbOfConnections; 71 72 public JTextField vdbName; 73 74 79 public VirtualDatabaseTab(WizardTabs tabs) 80 { 81 super(tabs, WizardConstants.TAB_VIRTUAL_DATABASE); 82 83 JPanel general = new JPanel (); 85 general.setBorder(BorderFactory.createTitledBorder(WizardTranslate 86 .get("label.database.general"))); 87 general.setLayout(new GridBagLayout ()); 88 this.add(general, constraints); 89 constraints.gridy = ++constraints.gridy; 90 JPanel poolPanel = new JPanel (); 91 poolPanel.setBorder(BorderFactory.createTitledBorder(WizardTranslate 92 .get("label.database.pool"))); 93 poolPanel.setLayout(new GridBagLayout ()); 94 this.add(poolPanel, constraints); 95 constraints.gridy = ++constraints.gridy; 96 JPanel miscellaneous = new JPanel (); 97 miscellaneous.setBorder(BorderFactory.createTitledBorder(WizardTranslate 98 .get("label.database.miscellaneous"))); 99 miscellaneous.setLayout(new GridBagLayout ()); 100 this.add(miscellaneous, constraints); 101 102 GridBagConstraints localconstraints = new GridBagConstraints (); 103 localconstraints.fill = GridBagConstraints.HORIZONTAL; 104 localconstraints.weightx = 1.0; 105 localconstraints.gridy = 0; 106 107 localconstraints.gridy = ++localconstraints.gridy; 109 vdbName = new JTextField (""); 110 localconstraints.gridx = 0; 111 general 112 .add(new JLabel (WizardTranslate.get("label.name")), localconstraints); 113 localconstraints.gridx = 1; 114 general.add(vdbName, localconstraints); 115 116 localconstraints.gridy = ++localconstraints.gridy; 118 localconstraints.gridx = 0; 119 general.add(new JLabel (WizardTranslate.get("label.distributed")), 120 localconstraints); 121 localconstraints.gridx = 1; 122 distributed = new JCheckBox (); 123 distributed.setName("label.distributed"); 124 distributed.addItemListener(this); 125 general.add(distributed, localconstraints); 126 127 localconstraints.gridy = ++localconstraints.gridy; 129 maxNbOfConnections = new JSlider (JSlider.HORIZONTAL, 0, 2000, 0); 130 maxNbOfConnections.setPaintTicks(true); 131 maxNbOfConnections.setPaintLabels(true); 132 maxNbOfConnections.setMajorTickSpacing(500); 133 localconstraints.gridx = 0; 134 general.add(new JLabel (WizardTranslate.get("label.maxNbOfConnections")), 135 localconstraints); 136 localconstraints.gridx = 1; 137 general.add(maxNbOfConnections, localconstraints); 138 139 localconstraints.gridy = 0; 140 141 localconstraints.gridy = ++localconstraints.gridy; 143 pool = new JCheckBox ("", true); 144 pool.addItemListener(this); 145 localconstraints.gridx = 0; 146 poolPanel.add(new JLabel (WizardTranslate.get("label.poolThreads")), 147 localconstraints); 148 localconstraints.gridx = 1; 149 poolPanel.add(pool, localconstraints); 150 151 localconstraints.gridy = ++localconstraints.gridy; 153 minNbOfThreads = new JSlider (JSlider.HORIZONTAL, 0, 2000, 0); 154 minNbOfThreads.setPaintTicks(true); 155 minNbOfThreads.setPaintLabels(true); 156 minNbOfThreads.setMajorTickSpacing(500); 157 localconstraints.gridx = 0; 158 poolPanel.add(new JLabel (WizardTranslate.get("label.minNbOfThreads")), 159 localconstraints); 160 localconstraints.gridx = 1; 161 poolPanel.add(minNbOfThreads, localconstraints); 162 163 localconstraints.gridy = ++localconstraints.gridy; 164 maxNbOfThreads = new JSlider (JSlider.HORIZONTAL, 0, 2000, 0); 165 maxNbOfThreads.setPaintTicks(true); 166 maxNbOfThreads.setPaintLabels(true); 167 maxNbOfThreads.setMajorTickSpacing(500); 168 localconstraints.gridx = 0; 169 poolPanel.add(new JLabel (WizardTranslate.get("label.maxNbOfThreads")), 170 localconstraints); 171 localconstraints.gridx = 1; 172 poolPanel.add(maxNbOfThreads, localconstraints); 173 174 localconstraints.gridy = ++localconstraints.gridy; 175 maxThreadIdleTime = new JSlider (JSlider.HORIZONTAL, 0, 2000, 0); 176 maxThreadIdleTime.setPaintTicks(true); 177 maxThreadIdleTime.setPaintLabels(true); 178 maxThreadIdleTime.setMajorTickSpacing(500); 179 localconstraints.gridx = 0; 180 poolPanel.add(new JLabel (WizardTranslate.get("label.maxThreadIdleTime")), 181 localconstraints); 182 localconstraints.gridx = 1; 183 poolPanel.add(maxThreadIdleTime, localconstraints); 184 185 localconstraints.gridy = 0; 186 187 localconstraints.gridy = ++localconstraints.gridy; 189 sqlDumpLength = new JSlider (JSlider.HORIZONTAL, 0, 512, 40); 190 sqlDumpLength.setPaintTicks(true); 191 sqlDumpLength.setPaintLabels(true); 192 sqlDumpLength.setMajorTickSpacing(100); 193 localconstraints.gridx = 0; 194 miscellaneous.add(new JLabel (WizardTranslate.get("label.sqlDumpLength")), 195 localconstraints); 196 localconstraints.gridx = 1; 197 miscellaneous.add(sqlDumpLength, localconstraints); 198 199 localconstraints.gridy = ++localconstraints.gridy; 201 blob = new JComboBox (WizardConstants.BLOB); 202 blob.setSelectedIndex(0); 203 blob.addItemListener(this); 204 localconstraints.gridx = 0; 205 miscellaneous.add(new JLabel (WizardTranslate 206 .get("label.blobEncodingMethod")), localconstraints); 207 localconstraints.gridx = 1; 208 miscellaneous.add(blob, localconstraints); 209 210 } 211 212 215 public void itemStateChanged(ItemEvent e) 216 { 217 JComponent box = (JComponent ) e.getSource(); 218 if (box == pool) 219 { 220 if (pool.getSelectedObjects() != null) 221 { 222 minNbOfThreads.setEnabled(true); 223 maxNbOfThreads.setEnabled(true); 224 maxThreadIdleTime.setEnabled(true); 225 } 226 else 227 { 228 minNbOfThreads.setEnabled(false); 229 maxNbOfThreads.setEnabled(false); 230 maxThreadIdleTime.setEnabled(false); 231 } 232 } 233 else if (box == distributed) 234 { 235 tabs.distributionChanged(); 236 } 237 } 238 239 244 public boolean isDistributedDB() 245 { 246 return distributed.getSelectedObjects() != null; 247 } 248 249 } | Popular Tags |