1 56 package org.objectstyle.cayenne.modeler.dialog.pref; 57 58 import java.awt.BorderLayout ; 59 60 import javax.swing.JButton ; 61 import javax.swing.JComboBox ; 62 import javax.swing.JLabel ; 63 import javax.swing.JPanel ; 64 import javax.swing.JScrollPane ; 65 66 import org.objectstyle.cayenne.modeler.util.CayenneController; 67 68 import com.jgoodies.forms.builder.PanelBuilder; 69 import com.jgoodies.forms.layout.CellConstraints; 70 import com.jgoodies.forms.layout.FormLayout; 71 72 75 public class DataSourcePreferencesView extends JPanel { 76 77 protected JButton addDataSource; 78 protected JButton duplicateDataSource; 79 protected JButton removeDataSource; 80 protected JButton testDataSource; 81 protected JComboBox dataSources; 82 protected DBConnectionInfoEditor dataSourceEditor; 83 84 public DataSourcePreferencesView(CayenneController controller) { 85 this.addDataSource = new JButton ("New..."); 86 this.duplicateDataSource = new JButton ("Duplicate..."); 87 this.removeDataSource = new JButton ("Delete"); 88 this.testDataSource = new JButton ("Test..."); 89 this.dataSources = new JComboBox (); 90 this.dataSourceEditor = new DBConnectionInfoEditor(controller); 91 92 CellConstraints cc = new CellConstraints(); 94 PanelBuilder builder = new PanelBuilder(new FormLayout( 95 "fill:min(150dlu;pref)", 96 "p, 3dlu, p, 10dlu, p, 3dlu, p, 3dlu, p, 10dlu, p")); 97 builder.setDefaultDialogBorder(); 98 99 builder.add(new JLabel ("Select DataSource"), cc.xy(1, 1)); 100 builder.add(dataSources, cc.xy(1, 3)); 101 builder.add(addDataSource, cc.xy(1, 5)); 102 builder.add(duplicateDataSource, cc.xy(1, 7)); 103 builder.add(removeDataSource, cc.xy(1, 9)); 104 builder.add(testDataSource, cc.xy(1, 11)); 105 106 setLayout(new BorderLayout ()); 107 add(new JScrollPane (dataSourceEditor.getView()), BorderLayout.CENTER); 108 add(builder.getPanel(), BorderLayout.EAST); 109 } 110 111 public DBConnectionInfoEditor getDataSourceEditor() { 112 return dataSourceEditor; 113 } 114 115 public JComboBox getDataSources() { 116 return dataSources; 117 } 118 119 public JButton getAddDataSource() { 120 return addDataSource; 121 } 122 123 public JButton getRemoveDataSource() { 124 return removeDataSource; 125 } 126 127 public JButton getTestDataSource() { 128 return testDataSource; 129 } 130 131 public JButton getDuplicateDataSource() { 132 return duplicateDataSource; 133 } 134 } | Popular Tags |