Mercurial > hg > ltpda-connection-manager
annotate ConnectionManager/src/connectionmanager/DatabaseSelectorDialog.java @ 7:ea3ae6ce9fea default tip
Improved Java interface look.
author | Daniele Nicolodi <daniele@grinta.net> |
---|---|
date | Wed, 23 Nov 2011 20:27:21 +0100 |
parents | 670905eb688a |
children |
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 |
7
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
3 import java.awt.Component; |
5
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
4 import java.awt.Point; |
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
5 import java.awt.event.MouseAdapter; |
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
6 import java.awt.event.MouseEvent; |
7
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
7 import javax.swing.JLabel; |
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
8 import javax.swing.JTable; |
5
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
9 import javax.swing.table.DefaultTableModel; |
7
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
10 import javax.swing.table.DefaultTableCellRenderer; |
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
11 |
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
12 |
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
13 class CellRenderer extends DefaultTableCellRenderer { |
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
14 public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { |
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
15 return super.getTableCellRendererComponent(table, value, isSelected, false, row, column); |
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
16 } |
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
17 } |
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
18 |
5
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
19 |
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
20 public class DatabaseSelectorDialog extends javax.swing.JDialog { |
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
21 |
6
670905eb688a
Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
5
diff
changeset
|
22 public boolean cancelled = true; |
670905eb688a
Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
5
diff
changeset
|
23 public String hostname; |
670905eb688a
Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
5
diff
changeset
|
24 public String database; |
670905eb688a
Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
5
diff
changeset
|
25 public String username; |
5
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 public DatabaseSelectorDialog(java.awt.Frame parent) { |
670905eb688a
Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
5
diff
changeset
|
28 super(parent, true); |
670905eb688a
Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
5
diff
changeset
|
29 initComponents(); |
7
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
30 getRootPane().setDefaultButton(selectButton); |
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
31 databasesTable.setDefaultRenderer(Object.class, new CellRenderer()); |
6
670905eb688a
Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
5
diff
changeset
|
32 databasesTable.addMouseListener(new MouseListenerDoubleClick()); |
670905eb688a
Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
5
diff
changeset
|
33 } |
5
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
34 |
6
670905eb688a
Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
5
diff
changeset
|
35 public DatabaseSelectorDialog() { |
5
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
36 super(new javax.swing.JFrame(), true); |
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
37 initComponents(); |
7
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
38 getRootPane().setDefaultButton(selectButton); |
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
39 databasesTable.setDefaultRenderer(Object.class, new CellRenderer()); |
5
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
40 databasesTable.addMouseListener(new MouseListenerDoubleClick()); |
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 |
6
670905eb688a
Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
5
diff
changeset
|
43 private class MouseListenerDoubleClick extends MouseAdapter { |
5
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
44 |
6
670905eb688a
Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
5
diff
changeset
|
45 @Override |
670905eb688a
Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
5
diff
changeset
|
46 public void mouseClicked(MouseEvent e) { |
670905eb688a
Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
5
diff
changeset
|
47 if (e.getClickCount() >= 2) { |
670905eb688a
Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
5
diff
changeset
|
48 cancelled = false; |
670905eb688a
Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
5
diff
changeset
|
49 Point p = e.getPoint(); |
670905eb688a
Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
5
diff
changeset
|
50 int row = databasesTable.rowAtPoint(p); |
670905eb688a
Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
5
diff
changeset
|
51 DefaultTableModel model = (DefaultTableModel) databasesTable.getModel(); |
670905eb688a
Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
5
diff
changeset
|
52 hostname = (String) model.getValueAt(row, 0); |
670905eb688a
Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
5
diff
changeset
|
53 database = (String) model.getValueAt(row, 1); |
670905eb688a
Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
5
diff
changeset
|
54 username = (String) model.getValueAt(row, 2); |
670905eb688a
Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
5
diff
changeset
|
55 doClose(); |
670905eb688a
Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
5
diff
changeset
|
56 } |
670905eb688a
Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
5
diff
changeset
|
57 } |
5
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
58 } |
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
59 |
6
670905eb688a
Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
5
diff
changeset
|
60 @SuppressWarnings("unchecked") |
5
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
61 // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents |
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
62 private void initComponents() { |
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 cancelButton = new javax.swing.JButton(); |
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
65 newButton = new javax.swing.JButton(); |
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
66 selectButton = new javax.swing.JButton(); |
7
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
67 scrollPane = new javax.swing.JScrollPane(); |
5
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
68 databasesTable = new javax.swing.JTable(); |
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 setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); |
7
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
71 setTitle("Select database"); |
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
72 setResizable(false); |
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
73 addKeyListener(new java.awt.event.KeyAdapter() { |
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
74 public void keyPressed(java.awt.event.KeyEvent evt) { |
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
75 formKeyPressed(evt); |
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
76 } |
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
77 }); |
5
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 cancelButton.setText("Cancel"); |
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
80 cancelButton.addActionListener(new java.awt.event.ActionListener() { |
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
81 public void actionPerformed(java.awt.event.ActionEvent evt) { |
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
82 cancelButtonActionPerformed(evt); |
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
83 } |
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 newButton.setText("New"); |
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
87 newButton.addActionListener(new java.awt.event.ActionListener() { |
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
88 public void actionPerformed(java.awt.event.ActionEvent evt) { |
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
89 newButtonActionPerformed(evt); |
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
90 } |
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 selectButton.setText("Select"); |
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
94 selectButton.addActionListener(new java.awt.event.ActionListener() { |
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
95 public void actionPerformed(java.awt.event.ActionEvent evt) { |
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
96 selectButtonActionPerformed(evt); |
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 }); |
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 databasesTable.setModel(new javax.swing.table.DefaultTableModel( |
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
101 new Object [][] { |
7
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
102 {"1", null, null}, |
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
103 {"2", null, null}, |
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
104 {"3", null, null}, |
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
105 {"4", null, null}, |
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
106 {"5", null, null}, |
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
107 {"6", null, null}, |
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
108 {"7", null, null}, |
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
109 {"8", null, null} |
5
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
110 }, |
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
111 new String [] { |
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
112 "Hostname", "Database", "Username" |
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
113 } |
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
114 ) { |
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
115 Class[] types = new Class [] { |
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
116 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
|
117 }; |
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
118 boolean[] canEdit = new boolean [] { |
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
119 false, false, false |
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 |
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
122 public Class getColumnClass(int columnIndex) { |
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
123 return types [columnIndex]; |
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
124 } |
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
125 |
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
126 public boolean isCellEditable(int rowIndex, int columnIndex) { |
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
127 return canEdit [columnIndex]; |
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
128 } |
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
129 }); |
7
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
130 databasesTable.setFocusable(false); |
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
131 databasesTable.setGridColor(new java.awt.Color(204, 204, 204)); |
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
132 databasesTable.setIntercellSpacing(new java.awt.Dimension(0, 0)); |
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
133 databasesTable.setRowHeight(24); |
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
134 databasesTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); |
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
135 databasesTable.setShowVerticalLines(false); |
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
136 scrollPane.setViewportView(databasesTable); |
5
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 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
|
139 getContentPane().setLayout(layout); |
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
140 layout.setHorizontalGroup( |
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
141 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) |
7
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
142 .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() |
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
143 .addContainerGap() |
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
144 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) |
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
145 .add(org.jdesktop.layout.GroupLayout.LEADING, scrollPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 409, Short.MAX_VALUE) |
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
146 .add(layout.createSequentialGroup() |
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
147 .add(newButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) |
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
148 .add(184, 184, 184) |
5
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
149 .add(cancelButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) |
7
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
150 .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) |
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
151 .add(selectButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) |
5
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
152 .addContainerGap()) |
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
153 ); |
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
154 layout.setVerticalGroup( |
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
155 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) |
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
156 .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() |
7
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
157 .addContainerGap() |
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
158 .add(scrollPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 212, Short.MAX_VALUE) |
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
159 .add(18, 18, 18) |
5
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
160 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.CENTER) |
7
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
161 .add(newButton) |
5
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
162 .add(selectButton) |
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
163 .add(cancelButton)) |
7
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
164 .addContainerGap()) |
5
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
165 ); |
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
166 |
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
167 pack(); |
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
168 }// </editor-fold>//GEN-END:initComponents |
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
169 |
6
670905eb688a
Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
5
diff
changeset
|
170 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
|
171 cancelled = true; |
670905eb688a
Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
5
diff
changeset
|
172 doClose(); |
670905eb688a
Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
5
diff
changeset
|
173 }//GEN-LAST:event_cancelButtonActionPerformed |
5
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
174 |
6
670905eb688a
Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
5
diff
changeset
|
175 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
|
176 cancelled = false; |
670905eb688a
Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
5
diff
changeset
|
177 int row = databasesTable.getSelectedRow(); |
670905eb688a
Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
5
diff
changeset
|
178 DefaultTableModel model = (DefaultTableModel) databasesTable.getModel(); |
670905eb688a
Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
5
diff
changeset
|
179 hostname = (String) model.getValueAt(row, 0); |
670905eb688a
Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
5
diff
changeset
|
180 database = (String) model.getValueAt(row, 1); |
670905eb688a
Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
5
diff
changeset
|
181 username = (String) model.getValueAt(row, 2); |
670905eb688a
Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
5
diff
changeset
|
182 doClose(); |
670905eb688a
Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
5
diff
changeset
|
183 }//GEN-LAST:event_selectButtonActionPerformed |
5
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
184 |
6
670905eb688a
Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
5
diff
changeset
|
185 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
|
186 DatabaseDialog dialog = new DatabaseDialog(); |
670905eb688a
Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
5
diff
changeset
|
187 dialog.setVisible(true); |
670905eb688a
Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
5
diff
changeset
|
188 if (!dialog.cancelled) { |
670905eb688a
Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
5
diff
changeset
|
189 cancelled = false; |
670905eb688a
Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
5
diff
changeset
|
190 hostname = dialog.hostname; |
670905eb688a
Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
5
diff
changeset
|
191 database = dialog.database; |
670905eb688a
Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
5
diff
changeset
|
192 username = new String(""); |
670905eb688a
Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
5
diff
changeset
|
193 doClose(); |
670905eb688a
Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
5
diff
changeset
|
194 } |
670905eb688a
Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
5
diff
changeset
|
195 }//GEN-LAST:event_newButtonActionPerformed |
5
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
196 |
7
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
197 private void formKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_formKeyPressed |
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
198 System.out.printf("key %d is %d\n", evt.getKeyCode(), evt.VK_DOWN); |
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
199 if (evt.getKeyCode() == evt.VK_DOWN) { |
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
200 int row = databasesTable.getSelectedRow() + 1; |
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
201 databasesTable.addRowSelectionInterval(row, row); |
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
202 return; |
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
203 } |
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
204 if (evt.getKeyCode() == evt.VK_UP) { |
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
205 int row = databasesTable.getSelectedRow() - 1; |
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
206 databasesTable.addRowSelectionInterval(row, row); |
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
207 return; |
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
208 } |
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
209 }//GEN-LAST:event_formKeyPressed |
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
210 |
6
670905eb688a
Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
5
diff
changeset
|
211 private void doClose() { |
5
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
212 setVisible(false); |
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
213 dispose(); |
6
670905eb688a
Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
5
diff
changeset
|
214 } |
5
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
215 |
6
670905eb688a
Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
5
diff
changeset
|
216 public void add(String hostname, String database, String username) { |
670905eb688a
Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
5
diff
changeset
|
217 DefaultTableModel model = (DefaultTableModel) databasesTable.getModel(); |
670905eb688a
Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
5
diff
changeset
|
218 model.insertRow(model.getRowCount(), new Object[]{hostname, database, username}); |
7
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
219 databasesTable.addRowSelectionInterval(0, 0); |
6
670905eb688a
Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
5
diff
changeset
|
220 } |
670905eb688a
Fix code indentation.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
5
diff
changeset
|
221 |
5
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
222 // Variables declaration - do not modify//GEN-BEGIN:variables |
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
223 private javax.swing.JButton cancelButton; |
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
224 private javax.swing.JTable databasesTable; |
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
225 private javax.swing.JButton newButton; |
7
ea3ae6ce9fea
Improved Java interface look.
Daniele Nicolodi <daniele@grinta.net>
parents:
6
diff
changeset
|
226 private javax.swing.JScrollPane scrollPane; |
5
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
227 private javax.swing.JButton selectButton; |
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
228 // End of variables declaration//GEN-END:variables |
35f1cfcaa5a9
Add crude Java GUI.
Daniele Nicolodi <daniele@science.unitn.it>
parents:
diff
changeset
|
229 } |