1 24 25 package org.objectweb.cjdbc.console.wizard.objects; 26 27 import java.awt.Color ; 28 import java.awt.GridBagConstraints ; 29 import java.awt.GridBagLayout ; 30 import java.awt.HeadlessException ; 31 import java.awt.event.ActionEvent ; 32 import java.awt.event.ActionListener ; 33 import java.util.ArrayList ; 34 35 import javax.swing.BorderFactory ; 36 import javax.swing.JButton ; 37 import javax.swing.JDialog ; 38 import javax.swing.JLabel ; 39 import javax.swing.JPanel ; 40 import javax.swing.JSlider ; 41 42 import org.objectweb.cjdbc.common.i18n.WizardTranslate; 43 import org.objectweb.cjdbc.console.gui.constants.GuiConstants; 44 import org.objectweb.cjdbc.console.wizard.WizardConstants; 45 46 53 public class ConnectionParameterDialog extends JDialog 54 implements 55 ActionListener 56 { 57 58 private ArrayList values; 59 60 66 public ConnectionParameterDialog(ConnectionTypeInfo type) 67 throws HeadlessException 68 { 69 super(); 70 this.setModal(true); 71 this.setTitle(type.getType()); 72 this.setResizable(false); 73 this.setBackground(Color.white); 74 75 values = new ArrayList (); 76 77 this.setSize(WizardConstants.CONNECTION_FRAME_WIDTH, 78 WizardConstants.CONNECTION_FRAME_HEIGHT); 79 GuiConstants.centerComponent(this, WizardConstants.CONNECTION_FRAME_WIDTH, 80 WizardConstants.CONNECTION_FRAME_HEIGHT); 81 82 JPanel pane = new JPanel (); 83 pane.setBorder(BorderFactory.createTitledBorder(type.getType())); 84 this.add(pane); 85 86 pane.setLayout(new GridBagLayout ()); 87 GridBagConstraints constraints = new GridBagConstraints (); 88 constraints.fill = GridBagConstraints.HORIZONTAL; 89 constraints.anchor = GridBagConstraints.CENTER; 90 91 constraints.weightx = 1.0; 92 93 String [] atts = type.getAttributes(); 94 for (int i = 0; i < atts.length; i++) 95 { 96 constraints.gridy = ++constraints.gridy; 97 constraints.gridx = 0; 98 pane.add(new JLabel (atts[i]), constraints); 99 constraints.gridx = 1; 100 JSlider slider = new JSlider (0, 600, type.getValue(i)); 101 slider.setPaintLabels(true); 102 slider.setPaintTicks(true); 103 slider.setPaintTrack(true); 104 slider.setMajorTickSpacing(100); 105 pane.add(slider, constraints); 106 values.add(slider); 107 } 108 109 constraints.gridy = ++constraints.gridy; 110 constraints.gridx = 0; 111 JButton button = new JButton (WizardTranslate.get("label.finish.edit")); 112 button.addActionListener(this); 113 pane.add(button, constraints); 114 115 this.validate(); 116 this.setVisible(true); 117 118 } 119 120 125 public ArrayList getValues() 126 { 127 int size = values.size(); 128 ArrayList results = new ArrayList (size); 129 for (int i = 0; i < size; i++) 130 results.add(new Integer ((((JSlider ) values.get(i)).getValue()))); 131 return results; 132 } 133 134 137 public void actionPerformed(ActionEvent e) 138 { 139 this.setVisible(false); 140 } 141 } | Popular Tags |