Package clips.directory.editors.update

Source Code of clips.directory.editors.update.PanelDloUpdate

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

/*
* PanelDloUpdate.java
*
* Created on 23.11.2009, 10:05:52
*/

package clips.directory.editors.update;

import cli_fmw.delegate.DelegateLine2;
import cli_fmw.main.ClipsException;
import cli_fmw.main.PageContainer;
import cli_fmw.main.PageGeneric;
import cli_fmw.utils.MessageBox;
import cli_fmw.utils.table_config_states.StateSaver;
import cli_fmw.utils.table_config_states.TableState;
import clips.delegate.directory.simple.dlo.DirectoryDrugDosageForm;
import clips.delegate.directory.simple.dlo.DirectoryDrugDosageUnit;
import clips.delegate.directory.simple.dlo.DirectoryDrugFarmGroup;
import clips.delegate.directory.simple.dlo.DirectoryDrugMNN;
import clips.delegate.directory.simple.dlo.DirectoryDrugTradeName;
import clips.delegate.directory.simple.dlo.DirectoryDrugVolumeUnit;
import clips.delegate.directory.simple.dlo.DirectoryDrugWeightUnit;
import clips.directory.editors.update.updaters.dlo.UpdaterDirectoryDrugDosageForm;
import clips.directory.editors.update.updaters.dlo.UpdaterDirectoryDrugDosageUnit;
import clips.directory.editors.update.updaters.dlo.UpdaterDirectoryDrugFarmGroup;
import clips.directory.editors.update.updaters.dlo.UpdaterDirectoryDrugMNN;
import clips.directory.editors.update.updaters.dlo.UpdaterDirectoryDrugTradeName;
import clips.directory.editors.update.updaters.dlo.UpdaterDirectoryDrugVolumeUnit;
import clips.directory.editors.update.updaters.dlo.UpdaterDirectoryDrugWeightUnit;
import clips.directory.editors.update.updaters.dlo.UpdaterDloCollaborators;
import clips.directory.editors.update.updaters.dlo.UpdaterDloDrugList;
import clips.directory.editors.update.updaters.dlo.UpdaterDloDrugSection;
import clips.directory.editors.update.updaters.dlo.UpdaterFacilityClients;
import clips.login.UserInfo;
import clips.main.ClipsConfig;
import java.util.ArrayList;
import javax.swing.JFileChooser;

/**
*
* @author lacoste
*/
public class PanelDloUpdate extends PageGeneric {
    private static ArrayList<UpdaterItem> updaterItemList;
     private static ClipsConfig cfg = ClipsConfig.getInstance();

    /** Creates new form PanelDloUpdate */
    public PanelDloUpdate(PageContainer container) throws ClipsException {
        super(container);
        initComponents();
        if (!UserInfo.get().canUseHiddenDirectoryItems()) {
            throw new ClipsException("Для обновления справочников необходим доступ к скрытым(удаленным) элементам");
        }
        init();
        tfDir.setText(cfg.getLastDBFImportPath().getAbsolutePath());
        tableUpdater.setModel(new TableModelUpdater(updaterItemList));
        resizeColumn();
        StateSaver.attachTo(this);
    }

    private void init() throws ClipsException {
        UpdaterFacilityClients updFacility = new UpdaterFacilityClients();

        UpdaterDirectoryDrugTradeName updTradeName =
                new UpdaterDirectoryDrugTradeName(DirectoryDrugTradeName.class, "C_TRN", "NAME_TRN");
        UpdaterDirectoryDrugMNN updMNN =
                new UpdaterDirectoryDrugMNN(DirectoryDrugMNN.class, "C_MNN", "NAME_MNN");
        UpdaterDirectoryDrugDosageForm updDosageForm =
                new UpdaterDirectoryDrugDosageForm(DirectoryDrugDosageForm.class, "C_LF", "NAME_LF");
        UpdaterDirectoryDrugDosageUnit updDosageUnit =
                new UpdaterDirectoryDrugDosageUnit(DirectoryDrugDosageUnit.class, "C_DLS", "NAME_DLS");
        UpdaterDirectoryDrugVolumeUnit updVolumeUnit =
                new UpdaterDirectoryDrugVolumeUnit(DirectoryDrugVolumeUnit.class, "C_VLF", "NAME_VLF");
        UpdaterDirectoryDrugWeightUnit updWeightUnit =
                new UpdaterDirectoryDrugWeightUnit(DirectoryDrugWeightUnit.class, "C_MLF", "NAME_MLF");
        UpdaterDirectoryDrugFarmGroup updFarmGroup =
                new UpdaterDirectoryDrugFarmGroup(DirectoryDrugFarmGroup.class, "C_FARG", "FNAME_FRG");
        UpdaterDloDrugSection updSection =
                new UpdaterDloDrugSection();
        UpdaterDloDrugList updDrugList = new UpdaterDloDrugList();
       
        UpdaterDloCollaborators updDloCollab = new UpdaterDloCollaborators();


        updaterItemList = new ArrayList<UpdaterItem>();
        updaterItemList.add(new UpdaterItem(updTradeName, false, ""));
        updaterItemList.add(new UpdaterItem(updMNN, false, ""));
        updaterItemList.add(new UpdaterItem(updDosageForm, false, ""));
        updaterItemList.add(new UpdaterItem(updDosageUnit, false, ""));
        updaterItemList.add(new UpdaterItem(updVolumeUnit, false, ""));
        updaterItemList.add(new UpdaterItem(updWeightUnit, false, ""));
        updaterItemList.add(new UpdaterItem(updFarmGroup, false, ""));
        updaterItemList.add(new UpdaterItem(updSection, false, ""));
        updaterItemList.add(new UpdaterItem(updDrugList, false, ""));
        updaterItemList.add(new UpdaterItem(updDloCollab, false, ""));
        updaterItemList.add(new UpdaterItem(updFacility, false, "Загружает регистр льготников"));
    }

    private void resizeColumn() {
    TableState          state = new TableState();
    state.setPreferredWidth(TableModelUpdater.COL_NEED,    2);
    state.setPreferredWidth(TableModelUpdater.COL_TITLE,  8);
    state.setPreferredWidth(TableModelUpdater.COL_FILENAME, 5);
    state.setPreferredWidth(TableModelUpdater.COL_COMMENT,   5);
      StateSaver.setDefaultState(this, tableUpdater, state);
    }
    /** 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() {

        jPanel2 = new javax.swing.JPanel();
        tfDir = new javax.swing.JTextField();
        btDirSelect = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        tableUpdater = new cli_fmw.utils.sorted_table.SortedTable();
        jPanel1 = new javax.swing.JPanel();
        btUpdate = new javax.swing.JButton();

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

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Путь для импорта"));
        jPanel2.setLayout(new java.awt.BorderLayout());

        tfDir.setEditable(false);
        jPanel2.add(tfDir, java.awt.BorderLayout.CENTER);

        btDirSelect.setText("Выбрать");
        btDirSelect.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btDirSelectActionPerformed(evt);
            }
        });
        jPanel2.add(btDirSelect, java.awt.BorderLayout.EAST);

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

        tableUpdater.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {

            }
        ));
        jScrollPane1.setViewportView(tableUpdater);

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

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

        btUpdate.setText("Начать обновление");
        btUpdate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btUpdateActionPerformed(evt);
            }
        });
        jPanel1.add(btUpdate);

        add(jPanel1, java.awt.BorderLayout.SOUTH);
    }// </editor-fold>//GEN-END:initComponents

    private void btDirSelectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btDirSelectActionPerformed
        JFileChooser    dlg = new JFileChooser();
        dlg.setCurrentDirectory(cfg.getLastDBFImportPath());
        dlg.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        int  res = dlg.showOpenDialog(this);
        if (res == JFileChooser.APPROVE_OPTION){
            cfg.setLastDBFImportPath(dlg.getSelectedFile());
        }
        tfDir.setText(cfg.getLastDBFImportPath().getAbsolutePath());
}//GEN-LAST:event_btDirSelectActionPerformed

    private void btUpdateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btUpdateActionPerformed
        try {
            for (int i = 0; i < updaterItemList.size(); i++) {
                UpdaterItem updaterItem = updaterItemList.get(i);
                if (updaterItem.need) {
                    updaterItem.updater.update();
                }
            }
        } catch (ClipsException ex) {
            MessageBox.showException(ex);
        }
    }//GEN-LAST:event_btUpdateActionPerformed

    @Override
    public String getPageTitle() {
        return "Обновление реестра льготников и справочников ДЛО";
    }

    @Override
    public DelegateLine2 getDelegate() {
        return null;
    }


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btDirSelect;
    private javax.swing.JButton btUpdate;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private cli_fmw.utils.sorted_table.SortedTable tableUpdater;
    private javax.swing.JTextField tfDir;
    // End of variables declaration//GEN-END:variables

}
TOP

Related Classes of clips.directory.editors.update.PanelDloUpdate

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.