The Backyard - EntityVisualPanel1 Diff
- Added parts are displayed like this.
- Deleted parts are displayed
like this.
package com.example.tableentity;
import java.util.Vector;
import javax.swing.JPanel;
import org.netbeans.api.db.explorer.ConnectionListener;
import org.netbeans.api.db.explorer.ConnectionManager;
import org.netbeans.api.db.explorer.DatabaseConnection;
public final class EntityVisualPanel1 extends JPanel implements ConnectionListener {
EntityWizardPanel1 wizard;
/** Creates new form EntityVisualPanel1 */
public EntityVisualPanel1(EntityWizardPanel1 initWizard) {
wizard = initWizard;
ConnectionManager.getDefault().addConnectionListener(this);
initComponents();
setupList();
}
void setupList() {
Vector v = new Vector();
DatabaseConnection[] dc = ConnectionManager.getDefault().getConnections();
for (int i = 0; i < dc.length; i++) {
v.add(dc[i].getName());
}
connectionList.setListData(v);
}
public void connectionsChanged() {
setupList();
}
DatabaseConnection selectedConnection() {
DatabaseConnection[] dc = ConnectionManager.getDefault().getConnections();
for (int i = 0; i < dc.length; i++) {
if (dc[i].getName().equals(connectionList.getSelectedValue())) {
return dc[i];
}
}
return null;
}
public String getName() {
return "Step #1";
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
addConnectionButton = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
connectionList = new javax.swing.JList();
setLayout(null);
jLabel1.setText("\u63a5\u7d9a\u5148\u3092\u9078\u629e");
add(jLabel1);
jLabel1.setBounds(40, 40, 110, 13);
addConnectionButton.setText("\u63a5\u7d9a\u5148\u3092\u8ffd\u52a0");
addConnectionButton.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
addConnectionButtonMouseClicked(evt);
}
});
add(addConnectionButton);
addConnectionButton.setBounds(220, 40, 120, 21);
connectionList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
connectionList.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
connectionListValueChanged(evt);
}
});
jScrollPane1.setViewportView(connectionList);
add(jScrollPane1);
jScrollPane1.setBounds(40, 70, 300, 130);
}// </editor-fold>
private void connectionListValueChanged(javax.swing.event.ListSelectionEvent evt) {
wizard.fireChangeEvent();
}
private void addConnectionButtonMouseClicked(java.awt.event.MouseEvent evt) {
ConnectionManager.getDefault().showAddConnectionDialog(null);
}
// Variables declaration - do not modify
private javax.swing.JButton addConnectionButton;
private javax.swing.JList connectionList;
private javax.swing.JLabel jLabel1;
private javax.swing.JScrollPane jScrollPane1;
// End of variables declaration
}
import java.util.Vector;
import javax.swing.JPanel;
import org.netbeans.api.db.explorer.ConnectionListener;
import org.netbeans.api.db.explorer.ConnectionManager;
import org.netbeans.api.db.explorer.DatabaseConnection;
public final class EntityVisualPanel1 extends JPanel implements ConnectionListener {
EntityWizardPanel1 wizard;
/** Creates new form EntityVisualPanel1 */
public EntityVisualPanel1(EntityWizardPanel1 initWizard) {
wizard = initWizard;
ConnectionManager.getDefault().addConnectionListener(this);
initComponents();
setupList();
}
void setupList() {
Vector v = new Vector();
DatabaseConnection[] dc = ConnectionManager.getDefault().getConnections();
for (int i = 0; i < dc.length; i++) {
v.add(dc[i].getName());
}
connectionList.setListData(v);
}
public void connectionsChanged() {
setupList();
}
DatabaseConnection selectedConnection() {
DatabaseConnection[] dc = ConnectionManager.getDefault().getConnections();
for (int i = 0; i < dc.length; i++) {
if (dc[i].getName().equals(connectionList.getSelectedValue())) {
return dc[i];
}
}
return null;
}
public String getName() {
return "Step #1";
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
addConnectionButton = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
connectionList = new javax.swing.JList();
setLayout(null);
jLabel1.setText("\u63a5\u7d9a\u5148\u3092\u9078\u629e");
add(jLabel1);
jLabel1.setBounds(40, 40, 110, 13);
addConnectionButton.setText("\u63a5\u7d9a\u5148\u3092\u8ffd\u52a0");
addConnectionButton.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
addConnectionButtonMouseClicked(evt);
}
});
add(addConnectionButton);
addConnectionButton.setBounds(220, 40, 120, 21);
connectionList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
connectionList.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
connectionListValueChanged(evt);
}
});
jScrollPane1.setViewportView(connectionList);
add(jScrollPane1);
jScrollPane1.setBounds(40, 70, 300, 130);
}// </editor-fold>
private void connectionListValueChanged(javax.swing.event.ListSelectionEvent evt) {
wizard.fireChangeEvent();
}
private void addConnectionButtonMouseClicked(java.awt.event.MouseEvent evt) {
ConnectionManager.getDefault().showAddConnectionDialog(null);
}
// Variables declaration - do not modify
private javax.swing.JButton addConnectionButton;
private javax.swing.JList connectionList;
private javax.swing.JLabel jLabel1;
private javax.swing.JScrollPane jScrollPane1;
// End of variables declaration
}