forked from Coded/SIPRP
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
308 lines
10 KiB
308 lines
10 KiB
package siprp.higiene.marcacoes;
|
|
|
|
import com.evolute.utils.*;
|
|
import com.evolute.utils.arrays.*;
|
|
import com.evolute.utils.data.*;
|
|
import com.evolute.utils.dataui.*;
|
|
import com.evolute.utils.db.*;
|
|
import com.evolute.utils.documents.*;
|
|
import com.evolute.utils.sql.*;
|
|
import com.evolute.utils.ui.*;
|
|
import com.evolute.utils.ui.calendar.*;
|
|
import com.evolute.utils.ui.panel.*;
|
|
import com.evolute.utils.ui.text.*;
|
|
import java.awt.*;
|
|
import java.util.*;
|
|
import javax.swing.*;
|
|
import siprp.data.*;
|
|
|
|
public class MarcacaoVisitaHSTPanel
|
|
extends JPanel
|
|
implements ControllableComponent, DataClassAware
|
|
{
|
|
private siprp.data.MarcacaoEstabelecimentoData marcacaoEstabelecimentoData;
|
|
private final ComponentsHashtable components = new ComponentsHashtable();
|
|
|
|
protected final SQLExecuter EXECUTER;
|
|
|
|
private final JLabel dataLabel = new JLabel( "Data da visita", JLabel.RIGHT );
|
|
private final JCalendarPanel dataPanel = new JCalendarPanel( null );
|
|
private final JButton emailButton = new JButton( "Enviar Email" );
|
|
private final JLabel dataFichaLabel = new JLabel( "Data do Relat\u00f3rio", JLabel.RIGHT );
|
|
private final JCalendarPanel dataFichaPanel = new JCalendarPanel( null );
|
|
private final JLabel tecnicoLabel = new JLabel( "T\u00e9cnico", JLabel.RIGHT );
|
|
private final JComboBox tecnicoList = new JComboBox();
|
|
private RadioButtonFixedPanel estadoList;
|
|
private final JScrollPane observacoesTextScroll = new JScrollPane();
|
|
private final StateTextArea observacoesText = new StateTextArea();
|
|
|
|
public MarcacaoVisitaHSTPanel()
|
|
throws Exception
|
|
{
|
|
DBManager dbm = ( DBManager )Singleton.getInstance( Singleton.DEFAULT_DBMANAGER );
|
|
if( dbm != null )
|
|
{
|
|
EXECUTER = ( SQLExecuter )dbm.getSharedExecuter( this );
|
|
}
|
|
else
|
|
{
|
|
EXECUTER = null;
|
|
}
|
|
setupComponents();
|
|
setupComponentsHashtable();
|
|
place();
|
|
}
|
|
|
|
public void setupComponents()
|
|
throws Exception
|
|
{
|
|
JComponent MarcacaoVisitaHSTPanel = this;
|
|
emailButton.setMinimumSize( new Dimension( 300, 20 ) );
|
|
emailButton.setPreferredSize( new Dimension( 200, 20 ) );
|
|
|
|
tecnicoList.addItem( new MappableObject( new Integer( -1 ), "" ) );
|
|
tecnicoList.setSelectedIndex( 0 );
|
|
|
|
IDObject estadoListOptions[] = new IDObject[]{
|
|
new MappableObject( new Integer( 0 ), "Por realizar" ),
|
|
new MappableObject( new Integer( 2 ), "Realizada" ),
|
|
new MappableObject( new Integer( 3 ), "Desmarcada pela empresa" ),
|
|
new MappableObject( new Integer( 4 ), "Desmarcada pela SIPRP" ),
|
|
};
|
|
estadoList = new RadioButtonFixedPanel( estadoListOptions, 6, 1, RadioButtonFixedPanel.ORIENTATION_VERTICAL, false, null );
|
|
estadoList.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Estado" ) );
|
|
|
|
observacoesTextScroll.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Observa\u00e7\u00f5es" ) );
|
|
observacoesText.setLineWrap( true );
|
|
observacoesText.setWrapStyleWord( true );
|
|
observacoesText.setRows( 5 );
|
|
|
|
}
|
|
|
|
public void place()
|
|
{
|
|
JPanel MarcacaoVisitaHSTPanel = this;
|
|
GridBagConstraints MarcacaoVisitaHSTPanelGBC = new GridBagConstraints();
|
|
MarcacaoVisitaHSTPanelGBC.insets = new Insets( 1, 1, 1, 1 );
|
|
GridBagLayout MarcacaoVisitaHSTPanelLayout = new GridBagLayout();
|
|
MarcacaoVisitaHSTPanel.setLayout( MarcacaoVisitaHSTPanelLayout );
|
|
MarcacaoVisitaHSTPanelGBC.gridx = 0;
|
|
MarcacaoVisitaHSTPanelGBC.gridy = 0;
|
|
MarcacaoVisitaHSTPanelGBC.gridwidth = 1;
|
|
MarcacaoVisitaHSTPanelGBC.gridheight = 1;
|
|
MarcacaoVisitaHSTPanelGBC.weightx = 0.0;
|
|
MarcacaoVisitaHSTPanelGBC.weighty = 0.0;
|
|
MarcacaoVisitaHSTPanelGBC.fill = GridBagConstraints.HORIZONTAL;
|
|
MarcacaoVisitaHSTPanelLayout.setConstraints( dataLabel, MarcacaoVisitaHSTPanelGBC );
|
|
MarcacaoVisitaHSTPanel.add( dataLabel );
|
|
|
|
MarcacaoVisitaHSTPanelGBC.gridx = 1;
|
|
MarcacaoVisitaHSTPanelGBC.gridy = 0;
|
|
MarcacaoVisitaHSTPanelGBC.gridwidth = 1;
|
|
MarcacaoVisitaHSTPanelGBC.gridheight = 1;
|
|
MarcacaoVisitaHSTPanelGBC.weightx = 0.5;
|
|
MarcacaoVisitaHSTPanelGBC.weighty = 0.0;
|
|
MarcacaoVisitaHSTPanelGBC.fill = GridBagConstraints.HORIZONTAL;
|
|
MarcacaoVisitaHSTPanelLayout.setConstraints( dataPanel, MarcacaoVisitaHSTPanelGBC );
|
|
MarcacaoVisitaHSTPanel.add( dataPanel );
|
|
|
|
MarcacaoVisitaHSTPanelGBC.gridx = 2;
|
|
MarcacaoVisitaHSTPanelGBC.gridy = 0;
|
|
MarcacaoVisitaHSTPanelGBC.gridwidth = 1;
|
|
MarcacaoVisitaHSTPanelGBC.gridheight = 1;
|
|
MarcacaoVisitaHSTPanelGBC.weightx = 0.5;
|
|
MarcacaoVisitaHSTPanelGBC.weighty = 0.0;
|
|
MarcacaoVisitaHSTPanelGBC.fill = GridBagConstraints.NONE;
|
|
MarcacaoVisitaHSTPanelLayout.setConstraints( emailButton, MarcacaoVisitaHSTPanelGBC );
|
|
MarcacaoVisitaHSTPanel.add( emailButton );
|
|
|
|
MarcacaoVisitaHSTPanelGBC.gridx = 0;
|
|
MarcacaoVisitaHSTPanelGBC.gridy = 1;
|
|
MarcacaoVisitaHSTPanelGBC.gridwidth = 1;
|
|
MarcacaoVisitaHSTPanelGBC.gridheight = 1;
|
|
MarcacaoVisitaHSTPanelGBC.weightx = 0.0;
|
|
MarcacaoVisitaHSTPanelGBC.weighty = 0.0;
|
|
MarcacaoVisitaHSTPanelGBC.fill = GridBagConstraints.HORIZONTAL;
|
|
MarcacaoVisitaHSTPanelLayout.setConstraints( dataFichaLabel, MarcacaoVisitaHSTPanelGBC );
|
|
MarcacaoVisitaHSTPanel.add( dataFichaLabel );
|
|
|
|
MarcacaoVisitaHSTPanelGBC.gridx = 1;
|
|
MarcacaoVisitaHSTPanelGBC.gridy = 1;
|
|
MarcacaoVisitaHSTPanelGBC.gridwidth = 1;
|
|
MarcacaoVisitaHSTPanelGBC.gridheight = 1;
|
|
MarcacaoVisitaHSTPanelGBC.weightx = 0.5;
|
|
MarcacaoVisitaHSTPanelGBC.weighty = 0.0;
|
|
MarcacaoVisitaHSTPanelGBC.fill = GridBagConstraints.HORIZONTAL;
|
|
MarcacaoVisitaHSTPanelLayout.setConstraints( dataFichaPanel, MarcacaoVisitaHSTPanelGBC );
|
|
MarcacaoVisitaHSTPanel.add( dataFichaPanel );
|
|
|
|
MarcacaoVisitaHSTPanelGBC.gridx = 0;
|
|
MarcacaoVisitaHSTPanelGBC.gridy = 2;
|
|
MarcacaoVisitaHSTPanelGBC.gridwidth = 1;
|
|
MarcacaoVisitaHSTPanelGBC.gridheight = 1;
|
|
MarcacaoVisitaHSTPanelGBC.weightx = 0.0;
|
|
MarcacaoVisitaHSTPanelGBC.weighty = 0.0;
|
|
MarcacaoVisitaHSTPanelGBC.fill = GridBagConstraints.HORIZONTAL;
|
|
MarcacaoVisitaHSTPanelLayout.setConstraints( tecnicoLabel, MarcacaoVisitaHSTPanelGBC );
|
|
MarcacaoVisitaHSTPanel.add( tecnicoLabel );
|
|
|
|
MarcacaoVisitaHSTPanelGBC.gridx = 1;
|
|
MarcacaoVisitaHSTPanelGBC.gridy = 2;
|
|
MarcacaoVisitaHSTPanelGBC.gridwidth = 1;
|
|
MarcacaoVisitaHSTPanelGBC.gridheight = 1;
|
|
MarcacaoVisitaHSTPanelGBC.weightx = 0.5;
|
|
MarcacaoVisitaHSTPanelGBC.weighty = 0.0;
|
|
MarcacaoVisitaHSTPanelGBC.fill = GridBagConstraints.HORIZONTAL;
|
|
MarcacaoVisitaHSTPanelLayout.setConstraints( tecnicoList, MarcacaoVisitaHSTPanelGBC );
|
|
MarcacaoVisitaHSTPanel.add( tecnicoList );
|
|
|
|
MarcacaoVisitaHSTPanelGBC.gridx = 0;
|
|
MarcacaoVisitaHSTPanelGBC.gridy = 3;
|
|
MarcacaoVisitaHSTPanelGBC.gridwidth = 3;
|
|
MarcacaoVisitaHSTPanelGBC.gridheight = 1;
|
|
MarcacaoVisitaHSTPanelGBC.weightx = 1.0;
|
|
MarcacaoVisitaHSTPanelGBC.weighty = 0.5;
|
|
MarcacaoVisitaHSTPanelGBC.fill = GridBagConstraints.BOTH;
|
|
MarcacaoVisitaHSTPanelLayout.setConstraints( estadoList, MarcacaoVisitaHSTPanelGBC );
|
|
MarcacaoVisitaHSTPanel.add( estadoList );
|
|
|
|
MarcacaoVisitaHSTPanelGBC.gridx = 0;
|
|
MarcacaoVisitaHSTPanelGBC.gridy = 4;
|
|
MarcacaoVisitaHSTPanelGBC.gridwidth = 3;
|
|
MarcacaoVisitaHSTPanelGBC.gridheight = 1;
|
|
MarcacaoVisitaHSTPanelGBC.weightx = 1.0;
|
|
MarcacaoVisitaHSTPanelGBC.weighty = 0.5;
|
|
observacoesTextScroll.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
|
|
observacoesTextScroll.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED );
|
|
observacoesTextScroll.setViewportView( observacoesText );
|
|
MarcacaoVisitaHSTPanelGBC.fill = GridBagConstraints.BOTH;
|
|
MarcacaoVisitaHSTPanelLayout.setConstraints( observacoesTextScroll, MarcacaoVisitaHSTPanelGBC );
|
|
MarcacaoVisitaHSTPanel.add( observacoesTextScroll );
|
|
|
|
}
|
|
|
|
private void setupComponentsHashtable()
|
|
{
|
|
components.putComponent( siprp.data.MarcacaoEstabelecimentoData.DATA, dataPanel );
|
|
components.putComponent( siprp.data.MarcacaoEstabelecimentoData.DATA_RELATORIO, dataFichaPanel );
|
|
components.putComponent( siprp.data.MarcacaoEstabelecimentoData.TECNICO_HST, tecnicoList );
|
|
components.putComponent( siprp.data.MarcacaoEstabelecimentoData.ESTADO, estadoList );
|
|
components.putComponent( siprp.data.MarcacaoEstabelecimentoData.OBSERVACOES, observacoesText );
|
|
}
|
|
|
|
public void fill( Object toFill )
|
|
{
|
|
clear();
|
|
if( toFill == null || !( toFill instanceof PropertyObject ) )
|
|
{
|
|
return;
|
|
}
|
|
Hashtable data = null;
|
|
if( toFill instanceof PropertyObject )
|
|
{
|
|
data = ( (PropertyObject) toFill ).getHashData();
|
|
if( toFill instanceof siprp.data.MarcacaoEstabelecimentoData )
|
|
{
|
|
marcacaoEstabelecimentoData = (siprp.data.MarcacaoEstabelecimentoData) toFill;
|
|
}
|
|
}
|
|
else if( toFill instanceof Hashtable )
|
|
{
|
|
data = (Hashtable) toFill;
|
|
}
|
|
else
|
|
{
|
|
return;
|
|
}
|
|
if( marcacaoEstabelecimentoData == null )
|
|
{
|
|
marcacaoEstabelecimentoData = new siprp.data.MarcacaoEstabelecimentoData();
|
|
marcacaoEstabelecimentoData.setHashData( data );
|
|
}
|
|
PropertyObject po = (PropertyObject) toFill;
|
|
String properties[] = (String[]) components.keySet().toArray( new String[ 0 ] );
|
|
ComponentController.fill( properties, po.getHashData(), components );
|
|
}
|
|
|
|
public Object save()
|
|
{
|
|
if( marcacaoEstabelecimentoData == null )
|
|
{
|
|
marcacaoEstabelecimentoData = new siprp.data.MarcacaoEstabelecimentoData();
|
|
}
|
|
Hashtable data = marcacaoEstabelecimentoData.getHashData();
|
|
String properties[] = (String[]) components.keySet().toArray( new String[ 0 ] );
|
|
ComponentController.save( properties, data, components );
|
|
if( !( marcacaoEstabelecimentoData instanceof PropertyObject ) )
|
|
{
|
|
return data;
|
|
}
|
|
marcacaoEstabelecimentoData.setHashData( data );
|
|
return marcacaoEstabelecimentoData;
|
|
}
|
|
|
|
public void clear()
|
|
{
|
|
marcacaoEstabelecimentoData = null;
|
|
String properties[] = (String[]) components.keySet().toArray( new String[ 0 ] );
|
|
ComponentController.clear( properties, components );
|
|
}
|
|
|
|
public void setEnabled( boolean enable )
|
|
{
|
|
String properties[] = (String[]) components.keySet().toArray( new String[ 0 ] );
|
|
ComponentController.setEnabled( properties, enable, components );
|
|
}
|
|
|
|
public Class getDataClass()
|
|
{
|
|
return siprp.data.MarcacaoEstabelecimentoData.class;
|
|
}
|
|
|
|
public JLabel getDataFichaLabel()
|
|
{
|
|
return dataFichaLabel;
|
|
}
|
|
|
|
public JCalendarPanel getDataFichaPanel()
|
|
{
|
|
return dataFichaPanel;
|
|
}
|
|
|
|
public JLabel getDataLabel()
|
|
{
|
|
return dataLabel;
|
|
}
|
|
|
|
public JCalendarPanel getDataPanel()
|
|
{
|
|
return dataPanel;
|
|
}
|
|
|
|
public JButton getEmailButton()
|
|
{
|
|
return emailButton;
|
|
}
|
|
|
|
public RadioButtonFixedPanel getEstadoList()
|
|
{
|
|
return estadoList;
|
|
}
|
|
|
|
public StateTextArea getObservacoesText()
|
|
{
|
|
return observacoesText;
|
|
}
|
|
|
|
public JLabel getTecnicoLabel()
|
|
{
|
|
return tecnicoLabel;
|
|
}
|
|
|
|
public JComboBox getTecnicoList()
|
|
{
|
|
return tecnicoList;
|
|
}
|
|
|
|
}
|