1 56 package org.objectstyle.cayenne.modeler.dialog.pref; 57 58 import java.awt.BorderLayout ; 59 import java.awt.Component ; 60 import java.util.ArrayList ; 61 import java.util.Collection ; 62 import java.util.Iterator ; 63 64 import javax.swing.JComboBox ; 65 import javax.swing.JPanel ; 66 import javax.swing.JPasswordField ; 67 import javax.swing.JTextField ; 68 69 import com.jgoodies.forms.builder.DefaultFormBuilder; 70 import com.jgoodies.forms.layout.FormLayout; 71 72 77 public class DBConnectionInfoEditorView extends JPanel { 78 79 protected JComboBox adapters; 80 protected JTextField driver; 81 protected JTextField url; 82 protected JTextField userName; 83 protected JPasswordField password; 84 85 protected Collection labels; 86 87 public DBConnectionInfoEditorView() { 88 adapters = new JComboBox (); 89 adapters.setEditable(true); 90 91 driver = new JTextField (); 92 url = new JTextField (); 93 userName = new JTextField (); 94 password = new JPasswordField (); 95 labels = new ArrayList (); 96 97 FormLayout layout = new FormLayout( 99 "right:pref, 3dlu, fill:max(50dlu;pref):grow", 100 ""); 101 DefaultFormBuilder builder = new DefaultFormBuilder(layout); 102 builder.setDefaultDialogBorder(); 103 104 labels.add(builder.append("Adapter:", adapters)); 105 labels.add(builder.append("JDBC Driver:", driver)); 106 labels.add(builder.append("DB URL:", url)); 107 labels.add(builder.append("User Name:", userName)); 108 labels.add(builder.append("Password:", password)); 109 110 this.setLayout(new BorderLayout ()); 111 this.add(builder.getPanel(), BorderLayout.CENTER); 112 } 113 114 public JComboBox getAdapters() { 115 return adapters; 116 } 117 118 public JTextField getDriver() { 119 return driver; 120 } 121 122 public JPasswordField getPassword() { 123 return password; 124 } 125 126 public JTextField getUrl() { 127 return url; 128 } 129 130 public JTextField getUserName() { 131 return userName; 132 } 133 134 public void setEnabled(boolean enabled) { 135 if (isEnabled() != enabled) { 136 super.setEnabled(enabled); 137 Iterator it = labels.iterator(); 138 while (it.hasNext()) { 139 Component c = (Component ) it.next(); 140 c.setEnabled(enabled); 141 } 142 143 adapters.setEnabled(enabled); 144 driver.setEnabled(enabled); 145 url.setEnabled(enabled); 146 userName.setEnabled(enabled); 147 password.setEnabled(enabled); 148 } 149 } 150 } | Popular Tags |