git-svn-id: https://svn.coded.pt/svn/SIPRP@763 bb69d46d-e84e-40c8-a05a-06db0d633741

lxbfYeaa
Tiago Simão 17 years ago
parent 7007cd475a
commit 5e9e0a5761

File diff suppressed because it is too large Load Diff

@ -1,8 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<driver project-version="3.0" class="org.postgresql.Driver"> <driver project-version="3.0" class="org.postgresql.Driver">
<url value="jdbc:postgresql://10.158.2.2:5432/siprp_local"/> <url value="jdbc:postgresql://storage:5432/siprp_local"/>
<!--url value="jdbc:postgresql://storage:5432/siprp_local"/-->
<!--url value="jdbc:postgresql://localhost:5432/siprp_local"/-->
<connectionPool min="1" max="1"/> <connectionPool min="1" max="1"/>
<login userName="postgres" password="Typein" encoderClass="org.apache.cayenne.conf.PlainTextPasswordEncoder" passwordLocation="model" passwordSource="Not Applicable"/> <login userName="postgres" password="Typein"/>
</driver> </driver>

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<domains project-version="3.0">
<domain name="SIPRP">
<property name="cayenne.DataRowStore.remote.notify" value="true"/>
<map name="SIPRPMap" location="SIPRPMap.map.xml"/>
<node name="SIPRPNode"
datasource="SIPRPNode.driver.xml"
factory="org.apache.cayenne.conf.DriverDataSourceFactory">
<map-ref name="SIPRPMap"/>
</node>
</domain>
</domains>

@ -1,12 +1,12 @@
package siprp; package siprp;
import static siprp.medicina.processo.ProcessoConstants.ESTADO_PROCESSO_BY_CODE; import static siprp.ProcessoConstants.ESTADO_PROCESSO_BY_CODE;
import static siprp.medicina.processo.ProcessoConstants.PROCESSO_ABERTO_CODE; import static siprp.ProcessoConstants.PROCESSO_ABERTO_CODE;
import static siprp.medicina.processo.ProcessoConstants.PROCESSO_ABERTO_DESCRIPTION; import static siprp.ProcessoConstants.PROCESSO_ABERTO_DESCRIPTION;
import static siprp.medicina.processo.ProcessoConstants.PROCESSO_CANCELADO_CODE; import static siprp.ProcessoConstants.PROCESSO_CANCELADO_CODE;
import static siprp.medicina.processo.ProcessoConstants.PROCESSO_CANCELADO_DESCRIPTION; import static siprp.ProcessoConstants.PROCESSO_CANCELADO_DESCRIPTION;
import static siprp.medicina.processo.ProcessoConstants.PROCESSO_FECHADO_CODE; import static siprp.ProcessoConstants.PROCESSO_FECHADO_CODE;
import static siprp.medicina.processo.ProcessoConstants.PROCESSO_FECHADO_DESCRIPTION; import static siprp.ProcessoConstants.PROCESSO_FECHADO_DESCRIPTION;
import java.awt.Color; import java.awt.Color;
import java.awt.GraphicsEnvironment; import java.awt.GraphicsEnvironment;

@ -1,61 +0,0 @@
/*
* SingletonConstants.java
*
* Created on 25 de Maio de 2004, 13:34
*/
package siprp;
/**
*
* @author fpalma
*/
public class SingletonConstants
{
public static final String PERSISTENCE_MANAGER = "PERSISTENCE_MANAGER";
public static final String SOFTWARE_NAME = "software_name";
public static final String COMPANY_NAME = "company_name";
public static final String COMPANY_LOGO = "company_logo";
public static final String COMPANY_ACRONYM = "company_acronym";
public static final String SUBJECT_CONSULTA = "subject_consulta";
public static final String LETTER_CONSULTA = "letter_consulta";
public static final String SUBJECT_CONSULTA_VACINAS = "subject_consulta_vacinas";
public static final String LETTER_CONSULTA_VACINAS = "letter_consulta_vacinas";
public static final String SUBJECT_EXAMES = "subject_exames";
public static final String LETTER_EXAMES = "letter_exames";
public static final String SUBJECT_VISITA = "subject_visita";
public static final String LETTER_VISITA = "letter_visita";
public static final String USES_HOUR = "uses_hour";
public static final String CODIGO_EMPRESA_FORMAT = "codigo_empresa_format";
public static final String FICHA_MARCA_EXAMES = "ficha_marca_exames";
public static final String EXCEL_FORMAT = "excel_format";
public static final String EXCEL_FORMAT_DEMISSAO = "excel_format_demissao";
public static final String MODULE_FICHA = "module_ficha";
public static final String MODULE_CLIENTES = "module_clientes";
public static final String WEB_AWARE = "web_aware";
public static final String MODULE_RELATORIO = "module_relatorio";
public static final String MODULE_LISTAGENS = "module_listagens";
public static final String WEB_USER = "web_user";
public static final String WEB_PASSWORD = "web_password";
public static final String WEB_URL_PREFIX = "web_url_prefix";
public static final String WEB_URL = "web_url";
public static final String WEB_DB_NAME = "web_db_name";
public static final String WEB_DRIVER_NAME = "web_driver_name";
public static final String LOCAL_USER = "local_user";
public static final String LOCAL_PASSWORD = "local_password";
public static final String LOCAL_URL_PREFIX = "local_url_prefix";
public static final String LOCAL_URL = "local_url";
public static final String LOCAL_DB_NAME = "local_db_name";
public static final String LOCAL_DRIVER_NAME = "local_driver_name";
public static final String SIPRP_TRACKER = "SIPRP_TRACKER";
/** Creates a new instance of SingletonConstants */
private SingletonConstants()
{
}
}

@ -1,481 +1,450 @@
package siprp.clientes; package siprp.clientes;
import static com.evolute.utils.strings.UnicodeLatin1Map.aacute;
import static com.evolute.utils.strings.UnicodeLatin1Map.atilde;
import static com.evolute.utils.strings.UnicodeLatin1Map.ccedil;
import static com.evolute.utils.strings.UnicodeLatin1Map.otilde;
import info.clearthought.layout.TableLayout;
import info.clearthought.layout.TableLayoutConstraints;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Vector;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JOptionPane;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.ScrollPaneConstants;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import org.apache.cayenne.CayenneDataObject;
import siprp.database.cayenne.objects.EmailPlanoDeActuacao;
import siprp.database.cayenne.objects.Estabelecimentos;
import siprp.database.cayenne.objects.Legislacao;
import siprp.database.cayenne.objects.LegislacaoEstabelecimento;
import siprp.database.cayenne.objects.PostoDeTrabalho;
import siprp.database.cayenne.objects.PostoDeTrabalhoEstabelecimento;
import siprp.database.cayenne.providers.PlanoActuacaoDAO;
import com.evolute.utils.dataui.ControllableComponent; import com.evolute.utils.dataui.ControllableComponent;
import com.evolute.utils.tables.VectorTableModel;
public class EstabelecimentoPlanoActuacaoPanel extends JPanel implements ControllableComponent public class EstabelecimentoPlanoActuacaoPanel extends JPanel implements ControllableComponent
{ {
private static final long serialVersionUID = 1L; // private static final long serialVersionUID = 1L;
//
private static final Dimension PREFERRED_DIMENSION_EMAIL = new Dimension(200,0); // private static final Dimension PREFERRED_DIMENSION_EMAIL = new Dimension(200,0);
//
private static final Dimension PREFERRED_DIMENSION_LEGISLACAO = new Dimension(400,0); // private static final Dimension PREFERRED_DIMENSION_LEGISLACAO = new Dimension(400,0);
//
private static final Dimension PREFERRED_DIMENSION_POSTO_TRABALHO = new Dimension(300,0); // private static final Dimension PREFERRED_DIMENSION_POSTO_TRABALHO = new Dimension(300,0);
//
private final VectorTableModel<EmailPlanoDeActuacao> modelEmail = new VectorTableModel<EmailPlanoDeActuacao>( new String[]{ "Endere" + ccedil + "o" } ); // private final VectorTableModel<EmailPlanoDeActuacao> modelEmail = new VectorTableModel<EmailPlanoDeActuacao>( new String[]{ "Endere" + ccedil + "o" } );
//
private final VectorTableModel<LegislacaoEstabelecimento> modelLegislacao = new VectorTableModel<LegislacaoEstabelecimento>( new String[]{ "Descri" + ccedil + atilde + "o" } ); // private final VectorTableModel<LegislacaoEstabelecimento> modelLegislacao = new VectorTableModel<LegislacaoEstabelecimento>( new String[]{ "Descri" + ccedil + atilde + "o" } );
//
private final VectorTableModel<PostoDeTrabalhoEstabelecimento> modelPostoTrabalho= new VectorTableModel<PostoDeTrabalhoEstabelecimento>( new String[]{ "Descri" + ccedil + atilde + "o" } ); // private final VectorTableModel<PostoDeTrabalhoEstabelecimento> modelPostoTrabalho= new VectorTableModel<PostoDeTrabalhoEstabelecimento>( new String[]{ "Descri" + ccedil + atilde + "o" } );
//
private final JTable tableEmail = new JTable( modelEmail ); // private final JTable tableEmail = new JTable( modelEmail );
//
private final JTable tableLegislacao = new JTable( modelLegislacao ); // private final JTable tableLegislacao = new JTable( modelLegislacao );
//
private final JTable tablePostoTrabalho = new JTable( modelPostoTrabalho ); // private final JTable tablePostoTrabalho = new JTable( modelPostoTrabalho );
//
private final JScrollPane scrollEmail = new JScrollPane( tableEmail, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER ); // private final JScrollPane scrollEmail = new JScrollPane( tableEmail, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER );
//
private final JScrollPane scrollLegislacao = new JScrollPane( tableLegislacao, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER ); // private final JScrollPane scrollLegislacao = new JScrollPane( tableLegislacao, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER );
//
private final JScrollPane scrollPostoTrabalho = new JScrollPane( tablePostoTrabalho, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER ); // private final JScrollPane scrollPostoTrabalho = new JScrollPane( tablePostoTrabalho, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER );
//
private final JPanel panelEmail = new JPanel(); // private final JPanel panelEmail = new JPanel();
//
private final JPanel panelLegislacao = new JPanel(); // private final JPanel panelLegislacao = new JPanel();
//
private final JPanel panelPostoTrabalho = new JPanel(); // private final JPanel panelPostoTrabalho = new JPanel();
//
private final JButton buttonEmailAdicionar = new JButton("Adicionar"); // private final JButton buttonEmailAdicionar = new JButton("Adicionar");
//
private final JButton buttonLegislacaoAdicionar = new JButton("Adicionar"); // private final JButton buttonLegislacaoAdicionar = new JButton("Adicionar");
//
private final JButton buttonPostoTrabalhoCriar = new JButton("Criar"); // private final JButton buttonPostoTrabalhoCriar = new JButton("Criar");
//
private final JButton buttonPostoTrabalhoEditar = new JButton("Editar"); // private final JButton buttonPostoTrabalhoEditar = new JButton("Editar");
//
private final JButton buttonPostoTrabalhoAdicionar = new JButton("Adicionar"); // private final JButton buttonPostoTrabalhoAdicionar = new JButton("Adicionar");
//
private final JButton buttonEmailRemover = new JButton("Remover"); // private final JButton buttonEmailRemover = new JButton("Remover");
//
private final JButton buttonLegislacaoRemover = new JButton("Remover"); // private final JButton buttonLegislacaoRemover = new JButton("Remover");
//
private final JButton buttonPostoTrabalhoRemover = new JButton("Remover"); // private final JButton buttonPostoTrabalhoRemover = new JButton("Remover");
//
private final PlanoActuacaoDAO provider = new PlanoActuacaoDAO(); // private final PlanoActuacaoDAO provider = new PlanoActuacaoDAO();
//
private Estabelecimentos estabelecimento = null; // private Estabelecimentos estabelecimento = null;
//
public EstabelecimentoPlanoActuacaoPanel() public EstabelecimentoPlanoActuacaoPanel()
{ {
startupComponents(); // startupComponents();
startupLayout(); // startupLayout();
placeComponents(); // placeComponents();
startupListeners(); // startupListeners();
} }
//
private void startupLayout() // private void startupLayout()
{ // {
startupEmailLayout(); // startupEmailLayout();
startupPostoTrabalhoLayout(); // startupPostoTrabalhoLayout();
startupLegislacaoLayout(); // startupLegislacaoLayout();
double [] cols = new double[]{ TableLayout.FILL, TableLayout.FILL, TableLayout.PREFERRED }; // double [] cols = new double[]{ TableLayout.FILL, TableLayout.FILL, TableLayout.PREFERRED };
double [] rows = new double[]{ TableLayout.FILL }; // double [] rows = new double[]{ TableLayout.FILL };
TableLayout layout = new TableLayout(cols,rows); // TableLayout layout = new TableLayout(cols,rows);
layout.setHGap( 5 ); // layout.setHGap( 5 );
layout.setVGap( 5 ); // layout.setVGap( 5 );
this.setLayout( layout ); // this.setLayout( layout );
} // }
//
private void startupEmailLayout() // private void startupEmailLayout()
{ // {
double [] cols = new double[]{ TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.FILL }; // double [] cols = new double[]{ TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.FILL };
double [] rows = new double[]{ TableLayout.FILL, TableLayout.MINIMUM }; // double [] rows = new double[]{ TableLayout.FILL, TableLayout.MINIMUM };
TableLayout layout = new TableLayout(cols,rows); // TableLayout layout = new TableLayout(cols,rows);
layout.setHGap( 5 ); // layout.setHGap( 5 );
layout.setVGap( 5 ); // layout.setVGap( 5 );
panelEmail.setLayout( layout ); // panelEmail.setLayout( layout );
} // }
//
private void startupPostoTrabalhoLayout() // private void startupPostoTrabalhoLayout()
{ // {
double [] cols = new double[]{ TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.FILL }; // double [] cols = new double[]{ TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.FILL };
double [] rows = new double[]{ TableLayout.FILL, TableLayout.MINIMUM }; // double [] rows = new double[]{ TableLayout.FILL, TableLayout.MINIMUM };
TableLayout layout = new TableLayout(cols,rows); // TableLayout layout = new TableLayout(cols,rows);
layout.setHGap( 5 ); // layout.setHGap( 5 );
layout.setVGap( 5 ); // layout.setVGap( 5 );
panelPostoTrabalho.setLayout( layout ); // panelPostoTrabalho.setLayout( layout );
} // }
//
private void startupLegislacaoLayout() // private void startupLegislacaoLayout()
{ // {
double [] cols = new double[]{ TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.FILL }; // double [] cols = new double[]{ TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.FILL };
double [] rows = new double[]{ TableLayout.FILL, TableLayout.MINIMUM }; // double [] rows = new double[]{ TableLayout.FILL, TableLayout.MINIMUM };
TableLayout layout = new TableLayout(cols,rows); // TableLayout layout = new TableLayout(cols,rows);
layout.setHGap( 5 ); // layout.setHGap( 5 );
layout.setVGap( 5 ); // layout.setVGap( 5 );
panelLegislacao.setLayout( layout ); // panelLegislacao.setLayout( layout );
} // }
//
private void startupComponents() // private void startupComponents()
{ // {
panelLegislacao.setPreferredSize( PREFERRED_DIMENSION_LEGISLACAO ); // panelLegislacao.setPreferredSize( PREFERRED_DIMENSION_LEGISLACAO );
panelLegislacao.setBorder( BorderFactory.createTitledBorder( "Legisla" + ccedil + otilde + "es" ) ); // panelLegislacao.setBorder( BorderFactory.createTitledBorder( "Legisla" + ccedil + otilde + "es" ) );
//
panelPostoTrabalho.setPreferredSize( PREFERRED_DIMENSION_POSTO_TRABALHO ); // panelPostoTrabalho.setPreferredSize( PREFERRED_DIMENSION_POSTO_TRABALHO );
panelPostoTrabalho.setBorder( BorderFactory.createTitledBorder( "Postos de trabalho" ) ); // panelPostoTrabalho.setBorder( BorderFactory.createTitledBorder( "Postos de trabalho" ) );
//
panelEmail.setPreferredSize( PREFERRED_DIMENSION_EMAIL ); // panelEmail.setPreferredSize( PREFERRED_DIMENSION_EMAIL );
panelEmail.setBorder( BorderFactory.createTitledBorder( "E-mails" ) ); // panelEmail.setBorder( BorderFactory.createTitledBorder( "E-mails" ) );
//
buttonEmailAdicionar.setEnabled( false ); // buttonEmailAdicionar.setEnabled( false );
buttonEmailRemover.setEnabled( false ); // buttonEmailRemover.setEnabled( false );
//
buttonLegislacaoAdicionar.setEnabled( false ); // buttonLegislacaoAdicionar.setEnabled( false );
buttonLegislacaoRemover.setEnabled( false ); // buttonLegislacaoRemover.setEnabled( false );
//
buttonPostoTrabalhoCriar.setEnabled( false ); // buttonPostoTrabalhoCriar.setEnabled( false );
buttonPostoTrabalhoEditar.setEnabled( false ); // buttonPostoTrabalhoEditar.setEnabled( false );
buttonPostoTrabalhoAdicionar.setEnabled( false ); // buttonPostoTrabalhoAdicionar.setEnabled( false );
buttonPostoTrabalhoRemover.setEnabled( false ); // buttonPostoTrabalhoRemover.setEnabled( false );
} // }
//
private void placeComponents() // private void placeComponents()
{ // {
//
panelEmail.add( scrollEmail, new TableLayoutConstraints( 0, 0, 2, 0 ) ); // panelEmail.add( scrollEmail, new TableLayoutConstraints( 0, 0, 2, 0 ) );
panelEmail.add( buttonEmailAdicionar, new TableLayoutConstraints( 0, 1 ) ); // panelEmail.add( buttonEmailAdicionar, new TableLayoutConstraints( 0, 1 ) );
panelEmail.add( buttonEmailRemover, new TableLayoutConstraints( 1, 1 ) ); // panelEmail.add( buttonEmailRemover, new TableLayoutConstraints( 1, 1 ) );
//
panelLegislacao.add( scrollLegislacao, new TableLayoutConstraints( 0, 0, 2, 0 ) ); // panelLegislacao.add( scrollLegislacao, new TableLayoutConstraints( 0, 0, 2, 0 ) );
panelLegislacao.add( buttonLegislacaoAdicionar, new TableLayoutConstraints( 0, 1 ) ); // panelLegislacao.add( buttonLegislacaoAdicionar, new TableLayoutConstraints( 0, 1 ) );
panelLegislacao.add( buttonLegislacaoRemover, new TableLayoutConstraints( 1, 1 ) ); // panelLegislacao.add( buttonLegislacaoRemover, new TableLayoutConstraints( 1, 1 ) );
//
panelPostoTrabalho.add( scrollPostoTrabalho, new TableLayoutConstraints( 0, 0, 4, 0 ) ); // panelPostoTrabalho.add( scrollPostoTrabalho, new TableLayoutConstraints( 0, 0, 4, 0 ) );
panelPostoTrabalho.add( buttonPostoTrabalhoCriar, new TableLayoutConstraints( 0, 1 ) ); // panelPostoTrabalho.add( buttonPostoTrabalhoCriar, new TableLayoutConstraints( 0, 1 ) );
panelPostoTrabalho.add( buttonPostoTrabalhoEditar, new TableLayoutConstraints( 1, 1 ) ); // panelPostoTrabalho.add( buttonPostoTrabalhoEditar, new TableLayoutConstraints( 1, 1 ) );
panelPostoTrabalho.add( buttonPostoTrabalhoAdicionar, new TableLayoutConstraints( 2, 1 ) ); // panelPostoTrabalho.add( buttonPostoTrabalhoAdicionar, new TableLayoutConstraints( 2, 1 ) );
panelPostoTrabalho.add( buttonPostoTrabalhoRemover, new TableLayoutConstraints( 3, 1 ) ); // panelPostoTrabalho.add( buttonPostoTrabalhoRemover, new TableLayoutConstraints( 3, 1 ) );
//
this.add( panelLegislacao, new TableLayoutConstraints( 0,0 ) ); // this.add( panelLegislacao, new TableLayoutConstraints( 0,0 ) );
this.add( panelPostoTrabalho, new TableLayoutConstraints( 1,0 ) ); // this.add( panelPostoTrabalho, new TableLayoutConstraints( 1,0 ) );
this.add( panelEmail, new TableLayoutConstraints( 2,0 ) ); // this.add( panelEmail, new TableLayoutConstraints( 2,0 ) );
//
} // }
//
private void refresh() // private void refresh()
{ // {
clear(); // clear();
load(); // load();
} // }
//
private void load() // private void load()
{ // {
if( estabelecimento != null ) // if( estabelecimento != null )
{ // {
modelEmail.setValues( new Vector<EmailPlanoDeActuacao>( estabelecimento.getEmailPlanoDeActuacaoArray() ) ); // modelEmail.setValues( new Vector<EmailPlanoDeActuacao>( estabelecimento.getEmailPlanoDeActuacaoArray() ) );
modelLegislacao.setValues( new Vector<LegislacaoEstabelecimento>( estabelecimento.getLegislacaoEstabelecimentoArray() ) ); // modelLegislacao.setValues( new Vector<LegislacaoEstabelecimento>( estabelecimento.getLegislacaoEstabelecimentoArray() ) );
modelPostoTrabalho.setValues( new Vector<PostoDeTrabalhoEstabelecimento>( estabelecimento.getPostoDeTrabalhoEstabelecimentoArray() ) ); // modelPostoTrabalho.setValues( new Vector<PostoDeTrabalhoEstabelecimento>( estabelecimento.getPostoDeTrabalhoEstabelecimentoArray() ) );
} // }
} // }
//
private void startupListeners() // private void startupListeners()
{ // {
buttonEmailAdicionar.addActionListener( new ActionListener() // buttonEmailAdicionar.addActionListener( new ActionListener()
{ // {
@Override // @Override
public void actionPerformed( ActionEvent e ) // public void actionPerformed( ActionEvent e )
{ // {
adicionarEmail(); // adicionarEmail();
} // }
} ); // } );
buttonEmailRemover.addActionListener( new ActionListener() // buttonEmailRemover.addActionListener( new ActionListener()
{ // {
@Override // @Override
public void actionPerformed( ActionEvent e ) // public void actionPerformed( ActionEvent e )
{ // {
removeSelected(tableEmail); // removeSelected(tableEmail);
} // }
} ); // } );
buttonLegislacaoAdicionar.addActionListener( new ActionListener() // buttonLegislacaoAdicionar.addActionListener( new ActionListener()
{ // {
@Override // @Override
public void actionPerformed( ActionEvent e ) // public void actionPerformed( ActionEvent e )
{ // {
adicionarLegislacao(); // adicionarLegislacao();
} // }
} ); // } );
buttonLegislacaoRemover.addActionListener( new ActionListener() // buttonLegislacaoRemover.addActionListener( new ActionListener()
{ // {
@Override // @Override
public void actionPerformed( ActionEvent e ) // public void actionPerformed( ActionEvent e )
{ // {
removeSelected(tableLegislacao); // removeSelected(tableLegislacao);
} // }
} ); // } );
buttonPostoTrabalhoCriar.addActionListener( new ActionListener() // buttonPostoTrabalhoCriar.addActionListener( new ActionListener()
{ // {
@Override // @Override
public void actionPerformed( ActionEvent e ) // public void actionPerformed( ActionEvent e )
{ // {
criarPostoTrabalho(); // criarPostoTrabalho();
} // }
} ); // } );
buttonPostoTrabalhoEditar.addActionListener( new ActionListener() // buttonPostoTrabalhoEditar.addActionListener( new ActionListener()
{ // {
@Override // @Override
public void actionPerformed( ActionEvent e ) // public void actionPerformed( ActionEvent e )
{ // {
alterarPostoTrabalho(); // alterarPostoTrabalho();
} // }
} ); // } );
buttonPostoTrabalhoAdicionar.addActionListener( new ActionListener() // buttonPostoTrabalhoAdicionar.addActionListener( new ActionListener()
{ // {
@Override // @Override
public void actionPerformed( ActionEvent e ) // public void actionPerformed( ActionEvent e )
{ // {
adicionarPostoTrabalho(); // adicionarPostoTrabalho();
} // }
} ); // } );
buttonPostoTrabalhoRemover.addActionListener( new ActionListener() // buttonPostoTrabalhoRemover.addActionListener( new ActionListener()
{ // {
@Override // @Override
public void actionPerformed( ActionEvent e ) // public void actionPerformed( ActionEvent e )
{ // {
removeSelected(tablePostoTrabalho); // removeSelected(tablePostoTrabalho);
} // }
} ); // } );
tableEmail.getSelectionModel().addListSelectionListener( new ListSelectionListener() // tableEmail.getSelectionModel().addListSelectionListener( new ListSelectionListener()
{ // {
@Override // @Override
public void valueChanged( ListSelectionEvent e ) // public void valueChanged( ListSelectionEvent e )
{ // {
if( !e.getValueIsAdjusting() ) // if( !e.getValueIsAdjusting() )
{ // {
buttonEmailRemover.setEnabled( tableEmail.getSelectedRowCount() > 0 ); // buttonEmailRemover.setEnabled( tableEmail.getSelectedRowCount() > 0 );
} // }
} // }
} ); // } );
tableLegislacao.getSelectionModel().addListSelectionListener( new ListSelectionListener() // tableLegislacao.getSelectionModel().addListSelectionListener( new ListSelectionListener()
{ // {
@Override // @Override
public void valueChanged( ListSelectionEvent e ) // public void valueChanged( ListSelectionEvent e )
{ // {
if( !e.getValueIsAdjusting() ) // if( !e.getValueIsAdjusting() )
{ // {
buttonLegislacaoRemover.setEnabled( tableLegislacao.getSelectedRowCount() > 0 ); // buttonLegislacaoRemover.setEnabled( tableLegislacao.getSelectedRowCount() > 0 );
} // }
} // }
} ); // } );
tablePostoTrabalho.getSelectionModel().addListSelectionListener( new ListSelectionListener() // tablePostoTrabalho.getSelectionModel().addListSelectionListener( new ListSelectionListener()
{ // {
@Override // @Override
public void valueChanged( ListSelectionEvent e ) // public void valueChanged( ListSelectionEvent e )
{ // {
if( !e.getValueIsAdjusting() ) // if( !e.getValueIsAdjusting() )
{ // {
buttonPostoTrabalhoEditar.setEnabled( tablePostoTrabalho.getSelectedRowCount() > 0 ); // buttonPostoTrabalhoEditar.setEnabled( tablePostoTrabalho.getSelectedRowCount() > 0 );
buttonPostoTrabalhoRemover.setEnabled( tablePostoTrabalho.getSelectedRowCount() > 0 ); // buttonPostoTrabalhoRemover.setEnabled( tablePostoTrabalho.getSelectedRowCount() > 0 );
} // }
} // }
} ); // } );
} // }
//
private void adicionarLegislacao() // private void adicionarLegislacao()
{ // {
Legislacao [] legislacoes = provider.getAllLegislacoesNotInEstabelecimento( estabelecimento ); // Legislacao [] legislacoes = provider.getAllLegislacoesNotInEstabelecimento( estabelecimento );
Legislacao legislacao = (Legislacao) JOptionPane.showInputDialog( // Legislacao legislacao = (Legislacao) JOptionPane.showInputDialog(
this, // this,
"Legisla" + ccedil + otilde + "es", // "Legisla" + ccedil + otilde + "es",
"Adicionar legisla" + ccedil + atilde + "o", JOptionPane.QUESTION_MESSAGE, null, legislacoes, null ); // "Adicionar legisla" + ccedil + atilde + "o", JOptionPane.QUESTION_MESSAGE, null, legislacoes, null );
adicionarLegislacao( legislacao ); // adicionarLegislacao( legislacao );
} // }
//
private void adicionarLegislacao( Legislacao legislacao ) // private void adicionarLegislacao( Legislacao legislacao )
{ // {
if( legislacao != null ) // if( legislacao != null )
{ // {
provider.addLegislacaoToEstabelecimento( legislacao, estabelecimento ); // provider.addLegislacaoToEstabelecimento( legislacao, estabelecimento );
refresh(); // refresh();
} // }
} // }
//
private void criarPostoTrabalho() // private void criarPostoTrabalho()
{ // {
String postoTrabalho = JOptionPane.showInputDialog( "Criar posto de trabalho" ); // String postoTrabalho = JOptionPane.showInputDialog( "Criar posto de trabalho" );
PostoDeTrabalho postoTrabalhoObject = criarPostoTrabalho( postoTrabalho ); // PostoDeTrabalho postoTrabalhoObject = criarPostoTrabalho( postoTrabalho );
if( postoTrabalhoObject != null ) // if( postoTrabalhoObject != null )
{ // {
adicionarPostoTrabalho( postoTrabalhoObject ); // adicionarPostoTrabalho( postoTrabalhoObject );
} // }
} // }
//
private PostoDeTrabalho criarPostoTrabalho( String postoTrabalho ) // private PostoDeTrabalho criarPostoTrabalho( String postoTrabalho )
{ // {
PostoDeTrabalho result = null; // PostoDeTrabalho result = null;
if( postoTrabalho != null ) // if( postoTrabalho != null )
{ // {
if( postoTrabalho.trim().length() > 0 ) // if( postoTrabalho.trim().length() > 0 )
{ // {
postoTrabalho = postoTrabalho.trim(); // postoTrabalho = postoTrabalho.trim();
result = provider.createPostoTrabalho( postoTrabalho ); // result = provider.createPostoTrabalho( postoTrabalho );
} // }
else // else
{ // {
JOptionPane.showMessageDialog( this, "Posto de trabalho inv" + aacute + "lido", "Erro", JOptionPane.ERROR_MESSAGE, null ); // JOptionPane.showMessageDialog( this, "Posto de trabalho inv" + aacute + "lido", "Erro", JOptionPane.ERROR_MESSAGE, null );
} // }
} // }
return result; // return result;
} // }
//
private PostoDeTrabalhoEstabelecimento getSelectedPostoTrabalhoRel() // private PostoDeTrabalhoEstabelecimento getSelectedPostoTrabalhoRel()
{ // {
PostoDeTrabalhoEstabelecimento result = null; // PostoDeTrabalhoEstabelecimento result = null;
int index = tablePostoTrabalho.getSelectedRow(); // int index = tablePostoTrabalho.getSelectedRow();
if( index != -1 ) // if( index != -1 )
{ // {
result = modelPostoTrabalho.getRowAt( index ); // result = modelPostoTrabalho.getRowAt( index );
} // }
return result; // return result;
} // }
//
private void alterarPostoTrabalho() // private void alterarPostoTrabalho()
{ // {
PostoDeTrabalhoEstabelecimento rel = getSelectedPostoTrabalhoRel(); // PostoDeTrabalhoEstabelecimento rel = getSelectedPostoTrabalhoRel();
if( rel != null ) // if( rel != null )
{ // {
String newDescription = JOptionPane.showInputDialog( "Editar medida", rel.getToPostoDeTrabalho().getDescription() ); // String newDescription = JOptionPane.showInputDialog( "Editar medida", rel.getToPostoDeTrabalho().getDescription() );
if( newDescription != null ) // if( newDescription != null )
{ // {
if( newDescription.trim().length() > 0 ) // if( newDescription.trim().length() > 0 )
{ // {
rel.getToPostoDeTrabalho().setDescription( newDescription ); // rel.getToPostoDeTrabalho().setDescription( newDescription );
provider.commit(); // provider.commit();
refresh(); // refresh();
} // }
else // else
{ // {
JOptionPane.showMessageDialog( this, "Medida inv" + aacute + "lida", "Erro", JOptionPane.ERROR_MESSAGE, null ); // JOptionPane.showMessageDialog( this, "Medida inv" + aacute + "lida", "Erro", JOptionPane.ERROR_MESSAGE, null );
} // }
} // }
} // }
} // }
//
private void adicionarPostoTrabalho() // private void adicionarPostoTrabalho()
{ // {
PostoDeTrabalho [] postos = provider.getAllPostosNotInEstabelecimento( estabelecimento ); // PostoDeTrabalho [] postos = provider.getAllPostosNotInEstabelecimento( estabelecimento );
PostoDeTrabalho postoDeTrabalho = (PostoDeTrabalho) JOptionPane.showInputDialog( // PostoDeTrabalho postoDeTrabalho = (PostoDeTrabalho) JOptionPane.showInputDialog(
this, // this,
"Postos de trabalho", // "Postos de trabalho",
"Adicionar posto de trabalho", // "Adicionar posto de trabalho",
JOptionPane.QUESTION_MESSAGE, // JOptionPane.QUESTION_MESSAGE,
null, // null,
postos, // postos,
null // null
); // );
adicionarPostoTrabalho( postoDeTrabalho ); // adicionarPostoTrabalho( postoDeTrabalho );
} // }
//
private void adicionarPostoTrabalho( PostoDeTrabalho postoTrabalho ) // private void adicionarPostoTrabalho( PostoDeTrabalho postoTrabalho )
{ // {
if( postoTrabalho != null ) // if( postoTrabalho != null )
{ // {
provider.addPostoTrabalhoToEstabelecimento( postoTrabalho, estabelecimento ); // provider.addPostoTrabalhoToEstabelecimento( postoTrabalho, estabelecimento );
refresh(); // refresh();
} // }
} // }
//
private void adicionarEmail() // private void adicionarEmail()
{ // {
adicionarEmail( JOptionPane.showInputDialog( "Inserir e-mail" ) ); // adicionarEmail( JOptionPane.showInputDialog( "Inserir e-mail" ) );
} // }
//
private void adicionarEmail( String email ) // private void adicionarEmail( String email )
{ // {
if( email != null && email.trim().length() > 0 ) // if( email != null && email.trim().length() > 0 )
{ // {
email = email.trim(); // email = email.trim();
boolean valid = email.toUpperCase().matches( "[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,6}" ); // boolean valid = email.toUpperCase().matches( "[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,6}" );
if( valid ) // if( valid )
{ // {
provider.addEmailToEstabelecimento( email, estabelecimento); // provider.addEmailToEstabelecimento( email, estabelecimento);
refresh(); // refresh();
} // }
else // else
{ // {
JOptionPane.showMessageDialog( this, "Endere" + ccedil + "o de e-mail inv" + aacute + "lido", "Erro", JOptionPane.ERROR_MESSAGE, null ); // JOptionPane.showMessageDialog( this, "Endere" + ccedil + "o de e-mail inv" + aacute + "lido", "Erro", JOptionPane.ERROR_MESSAGE, null );
} // }
} // }
} // }
//
private void removeSelected( JTable table ) // private void removeSelected( JTable table )
{ // {
VectorTableModel<? extends CayenneDataObject> model = (VectorTableModel<? extends CayenneDataObject>) table.getModel(); // VectorTableModel<? extends CayenneDataObject> model = (VectorTableModel<? extends CayenneDataObject>) table.getModel();
int indexes [] = table.getSelectedRows(); // int indexes [] = table.getSelectedRows();
if( indexes != null && indexes.length > 0 ) // if( indexes != null && indexes.length > 0 )
{ // {
for( int i = 0; i < indexes.length; ++i ) // for( int i = 0; i < indexes.length; ++i )
{ // {
removeSelected( model, indexes[i] ); // removeSelected( model, indexes[i] );
} // }
refresh(); // refresh();
} // }
} // }
//
private void removeSelected( VectorTableModel<? extends CayenneDataObject> model, int index ) // private void removeSelected( VectorTableModel<? extends CayenneDataObject> model, int index )
{ // {
provider.delete( model.getRowAt( index ) ); // provider.delete( model.getRowAt( index ) );
} // }
@Override @Override
public void clear() public void clear()
{ {
modelEmail.clearAll(); // modelEmail.clearAll();
modelLegislacao.clearAll(); // modelLegislacao.clearAll();
modelPostoTrabalho.clearAll(); // modelPostoTrabalho.clearAll();
} }
@Override @Override
public void fill( Object value ) public void fill( Object value )
{ {
if( value != null ) // if( value != null )
{ // {
if( value instanceof Integer ) // if( value instanceof Integer )
{ // {
estabelecimento = provider.getEstabelecimentoByID( (Integer) value ); // estabelecimento = provider.getEstabelecimentoByID( (Integer) value );
} // }
setEnabled( true ); // setEnabled( true );
} // }
else // else
{ // {
estabelecimento = null; // estabelecimento = null;
setEnabled( false ); // setEnabled( false );
} // }
refresh(); // refresh();
} }
@Override @Override
@ -487,16 +456,16 @@ public class EstabelecimentoPlanoActuacaoPanel extends JPanel implements Control
@Override @Override
public void setEnabled( boolean enabled ) public void setEnabled( boolean enabled )
{ {
tableEmail.setEnabled( enabled ); // tableEmail.setEnabled( enabled );
tableLegislacao.setEnabled( enabled ); // tableLegislacao.setEnabled( enabled );
tablePostoTrabalho.setEnabled( enabled ); // tablePostoTrabalho.setEnabled( enabled );
buttonEmailAdicionar.setEnabled( enabled ); // buttonEmailAdicionar.setEnabled( enabled );
buttonLegislacaoAdicionar.setEnabled( enabled ); // buttonLegislacaoAdicionar.setEnabled( enabled );
buttonPostoTrabalhoAdicionar.setEnabled( enabled ); // buttonPostoTrabalhoAdicionar.setEnabled( enabled );
buttonPostoTrabalhoCriar.setEnabled( enabled ); // buttonPostoTrabalhoCriar.setEnabled( enabled );
tableEmail.clearSelection(); // tableEmail.clearSelection();
tableLegislacao.clearSelection(); // tableLegislacao.clearSelection();
tablePostoTrabalho.clearSelection(); // tablePostoTrabalho.clearSelection();
} }
} }

Loading…
Cancel
Save