}
}
});
}
{
jTextFieldDescription = new JTextField4j();
desktopPane.add(jTextFieldDescription);
jTextFieldDescription.setFocusCycleRoot(true);
jTextFieldDescription.setBounds(425, 40, 325, 21);
jTextFieldDescription.addKeyListener(new KeyAdapter()
{
public void keyTyped(KeyEvent evt)
{
jTextFieldKeyTyped();
}
});
}
{
jTextFieldURL = new JTextField4j();
desktopPane.add(jTextFieldURL);
jTextFieldURL.setFocusCycleRoot(true);
jTextFieldURL.setBounds(425, 65, 325, 21);
jTextFieldURL.addKeyListener(new KeyAdapter()
{
public void keyTyped(KeyEvent evt)
{
jTextFieldKeyTyped();
}
});
}
{
jLabelDatabaseType = new JLabel4j_std();
desktopPane.add(jLabelDatabaseType);
jLabelDatabaseType.setText("Database Type");
jLabelDatabaseType.setHorizontalAlignment(SwingConstants.RIGHT);
jLabelDatabaseType.setHorizontalTextPosition(SwingConstants.RIGHT);
jLabelDatabaseType.setBounds(291, 91, 127, 21);
}
{
ComboBoxModel jComboBoxjdbcDriverModel = new DefaultComboBoxModel(new String[]
{ "", "mySQL", "Oracle", "SQL Server", "Web URL" });
jComboBoxjdbcDriver = new JComboBox4j();
desktopPane.add(jComboBoxjdbcDriver);
jComboBoxjdbcDriver.setModel(jComboBoxjdbcDriverModel);
jComboBoxjdbcDriver.setBounds(425, 90, 164, 21);
jComboBoxjdbcDriver.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent evt)
{
if (jComboBoxjdbcDriver.getSelectedItem().toString().equals("Oracle"))
{
jTextFieldDriver.setText("oracle.jdbc.driver.OracleDriver");
jTextFieldConnect.setText("jdbc:oracle:thin:@jdbcServer:jdbcPort:jdbcSID");
jTextFieldDateTime.setText("sysdate");
jTextFieldSelectLimit.setText("rownum");
jTextFieldServer.setText("localhost");
jTextFieldPort.setText("1521");
}
if (jComboBoxjdbcDriver.getSelectedItem().toString().equals("mySQL"))
{
jTextFieldDriver.setText("com.mysql.jdbc.Driver");
jTextFieldConnect.setText("jdbc:mysql://jdbcServer/jdbcDatabase");
jTextFieldDateTime.setText("sysdate");
jTextFieldSelectLimit.setText("limit");
jTextFieldServer.setText("localhost");
jTextFieldPort.setText("3306");
}
if (jComboBoxjdbcDriver.getSelectedItem().toString().equals("SQL Server"))
{
jTextFieldDriver.setText("com.microsoft.sqlserver.jdbc.SQLServerDriver");
jTextFieldConnect.setText("jdbc:sqlserver://jdbcServer\\jdbcSID");
jTextFieldDateTime.setText("sysdate");
jTextFieldSelectLimit.setText("top");
jTextFieldServer.setText("localhost");
jTextFieldPort.setText("1433");
}
if (jComboBoxjdbcDriver.getSelectedItem().toString().equals("Web URL"))
{
jTextFieldDriver.setText("http");
jTextFieldConnect.setText("");
jTextFieldDateTime.setText("");
jTextFieldSelectLimit.setText("");
jTextFieldServer.setText("");
jTextFieldPort.setText("");
}
jTextFieldKeyTyped();
}
});
}
{
jTextFieldConnect = new JTextField4j();
desktopPane.add(jTextFieldConnect);
jTextFieldConnect.setFocusCycleRoot(true);
jTextFieldConnect.setBounds(425, 145, 325, 21);
jTextFieldConnect.setEditable(false);
jTextFieldConnect.setEnabled(false);
jTextFieldConnect.setDisabledTextColor(Common.color_textdisabled);
jTextFieldConnect.addKeyListener(new KeyAdapter()
{
public void keyTyped(KeyEvent evt)
{
jTextFieldKeyTyped();
}
});
}
{
jLabelDriver = new JLabel4j_std();
desktopPane.add(jLabelDriver);
jLabelDriver.setText("Driver");
jLabelDriver.setHorizontalAlignment(SwingConstants.RIGHT);
jLabelDriver.setHorizontalTextPosition(SwingConstants.RIGHT);
jLabelDriver.setBounds(291, 116, 127, 21);
}
{
jLabelDatabase = new JLabel4j_std();
desktopPane.add(jLabelDatabase);
jLabelDatabase.setText("Database");
jLabelDatabase.setHorizontalAlignment(SwingConstants.RIGHT);
jLabelDatabase.setHorizontalTextPosition(SwingConstants.RIGHT);
jLabelDatabase.setBounds(320, 196, 98, 21);
}
{
jLabelDBDateTime = new JLabel4j_std();
desktopPane.add(jLabelDBDateTime);
jLabelDBDateTime.setText("DB Date Time");
jLabelDBDateTime.setHorizontalAlignment(SwingConstants.RIGHT);
jLabelDBDateTime.setHorizontalTextPosition(SwingConstants.RIGHT);
jLabelDBDateTime.setBounds(291, 321, 127, 21);
}
{
jLabelPassword = new JLabel4j_std();
desktopPane.add(jLabelPassword);
jLabelPassword.setText("Password");
jLabelPassword.setHorizontalAlignment(SwingConstants.RIGHT);
jLabelPassword.setHorizontalTextPosition(SwingConstants.RIGHT);
jLabelPassword.setBounds(291, 296, 127, 21);
}
{
jLabelDescription = new JLabel4j_std();
desktopPane.add(jLabelDescription);
jLabelDescription.setText("Description");
jLabelDescription.setHorizontalAlignment(SwingConstants.RIGHT);
jLabelDescription.setHorizontalTextPosition(SwingConstants.RIGHT);
jLabelDescription.setBounds(291, 41, 127, 21);
}
{
jLabelSiteNo = new JLabel4j_std();
desktopPane.add(jLabelSiteNo);
jLabelSiteNo.setText("Site No");
jLabelSiteNo.setHorizontalAlignment(SwingConstants.RIGHT);
jLabelSiteNo.setHorizontalTextPosition(SwingConstants.RIGHT);
jLabelSiteNo.setBounds(291, 15, 127, 21);
}
{
jLabelUsername = new JLabel4j_std();
desktopPane.add(jLabelUsername);
jLabelUsername.setText("Username");
jLabelUsername.setHorizontalAlignment(SwingConstants.RIGHT);
jLabelUsername.setHorizontalTextPosition(SwingConstants.RIGHT);
jLabelUsername.setBounds(291, 271, 127, 21);
}
{
jLabelPort = new JLabel4j_std();
desktopPane.add(jLabelPort);
jLabelPort.setText("Port");
jLabelPort.setHorizontalAlignment(SwingConstants.RIGHT);
jLabelPort.setHorizontalTextPosition(SwingConstants.RIGHT);
jLabelPort.setBounds(320, 221, 98, 21);
}
{
jTextFieldDateTime = new JTextField4j();
desktopPane.add(jTextFieldDateTime);
jTextFieldDateTime.setFocusCycleRoot(true);
jTextFieldDateTime.setBounds(425, 320, 325, 21);
jTextFieldDateTime.addKeyListener(new KeyAdapter()
{
public void keyTyped(KeyEvent evt)
{
jTextFieldKeyTyped();
}
});
}
{
jTextFieldUsername = new JTextField4j();
desktopPane.add(jTextFieldUsername);
jTextFieldUsername.setFocusCycleRoot(true);
jTextFieldUsername.setBounds(425, 270, 325, 21);
jTextFieldUsername.addKeyListener(new KeyAdapter()
{
public void keyTyped(KeyEvent evt)
{
jTextFieldKeyTyped();
}
});
}
{
jTextFieldPassword = new JPasswordField(10);
desktopPane.add(jTextFieldPassword);
jTextFieldPassword.setFocusCycleRoot(true);
jTextFieldPassword.setBounds(425, 295, 325, 21);
jTextFieldPassword.addKeyListener(new KeyAdapter()
{
public void keyTyped(KeyEvent evt)
{
jTextFieldKeyTyped();
}
});
}
{
jTextFieldPort = new JTextField4j();
desktopPane.add(jTextFieldPort);
jTextFieldPort.setFocusCycleRoot(true);
jTextFieldPort.setBounds(425, 220, 325, 21);
jTextFieldPort.addKeyListener(new KeyAdapter()
{
public void keyTyped(KeyEvent evt)
{
jTextFieldKeyTyped();
}
});
}
{
jTextFieldSID = new JTextField4j();
desktopPane.add(jTextFieldSID);
jTextFieldSID.setFocusCycleRoot(true);
jTextFieldSID.setBounds(425, 245, 325, 21);
jTextFieldSID.addKeyListener(new KeyAdapter()
{
public void keyTyped(KeyEvent evt)
{
jTextFieldKeyTyped();
}
});
}
{
jTextFieldSiteNo = new JTextField4j();
desktopPane.add(jTextFieldSiteNo);
jTextFieldSiteNo.setFocusCycleRoot(true);
jTextFieldSiteNo.setBounds(425, 14, 28, 21);
jTextFieldSiteNo.setHorizontalAlignment(SwingConstants.CENTER);
jTextFieldSiteNo.setEnabled(false);
jTextFieldSiteNo.addKeyListener(new KeyAdapter()
{
public void keyTyped(KeyEvent evt)
{
jTextFieldKeyTyped();
}
});
}
{
jTextFieldDriver = new JTextField4j();
desktopPane.add(jTextFieldDriver);
jTextFieldDriver.setFocusCycleRoot(true);
jTextFieldDriver.setBounds(425, 117, 325, 21);
jTextFieldDriver.setEditable(false);
jTextFieldDriver.setEnabled(false);
jTextFieldDriver.setDisabledTextColor(Common.color_textdisabled);
jTextFieldDriver.addKeyListener(new KeyAdapter()
{
public void keyTyped(KeyEvent evt)
{
jTextFieldKeyTyped();
}
});
}
{
jCheckBoxEnabled = new JCheckBox();
jCheckBoxEnabled.setFont(Common.font_std);
desktopPane.add(jCheckBoxEnabled);
jCheckBoxEnabled.setText("Enabled");
jCheckBoxEnabled.setBounds(467, 14, 91, 21);
jCheckBoxEnabled.setBackground(new java.awt.Color(255, 255, 255));
jCheckBoxEnabled.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent evt)
{
jTextFieldKeyTyped();
}
});
}
{
jCheckBoxSplash = new JCheckBox();
jCheckBoxSplash.setSelected(true);
jCheckBoxSplash.setFont(Common.font_std);
desktopPane.add(jCheckBoxSplash);
jCheckBoxSplash.setText("Enable Splash Screen");
jCheckBoxSplash.setBounds(687, 445, 150, 21);
jCheckBoxSplash.setBackground(new java.awt.Color(255, 255, 255));
jCheckBoxSplash.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent evt)
{
jTextFieldKeyTyped();
}
});
}
{
jLabelSID = new JLabel4j_std();
desktopPane.add(jLabelSID);
jLabelSID.setText("SID");
jLabelSID.setHorizontalAlignment(SwingConstants.RIGHT);
jLabelSID.setHorizontalTextPosition(SwingConstants.RIGHT);
jLabelSID.setBounds(320, 246, 98, 21);
}
{
jButtonCancel = new JButton4j(Common.icon_cancel);
desktopPane.add(jButtonCancel);
jButtonCancel.setText("Cancel");
jButtonCancel.setBounds(762, 345, 160, 36);
jButtonCancel.setEnabled(false);
jButtonCancel.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent evt)
{
getHostData();
}
});
}
{
jTextFieldServer = new JTextField4j();
desktopPane.add(jTextFieldServer);
jTextFieldServer.setFocusCycleRoot(true);
jTextFieldServer.setBounds(425, 170, 325, 21);
jTextFieldServer.setEnabled(false);
jTextFieldServer.addKeyListener(new KeyAdapter()
{
public void keyTyped(KeyEvent evt)
{
jTextFieldKeyTyped();
}
});
}
{
jLabelConnectionString = new JLabel4j_std();
desktopPane.add(jLabelConnectionString);
jLabelConnectionString.setText("Connect String");
jLabelConnectionString.setHorizontalAlignment(SwingConstants.RIGHT);
jLabelConnectionString.setHorizontalTextPosition(SwingConstants.RIGHT);
jLabelConnectionString.setBounds(291, 141, 127, 21);
}
{
jTextFieldDatabase = new JTextField4j();
desktopPane.add(jTextFieldDatabase);
jTextFieldDatabase.setEnabled(false);
jTextFieldDatabase.setFocusCycleRoot(true);
jTextFieldDatabase.setBounds(425, 195, 325, 21);
jTextFieldDatabase.addKeyListener(new KeyAdapter()
{
public void keyTyped(KeyEvent evt)
{
jTextFieldKeyTyped();
}
});
}
{
jLabelServer = new JLabel4j_std();
desktopPane.add(jLabelServer);
jLabelServer.setText("Server");
jLabelServer.setHorizontalAlignment(SwingConstants.RIGHT);
jLabelServer.setHorizontalTextPosition(SwingConstants.RIGHT);
jLabelServer.setBounds(320, 171, 98, 21);
}
{
jButtonTest = new JButton4j(Common.icon_connect);
desktopPane.add(jButtonTest);
jButtonTest.setText("Connect to DB");
jButtonTest.setBounds(762, 86, 160, 36);
jButtonTest.setToolTipText("Connect to selected Host Database");
jButtonTest.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent evt)
{
writeBackHosts(hostList);
int j = jListHosts.getSelectedIndex();
JHost hst = (JHost) jListHosts.getModel().getElementAt(j);
Common.selectedHostID = hst.getSiteNumber();
if (Common.hostList.getHost(Common.selectedHostID).connect(Common.sessionID, Common.selectedHostID))
{
btnSchema.setEnabled(true);
jButtonUpdate.setEnabled(true);
Common.hostList.getHost(Common.selectedHostID).disconnect(Common.sessionID);
} else
{
jButtonUpdate.setEnabled(false);
btnSchema.setEnabled(false);
}
}
});
}
{
jButtonUpdate = new JButton4j(Common.icon_update);
desktopPane.add(jButtonUpdate);
jButtonUpdate.setText("Create/Update Tables");
jButtonUpdate.setBounds(762, 123, 160, 36);
jButtonUpdate.setEnabled(false);
jButtonUpdate.setToolTipText("Create or Upgrade Application Database Schema");
jButtonUpdate.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent evt)
{
writeBackHosts(hostList);
int j = jListHosts.getSelectedIndex();
JHost hst = (JHost) jListHosts.getModel().getElementAt(j);
Common.selectedHostID = hst.getSiteNumber();
if (Common.hostList.getHost(Common.selectedHostID).connect(Common.sessionID, Common.selectedHostID))
{
JDBSchema schema = new JDBSchema(Common.sessionID, Common.hostList.getHost(Common.selectedHostID));
JDBUpdateRequest updrst = new JDBUpdateRequest();
updrst = schema.validate(false);
if (updrst.schema_updateRequired)
{
int continueUpdate = JOptionPane.showConfirmDialog(me, "Current Schema Version is " + String.valueOf(updrst.schema_currentVersion) + ", required version is " + String.valueOf(updrst.schema_requiredVersion)
+ ". Upgrade ?", "Connection to (" + hst.getSiteDescription() + ")", JOptionPane.YES_NO_OPTION);
if (continueUpdate == 0)
{
LinkedList<JDBDDL> cmds = new LinkedList<JDBDDL>();
cmds.clear();
cmds = JXMLSchema.loadDDLStatements(jTextFieldDriver.getText(), "xml/schema/" + Common.hostList.getHost(Common.selectedHostID).getDatabaseParameters().getjdbcDriver() + "/");
boolean updateCtrl = false;
if (cmds.size() > 0)
{
if (schema.executeDDL(cmds, progressBar, labelCommand) == true)
{
updateCtrl = true;
} else
{
JUtility.errorBeep();
JDialogDMLErrors dmlerrs = new JDialogDMLErrors(me, cmds);
dmlerrs.setModal(true);
int ignoreDDLErrors = JOptionPane.showConfirmDialog(me, "Ignore Errors and set SCHEMA version to " + String.valueOf(updrst.schema_requiredVersion) + " ?", "Connection to (" + hst.getSiteDescription()
+ ")", JOptionPane.YES_NO_OPTION);
if (ignoreDDLErrors == 0)
{
updateCtrl = true;
}
}
} else
{
JOptionPane.showMessageDialog(me, "No DDL Commands found", "Connection to (" + hst.getSiteDescription() + ")", JOptionPane.WARNING_MESSAGE);
}
if (updateCtrl)
{
JDBControl ctrl = new JDBControl(Common.selectedHostID, Common.sessionID);
if (ctrl.getProperties("SCHEMA VERSION"))
{
ctrl.setKeyValue(String.valueOf(updrst.schema_requiredVersion));
ctrl.update();
} else
{
ctrl.create("SCHEMA VERSION", String.valueOf(updrst.schema_requiredVersion), "Schema Version");
}
JOptionPane.showMessageDialog(me, "Schema Version now set to " + String.valueOf(JVersion.getSchemaVersion()), "Control Table", JOptionPane.INFORMATION_MESSAGE);
}
}
} else
{
JOptionPane.showMessageDialog(me, "No Schema update Required", "Connection to (" + hst.getSiteDescription() + ")", JOptionPane.INFORMATION_MESSAGE);
}
if (updrst.program_updateRequired)
{
JDBControl ctrl = new JDBControl(Common.selectedHostID, Common.sessionID);
if (ctrl.getProperties("PROGRAM VERSION"))
{
ctrl.setKeyValue(JVersion.getProgramVersion());
ctrl.update();
} else
{
ctrl.create("PROGRAM VERSION", JVersion.getProgramVersion(), "Program Version");
}
JOptionPane.showMessageDialog(me, "Program Version now set to " + JVersion.getProgramVersion(), "Control Table", JOptionPane.INFORMATION_MESSAGE);
}
Common.hostList.getHost(Common.selectedHostID).disconnect(Common.sessionID);
}
}
});
}
{
jTextFieldSelectLimit = new JTextField4j();
desktopPane.add(jTextFieldSelectLimit);
jTextFieldSelectLimit.setBounds(425, 345, 325, 21);
jTextFieldSelectLimit.addKeyListener(new KeyAdapter()
{
public void keyTyped(KeyEvent evt)
{
jTextFieldKeyTyped();
}
});
jTextFieldSelectLimit.setFocusCycleRoot(true);
jTextFieldSelectLimit.setEnabled(false);
}
{
jLabelSelectTime = new JLabel4j_std();
desktopPane.add(jLabelSelectTime);
jLabelSelectTime.setText("DB Select Limit");
jLabelSelectTime.setHorizontalAlignment(SwingConstants.RIGHT);
jLabelSelectTime.setHorizontalTextPosition(SwingConstants.RIGHT);
jLabelSelectTime.setBounds(291, 346, 127, 21);
}
{
jLabelSchema = new JLabel4j_std();
desktopPane.add(jLabelSchema);
jLabelSchema.setText("DB Schema");
jLabelSchema.setHorizontalAlignment(SwingConstants.RIGHT);
jLabelSchema.setHorizontalTextPosition(SwingConstants.RIGHT);
jLabelSchema.setBounds(291, 370, 127, 21);
}
{
jTextFieldSchema = new JTextField4j();
desktopPane.add(jTextFieldSchema);
jTextFieldSchema.setEnabled(false);
jTextFieldSchema.setBounds(425, 370, 325, 21);
jTextFieldSchema.addKeyListener(new KeyAdapter()
{
public void keyTyped(KeyEvent evt)
{
jTextFieldKeyTyped();
}
});
jTextFieldSchema.setFocusCycleRoot(true);
}
{
jLabelMenuURL = new JLabel4j_std();
jLabelMenuURL.setHorizontalTextPosition(SwingConstants.RIGHT);
jLabelMenuURL.setHorizontalAlignment(SwingConstants.RIGHT);
jLabelMenuURL.setText("URL");
jLabelMenuURL.setBounds(291, 66, 127, 21);
desktopPane.add(jLabelMenuURL);
}
{
jTextFieldUniqueID = new JTextField4j();
jTextFieldUniqueID.addKeyListener(new KeyAdapter()
{
@Override
public void keyTyped(KeyEvent e)
{
jTextFieldKeyTyped();
}
});
jTextFieldUniqueID.setEditable(true);
jTextFieldUniqueID.setBounds(425, 395, 325, 21);
desktopPane.add(jTextFieldUniqueID);
}
{
jLabelUniqueID = new JLabel4j_std();
jLabelUniqueID.setText("Unique ID");
jLabelUniqueID.setHorizontalAlignment(SwingConstants.RIGHT);
jLabelUniqueID.setHorizontalTextPosition(SwingConstants.RIGHT);
jLabelUniqueID.setBounds(291, 396, 127, 21);
desktopPane.add(jLabelUniqueID);
}
{
btnSchema = new JButton4j(Common.icon_report);
btnSchema.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
writeBackHosts(hostList);
int j = jListHosts.getSelectedIndex();
JHost hst = (JHost) jListHosts.getModel().getElementAt(j);
Common.selectedHostID = hst.getSiteNumber();
if (Common.hostList.getHost(Common.selectedHostID).connect(Common.sessionID, Common.selectedHostID))
{
btnSchema.setEnabled(true);
jButtonUpdate.setEnabled(true);
JDBStructure struct = new JDBStructure(Common.selectedHostID, Common.sessionID);
struct.exportSchema();
struct.saveAs("SCHEMA " + Common.hostList.getHost(Common.selectedHostID).getSiteDescription() + ".txt", Common.mainForm);
Common.hostList.getHost(Common.selectedHostID).disconnect(Common.sessionID);
} else
{
jButtonUpdate.setEnabled(false);
btnSchema.setEnabled(false);
}
}
});
btnSchema.setText("DB Schema Report");
btnSchema.setEnabled(false);
btnSchema.setBounds(762, 308, 160, 36);
desktopPane.add(btnSchema);
}
}
progressBar.setBounds(10, 521, 912, 28);
progressBar.setBackground(Color.WHITE);
progressBar.setForeground(Color.BLUE);
desktopPane.add(progressBar);
labelCommand.setBounds(10, 548, 912, 23);
labelCommand.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
desktopPane.add(labelCommand);
JButton4j btnService = new JButton4j(Common.icon_interface);
btnService.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
if (jListHosts.getSelectedIndex() > -1)
{
int j = jListHosts.getSelectedIndex();
String desc = hostList.get(j).getSiteDescription();
for (int x = 0; x < hostList.size(); x++)
{
if (x==j)
{
hostList.get(x).setUniqueID("service");
}
else
{
hostList.get(x).setUniqueID("");
}
}
populateList(desc);
getHostData();
setSaveButtonState(true);
}
}
});
btnService.setToolTipText("Connect to selected Host Database");
btnService.setText("Assign to Service");
btnService.setBounds(762, 234, 160, 36);
desktopPane.add(btnService);
JLabel4j_std label4j_std = new JLabel4j_std();
label4j_std.setFont(new Font("Arial", Font.BOLD, 11));
label4j_std.setText("Database Connections");
label4j_std.setHorizontalTextPosition(SwingConstants.LEFT);
label4j_std.setHorizontalAlignment(SwingConstants.LEFT);
label4j_std.setBounds(14, 15, 127, 21);
desktopPane.add(label4j_std);
JLabel4j_std JLabelUpdateHostURL = new JLabel4j_std();
JLabelUpdateHostURL.setText("URL for Update");
JLabelUpdateHostURL.setHorizontalTextPosition(SwingConstants.RIGHT);
JLabelUpdateHostURL.setHorizontalAlignment(SwingConstants.RIGHT);
JLabelUpdateHostURL.setBounds(291, 470, 127, 21);
desktopPane.add(JLabelUpdateHostURL);
JTextFieldUpdateURL = new JTextField4j();
JTextFieldUpdateURL.addKeyListener(new KeyAdapter()
{
@Override
public void keyTyped(KeyEvent arg0)
{