annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
1 package connectionmanager;
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
2
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
3 import java.awt.Point;
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
4 import java.awt.event.MouseAdapter;
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
5 import java.awt.event.MouseEvent;
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
6 import javax.swing.table.DefaultTableModel;
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
7
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
8 public class DatabaseSelectorDialog extends javax.swing.JDialog {
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
9
6
670905eb688a Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents: 5
diff changeset
10 public boolean cancelled = true;
670905eb688a Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents: 5
diff changeset
11 public String hostname;
670905eb688a Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents: 5
diff changeset
12 public String database;
670905eb688a Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents: 5
diff changeset
13 public String username;
5
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
14
6
670905eb688a Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents: 5
diff changeset
15 public DatabaseSelectorDialog(java.awt.Frame parent) {
670905eb688a Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents: 5
diff changeset
16 super(parent, true);
670905eb688a Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents: 5
diff changeset
17 initComponents();
670905eb688a Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents: 5
diff changeset
18 databasesTable.addMouseListener(new MouseListenerDoubleClick());
670905eb688a Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents: 5
diff changeset
19 }
5
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
20
6
670905eb688a Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents: 5
diff changeset
21 public DatabaseSelectorDialog() {
5
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
22 super(new javax.swing.JFrame(), true);
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
23 initComponents();
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
24 databasesTable.addMouseListener(new MouseListenerDoubleClick());
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
25 }
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
26
6
670905eb688a Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents: 5
diff changeset
27 private class MouseListenerDoubleClick extends MouseAdapter {
5
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
28
6
670905eb688a Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents: 5
diff changeset
29 @Override
670905eb688a Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents: 5
diff changeset
30 public void mouseClicked(MouseEvent e) {
670905eb688a Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents: 5
diff changeset
31 if (e.getClickCount() >= 2) {
670905eb688a Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents: 5
diff changeset
32 cancelled = false;
670905eb688a Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents: 5
diff changeset
33 Point p = e.getPoint();
670905eb688a Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents: 5
diff changeset
34 int row = databasesTable.rowAtPoint(p);
670905eb688a Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents: 5
diff changeset
35 DefaultTableModel model = (DefaultTableModel) databasesTable.getModel();
670905eb688a Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents: 5
diff changeset
36 hostname = (String) model.getValueAt(row, 0);
670905eb688a Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents: 5
diff changeset
37 database = (String) model.getValueAt(row, 1);
670905eb688a Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents: 5
diff changeset
38 username = (String) model.getValueAt(row, 2);
670905eb688a Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents: 5
diff changeset
39 doClose();
670905eb688a Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents: 5
diff changeset
40 }
670905eb688a Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents: 5
diff changeset
41 }
5
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
42 }
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
43
6
670905eb688a Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents: 5
diff changeset
44 @SuppressWarnings("unchecked")
5
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
45 // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
46 private void initComponents() {
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
47
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
48 cancelButton = new javax.swing.JButton();
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
49 newButton = new javax.swing.JButton();
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
50 selectButton = new javax.swing.JButton();
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
51 jScrollPane1 = new javax.swing.JScrollPane();
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
52 databasesTable = new javax.swing.JTable();
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
53
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
54 setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
55 setTitle("Select a connection");
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
56
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
57 cancelButton.setText("Cancel");
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
58 cancelButton.addActionListener(new java.awt.event.ActionListener() {
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
59 public void actionPerformed(java.awt.event.ActionEvent evt) {
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
60 cancelButtonActionPerformed(evt);
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
61 }
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
62 });
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
63
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
64 newButton.setText("New");
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
65 newButton.addActionListener(new java.awt.event.ActionListener() {
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
66 public void actionPerformed(java.awt.event.ActionEvent evt) {
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
67 newButtonActionPerformed(evt);
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
68 }
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
69 });
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
70
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
71 selectButton.setText("Select");
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
72 selectButton.addActionListener(new java.awt.event.ActionListener() {
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
73 public void actionPerformed(java.awt.event.ActionEvent evt) {
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
74 selectButtonActionPerformed(evt);
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
75 }
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
76 });
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
77
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
78 databasesTable.setModel(new javax.swing.table.DefaultTableModel(
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
79 new Object [][] {
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
80
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
81 },
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
82 new String [] {
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
83 "Hostname", "Database", "Username"
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
84 }
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
85 ) {
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
86 Class[] types = new Class [] {
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
87 java.lang.String.class, java.lang.String.class, java.lang.String.class
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
88 };
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
89 boolean[] canEdit = new boolean [] {
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
90 false, false, false
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
91 };
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
92
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
93 public Class getColumnClass(int columnIndex) {
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
94 return types [columnIndex];
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
95 }
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
96
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
97 public boolean isCellEditable(int rowIndex, int columnIndex) {
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
98 return canEdit [columnIndex];
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
99 }
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
100 });
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
101 jScrollPane1.setViewportView(databasesTable);
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
102
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
103 org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
104 getContentPane().setLayout(layout);
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
105 layout.setHorizontalGroup(
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
106 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
107 .add(layout.createSequentialGroup()
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
108 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
109 .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
110 .add(183, 183, 183)
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
111 .add(cancelButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
112 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
113 .add(newButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
114 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
115 .add(selectButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
116 .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
117 .addContainerGap()
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
118 .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)))
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
119 .addContainerGap())
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
120 );
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
121 layout.setVerticalGroup(
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
122 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
123 .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
124 .addContainerGap(20, Short.MAX_VALUE)
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
125 .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 225, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
126 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
127 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.CENTER)
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
128 .add(selectButton)
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
129 .add(newButton)
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
130 .add(cancelButton))
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
131 .add(207, 207, 207))
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
132 );
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
133
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
134 pack();
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
135 }// </editor-fold>//GEN-END:initComponents
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
136
6
670905eb688a Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents: 5
diff changeset
137 private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
670905eb688a Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents: 5
diff changeset
138 cancelled = true;
670905eb688a Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents: 5
diff changeset
139 doClose();
670905eb688a Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents: 5
diff changeset
140 }//GEN-LAST:event_cancelButtonActionPerformed
5
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
141
6
670905eb688a Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents: 5
diff changeset
142 private void selectButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_selectButtonActionPerformed
670905eb688a Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents: 5
diff changeset
143 cancelled = false;
670905eb688a Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents: 5
diff changeset
144 int row = databasesTable.getSelectedRow();
670905eb688a Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents: 5
diff changeset
145 DefaultTableModel model = (DefaultTableModel) databasesTable.getModel();
670905eb688a Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents: 5
diff changeset
146 hostname = (String) model.getValueAt(row, 0);
670905eb688a Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents: 5
diff changeset
147 database = (String) model.getValueAt(row, 1);
670905eb688a Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents: 5
diff changeset
148 username = (String) model.getValueAt(row, 2);
670905eb688a Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents: 5
diff changeset
149 doClose();
670905eb688a Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents: 5
diff changeset
150 }//GEN-LAST:event_selectButtonActionPerformed
5
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
151
6
670905eb688a Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents: 5
diff changeset
152 private void newButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newButtonActionPerformed
670905eb688a Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents: 5
diff changeset
153 DatabaseDialog dialog = new DatabaseDialog();
670905eb688a Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents: 5
diff changeset
154 dialog.setVisible(true);
670905eb688a Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents: 5
diff changeset
155 if (!dialog.cancelled) {
670905eb688a Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents: 5
diff changeset
156 cancelled = false;
670905eb688a Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents: 5
diff changeset
157 hostname = dialog.hostname;
670905eb688a Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents: 5
diff changeset
158 database = dialog.database;
670905eb688a Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents: 5
diff changeset
159 username = new String("");
670905eb688a Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents: 5
diff changeset
160 doClose();
670905eb688a Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents: 5
diff changeset
161 }
670905eb688a Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents: 5
diff changeset
162 }//GEN-LAST:event_newButtonActionPerformed
5
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
163
6
670905eb688a Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents: 5
diff changeset
164 private void doClose() {
5
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
165 setVisible(false);
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
166 dispose();
6
670905eb688a Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents: 5
diff changeset
167 }
5
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
168
6
670905eb688a Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents: 5
diff changeset
169 public void add(String hostname, String database, String username) {
670905eb688a Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents: 5
diff changeset
170 DefaultTableModel model = (DefaultTableModel) databasesTable.getModel();
670905eb688a Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents: 5
diff changeset
171 model.insertRow(model.getRowCount(), new Object[]{hostname, database, username});
670905eb688a Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents: 5
diff changeset
172 }
670905eb688a Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents: 5
diff changeset
173
5
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
174 // Variables declaration - do not modify//GEN-BEGIN:variables
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
175 private javax.swing.JButton cancelButton;
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
176 private javax.swing.JTable databasesTable;
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
177 private javax.swing.JScrollPane jScrollPane1;
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
178 private javax.swing.JButton newButton;
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
179 private javax.swing.JButton selectButton;
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
180 // End of variables declaration//GEN-END:variables
35f1cfcaa5a9 Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff changeset
181 }