1 56 package org.objectstyle.cayenne.modeler.dialog.db; 57 58 import java.awt.BorderLayout ; 59 import java.awt.FlowLayout ; 60 61 import javax.swing.JButton ; 62 import javax.swing.JComboBox ; 63 import javax.swing.JDialog ; 64 import javax.swing.JPanel ; 65 66 import org.objectstyle.cayenne.modeler.dialog.pref.DBConnectionInfoEditor; 67 import org.objectstyle.cayenne.modeler.util.CayenneController; 68 69 import com.jgoodies.forms.builder.PanelBuilder; 70 import com.jgoodies.forms.layout.CellConstraints; 71 import com.jgoodies.forms.layout.FormLayout; 72 73 76 public class DataSourceWizardView extends JDialog { 77 78 protected JComboBox dataSources; 79 protected JButton configButton; 80 protected JButton okButton; 81 protected JButton cancelButton; 82 protected DBConnectionInfoEditor connectionInfo; 83 84 public DataSourceWizardView(CayenneController controller) { 85 this.dataSources = new JComboBox (); 86 87 this.configButton = new JButton ("..."); 88 this.configButton.setToolTipText("configure local DataSource"); 89 this.okButton = new JButton ("Continue"); 90 this.cancelButton = new JButton ("Cancel"); 91 this.connectionInfo = new DBConnectionInfoEditor(controller); 92 93 CellConstraints cc = new CellConstraints(); 94 PanelBuilder builder = new PanelBuilder(new FormLayout( 95 "20dlu:grow, pref, 3dlu, fill:max(50dlu;pref), 3dlu, fill:20dlu", 96 "p")); 97 builder.setDefaultDialogBorder(); 98 99 builder.addLabel("Saved DataSources:", cc.xy(2, 1)); 100 builder.add(dataSources, cc.xy(4, 1)); 101 builder.add(configButton, cc.xy(6, 1)); 102 103 JPanel buttons = new JPanel (new FlowLayout (FlowLayout.RIGHT)); 104 buttons.add(cancelButton); 105 buttons.add(okButton); 106 107 getContentPane().setLayout(new BorderLayout ()); 108 getContentPane().add(builder.getPanel(), BorderLayout.NORTH); 109 getContentPane().add(connectionInfo.getView(), BorderLayout.CENTER); 110 getContentPane().add(buttons, BorderLayout.SOUTH); 111 112 setTitle("DB Connection Info"); 113 } 114 115 public JComboBox getDataSources() { 116 return dataSources; 117 } 118 119 public JButton getCancelButton() { 120 return cancelButton; 121 } 122 123 public JButton getConfigButton() { 124 return configButton; 125 } 126 127 public JButton getOkButton() { 128 return okButton; 129 } 130 131 public DBConnectionInfoEditor getConnectionInfo() { 132 return connectionInfo; 133 } 134 } | Popular Tags |