annotate ConnectionManager/src/connectionmanager/DatabaseSelectorDialog.java @ 5:35f1cfcaa5a9

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