Package event_manager.views

Source Code of event_manager.views.View

package event_manager.views;

import event_manager.controllers.ClientsController;
import event_manager.controllers.EventsController;
import event_manager.controllers.StaffsController;
import event_manager.helpers.ViewHelper;
import event_manager.models.Client;
import event_manager.models.Event;
import event_manager.models.Staff;
import event_manager.views.forms.UpdateRateForm;
import event_manager.views.panels.ListPanel;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Toolkit;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.EtchedBorder;

/**
*
* @author uzzaldevkota
*/
public class View extends javax.swing.JFrame implements ViewInterface {

    private int tabIndex = 0;
    private final List openTabs = new ArrayList<String>();

    /**
     * Creates new form View
     */
    public View() {
        initComponents();
        setTitle(ViewHelper.getTitle(View.class.getSimpleName()));
        setLocationRelativeTo(null);
        openTabs.add(tabIndex, this.getName());
    }

    public View maximize() {
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        setBounds(0,0,screenSize.width, screenSize.height);
        return this;
    }
   
    /**
     * 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() {

        homePanel = new javax.swing.JPanel();
        homeButtonsPanel = new javax.swing.JPanel();
        updateRatesButton = new javax.swing.JButton();
        listStaffsButton = new javax.swing.JButton();
        listEventsButton = new javax.swing.JButton();
        closeButton = new javax.swing.JButton();
        newEventButton = new javax.swing.JButton();
        newStaffButton = new javax.swing.JButton();
        newClientButton = new javax.swing.JButton();
        listClientsButton = new javax.swing.JButton();
        jSeparator1 = new javax.swing.JSeparator();
        mainTabbedPane = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        menuBar = new javax.swing.JMenuBar();
        fileMenu = new javax.swing.JMenu();
        exitMenuItem = new javax.swing.JMenuItem();
        eventMenu = new javax.swing.JMenu();
        listEventsMenuItem = new javax.swing.JMenuItem();
        newEventMenuItem = new javax.swing.JMenuItem();
        clientMenu = new javax.swing.JMenu();
        listClientsMenuItem = new javax.swing.JMenuItem();
        newClientMenuItem = new javax.swing.JMenuItem();
        staffMenu = new javax.swing.JMenu();
        listStaffsMenuItem = new javax.swing.JMenuItem();
        newStaffMenuItem = new javax.swing.JMenuItem();
        helpMenu = new javax.swing.JMenu();
        aboutMenuItem = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        homePanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "ISS - Event Manager", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Abadi MT Condensed Extra Bold", 0, 18))); // NOI18N

        updateRatesButton.setFont(new java.awt.Font("Abadi MT Condensed Extra Bold", 0, 18)); // NOI18N
        updateRatesButton.setText("Update Rates");
        updateRatesButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                updateRatesButtonActionPerformed(evt);
            }
        });

        listStaffsButton.setFont(new java.awt.Font("Abadi MT Condensed Extra Bold", 0, 18)); // NOI18N
        listStaffsButton.setText("List Staffs");
        listStaffsButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                listStaffsButtonActionPerformed(evt);
            }
        });

        listEventsButton.setFont(new java.awt.Font("Abadi MT Condensed Extra Bold", 0, 18)); // NOI18N
        listEventsButton.setText("List Events");
        listEventsButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                listEventsButtonActionPerformed(evt);
            }
        });

        closeButton.setFont(new java.awt.Font("Abadi MT Condensed Extra Bold", 0, 18)); // NOI18N
        closeButton.setText("Close");
        closeButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                closeButtonActionPerformed(evt);
            }
        });

        newEventButton.setFont(new java.awt.Font("Abadi MT Condensed Extra Bold", 0, 18)); // NOI18N
        newEventButton.setText("New Event");
        newEventButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                newEventButtonActionPerformed(evt);
            }
        });

        newStaffButton.setFont(new java.awt.Font("Abadi MT Condensed Extra Bold", 0, 18)); // NOI18N
        newStaffButton.setText("New Staff");
        newStaffButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                newStaffButtonActionPerformed(evt);
            }
        });

        newClientButton.setFont(new java.awt.Font("Abadi MT Condensed Extra Bold", 0, 18)); // NOI18N
        newClientButton.setText("New Client");
        newClientButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                newClientButtonActionPerformed(evt);
            }
        });

        listClientsButton.setFont(new java.awt.Font("Abadi MT Condensed Extra Bold", 0, 18)); // NOI18N
        listClientsButton.setText("List Clients");
        listClientsButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                listClientsButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout homeButtonsPanelLayout = new javax.swing.GroupLayout(homeButtonsPanel);
        homeButtonsPanel.setLayout(homeButtonsPanelLayout);
        homeButtonsPanelLayout.setHorizontalGroup(
            homeButtonsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(homeButtonsPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(homeButtonsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(listEventsButton, javax.swing.GroupLayout.PREFERRED_SIZE, 163, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(listStaffsButton, javax.swing.GroupLayout.PREFERRED_SIZE, 163, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(newEventButton, javax.swing.GroupLayout.PREFERRED_SIZE, 163, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(updateRatesButton, javax.swing.GroupLayout.PREFERRED_SIZE, 163, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(closeButton, javax.swing.GroupLayout.PREFERRED_SIZE, 163, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(newStaffButton, javax.swing.GroupLayout.PREFERRED_SIZE, 163, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(newClientButton, javax.swing.GroupLayout.PREFERRED_SIZE, 163, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(listClientsButton, javax.swing.GroupLayout.PREFERRED_SIZE, 163, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        homeButtonsPanelLayout.setVerticalGroup(
            homeButtonsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(homeButtonsPanelLayout.createSequentialGroup()
                .addGap(20, 20, 20)
                .addComponent(listEventsButton, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(listStaffsButton, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(listClientsButton, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(newEventButton, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(newStaffButton, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(newClientButton, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(updateRatesButton, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(closeButton, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jSeparator1.setOrientation(javax.swing.SwingConstants.VERTICAL);

        mainTabbedPane.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                mainTabbedPaneMouseClicked(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 512, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 441, Short.MAX_VALUE)
        );

        mainTabbedPane.addTab("Home", jPanel1);

        javax.swing.GroupLayout homePanelLayout = new javax.swing.GroupLayout(homePanel);
        homePanel.setLayout(homePanelLayout);
        homePanelLayout.setHorizontalGroup(
            homePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(homePanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(homeButtonsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(12, 12, 12)
                .addComponent(mainTabbedPane)
                .addContainerGap())
        );
        homePanelLayout.setVerticalGroup(
            homePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, homePanelLayout.createSequentialGroup()
                .addGroup(homePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(homeButtonsPanel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(mainTabbedPane)
                    .addComponent(jSeparator1))
                .addContainerGap())
        );

        menuBar.setForeground(new java.awt.Color(51, 51, 51));

        fileMenu.setMnemonic('f');
        fileMenu.setText("File");

        exitMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F4, java.awt.event.InputEvent.ALT_MASK));
        exitMenuItem.setMnemonic('x');
        exitMenuItem.setText("Exit");
        exitMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                exitMenuItemActionPerformed(evt);
            }
        });
        fileMenu.add(exitMenuItem);

        menuBar.add(fileMenu);

        eventMenu.setMnemonic('e');
        eventMenu.setText("Event");

        listEventsMenuItem.setMnemonic('l');
        listEventsMenuItem.setText("List Events");
        listEventsMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                listEventsMenuItemActionPerformed(evt);
            }
        });
        eventMenu.add(listEventsMenuItem);

        newEventMenuItem.setMnemonic('n');
        newEventMenuItem.setText("New Event");
        newEventMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                newEventMenuItemActionPerformed(evt);
            }
        });
        eventMenu.add(newEventMenuItem);

        menuBar.add(eventMenu);

        clientMenu.setMnemonic('c');
        clientMenu.setText("Client");

        listClientsMenuItem.setMnemonic('l');
        listClientsMenuItem.setText("List Clients");
        listClientsMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                listClientsMenuItemActionPerformed(evt);
            }
        });
        clientMenu.add(listClientsMenuItem);

        newClientMenuItem.setMnemonic('n');
        newClientMenuItem.setText("New Client");
        newClientMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                newClientMenuItemActionPerformed(evt);
            }
        });
        clientMenu.add(newClientMenuItem);

        menuBar.add(clientMenu);

        staffMenu.setMnemonic('s');
        staffMenu.setText("Staff");

        listStaffsMenuItem.setMnemonic('l');
        listStaffsMenuItem.setText("List Staffs");
        listStaffsMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                listStaffsMenuItemActionPerformed(evt);
            }
        });
        staffMenu.add(listStaffsMenuItem);

        newStaffMenuItem.setMnemonic('n');
        newStaffMenuItem.setText("New Staff");
        newStaffMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                newStaffMenuItemActionPerformed(evt);
            }
        });
        staffMenu.add(newStaffMenuItem);

        menuBar.add(staffMenu);

        helpMenu.setMnemonic('h');
        helpMenu.setText("Help");

        aboutMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F1, 0));
        aboutMenuItem.setMnemonic('a');
        aboutMenuItem.setText("About");
        aboutMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                aboutMenuItemActionPerformed(evt);
            }
        });
        helpMenu.add(aboutMenuItem);

        menuBar.add(helpMenu);

        setJMenuBar(menuBar);

        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()
                .addComponent(homePanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(homePanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

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

    private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitMenuItemActionPerformed
        System.exit(0);
    }//GEN-LAST:event_exitMenuItemActionPerformed

    private void aboutMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_aboutMenuItemActionPerformed
        ViewHelper.showAbout();
    }//GEN-LAST:event_aboutMenuItemActionPerformed

    private void listStaffsMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_listStaffsMenuItemActionPerformed
        listStaffs();
    }//GEN-LAST:event_listStaffsMenuItemActionPerformed

    private void newStaffMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newStaffMenuItemActionPerformed
        newStaff();
    }//GEN-LAST:event_newStaffMenuItemActionPerformed

    private void listClientsMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_listClientsMenuItemActionPerformed
        listClients();
    }//GEN-LAST:event_listClientsMenuItemActionPerformed

    private void newClientMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newClientMenuItemActionPerformed
        newClient();
    }//GEN-LAST:event_newClientMenuItemActionPerformed

    private void listEventsMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_listEventsMenuItemActionPerformed
        listEvents();
    }//GEN-LAST:event_listEventsMenuItemActionPerformed

    private void newEventMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newEventMenuItemActionPerformed
        newEvent();
    }//GEN-LAST:event_newEventMenuItemActionPerformed

    private void listEventsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_listEventsButtonActionPerformed
        listEvents();
    }//GEN-LAST:event_listEventsButtonActionPerformed

    private void listStaffsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_listStaffsButtonActionPerformed
        listStaffs();
    }//GEN-LAST:event_listStaffsButtonActionPerformed

    private void updateRatesButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_updateRatesButtonActionPerformed
        new UpdateRateForm(this, true).setVisible(true);
    }//GEN-LAST:event_updateRatesButtonActionPerformed

    private void closeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_closeButtonActionPerformed
        System.exit(0);
    }//GEN-LAST:event_closeButtonActionPerformed

    private void mainTabbedPaneMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_mainTabbedPaneMouseClicked
        if(evt.getClickCount() > 1) {
            closeTab(mainTabbedPane.getSelectedIndex());
        }
    }//GEN-LAST:event_mainTabbedPaneMouseClicked

    private void newEventButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newEventButtonActionPerformed
        newEvent();
    }//GEN-LAST:event_newEventButtonActionPerformed

    private void newStaffButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newStaffButtonActionPerformed
        newStaff();
    }//GEN-LAST:event_newStaffButtonActionPerformed

    private void newClientButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newClientButtonActionPerformed
        newClient();
    }//GEN-LAST:event_newClientButtonActionPerformed

    private void listClientsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_listClientsButtonActionPerformed
        listClients();
    }//GEN-LAST:event_listClientsButtonActionPerformed

    // Called in controller::index method
    @Override
    public void show(String panelName, int panelId) {
        if(openTabs.contains(panelName)) {
            showTab(panelName);
        } else if(openTabs.size() > ViewHelper.TAB_LIMIT) {
            ViewHelper.showDialog("Too many tabs, close some.");
        } else {
            newTab(panelName, panelId);
        }
    }

    private void showTab(String panelName) {
        int index = openTabs.indexOf(panelName);
        mainTabbedPane.setSelectedIndex(index);
    }

    private void newTab(final String panelName, int panelId) {
        Component panel = null;
        switch(panelId) {
            case ViewHelper.LIST_EVENT:
                panel = new ListPanel(new EventsController(), new Event(), this);
                break;
            case ViewHelper.LIST_STAFF:
                panel = new ListPanel(new StaffsController(), new Staff(), this);
                break;
            case ViewHelper.LIST_CLIENT:
                panel = new ListPanel(new ClientsController(), new Client(), this);
                break;
            default:
                ViewHelper.showDialog("I don't know that panel");
        }
        mainTabbedPane.add(panel);
//        homeTabbedPane.addTab(panelName, panel);
        mainTabbedPane.setSelectedIndex(++tabIndex);
        mainTabbedPane.setTitleAt(tabIndex, panelName);

        // Tab Component
        JPanel pnlTab = new JPanel(new GridBagLayout());
        pnlTab.setOpaque(false);
        JLabel lblTitle = new JLabel("                   ");
        final JButton btnClose = new JButton("x");
        btnClose.setBorder(null);
        btnClose.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseEntered(MouseEvent evt) {
                btnClose.setBorder(new EtchedBorder());
            }
            @Override
            public void mouseExited(MouseEvent evt) {
                btnClose.setBorder(null);
            }

            @Override
            public void mouseClicked(MouseEvent evt) {
                closeTab(mainTabbedPane.indexOfTab(panelName));
            }
        });

        GridBagConstraints gbc = new GridBagConstraints();
        gbc.gridx = 1;
        gbc.gridy = 0;
        gbc.weightx = 1;
        pnlTab.add(lblTitle, gbc);

        gbc.gridx++;
        gbc.weightx = 0;
        pnlTab.add(btnClose, gbc);

        mainTabbedPane.setTabComponentAt(tabIndex, pnlTab);

        openTabs.add(tabIndex, panelName);
    }

    private void closeTab(int index) {
        if(index > 0) {
            mainTabbedPane.remove(index);
            openTabs.remove(index);
            tabIndex--;
        }
    }

    // View to controller mapping functions
    private void listEvents() {
        new EventsController().index(this);
    }

    private void listStaffs() {
        new StaffsController().index(this);
    }

    private void listClients() {
        new ClientsController().index(this);
    }

    private void newEvent() {
        new EventsController().createNew(this);
    }

    private void newStaff() {
        new StaffsController().createNew(this);
    }

    private void newClient() {
        new ClientsController().createNew(this);
    }
   
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuItem aboutMenuItem;
    private javax.swing.JMenu clientMenu;
    private javax.swing.JButton closeButton;
    private javax.swing.JMenu eventMenu;
    private javax.swing.JMenuItem exitMenuItem;
    private javax.swing.JMenu fileMenu;
    private javax.swing.JMenu helpMenu;
    private javax.swing.JPanel homeButtonsPanel;
    private javax.swing.JPanel homePanel;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JButton listClientsButton;
    private javax.swing.JMenuItem listClientsMenuItem;
    private javax.swing.JButton listEventsButton;
    private javax.swing.JMenuItem listEventsMenuItem;
    private javax.swing.JButton listStaffsButton;
    private javax.swing.JMenuItem listStaffsMenuItem;
    private javax.swing.JTabbedPane mainTabbedPane;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JButton newClientButton;
    private javax.swing.JMenuItem newClientMenuItem;
    private javax.swing.JButton newEventButton;
    private javax.swing.JMenuItem newEventMenuItem;
    private javax.swing.JButton newStaffButton;
    private javax.swing.JMenuItem newStaffMenuItem;
    private javax.swing.JMenu staffMenu;
    private javax.swing.JButton updateRatesButton;
    // End of variables declaration//GEN-END:variables

}
TOP

Related Classes of event_manager.views.View

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.