Package edu.bellevue.its.migration.gui.frames.developer

Source Code of edu.bellevue.its.migration.gui.frames.developer.EditRequestFrame

/*
* 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.Fileattachment;
import edu.bellevue.its.migration.entities.Generalinfo;
import edu.bellevue.its.migration.entities.Peerreview;
import edu.bellevue.its.migration.entities.Request;
import edu.bellevue.its.migration.entities.Securityoverview;
import edu.bellevue.its.migration.entities.Techoverview;
import edu.bellevue.its.migration.global.AppGlobals;
import edu.bellevue.its.migration.global.AppHelper;
import edu.bellevue.its.migration.gui.MainApp;
import edu.bellevue.its.migration.gui.frames.UpdateableFrame;
import edu.bellevue.its.migration.gui.frames.UpdateableFrame;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.criterion.Restrictions;

/**
*
* @author tslater
*/
public class EditRequestFrame extends javax.swing.JInternalFrame implements UpdateableFrame {

    /**
     * Creates new form EditRequestFrame
     */
   
    private Request currentRequest;
   
    public EditRequestFrame() {
        initComponents();
       
        currentRequest = new Request();
       
        currentRequest.setGeneralinfo(new Generalinfo());
        currentRequest.setPeerreview(new Peerreview());
        currentRequest.setSecurityoverview(new Securityoverview());
        currentRequest.setTechoverview(new Techoverview());
        currentRequest.setUser(AppGlobals.getInstance().loggedInUser);
       
        currentRequest.getGeneralinfo().getRequests().add(currentRequest);
        currentRequest.getPeerreview().getRequests().add(currentRequest);
        currentRequest.getSecurityoverview().getRequests().add(currentRequest);
        currentRequest.getTechoverview().getRequests().add(currentRequest);
       
        initDisplayFields();
        this.title = "Create New Request";
    }

    public EditRequestFrame(int requestId)
    {
        initComponents();
        Session s = AppGlobals.getInstance().hibernateSession;
        currentRequest = (Request) s.createCriteria(Request.class).add(Restrictions.eq("idRequest",requestId)).uniqueResult();
       
        initDisplayFields();
       
        this.title = "Edit Request #" + requestId;
    }
   
    public void updateView()
    {
        initDisplayFields();
       
        btnGeneralInfo.setEnabled(true);
        btnPeerReview.setEnabled(true);
        btnSecurityOverview.setEnabled(true);
        btnTechOverview.setEnabled(true);
       
    }
   
    private void initDisplayFields()
    {
        txtRequestor.setText(AppHelper.getUserDisplayName(currentRequest.getUser()));
       
        Peerreview review = currentRequest.getPeerreview();
        if (review != null)
        {
            boolean reviewed = (review.getIdPeerReview() != null);
            if (reviewed)
            {
                txtPeerReview.setText("Reviewed");
            } else
            {
                txtPeerReview.setText("Needs Review");
            }
        }
       
        Generalinfo gi = currentRequest.getGeneralinfo();
       
        if (gi != null)
        {
            if (gi.getRequestedDate() == null)
            {
                txtGeneralInfo.setText("Incomplete");
            } else
            {
                txtGeneralInfo.setText("Completed");
            }
            if (gi.getSecurityRequired()!= null && gi.getSecurityRequired().equals("Y"))
            {
                btnSecurityOverview.setEnabled(true);
                Securityoverview so = currentRequest.getSecurityoverview();
               
                if (so != null)
                {
                    boolean approved = (so.getSecurityApprover() > 0);
                    if (approved)
                    {
                        txtSecurityOverview.setText("Approved");
                    } else
                    {
                        txtSecurityOverview.setText("Needs Approval");
                    }
                }
               
            } else
            {
                btnSecurityOverview.setEnabled(false);
                txtSecurityOverview.setText("Not Required");
            }

            if (gi.getTechReviewReq() != null && gi.getTechReviewReq().equals("Y"))
            {
                txtTechOverview.setText("Review Required");
            } else
            {
                txtTechOverview.setText("No Review Required");
            }
        }
       
    }
    /**
     * 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();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        txtRequestor = new javax.swing.JTextField();
        txtGeneralInfo = new javax.swing.JTextField();
        txtTechOverview = new javax.swing.JTextField();
        txtSecurityOverview = new javax.swing.JTextField();
        txtPeerReview = new javax.swing.JTextField();
        cmbRequestType = new javax.swing.JComboBox();
        btnGeneralInfo = new javax.swing.JButton();
        btnTechOverview = new javax.swing.JButton();
        btnSecurityOverview = new javax.swing.JButton();
        btnPeerReview = new javax.swing.JButton();
        jButton5 = new javax.swing.JButton();
        jButton6 = new javax.swing.JButton();

        setClosable(true);
        setIconifiable(true);
        setResizable(true);

        jLabel1.setText("General Information: ");
        jLabel1.setToolTipText("");

        jLabel2.setText("Technical Overview: ");

        jLabel3.setText("Security Overview: ");

        jLabel4.setText("Peer Review: ");

        jLabel5.setText("Requestor: ");

        jLabel6.setText("Request Type: ");

        txtRequestor.setEditable(false);

        txtGeneralInfo.setEditable(false);

        txtTechOverview.setEditable(false);

        txtSecurityOverview.setEditable(false);

        txtPeerReview.setEditable(false);

        cmbRequestType.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        btnGeneralInfo.setText("->");
        btnGeneralInfo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnGeneralInfoActionPerformed(evt);
            }
        });

        btnTechOverview.setText("->");
        btnTechOverview.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnTechOverviewActionPerformed(evt);
            }
        });

        btnSecurityOverview.setText("->");
        btnSecurityOverview.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSecurityOverviewActionPerformed(evt);
            }
        });

        btnPeerReview.setText("->");
        btnPeerReview.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPeerReviewActionPerformed(evt);
            }
        });

        jButton5.setText("Save");
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });

        jButton6.setText("Cancel");

        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)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel5)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel1)
                                .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(jLabel4, javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(jLabel6, javax.swing.GroupLayout.Alignment.TRAILING)))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(txtRequestor)
                            .addComponent(txtGeneralInfo, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE)
                            .addComponent(txtTechOverview, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE)
                            .addComponent(txtSecurityOverview, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE)
                            .addComponent(txtPeerReview, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE)
                            .addComponent(cmbRequestType, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jButton5)
                        .addGap(18, 18, 18)
                        .addComponent(jButton6)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btnGeneralInfo)
                    .addComponent(btnTechOverview)
                    .addComponent(btnSecurityOverview)
                    .addComponent(btnPeerReview))
                .addContainerGap(62, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(22, 22, 22)
                .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))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(txtGeneralInfo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnGeneralInfo))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(txtTechOverview, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnTechOverview))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(txtSecurityOverview, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnSecurityOverview))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(txtPeerReview, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnPeerReview))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(cmbRequestType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton5)
                    .addComponent(jButton6))
                .addContainerGap(62, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnGeneralInfoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGeneralInfoActionPerformed
        // TODO add your handling code here:
        EditGeneralInfoFrame egif = new EditGeneralInfoFrame(this, currentRequest.getGeneralinfo());
        MainApp.getDesktop().add(egif);
        egif.setVisible(true);
        btnGeneralInfo.setEnabled(false);
    }//GEN-LAST:event_btnGeneralInfoActionPerformed

    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
        // TODO add your handling code here:
        Session s = AppGlobals.getInstance().hibernateSession;
        Transaction t = s.beginTransaction();
            s.save(currentRequest.getSecurityoverview());
            s.save(currentRequest.getGeneralinfo());
            s.save(currentRequest.getPeerreview());
            s.save(currentRequest.getTechoverview());
           
            if (currentRequest.getTechoverview().getFileattachments() != null)
            {
                Fileattachment[] files = currentRequest.getTechoverview().getFileattachments().toArray(new Fileattachment[0]);
                for (Fileattachment f : files)
                {
                    s.save(f);
                }
            }
           
            if (currentRequest.getSecurityoverview().getFileattachments() != null)
            {
                Fileattachment[] files = currentRequest.getSecurityoverview().getFileattachments().toArray(new Fileattachment[0]);
                for (Fileattachment f : files)
                {
                    s.save(f);
                }
            }
           
            s.save(currentRequest);
        t.commit();
    }//GEN-LAST:event_jButton5ActionPerformed

    private void btnTechOverviewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTechOverviewActionPerformed
        // TODO add your handling code here:
        EditTechnicalOverviewFrame etof = new EditTechnicalOverviewFrame(this, currentRequest.getTechoverview());
        MainApp.getDesktop().add(etof);
        etof.setVisible(true);
        btnTechOverview.setEnabled(false);
    }//GEN-LAST:event_btnTechOverviewActionPerformed

    private void btnSecurityOverviewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSecurityOverviewActionPerformed
        // TODO add your handling code here:
        EditSecurityOverviewFrame esof = new EditSecurityOverviewFrame(this, currentRequest.getSecurityoverview(),false);
        MainApp.getDesktop().add(esof);
        esof.setVisible(true);
        btnSecurityOverview.setEnabled(false);
    }//GEN-LAST:event_btnSecurityOverviewActionPerformed

    private void btnPeerReviewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPeerReviewActionPerformed
        // TODO add your handling code here:
        boolean readonly = currentRequest.getUser().getUserName().equals(AppGlobals.getInstance().loggedInUser.getUserName());
       
        EditPeerReviewFrame eprf = new EditPeerReviewFrame(this, currentRequest.getPeerreview(),readonly);
        MainApp.getDesktop().add(eprf);
        eprf.setVisible(true);
        btnPeerReview.setEnabled(false);
    }//GEN-LAST:event_btnPeerReviewActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnGeneralInfo;
    private javax.swing.JButton btnPeerReview;
    private javax.swing.JButton btnSecurityOverview;
    private javax.swing.JButton btnTechOverview;
    private javax.swing.JComboBox cmbRequestType;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    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.JTextField txtGeneralInfo;
    private javax.swing.JTextField txtPeerReview;
    private javax.swing.JTextField txtRequestor;
    private javax.swing.JTextField txtSecurityOverview;
    private javax.swing.JTextField txtTechOverview;
    // End of variables declaration//GEN-END:variables
}
TOP

Related Classes of edu.bellevue.its.migration.gui.frames.developer.EditRequestFrame

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.