Package clips.kek.committee

Source Code of clips.kek.committee.PanelEditCommittee

/*
* PanelEditCommittee.java
*
* Created on 24 Апрель 2008 г., 14:53
*/

package clips.kek.committee;
import beans.cec.entity.CommitteeResolutionDetails;
import cli_fmw.delegate.DelegateLine2;
import cli_fmw.delegate.lists.DataChunk;
import clips.kek.resolution.TableModelComResolutionList;
import clips.kek.resolution.ComResDlg;
import clips.kek.direction.TableModelDirMemList;
import clips.kek.direction.TableCellRendererDirectionList;
import clips.delegate.doctor.direction.DirectionLocal;
import cli_fmw.main.ClipsException;
import clips.delegate.kek.CommitteeDirectionData;
import clips.delegate.kek.CommitteeLocal;
import clips.delegate.kek.CommitteeMemberData;
import clips.delegate.kek.CommitteeResolutionData;
import clips.delegate.kek.InabilityData;
import clips.directory.dialogs.collaborators.DirectoryDialogCollaborators;
import clips.kek.inability.DlgInabilityEdit;
import clips.kek.inability.TableModelInabilityList;
import clips.kek.resolution.TableCellRendererResolutionList;
import cli_fmw.main.ContentStateListener;
import cli_fmw.main.MainWindow;
import cli_fmw.main.PageContainer;
import cli_fmw.main.PageGeneric;
import cli_fmw.main.Persistentable;
import cli_fmw.main.Printable;
import cli_fmw.main.PageGeneric;
import cli_fmw.utils.Selector;
import cli_fmw.utils.SelectorEditable;
import cli_fmw.utils.MessageBox;
import cli_fmw.utils.ModalDialog;
import cli_fmw.utils.delegate_models.DelegateDateModel;
import cli_fmw.utils.table_config_states.StateSaver;
import cli_fmw.utils.table_config_states.TableState;
import clips.delegate.directory.ro.DirectoryCollaboratorItem;
import clips.kek.direction.DlgDirectionSearch;
import clips.login.UserInfo;
import java.awt.Frame;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.ArrayList;
import java.util.Date;
import javax.swing.DefaultListModel;
import javax.swing.JTextField;
import javax.swing.ListSelectionModel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;

/**
*панель формирования состава и рассматриваемых направлений комиссии
* @author  lacoste
*/
public class PanelEditCommittee extends PageGeneric implements Persistentable, Printable {
   
    private CommitteeLocal committee;      //собственно сам делегат-комиссия
    private ArrayList<CommitteeDirectionData> comDirList;
    private ArrayList<CommitteeResolutionData> comResList;
    private ArrayList<InabilityData> inabilityList;
    private ArrayList<CommitteeMemberData> memberList;
    private ArrayList<DirectionLocal> directions = new ArrayList<DirectionLocal>();
   
    private boolean forceResolutions = false;
    private boolean forceInabilities = false;
   
    private ContentStateListener emptyListener = new ContentStateListener() {

        @Override
        public void contentStateChanged() {
        }
    };
  
    /**
     * Creates new form PanelEditCommittee
     * @param container
     * @param comittee
     * @throws ClipsException
     */
    public PanelEditCommittee(PageContainer container, CommitteeLocal comittee) throws ClipsException {
        super(container);
        initComponents();       
        this.committee = comittee;
       
        //слушатель для датачузера
        new DelegateDateModel<CommitteeLocal>(comittee, dateCom) {

            @Override
            protected Date getDateImp() throws ClipsException {
                return getDelegate().getDate();
            }

            @Override
            protected void setDateImp(Date date) throws ClipsException {
                getDelegate().setDate(date);
            }
        };
       
        tabDirectionList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

            @Override
            public void valueChanged(ListSelectionEvent e) {
               
                    int k = tabDirectionList.getSelectedRowSorted();
                   
                    if (k < 0) {
                        btDelDir.setEnabled(false);
                        btSetResolution.setEnabled(false);
                        btSetResolution.setText("Вынести решение");
                    }
                    else {
                        btDelDir.setEnabled(true);
                        btSetResolution.setEnabled(true);
                        try {
                            if (committee.getResolutionByDirection(comDirList.get(k)) != null) {
                                btSetResolution.setText("Просмотр решения");
                            }
                            else {
                                btSetResolution.setText("Вынести решение");
                            }
                        } catch (ClipsException ex) {
                            MessageBox.showException(ex);
                        }
                    }
                    fireContainerEventStateChanged();
            }
        });
       
        tabResolutionList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

            @Override
            public void valueChanged(ListSelectionEvent e) {
              
                    int k = tabResolutionList.getSelectedRowSorted();

                    if (k < 0) {
                        btDelResolution.setEnabled(false);
                        btSetComResRendered.setEnabled(false);
                        btComResView.setEnabled(false);
                        btSetInability.setEnabled(false);
                        btSetInability.setText("Направить на МСЭК");
                    }
                    else {
                        try {
                            if (comResList.get(k).isRendered()) {
                                btSetComResRendered.setEnabled(false);
                                if (committee.getInabilityByResolution(comResList.get(k)) != null) {
                                    btSetInability.setEnabled(true);
                                    btSetInability.setText("Просмотр направления на МСЭК");
                                }
                                else {
                                    btSetInability.setEnabled(false);
                                }
                            }
                            else {
                                btSetComResRendered.setEnabled(true);
                                btSetInability.setEnabled(true);
                                btSetInability.setText("Направить на МСЭК");
                            }
                        } catch (ClipsException ex) {
                            MessageBox.showException(ex);
                        }
                        btDelResolution.setEnabled(true);
                        btComResView.setEnabled(true);
                       
                    }
                    fireContainerEventStateChanged();
            }
        });
       
        tabInabilidityList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

            @Override
            public void valueChanged(ListSelectionEvent e) {
                btInabilityView.setEnabled(tabInabilidityList.getSelectedRowSorted() > -1);
                btInabilityDel.setEnabled(tabInabilidityList.getSelectedRowSorted() > -1);
                fireContainerEventStateChanged();
            }
        });
       
        jTabbedPane1.addChangeListener(new ChangeListener() {

            @Override
            public void stateChanged(ChangeEvent e) {
                fireContainerEventStateChanged();
            }
        });
       
        setScreenFields();
        tabDirectionList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION)
        tabResolutionList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION)
        tabInabilidityList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    resizeColumnDirections();
    resizeColumnResolutions();
    resizeColumnInabilities();
    StateSaver.attachTo(this);
    }
   
   
    private void setScreenFields() throws ClipsException {               
        reloadTableDirections();
        reloadTableResolutions();
        reloadTableInabilities();
        resetMemberListUI();
    }
   
    /**
     * Направления комиссии
     */
    private void formDirList() throws ClipsException {
        SelectorEditable<CommitteeDirectionData> list = committee.getDirectionList();
        comDirList = new ArrayList<CommitteeDirectionData>();
        for (int i = 0; i < list.size(); i++) {
            comDirList.add(list.get(i));
        }
    }
   
    private void reloadTableDirections() throws ClipsException {
        formDirList();
        tabDirectionList.setModel(new TableModelDirMemList(comDirList));       
        tabDirectionList.setDefaultRenderer(Object.class, new TableCellRendererDirectionList());       
    }
   
    private void resizeColumnDirections() {
    TableState          state = new TableState();
    state.setPreferredWidth(TableModelDirMemList.COL_DIRMEM_ID,    2);
    state.setPreferredWidth(TableModelDirMemList.COL_CLIENT,    11);
    state.setPreferredWidth(TableModelDirMemList.COL_DATE,      6);
    state.setPreferredWidth(TableModelDirMemList.COL_MKB,      11);
    state.setPreferredWidth(TableModelDirMemList.COL_REASON,    10);
    state.setPreferredWidth(TableModelDirMemList.COL_DESC,      10);
    state.setPreferredWidth(TableModelDirMemList.COL_COLLAB,    10);
      StateSaver.setDefaultState(this, tabDirectionList, state);
    }
   
    /**
     * Решения комиссии
     */
    private void formResList() throws ClipsException {       
        Selector<CommitteeResolutionData> list = committee.getResolutionList(forceResolutions);
        comResList = new ArrayList<CommitteeResolutionData>();
        for (int i = 0; i < list.size(); i ++) {
            comResList.add(list.get(i));
        }
        forceResolutions = false;
    }
   
    private void reloadTableResolutions() throws ClipsException {
        formResList();
        tabResolutionList.setModel(new TableModelComResolutionList(comResList, committee));
        tabResolutionList.setDefaultRenderer(Object.class, new TableCellRendererResolutionList(comResList));
    }
   
    private void resizeColumnResolutions() {
    TableState          state = new TableState();
    state.setPreferredWidth(TableModelComResolutionList.COL_RES_ID,    3);
    state.setPreferredWidth(TableModelComResolutionList.COL_TYPE,    12);
    state.setPreferredWidth(TableModelComResolutionList.COL_MKB,    14);
    state.setPreferredWidth(TableModelComResolutionList.COL_DESC,    13);
    state.setPreferredWidth(TableModelComResolutionList.COL_COLLAB,    13);
    state.setPreferredWidth(TableModelComResolutionList.COL_COMDIR_ID,  5);
      StateSaver.setDefaultState(this, tabResolutionList, state);
    }
   
    /**
     * Направления на МСЭК комиссии
     */
    private void formInabilityList() throws ClipsException {
        SelectorEditable<InabilityData> list = committee.getInabilityList(forceInabilities);
        inabilityList = new ArrayList<InabilityData>();
        for (int i = 0; i < list.size(); i++) {
            inabilityList.add(list.get(i));               
        }
        forceInabilities = false;
    }
   
    private void reloadTableInabilities() throws ClipsException {
        formInabilityList();
        tabInabilidityList.setModel(new TableModelInabilityList(inabilityList, committee));
    }
   
    private void resizeColumnInabilities() {
     TableState          state = new TableState();
    state.setPreferredWidth(TableModelInabilityList.COL_ID,      2);
    state.setPreferredWidth(TableModelInabilityList.COL_DATE_IN,  6);
    state.setPreferredWidth(TableModelInabilityList.COL_LEVEL_IN,  5);
    state.setPreferredWidth(TableModelInabilityList.COL_DATE_OUT,  6);
    state.setPreferredWidth(TableModelInabilityList.COL_LEVEL_OUT,  5);
    state.setPreferredWidth(TableModelInabilityList.COL_DESC,    8);
    state.setPreferredWidth(TableModelInabilityList.COL_RES_ID,    3);
      StateSaver.setDefaultState(this, tabInabilidityList, state);
    }
   
    /**
     * Члены комиссии
     */
    private void resetMemberListUI() throws ClipsException {
        DefaultListModel model = new DefaultListModel()
        SelectorEditable<CommitteeMemberData> list = committee.getMemberList();
        memberList = new ArrayList<CommitteeMemberData>();
        for (int i = 0; i < list.size(); i++) {
            memberList.add(list.get(i));
        }
        for (int i = 0; i < list.size(); i++) {
            model.addElement(memberList.get(i).getCollaborator());           
        }
        lstCollab.setModel(model);            
    }
   
    /** 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.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        dateCom = new org.infotechservice.ICalendar.components.ICDateChooser();
        jSplitPane1 = new javax.swing.JSplitPane();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        lstCollab = new javax.swing.JList();
        jPanel4 = new javax.swing.JPanel();
        addCollab = new javax.swing.JButton();
        removeCollab = new javax.swing.JButton();
        jPanel7 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jPanel8 = new javax.swing.JPanel();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        panelDirection = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        tabDirectionList = new cli_fmw.utils.sorted_table.SortedTable();
        jPanel5 = new javax.swing.JPanel();
        btAddDirections = new javax.swing.JButton();
        btDelDir = new javax.swing.JButton();
        btSetResolution = new javax.swing.JButton();
        panelResolution = new javax.swing.JPanel();
        jPanel9 = new javax.swing.JPanel();
        btComResView = new javax.swing.JButton();
        btSetComResRendered = new javax.swing.JButton();
        btDelResolution = new javax.swing.JButton();
        btSetInability = new javax.swing.JButton();
        jScrollPane3 = new javax.swing.JScrollPane();
        tabResolutionList = new cli_fmw.utils.sorted_table.SortedTable();
        panelInability = new javax.swing.JPanel();
        jPanel11 = new javax.swing.JPanel();
        btInabilityView = new javax.swing.JButton();
        btInabilityDel = new javax.swing.JButton();
        jScrollPane4 = new javax.swing.JScrollPane();
        tabInabilidityList = new cli_fmw.utils.sorted_table.SortedTable();

        jPanel1.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));

        jLabel1.setText("Дата комиссии:  ");
        jPanel1.add(jLabel1);

        dateCom.setPreferredSize(new java.awt.Dimension(120, 19));
        jPanel1.add(dateCom);

        jSplitPane1.setBorder(null);
        jSplitPane1.setDividerLocation(220);
        jSplitPane1.setDividerSize(5);

        jPanel2.setLayout(new java.awt.BorderLayout());

        jScrollPane1.setViewportView(lstCollab);

        jPanel2.add(jScrollPane1, java.awt.BorderLayout.CENTER);

        jPanel4.setLayout(new java.awt.GridLayout(1, 0, 5, 5));

        addCollab.setText("<html><Center>Добавить<br>врача</Center></html>");
        addCollab.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addCollabActionPerformed(evt);
            }
        });
        jPanel4.add(addCollab);

        removeCollab.setText("<html><Center>Удалить<br>врача</Center></html>");
        removeCollab.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                removeCollabActionPerformed(evt);
            }
        });
        jPanel4.add(removeCollab);

        jPanel2.add(jPanel4, java.awt.BorderLayout.SOUTH);

        jPanel7.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT, 0, 5));

        jLabel2.setText("Список членов комиссии:");
        jPanel7.add(jLabel2);

        jPanel2.add(jPanel7, java.awt.BorderLayout.PAGE_START);

        jSplitPane1.setLeftComponent(jPanel2);

        jPanel8.setLayout(new java.awt.BorderLayout());

        panelDirection.setName("panelDirection"); // NOI18N
        panelDirection.setLayout(new java.awt.BorderLayout());

        jScrollPane2.addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentResized(java.awt.event.ComponentEvent evt) {
                jScrollPane2ComponentResized(evt);
            }
        });
        jScrollPane2.setViewportView(tabDirectionList);

        panelDirection.add(jScrollPane2, java.awt.BorderLayout.CENTER);

        jPanel5.setPreferredSize(new java.awt.Dimension(610, 40));

        btAddDirections.setText("Добавить направления");
        btAddDirections.setPreferredSize(new java.awt.Dimension(220, 34));
        btAddDirections.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btAddDirectionsActionPerformed(evt);
            }
        });
        jPanel5.add(btAddDirections);

        btDelDir.setText("Удалить направление");
        btDelDir.setEnabled(false);
        btDelDir.setPreferredSize(new java.awt.Dimension(220, 34));
        btDelDir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btDelDirActionPerformed(evt);
            }
        });
        jPanel5.add(btDelDir);

        btSetResolution.setText("Вынести решение");
        btSetResolution.setEnabled(false);
        btSetResolution.setPreferredSize(new java.awt.Dimension(220, 34));
        btSetResolution.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btSetResolutionActionPerformed(evt);
            }
        });
        jPanel5.add(btSetResolution);

        panelDirection.add(jPanel5, java.awt.BorderLayout.PAGE_END);

        jTabbedPane1.addTab("Список направлений", panelDirection);

        panelResolution.setName("panelResolution"); // NOI18N
        panelResolution.setLayout(new java.awt.BorderLayout());

        btComResView.setText("Просмотреть решение");
        btComResView.setEnabled(false);
        btComResView.setPreferredSize(new java.awt.Dimension(180, 34));
        btComResView.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btComResViewActionPerformed(evt);
            }
        });
        jPanel9.add(btComResView);

        btSetComResRendered.setText("Погасить решение");
        btSetComResRendered.setEnabled(false);
        btSetComResRendered.setPreferredSize(new java.awt.Dimension(160, 34));
        btSetComResRendered.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btSetComResRenderedActionPerformed(evt);
            }
        });
        jPanel9.add(btSetComResRendered);

        btDelResolution.setText("Удалить решение");
        btDelResolution.setEnabled(false);
        btDelResolution.setPreferredSize(new java.awt.Dimension(150, 34));
        btDelResolution.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btDelResolutionActionPerformed(evt);
            }
        });
        jPanel9.add(btDelResolution);

        btSetInability.setText("Направить на МСЭК");
        btSetInability.setEnabled(false);
        btSetInability.setMaximumSize(new java.awt.Dimension(206, 29));
        btSetInability.setMinimumSize(new java.awt.Dimension(206, 29));
        btSetInability.setPreferredSize(new java.awt.Dimension(180, 34));
        btSetInability.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btSetInabilityActionPerformed(evt);
            }
        });
        jPanel9.add(btSetInability);

        panelResolution.add(jPanel9, java.awt.BorderLayout.PAGE_END);

        jScrollPane3.addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentResized(java.awt.event.ComponentEvent evt) {
                jScrollPane3ComponentResized(evt);
            }
        });

        tabResolutionList.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tabResolutionListMouseClicked(evt);
            }
        });
        jScrollPane3.setViewportView(tabResolutionList);

        panelResolution.add(jScrollPane3, java.awt.BorderLayout.CENTER);

        jTabbedPane1.addTab("Список решений", panelResolution);

        panelInability.setName("panelInability"); // NOI18N
        panelInability.setLayout(new java.awt.BorderLayout());

        btInabilityView.setText("Просмотреть направление на МСЭК");
        btInabilityView.setEnabled(false);
        btInabilityView.setPreferredSize(new java.awt.Dimension(290, 34));
        btInabilityView.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btInabilityViewActionPerformed(evt);
            }
        });
        jPanel11.add(btInabilityView);

        btInabilityDel.setText("Удалить направление на МСЭК");
        btInabilityDel.setEnabled(false);
        btInabilityDel.setPreferredSize(btInabilityView.getPreferredSize());
        btInabilityDel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btInabilityDelActionPerformed(evt);
            }
        });
        jPanel11.add(btInabilityDel);

        panelInability.add(jPanel11, java.awt.BorderLayout.PAGE_END);

        jScrollPane4.addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentResized(java.awt.event.ComponentEvent evt) {
                jScrollPane4ComponentResized(evt);
            }
        });

        tabInabilidityList.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tabInabilidityListMouseClicked(evt);
            }
        });
        jScrollPane4.setViewportView(tabInabilidityList);

        panelInability.add(jScrollPane4, java.awt.BorderLayout.CENTER);

        jTabbedPane1.addTab("Список направлений на МСЭК", panelInability);

        jPanel8.add(jTabbedPane1, java.awt.BorderLayout.CENTER);

        jSplitPane1.setRightComponent(jPanel8);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 944, Short.MAX_VALUE)
                    .addComponent(jSplitPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 944, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 391, Short.MAX_VALUE)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void addCollabActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addCollabActionPerformed
        try {
            DirectoryDialogCollaborators dlg = new DirectoryDialogCollaborators(false, true, false, null);
            dlg.setVisible(true);
            if (dlg.getDlgResult() == ModalDialog.DLG_OK) {
               Selector coll = dlg.getSelectedItems();
               DirectoryCollaboratorItem collaborator = (DirectoryCollaboratorItem) coll.get(0);
               boolean isIn = false;
               for (int i = 0; i < memberList.size(); i++) {
                   if (collaborator.getID() == memberList.get(i).getCollaborator().getID()) {
                       isIn = true;
                       break;
                   }
               }
               if (!isIn) {
                   CommitteeMemberData cm = new CommitteeMemberData(committee);
                   cm.setCollaborator(collaborator);
                   committee.getMemberList().append(cm);
                   resetMemberListUI();
               }
            }
        } catch (ClipsException ex) {
            MessageBox.showException(ex);
        }
    }//GEN-LAST:event_addCollabActionPerformed

    private void jScrollPane2ComponentResized(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_jScrollPane2ComponentResized

    }//GEN-LAST:event_jScrollPane2ComponentResized

    private void removeCollabActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeCollabActionPerformed
        if (lstCollab.getSelectedIndex() < 0) {
            MessageBox.showWarning(MessageBox.W_LIST_ELEMENT_NOT_SELECT);
            return;
        }
        try {
            committee.getMemberList().remove(lstCollab.getSelectedIndex());           
            resetMemberListUI();
        } catch(ClipsException e) {
            MessageBox.showException(e);
        }    
    }//GEN-LAST:event_removeCollabActionPerformed

   
    private void btSetResolutionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btSetResolutionActionPerformed
        try {
            int row = tabDirectionList.getSelectedRowSorted();
            if (row < 0) {
                return;
            }
            if (committee.getMemberList().size() == 0) {
                MessageBox.showWarning(MessageBox.W_COMMITTEE_NOT_MADE);
            }
            else {
                CommitteeDirectionData dirData = committee.getDirectionList().get(row);
                CommitteeResolutionData comResData = committee.getResolutionByDirection(dirData);
                if (comResData != null) {
                    jTabbedPane1.setSelectedComponent(panelResolution);
                    for (int i = 0; i < comResList.size(); i++) {
                        if (comResList.get(i).equals(comResData)) {
                            tabResolutionList.setRowSelectionInterval(i, i);
                            break;
                        }
                    }
                }
                else {
                    comResData = new CommitteeResolutionData(dirData);
                    ComResDlg dlg = new ComResDlg(MainWindow.mainWindow, comResData, getAuditManager());
                    dlg.setVisible(true);
                    if (dlg.getDlgResult() == ModalDialog.DLG_OK) {
                        comResData.setCollaborator(UserInfo.get().getCollaborator());
                        committee.getResolutionList(false).append(comResData);
                        DirectionLocal direction = dirData.getDirection(getAuditManager());
                        direction.addContentStateListener(emptyListener);
                        direction.setOrdered(true);
                        directions.add(direction);
                    }
                }
            }
        } catch (ClipsException ex) {           
            MessageBox.showException(ex);
        }       
}//GEN-LAST:event_btSetResolutionActionPerformed

    private void btAddDirectionsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btAddDirectionsActionPerformed
        try {
            DlgDirectionSearch dialog = new DlgDirectionSearch(MainWindow.mainWindow, committee);
            dialog.setVisible(true);
            if (dialog.getDlgResult() == ModalDialog.DLG_CANCEL) {
                return;
            }
            ArrayList<CommitteeDirectionData> list = dialog.getDirMemList();
            for (int i = 0; i < list.size(); i++) {
                DirectionLocal dir = list.get(i).getDirection(getAuditManager());
                boolean isIn = false;
                for (int j = 0; j < comDirList.size(); j++) {
                    if (dir.getID() == comDirList.get(j).getDetails().directionID) {
                        isIn = true;                       
                    }
                }
                if (!isIn) {
                    committee.getDirectionList().append(list.get(i));                   
                }
            }
            reloadTableDirections();
        } catch (ClipsException ex) {
            MessageBox.showException(ex);
        }
    }//GEN-LAST:event_btAddDirectionsActionPerformed

    private void btDelDirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btDelDirActionPerformed
        try {
            int k = tabDirectionList.getSelectedRowSorted();
            if (k < 0) {
                return;
            }
            if (isDirty()) {
                MessageBox.showWarning(MessageBox.W_NOT_CLOSE_EDITING);
                return;
            }
            CommitteeDirectionData comDir = comDirList.get(k);
            DirectionLocal direction = comDir.getDirection(getAuditManager());
            direction.addContentStateListener(emptyListener);           
           
            committee.getDirectionList().remove(comDir);
            direction.setOrdered(false);
            directions.add(direction);
            reloadTableDirections();
        } catch(ClipsException ex) {
            MessageBox.showException(ex);
        }
    }//GEN-LAST:event_btDelDirActionPerformed

private void btSetComResRenderedActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btSetComResRenderedActionPerformed
    try {
        int row = tabResolutionList.getSelectedRowSorted();
        if (row > -1) {
            CommitteeResolutionData comRes = comResList.get(row);
            comRes.setRendered(true);
        }
    } catch (ClipsException ex) {
        MessageBox.showException(ex);
    }
}//GEN-LAST:event_btSetComResRenderedActionPerformed

private void btSetInabilityActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btSetInabilityActionPerformed
    try {
        int row = tabResolutionList.getSelectedRowSorted();
        if (row < 0) {
            return;
        }
        if (committee.getMemberList().size() == 0) {           
            MessageBox.showWarning(MessageBox.W_COMMITTEE_NOT_MADE);
        }
        else {
            CommitteeResolutionData comRes = committee.getResolutionList(false).get(row);
           
            if(comRes.getId() == 0) {
                throw new ClipsException("Перед данным действием необходимо сохранить список решений КЭК");
            }
            InabilityData inability = committee.getInabilityByResolution(comRes);
            if (inability != null) {
                jTabbedPane1.setSelectedComponent(panelInability);
                for (int i = 0; i < inabilityList.size(); i++) {
                    if (inabilityList.get(i).equals(inability)) {
                        tabInabilidityList.setRowSelectionInterval(i, i);
                        break;
                    }
                }
            } else {
                if (comRes.isRendered()) {
                    return;
                }
                inability = new InabilityData(comRes);
                DlgInabilityEdit dlg = new DlgInabilityEdit(MainWindow.mainWindow, inability, getAuditManager());
                dlg.setVisible(true);
                if (dlg.getDlgResult() == ModalDialog.DLG_OK) {
                    comRes.setRendered(true);
                    committee.getInabilityList(false).append(inability);
                }
            }
        }
    } catch (ClipsException ex) {           
        MessageBox.showException(ex);
    }
}//GEN-LAST:event_btSetInabilityActionPerformed

private void btDelResolutionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btDelResolutionActionPerformed
    try {
        if (isDirty()) {
            MessageBox.showWarning(MessageBox.W_NOT_CLOSE_EDITING);
            return;
        }
        int row = tabResolutionList.getSelectedRowSorted();
        if (row > -1) {
            CommitteeResolutionData comRes = comResList.get(row);
            CommitteeDirectionData comDir = null;
            int id = committee.getResolutionList(false).get(row).getKey();
            for (int i = 0; i < comDirList.size(); i++) {
                if (comDirList.get(i).getId() == id) {
                    comDir = comDirList.get(i);
                    break;
                }
            }
            DirectionLocal direction = comDir.getDirection(getAuditManager());
            direction.addContentStateListener(emptyListener);
           
            committee.getResolutionList(false).remove(comRes);
            direction.setOrdered(false);
            directions.add(direction);
           
            reloadTableResolutions();
        }
    } catch (ClipsException ex) {
        MessageBox.showException(ex);
    }
}//GEN-LAST:event_btDelResolutionActionPerformed

private void btComResViewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btComResViewActionPerformed
    try {
        int row  = tabResolutionList.getSelectedRowSorted();
        if (row > -1) {
            CommitteeResolutionData data = comResList.get(row);
            CommitteeResolutionData comResData = (CommitteeResolutionData) data.clone();
            ComResDlg dlg = new ComResDlg(MainWindow.mainWindow, comResData, getAuditManager());
            dlg.setVisible(true);
            if (dlg.getDlgResult() == ModalDialog.DLG_OK) {
                data.setCollaborator(comResData.getCollaborator());
                data.setDescription(comResData.getDescription());
                data.setMkb(comResData.getMkb());
                data.setRendered(comResData.isRendered());
                data.setType(comResData.getType());
            }
        }
    } catch (ClipsException ex) {
        MessageBox.showException(ex);
    }
}//GEN-LAST:event_btComResViewActionPerformed

private void btInabilityViewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btInabilityViewActionPerformed
    try {
        int row = tabInabilidityList.getSelectedRowSorted();
        if (row > -1) {
            InabilityData inabilityData = inabilityList.get(row);
            InabilityData inability = (InabilityData) inabilityData.clone();
            DlgInabilityEdit dlg = new DlgInabilityEdit(MainWindow.mainWindow, inability, getAuditManager());
            dlg.setVisible(true);
            if (dlg.getDlgResult() == ModalDialog.DLG_OK) {
                inabilityData.setDate(inability.getDate());
                inabilityData.setDateAnswer(inability.getDateAnswer());
                inabilityData.setDesc(inability.getDesc());
                inabilityData.setLevelIn(inability.getLevelIn());
                inabilityData.setLevelOut(inability.getLevelOut());
            }
        }
    } catch (ClipsException ex) {
        MessageBox.showException(ex);
    }
}//GEN-LAST:event_btInabilityViewActionPerformed

private void btInabilityDelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btInabilityDelActionPerformed
    try {
        int row = tabInabilidityList.getSelectedRowSorted();
        if (row > -1) {
            InabilityData inabilityData = inabilityList.get(row);
            CommitteeResolutionData comRes = null;
            int id = committee.getInabilityList(false).get(row).getKey();
            for (int i = 0; i < comResList.size(); i++) {
                if (comResList.get(i).getId() == id) {
                    comRes = comResList.get(i);
                    break;
                }
            }
            comRes.setRendered(false);
            committee.getInabilityList(false).remove(inabilityData);
            reloadTableInabilities();
        }
    } catch (ClipsException ex) {
        MessageBox.showException(ex);
    }
}//GEN-LAST:event_btInabilityDelActionPerformed

private void tabResolutionListMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tabResolutionListMouseClicked
    try {
        if (evt.getClickCount() < 2) {
            return;
        }
        int index = committee.getResolutionList(false).get(tabResolutionList.getSelectedRowSorted()).getKey();
        for (int i = 0; i < comDirList.size(); i++) {
            if (comDirList.get(i).getId() == index) {
                tabDirectionList.setRowSelectionInterval(i, i);
                break;
            }
        }
        jTabbedPane1.setSelectedComponent(panelDirection);
    } catch (ClipsException ex) {
        MessageBox.showException(ex);
    }
}//GEN-LAST:event_tabResolutionListMouseClicked

private void jScrollPane3ComponentResized(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_jScrollPane3ComponentResized

}//GEN-LAST:event_jScrollPane3ComponentResized

private void tabInabilidityListMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tabInabilidityListMouseClicked
    try {
        if (evt.getClickCount() < 2) {
            return;
        }
        int index = committee.getInabilityList(false).get(tabInabilidityList.getSelectedRowSorted()).getKey();
        for (int i = 0; i < comResList.size(); i++) {
            if (comResList.get(i).getId() == index) {
                tabResolutionList.setRowSelectionInterval(i, i);
                break;
            }
        }
        jTabbedPane1.setSelectedComponent(panelResolution);
    } catch (ClipsException ex) {
        MessageBox.showException(ex);
    }
}//GEN-LAST:event_tabInabilidityListMouseClicked

private void jScrollPane4ComponentResized(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_jScrollPane4ComponentResized
   
}//GEN-LAST:event_jScrollPane4ComponentResized

    @Override
    public String getPageTitle() {
        String title = "Комиссия ";
        return title;
    }

   
   
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton addCollab;
    private javax.swing.JButton btAddDirections;
    private javax.swing.JButton btComResView;
    private javax.swing.JButton btDelDir;
    private javax.swing.JButton btDelResolution;
    private javax.swing.JButton btInabilityDel;
    private javax.swing.JButton btInabilityView;
    private javax.swing.JButton btSetComResRendered;
    private javax.swing.JButton btSetInability;
    private javax.swing.JButton btSetResolution;
    private org.infotechservice.ICalendar.components.ICDateChooser dateCom;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel11;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JSplitPane jSplitPane1;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JList lstCollab;
    private javax.swing.JPanel panelDirection;
    private javax.swing.JPanel panelInability;
    private javax.swing.JPanel panelResolution;
    private javax.swing.JButton removeCollab;
    private cli_fmw.utils.sorted_table.SortedTable tabDirectionList;
    private cli_fmw.utils.sorted_table.SortedTable tabInabilidityList;
    private cli_fmw.utils.sorted_table.SortedTable tabResolutionList;
    // End of variables declaration//GEN-END:variables

    @Override
    public boolean isDirty() {
        return committee == null ? false : committee.isDirty();
    }

    @Override
    public void save() { 
        try {
            if (committee.isDirty()) {
                for (int i = 0; i < directions.size(); i++) {
                    DirectionLocal direction = directions.get(i);
                    if (direction != null && direction.isDirty()) {
                        direction.save1();
                    }
                }
                committee.save1();
                forceResolutions = true;
                forceInabilities = true;
                setScreenFields();
                directions.clear();
            }
        } catch (ClipsException ex) {
            MessageBox.showException(ex);
        }
    }

    @Override
    public void restore() {       
        try {
            if (committee.isNewlyCreated()) {
                committee = null;
                getContainer().removePage(this, false);
            }
            else {
                for (int i = 0; i < directions.size(); i++) {
                    DirectionLocal direction = directions.get(i);
                    if (direction != null && direction.isDirty()) {
                        direction.restore();
                    }
                }
                committee.restore();
                setScreenFields();
                directions.clear();
            }
        } catch (ClipsException ex) {
            MessageBox.showException(ex);
        }
    }

    @Override
    public boolean readyForPrint() {
        /*boolean isSomeSelected = false;
        if (jTabbedPane1.getSelectedComponent().getName().equals("panelDirection")) {
        isSomeSelected = tabDirectionList.getSelectedRowCount() > 0;
        }
        else if (jTabbedPane1.getSelectedComponent().getName().equals("panelResolution")) {
        isSomeSelected = tabResolutionList.getSelectedRowCount() > 0;
        }
        else if (jTabbedPane1.getSelectedComponent().getName().equals("panelInability")) {
        isSomeSelected = tabInabilidityList.getSelectedRowCount() > 0;
        }
        return isSomeSelected && !isDirty();*/
        return false;
    }

    @Override
    public void print() {
    /*try {
        if (readyForPrint()) {
        FormReportCreator creater = ReporterFactory.createFormReporter(getClass());
        HashMap<String, Object> data = new LinkedHashMap<String, Object>();
        data.put("date", "Дата комиссии: " + Converter.dateToString(dateCom.getDate()));

        String mems = "Состав комиссии: ";
        for (int i = 0; i < memberList.size(); i++) {
        mems += memberList.get(i).getCollaborator().getTitle() +
        (i != memberList.size() - 1 ? ", " : ".");
        }
        data.put("mems", mems);

        String title = "";
        if (jTabbedPane1.getSelectedComponent().getName().equals("panelDirection")) {
        title = "Направление на комиссию";
        int k = tabDirectionList.getSelectedRowSorted();
        DirectionLocal directionLocal = comDirList.get(k).getDirection();
        data.put("dirClient", "");
        data.put("dirDate", "");
        data.put("dirMKB", "");
        }
        else if (jTabbedPane1.getSelectedComponent().getName().equals("panelResolution")) {
        title += "Решение комиссии";
        }
        else if (jTabbedPane1.getSelectedComponent().getName().equals("panelInability")) {
        title += "Направление на МСЭК";
        }
        creater.createReport(title, new TableReportOptions(TableReportOptions.PageOrentation.horizontal),
        data.entrySet(), null);
        creater.finish();
        }
        } catch (ClipsException ex) {
        MessageBox.showException(ex);
        }*/
    }

    @Override
    public DelegateLine2 getDelegate() {
        return committee;
    }
   
}
TOP

Related Classes of clips.kek.committee.PanelEditCommittee

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.