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.JLabel ; 36 import javax.swing.JPanel ; 37 import javax.swing.JSlider ; 38 39 import org.objectweb.cjdbc.common.i18n.WizardTranslate; 40 import org.objectweb.cjdbc.console.wizard.WizardConstants; 41 import org.objectweb.cjdbc.console.wizard.WizardTab; 42 import org.objectweb.cjdbc.console.wizard.WizardTabs; 43 44 51 public class CachingTab extends WizardTab implements ItemListener 52 { 53 54 public JCheckBox metadataenable; 55 56 public JCheckBox parsingenable; 57 58 public JCheckBox resultenable; 59 60 public JSlider maxNbOfMetadata; 61 62 public JSlider maxNbOfField; 63 64 public JCheckBox backgroundParsing; 65 66 public JSlider maxNbOfEntries; 67 68 public JSlider resultMaxNbOfEntries; 69 70 public JSlider pendingTimeout; 71 72 public JComboBox granularity; 73 74 79 public CachingTab(WizardTabs tabs) 80 { 81 super(tabs, WizardConstants.TAB_CACHING); 82 83 87 JPanel metadatacache = new JPanel (); 88 metadatacache.setBorder(BorderFactory.createTitledBorder(WizardTranslate 89 .get("label.metadatacache"))); 90 metadatacache.setLayout(new GridBagLayout ()); 91 GridBagConstraints metadatacacheconstraints = new GridBagConstraints (); 92 metadatacacheconstraints.fill = GridBagConstraints.HORIZONTAL; 93 metadatacacheconstraints.weightx = 1.0; 94 95 metadatacacheconstraints.gridy = ++metadatacacheconstraints.gridy; 97 metadatacacheconstraints.gridx = 0; 98 metadatacache.add(new JLabel (WizardTranslate.get("label.enable")), 99 metadatacacheconstraints); 100 metadatacacheconstraints.gridx = 1; 101 metadataenable = new JCheckBox (); 102 metadataenable.addItemListener(this); 103 metadatacache.add(metadataenable, metadatacacheconstraints); 104 105 metadatacacheconstraints.gridy = ++metadatacacheconstraints.gridy; 107 maxNbOfMetadata = new JSlider (JSlider.HORIZONTAL, 0, 200000, 10000); 108 maxNbOfMetadata.setPaintTicks(true); 109 maxNbOfMetadata.setPaintLabels(true); 110 maxNbOfMetadata.setMajorTickSpacing(50000); 111 maxNbOfMetadata.setEnabled(false); 112 metadatacacheconstraints.gridx = 0; 113 metadatacache.add(new JLabel (WizardTranslate.get("label.maxNbOfMetadata")), 114 metadatacacheconstraints); 115 metadatacacheconstraints.gridx = 1; 116 metadatacache.add(maxNbOfMetadata, metadatacacheconstraints); 117 118 metadatacacheconstraints.gridy = ++metadatacacheconstraints.gridy; 120 maxNbOfField = new JSlider (JSlider.HORIZONTAL, 0, 1000, 0); 121 maxNbOfField.setPaintTicks(true); 122 maxNbOfField.setPaintLabels(true); 123 maxNbOfField.setMajorTickSpacing(100); 124 maxNbOfField.setEnabled(false); 125 metadatacacheconstraints.gridx = 0; 126 metadatacache.add(new JLabel (WizardTranslate.get("label.maxNbOfFields")), 127 metadatacacheconstraints); 128 metadatacacheconstraints.gridx = 1; 129 metadatacache.add(maxNbOfField, metadatacacheconstraints); 130 131 this.add(metadatacache, constraints); 132 constraints.gridy = ++constraints.gridy; 133 134 138 JPanel parsingcache = new JPanel (); 139 parsingcache.setBorder(BorderFactory.createTitledBorder(WizardTranslate 140 .get("label.parsingcache"))); 141 parsingcache.setLayout(new GridBagLayout ()); 142 GridBagConstraints parsingcacheconstraints = new GridBagConstraints (); 143 parsingcacheconstraints.fill = GridBagConstraints.HORIZONTAL; 144 parsingcacheconstraints.weightx = 1.0; 145 146 parsingcacheconstraints.gridy = ++parsingcacheconstraints.gridy; 148 parsingcacheconstraints.gridx = 0; 149 parsingcache.add(new JLabel (WizardTranslate.get("label.enable")), 150 parsingcacheconstraints); 151 parsingcacheconstraints.gridx = 1; 152 parsingenable = new JCheckBox (); 153 parsingenable.addItemListener(this); 154 parsingcache.add(parsingenable, parsingcacheconstraints); 155 156 parsingcacheconstraints.gridy = ++parsingcacheconstraints.gridy; 158 parsingcacheconstraints.gridx = 0; 159 parsingcache.add( 160 new JLabel (WizardTranslate.get("label.backgroundParsing")), 161 parsingcacheconstraints); 162 parsingcacheconstraints.gridx = 1; 163 backgroundParsing = new JCheckBox (); 164 backgroundParsing.addItemListener(this); 165 backgroundParsing.setEnabled(false); 166 parsingcache.add(backgroundParsing, parsingcacheconstraints); 167 168 parsingcacheconstraints.gridy = ++parsingcacheconstraints.gridy; 170 maxNbOfEntries = new JSlider (JSlider.HORIZONTAL, 0, 10000, 5000); 171 maxNbOfEntries.setPaintTicks(true); 172 maxNbOfEntries.setPaintLabels(true); 173 maxNbOfEntries.setMajorTickSpacing(2500); 174 maxNbOfEntries.setEnabled(false); 175 parsingcacheconstraints.gridx = 0; 176 parsingcache.add(new JLabel (WizardTranslate.get("label.maxNbOfEntries")), 177 parsingcacheconstraints); 178 parsingcacheconstraints.gridx = 1; 179 parsingcache.add(maxNbOfEntries, parsingcacheconstraints); 180 181 this.add(parsingcache, constraints); 182 constraints.gridy = ++constraints.gridy; 183 184 188 JPanel resultcache = new JPanel (); 189 resultcache.setBorder(BorderFactory.createTitledBorder(WizardTranslate 190 .get("label.resultcache"))); 191 resultcache.setLayout(new GridBagLayout ()); 192 GridBagConstraints resultcacheconstraints = new GridBagConstraints (); 193 resultcacheconstraints.fill = GridBagConstraints.HORIZONTAL; 194 resultcacheconstraints.weightx = 1.0; 195 196 resultcacheconstraints.gridy = ++resultcacheconstraints.gridy; 198 resultcacheconstraints.gridx = 0; 199 resultcache.add(new JLabel (WizardTranslate.get("label.enable")), 200 resultcacheconstraints); 201 resultcacheconstraints.gridx = 1; 202 resultenable = new JCheckBox (); 203 resultenable.addItemListener(this); 204 resultcache.add(resultenable, resultcacheconstraints); 205 206 resultcacheconstraints.gridy = ++resultcacheconstraints.gridy; 208 granularity = new JComboBox (WizardConstants.RESULT_CACHE_GRANULARITY); 209 granularity.setSelectedIndex(0); 210 granularity.addItemListener(this); 211 granularity.setEnabled(false); 212 resultcacheconstraints.gridx = 0; 213 resultcache.add(new JLabel (WizardTranslate.get("label.granularity")), 214 resultcacheconstraints); 215 resultcacheconstraints.gridx = 1; 216 resultcache.add(granularity, resultcacheconstraints); 217 218 resultcacheconstraints.gridy = ++resultcacheconstraints.gridy; 220 resultMaxNbOfEntries = new JSlider (JSlider.HORIZONTAL, 0, 1000000, 100000); 221 resultMaxNbOfEntries.setPaintTicks(true); 222 resultMaxNbOfEntries.setMajorTickSpacing(100000); 223 resultMaxNbOfEntries.setEnabled(false); 224 resultcacheconstraints.gridx = 0; 225 resultcache.add(new JLabel (WizardTranslate.get("label.maxNbOfEntries")), 226 resultcacheconstraints); 227 resultcacheconstraints.gridx = 1; 228 resultcache.add(resultMaxNbOfEntries, resultcacheconstraints); 229 230 resultcacheconstraints.gridy = ++resultcacheconstraints.gridy; 232 pendingTimeout = new JSlider (JSlider.HORIZONTAL, 0, 3600, 0); 233 pendingTimeout.setPaintTicks(true); 234 pendingTimeout.setPaintLabels(true); 235 pendingTimeout.setMajorTickSpacing(600); 236 pendingTimeout.setEnabled(false); 237 resultcacheconstraints.gridx = 0; 238 resultcache.add(new JLabel (WizardTranslate.get("label.pendingTimeout")), 239 resultcacheconstraints); 240 resultcacheconstraints.gridx = 1; 241 resultcache.add(pendingTimeout, resultcacheconstraints); 242 243 this.add(resultcache, constraints); 244 constraints.gridy = ++constraints.gridy; 245 246 } 247 248 251 public void itemStateChanged(ItemEvent e) 252 { 253 Object source = e.getSource(); 254 if (source == resultenable) 255 { 256 boolean enable = resultenable.getSelectedObjects() != null; 257 granularity.setEnabled(enable); 258 pendingTimeout.setEnabled(enable); 259 resultMaxNbOfEntries.setEnabled(enable); 260 } 261 else if (source == parsingenable) 262 { 263 boolean enable = parsingenable.getSelectedObjects() != null; 264 backgroundParsing.setEnabled(enable); 265 maxNbOfEntries.setEnabled(enable); 266 } 267 else if (source == metadataenable) 268 { 269 boolean enable = metadataenable.getSelectedObjects() != null; 270 maxNbOfMetadata.setEnabled(enable); 271 maxNbOfField.setEnabled(enable); 272 } 273 } 274 } | Popular Tags |