/*���ܼ�飄1�7
*�����һ������ʱ�����Ľ��棬�ᅣ1�7���û����ü�ͥ�ͽ�b�����û���
*/
package realcix20.guis.views;
import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.util.Iterator;
import java.util.StringTokenizer;
import java.util.Vector;
import javax.crypto.Cipher;
import javax.crypto.SealedObject;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.KeyStroke;
import javax.swing.table.DefaultTableModel;
import realcix20.classes.FamilyClass;
import realcix20.classes.LedgerClass;
import realcix20.classes.UserClass;
import realcix20.classes.basic.Cell;
import realcix20.classes.basic.ClassManager;
import realcix20.classes.basic.Column;
import realcix20.classes.basic.Row;
import realcix20.guis.components.DetailList;
import realcix20.guis.relationships.RelationManager;
import realcix20.guis.utils.ComponentExt;
import realcix20.guis.utils.ComponentManager;
import realcix20.guis.utils.DialogManager;
import realcix20.guis.utils.ImageManager;
import realcix20.guis.utils.MnemonicGenerator;
import realcix20.guis.utils.TimeManager;
import realcix20.guis.utils.TxtManager;
import realcix20.utils.DAO;
import realcix20.utils.GlobalValueManager;
import realcix20.utils.ObjectUtil;
import realcix20.utils.Resources;
import com.jgoodies.forms.factories.DefaultComponentFactory;
import com.jgoodies.forms.factories.FormFactory;
import com.jgoodies.forms.layout.CellConstraints;
import com.jgoodies.forms.layout.ColumnSpec;
import com.jgoodies.forms.layout.FormLayout;
import com.jgoodies.forms.layout.RowSpec;
public class FirstTimeView extends JFrame implements ActionListener, WindowListener {
private FamilyClass family;
private Vector headComponentExts;
private Vector headAlertLabels;
private Vector itemComponentExts;
private Vector componentExts;
private Row currentRow;
private String action;
private RelationManager relationManager;
public FirstTimeView() {
family = (FamilyClass)ClassManager.createClass(110);
currentRow = new Row(family.getRowType());
action = "ADD";
addWindowListener(this);
initialHeadAndItemComponentExts();
createRelation();
setAllComponentValue();
initMenuBar();
initComponents();
}
private void initComponents() {
CellConstraints cc = new CellConstraints();
int currentLocation = 0;
Container contentPane = getContentPane();
contentPane.setLayout(new GridBagLayout());
((GridBagLayout)contentPane.getLayout()).columnWidths = new int[] {0, 0};
((GridBagLayout)contentPane.getLayout()).rowHeights = new int[] {0, 0, 0, 0, 0, 0};
((GridBagLayout)contentPane.getLayout()).columnWeights = new double[] {1.0, 1.0E-4};
((GridBagLayout)contentPane.getLayout()).rowWeights = new double[] {0.0, 0.0, 0.0, 1.0, 0.0, 1.0E-4};
DefaultComponentFactory compFactory = DefaultComponentFactory.getInstance();
JComponent titleText = compFactory.createSeparator(TxtManager.getTxt("VIEW.OBJECTEDIT.PROPERTIESTITLE"));
contentPane.add(titleText, new GridBagConstraints(0, currentLocation, 1, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
new Insets(10, 10, 15, 10), 0, 0));
currentLocation++;
JTabbedPane propertyPane = new JTabbedPane();
propertyPane.setPreferredSize(new Dimension(600, 300));
Iterator headComponentExtIter = headComponentExts.iterator();
headAlertLabels = new Vector();
Iterator headGroupNameIter = family.getHeadGroupnames().iterator();
while (headGroupNameIter.hasNext()) {
int groupName = ((Integer)headGroupNameIter.next()).intValue();
JPanel groupPanel = new JPanel();
JScrollPane groupScrollPane = new JScrollPane();
groupScrollPane.setViewportView(groupPanel);
ColumnSpec[] columnSpec = new ColumnSpec[] {
new ColumnSpec("10px"),
FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
new ColumnSpec("150px"),
FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
new ColumnSpec("150px"),
FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
new ColumnSpec("150px")
};
int rowCount = family.getGroupHeadFieldCount(groupName);
RowSpec[] rowSpec = new RowSpec[rowCount * 2 + 1];
rowSpec[0] = new RowSpec("10px");
rowSpec[1] = FormFactory.LINE_GAP_ROWSPEC;
for (int i = 1; i <= rowCount - 1; i++) {
rowSpec[i * 2] = new RowSpec("20px");
rowSpec[i * 2 + 1] = FormFactory.LINE_GAP_ROWSPEC;
}
rowSpec[rowCount * 2] = new RowSpec("20px");
groupPanel.setLayout(new FormLayout(columnSpec, rowSpec));
int currentComponentNumber = 1;
Iterator columnIter = family.getColumns().iterator();
while (columnIter.hasNext()) {
Column column = (Column)columnIter.next();
if ( (column.isHeadField()) && (column.getGroupName() == groupName) ) {
JLabel label = new JLabel(column.toString());
groupPanel.add(label, cc.xy(3, currentComponentNumber * 2 + 1));
ComponentExt componentExt = (ComponentExt)headComponentExtIter.next();
JComponent component = componentExt.getComponent();
groupPanel.add(component, cc.xy(5, currentComponentNumber * 2 + 1));
JLabel alertLabel = new JLabel();
componentExt.setAlertLabel(alertLabel);
alertLabel.setForeground(Color.RED);
if (column.isPrimaryKey()) {
alertLabel.setIcon(ImageManager.getImage(ImageManager.HELP_IMAGE));
} else {
alertLabel.setVisible(false);
}
groupPanel.add(alertLabel, cc.xy(7, currentComponentNumber * 2 + 1));
headAlertLabels.add(alertLabel);
currentComponentNumber++;
}
}
String groupNameString = "GRP." + new Integer(groupName).toString();
propertyPane.addTab(TxtManager.getTxt(groupNameString), groupScrollPane);
contentPane.add(propertyPane, new GridBagConstraints(0, currentLocation, 1, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(10, 10, 10, 10), 0, 0));
currentLocation++;
}
JPanel controlPanel = new JPanel();
controlPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
JButton confirmButton = new JButton();
confirmButton.setText(MnemonicGenerator.generateMnemonicString(TxtManager.getTxt("VIEW.GLOBAL.CONFIRMBUTTON"), KeyEvent.VK_O));
confirmButton.setMnemonic(KeyEvent.VK_O);
confirmButton.setIcon(ImageManager.getImage(ImageManager.CONFIRM_IMAGE));
confirmButton.setPreferredSize(new Dimension(75, 20));
confirmButton.setActionCommand("Confirm");
confirmButton.addActionListener(this);
controlPanel.add(confirmButton);
JButton cancelButton = new JButton();
cancelButton.setText(MnemonicGenerator.generateMnemonicString(TxtManager.getTxt("VIEW.GLOBAL.CANCELBUTTON"), KeyEvent.VK_C));
cancelButton.setMnemonic(KeyEvent.VK_C);
cancelButton.setIcon(ImageManager.getImage(ImageManager.CANCEL_IMAGE));
cancelButton.setPreferredSize(new Dimension(75, 20));
cancelButton.setActionCommand("Exit");
cancelButton.addActionListener(this);
controlPanel.add(cancelButton);
contentPane.add(controlPanel, new GridBagConstraints(0, currentLocation, 1, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(0, 0, 0, 5), 0, 0));
currentLocation++;
pack();
setResizable(false);
setVisible(true);
setLocationRelativeTo(null);
setTitle(TxtManager.getTxt("VIEW.APPLICATION.TITLE"));
setIconImage(ImageManager.getImage(ImageManager.REALCIX_APP_IAMGE).getImage());
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
}
private void initMenuBar() {
JMenuBar menuBar = new JMenuBar();
menuBar.setVisible(true);
JMenu notVisibleMenu = new JMenu();
notVisibleMenu.setVisible(false);
menuBar.add(notVisibleMenu);
JMenuItem menuItem = new JMenuItem();
menuItem.setAccelerator(KeyStroke.getKeyStroke("ESCAPE"));
menuItem.setActionCommand("Exit");
menuItem.addActionListener(this);
menuItem.setVisible(false);
notVisibleMenu.add(menuItem);
menuItem = new JMenuItem();
menuItem.setAccelerator(KeyStroke.getKeyStroke("ENTER"));
menuItem.setActionCommand("Confirm");
menuItem.addActionListener(this);
menuItem.setVisible(false);
notVisibleMenu.add(menuItem);
setJMenuBar(menuBar);
}
private void initialHeadAndItemComponentExts() {
headComponentExts = new Vector();
itemComponentExts = new Vector();
Iterator columnIter = family.getColumns().iterator();
while (columnIter.hasNext()) {
Column column = (Column)columnIter.next();
if (column.isHeadField()) {
ComponentExt componentExt = new ComponentExt(ComponentManager.getComponent(column), column, currentRow);
headComponentExts.add(componentExt);
}
else if (column.isItemField()) {
ComponentExt componentExt = new ComponentExt(ComponentManager.getComponent(column), column, currentRow);
itemComponentExts.add(componentExt);
}
}
}
private void createRelation() {
componentExts = (Vector)headComponentExts.clone();
componentExts.addAll(itemComponentExts);
relationManager = RelationManager.getInstance(componentExts);
}
private void setAllComponentValue() {
Iterator componentExtIter = componentExts.iterator();
while (componentExtIter.hasNext()) {
ComponentExt componentExt = (ComponentExt)componentExtIter.next();
Column column = componentExt.getColumn();
Row row = componentExt.getRow();
JComponent component = componentExt.getComponent();
if (action.equals("Add")) {
Vector parameters = relationManager.getParameters_Defvalue(componentExt);
if (parameters != null) {
String sql = relationManager.getSQL_Defvalue(componentExt, parameters);
DAO dao = DAO.getInstance();
dao.query(sql);
for (int i = 0; i < parameters.size(); i++) {
String parameter = (String)parameters.get(i);
StringTokenizer st = new StringTokenizer(parameter, ".");
String tableName = (String)st.nextElement();
String columnName = (String)st.nextElement();
ComponentExt tempComponentExt = relationManager.findComponentExt(tableName, columnName);
JComponent tempComponent = tempComponentExt.getComponent();
dao.setObject(i+1, ComponentManager.getValue(tempComponent));
}
ResultSet rs = dao.executeQuery();
try {
if (rs.next()) {
ResultSetMetaData rsmd = rs.getMetaData();
for (int i = 1; i <= rsmd.getColumnCount(); i++) {
ComponentExt tempComponentExt = relationManager.findComponentExt(column.getTableName(), rsmd.getColumnName(i));
boolean isThisObjectColumn = (tempComponentExt != null);
if (isThisObjectColumn) {
if (rs.getObject(i) != null) {
ComponentManager.setValue(rs.getObject(i), tempComponentExt.getComponent());
}
}
}
}
rs.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
}
private void exitApplication() {
int n = DialogManager.showYesNoDialog(this, TxtManager.getTxt("alert.exit"));
if (n == 0) {
DAO dao = DAO.getInstance();
dao.commit();
dao.deleteDAO();
System.exit(0);
}
}
private boolean validateForm() {
boolean result = true;
//first, validate the mandatory form components
Iterator componentExtIter = headComponentExts.iterator();
Iterator alertLabelIter = headAlertLabels.iterator();
while (componentExtIter.hasNext()) {
ComponentExt componentExt = (ComponentExt)componentExtIter.next();
JLabel alertLabel = (JLabel)alertLabelIter.next();
JComponent component = componentExt.getComponent();
Column column = componentExt.getColumn();
if (column.isMandatory()) {
if ( (ComponentManager.getValue(component) == null) || (ComponentManager.getValue(component).equals("")) ) {
alertLabel.setVisible(true);
alertLabel.setIcon(ImageManager.getImage(ImageManager.EXCLAMATION_IMAGE));
if (column.isPrimaryKey()) {
alertLabel.setText(TxtManager.getTxt("VALIDATE.PRIMARYKEYISMUST"));
} else {
alertLabel.setText(TxtManager.getTxt("VALIDATE.NULLVALUE"));
}
result = false;
} else {
if (column.isPrimaryKey()) {
alertLabel.setIcon(ImageManager.getImage(ImageManager.HELP_IMAGE));
alertLabel.setText("");
} else {
alertLabel.setVisible(false);
}
}
}
}
//second,validate insert or edit execute
if (result) {
setHeadCellValue(currentRow);
if (action.equals("Add"))
result = family.classInsert_WholeObject(currentRow, true);
componentExtIter = headComponentExts.iterator();
alertLabelIter = headAlertLabels.iterator();
while (componentExtIter.hasNext()) {
ComponentExt componentExt = (ComponentExt)componentExtIter.next();
JLabel alertLabel = (JLabel)alertLabelIter.next();
Column column = componentExt.getColumn();
if (column.isPrimaryKey()) {
if (!result) {
alertLabel.setIcon(ImageManager.getImage(ImageManager.EXCLAMATION_IMAGE));
alertLabel.setText(TxtManager.getTxt("VALIDATE.PRIMARYKEYCONFLICT"));
} else {
alertLabel.setIcon(ImageManager.getImage(ImageManager.HELP_IMAGE));
alertLabel.setText("");
}
}
}
}
//third, validate 81 components
if (result) {
result = validate81Components();
}
if (!result)
DialogManager.showMessageDialog(this, TxtManager.getTxt("VALIDATE.FAIL"));
return result;
}
private boolean validate81Components() {
boolean result = true;
Iterator componentExtIter = headComponentExts.iterator();
Iterator alertLabelIter = headAlertLabels.iterator();
while (componentExtIter.hasNext()) {
ComponentExt componentExt = (ComponentExt)componentExtIter.next();
JLabel alertLabel = (JLabel)alertLabelIter.next();
JComponent component = componentExt.getComponent();
Column column = componentExt.getColumn();
if (column.getInputType() == 81) {
boolean cellResult = true;
DetailList detailList = (DetailList)component;
Object value = detailList.getValue();
detailList.getNotVisibleTableButton().doClick();
Vector columns = detailList.getColumns();
DefaultTableModel model = (DefaultTableModel)detailList.getTable().getModel();
Vector dataVector = model.getDataVector();
Iterator dataVectorsIter = dataVector.iterator();
while (dataVectorsIter.hasNext()) {
Vector rowDatas = (Vector)dataVectorsIter.next();
Object rowValue = rowDatas.get(rowDatas.size() - 1);
if (value == null)
value = "";
if (rowValue == null)
rowValue = "";
if (value.equals(rowValue)) {
if (column.getCControls() == null) {
cellResult = true;
break;
} else {
StringTokenizer st = new StringTokenizer(column.getCControls(), "!!");
boolean childResult = true;
while (st.hasMoreElements()) {
StringTokenizer stt = new StringTokenizer((String)st.nextElement(), ".");
String tableName = (String)stt.nextElement();
String columnName = (String)stt.nextElement();
Object newValue = ObjectUtil.findNewCell(currentRow, tableName, columnName).getColumnValue();
boolean find = false;
for (int i = 0; i < rowDatas.size() - 1; i++) {
String columnString = (String)columns.get(i);
StringTokenizer sttt = new StringTokenizer(columnString, "-");
String tempTableName = (String)sttt.nextElement();
String tempColumnName = (String)sttt.nextElement();
Object tempValue = rowDatas.get(i);
if ( (tableName.equals(tempTableName)) && (columnName.equals(tempColumnName)) ) {
find = true;
// Object tempValue = rowDatas.get(i);
if (!newValue.equals(tempValue)) {
childResult = false;
}
}
if (find) {
break;
}
}
if (!childResult) {
break;
}
}
if (childResult) {
cellResult = true;
break;
}
// System.err.println("CellResult = " + cellResult);
if (cellResult)
break;
}
} else {
cellResult = false;
}
}
if (!cellResult) {
result = false;
alertLabel.setVisible(true);
alertLabel.setIcon(ImageManager.getImage(ImageManager.EXCLAMATION_IMAGE));
alertLabel.setText(TxtManager.getTxt("VALIDATE.VALUEISNOTALLOWED"));
} else {
alertLabel.setVisible(false);
}
}
}
return result;
}
private void setHeadCellValue(Row row) {
Iterator componentExtIter = headComponentExts.iterator();
while (componentExtIter.hasNext()) {
ComponentExt componentExt = (ComponentExt)componentExtIter.next();
Column column = componentExt.getColumn();
JComponent component = componentExt.getComponent();
// System.err.println(ComponentManager.getValue(component));
Cell cell = ObjectUtil.findNewCell(row, column.getTableName(), column.getColumnName());
if (action.equals("ADD")) {
if ( (column.getInputType() == 22) || (column.getInputType() == 24) ) {//created by
cell.setColumnValue(GlobalValueManager.getValue("SESSION.LOGINUSER"));
} else if ( (column.getInputType() == 21) || (column.getInputType() == 23) ) {//created
java.util.Date date = new java.util.Date();
String now = TimeManager.getTime(date.getTime());
cell.setColumnValue(now);
} else {
cell.setColumnValue(ComponentManager.getValue(component));
}
}
}
}
private void setApplicationValues() {
if (validateForm()) {
SealedObject password = showSuperPasswordDialog();
StringBuffer sb = new StringBuffer(TxtManager.getTxt("INFORMATION.CREATEFAMILY1"));
sb.append(ObjectUtil.findNewCell(currentRow, "FAMILY", "FAMILY").getColumnValue().toString() + " " +
TxtManager.getTxt("INFORMATION.CREATEFAMILY2"));
DialogManager.showMessageDialog(this, sb.toString());
String lang = ObjectUtil.findNewCell(currentRow, "FAMILY", "LANG").getColumnValue().toString();
Row superUserRow = UserClass.createSuperUser(currentRow, password, lang);
UserClass.createMePartner(superUserRow);
LedgerClass.updateAllLDsRUSER((String)ObjectUtil.findNewCell(currentRow, "FAMILY", "FAMILY").getColumnValue());
sb = new StringBuffer(TxtManager.getTxt("INFORMATION.CREATESUPERUSER1"));
sb.append(ObjectUtil.findNewCell(currentRow, "FAMILY", "FAMILY").getColumnValue().toString() + " " +
TxtManager.getTxt("INFORMATION.CREATESUPERUSER2"));
family.classInsert_WholeObject(currentRow, false);
GlobalValueManager.setValue("firsttime", "FALSE");
GlobalValueManager.setApplicationLang(lang);
String firstTime = String.valueOf(System.currentTimeMillis());
GlobalValueManager.setValue("firsttimedate", firstTime);
Resources.LANGUAGE = GlobalValueManager.getApplicationLang();
//set LC to LC XR
DAO dao = DAO.getInstance();
dao.update(Resources.INSERT_XR_SQL);
dao.setObject(1, ObjectUtil.findNewCell(currentRow, "FAMILY", "LC").getColumnValue());
dao.setObject(2, ObjectUtil.findNewCell(currentRow, "FAMILY", "LC").getColumnValue());
dao.setObject(3, 1);
StringBuffer bb = new StringBuffer("1970-01-01 01:01:01");
dao.setObject(4, bb.toString());
dao.setObject(5, 1.0);
dao.setObject(6, 1.0);
dao.setObject(7, 1.0);
dao.setObject(8, bb.toString());
dao.setObject(9, ObjectUtil.findNewCell(currentRow, "FAMILY", "FAMILY").getColumnValue());
dao.setObject(10, bb.toString());
dao.setObject(11, ObjectUtil.findNewCell(currentRow, "FAMILY", "FAMILY").getColumnValue());
dao.executeUpdate();
DialogManager.showMessageDialog(this, sb.toString());
DialogManager.showMessageDialog(this, TxtManager.getTxt("INFORMATION.PLEASELOGIN"));
dispose();
new LoginFrame();
}
}
private SealedObject showSuperPasswordDialog() {
SealedObject password = null;
JPanel panel = new JPanel();
CellConstraints cc = new CellConstraints();
panel.setLayout(new FormLayout(
new ColumnSpec[] {
new ColumnSpec("10px"),
FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
new ColumnSpec("150px"),
FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
new ColumnSpec("100px"),
FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
new ColumnSpec("150px")
},
new RowSpec[] {
new RowSpec("10px"),
FormFactory.LINE_GAP_ROWSPEC,
new RowSpec("20px"),
FormFactory.LINE_GAP_ROWSPEC,
new RowSpec("20px"),
}));
JLabel superUserPasswordLabel1 = new JLabel();
superUserPasswordLabel1.setText(TxtManager.getTxt("VIEW.PASSWORDEDIT.SUPERUSERPASSWORDLABEL"));
panel.add(superUserPasswordLabel1, cc.xy(3, 3));
JPasswordField superUserPasswordField1 = new JPasswordField();
panel.add(superUserPasswordField1, cc.xy(5, 3));
JLabel alertSuperPasswordLabelLabel1 = new JLabel();
alertSuperPasswordLabelLabel1.setVisible(false);
panel.add(alertSuperPasswordLabelLabel1, cc.xy(7, 3));
JLabel superUserPasswordLabel2 = new JLabel();
superUserPasswordLabel2.setText(TxtManager.getTxt("VIEW.PASSWORDEDIT.NEWPASSWORDLABEL2"));
panel.add(superUserPasswordLabel2, cc.xy(3, 5));
JPasswordField superUserPasswordField2 = new JPasswordField();
panel.add(superUserPasswordField2, cc.xy(5, 5));
JLabel alertSuperUserPasswordLabel2 = new JLabel();
alertSuperUserPasswordLabel2.setVisible(false);
panel.add(alertSuperUserPasswordLabel2, cc.xy(7, 5));
Object[] options = {TxtManager.getTxt("VIEW.GLOBAL.CONFIRMBUTTON"),
TxtManager.getTxt("VIEW.GLOBAL.CANCELBUTTON")};
int n = -1;
while ( (n != 0) && (n != 1) ) {
n = JOptionPane.showOptionDialog(this, panel, TxtManager.getTxt("INFORMATION.CREATESUPERUSERPASSWORD"),
JOptionPane.OK_OPTION, JOptionPane.PLAIN_MESSAGE, null, options, options[0]);
if (n == 0) {
if (superUserPasswordField1.getPassword().length == 0) {
alertSuperPasswordLabelLabel1.setText(TxtManager.getTxt("VALIDATE.NULLVALUE"));
alertSuperPasswordLabelLabel1.setIcon(ImageManager.getImage(ImageManager.ALERT_IMAGE));
alertSuperPasswordLabelLabel1.setVisible(true);
n = -1;
} else {
alertSuperPasswordLabelLabel1.setVisible(false);
}
if (superUserPasswordField2.getPassword().length == 0) {
alertSuperUserPasswordLabel2.setText(TxtManager.getTxt("VALIDATE.NULLVALUE"));
alertSuperUserPasswordLabel2.setIcon(ImageManager.getImage(ImageManager.ALERT_IMAGE));
alertSuperUserPasswordLabel2.setVisible(true);
n = -1;
} else {
alertSuperUserPasswordLabel2.setVisible(false);
}
if (n!= -1) {
String newPassword1 = new String(superUserPasswordField1.getPassword());
String newPassword2 = new String(superUserPasswordField2.getPassword());
if (!newPassword1.equals(newPassword2)) {
alertSuperUserPasswordLabel2.setText(TxtManager.getTxt("VALIDATE.PASSWORDNOTEQUAL"));
alertSuperUserPasswordLabel2.setIcon(ImageManager.getImage(ImageManager.ALERT_IMAGE));
alertSuperUserPasswordLabel2.setVisible(true);
n = -1;
} else {
alertSuperUserPasswordLabel2.setVisible(false);
}
}
}
}
if (n == 0) {
try {
Cipher cipher = Cipher.getInstance("DES");
cipher.init(Cipher.ENCRYPT_MODE, GlobalValueManager.getPasswordKey());
String passwordString = new String(superUserPasswordField1.getPassword());
password = new SealedObject(passwordString, cipher);
} catch (Exception e) {
e.printStackTrace();
}
}
return password;
}
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals("Exit")) {
exitApplication();
} else if (e.getActionCommand().equals("Confirm")) {
setApplicationValues();
}
}
public void windowClosing(WindowEvent e) {
exitApplication();
}
public void windowClosed(WindowEvent e) {
}
public void windowOpened(WindowEvent e) {
}
public void windowIconified(WindowEvent e) {
}
public void windowDeiconified(WindowEvent e) {
}
public void windowActivated(WindowEvent e) {
}
public void windowDeactivated(WindowEvent e) {
}
public void windowGainedFocus(WindowEvent e) {
}
public void windowLostFocus(WindowEvent e) {
}
public void windowStateChanged(WindowEvent e) {
}
}