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

lxbfYeaa
Tiago Simão 17 years ago
parent 620715c814
commit 61dadc84a6

@ -15,7 +15,7 @@ public class GestaoRelatorioWindow extends JFrame implements TrackableWindow
public static final String TITLE = "Gest" + atilde + "o de Relat" + oacute + "rio de Higiene e Seguran" + ccedil + "a";
private static final Dimension SIZE = new Dimension( 800, 600 );
private static final Dimension SIZE = new Dimension( 1024, 700 );
private static final long serialVersionUID = 1L;

@ -3,6 +3,7 @@ package siprp.higiene.gestao;
import javax.swing.JTabbedPane;
import siprp.higiene.gestao.legislacao.GerirLegislacaoPanel;
import siprp.higiene.gestao.normalizacao.GerirNormalizacaoPanel;
import siprp.higiene.gestao.riscos.GerirRiscosPanel;
import static com.evolute.utils.strings.UnicodeLatin1Map.*;
@ -15,6 +16,8 @@ public class GlobalPanel extends JTabbedPane
private final GerirRiscosPanel panelRiscos = new GerirRiscosPanel();
private final GerirLegislacaoPanel panelLegislacao = new GerirLegislacaoPanel();
private final GerirNormalizacaoPanel panelNormalizacao= new GerirNormalizacaoPanel();
public GlobalPanel()
{
@ -28,6 +31,7 @@ public class GlobalPanel extends JTabbedPane
{
addTab( "Riscos", panelRiscos );
addTab( "Legisla" + ccedil + atilde + "o", panelLegislacao );
addTab( "Normaliza" + ccedil + atilde + "o", panelNormalizacao );
}
private void setupLayout()

@ -363,9 +363,17 @@ public class GerirLegislacaoPanel extends JPanel
private void removerCategoria()
{
if( selectedCategoria != null )
try
{
selectedCategoria.setDeletedDate( new Date() );
if( selectedCategoria != null )
{
selectedCategoria.setDeletedDate( new Date() );
selectedCategoria.save();
reload();
}
} catch( Exception e )
{
LeafError.error( e );
}
}

@ -0,0 +1,504 @@
package siprp.higiene.gestao.normalizacao;
import static com.evolute.utils.strings.UnicodeLatin1Map.atilde;
import static com.evolute.utils.strings.UnicodeLatin1Map.ccedil;
import static com.evolute.utils.strings.UnicodeLatin1Map.oacute;
import info.clearthought.layout.TableLayout;
import info.clearthought.layout.TableLayoutConstraints;
import java.awt.GridLayout;
import java.awt.LayoutManager;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.Date;
import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.JTree;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath;
import javax.swing.tree.TreeSelectionModel;
import leaf.data.Validator;
import leaf.ui.LeafButton;
import leaf.ui.LeafError;
import leaf.ui.LeafTextAreaEditor;
import leaf.ui.TreeTools;
import siprp.database.cayenne.objects.HsNormalizacao;
import siprp.logic.HigieneSegurancaLogic;
public class GerirNormalizacaoPanel extends JPanel
{
private static final long serialVersionUID = 1L;
private final JPanel panelPortuguesa = new JPanel();
private final JPanel panelInternacional = new JPanel();
private final JPanel panelButtonsPortuguesa = new JPanel();
private final LeafButton buttonPortuguesaCriar = new LeafButton( "Criar" );
private final LeafButton buttonPortuguesaEditar = new LeafButton( "Editar" );
private final LeafButton buttonPortuguesaRemover = new LeafButton( "Remover" );
private final JPanel panelButtonsInternacional = new JPanel();
private final LeafButton buttonInternacionalCriar = new LeafButton( "Criar" );
private final LeafButton buttonInternacionalEditar = new LeafButton( "Editar" );
private final LeafButton buttonInternacionalRemover = new LeafButton( "Remover" );
private final DefaultMutableTreeNode rootPortuguesa = new DefaultMutableTreeNode();
private final DefaultTreeModel modelPortuguesa = new DefaultTreeModel( rootPortuguesa );
private final JTree treePortuguesa = new JTree( modelPortuguesa );
private final JScrollPane scrollPortuguesa = new JScrollPane( treePortuguesa );
private final DefaultMutableTreeNode rootInternacional = new DefaultMutableTreeNode();
private final DefaultTreeModel modelInternacional = new DefaultTreeModel( rootInternacional );
private final JTree treeInternacional = new JTree( modelInternacional );
private final JScrollPane scrollInternacional = new JScrollPane( treeInternacional );
private HsNormalizacao selectedPortuguesa = null;
private HsNormalizacao selectedInternacional = null;
private final JPanel panelData = new JPanel();
private final JTextField textCodigo = new JTextField(10);
private final LeafTextAreaEditor textDescricao = new LeafTextAreaEditor( new Validator<String>()
{
@Override
public boolean isValid( String object )
{
return true;
}
} );
public GerirNormalizacaoPanel()
{
startupComponents();
startupLayout();
placeComponents();
setupListeners();
reload();
}
private void startupComponents()
{
panelPortuguesa.setBorder( BorderFactory.createTitledBorder( "Normaliza" + ccedil + atilde + "o Portuguesa" ) );
panelInternacional.setBorder( BorderFactory.createTitledBorder( "Normaliza" + ccedil + atilde + "o Internacional" ) );
treeInternacional.setRootVisible( false );
treePortuguesa.setRootVisible( false );
treeInternacional.getSelectionModel().setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION );
treePortuguesa.getSelectionModel().setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION );
textCodigo.setEnabled( false );
}
private void startupLayout()
{
LayoutManager layout = new TableLayout( new double[] {
TableLayout.FILL, TableLayout.FILL
}, new double[] {
TableLayout.FILL, TableLayout.FILL
} );
this.setLayout( layout );
layout = new TableLayout( new double[] {
TableLayout.MINIMUM, TableLayout.FILL
}, new double[] {
TableLayout.MINIMUM, TableLayout.FILL
} );
panelPortuguesa.setLayout( layout );
((TableLayout) layout).setHGap( 5 );
((TableLayout) layout).setVGap( 5 );
layout = new TableLayout( new double[] {
TableLayout.MINIMUM, TableLayout.FILL
}, new double[] {
TableLayout.MINIMUM, TableLayout.FILL
} );
((TableLayout) layout).setHGap( 5 );
((TableLayout) layout).setVGap( 5 );
panelInternacional.setLayout( layout );
layout = new GridLayout( 3, 1, 5, 5 );
panelButtonsPortuguesa.setLayout( layout );
layout = new GridLayout( 3, 1, 5, 5 );
panelButtonsInternacional.setLayout( layout );
layout = new TableLayout( new double[] {
TableLayout.MINIMUM, TableLayout.PREFERRED, TableLayout.FILL
}, new double[] {
TableLayout.MINIMUM, TableLayout.FILL
} );
((TableLayout) layout).setHGap( 5 );
((TableLayout) layout).setVGap( 5 );
panelData.setLayout( layout );
}
private void placeComponents()
{
panelButtonsPortuguesa.add( buttonPortuguesaCriar );
panelButtonsPortuguesa.add( buttonPortuguesaEditar );
panelButtonsPortuguesa.add( buttonPortuguesaRemover );
panelButtonsInternacional.add( buttonInternacionalCriar );
panelButtonsInternacional.add( buttonInternacionalEditar );
panelButtonsInternacional.add( buttonInternacionalRemover );
panelPortuguesa.add( panelButtonsPortuguesa, new TableLayoutConstraints( 0, 0 ) );
panelPortuguesa.add( scrollPortuguesa, new TableLayoutConstraints( 1, 0, 1, 1 ) );
panelInternacional.add( panelButtonsInternacional, new TableLayoutConstraints( 0, 0 ) );
panelInternacional.add( scrollInternacional, new TableLayoutConstraints( 1, 0, 1, 1 ) );
panelData.add( new JLabel("C" + oacute + "digo"), new TableLayoutConstraints( 0, 0 ) );
panelData.add( textCodigo, new TableLayoutConstraints( 1, 0 ) );
panelData.add( textDescricao, new TableLayoutConstraints( 0, 1, 2, 1 ) );
this.add( panelPortuguesa, new TableLayoutConstraints( 0, 0 ) );
this.add( panelInternacional, new TableLayoutConstraints( 0, 1 ) );
this.add( panelData, new TableLayoutConstraints( 1, 0, 1, 1 ) );
}
private void setupListeners()
{
treeInternacional.getSelectionModel().addTreeSelectionListener( new TreeSelectionListener()
{
@Override
public void valueChanged( TreeSelectionEvent e )
{
TreePath selectionPath = e.getNewLeadSelectionPath();
if( selectionPath != null )
{
Object last = selectionPath.getLastPathComponent();
if( last instanceof DefaultMutableTreeNode )
{
Object userObject = ((DefaultMutableTreeNode) last).getUserObject();
if( userObject instanceof HsNormalizacao )
{
selectedInternacional = (HsNormalizacao) userObject;
}
}
treePortuguesa.clearSelection();
selectedPortuguesa = null;
}
else
{
selectedInternacional = null;
}
refreshData();
setEnable();
}
} );
treePortuguesa.getSelectionModel().addTreeSelectionListener( new TreeSelectionListener()
{
@Override
public void valueChanged( TreeSelectionEvent e )
{
TreePath selectionPath = e.getNewLeadSelectionPath();
if( selectionPath != null )
{
Object last = selectionPath.getLastPathComponent();
if( last instanceof DefaultMutableTreeNode )
{
Object userObject = ((DefaultMutableTreeNode) last).getUserObject();
if( userObject instanceof HsNormalizacao )
{
selectedPortuguesa = (HsNormalizacao) userObject;
}
}
treeInternacional.clearSelection();
selectedInternacional = null;
}
else
{
selectedPortuguesa = null;
}
refreshData();
setEnable();
}
} );
textDescricao.addPropertyChangeListener( LeafTextAreaEditor.ACTION_SAVE, new PropertyChangeListener()
{
@Override
public void propertyChange( PropertyChangeEvent evt )
{
try
{
String newValue = (String) evt.getNewValue();
if( selectedInternacional != null )
{
selectedInternacional.setDescricao( newValue );
selectedInternacional.save();
}
else if( selectedPortuguesa != null )
{
selectedPortuguesa.setDescricao( newValue );
selectedPortuguesa.save();
}
reload();
} catch( Exception e )
{
LeafError.error( e );
}
}
} );
buttonPortuguesaCriar.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
criarPortuguesa();
}
} );
buttonPortuguesaEditar.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
editarPortuguesa();
}
} );
buttonPortuguesaRemover.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
removerPortuguesa();
}
} );
buttonInternacionalCriar.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
criarInternacional();
}
} );
buttonInternacionalEditar.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
editarInternacional();
}
} );
buttonInternacionalRemover.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
removerInternacional();
}
} );
}
private String getCodigoForNormalizacao( boolean criar, boolean portuguesa )
{
String result = null;
if( criar )
{
result = JOptionPane.showInputDialog( this, "C" + oacute + "digo", "Criar normaliza" + ccedil + atilde + "o" + (portuguesa ? " Portuguesa": " internacional"), JOptionPane.QUESTION_MESSAGE );
}
else
{
result = JOptionPane.showInputDialog( this, "C" + oacute + "digo", portuguesa ? selectedPortuguesa.getCodigo() : selectedInternacional.getCodigo() );
}
return result;
}
private boolean isValidCodigo( String codigo )
{
boolean result = false;
if( codigo != null )
{
result = true;
}
return result;
}
private void criarPortuguesa()
{
try
{
String codigo = getCodigoForNormalizacao(true,true);
if( isValidCodigo(codigo) )
{
HsNormalizacao normalizacao = new HsNormalizacao();
normalizacao.setDescricao( "" );
normalizacao.setCodigo( codigo );
normalizacao.setPortuguesa( true );
normalizacao.save();
reload();
}
} catch( Exception e )
{
LeafError.error( e );
}
}
private void editarPortuguesa()
{
try
{
if( selectedPortuguesa != null )
{
String codigo = getCodigoForNormalizacao(false, true);
if( isValidCodigo(codigo) )
{
selectedPortuguesa.setCodigo( codigo );
selectedPortuguesa.save();
reload();
}
}
} catch( Exception e )
{
LeafError.error( e );
}
}
private void removerPortuguesa()
{
try
{
if( selectedPortuguesa != null )
{
selectedPortuguesa.setDeletedDate( new Date() );
selectedPortuguesa.save();
reload();
}
} catch( Exception e )
{
LeafError.error( e );
}
}
private void criarInternacional()
{
try
{
String codigo = getCodigoForNormalizacao(true, false);
if( isValidCodigo(codigo) )
{
HsNormalizacao normalizacao = new HsNormalizacao();
normalizacao.setDescricao( "" );
normalizacao.setCodigo( codigo );
normalizacao.setPortuguesa( false );
normalizacao.save();
reload();
}
} catch( Exception e )
{
LeafError.error( e );
}
}
private void editarInternacional()
{
try
{
if( selectedInternacional != null )
{
String codigo = getCodigoForNormalizacao(false, false);
if( isValidCodigo(codigo) )
{
selectedInternacional.setCodigo( codigo );
selectedInternacional.save();
reload();
}
}
} catch( Exception e )
{
LeafError.error( e );
}
}
private void removerInternacional()
{
try
{
if( selectedInternacional != null )
{
selectedInternacional.setDeletedDate( new Date() );
selectedInternacional.save();
reload();
}
} catch( Exception e )
{
LeafError.error( e );
}
}
private void reload()
{
rootPortuguesa.removeAllChildren();
rootInternacional.removeAllChildren();
textCodigo.setText( "" );
TreeTools.merge( rootPortuguesa, HigieneSegurancaLogic.getNormalizacao( true ) );
TreeTools.merge( rootInternacional, HigieneSegurancaLogic.getNormalizacao( false ) );
TreeTools.refreshTree( treePortuguesa, rootPortuguesa );
TreeTools.refreshTree( treeInternacional, rootInternacional );
}
private void refreshData()
{
buttonInternacionalRemover.setEnabled( false );
buttonPortuguesaRemover.setEnabled( false );
buttonInternacionalEditar.setEnabled( false );
buttonPortuguesaEditar.setEnabled( false );
textDescricao.setEnabled( false );
if( selectedInternacional != null )
{
textDescricao.setValue( selectedInternacional.getDescricao() );
textDescricao.setEnabled( true );
textCodigo.setText( selectedInternacional.getCodigo() );
}
else if( selectedPortuguesa != null )
{
textDescricao.setValue( selectedPortuguesa.getDescricao() );
textDescricao.setEnabled( true );
textCodigo.setText( selectedPortuguesa.getCodigo() );
}
else
{
textDescricao.setValue( null );
textCodigo.setText( "" );
}
}
private void setEnable()
{
buttonPortuguesaEditar.setEnabled( selectedPortuguesa != null );
buttonPortuguesaRemover.setEnabled( selectedPortuguesa != null );
buttonInternacionalEditar.setEnabled( selectedInternacional != null );
buttonInternacionalRemover.setEnabled( selectedInternacional != null );
}
}

@ -130,7 +130,7 @@ public class AdicionarAreasPanel extends JPanel
{
DefaultMutableTreeNode allPostos = HigieneSegurancaLogic.getAreasTree( estabelecimento.getToEmpresas() );
TreeTools.removeAll( allPostos, HigieneSegurancaLogic.getPostosTree( estabelecimento ) );
TreeInserterDialog dialog = new TreeInserterDialog( "Adicionar Postos de Trabalho", allPostos );
TreeInserterDialog dialog = new TreeInserterDialog( this, "Adicionar Postos de Trabalho", allPostos );
save( dialog.getResult() );
refresh();
}

@ -36,31 +36,35 @@ import siprp.logic.node.PostoNode;
public class GerirAreasPanel extends JPanel
{
private static final long serialVersionUID = 1L;
private final JPanel panelButtons = new JPanel();
private final JPanel panelTree = new JPanel();
public final LeafButton buttonAreaCriar = new LeafButton( "Criar" );
public final LeafButton buttonAreaEditar = new LeafButton( "Editar" );
public final LeafButton buttonAreaRemover = new LeafButton( "Remover" );
public final LeafButton buttonPostoCriar = new LeafButton( "Criar" );
public final LeafButton buttonPostoEditar = new LeafButton( "Editar" );
public final LeafButton buttonPostoRemover = new LeafButton( "Remover" );
private final DefaultMutableTreeNode root = new DefaultMutableTreeNode();
private final DefaultTreeModel model = new DefaultTreeModel( root );
public final JTree tree = new JTree( model );
private final JScrollPane scroll = new JScrollPane( tree );
private Empresas empresa = null;
public GerirAreasPanel()
{
startupComponents();
@ -69,7 +73,6 @@ public class GerirAreasPanel extends JPanel
setupListeners();
}
private void startupComponents()
{
panelButtons.setPreferredSize( new Dimension( 150, 0 ) );
@ -77,59 +80,65 @@ public class GerirAreasPanel extends JPanel
tree.setRootVisible( false );
tree.getSelectionModel().setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION );
}
private void startupLayout()
{
TableLayout layout = new TableLayout(
new double[]{ TableLayout.FILL },
new double[]{ TableLayout.MINIMUM, TableLayout.FILL }
);
TableLayout layout = new TableLayout( new double[] {
TableLayout.FILL
}, new double[] {
TableLayout.MINIMUM, TableLayout.FILL
} );
layout.setHGap( 5 );
layout.setVGap( 5 );
setLayout( layout );
layout = new TableLayout(
new double[]{ TableLayout.MINIMUM, TableLayout.FILL, TableLayout.MINIMUM },
new double[]{ TableLayout.MINIMUM }
);
layout = new TableLayout( new double[] {
TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.FILL
}, new double[] {
TableLayout.MINIMUM
} );
layout.setHGap( 5 );
layout.setVGap( 5 );
panelButtons.setLayout( layout );
layout = new TableLayout(
new double[]{ TableLayout.FILL },
new double[]{ TableLayout.FILL }
);
layout = new TableLayout( new double[] {
TableLayout.FILL
}, new double[] {
TableLayout.FILL
} );
layout.setHGap( 5 );
layout.setVGap( 5 );
panelTree.setLayout( layout );
}
private void placeComponents()
{
JPanel panel = new JPanel();
panel.setBorder( BorderFactory.createTitledBorder( "Area" ) );
panel.setLayout( new GridLayout( 2, 1 ) );
panel.setLayout( new GridLayout( 3, 1 ) );
panel.add( buttonAreaCriar );
panel.add( buttonAreaEditar );
panel.add( buttonAreaRemover );
panelButtons.add( panel, new TableLayoutConstraints( 0, 0 ) );
panel = new JPanel();
panel.setBorder( BorderFactory.createTitledBorder( "Posto" ) );
panel.setLayout( new GridLayout( 2, 1 ) );
panel.setLayout( new GridLayout( 3, 1 ) );
panel.add( buttonPostoCriar );
panel.add( buttonPostoEditar );
panel.add( buttonPostoRemover );
panelButtons.add( panel, new TableLayoutConstraints( 2, 0 ) );
panelTree.add( scroll, new TableLayoutConstraints( 0,0 ) );
panelButtons.add( panel, new TableLayoutConstraints( 1, 0 ) );
panelTree.add( scroll, new TableLayoutConstraints( 0, 0 ) );
add( panelButtons, new TableLayoutConstraints( 0, 0 ) );
add( panelTree, new TableLayoutConstraints( 0, 1 ) );
}
private void setupListeners()
{
tree.getSelectionModel().addTreeSelectionListener( new TreeSelectionListener(){
tree.getSelectionModel().addTreeSelectionListener( new TreeSelectionListener()
{
@Override
public void valueChanged( TreeSelectionEvent e )
{
@ -144,6 +153,14 @@ public class GerirAreasPanel extends JPanel
criarArea();
}
} );
buttonAreaEditar.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
editarArea();
}
} );
buttonAreaRemover.addActionListener( new ActionListener()
{
@Override
@ -160,6 +177,14 @@ public class GerirAreasPanel extends JPanel
criarPosto();
}
} );
buttonPostoEditar.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
editarPosto();
}
} );
buttonPostoRemover.addActionListener( new ActionListener()
{
@Override
@ -169,7 +194,7 @@ public class GerirAreasPanel extends JPanel
}
} );
}
private void criarArea()
{
try
@ -188,10 +213,31 @@ public class GerirAreasPanel extends JPanel
}
} catch( Exception e )
{
LeafError.error(e);
LeafError.error( e );
}
}
private void editarArea()
{
try
{
HsArea area = getSelectedArea();
if( area != null )
{
String areaString = JOptionPane.showInputDialog( this, "Descri" + ccedil + atilde + "o", area.getDescription() );
if( areaString != null )
{
area.setDescription( areaString );
area.save();
refresh();
}
}
} catch( Exception e )
{
LeafError.error( e );
}
}
private void removerArea()
{
try
@ -204,10 +250,10 @@ public class GerirAreasPanel extends JPanel
}
} catch( Exception e )
{
LeafError.error(e);
LeafError.error( e );
}
}
private void criarPosto()
{
try
@ -228,10 +274,31 @@ public class GerirAreasPanel extends JPanel
}
} catch( Exception e )
{
LeafError.error(e);
LeafError.error( e );
}
}
private void editarPosto()
{
try
{
HsPosto posto = getSelectedPosto();
if( posto != null )
{
String postoString = JOptionPane.showInputDialog( this, "Descri" + ccedil + atilde + "o", posto.getDescription() );
if( postoString != null )
{
posto.setDescription( postoString );
posto.save();
refresh();
}
}
} catch( Exception e )
{
LeafError.error( e );
}
}
private void removerPosto()
{
try
@ -245,10 +312,10 @@ public class GerirAreasPanel extends JPanel
}
} catch( Exception e )
{
LeafError.error(e);
LeafError.error( e );
}
}
private HsArea getSelectedArea()
{
HsArea result = null;
@ -258,19 +325,19 @@ public class GerirAreasPanel extends JPanel
Object leaf = path.getLastPathComponent();
if( leaf != null )
{
if(leaf instanceof AreaNode)
if( leaf instanceof AreaNode )
{
result = (HsArea) ((AreaNode)leaf).getUserObject();
result = (HsArea) ((AreaNode) leaf).getUserObject();
}
else if(leaf instanceof PostoNode)
else if( leaf instanceof PostoNode )
{
result = (HsArea) ((HsPosto)((PostoNode)leaf).getUserObject()).getToHsArea();
result = (HsArea) ((HsPosto) ((PostoNode) leaf).getUserObject()).getToHsArea();
}
}
}
return result;
}
private HsPosto getSelectedPosto()
{
HsPosto result = null;
@ -278,54 +345,55 @@ public class GerirAreasPanel extends JPanel
if( path != null )
{
Object leaf = path.getLastPathComponent();
if( leaf != null && ( leaf instanceof PostoNode ) )
if( leaf != null && (leaf instanceof PostoNode) )
{
result = (HsPosto) ((PostoNode)leaf).getUserObject();
result = (HsPosto) ((PostoNode) leaf).getUserObject();
}
}
return result;
}
private void setEnabled()
{
TreePath path = tree.getSelectionPath();
TreeNode node = path == null ? null : (TreeNode) path.getLastPathComponent();
boolean areaSelected = node != null && ( node instanceof AreaNode );
boolean postoSelected = node != null && ( node instanceof PostoNode );
boolean areaSelected = node != null && (node instanceof AreaNode);
boolean postoSelected = node != null && (node instanceof PostoNode);
buttonPostoCriar.setEnabled( areaSelected || postoSelected );
buttonPostoEditar.setEnabled( postoSelected );
buttonPostoRemover.setEnabled( postoSelected );
buttonAreaRemover.setEnabled( areaSelected );
buttonAreaCriar.setEnabled( empresa != null );
buttonAreaEditar.setEnabled( areaSelected );
}
public void refresh()
{
root.removeAllChildren();
if( empresa != null )
{
for( HsArea area : empresa.getHsAreaArray())
for( HsArea area : empresa.getHsAreaArray() )
{
addArea( area );
}
}
setEnabled();
TreeTools.refreshTree(tree, root);
TreeTools.refreshTree( tree, root );
}
private void addArea( HsArea area )
{
if( area != null )
{
AreaNode areaNode = new AreaNode( area );
for ( HsPosto posto : area.getHsPostoArray() )
for( HsPosto posto : area.getHsPostoArray() )
{
addPosto( posto, areaNode );
}
root.add( areaNode );
}
}
private void addPosto( HsPosto posto, AreaNode areaNode )
{
if( posto != null && posto.getDeletedDate() == null )
@ -340,5 +408,5 @@ public class GerirAreasPanel extends JPanel
this.empresa = empresa;
refresh();
}
}

@ -136,7 +136,7 @@ public class AdicionarRiscosPanel extends JPanel
{
DefaultMutableTreeNode allRiscos = getAllRiscos();
TreeTools.removeAll( allRiscos, getRiscosTree() );
TreeInserterDialog dialog = new TreeInserterDialog( "Adicionar Riscos", allRiscos );
TreeInserterDialog dialog = new TreeInserterDialog( this, "Adicionar Riscos", allRiscos );
DefaultMutableTreeNode result = dialog.getResult();
if( result != null )
{

@ -20,6 +20,7 @@ import siprp.database.cayenne.objects.HsMedida;
import com.evolute.utils.images.ImageException;
import com.evolute.utils.images.ImageIconLoader;
import com.evolute.utils.ui.text.CopyPasteHandler;
public class GerirMedidaPanel extends JPanel
{
@ -66,8 +67,10 @@ public class GerirMedidaPanel extends JPanel
{
fieldTextMedida.setWrapStyleWord( true );
fieldTextMedida.setLineWrap( true );
new CopyPasteHandler(fieldTextMedida);
fieldTextRequisitosLegais.setWrapStyleWord( true );
fieldTextRequisitosLegais.setLineWrap( true );
new CopyPasteHandler(fieldTextRequisitosLegais);
scrollMedida.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
scrollMedida.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS );
scrollRequesitos.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );

@ -405,7 +405,7 @@ public class GerirRiscosPanel extends JPanel
private void startupComponents()
{
panelButtons.setPreferredSize( new Dimension( 150, 0 ) );
panelTree.setPreferredSize( new Dimension( 300, 0 ) );
panelTree.setPreferredSize( new Dimension( 400, 0 ) );
tree.setRootVisible( false );
tree.getSelectionModel().setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION );
}

@ -6,7 +6,6 @@ import static com.evolute.utils.strings.UnicodeLatin1Map.ccedil;
import static com.evolute.utils.strings.UnicodeLatin1Map.eacute;
import static com.evolute.utils.strings.UnicodeLatin1Map.iacute;
import static com.evolute.utils.strings.UnicodeLatin1Map.oacute;
import static com.evolute.utils.strings.UnicodeLatin1Map.otilde;
import info.clearthought.layout.TableLayout;
import info.clearthought.layout.TableLayoutConstraints;
@ -59,11 +58,11 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
private final JTextField fieldNome1 = new JTextField();
private final JTextField fieldNome2 = new JTextField();
private final JTextField fieldNome3 = new JTextField();
// private final JTextField fieldNome3 = new JTextField();
private final JTextField fieldFuncao1 = new JTextField();
private final JTextField fieldFuncao2 = new JTextField();
private final JTextField fieldFuncao3 = new JTextField();
// private final JTextField fieldFuncao3 = new JTextField();
private final LeafIconButton buttonSave = LeafIconButton.createButton( ICON_NAME_SAVE );
private final LeafIconButton buttonRevert = LeafIconButton.createButton( ICON_NAME_REVERT );
@ -92,20 +91,20 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
private void startupComponents()
{
dataRelatorio.setPreferredSize( new Dimension( 150, 0 ) );
panelEquipamentos.setPreferredSize( new Dimension( 200, 0 ) );
panelEquipamentos.setPreferredSize( new Dimension( 400, 0 ) );
fieldFuncao1.setPreferredSize( new Dimension( 100, 0 ) );
bg.add( radioInicial );
bg.add( radioPeriodica );
panelAcompanhantes.setBorder( BorderFactory.createTitledBorder( "Pessoas que acompanharam" ) );
panelEquipamentos.setBorder( BorderFactory.createTitledBorder( "Equipamentos de medi"+ccedil+atilde+"o" ) );
tabs.addTab( "Plano de actua" + ccedil + atilde + "o", panelPlano );
tabs.addTab( "Legisla" + ccedil + otilde + "es", panelLegislacao );
tabs.addTab( "Legisla" + ccedil + atilde + "o", panelLegislacao );
}
private void startupLayout()
{
TableLayout layout = new TableLayout( new double[] {
TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.PREFERRED, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.FILL
TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.PREFERRED, TableLayout.FILL, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.PREFERRED
}, new double[] {
TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.FILL
} );
@ -116,7 +115,7 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
layout = new TableLayout( new double[] {
TableLayout.MINIMUM, TableLayout.FILL, TableLayout.MINIMUM, TableLayout.PREFERRED
}, new double[] {
TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM
TableLayout.MINIMUM, TableLayout.MINIMUM/*, TableLayout.MINIMUM*/
} );
layout.setVGap( 5 );
layout.setHGap( 5 );
@ -133,10 +132,10 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
panelAcompanhantes.add( fieldNome2, new TableLayoutConstraints( 1, 1 ) );
panelAcompanhantes.add( new JLabel( "Fun" + ccedil + atilde + "o" ), new TableLayoutConstraints( 2, 1 ) );
panelAcompanhantes.add( fieldFuncao2, new TableLayoutConstraints( 3, 1 ) );
panelAcompanhantes.add( new JLabel( "Nome" ), new TableLayoutConstraints( 0, 2 ) );
panelAcompanhantes.add( fieldNome3, new TableLayoutConstraints( 1, 2 ) );
panelAcompanhantes.add( new JLabel( "Fun" + ccedil + atilde + "o" ), new TableLayoutConstraints( 2, 2 ) );
panelAcompanhantes.add( fieldFuncao3, new TableLayoutConstraints( 3, 2 ) );
// panelAcompanhantes.add( new JLabel( "Nome" ), new TableLayoutConstraints( 0, 2 ) );
// panelAcompanhantes.add( fieldNome3, new TableLayoutConstraints( 1, 2 ) );
// panelAcompanhantes.add( new JLabel( "Fun" + ccedil + atilde + "o" ), new TableLayoutConstraints( 2, 2 ) );
// panelAcompanhantes.add( fieldFuncao3, new TableLayoutConstraints( 3, 2 ) );
TableLayout layout = new TableLayout( new double[] {
TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.FILL, TableLayout.MINIMUM
@ -155,10 +154,12 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
add( panel, new TableLayoutConstraints( 0, 0, 7, 0 ) );
add( new JLabel( "Data do relat" + oacute + "rio" ), new TableLayoutConstraints( 0, 1, 2, 1 ) );
add( dataRelatorio, new TableLayoutConstraints( 3, 1 ) );
add( new JLabel( "Avalia" + ccedil + atilde + "o" ), new TableLayoutConstraints( 4, 1 ) );
JLabel labelAvaliacao = new JLabel( "Avalia" + ccedil + atilde + "o" );
labelAvaliacao.setHorizontalAlignment( JLabel.RIGHT );
add( labelAvaliacao , new TableLayoutConstraints( 4, 1 ) );
add( radioInicial, new TableLayoutConstraints( 5, 1 ) );
add( radioPeriodica, new TableLayoutConstraints( 6, 1 ) );
add( new JLabel( "T" + eacute + "cnico de H.S." ), new TableLayoutConstraints( 0, 2, 2, 2 ) );
add( new JLabel( "T" + eacute + "cnico Superior de H.S." ), new TableLayoutConstraints( 0, 2, 2, 2 ) );
add( fieldTecnico, new TableLayoutConstraints( 3, 2, 6, 2 ) );
add( panelEquipamentos, new TableLayoutConstraints( 7, 1, 7, 3 ) );
add( panelAcompanhantes, new TableLayoutConstraints( 0, 3, 6, 3 ) );
@ -169,10 +170,10 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
{
fieldFuncao1.addCaretListener( this );
fieldFuncao2.addCaretListener( this );
fieldFuncao3.addCaretListener( this );
// fieldFuncao3.addCaretListener( this );
fieldNome1.addCaretListener( this );
fieldNome2.addCaretListener( this );
fieldNome3.addCaretListener( this );
// fieldNome3.addCaretListener( this );
dataRelatorio.addChangeListener( this );
radioInicial.addActionListener( this );
radioPeriodica.addActionListener( this );
@ -258,11 +259,11 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
}
relatorio.setAcompanhante1( fieldNome1.getText() );
relatorio.setAcompanhante2( fieldNome2.getText() );
relatorio.setAcompanhante3( fieldNome3.getText() );
// relatorio.setAcompanhante3( fieldNome3.getText() );
relatorio.setFuncaoAcompanhante1(fieldFuncao1.getText());
relatorio.setFuncaoAcompanhante2(fieldFuncao2.getText());
relatorio.setFuncaoAcompanhante3(fieldFuncao3.getText());
// relatorio.setFuncaoAcompanhante3(fieldFuncao3.getText());
relatorio.save();
refresh();
buttonRevert.setEnabled( false );
@ -308,10 +309,10 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
fieldTecnico.setText( tecnicoName );
fieldNome1.setText( relatorio == null ? null : relatorio.getAcompanhante1() );
fieldNome2.setText( relatorio == null ? null : relatorio.getAcompanhante2() );
fieldNome3.setText( relatorio == null ? null : relatorio.getAcompanhante3() );
// fieldNome3.setText( relatorio == null ? null : relatorio.getAcompanhante3() );
fieldFuncao1.setText( relatorio == null ? null : relatorio.getFuncaoAcompanhante1() );
fieldFuncao2.setText( relatorio == null ? null : relatorio.getFuncaoAcompanhante2() );
fieldFuncao3.setText( relatorio == null ? null : relatorio.getFuncaoAcompanhante3() );
// fieldFuncao3.setText( relatorio == null ? null : relatorio.getFuncaoAcompanhante3() );
}
private void setEnabled()
@ -323,10 +324,10 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
fieldTecnico.setEnabled( false );
fieldNome1.setEnabled( enabled );
fieldNome2.setEnabled( enabled );
fieldNome3.setEnabled( enabled );
// fieldNome3.setEnabled( enabled );
fieldFuncao1.setEnabled( enabled );
fieldFuncao2.setEnabled( enabled );
fieldFuncao3.setEnabled( enabled );
// fieldFuncao3.setEnabled( enabled );
buttonSubmit.setEnabled( enabled );
}

@ -7,6 +7,7 @@ import info.clearthought.layout.TableLayout;
import info.clearthought.layout.TableLayoutConstraints;
import java.awt.CardLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyChangeEvent;
@ -149,13 +150,14 @@ public class PlanoActuacaoPanel extends JPanel
{
riscos.setBorder( BorderFactory.createTitledBorder( "Medidas" ) );
areas.setBorder( BorderFactory.createTitledBorder( "Postos de trabalho" ) );
areas.setPreferredSize( new Dimension(250,0) );
buttonRevert.setToolTipText( "Carregar dados do estabelecimento" );
}
private void startupLayout()
{
TableLayout layout = new TableLayout(
new double[]{ TableLayout.MINIMUM, TableLayout.FILL, TableLayout.FILL, TableLayout.FILL },
new double[]{ TableLayout.MINIMUM, TableLayout.PREFERRED, TableLayout.FILL, TableLayout.FILL },
new double[]{ TableLayout.MINIMUM, TableLayout.FILL }
);
layout.setHGap( 5 );

@ -9,12 +9,27 @@
package siprp.update;
import java.util.*;
import java.util.Vector;
import com.evolute.utils.*;
import com.evolute.utils.arrays.*;
import com.evolute.utils.db.*;
import com.evolute.utils.sql.*;
import siprp.update.updates.V10_0_To_V10_1;
import siprp.update.updates.V9_1_To_V9_2;
import siprp.update.updates.V9_2_To_V9_3;
import siprp.update.updates.V9_3_To_V9_4;
import siprp.update.updates.V9_4_To_V9_5;
import siprp.update.updates.V9_5_To_V9_6;
import siprp.update.updates.V9_6_To_V9_7;
import siprp.update.updates.V9_7_To_V9_8;
import siprp.update.updates.V9_8_To_V9_9;
import siprp.update.updates.V9_9_To_V10_0;
import com.evolute.utils.Singleton;
import com.evolute.utils.arrays.Virtual2DArray;
import com.evolute.utils.db.DBManager;
import com.evolute.utils.db.Executer;
import com.evolute.utils.sql.Assignment;
import com.evolute.utils.sql.Field;
import com.evolute.utils.sql.Insert;
import com.evolute.utils.sql.Select;
/**
@ -25,21 +40,21 @@ public class UpdateList
{
protected static final Update UPDATE_LIST[] =
new Update[]{
// new siprp.update.updates.V6_1_To_V7_0(), new siprp.update.updates.V7_0_To_V7_2(),
// new siprp.update.updates.V7_2_To_V7_4(), new siprp.update.updates.V7_4_To_V7_5(),
// new siprp.update.updates.V7_5_To_V7_6(), new siprp.update.updates.V7_6_To_V7_7(),
// new siprp.update.updates.V7_7_To_V7_8(), new siprp.update.updates.V7_8_To_V7_9(),
// new siprp.update.updates.V7_9_To_V8_0(), new siprp.update.updates.V8_0_To_V8_1(),
// new siprp.update.updates.V8_1_To_V8_2(), new siprp.update.updates.V8_2_To_V8_3(),
// new siprp.update.updates.V8_3_To_V8_4(), new siprp.update.updates.V8_4_To_V8_5(),
// new siprp.update.updates.V8_5_To_V8_6(), new siprp.update.updates.V8_6_To_V8_7(),
// new siprp.update.updates.V8_7_To_V8_8(), new siprp.update.updates.V8_8_To_V8_9(),
// new siprp.update.updates.V8_9_To_V9_0(), new siprp.update.updates.V9_0_To_V9_1(),
new siprp.update.updates.V9_1_To_V9_2(), new siprp.update.updates.V9_2_To_V9_3(),
new siprp.update.updates.V9_3_To_V9_4(), new siprp.update.updates.V9_4_To_V9_5(),
new siprp.update.updates.V9_5_To_V9_6(), new siprp.update.updates.V9_6_To_V9_7(),
new siprp.update.updates.V9_7_To_V9_8(), new siprp.update.updates.V9_8_To_V9_9(),
new siprp.update.updates.V9_9_To_V10_0() };
// new V6_1_To_V7_0(), new V7_0_To_V7_2(),
// new V7_2_To_V7_4(), new V7_4_To_V7_5(),
// new V7_5_To_V7_6(), new V7_6_To_V7_7(),
// new V7_7_To_V7_8(), new V7_8_To_V7_9(),
// new V7_9_To_V8_0(), new V8_0_To_V8_1(),
// new V8_1_To_V8_2(), new V8_2_To_V8_3(),
// new V8_3_To_V8_4(), new V8_4_To_V8_5(),
// new V8_5_To_V8_6(), new V8_6_To_V8_7(),
// new V8_7_To_V8_8(), new V8_8_To_V8_9(),
// new V8_9_To_V9_0(), new V9_0_To_V9_1(),
new V9_1_To_V9_2(), new V9_2_To_V9_3(),
new V9_3_To_V9_4(), new V9_4_To_V9_5(),
new V9_5_To_V9_6(), new V9_6_To_V9_7(),
new V9_7_To_V9_8(), new V9_8_To_V9_9(),
new V9_9_To_V10_0(), new V10_0_To_V10_1() };
protected static Executer EXECUTER;
protected static double version = -1;

@ -0,0 +1,59 @@
package siprp.update.updates;
import com.evolute.utils.Singleton;
import com.evolute.utils.db.DBManager;
import com.evolute.utils.db.Executer;
public class V10_0_To_V10_1
implements siprp.update.Update
{
public V10_0_To_V10_1()
{
}
public String []listChanges()
{
return new String[]{
"adicionadas normalizacoes para estabelecimentos e empresas"
};
}
public double getStartVersion()
{
return 10.0;
}
public double getEndVersion()
{
return 10.1;
}
public void doUpdate()
throws Exception
{
DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER );
Executer executer = dbm.getSharedExecuter();
com.evolute.utils.sql.Update update =
new com.evolute.utils.sql.Update(
"CREATE TABLE hs_normalizacao_empresa " +
"( " +
" normalizacao_id int4 REFERENCES hs_normalizacao(id), " +
" empresa_id int4 REFERENCES empresas(id), " +
" CONSTRAINT hs_normalizacao_empresa_pkey PRIMARY KEY(normalizacao_id,empresa_id) " +
"); " +
"CREATE TABLE hs_normalizacao_estabelecimento " +
"( " +
" normalizacao_id int4 REFERENCES hs_normalizacao(id), " +
" estabelecimento_id int4 REFERENCES estabelecimentos(id), " +
" CONSTRAINT hs_normalizacao_estabelecimento_pkey PRIMARY KEY(normalizacao_id,estabelecimento_id) " +
");"
);
executer.executeQuery( update );
}
public String toString()
{
return "v" + getStartVersion() + " para v" + getEndVersion();
}
}

@ -269,6 +269,14 @@
<db-key-cache-size>1</db-key-cache-size>
</db-key-generator>
</db-entity>
<db-entity name="hs_normalizacao_empresa" schema="public">
<db-attribute name="empresa_id" type="INTEGER" isPrimaryKey="true" isMandatory="true" length="10"/>
<db-attribute name="normalizacao_id" type="INTEGER" isPrimaryKey="true" isMandatory="true" length="10"/>
</db-entity>
<db-entity name="hs_normalizacao_estabelecimento" schema="public">
<db-attribute name="estabelecimento_id" type="INTEGER" isPrimaryKey="true" isMandatory="true" length="10"/>
<db-attribute name="normalizacao_id" type="INTEGER" isPrimaryKey="true" isMandatory="true" length="10"/>
</db-entity>
<db-entity name="hs_posto" schema="public">
<db-attribute name="area_id" type="INTEGER" length="10"/>
<db-attribute name="deleted_date" type="TIMESTAMP"/>
@ -933,6 +941,10 @@
<obj-attribute name="descricao" type="java.lang.String" db-attribute-path="descricao"/>
<obj-attribute name="portuguesa" type="java.lang.Boolean" db-attribute-path="portuguesa"/>
</obj-entity>
<obj-entity name="HsNormalizacaoEmpresa" className="siprp.database.cayenne.objects.HsNormalizacaoEmpresa" dbEntityName="hs_normalizacao_empresa" superClassName="siprp.database.cayenne.objects.BaseObject">
</obj-entity>
<obj-entity name="HsNormalizacaoEstabelecimento" className="siprp.database.cayenne.objects.HsNormalizacaoEstabelecimento" dbEntityName="hs_normalizacao_estabelecimento" superClassName="siprp.database.cayenne.objects.BaseObject">
</obj-entity>
<obj-entity name="HsPosto" className="siprp.database.cayenne.objects.HsPosto" dbEntityName="hs_posto" superClassName="siprp.database.cayenne.objects.BaseObject">
<obj-attribute name="deletedDate" type="java.util.Date" db-attribute-path="deleted_date"/>
<obj-attribute name="description" type="java.lang.String" db-attribute-path="description"/>
@ -1235,6 +1247,9 @@
<db-relationship name="hsEmailEmpresa" source="empresas" target="hs_email_empresa" toDependentPK="true" toMany="true">
<db-attribute-pair source="id" target="empresa_id"/>
</db-relationship>
<db-relationship name="hsNormalizacaoEmpresaArray" source="empresas" target="hs_normalizacao_empresa" toDependentPK="true" toMany="true">
<db-attribute-pair source="id" target="empresa_id"/>
</db-relationship>
<db-relationship name="hsRiscoEmpresaArray" source="empresas" target="hs_risco_empresa" toDependentPK="true" toMany="true">
<db-attribute-pair source="id" target="empresa_id"/>
</db-relationship>
@ -1268,6 +1283,9 @@
<db-relationship name="hsEmailEstabelecimento" source="estabelecimentos" target="hs_email_estabelecimento" toDependentPK="true" toMany="true">
<db-attribute-pair source="id" target="estabelecimento_id"/>
</db-relationship>
<db-relationship name="hsNormalizacaoEstabelecimentoArray" source="estabelecimentos" target="hs_normalizacao_estabelecimento" toDependentPK="true" toMany="true">
<db-attribute-pair source="id" target="estabelecimento_id"/>
</db-relationship>
<db-relationship name="hsPostoEstabelecimentoArray" source="estabelecimentos" target="hs_posto_estabelecimento" toDependentPK="true" toMany="true">
<db-attribute-pair source="id" target="estabelecimento_id"/>
</db-relationship>
@ -1358,6 +1376,24 @@
<db-relationship name="hsRiscoMedidaArray" source="hs_medida" target="hs_risco_medida" toDependentPK="true" toMany="true">
<db-attribute-pair source="id" target="medida_id"/>
</db-relationship>
<db-relationship name="hsNormalizacaoEmpresaArray" source="hs_normalizacao" target="hs_normalizacao_empresa" toDependentPK="true" toMany="true">
<db-attribute-pair source="id" target="normalizacao_id"/>
</db-relationship>
<db-relationship name="hsNormalizacaoEstabelecimentoArray" source="hs_normalizacao" target="hs_normalizacao_estabelecimento" toDependentPK="true" toMany="true">
<db-attribute-pair source="id" target="normalizacao_id"/>
</db-relationship>
<db-relationship name="toEmpresa" source="hs_normalizacao_empresa" target="empresas" toMany="false">
<db-attribute-pair source="empresa_id" target="id"/>
</db-relationship>
<db-relationship name="toHsNormalizacao" source="hs_normalizacao_empresa" target="hs_normalizacao" toMany="false">
<db-attribute-pair source="normalizacao_id" target="id"/>
</db-relationship>
<db-relationship name="toEstabelecimento" source="hs_normalizacao_estabelecimento" target="estabelecimentos" toMany="false">
<db-attribute-pair source="estabelecimento_id" target="id"/>
</db-relationship>
<db-relationship name="toHsNormalizacao" source="hs_normalizacao_estabelecimento" target="hs_normalizacao" toMany="false">
<db-attribute-pair source="normalizacao_id" target="id"/>
</db-relationship>
<db-relationship name="hsPostoEstabelecimentoArray" source="hs_posto" target="hs_posto_estabelecimento" toDependentPK="true" toMany="true">
<db-attribute-pair source="id" target="posto_id"/>
</db-relationship>
@ -1825,6 +1861,10 @@
<obj-relationship name="toHsLegislacao" source="HsLegislacaoEstabelecimento" target="HsLegislacao" deleteRule="Nullify" db-relationship-path="toHsLegislacao"/>
<obj-relationship name="hsPostoMedidaArray" source="HsMedida" target="HsPostoMedida" deleteRule="Cascade" db-relationship-path="hsPostoMedidaArray"/>
<obj-relationship name="hsRiscoMedidaArray" source="HsMedida" target="HsRiscoMedida" deleteRule="Cascade" db-relationship-path="hsRiscoMedidaArray"/>
<obj-relationship name="toEmpresa" source="HsNormalizacaoEmpresa" target="Empresas" db-relationship-path="toEmpresa"/>
<obj-relationship name="toHsNormalizacao" source="HsNormalizacaoEmpresa" target="HsNormalizacao" db-relationship-path="toHsNormalizacao"/>
<obj-relationship name="toEstabelecimento" source="HsNormalizacaoEstabelecimento" target="Estabelecimentos" db-relationship-path="toEstabelecimento"/>
<obj-relationship name="toHsNormalizacao" source="HsNormalizacaoEstabelecimento" target="HsNormalizacao" db-relationship-path="toHsNormalizacao"/>
<obj-relationship name="hsPostoEstabelecimentoArray" source="HsPosto" target="HsPostoEstabelecimento" deleteRule="Cascade" db-relationship-path="hsPostoEstabelecimentoArray"/>
<obj-relationship name="hsPostoMedidaArray" source="HsPosto" target="HsPostoMedida" deleteRule="Cascade" db-relationship-path="hsPostoMedidaArray"/>
<obj-relationship name="hsPostoRiscoArray" source="HsPosto" target="HsPostoRisco" deleteRule="Cascade" db-relationship-path="hsPostoRiscoArray"/>

@ -13,6 +13,8 @@ import javax.swing.JTextArea;
import javax.swing.event.CaretEvent;
import javax.swing.event.CaretListener;
import com.evolute.utils.ui.text.CopyPasteHandler;
import leaf.data.Validator;
public class LeafTextAreaEditor extends JPanel
@ -61,6 +63,7 @@ public class LeafTextAreaEditor extends JPanel
{
fieldText.setWrapStyleWord( true );
fieldText.setLineWrap( true );
new CopyPasteHandler(fieldText);
scroll.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
scroll.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS );
buttonSave.setMargin( new Insets(0,0,0,0) );

@ -3,6 +3,7 @@ package leaf.ui;
import info.clearthought.layout.TableLayout;
import info.clearthought.layout.TableLayoutConstraints;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Insets;
import java.awt.event.ActionEvent;
@ -61,7 +62,7 @@ public class TreeInserterDialog extends JDialog
private final LeafButton buttonCancel = new LeafButton( "Cancelar" );
public TreeInserterDialog( String title, DefaultMutableTreeNode root )
public TreeInserterDialog( Component relativeTo, String title, DefaultMutableTreeNode root )
{
this.allRoot = root;
this.allModel = new DefaultTreeModel( allRoot );
@ -82,7 +83,7 @@ public class TreeInserterDialog extends JDialog
startupListeners();
TreeTools.refreshTree(allTree, allRoot);
setEnabled();
this.setLocationRelativeTo( null );
this.setLocationRelativeTo( relativeTo );
this.setSize( 680, 400 );
this.setModal( true );
this.setVisible( true );
@ -91,9 +92,9 @@ public class TreeInserterDialog extends JDialog
private void startupComponents()
{
newTree.setRootVisible( false );
newTree.getSelectionModel().setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION );
newTree.getSelectionModel().setSelectionMode( TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION );
allTree.setRootVisible( false );
allTree.getSelectionModel().setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION );
allTree.getSelectionModel().setSelectionMode( TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
allScroll.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS );
allScroll.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
newScroll.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS );
@ -181,32 +182,35 @@ public class TreeInserterDialog extends JDialog
private void move( JTree from, JTree to )
{
TreePath path = from.getSelectionPath();
DefaultMutableTreeNode fromRoot = (DefaultMutableTreeNode) from.getModel().getRoot();
DefaultMutableTreeNode toRoot = (DefaultMutableTreeNode) to.getModel().getRoot();
if( path != null )
TreePath [] paths = from.getSelectionPaths();
if( paths != null )
{
for( int i = 1; i < path.getPathCount(); ++i )
DefaultMutableTreeNode fromRoot = (DefaultMutableTreeNode) from.getModel().getRoot();
DefaultMutableTreeNode toRoot = (DefaultMutableTreeNode) to.getModel().getRoot();
for( TreePath path : paths )
{
DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getPathComponent( i );
DefaultMutableTreeNode parent = (DefaultMutableTreeNode) path.getPathComponent( i-1 );
if( node != null && parent != null )
for( int i = 1; i < path.getPathCount(); ++i )
{
DefaultMutableTreeNode exists = TreeTools.findNodeWithUserObject( node.getUserObject(), toRoot );
if( exists == null )
DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getPathComponent( i );
DefaultMutableTreeNode parent = (DefaultMutableTreeNode) path.getPathComponent( i-1 );
if( node != null && parent != null )
{
add(node, parent.getUserObject(), toRoot, path.getPathCount() == i + 1 );
}
else
{
TreeTools.merge( exists, node );
DefaultMutableTreeNode exists = TreeTools.findNodeWithUserObject( node.getUserObject(), toRoot );
if( exists == null )
{
add(node, parent.getUserObject(), toRoot, path.getPathCount() == i + 1 );
}
else if( i + 1 == path.getPathCount() )
{
TreeTools.merge( exists, node );
}
}
}
removeNode( (DefaultMutableTreeNode) path.getLastPathComponent(), fromRoot );
}
removeNode( (DefaultMutableTreeNode) path.getLastPathComponent(), fromRoot );
TreeTools.refreshTree( from, fromRoot );
TreeTools.refreshTree( to, toRoot );
}
TreeTools.refreshTree( from, fromRoot );
TreeTools.refreshTree( to, toRoot );
}
private void removeNode( DefaultMutableTreeNode node, DefaultMutableTreeNode root )

@ -3,5 +3,29 @@ package siprp.database.cayenne.objects;
import siprp.database.cayenne.objects.auto._HsNormalizacao;
public class HsNormalizacao extends _HsNormalizacao {
private static final long serialVersionUID = 1L;
private static final int TO_STRING_LENGTH = 58;
@Override
public String getDescricao()
{
return parseFromUnicode( super.getDescricao() );
}
@Override
public void setDescricao( String nome )
{
super.setDescricao( parseToUnicode( nome ) );
}
@Override
public String toString()
{
String codigo = getCodigo();
String descricao = getDescricao() == null ? "" : getDescricao().replaceAll( "\n", " " );
return (codigo == null ? "" : codigo ) + ": " + ( descricao.substring( 0, Math.min( TO_STRING_LENGTH, descricao.length() ) ) + ( TO_STRING_LENGTH < descricao.length() ? "..." : "" ) );
}
}

@ -0,0 +1,7 @@
package siprp.database.cayenne.objects;
import siprp.database.cayenne.objects.auto._HsNormalizacaoEmpresa;
public class HsNormalizacaoEmpresa extends _HsNormalizacaoEmpresa {
}

@ -0,0 +1,7 @@
package siprp.database.cayenne.objects;
import siprp.database.cayenne.objects.auto._HsNormalizacaoEstabelecimento;
public class HsNormalizacaoEstabelecimento extends _HsNormalizacaoEstabelecimento {
}

@ -9,6 +9,6 @@ public class HsRiscoMedida extends _HsRiscoMedida {
public String toString()
{
String d = getToHsMedida() == null ? null : getToHsMedida().getRequesitosLegais();
return d == null ? " " : d.substring( 0, Math.min( 20, d.length() ) ) + "...";
return d == null ? " " : d.substring( 0, Math.min( 40, d.length() ) ) + "...";
}
}

@ -0,0 +1,39 @@
package siprp.database.cayenne.objects.auto;
import siprp.database.cayenne.objects.BaseObject;
import siprp.database.cayenne.objects.Empresas;
import siprp.database.cayenne.objects.HsNormalizacao;
/**
* Class _HsNormalizacaoEmpresa was generated by Cayenne.
* It is probably a good idea to avoid changing this class manually,
* since it may be overwritten next time code is regenerated.
* If you need to make any customizations, please use subclass.
*/
public abstract class _HsNormalizacaoEmpresa extends BaseObject {
public static final String TO_EMPRESA_PROPERTY = "toEmpresa";
public static final String TO_HS_NORMALIZACAO_PROPERTY = "toHsNormalizacao";
public static final String EMPRESA_ID_PK_COLUMN = "empresa_id";
public static final String NORMALIZACAO_ID_PK_COLUMN = "normalizacao_id";
public void setToEmpresa(Empresas toEmpresa) {
setToOneTarget("toEmpresa", toEmpresa, true);
}
public Empresas getToEmpresa() {
return (Empresas)readProperty("toEmpresa");
}
public void setToHsNormalizacao(HsNormalizacao toHsNormalizacao) {
setToOneTarget("toHsNormalizacao", toHsNormalizacao, true);
}
public HsNormalizacao getToHsNormalizacao() {
return (HsNormalizacao)readProperty("toHsNormalizacao");
}
}

@ -0,0 +1,39 @@
package siprp.database.cayenne.objects.auto;
import siprp.database.cayenne.objects.BaseObject;
import siprp.database.cayenne.objects.Estabelecimentos;
import siprp.database.cayenne.objects.HsNormalizacao;
/**
* Class _HsNormalizacaoEstabelecimento was generated by Cayenne.
* It is probably a good idea to avoid changing this class manually,
* since it may be overwritten next time code is regenerated.
* If you need to make any customizations, please use subclass.
*/
public abstract class _HsNormalizacaoEstabelecimento extends BaseObject {
public static final String TO_ESTABELECIMENTO_PROPERTY = "toEstabelecimento";
public static final String TO_HS_NORMALIZACAO_PROPERTY = "toHsNormalizacao";
public static final String ESTABELECIMENTO_ID_PK_COLUMN = "estabelecimento_id";
public static final String NORMALIZACAO_ID_PK_COLUMN = "normalizacao_id";
public void setToEstabelecimento(Estabelecimentos toEstabelecimento) {
setToOneTarget("toEstabelecimento", toEstabelecimento, true);
}
public Estabelecimentos getToEstabelecimento() {
return (Estabelecimentos)readProperty("toEstabelecimento");
}
public void setToHsNormalizacao(HsNormalizacao toHsNormalizacao) {
setToOneTarget("toHsNormalizacao", toHsNormalizacao, true);
}
public HsNormalizacao getToHsNormalizacao() {
return (HsNormalizacao)readProperty("toHsNormalizacao");
}
}

@ -12,6 +12,7 @@ import siprp.database.cayenne.objects.EmailPlanoDeActuacao;
import siprp.database.cayenne.objects.Estabelecimentos;
import siprp.database.cayenne.objects.HsLegislacao;
import siprp.database.cayenne.objects.HsLegislacaoCategoria;
import siprp.database.cayenne.objects.HsNormalizacao;
import siprp.database.cayenne.objects.HsPosto;
import siprp.database.cayenne.objects.HsPostoRisco;
import siprp.database.cayenne.objects.HsRelatorio;
@ -324,4 +325,13 @@ public class PlanoActuacaoDAO extends MainDAO
return context.performQuery( query );
}
public List<HsNormalizacao> getNormalizacao( boolean portuguesa )
{
SelectQuery query = new SelectQuery( HsNormalizacao.class );
query.andQualifier( ExpressionFactory.matchExp( HsNormalizacao.DELETED_DATE_PROPERTY, null ) );
query.andQualifier( ExpressionFactory.matchExp( HsNormalizacao.PORTUGUESA_PROPERTY, portuguesa ) );
query.addOrdering( HsNormalizacao.CODIGO_PROPERTY, true );
return context.performQuery( query );
}
}

@ -12,6 +12,7 @@ import siprp.database.cayenne.objects.Estabelecimentos;
import siprp.database.cayenne.objects.HsArea;
import siprp.database.cayenne.objects.HsLegislacao;
import siprp.database.cayenne.objects.HsLegislacaoCategoria;
import siprp.database.cayenne.objects.HsNormalizacao;
import siprp.database.cayenne.objects.HsPosto;
import siprp.database.cayenne.objects.HsPostoEstabelecimento;
import siprp.database.cayenne.objects.HsPostoRisco;
@ -289,5 +290,16 @@ public class HigieneSegurancaLogic
}
return result;
}
public static DefaultMutableTreeNode getNormalizacao( boolean portuguesa )
{
DefaultMutableTreeNode result = new DefaultMutableTreeNode();
for( HsNormalizacao normalizacao : planoProvider.getNormalizacao( portuguesa ) )
{
DefaultMutableTreeNode normalizacaoNode = new DefaultMutableTreeNode( normalizacao );
result.add( normalizacaoNode );
}
return result;
}
}

Loading…
Cancel
Save