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 40 import org.objectweb.cjdbc.common.i18n.WizardTranslate; 41 import org.objectweb.cjdbc.common.xml.DatabasesXmlTags; 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 55 public class RequestManagerTab extends WizardTab implements ItemListener 56 { 57 58 public JCheckBox caseSensitiveParsing; 59 60 public JSlider beginTimeout; 61 62 public JSlider commitTimeout; 63 64 public JSlider rollbackTimeout; 65 66 public JComboBox scheduler; 67 68 public JPanel shedulerPanel; 69 70 public GridBagConstraints shedulerPanelconstraints; 71 72 public JComboBox schedulerLevel; 73 74 public JComboBox loadbalancer; 75 76 public GridBagConstraints loadbalancerPanelconstraints; 77 78 public JPanel loadbalancerPanel; 79 80 public JCheckBox usecaching; 81 82 public JCheckBox userecoverylog; 83 84 public JComboBox wait4completion; 85 86 91 public RequestManagerTab(WizardTabs tabs) 92 { 93 super(tabs, WizardConstants.TAB_REQUEST_MANAGER); 94 95 99 JPanel general = new JPanel (); 100 general.setBorder(BorderFactory.createTitledBorder(WizardTranslate 101 .get("label.scheduler"))); 102 general.setLayout(new GridBagLayout ()); 103 GridBagConstraints generalconstraints = new GridBagConstraints (); 104 generalconstraints.fill = GridBagConstraints.HORIZONTAL; 105 generalconstraints.weightx = 1.0; 106 107 generalconstraints.gridy = ++generalconstraints.gridy; 109 generalconstraints.gridx = 0; 110 general.add(new JLabel (WizardTranslate.get("label.caseSensitiveParsing")), 111 generalconstraints); 112 generalconstraints.gridx = 1; 113 caseSensitiveParsing = new JCheckBox (); 114 caseSensitiveParsing.setName("label.caseSensitiveParsing"); 115 general.add(caseSensitiveParsing, generalconstraints); 116 117 generalconstraints.gridy = ++generalconstraints.gridy; 119 beginTimeout = new JSlider (JSlider.HORIZONTAL, 0, 2000, 60); 120 beginTimeout.setPaintTicks(true); 121 beginTimeout.setPaintLabels(true); 122 beginTimeout.setMajorTickSpacing(500); 123 generalconstraints.gridx = 0; 124 general.add(new JLabel (WizardTranslate.get("label.beginTimeout")), 125 generalconstraints); 126 generalconstraints.gridx = 1; 127 general.add(beginTimeout, generalconstraints); 128 129 generalconstraints.gridy = ++generalconstraints.gridy; 131 commitTimeout = new JSlider (JSlider.HORIZONTAL, 0, 2000, 60); 132 commitTimeout.setPaintTicks(true); 133 commitTimeout.setPaintLabels(true); 134 commitTimeout.setMajorTickSpacing(500); 135 generalconstraints.gridx = 0; 136 general.add(new JLabel (WizardTranslate.get("label.commitTimeout")), 137 generalconstraints); 138 generalconstraints.gridx = 1; 139 general.add(commitTimeout, generalconstraints); 140 141 generalconstraints.gridy = ++generalconstraints.gridy; 143 rollbackTimeout = new JSlider (JSlider.HORIZONTAL, 0, 2000, 60); 144 rollbackTimeout.setPaintTicks(true); 145 rollbackTimeout.setPaintLabels(true); 146 rollbackTimeout.setMajorTickSpacing(500); 147 generalconstraints.gridx = 0; 148 general.add(new JLabel (WizardTranslate.get("label.rollbackTimeout")), 149 generalconstraints); 150 generalconstraints.gridx = 1; 151 general.add(rollbackTimeout, generalconstraints); 152 153 generalconstraints.gridy = ++generalconstraints.gridy; 155 generalconstraints.gridx = 0; 156 general.add(new JLabel (WizardTranslate.get("label.usecaching")), 157 generalconstraints); 158 generalconstraints.gridx = 1; 159 usecaching = new JCheckBox (); 160 usecaching.setName("label.usecaching"); 161 usecaching.addItemListener(this); 162 general.add(usecaching, generalconstraints); 163 164 generalconstraints.gridy = ++generalconstraints.gridy; 166 generalconstraints.gridx = 0; 167 general.add(new JLabel (WizardTranslate.get("label.userecoverylog")), 168 generalconstraints); 169 generalconstraints.gridx = 1; 170 userecoverylog = new JCheckBox (); 171 userecoverylog.addItemListener(this); 172 userecoverylog.setName("label.userecoverylog"); 173 general.add(userecoverylog, generalconstraints); 174 175 this.add(general, constraints); 176 constraints.gridy = ++constraints.gridy; 177 178 182 shedulerPanel = new JPanel (); 183 shedulerPanel.setBorder(BorderFactory.createTitledBorder(WizardTranslate 184 .get("label.scheduler"))); 185 shedulerPanel.setLayout(new GridBagLayout ()); 186 shedulerPanelconstraints = new GridBagConstraints (); 187 shedulerPanelconstraints.fill = GridBagConstraints.HORIZONTAL; 188 shedulerPanelconstraints.weightx = 1.0; 189 190 scheduler = new JComboBox (WizardConstants.SCHEDULERS_STANDARD); 192 scheduler.setSelectedIndex(0); 193 scheduler.addItemListener(this); 194 shedulerPanelconstraints.gridx = 0; 195 shedulerPanel.add(new JLabel (WizardTranslate.get("label.scheduler.type")), 196 shedulerPanelconstraints); 197 shedulerPanelconstraints.gridx = 1; 198 shedulerPanel.add(scheduler, shedulerPanelconstraints); 199 200 shedulerPanelconstraints.gridy = 1; 201 schedulerLevel = new JComboBox (WizardConstants.SCHEDULER_SINGLEDB_LEVELS); 202 schedulerLevel.setSelectedIndex(0); 203 schedulerLevel.addItemListener(this); 204 shedulerPanelconstraints.gridx = 0; 205 shedulerPanel.add(new JLabel (WizardTranslate.get("label.scheduler.level")), 206 shedulerPanelconstraints); 207 shedulerPanelconstraints.gridx = 1; 208 shedulerPanel.add(schedulerLevel, shedulerPanelconstraints); 209 210 this.add(shedulerPanel, constraints); 211 constraints.gridy = ++constraints.gridy; 212 213 217 loadbalancerPanel = new JPanel (); 218 loadbalancerPanel.setBorder(BorderFactory 219 .createTitledBorder(WizardTranslate.get("label.loadbalancer"))); 220 loadbalancerPanel.setLayout(new GridBagLayout ()); 221 loadbalancerPanelconstraints = new GridBagConstraints (); 222 loadbalancerPanelconstraints.fill = GridBagConstraints.HORIZONTAL; 223 loadbalancerPanelconstraints.weightx = 1.0; 224 225 loadbalancer = new JComboBox (WizardConstants.LOAD_BALANCER_SINGLEDB); 226 loadbalancer.setSelectedIndex(0); 227 loadbalancer.addItemListener(this); 228 loadbalancerPanelconstraints.gridx = 0; 229 loadbalancerPanel.add(new JLabel (WizardTranslate 230 .get("label.loadbalancer.type")), loadbalancerPanelconstraints); 231 loadbalancerPanelconstraints.gridx = 1; 232 loadbalancerPanel.add(loadbalancer, loadbalancerPanelconstraints); 233 234 loadbalancerPanelconstraints.gridy = 1; 235 wait4completion = new JComboBox (WizardConstants.WAIT_POLICIES); 236 wait4completion.setEnabled(false); 237 loadbalancerPanelconstraints.gridx = 0; 238 loadbalancerPanel.add(new JLabel (WizardTranslate 239 .get("label.loadbalancer.wait")), loadbalancerPanelconstraints); 240 loadbalancerPanelconstraints.gridx = 1; 241 loadbalancerPanel.add(wait4completion, loadbalancerPanelconstraints); 242 243 this.add(loadbalancerPanel, constraints); 244 } 245 246 249 public void distributionChanged() 250 { 251 shedulerPanel.remove(scheduler); 252 if (tabs.isDistributedDatabase()) 253 { 254 scheduler = new JComboBox (WizardConstants.SCHEDULERS_DISTRIBUTED); 255 } 256 else 257 { 258 scheduler = new JComboBox (WizardConstants.SCHEDULERS_STANDARD); 259 } 260 scheduler.setSelectedIndex(0); 261 scheduler.addItemListener(this); 262 shedulerPanelconstraints.gridx = 1; 263 shedulerPanelconstraints.gridy = 0; 264 shedulerPanel.add(scheduler, shedulerPanelconstraints); 265 shedulerPanel.validate(); 266 shedulerPanel.repaint(); 267 } 268 269 272 public void itemStateChanged(ItemEvent e) 273 { 274 JComponent source = (JComponent ) e.getSource(); 275 if (source.equals(scheduler)) 276 { 277 shedulerPanel.remove(schedulerLevel); 279 if (scheduler.getSelectedIndex() == 0) 280 schedulerLevel = new JComboBox ( 281 WizardConstants.SCHEDULER_SINGLEDB_LEVELS); 282 else if (scheduler.getSelectedIndex() == 1) 283 schedulerLevel = new JComboBox (WizardConstants.SCHEDULER_RAIDB0_LEVELS); 284 else if (scheduler.getSelectedIndex() == 2) 285 schedulerLevel = new JComboBox (WizardConstants.SCHEDULER_RAIDB1_LEVELS); 286 else if (scheduler.getSelectedIndex() == 3) 287 schedulerLevel = new JComboBox (WizardConstants.SCHEDULER_RAIDB2_LEVELS); 288 289 shedulerPanelconstraints.gridx = 1; 290 shedulerPanelconstraints.gridy = 1; 291 schedulerLevel.setSelectedIndex(0); 292 schedulerLevel.addItemListener(this); 293 shedulerPanel.add(schedulerLevel, shedulerPanelconstraints); 294 shedulerPanel.validate(); 295 shedulerPanel.repaint(); 296 297 loadbalancerPanel.remove(loadbalancer); 299 if (scheduler.getSelectedIndex() == 0) 300 loadbalancer = new JComboBox (WizardConstants.LOAD_BALANCER_SINGLEDB); 301 else if (scheduler.getSelectedIndex() == 1) 302 loadbalancer = new JComboBox (WizardConstants.LOAD_BALANCER_RAIDB0); 303 else if (scheduler.getSelectedIndex() == 2) 304 loadbalancer = new JComboBox (WizardConstants.LOAD_BALANCER_RAIDB1); 305 else if (scheduler.getSelectedIndex() == 3) 306 loadbalancer = new JComboBox (WizardConstants.LOAD_BALANCER_RAIDB2); 307 308 loadbalancerPanelconstraints.gridx = 1; 309 loadbalancerPanelconstraints.gridy = 0; 310 loadbalancer.setSelectedIndex(0); 311 loadbalancer.addItemListener(this); 312 loadbalancerPanel.add(loadbalancer, loadbalancerPanelconstraints); 313 loadbalancerPanel.validate(); 314 loadbalancerPanel.repaint(); 315 316 } 317 else if (source.equals(usecaching)) 318 { 319 if (usecaching.getSelectedObjects() != null) 320 tabs.setTabEnabled(WizardConstants.TAB_CACHING, true); 321 else 322 tabs.setTabEnabled(WizardConstants.TAB_CACHING, false); 323 } 324 else if (source.equals(userecoverylog)) 325 { 326 if (userecoverylog.getSelectedObjects() != null) 327 tabs.setTabEnabled(WizardConstants.TAB_RECOVERY, true); 328 else 329 tabs.setTabEnabled(WizardConstants.TAB_RECOVERY, false); 330 } 331 332 if (source.equals(loadbalancer) || source.equals(scheduler)) 334 { 335 String selected = (String ) loadbalancer.getSelectedItem(); 336 if (selected.startsWith(DatabasesXmlTags.ELT_RAIDb_1) 337 || selected.startsWith(DatabasesXmlTags.ELT_RAIDb_2)) 338 wait4completion.setEnabled(true); 339 else 340 wait4completion.setEnabled(false); 341 } 342 } 343 } | Popular Tags |