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()
{
startupEmailLayout();
startupPostoTrabalhoLayout();
startupLegislacaoLayout();
double [] cols = new double[]{ TableLayout.FILL, TableLayout.FILL, TableLayout.PREFERRED };
double [] rows = new double[]{ TableLayout.FILL };
TableLayout layout = new TableLayout(cols,rows);
layout.setHGap( 5 );
layout.setVGap( 5 );
this.setLayout( layout );
}
private void startupEmailLayout()
{
double [] cols = new double[]{ TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.FILL };
double [] rows = new double[]{ TableLayout.FILL, TableLayout.MINIMUM };
TableLayout layout = new TableLayout(cols,rows);
layout.setHGap( 5 );
layout.setVGap( 5 );
panelEmail.setLayout( layout );
}
private void startupPostoTrabalhoLayout()
{
double [] cols = new double[]{ TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.FILL };
double [] rows = new double[]{ TableLayout.FILL, TableLayout.MINIMUM };
TableLayout layout = new TableLayout(cols,rows);
layout.setHGap( 5 );
layout.setVGap( 5 );
panelPostoTrabalho.setLayout( layout );
}
private void startupLegislacaoLayout()
{
double [] cols = new double[]{ TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.FILL };
double [] rows = new double[]{ TableLayout.FILL, TableLayout.MINIMUM };
TableLayout layout = new TableLayout(cols,rows);
layout.setHGap( 5 );
layout.setVGap( 5 );
panelLegislacao.setLayout( layout );
}
private void startupComponents()
{
panelLegislacao.setPreferredSize( PREFERRED_DIMENSION_LEGISLACAO );
panelLegislacao.setBorder( BorderFactory.createTitledBorder( "Legisla" + ccedil + otilde + "es" ) );
panelPostoTrabalho.setPreferredSize( PREFERRED_DIMENSION_POSTO_TRABALHO );
panelPostoTrabalho.setBorder( BorderFactory.createTitledBorder( "Postos de trabalho" ) );
panelEmail.setPreferredSize( PREFERRED_DIMENSION_EMAIL );
panelEmail.setBorder( BorderFactory.createTitledBorder( "E-mails" ) );
buttonEmailAdicionar.setEnabled( false );
buttonEmailRemover.setEnabled( false );
buttonLegislacaoAdicionar.setEnabled( false );
buttonLegislacaoRemover.setEnabled( false );
buttonPostoTrabalhoCriar.setEnabled( false );
buttonPostoTrabalhoEditar.setEnabled( false );
buttonPostoTrabalhoAdicionar.setEnabled( false );
buttonPostoTrabalhoRemover.setEnabled( false );
}
private void placeComponents()
{
panelEmail.add( scrollEmail, new TableLayoutConstraints( 0, 0, 2, 0 ) );
panelEmail.add( buttonEmailAdicionar, new TableLayoutConstraints( 0, 1 ) );
panelEmail.add( buttonEmailRemover, new TableLayoutConstraints( 1, 1 ) );
panelLegislacao.add( scrollLegislacao, new TableLayoutConstraints( 0, 0, 2, 0 ) );
panelLegislacao.add( buttonLegislacaoAdicionar, new TableLayoutConstraints( 0, 1 ) );
panelLegislacao.add( buttonLegislacaoRemover, new TableLayoutConstraints( 1, 1 ) );
panelPostoTrabalho.add( scrollPostoTrabalho, new TableLayoutConstraints( 0, 0, 4, 0 ) );
panelPostoTrabalho.add( buttonPostoTrabalhoCriar, new TableLayoutConstraints( 0, 1 ) );
panelPostoTrabalho.add( buttonPostoTrabalhoEditar, new TableLayoutConstraints( 1, 1 ) );
panelPostoTrabalho.add( buttonPostoTrabalhoAdicionar, new TableLayoutConstraints( 2, 1 ) );
panelPostoTrabalho.add( buttonPostoTrabalhoRemover, new TableLayoutConstraints( 3, 1 ) );
this.add( panelLegislacao, new TableLayoutConstraints( 0,0 ) );
this.add( panelPostoTrabalho, new TableLayoutConstraints( 1,0 ) );
this.add( panelEmail, new TableLayoutConstraints( 2,0 ) );
}
private void refresh()
{
clear();
load();
}
private void load()
{
if( estabelecimento != null )
{
modelEmail.setValues( new Vector<EmailPlanoDeActuacao>( estabelecimento.getEmailPlanoDeActuacaoArray() ) );
modelLegislacao.setValues( new Vector<LegislacaoEstabelecimento>( estabelecimento.getLegislacaoEstabelecimentoArray() ) );
modelPostoTrabalho.setValues( new Vector<PostoDeTrabalhoEstabelecimento>( estabelecimento.getPostoDeTrabalhoEstabelecimentoArray() ) );
}
}
private void startupListeners()
{
buttonEmailAdicionar.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
adicionarEmail();
}
} );
buttonEmailRemover.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
removeSelected(tableEmail);
}
} );
buttonLegislacaoAdicionar.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
adicionarLegislacao();
}
} );
buttonLegislacaoRemover.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
removeSelected(tableLegislacao);
}
} );
buttonPostoTrabalhoCriar.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
criarPostoTrabalho();
}
} );
buttonPostoTrabalhoEditar.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
alterarPostoTrabalho();
}
} );
buttonPostoTrabalhoAdicionar.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
adicionarPostoTrabalho();
}
} );
buttonPostoTrabalhoRemover.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
removeSelected(tablePostoTrabalho);
}
} );
tableEmail.getSelectionModel().addListSelectionListener( new ListSelectionListener()
{
@Override
public void valueChanged( ListSelectionEvent e )
{
if( !e.getValueIsAdjusting() )
{
buttonEmailRemover.setEnabled( tableEmail.getSelectedRowCount() > 0 );
}
}
} );
tableLegislacao.getSelectionModel().addListSelectionListener( new ListSelectionListener()
{
@Override
public void valueChanged( ListSelectionEvent e )
{
if( !e.getValueIsAdjusting() )
{
buttonLegislacaoRemover.setEnabled( tableLegislacao.getSelectedRowCount() > 0 );
}
}
} );
tablePostoTrabalho.getSelectionModel().addListSelectionListener( new ListSelectionListener()
{
@Override
public void valueChanged( ListSelectionEvent e )
{
if( !e.getValueIsAdjusting() )
{
buttonPostoTrabalhoEditar.setEnabled( tablePostoTrabalho.getSelectedRowCount() > 0 );
buttonPostoTrabalhoRemover.setEnabled( tablePostoTrabalho.getSelectedRowCount() > 0 );
}
}
} );
}
private void adicionarLegislacao()
{
Legislacao [] legislacoes = provider.getAllLegislacoesNotInEstabelecimento( estabelecimento );
Legislacao legislacao = (Legislacao) JOptionPane.showInputDialog(
this,
"Legisla" + ccedil + otilde + "es",
"Adicionar legisla" + ccedil + atilde + "o", JOptionPane.QUESTION_MESSAGE, null, legislacoes, null );
adicionarLegislacao( legislacao );
}
private void adicionarLegislacao( Legislacao legislacao )
{
if( legislacao != null )
{
provider.addLegislacaoToEstabelecimento( legislacao, estabelecimento );
refresh();
}
}
private void criarPostoTrabalho()
{
String postoTrabalho = JOptionPane.showInputDialog( "Criar posto de trabalho" );
PostoDeTrabalho postoTrabalhoObject = criarPostoTrabalho( postoTrabalho );
if( postoTrabalhoObject != null )
{
adicionarPostoTrabalho( postoTrabalhoObject );
}
}
private PostoDeTrabalho criarPostoTrabalho( String postoTrabalho )
{
PostoDeTrabalho result = null;
if( postoTrabalho != null )
{
if( postoTrabalho.trim().length() > 0 )
{
postoTrabalho = postoTrabalho.trim();
result = provider.createPostoTrabalho( postoTrabalho );
}
else
{
JOptionPane.showMessageDialog( this, "Posto de trabalho inv" + aacute + "lido", "Erro", JOptionPane.ERROR_MESSAGE, null );
}
}
return result;
}
private PostoDeTrabalhoEstabelecimento getSelectedPostoTrabalhoRel()
{
PostoDeTrabalhoEstabelecimento result = null;
int index = tablePostoTrabalho.getSelectedRow();
if( index != -1 )
{
result = modelPostoTrabalho.getRowAt( index );
}
return result;
}
private void alterarPostoTrabalho()
{
PostoDeTrabalhoEstabelecimento rel = getSelectedPostoTrabalhoRel();
if( rel != null )
{
String newDescription = JOptionPane.showInputDialog( "Editar medida", rel.getToPostoDeTrabalho().getDescription() );
if( newDescription != null )
{
if( newDescription.trim().length() > 0 )
{
rel.getToPostoDeTrabalho().setDescription( newDescription );
provider.commit();
refresh();
}
else
{
JOptionPane.showMessageDialog( this, "Medida inv" + aacute + "lida", "Erro", JOptionPane.ERROR_MESSAGE, null );
}
}
}
}
private void adicionarPostoTrabalho()
{
PostoDeTrabalho [] postos = provider.getAllPostosNotInEstabelecimento( estabelecimento );
PostoDeTrabalho postoDeTrabalho = (PostoDeTrabalho) JOptionPane.showInputDialog(
this,
"Postos de trabalho",
"Adicionar posto de trabalho",
JOptionPane.QUESTION_MESSAGE,
null,
postos,
null
);
adicionarPostoTrabalho( postoDeTrabalho );
}
private void adicionarPostoTrabalho( PostoDeTrabalho postoTrabalho )
{
if( postoTrabalho != null )
{
provider.addPostoTrabalhoToEstabelecimento( postoTrabalho, estabelecimento );
refresh();
}
}
private void adicionarEmail()
{
adicionarEmail( JOptionPane.showInputDialog( "Inserir e-mail" ) );
}
private void adicionarEmail( String email )
{
if( email != null && email.trim().length() > 0 )
{
email = email.trim();
boolean valid = email.toUpperCase().matches( "[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,6}" );
if( valid )
{
provider.addEmailToEstabelecimento( email, estabelecimento);
refresh();
}
else
{
JOptionPane.showMessageDialog( this, "Endere" + ccedil + "o de e-mail inv" + aacute + "lido", "Erro", JOptionPane.ERROR_MESSAGE, null );
}
}
}
private void removeSelected( JTable table )
{
VectorTableModel<? extends CayenneDataObject> model = (VectorTableModel<? extends CayenneDataObject>) table.getModel();
int indexes [] = table.getSelectedRows();
if( indexes != null && indexes.length > 0 )
{
for( int i = 0; i < indexes.length; ++i )
{
removeSelected( model, indexes[i] );
}
refresh();
}
}
private void removeSelected( VectorTableModel<? extends CayenneDataObject> model, int index )
{
provider.delete( model.getRowAt( index ) );
} }
//
// private void startupLayout()
// {
// startupEmailLayout();
// startupPostoTrabalhoLayout();
// startupLegislacaoLayout();
// double [] cols = new double[]{ TableLayout.FILL, TableLayout.FILL, TableLayout.PREFERRED };
// double [] rows = new double[]{ TableLayout.FILL };
// TableLayout layout = new TableLayout(cols,rows);
// layout.setHGap( 5 );
// layout.setVGap( 5 );
// this.setLayout( layout );
// }
//
// private void startupEmailLayout()
// {
// double [] cols = new double[]{ TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.FILL };
// double [] rows = new double[]{ TableLayout.FILL, TableLayout.MINIMUM };
// TableLayout layout = new TableLayout(cols,rows);
// layout.setHGap( 5 );
// layout.setVGap( 5 );
// panelEmail.setLayout( layout );
// }
//
// private void startupPostoTrabalhoLayout()
// {
// double [] cols = new double[]{ TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.FILL };
// double [] rows = new double[]{ TableLayout.FILL, TableLayout.MINIMUM };
// TableLayout layout = new TableLayout(cols,rows);
// layout.setHGap( 5 );
// layout.setVGap( 5 );
// panelPostoTrabalho.setLayout( layout );
// }
//
// private void startupLegislacaoLayout()
// {
// double [] cols = new double[]{ TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.FILL };
// double [] rows = new double[]{ TableLayout.FILL, TableLayout.MINIMUM };
// TableLayout layout = new TableLayout(cols,rows);
// layout.setHGap( 5 );
// layout.setVGap( 5 );
// panelLegislacao.setLayout( layout );
// }
//
// private void startupComponents()
// {
// panelLegislacao.setPreferredSize( PREFERRED_DIMENSION_LEGISLACAO );
// panelLegislacao.setBorder( BorderFactory.createTitledBorder( "Legisla" + ccedil + otilde + "es" ) );
//
// panelPostoTrabalho.setPreferredSize( PREFERRED_DIMENSION_POSTO_TRABALHO );
// panelPostoTrabalho.setBorder( BorderFactory.createTitledBorder( "Postos de trabalho" ) );
//
// panelEmail.setPreferredSize( PREFERRED_DIMENSION_EMAIL );
// panelEmail.setBorder( BorderFactory.createTitledBorder( "E-mails" ) );
//
// buttonEmailAdicionar.setEnabled( false );
// buttonEmailRemover.setEnabled( false );
//
// buttonLegislacaoAdicionar.setEnabled( false );
// buttonLegislacaoRemover.setEnabled( false );
//
// buttonPostoTrabalhoCriar.setEnabled( false );
// buttonPostoTrabalhoEditar.setEnabled( false );
// buttonPostoTrabalhoAdicionar.setEnabled( false );
// buttonPostoTrabalhoRemover.setEnabled( false );
// }
//
// private void placeComponents()
// {
//
// panelEmail.add( scrollEmail, new TableLayoutConstraints( 0, 0, 2, 0 ) );
// panelEmail.add( buttonEmailAdicionar, new TableLayoutConstraints( 0, 1 ) );
// panelEmail.add( buttonEmailRemover, new TableLayoutConstraints( 1, 1 ) );
//
// panelLegislacao.add( scrollLegislacao, new TableLayoutConstraints( 0, 0, 2, 0 ) );
// panelLegislacao.add( buttonLegislacaoAdicionar, new TableLayoutConstraints( 0, 1 ) );
// panelLegislacao.add( buttonLegislacaoRemover, new TableLayoutConstraints( 1, 1 ) );
//
// panelPostoTrabalho.add( scrollPostoTrabalho, new TableLayoutConstraints( 0, 0, 4, 0 ) );
// panelPostoTrabalho.add( buttonPostoTrabalhoCriar, new TableLayoutConstraints( 0, 1 ) );
// panelPostoTrabalho.add( buttonPostoTrabalhoEditar, new TableLayoutConstraints( 1, 1 ) );
// panelPostoTrabalho.add( buttonPostoTrabalhoAdicionar, new TableLayoutConstraints( 2, 1 ) );
// panelPostoTrabalho.add( buttonPostoTrabalhoRemover, new TableLayoutConstraints( 3, 1 ) );
//
// this.add( panelLegislacao, new TableLayoutConstraints( 0,0 ) );
// this.add( panelPostoTrabalho, new TableLayoutConstraints( 1,0 ) );
// this.add( panelEmail, new TableLayoutConstraints( 2,0 ) );
//
// }
//
// private void refresh()
// {
// clear();
// load();
// }
//
// private void load()
// {
// if( estabelecimento != null )
// {
// modelEmail.setValues( new Vector<EmailPlanoDeActuacao>( estabelecimento.getEmailPlanoDeActuacaoArray() ) );
// modelLegislacao.setValues( new Vector<LegislacaoEstabelecimento>( estabelecimento.getLegislacaoEstabelecimentoArray() ) );
// modelPostoTrabalho.setValues( new Vector<PostoDeTrabalhoEstabelecimento>( estabelecimento.getPostoDeTrabalhoEstabelecimentoArray() ) );
// }
// }
//
// private void startupListeners()
// {
// buttonEmailAdicionar.addActionListener( new ActionListener()
// {
// @Override
// public void actionPerformed( ActionEvent e )
// {
// adicionarEmail();
// }
// } );
// buttonEmailRemover.addActionListener( new ActionListener()
// {
// @Override
// public void actionPerformed( ActionEvent e )
// {
// removeSelected(tableEmail);
// }
// } );
// buttonLegislacaoAdicionar.addActionListener( new ActionListener()
// {
// @Override
// public void actionPerformed( ActionEvent e )
// {
// adicionarLegislacao();
// }
// } );
// buttonLegislacaoRemover.addActionListener( new ActionListener()
// {
// @Override
// public void actionPerformed( ActionEvent e )
// {
// removeSelected(tableLegislacao);
// }
// } );
// buttonPostoTrabalhoCriar.addActionListener( new ActionListener()
// {
// @Override
// public void actionPerformed( ActionEvent e )
// {
// criarPostoTrabalho();
// }
// } );
// buttonPostoTrabalhoEditar.addActionListener( new ActionListener()
// {
// @Override
// public void actionPerformed( ActionEvent e )
// {
// alterarPostoTrabalho();
// }
// } );
// buttonPostoTrabalhoAdicionar.addActionListener( new ActionListener()
// {
// @Override
// public void actionPerformed( ActionEvent e )
// {
// adicionarPostoTrabalho();
// }
// } );
// buttonPostoTrabalhoRemover.addActionListener( new ActionListener()
// {
// @Override
// public void actionPerformed( ActionEvent e )
// {
// removeSelected(tablePostoTrabalho);
// }
// } );
// tableEmail.getSelectionModel().addListSelectionListener( new ListSelectionListener()
// {
// @Override
// public void valueChanged( ListSelectionEvent e )
// {
// if( !e.getValueIsAdjusting() )
// {
// buttonEmailRemover.setEnabled( tableEmail.getSelectedRowCount() > 0 );
// }
// }
// } );
// tableLegislacao.getSelectionModel().addListSelectionListener( new ListSelectionListener()
// {
// @Override
// public void valueChanged( ListSelectionEvent e )
// {
// if( !e.getValueIsAdjusting() )
// {
// buttonLegislacaoRemover.setEnabled( tableLegislacao.getSelectedRowCount() > 0 );
// }
// }
// } );
// tablePostoTrabalho.getSelectionModel().addListSelectionListener( new ListSelectionListener()
// {
// @Override
// public void valueChanged( ListSelectionEvent e )
// {
// if( !e.getValueIsAdjusting() )
// {
// buttonPostoTrabalhoEditar.setEnabled( tablePostoTrabalho.getSelectedRowCount() > 0 );
// buttonPostoTrabalhoRemover.setEnabled( tablePostoTrabalho.getSelectedRowCount() > 0 );
// }
// }
// } );
// }
//
// private void adicionarLegislacao()
// {
// Legislacao [] legislacoes = provider.getAllLegislacoesNotInEstabelecimento( estabelecimento );
// Legislacao legislacao = (Legislacao) JOptionPane.showInputDialog(
// this,
// "Legisla" + ccedil + otilde + "es",
// "Adicionar legisla" + ccedil + atilde + "o", JOptionPane.QUESTION_MESSAGE, null, legislacoes, null );
// adicionarLegislacao( legislacao );
// }
//
// private void adicionarLegislacao( Legislacao legislacao )
// {
// if( legislacao != null )
// {
// provider.addLegislacaoToEstabelecimento( legislacao, estabelecimento );
// refresh();
// }
// }
//
// private void criarPostoTrabalho()
// {
// String postoTrabalho = JOptionPane.showInputDialog( "Criar posto de trabalho" );
// PostoDeTrabalho postoTrabalhoObject = criarPostoTrabalho( postoTrabalho );
// if( postoTrabalhoObject != null )
// {
// adicionarPostoTrabalho( postoTrabalhoObject );
// }
// }
//
// private PostoDeTrabalho criarPostoTrabalho( String postoTrabalho )
// {
// PostoDeTrabalho result = null;
// if( postoTrabalho != null )
// {
// if( postoTrabalho.trim().length() > 0 )
// {
// postoTrabalho = postoTrabalho.trim();
// result = provider.createPostoTrabalho( postoTrabalho );
// }
// else
// {
// JOptionPane.showMessageDialog( this, "Posto de trabalho inv" + aacute + "lido", "Erro", JOptionPane.ERROR_MESSAGE, null );
// }
// }
// return result;
// }
//
// private PostoDeTrabalhoEstabelecimento getSelectedPostoTrabalhoRel()
// {
// PostoDeTrabalhoEstabelecimento result = null;
// int index = tablePostoTrabalho.getSelectedRow();
// if( index != -1 )
// {
// result = modelPostoTrabalho.getRowAt( index );
// }
// return result;
// }
//
// private void alterarPostoTrabalho()
// {
// PostoDeTrabalhoEstabelecimento rel = getSelectedPostoTrabalhoRel();
// if( rel != null )
// {
// String newDescription = JOptionPane.showInputDialog( "Editar medida", rel.getToPostoDeTrabalho().getDescription() );
// if( newDescription != null )
// {
// if( newDescription.trim().length() > 0 )
// {
// rel.getToPostoDeTrabalho().setDescription( newDescription );
// provider.commit();
// refresh();
// }
// else
// {
// JOptionPane.showMessageDialog( this, "Medida inv" + aacute + "lida", "Erro", JOptionPane.ERROR_MESSAGE, null );
// }
// }
// }
// }
//
// private void adicionarPostoTrabalho()
// {
// PostoDeTrabalho [] postos = provider.getAllPostosNotInEstabelecimento( estabelecimento );
// PostoDeTrabalho postoDeTrabalho = (PostoDeTrabalho) JOptionPane.showInputDialog(
// this,
// "Postos de trabalho",
// "Adicionar posto de trabalho",
// JOptionPane.QUESTION_MESSAGE,
// null,
// postos,
// null
// );
// adicionarPostoTrabalho( postoDeTrabalho );
// }
//
// private void adicionarPostoTrabalho( PostoDeTrabalho postoTrabalho )
// {
// if( postoTrabalho != null )
// {
// provider.addPostoTrabalhoToEstabelecimento( postoTrabalho, estabelecimento );
// refresh();
// }
// }
//
// private void adicionarEmail()
// {
// adicionarEmail( JOptionPane.showInputDialog( "Inserir e-mail" ) );
// }
//
// private void adicionarEmail( String email )
// {
// if( email != null && email.trim().length() > 0 )
// {
// email = email.trim();
// boolean valid = email.toUpperCase().matches( "[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,6}" );
// if( valid )
// {
// provider.addEmailToEstabelecimento( email, estabelecimento);
// refresh();
// }
// else
// {
// JOptionPane.showMessageDialog( this, "Endere" + ccedil + "o de e-mail inv" + aacute + "lido", "Erro", JOptionPane.ERROR_MESSAGE, null );
// }
// }
// }
//
// private void removeSelected( JTable table )
// {
// VectorTableModel<? extends CayenneDataObject> model = (VectorTableModel<? extends CayenneDataObject>) table.getModel();
// int indexes [] = table.getSelectedRows();
// if( indexes != null && indexes.length > 0 )
// {
// for( int i = 0; i < indexes.length; ++i )
// {
// removeSelected( model, indexes[i] );
// }
// refresh();
// }
// }
//
// private void removeSelected( VectorTableModel<? extends CayenneDataObject> model, int 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