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.
SIPRP/trunk/SIPRPSoft/src/siprp/clientes/EstabelecimentoPlanoActuaca...

472 lines
15 KiB

package siprp.clientes;
import javax.swing.JPanel;
import com.evolute.utils.dataui.ControllableComponent;
public class EstabelecimentoPlanoActuacaoPanel extends JPanel implements ControllableComponent
{
// private static final long serialVersionUID = 1L;
//
// 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_POSTO_TRABALHO = new Dimension(300,0);
//
// 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<PostoDeTrabalhoEstabelecimento> modelPostoTrabalho= new VectorTableModel<PostoDeTrabalhoEstabelecimento>( new String[]{ "Descri" + ccedil + atilde + "o" } );
//
// private final JTable tableEmail = new JTable( modelEmail );
//
// private final JTable tableLegislacao = new JTable( modelLegislacao );
//
// 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 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 JPanel panelEmail = new JPanel();
//
// private final JPanel panelLegislacao = new JPanel();
//
// private final JPanel panelPostoTrabalho = new JPanel();
//
// private final JButton buttonEmailAdicionar = new JButton("Adicionar");
//
// private final JButton buttonLegislacaoAdicionar = new JButton("Adicionar");
//
// private final JButton buttonPostoTrabalhoCriar = new JButton("Criar");
//
// private final JButton buttonPostoTrabalhoEditar = new JButton("Editar");
//
// private final JButton buttonPostoTrabalhoAdicionar = new JButton("Adicionar");
//
// private final JButton buttonEmailRemover = new JButton("Remover");
//
// private final JButton buttonLegislacaoRemover = new JButton("Remover");
//
// private final JButton buttonPostoTrabalhoRemover = new JButton("Remover");
//
// private final PlanoActuacaoDAO provider = new PlanoActuacaoDAO();
//
// private Estabelecimentos estabelecimento = null;
//
public EstabelecimentoPlanoActuacaoPanel()
{
// startupComponents();
// startupLayout();
// placeComponents();
// 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 ) );
// }
@Override
public void clear()
{
// modelEmail.clearAll();
// modelLegislacao.clearAll();
// modelPostoTrabalho.clearAll();
}
@Override
public void fill( Object value )
{
// if( value != null )
// {
// if( value instanceof Integer )
// {
// estabelecimento = provider.getEstabelecimentoByID( (Integer) value );
// }
// setEnabled( true );
// }
// else
// {
// estabelecimento = null;
// setEnabled( false );
// }
// refresh();
}
@Override
public Object save()
{
return null;
}
@Override
public void setEnabled( boolean enabled )
{
// tableEmail.setEnabled( enabled );
// tableLegislacao.setEnabled( enabled );
// tablePostoTrabalho.setEnabled( enabled );
// buttonEmailAdicionar.setEnabled( enabled );
// buttonLegislacaoAdicionar.setEnabled( enabled );
// buttonPostoTrabalhoAdicionar.setEnabled( enabled );
// buttonPostoTrabalhoCriar.setEnabled( enabled );
// tableEmail.clearSelection();
// tableLegislacao.clearSelection();
// tablePostoTrabalho.clearSelection();
}
}