package org.pasif.gui;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JInternalFrame;
import org.jdesktop.application.Action;
import org.jdesktop.application.Application;
import org.jdesktop.application.ResourceMap;
public class BaseConfigurationFrame extends javax.swing.JInternalFrame {
private Boolean save = false;
public BaseConfigurationFrame() {
initComponents();
ResourceMap resourceMap = Application.getInstance(Client.class).getContext().getResourceMap(BaseConfigurationFrame.class);
dbType.setModel(new DefaultComboBoxModel(resourceMap.getString("db.support").split(",")));
Properties p = new Properties();
try {
p.load(new FileInputStream("configuration.properties"));
} catch (IOException ex) {
ex.printStackTrace();
}
System.out.println(p.getProperty("db.ip"));
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
mainPanel = new javax.swing.JPanel();
jPanel1 = new javax.swing.JPanel();
jLabel16 = new javax.swing.JLabel();
dbUrl = new javax.swing.JTextField();
jLabel20 = new javax.swing.JLabel();
dbUserName = new javax.swing.JTextField();
jLabel21 = new javax.swing.JLabel();
dbPassword = new javax.swing.JPasswordField();
jLabel22 = new javax.swing.JLabel();
dbType = new javax.swing.JComboBox();
jLabel12 = new javax.swing.JLabel();
dbName = new javax.swing.JTextField();
jLabel17 = new javax.swing.JLabel();
dbName1 = new javax.swing.JTextField();
jPanel5 = new javax.swing.JPanel();
jLabel14 = new javax.swing.JLabel();
host = new javax.swing.JTextField();
jLabel15 = new javax.swing.JLabel();
port = new javax.swing.JTextField();
jLabel13 = new javax.swing.JLabel();
exportPath = new javax.swing.JTextField();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
setClosable(true);
setIconifiable(true);
setMaximizable(true);
setResizable(true);
org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(org.pasif.gui.Client.class).getContext().getResourceMap(BaseConfigurationFrame.class);
setTitle(resourceMap.getString("Form.title")); // NOI18N
setAutoscrolls(true);
setName("Form"); // NOI18N
addPropertyChangeListener(new java.beans.PropertyChangeListener() {
public void propertyChange(java.beans.PropertyChangeEvent evt) {
formPropertyChange(evt);
}
});
mainPanel.setMaximumSize(new java.awt.Dimension(32764, 32764));
mainPanel.setMinimumSize(new java.awt.Dimension(640, 480));
mainPanel.setName("mainPanel"); // NOI18N
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jPanel1.border.title"))); // NOI18N
jPanel1.setName("jPanel1"); // NOI18N
jLabel16.setText(resourceMap.getString("jLabel16.text")); // NOI18N
jLabel16.setName("jLabel16"); // NOI18N
dbUrl.setText(resourceMap.getString("dbUrl.text")); // NOI18N
dbUrl.setName("dbUrl"); // NOI18N
dbUrl.setPreferredSize(new java.awt.Dimension(75, 20));
dbUrl.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
edited(evt);
}
});
jLabel20.setText(resourceMap.getString("jLabel20.text")); // NOI18N
jLabel20.setName("jLabel20"); // NOI18N
dbUserName.setText(resourceMap.getString("dbUserName.text")); // NOI18N
dbUserName.setName("dbUserName"); // NOI18N
dbUserName.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
edited(evt);
}
});
jLabel21.setText(resourceMap.getString("jLabel21.text")); // NOI18N
jLabel21.setName("jLabel21"); // NOI18N
dbPassword.setText(resourceMap.getString("dbPassword.text")); // NOI18N
dbPassword.setName("dbPassword"); // NOI18N
dbPassword.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
edited(evt);
}
});
jLabel22.setText(resourceMap.getString("jLabel22.text")); // NOI18N
jLabel22.setName("jLabel22"); // NOI18N
dbType.setModel(new DefaultComboBoxModel(new String[]{}));
dbType.setName("dbType"); // NOI18N
dbType.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
dbTypeActionPerformed(evt);
}
});
jLabel12.setText(resourceMap.getString("jLabel12.text")); // NOI18N
jLabel12.setName("jLabel12"); // NOI18N
dbName.setText(resourceMap.getString("dbName.text")); // NOI18N
dbName.setName("dbName"); // NOI18N
dbName.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
edited(evt);
}
});
jLabel17.setText(resourceMap.getString("jLabel17.text")); // NOI18N
jLabel17.setName("jLabel17"); // NOI18N
dbName1.setText(resourceMap.getString("dbName1.text")); // NOI18N
dbName1.setName("dbName1"); // NOI18N
dbName1.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
edited(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel17)
.addComponent(jLabel22)
.addComponent(jLabel20))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(dbType, 0, 161, Short.MAX_VALUE)
.addComponent(dbName1, javax.swing.GroupLayout.DEFAULT_SIZE, 161, Short.MAX_VALUE)
.addComponent(dbUserName, javax.swing.GroupLayout.DEFAULT_SIZE, 161, Short.MAX_VALUE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel16)
.addComponent(jLabel12)
.addComponent(jLabel21))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(dbUrl, javax.swing.GroupLayout.DEFAULT_SIZE, 152, Short.MAX_VALUE)
.addComponent(dbPassword, javax.swing.GroupLayout.DEFAULT_SIZE, 152, Short.MAX_VALUE)
.addComponent(dbName, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 152, Short.MAX_VALUE))
.addContainerGap())
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel22)
.addComponent(dbType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel17)
.addComponent(dbName1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel12)
.addComponent(dbName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(8, 8, 8)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel20)
.addComponent(dbUserName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel21)
.addComponent(dbPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addComponent(jLabel16)
.addComponent(dbUrl, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
);
jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jPanel5.border.title"))); // NOI18N
jPanel5.setName("jPanel5"); // NOI18N
jLabel14.setText(resourceMap.getString("jLabel14.text")); // NOI18N
jLabel14.setName("jLabel14"); // NOI18N
host.setText(resourceMap.getString("host.text")); // NOI18N
host.setName("host"); // NOI18N
host.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
edited(evt);
}
});
jLabel15.setText(resourceMap.getString("jLabel15.text")); // NOI18N
jLabel15.setName("jLabel15"); // NOI18N
port.setText(resourceMap.getString("port.text")); // NOI18N
port.setName("port"); // NOI18N
port.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
edited(evt);
}
});
jLabel13.setText(resourceMap.getString("jLabel13.text")); // NOI18N
jLabel13.setName("jLabel13"); // NOI18N
exportPath.setText(resourceMap.getString("exportPath.text")); // NOI18N
exportPath.setName("exportPath"); // NOI18N
exportPath.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
edited(evt);
}
});
javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
jPanel5.setLayout(jPanel5Layout);
jPanel5Layout.setHorizontalGroup(
jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel5Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel5Layout.createSequentialGroup()
.addComponent(jLabel14)
.addGap(18, 18, 18)
.addComponent(host, javax.swing.GroupLayout.PREFERRED_SIZE, 149, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jLabel15)
.addGap(18, 18, 18)
.addComponent(port, javax.swing.GroupLayout.DEFAULT_SIZE, 162, Short.MAX_VALUE))
.addGroup(jPanel5Layout.createSequentialGroup()
.addComponent(jLabel13)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(exportPath, javax.swing.GroupLayout.DEFAULT_SIZE, 373, Short.MAX_VALUE)))
.addContainerGap())
);
jPanel5Layout.setVerticalGroup(
jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel5Layout.createSequentialGroup()
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel14)
.addComponent(host, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel15)
.addComponent(port, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel13)
.addComponent(exportPath, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jButton2.setText(resourceMap.getString("jButton2.text")); // NOI18N
jButton2.setName("jButton2"); // NOI18N
javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(org.pasif.gui.Client.class).getContext().getActionMap(BaseConfigurationFrame.class, this);
jButton3.setAction(actionMap.get("exit")); // NOI18N
jButton3.setText(resourceMap.getString("jButton3.text")); // NOI18N
jButton3.setName("jButton3"); // NOI18N
javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
mainPanel.setLayout(mainPanelLayout);
mainPanelLayout.setHorizontalGroup(
mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(mainPanelLayout.createSequentialGroup()
.addContainerGap()
.addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mainPanelLayout.createSequentialGroup()
.addComponent(jButton2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton3))
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);
mainPanelLayout.setVerticalGroup(
mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(mainPanelLayout.createSequentialGroup()
.addGap(10, 10, 10)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton3)
.addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(mainPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 549, Short.MAX_VALUE)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(mainPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 264, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
getAccessibleContext().setAccessibleName(resourceMap.getString("Form.AccessibleContext.accessibleName")); // NOI18N
getAccessibleContext().setAccessibleDescription(resourceMap.getString("Form.AccessibleContext.accessibleDescription")); // NOI18N
pack();
}// </editor-fold>//GEN-END:initComponents
private void formPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_formPropertyChange
if (evt.getPropertyName().equals("icon") && evt.getOldValue().equals(Boolean.FALSE) && evt.getNewValue().equals(Boolean.TRUE)) {
JInternalFrame j = (JInternalFrame) evt.getSource();
j.setVisible(true);
j.moveToFront();
}
}//GEN-LAST:event_formPropertyChange
private void edited(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_edited
this.save = true;
}//GEN-LAST:event_edited
private void dbTypeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dbTypeActionPerformed
this.save = true;
}//GEN-LAST:event_dbTypeActionPerformed
@Action
public void exit() {
dispose();
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JTextField dbName;
private javax.swing.JTextField dbName1;
private javax.swing.JPasswordField dbPassword;
private javax.swing.JComboBox dbType;
private javax.swing.JTextField dbUrl;
private javax.swing.JTextField dbUserName;
private javax.swing.JTextField exportPath;
private javax.swing.JTextField host;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel14;
private javax.swing.JLabel jLabel15;
private javax.swing.JLabel jLabel16;
private javax.swing.JLabel jLabel17;
private javax.swing.JLabel jLabel20;
private javax.swing.JLabel jLabel21;
private javax.swing.JLabel jLabel22;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel5;
private javax.swing.JPanel mainPanel;
private javax.swing.JTextField port;
// End of variables declaration//GEN-END:variables
}