package cz.cvut.fel.restauracefel.smeny.smeny_gui; import java.io.FileNotFoundException; import java.rmi.NotBoundException; import java.rmi.RemoteException; import java.util.logging.Level; import java.util.logging.Logger; import cz.cvut.fel.restauracefel.library.service.EmptyListException; import cz.cvut.fel.restauracefel.smeny.SmenyController.SmenyController; /** * Trida vytvarejici dialog pro vyber uzivatele, ktery bude prihlasen na smenu. * * @author Martin Kosek */ public class ChooseEmployeeDialog extends AbstractDialog { private int rowNumber; //index of saved userId in table private OverviewLeaderShiftForm parent; /** * Konstruktor tridy ChooseEmployeeDialog * * @param mainFrame instance tridy MainFrame jenz vytvorila tento formular * @param modal * @param rowNumber cislo zvoleneho radku z tabulky se smenami * @param table odkaz na tabulku se smenami * * @throws java.rmi.RemoteException * @throws java.rmi.NotBoundException * @throws java.io.FileNotFoundException */ public ChooseEmployeeDialog(MainFrame mainFrame, boolean modal, int rowNumber, OverviewLeaderShiftForm parent) throws EmptyListException, RemoteException, NotBoundException, FileNotFoundException { super(mainFrame, modal); this.rowNumber = rowNumber; this.parent = parent; initComponents(); setDefaultCloseOperation(DISPOSE_ON_CLOSE); refresh(); } /** * Metoda provadi aktualizaci seznamu vsech vsech zamestnancu. * * @throws java.rmi.RemoteException * @throws java.rmi.NotBoundException * @throws java.io.FileNotFoundException */ protected void refresh() throws EmptyListException, RemoteException, NotBoundException, FileNotFoundException { SmenyController.getInstance().generateDataListEmployees(); jListEmployees.setListData(SmenyController.getInstance().getDataListEmployees()); } /** 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() { jPanel1 = new javax.swing.JPanel(); jScrollPane1 = new javax.swing.JScrollPane(); jListEmployees = new javax.swing.JList(); jButtonBack = new javax.swing.JButton(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setModal(true); setResizable(false); setUndecorated(true); jPanel1.setBackground(new java.awt.Color(255, 255, 255)); jPanel1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED)); jScrollPane1.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); jListEmployees.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N jListEmployees.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); jListEmployees.setAlignmentX(2.0F); jListEmployees.setFixedCellHeight(50); jListEmployees.setFixedCellWidth(400); jListEmployees.setFocusCycleRoot(true); jListEmployees.setLayoutOrientation(javax.swing.JList.HORIZONTAL_WRAP); jListEmployees.setSelectionBackground(javax.swing.UIManager.getDefaults().getColor("InternalFrame.inactiveTitleGradient")); jListEmployees.setVisibleRowCount(-1); jListEmployees.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { clicked(evt); } }); jScrollPane1.setViewportView(jListEmployees); jButtonBack.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cz/cvut/fel/restauracefel/buttons/ko.png"))); // NOI18N jButtonBack.setText(" Zavřít"); jButtonBack.setToolTipText("Vymazat pole stůl"); jButtonBack.setBorder(null); jButtonBack.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonBackActionPerformed(evt); } }); jLabel1.setFont(new java.awt.Font("Tahoma", 1, 18)); jLabel1.setText("Přihlásit zaměstnance"); jLabel2.setText("Kliknutím přihlásíte zaměstnance ke směně"); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(20, 20, 20) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 371, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel1))) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() .addContainerGap(31, Short.MAX_VALUE) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 419, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButtonBack, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(206, 206, 206))) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(18, 18, 18) .addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jLabel2) .addGap(18, 18, 18) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 262, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(30, 30, 30) .addComponent(jButtonBack, javax.swing.GroupLayout.PREFERRED_SIZE, 60, 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) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 479, javax.swing.GroupLayout.PREFERRED_SIZE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) ); pack(); }// </editor-fold>//GEN-END:initComponents private void jButtonBackActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonBackActionPerformed dispose(); }//GEN-LAST:event_jButtonBackActionPerformed private void clicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_clicked int userIndexId = jListEmployees.getSelectedIndex(); try { SmenyController.getInstance().saveUserToWorkShift(userIndexId, this.rowNumber); parent.reloadTable(parent.getCurrentFilter()); } catch (FileNotFoundException ex) { Logger.getLogger(ChooseEmployeeDialog.class.getName()).log(Level.SEVERE, null, ex); } catch (NotBoundException ex) { Logger.getLogger(ChooseEmployeeDialog.class.getName()).log(Level.SEVERE, null, ex); } catch (RemoteException ex) { Logger.getLogger(ChooseEmployeeDialog.class.getName()).log(Level.SEVERE, null, ex); } dispose(); }//GEN-LAST:event_clicked // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton jButtonBack; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JList jListEmployees; private javax.swing.JPanel jPanel1; private javax.swing.JScrollPane jScrollPane1; // End of variables declaration//GEN-END:variables }