comparison ConnectionManager/src/connectionmanager/DatabaseSelectorDialog.java @ 6:670905eb688a

Fix code indentation.
author Daniele Nicolodi <daniele@science.unitn.it>
date Wed, 02 Jun 2010 18:02:25 +0200
parents 35f1cfcaa5a9
children ea3ae6ce9fea
comparison
equal deleted inserted replaced
5:35f1cfcaa5a9 6:670905eb688a
5 import java.awt.event.MouseEvent; 5 import java.awt.event.MouseEvent;
6 import javax.swing.table.DefaultTableModel; 6 import javax.swing.table.DefaultTableModel;
7 7
8 public class DatabaseSelectorDialog extends javax.swing.JDialog { 8 public class DatabaseSelectorDialog extends javax.swing.JDialog {
9 9
10 private boolean cancelled = true; 10 public boolean cancelled = true;
11 public String hostname;
12 public String database;
13 public String username;
11 14
12 public String hostname; 15 public DatabaseSelectorDialog(java.awt.Frame parent) {
13 public String database; 16 super(parent, true);
14 public String username; 17 initComponents();
18 databasesTable.addMouseListener(new MouseListenerDoubleClick());
19 }
15 20
16 public DatabaseSelectorDialog(java.awt.Frame parent) { 21 public DatabaseSelectorDialog() {
17 super(parent, true);
18 initComponents();
19 databasesTable.addMouseListener(new MouseListenerDoubleClick());
20 }
21
22 public DatabaseSelectorDialog() {
23 super(new javax.swing.JFrame(), true); 22 super(new javax.swing.JFrame(), true);
24 initComponents(); 23 initComponents();
25 databasesTable.addMouseListener(new MouseListenerDoubleClick()); 24 databasesTable.addMouseListener(new MouseListenerDoubleClick());
26 } 25 }
27 26
28 private class MouseListenerDoubleClick extends MouseAdapter { 27 private class MouseListenerDoubleClick extends MouseAdapter {
29 28
30 @Override 29 @Override
31 public void mouseClicked(MouseEvent e) { 30 public void mouseClicked(MouseEvent e) {
32 if (e.getClickCount() >= 2) { 31 if (e.getClickCount() >= 2) {
33 cancelled = false; 32 cancelled = false;
34 Point p = e.getPoint(); 33 Point p = e.getPoint();
35 int row = databasesTable.rowAtPoint(p); 34 int row = databasesTable.rowAtPoint(p);
36 DefaultTableModel model = (DefaultTableModel)databasesTable.getModel(); 35 DefaultTableModel model = (DefaultTableModel) databasesTable.getModel();
37 hostname = (String)model.getValueAt(row, 0); 36 hostname = (String) model.getValueAt(row, 0);
38 database = (String)model.getValueAt(row, 1); 37 database = (String) model.getValueAt(row, 1);
39 username = (String)model.getValueAt(row, 2); 38 username = (String) model.getValueAt(row, 2);
40 doClose(); 39 doClose();
41 } 40 }
41 }
42 } 42 }
43 }
44 43
45 @SuppressWarnings("unchecked") 44 @SuppressWarnings("unchecked")
46 // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents 45 // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
47 private void initComponents() { 46 private void initComponents() {
48 47
49 cancelButton = new javax.swing.JButton(); 48 cancelButton = new javax.swing.JButton();
50 newButton = new javax.swing.JButton(); 49 newButton = new javax.swing.JButton();
133 ); 132 );
134 133
135 pack(); 134 pack();
136 }// </editor-fold>//GEN-END:initComponents 135 }// </editor-fold>//GEN-END:initComponents
137 136
138 private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed 137 private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
139 cancelled = true; 138 cancelled = true;
140 doClose(); 139 doClose();
141 }//GEN-LAST:event_cancelButtonActionPerformed 140 }//GEN-LAST:event_cancelButtonActionPerformed
142 141
143 private void selectButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_selectButtonActionPerformed 142 private void selectButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_selectButtonActionPerformed
144 cancelled = false; 143 cancelled = false;
145 int row = databasesTable.getSelectedRow(); 144 int row = databasesTable.getSelectedRow();
146 DefaultTableModel model = (DefaultTableModel)databasesTable.getModel(); 145 DefaultTableModel model = (DefaultTableModel) databasesTable.getModel();
147 hostname = (String)model.getValueAt(row, 0); 146 hostname = (String) model.getValueAt(row, 0);
148 database = (String)model.getValueAt(row, 1); 147 database = (String) model.getValueAt(row, 1);
149 username = (String)model.getValueAt(row, 2); 148 username = (String) model.getValueAt(row, 2);
150 doClose(); 149 doClose();
151 }//GEN-LAST:event_selectButtonActionPerformed 150 }//GEN-LAST:event_selectButtonActionPerformed
152 151
153 private void newButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newButtonActionPerformed 152 private void newButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newButtonActionPerformed
154 DatabaseDialog dialog = new DatabaseDialog(); 153 DatabaseDialog dialog = new DatabaseDialog();
155 dialog.setVisible(true); 154 dialog.setVisible(true);
156 if (!dialog.cancelled) { 155 if (!dialog.cancelled) {
157 cancelled = false; 156 cancelled = false;
158 hostname = dialog.hostname; 157 hostname = dialog.hostname;
159 database = dialog.database; 158 database = dialog.database;
160 username = new String(""); 159 username = new String("");
161 doClose(); 160 doClose();
162 } 161 }
163 }//GEN-LAST:event_newButtonActionPerformed 162 }//GEN-LAST:event_newButtonActionPerformed
164 163
165 private void doClose() { 164 private void doClose() {
166 setVisible(false); 165 setVisible(false);
167 dispose(); 166 dispose();
168 } 167 }
169 168
170 public void add(String hostname, String database, String username) { 169 public void add(String hostname, String database, String username) {
171 DefaultTableModel model = (DefaultTableModel)databasesTable.getModel(); 170 DefaultTableModel model = (DefaultTableModel) databasesTable.getModel();
172 model.insertRow(model.getRowCount(), new Object[] { hostname, database, username }); 171 model.insertRow(model.getRowCount(), new Object[]{hostname, database, username});
173 } 172 }
174 173
175 // Variables declaration - do not modify//GEN-BEGIN:variables 174 // Variables declaration - do not modify//GEN-BEGIN:variables
176 private javax.swing.JButton cancelButton; 175 private javax.swing.JButton cancelButton;
177 private javax.swing.JTable databasesTable; 176 private javax.swing.JTable databasesTable;
178 private javax.swing.JScrollPane jScrollPane1; 177 private javax.swing.JScrollPane jScrollPane1;
179 private javax.swing.JButton newButton; 178 private javax.swing.JButton newButton;