/*
* DialogPrescriptionItem.java
*
* Created on 6 Октябрь 2008 г., 12:10
*/
package clips.doctor.prescription;
import clips.delegate.directory.complex.DirectoryVidalItem;
import clips.directory.editors.matter.VidalChangeListener;
import clips.directory.editors.vidalAtc.PanelVidalAtcEdit;
import clips.directory.editors.vidalFarm.PanelVidalFarmEdit;
import clips.directory.editors.vidalMkb10.PanelMkb10VidalEdit;
import cli_fmw.main.ClipsException;
import cli_fmw.utils.ModalDialog;
import cli_fmw.main.PageGeneric;
import cli_fmw.main.PageContainer;
import cli_fmw.main.PageException;
import cli_fmw.main.audit.AuditManager;
import cli_fmw.utils.ModalDialog;
import cli_fmw.utils.table_config_states.StateSaver;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Toolkit;
/**
*
* @author lacoste
*/
public class DialogClassificators extends ModalDialog implements PageContainer, VidalChangeListener{
private PanelVidalFarmEdit panelFarm;
private PanelMkb10VidalEdit panelMkb10;
private PanelVidalAtcEdit panelATC;
private DirectoryVidalItem vidal;
/** Creates new form DialogPrescriptionItem */
public DialogClassificators(java.awt.Frame parent, AuditManager am) throws ClipsException {
super(parent, "Классификаторы лекарственных препаратов", am);
initComponents();
this.setSize(1000, 700);
//center dialog
Dimension scrSize=Toolkit.getDefaultToolkit().getScreenSize();
Rectangle dlgSize=this.getBounds();
this.setLocation((scrSize.width-dlgSize.width)/2,(scrSize.height-dlgSize.height)/2);
panelFarm = new PanelVidalFarmEdit(this, true);
tabs.add(panelFarm.getPageTitle(), panelFarm);
panelATC = new PanelVidalAtcEdit(this, true);
tabs.add(panelATC.getPageTitle(), panelATC);
panelMkb10 = new PanelMkb10VidalEdit(this, true);
tabs.add(panelMkb10.getPageTitle(), panelMkb10);
StateSaver.attachTo(this);
}
private void setEnabledComponents() {
btOk.setEnabled(vidal != null);
}
public DirectoryVidalItem getVidal() {
return vidal;
}
/** 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() {
tabs = new javax.swing.JTabbedPane();
jPanel1 = new javax.swing.JPanel();
btOk = new javax.swing.JButton();
btCancel = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
tabs.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
tabsStateChanged(evt);
}
});
jPanel1.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT));
btOk.setText("Выбрать");
btOk.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btOkActionPerformed(evt);
}
});
jPanel1.add(btOk);
btCancel.setText("Отменить");
btCancel.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btCancelActionPerformed(evt);
}
});
jPanel1.add(btCancel);
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)
.addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 759, Short.MAX_VALUE)
.addComponent(tabs, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 759, Short.MAX_VALUE))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(tabs, javax.swing.GroupLayout.DEFAULT_SIZE, 409, Short.MAX_VALUE)
.addGap(5, 5, 5)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void btOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btOkActionPerformed
setDlgResult(ModalDialog.DLG_OK);
dispose();
}//GEN-LAST:event_btOkActionPerformed
private void btCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btCancelActionPerformed
setDlgResult(ModalDialog.DLG_CANCEL);
dispose();
}//GEN-LAST:event_btCancelActionPerformed
private void tabsStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_tabsStateChanged
Component component = tabs.getSelectedComponent();
if (component instanceof PanelMkb10VidalEdit) {
vidal = ((PanelMkb10VidalEdit) component).getVidalItem();
} else if (component instanceof PanelVidalAtcEdit) {
vidal = ((PanelVidalAtcEdit) component).getVidalItem();
} else if (component instanceof PanelVidalFarmEdit) {
vidal = ((PanelVidalFarmEdit) component).getVidalItem();
} else {
vidal = null;
}
setEnabledComponents();
}//GEN-LAST:event_tabsStateChanged
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btCancel;
private javax.swing.JButton btOk;
private javax.swing.JPanel jPanel1;
private javax.swing.JTabbedPane tabs;
// End of variables declaration//GEN-END:variables
@Override
public PageGeneric addNewPage(PageGeneric pageToAdd, PageGeneric afterPage) throws PageException {
return null;
}
@Override
public void removePage(PageGeneric page, boolean forced) throws PageException {
}
@Override
public void activatePage(PageGeneric page) throws PageException {
}
@Override
public PageGeneric getActivePage() {
return null;
}
@Override
public int getPageCount() {
return 0;
}
@Override
public PageGeneric getPage(int index) {
return null;
}
@Override
public void contentStateChanged() {
}
@Override
public void vidalChanged(DirectoryVidalItem vidal) {
this.vidal = vidal;
System.out.println("Vidal changed : " + vidal);
setEnabledComponents();
}
}