/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package edu.bellevue.its.migration.gui.frames.developer;
import edu.bellevue.its.migration.entities.Generalinfo;
import edu.bellevue.its.migration.entities.User;
import edu.bellevue.its.migration.gui.dialogs.ModifiedFileDialog;
import edu.bellevue.its.migration.gui.dialogs.UserLookupDialog;
import edu.bellevue.its.migration.global.AppHelper;
import edu.bellevue.its.migration.gui.frames.UpdateableFrame;
import java.awt.Point;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Enumeration;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultListModel;
import javax.swing.JCheckBox;
import javax.swing.JInternalFrame;
import javax.swing.JOptionPane;
import javax.swing.ListModel;
/**
*
* @author tslater
*/
public class EditGeneralInfoFrame extends javax.swing.JInternalFrame implements UpdateableFrame {
/**
* Creates new form EditGeneralInfoFrame
*/
private Generalinfo gi;
private User businessAnalyst;
private UpdateableFrame owner;
public EditGeneralInfoFrame(UpdateableFrame frame, Generalinfo gi)
{
initComponents();
this.gi = gi;
owner = frame;
AppHelper.placeRightOfParent(this,((JInternalFrame)owner));
initFields();
}
public void updateView()
{
initFields();
}
private void initFields()
{
String pillarString = gi.getPillar();
if (pillarString != null)
{
chkCS.setSelected(pillarString.contains(" CS "));
chkCRM.setSelected(pillarString.contains(" CRM "));
chkFIN.setSelected(pillarString.contains(" FIN "));
chkPortal.setSelected(pillarString.contains(" PORTAL "));
chkWeb.setSelected(pillarString.contains(" WEB "));
}
if (gi.getSecurityRequired() != null)
chkSecurity.setSelected(gi.getSecurityRequired().equals("Y"));
if (gi.getTechReviewReq() != null)
chkTechReview.setSelected(gi.getTechReviewReq().equals("Y"));
if (gi.getNotifyOs() != null)
chkNotifyOS.setSelected(gi.getNotifyOs().equals("Y"));
if (gi.getNotifySd() != null)
chkNotifySD.setSelected(gi.getNotifySd().equals("Y"));
//chkNotifyPortal.setSelected(gi.getNotifyPortal().equals("Y"));
businessAnalyst = AppHelper.getUserById(gi.getBusinessAnalyst());
if (businessAnalyst != null)
{
txtBA.setText(AppHelper.getUserDisplayName(businessAnalyst));
}
if (gi.getTicketNumber() != null)
txtTicketNumber.setText(gi.getTicketNumber());
if (gi.getDescription() != null)
txtDescription.setText(gi.getDescription());
if (gi.getPurpose() != null)
txtPurpose.setText(gi.getPurpose());
if (gi.getRequestor() != null)
txtRequestor.setText(gi.getRequestor());
if (gi.getRequestedDate() != null)
txtReqDate.setText(new SimpleDateFormat("MM/DD/yyyy").format(gi.getRequestedDate()));
String modifiedFiles = gi.getModifiedFiles();
if (modifiedFiles != null)
{
String[] files = modifiedFiles.split("\n");
DefaultListModel dlm = (DefaultListModel)lstChangedFiles.getModel();
for(String s : files)
{
dlm.addElement(s);
}
}
}
/**
* 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.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
chkCS = new javax.swing.JCheckBox();
chkCRM = new javax.swing.JCheckBox();
chkFIN = new javax.swing.JCheckBox();
chkPortal = new javax.swing.JCheckBox();
chkWeb = new javax.swing.JCheckBox();
jLabel2 = new javax.swing.JLabel();
txtTicketNumber = new javax.swing.JTextField();
jLabel3 = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
txtDescription = new javax.swing.JTextArea();
jLabel4 = new javax.swing.JLabel();
jScrollPane2 = new javax.swing.JScrollPane();
txtPurpose = new javax.swing.JTextArea();
jLabel5 = new javax.swing.JLabel();
txtRequestor = new javax.swing.JTextField();
jLabel6 = new javax.swing.JLabel();
txtReqDate = new javax.swing.JTextField();
jLabel7 = new javax.swing.JLabel();
txtBA = new javax.swing.JTextField();
btnFindBA = new javax.swing.JButton();
chkTechReview = new javax.swing.JCheckBox();
chkSecurity = new javax.swing.JCheckBox();
chkNotifyPortal = new javax.swing.JCheckBox();
chkNotifyOS = new javax.swing.JCheckBox();
chkNotifySD = new javax.swing.JCheckBox();
btnTodayDate = new javax.swing.JButton();
btnSave = new javax.swing.JButton();
btnCancel = new javax.swing.JButton();
jScrollPane3 = new javax.swing.JScrollPane();
lstChangedFiles = new javax.swing.JList();
btnAddModifiedFile = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jLabel8 = new javax.swing.JLabel();
setIconifiable(true);
setResizable(true);
jLabel1.setText("Pillar: ");
chkCS.setText("CS");
chkCRM.setText("CRM");
chkFIN.setText("FIN");
chkPortal.setText("PORTAL");
chkWeb.setText("WEB");
jLabel2.setText("Ticket #:");
jLabel3.setText("Description: ");
txtDescription.setColumns(20);
txtDescription.setRows(5);
jScrollPane1.setViewportView(txtDescription);
jLabel4.setText("Purpose: ");
txtPurpose.setColumns(20);
txtPurpose.setRows(5);
jScrollPane2.setViewportView(txtPurpose);
jLabel5.setText("Requestor: ");
jLabel6.setText("Request Date: ");
jLabel7.setText("BA:");
txtBA.setEditable(false);
btnFindBA.setText("...");
btnFindBA.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnFindBAActionPerformed(evt);
}
});
chkTechReview.setText("Tech Review");
chkSecurity.setText("Security");
chkNotifyPortal.setText("Notify Portal");
chkNotifyOS.setText("Notify OS");
chkNotifySD.setText("Notify SD");
btnTodayDate.setText("<>");
btnTodayDate.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnTodayDateActionPerformed(evt);
}
});
btnSave.setText("Save");
btnSave.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnSaveActionPerformed(evt);
}
});
btnCancel.setText("Cancel");
btnCancel.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnCancelActionPerformed(evt);
}
});
lstChangedFiles.setModel(new DefaultListModel());
jScrollPane3.setViewportView(lstChangedFiles);
btnAddModifiedFile.setText("+");
btnAddModifiedFile.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnAddModifiedFileActionPerformed(evt);
}
});
jButton2.setText("-");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
jLabel8.setText("Changed Files:");
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()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(jScrollPane1)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(chkCS)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(chkCRM)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(chkFIN)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(chkPortal)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(chkWeb))
.addComponent(jLabel3, javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(txtTicketNumber)))
.addComponent(jLabel4))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel5)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(txtRequestor))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel6)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(txtReqDate, javax.swing.GroupLayout.PREFERRED_SIZE, 155, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnTodayDate, javax.swing.GroupLayout.PREFERRED_SIZE, 1, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addGap(2, 2, 2)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(chkTechReview)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(chkSecurity))
.addGroup(layout.createSequentialGroup()
.addComponent(chkNotifyPortal)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(chkNotifyOS)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(chkNotifySD))))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel8)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btnAddModifiedFile, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jScrollPane3)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel7)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(txtBA, javax.swing.GroupLayout.PREFERRED_SIZE, 211, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnFindBA))))
.addGroup(layout.createSequentialGroup()
.addGap(71, 71, 71)
.addComponent(btnSave)
.addGap(18, 18, 18)
.addComponent(btnCancel))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(16, 16, 16)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(chkCS)
.addComponent(chkCRM)
.addComponent(chkFIN)
.addComponent(chkPortal)
.addComponent(chkWeb))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(txtTicketNumber, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jLabel4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel5)
.addComponent(txtRequestor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel6)
.addComponent(txtReqDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnTodayDate))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel7)
.addComponent(txtBA, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnFindBA))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel8)
.addComponent(btnAddModifiedFile)
.addComponent(jButton2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(chkTechReview)
.addComponent(chkSecurity))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(chkNotifyPortal)
.addComponent(chkNotifyOS)
.addComponent(chkNotifySD))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnSave)
.addComponent(btnCancel))
.addContainerGap(36, Short.MAX_VALUE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void btnSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSaveActionPerformed
// TODO add your handling code here:
// update pillar
updatePillar();
updateNotifies();
updateRequireds();
gi.setTicketNumber(txtTicketNumber.getText());
gi.setDescription(txtDescription.getText());
gi.setPurpose(txtPurpose.getText());
gi.setRequestor(txtRequestor.getText());
ListModel lm = lstChangedFiles.getModel();
DefaultListModel dlm = (DefaultListModel)lstChangedFiles.getModel();
Enumeration e = dlm.elements();
StringBuilder sb = new StringBuilder();
while (e.hasMoreElements())
{
sb.append(e.nextElement().toString()).append("\n");
}
gi.setModifiedFiles(sb.toString());
if (businessAnalyst != null)
{
gi.setBusinessAnalyst(businessAnalyst.getIdUser());
}
SimpleDateFormat sdf = new SimpleDateFormat("MM/DD/yyyy");
try {
Date d = sdf.parse(txtReqDate.getText());
gi.setRequestedDate(d);
} catch (ParseException ex) {
JOptionPane.showMessageDialog(this, "Requested Date is not in a valid format (MM/DD/YYYY) Please correct and resave.");
Logger.getLogger(EditGeneralInfoFrame.class.getName()).log(Level.SEVERE, null, ex);
return;
}
this.setVisible(false);
owner.updateView();
}//GEN-LAST:event_btnSaveActionPerformed
private void btnTodayDateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTodayDateActionPerformed
// TODO add your handling code here:
Date d = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("MM/DD/yyyy");
String result = sdf.format(d);
txtReqDate.setText(result);
}//GEN-LAST:event_btnTodayDateActionPerformed
private void btnAddModifiedFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddModifiedFileActionPerformed
// TODO add your handling code here:
ModifiedFileDialog mfd = new ModifiedFileDialog(null, true);
mfd.setVisible(true);
String s = mfd.dialogResult;
if (s != null)
{
DefaultListModel dlm = (DefaultListModel)lstChangedFiles.getModel();
dlm.addElement(s);
}
}//GEN-LAST:event_btnAddModifiedFileActionPerformed
private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
// TODO add your handling code here:
owner.updateView();
this.setVisible(false);
}//GEN-LAST:event_btnCancelActionPerformed
private void btnFindBAActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnFindBAActionPerformed
// TODO add your handling code here:
UserLookupDialog uld = new UserLookupDialog(null, true, "BA");
uld.setVisible(true);
if (uld.dialogResult != null)
{
gi.setBusinessAnalyst(uld.dialogResult.getIdUser());
txtBA.setText(AppHelper.getUserDisplayName(uld.dialogResult));
}
}//GEN-LAST:event_btnFindBAActionPerformed
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
// TODO add your handling code here:
DefaultListModel dlm = (DefaultListModel)lstChangedFiles.getModel();
try
{
dlm.remove(lstChangedFiles.getSelectedIndex());
}catch (Exception e){}
}//GEN-LAST:event_jButton2ActionPerformed
private void updateRequireds()
{
gi.setTechReviewReq(chkTechReview.isSelected() ? "Y" : "N");
gi.setSecurityRequired(chkSecurity.isSelected() ? "Y" : "N");
}
private void updateNotifies()
{
//gi.setNotifyPortal(chkNotifyPortal.isSelected() ? "Y" : "N");
gi.setNotifyOs(chkNotifyOS.isSelected() ? "Y" : "N");
gi.setNotifySd(chkNotifySD.isSelected() ? "Y" : "N");
}
private void updatePillar()
{
StringBuilder sb = new StringBuilder();
if (chkCS.isSelected())
{
sb.append(" CS ");
}
if (chkCRM.isSelected())
{
sb.append(" CRM ");
}
if (chkFIN.isSelected())
{
sb.append(" FIN ");
}
if (chkPortal.isSelected())
{
sb.append(" PORTAL ");
}
if (chkWeb.isSelected())
{
sb.append(" WEB ");
}
gi.setPillar(sb.toString());
}
private void chkPillarActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
JCheckBox chk = ((JCheckBox)evt.getSource());
String pillarText = chk.getText();
if (gi.getPillar().contains(pillarText))
{
if (chk.isSelected() == false)
{
gi.setPillar(gi.getPillar().replace(" " + pillarText + " ",""));
}
} else
{
if (chk.isSelected())
{
gi.setPillar(gi.getPillar() + " " + pillarText + " ");
}
}
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btnAddModifiedFile;
private javax.swing.JButton btnCancel;
private javax.swing.JButton btnFindBA;
private javax.swing.JButton btnSave;
private javax.swing.JButton btnTodayDate;
private javax.swing.JCheckBox chkCRM;
private javax.swing.JCheckBox chkCS;
private javax.swing.JCheckBox chkFIN;
private javax.swing.JCheckBox chkNotifyOS;
private javax.swing.JCheckBox chkNotifyPortal;
private javax.swing.JCheckBox chkNotifySD;
private javax.swing.JCheckBox chkPortal;
private javax.swing.JCheckBox chkSecurity;
private javax.swing.JCheckBox chkTechReview;
private javax.swing.JCheckBox chkWeb;
private javax.swing.JButton jButton2;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JScrollPane jScrollPane3;
private javax.swing.JList lstChangedFiles;
private javax.swing.JTextField txtBA;
private javax.swing.JTextArea txtDescription;
private javax.swing.JTextArea txtPurpose;
private javax.swing.JTextField txtReqDate;
private javax.swing.JTextField txtRequestor;
private javax.swing.JTextField txtTicketNumber;
// End of variables declaration//GEN-END:variables
}