forked from Coded/SIPRP
				
			git-svn-id: https://svn.coded.pt/svn/SIPRP@801 bb69d46d-e84e-40c8-a05a-06db0d633741
	
		
	
				
					
				
			
							parent
							
								
									b978a47680
								
							
						
					
					
						commit
						7a985cc91a
					
				| @ -0,0 +1,91 @@ | |||||||
|  | package siprp.higiene.gestao; | ||||||
|  | 
 | ||||||
|  | import info.clearthought.layout.TableLayout; | ||||||
|  | import info.clearthought.layout.TableLayoutConstraints; | ||||||
|  | 
 | ||||||
|  | import javax.swing.JPanel; | ||||||
|  | import javax.swing.JScrollPane; | ||||||
|  | import javax.swing.JTable; | ||||||
|  | import javax.swing.JTree; | ||||||
|  | import javax.swing.ListSelectionModel; | ||||||
|  | import javax.swing.event.ListSelectionListener; | ||||||
|  | import javax.swing.tree.DefaultMutableTreeNode; | ||||||
|  | import javax.swing.tree.DefaultTreeModel; | ||||||
|  | import javax.swing.tree.TreeSelectionModel; | ||||||
|  | 
 | ||||||
|  | import siprp.database.cayenne.objects.Empresas; | ||||||
|  | 
 | ||||||
|  | import com.evolute.utils.tables.VectorTableModel; | ||||||
|  | 
 | ||||||
|  | import leaf.ui.LeafButton; | ||||||
|  | 
 | ||||||
|  | public class AdicionarEmailsPanel extends JPanel | ||||||
|  | { | ||||||
|  | 
 | ||||||
|  | 	private static final long serialVersionUID = 1L; | ||||||
|  | 	 | ||||||
|  | 	private final LeafButton buttonAdicionar = new LeafButton("Adicionar"); | ||||||
|  | 	 | ||||||
|  | 	private final LeafButton buttonRemover = new LeafButton("Remover"); | ||||||
|  | 	 | ||||||
|  | 	private final VectorTableModel<String> model = new VectorTableModel<String>( new String[]{ "" } ); | ||||||
|  | 	 | ||||||
|  | 	private final JTable table = new JTable( model ); | ||||||
|  | 	 | ||||||
|  | 	private final JScrollPane scroll = new JScrollPane( table ); | ||||||
|  | 
 | ||||||
|  | 	public AdicionarEmailsPanel() | ||||||
|  | 	{ | ||||||
|  | 		startupComponents(); | ||||||
|  | 		setupLayout(); | ||||||
|  | 		placeComponents(); | ||||||
|  | 		startupListeners(); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private void startupComponents() | ||||||
|  | 	{ | ||||||
|  | 		buttonAdicionar.setEnabled( false ); | ||||||
|  | 		buttonRemover.setEnabled( false ); | ||||||
|  | 		table.getSelectionModel().setSelectionMode( ListSelectionModel.SINGLE_SELECTION ); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private void setupLayout() | ||||||
|  | 	{ | ||||||
|  | 		TableLayout layout = new TableLayout( | ||||||
|  | 				new double[]{ TableLayout.FILL }, | ||||||
|  | 				new double[]{ TableLayout.MINIMUM, TableLayout.FILL } | ||||||
|  | 				); | ||||||
|  | 		layout.setHGap( 5 ); | ||||||
|  | 		layout.setVGap( 5 ); | ||||||
|  | 		setLayout( layout ); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private void placeComponents() | ||||||
|  | 	{ | ||||||
|  | 		JPanel panel = new JPanel(); | ||||||
|  | 		TableLayout layout = new TableLayout( | ||||||
|  | 				new double[]{ TableLayout.MINIMUM, TableLayout.FILL, TableLayout.MINIMUM }, | ||||||
|  | 				new double[]{ TableLayout.MINIMUM } | ||||||
|  | 				); | ||||||
|  | 		layout.setHGap( 5 ); | ||||||
|  | 		layout.setVGap( 5 ); | ||||||
|  | 		panel.setLayout( layout ); | ||||||
|  | 		panel.add( buttonAdicionar, new TableLayoutConstraints( 0, 0 ) ); | ||||||
|  | 		panel.add( buttonRemover, new TableLayoutConstraints( 2, 0 ) ); | ||||||
|  | 			 | ||||||
|  | 		add( panel, new TableLayoutConstraints( 0, 0 ) ); | ||||||
|  | 		add( scroll, new TableLayoutConstraints( 0, 1 ) ); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private void startupListeners() | ||||||
|  | 	{ | ||||||
|  | 		 | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	public void setEmpresa( Empresas empresa ) | ||||||
|  | 	{ | ||||||
|  | 		// TODO Auto-generated method stub
 | ||||||
|  | 		 | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | } | ||||||
| @ -0,0 +1,89 @@ | |||||||
|  | package siprp.higiene.gestao; | ||||||
|  | 
 | ||||||
|  | import info.clearthought.layout.TableLayout; | ||||||
|  | import info.clearthought.layout.TableLayoutConstraints; | ||||||
|  | 
 | ||||||
|  | import javax.swing.JPanel; | ||||||
|  | import javax.swing.JScrollPane; | ||||||
|  | import javax.swing.JTree; | ||||||
|  | import javax.swing.tree.DefaultMutableTreeNode; | ||||||
|  | import javax.swing.tree.DefaultTreeModel; | ||||||
|  | import javax.swing.tree.TreeSelectionModel; | ||||||
|  | 
 | ||||||
|  | import siprp.database.cayenne.objects.Empresas; | ||||||
|  | 
 | ||||||
|  | import leaf.ui.LeafButton; | ||||||
|  | 
 | ||||||
|  | public class AdicionarLegislacaoPanel extends JPanel | ||||||
|  | { | ||||||
|  | 
 | ||||||
|  | 	private static final long serialVersionUID = 1L; | ||||||
|  | 	 | ||||||
|  | 	private final LeafButton buttonAdicionar = new LeafButton("Adicionar"); | ||||||
|  | 	 | ||||||
|  | 	private final LeafButton buttonRemover = 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 ); | ||||||
|  | 
 | ||||||
|  | 	public AdicionarLegislacaoPanel() | ||||||
|  | 	{ | ||||||
|  | 		startupComponents(); | ||||||
|  | 		setupLayout(); | ||||||
|  | 		placeComponents(); | ||||||
|  | 		startupListeners(); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private void startupComponents() | ||||||
|  | 	{ | ||||||
|  | 		buttonAdicionar.setEnabled( false ); | ||||||
|  | 		buttonRemover.setEnabled( false ); | ||||||
|  | 		tree.setRootVisible( false ); | ||||||
|  | 		tree.getSelectionModel().setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION ); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private void setupLayout() | ||||||
|  | 	{ | ||||||
|  | 		TableLayout layout = new TableLayout( | ||||||
|  | 				new double[]{ TableLayout.FILL }, | ||||||
|  | 				new double[]{ TableLayout.MINIMUM, TableLayout.FILL } | ||||||
|  | 				); | ||||||
|  | 		layout.setHGap( 5 ); | ||||||
|  | 		layout.setVGap( 5 ); | ||||||
|  | 		setLayout( layout ); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private void placeComponents() | ||||||
|  | 	{ | ||||||
|  | 		JPanel panel = new JPanel(); | ||||||
|  | 		TableLayout layout = new TableLayout( | ||||||
|  | 				new double[]{ TableLayout.MINIMUM, TableLayout.FILL, TableLayout.MINIMUM }, | ||||||
|  | 				new double[]{ TableLayout.MINIMUM } | ||||||
|  | 				); | ||||||
|  | 		layout.setHGap( 5 ); | ||||||
|  | 		layout.setVGap( 5 ); | ||||||
|  | 		panel.setLayout( layout ); | ||||||
|  | 		panel.add( buttonAdicionar, new TableLayoutConstraints( 0, 0 ) ); | ||||||
|  | 		panel.add( buttonRemover, new TableLayoutConstraints( 2, 0 ) ); | ||||||
|  | 			 | ||||||
|  | 		add( panel, new TableLayoutConstraints( 0, 0 ) ); | ||||||
|  | 		add( scroll, new TableLayoutConstraints( 0, 1 ) ); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private void startupListeners() | ||||||
|  | 	{ | ||||||
|  | 		 | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	public void setEmpresa( Empresas empresa ) | ||||||
|  | 	{ | ||||||
|  | 		// TODO Auto-generated method stub
 | ||||||
|  | 		 | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | } | ||||||
| @ -0,0 +1,102 @@ | |||||||
|  | package siprp.higiene.gestao; | ||||||
|  | 
 | ||||||
|  | import info.clearthought.layout.TableLayout; | ||||||
|  | import info.clearthought.layout.TableLayoutConstraints; | ||||||
|  | 
 | ||||||
|  | import java.awt.event.ItemEvent; | ||||||
|  | import java.awt.event.ItemListener; | ||||||
|  | import java.util.List; | ||||||
|  | 
 | ||||||
|  | import javax.swing.JComboBox; | ||||||
|  | import javax.swing.JLabel; | ||||||
|  | import javax.swing.JPanel; | ||||||
|  | import javax.swing.JTabbedPane; | ||||||
|  | 
 | ||||||
|  | import siprp.database.cayenne.objects.Empresas; | ||||||
|  | import siprp.database.cayenne.providers.MedicinaDAO; | ||||||
|  | 
 | ||||||
|  | public class EmpresaPanel extends JPanel | ||||||
|  | { | ||||||
|  | 
 | ||||||
|  | 	private static final long serialVersionUID = 1L; | ||||||
|  | 	 | ||||||
|  | 	private final JComboBox comboEmpresa = new JComboBox(); | ||||||
|  | 	 | ||||||
|  | 	private final GerirEmpresaPanel panelEmpresa = new GerirEmpresaPanel(); | ||||||
|  | 	 | ||||||
|  | 	private final GerirEstabelecimentosPanel panelEstabelecimentos = new GerirEstabelecimentosPanel(); | ||||||
|  | 	 | ||||||
|  | 	private final JTabbedPane tabs = new JTabbedPane(); | ||||||
|  | 
 | ||||||
|  | 	public EmpresaPanel() | ||||||
|  | 	{ | ||||||
|  | 		startupComponents(); | ||||||
|  | 		setupLayout(); | ||||||
|  | 		placeComponents(); | ||||||
|  | 		startupListeners(); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private void startupComponents() | ||||||
|  | 	{ | ||||||
|  | 		List<Empresas> empresas = new MedicinaDAO().getAllEmpresas(); | ||||||
|  | 		if( empresas != null ) | ||||||
|  | 		{ | ||||||
|  | 			for( Empresas empresa : empresas ) | ||||||
|  | 			{ | ||||||
|  | 				comboEmpresa.addItem( empresa ); | ||||||
|  | 			} | ||||||
|  | 			if( comboEmpresa.getItemCount() > 0 ) | ||||||
|  | 			{ | ||||||
|  | 				comboEmpresa.setSelectedIndex( 0 ); | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 		tabs.addTab( "Empresa", panelEmpresa ); | ||||||
|  | 		tabs.addTab( "Estabelecimentos", panelEstabelecimentos ); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private void setupLayout() | ||||||
|  | 	{ | ||||||
|  | 		double[] cols = new double[]{ | ||||||
|  | 		                             TableLayout.MINIMUM, TableLayout.FILL, | ||||||
|  | 		}; | ||||||
|  | 		double[] rows = new double[]{ | ||||||
|  | 		                             TableLayout.MINIMUM, TableLayout.FILL, | ||||||
|  | 		}; | ||||||
|  | 		TableLayout layout = new TableLayout(cols,rows); | ||||||
|  | 		layout.setHGap( 10 ); | ||||||
|  | 		layout.setVGap( 10 ); | ||||||
|  | 		this.setLayout( layout ); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private void placeComponents() | ||||||
|  | 	{ | ||||||
|  | 		this.add( new JLabel( "Empresa" ), new TableLayoutConstraints(0,0) ); | ||||||
|  | 		this.add( comboEmpresa, new TableLayoutConstraints(1,0) ); | ||||||
|  | 		this.add( tabs, new TableLayoutConstraints(0,1,1,1) ); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private void startupListeners() | ||||||
|  | 	{ | ||||||
|  | 		comboEmpresa.addItemListener( new ItemListener(){ | ||||||
|  | 			@Override | ||||||
|  | 			public void itemStateChanged( ItemEvent e ) | ||||||
|  | 			{ | ||||||
|  | 				Object item = e.getItem(); | ||||||
|  | 				if( item != null && ItemEvent.SELECTED == e.getStateChange() ) | ||||||
|  | 				{ | ||||||
|  | 					if( item instanceof Empresas ) | ||||||
|  | 					{ | ||||||
|  | 						panelEmpresa.setEmpresa( (Empresas) item ); | ||||||
|  | 						panelEstabelecimentos.setEmpresa( (Empresas) item ); | ||||||
|  | 					} | ||||||
|  | 				} | ||||||
|  | 				else if( ItemEvent.DESELECTED == e.getStateChange() ) | ||||||
|  | 				{ | ||||||
|  | 					panelEmpresa.setEmpresa( null ); | ||||||
|  | 					panelEstabelecimentos.setEmpresa( null ); | ||||||
|  | 				} | ||||||
|  | 			}		 | ||||||
|  | 		}); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | } | ||||||
| @ -0,0 +1,75 @@ | |||||||
|  | package siprp.higiene.gestao; | ||||||
|  | 
 | ||||||
|  | import java.awt.Dimension; | ||||||
|  | 
 | ||||||
|  | import info.clearthought.layout.TableLayout; | ||||||
|  | import info.clearthought.layout.TableLayoutConstraints; | ||||||
|  | 
 | ||||||
|  | import javax.swing.BorderFactory; | ||||||
|  | import javax.swing.JPanel; | ||||||
|  | 
 | ||||||
|  | import siprp.database.cayenne.objects.Empresas; | ||||||
|  | import siprp.higiene.gestao.postos.GerirAreasPanel; | ||||||
|  | import siprp.higiene.gestao.riscos.AdicionarRiscosPanel; | ||||||
|  | 
 | ||||||
|  | import static com.evolute.utils.strings.UnicodeLatin1Map.*; | ||||||
|  | 
 | ||||||
|  | public class GerirEmpresaPanel extends JPanel | ||||||
|  | { | ||||||
|  | 
 | ||||||
|  | 	private static final long serialVersionUID = 1L; | ||||||
|  | 	 | ||||||
|  | 	private final GerirAreasPanel panelAreas = new GerirAreasPanel(); | ||||||
|  | 	private final AdicionarRiscosPanel panelRiscos = new AdicionarRiscosPanel(); | ||||||
|  | 	private final AdicionarEmailsPanel panelEmails = new AdicionarEmailsPanel(); | ||||||
|  | 	private final AdicionarLegislacaoPanel panelLegislacao = new AdicionarLegislacaoPanel(); | ||||||
|  | 
 | ||||||
|  | 	public GerirEmpresaPanel() | ||||||
|  | 	{ | ||||||
|  | 		startupComponents(); | ||||||
|  | 		setupLayout(); | ||||||
|  | 		placeComponents(); | ||||||
|  | 		startupListeners(); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private void startupComponents() | ||||||
|  | 	{ | ||||||
|  | 		panelAreas.setBorder( BorderFactory.createTitledBorder( "Postos de trabalho" ) ); | ||||||
|  | 		panelRiscos.setBorder( BorderFactory.createTitledBorder( "Riscos" ) ); | ||||||
|  | 		panelEmails.setBorder( BorderFactory.createTitledBorder( "Emails" ) ); | ||||||
|  | 		panelLegislacao.setBorder( BorderFactory.createTitledBorder( "Legisla" + ccedil + atilde + "o" ) ); | ||||||
|  | 		panelEmails.setPreferredSize( new Dimension(0,150) ); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private void setupLayout() | ||||||
|  | 	{ | ||||||
|  | 		double [] cols = new double[]{ TableLayout.FILL, TableLayout.FILL, TableLayout.FILL, }; | ||||||
|  | 		double [] rows = new double[]{ TableLayout.FILL, TableLayout.PREFERRED }; | ||||||
|  | 		TableLayout layout = new TableLayout( cols, rows ); | ||||||
|  | 		layout.setHGap( 5 ); | ||||||
|  | 		layout.setVGap( 5 ); | ||||||
|  | 		this.setLayout( layout ); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private void placeComponents() | ||||||
|  | 	{ | ||||||
|  | 		this.add( panelAreas, new TableLayoutConstraints( 0, 0, 0, 1 ) ); | ||||||
|  | 		this.add( panelRiscos, new TableLayoutConstraints( 1, 0, 1, 1 ) ); | ||||||
|  | 		this.add( panelLegislacao, new TableLayoutConstraints( 2, 0  ) ); | ||||||
|  | 		this.add( panelEmails, new TableLayoutConstraints( 2, 1 ) ); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private void startupListeners() | ||||||
|  | 	{ | ||||||
|  | 		 | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	public void setEmpresa( Empresas empresa ) | ||||||
|  | 	{ | ||||||
|  | 		panelAreas.setEmpresa( empresa ); | ||||||
|  | 		panelEmails.setEmpresa( empresa ); | ||||||
|  | 		panelLegislacao.setEmpresa( empresa ); | ||||||
|  | 		panelRiscos.setEmpresa( empresa ); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | } | ||||||
| @ -0,0 +1,105 @@ | |||||||
|  | package siprp.higiene.gestao; | ||||||
|  | 
 | ||||||
|  | import static com.evolute.utils.strings.UnicodeLatin1Map.atilde; | ||||||
|  | import static com.evolute.utils.strings.UnicodeLatin1Map.ccedil; | ||||||
|  | import info.clearthought.layout.TableLayout; | ||||||
|  | import info.clearthought.layout.TableLayoutConstraints; | ||||||
|  | 
 | ||||||
|  | import java.awt.Dimension; | ||||||
|  | import java.awt.event.ItemEvent; | ||||||
|  | import java.awt.event.ItemListener; | ||||||
|  | 
 | ||||||
|  | import javax.swing.BorderFactory; | ||||||
|  | import javax.swing.JComboBox; | ||||||
|  | import javax.swing.JPanel; | ||||||
|  | 
 | ||||||
|  | import siprp.database.cayenne.objects.Empresas; | ||||||
|  | import siprp.database.cayenne.objects.Estabelecimentos; | ||||||
|  | import siprp.higiene.gestao.postos.AdicionarAreasPanel; | ||||||
|  | import siprp.higiene.gestao.riscos.AdicionarRiscosPanel; | ||||||
|  | 
 | ||||||
|  | public class GerirEstabelecimentosPanel extends JPanel | ||||||
|  | { | ||||||
|  | 
 | ||||||
|  | 	private static final long serialVersionUID = 1L; | ||||||
|  | 	 | ||||||
|  | 	private final JComboBox comboEstabelecimentos = new JComboBox(); | ||||||
|  | 	private final AdicionarAreasPanel panelAreas = new AdicionarAreasPanel(); | ||||||
|  | 	private final AdicionarRiscosPanel panelRiscos = new AdicionarRiscosPanel(); | ||||||
|  | 	private final AdicionarEmailsPanel panelEmails = new AdicionarEmailsPanel(); | ||||||
|  | 	private final AdicionarLegislacaoPanel panelLegislacao = new AdicionarLegislacaoPanel(); | ||||||
|  | 
 | ||||||
|  | 	public GerirEstabelecimentosPanel() | ||||||
|  | 	{ | ||||||
|  | 		startupComponents(); | ||||||
|  | 		setupLayout(); | ||||||
|  | 		placeComponents(); | ||||||
|  | 		startupListeners(); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private void startupComponents() | ||||||
|  | 	{ | ||||||
|  | 		panelAreas.setBorder( BorderFactory.createTitledBorder( "Postos de trabalho" ) ); | ||||||
|  | 		panelRiscos.setBorder( BorderFactory.createTitledBorder( "Riscos" ) ); | ||||||
|  | 		panelEmails.setBorder( BorderFactory.createTitledBorder( "Emails" ) ); | ||||||
|  | 		panelLegislacao.setBorder( BorderFactory.createTitledBorder( "Legisla" + ccedil + atilde + "o" ) ); | ||||||
|  | 		 | ||||||
|  | 		panelEmails.setPreferredSize( new Dimension(0,150) ); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private void setupLayout() | ||||||
|  | 	{ | ||||||
|  | 		double [] cols = new double[]{ TableLayout.FILL, TableLayout.FILL, TableLayout.FILL, }; | ||||||
|  | 		double [] rows = new double[]{ TableLayout.MINIMUM, TableLayout.FILL, TableLayout.PREFERRED }; | ||||||
|  | 		TableLayout layout = new TableLayout( cols, rows ); | ||||||
|  | 		layout.setHGap( 5 ); | ||||||
|  | 		layout.setVGap( 5 ); | ||||||
|  | 		this.setLayout( layout ); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private void placeComponents() | ||||||
|  | 	{ | ||||||
|  | 		this.add( comboEstabelecimentos, new TableLayoutConstraints( 0, 0, 2, 0 ) ); | ||||||
|  | 		this.add( panelAreas, new TableLayoutConstraints( 0, 1, 0, 2 ) ); | ||||||
|  | 		this.add( panelRiscos, new TableLayoutConstraints( 1, 1, 1, 2 ) ); | ||||||
|  | 		this.add( panelLegislacao, new TableLayoutConstraints( 2, 1 ) ); | ||||||
|  | 		this.add( panelEmails, new TableLayoutConstraints( 2, 2 ) ); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private void startupListeners() | ||||||
|  | 	{ | ||||||
|  | 		comboEstabelecimentos.addItemListener( new ItemListener() | ||||||
|  | 		{ | ||||||
|  | 			@Override | ||||||
|  | 			public void itemStateChanged( ItemEvent e ) | ||||||
|  | 			{ | ||||||
|  | 				if( e.getItem() != null && ItemEvent.SELECTED == e.getStateChange() ) | ||||||
|  | 				{ | ||||||
|  | 					if( e.getItem() instanceof Estabelecimentos ) | ||||||
|  | 					{ | ||||||
|  | 						panelAreas.setEstabelecimento( (Estabelecimentos) e.getItem() ); | ||||||
|  | 					} | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
|  | 		} ); | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	public void setEmpresa( Empresas empresa ) | ||||||
|  | 	{ | ||||||
|  | 		comboEstabelecimentos.removeAllItems(); | ||||||
|  | 		if( empresa != null ) | ||||||
|  | 		{ | ||||||
|  | 			for( Estabelecimentos estabelecimento : empresa.getEstabelecimentosArray() ) | ||||||
|  | 			{ | ||||||
|  | 				comboEstabelecimentos.addItem( estabelecimento ); | ||||||
|  | 			} | ||||||
|  | 			if( comboEstabelecimentos.getItemCount() > 0 ) | ||||||
|  | 			{ | ||||||
|  | 				comboEstabelecimentos.setSelectedIndex( 0 ); | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 		panelEmails.setEmpresa( empresa ); | ||||||
|  | 		panelLegislacao.setEmpresa( empresa ); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | } | ||||||
| @ -0,0 +1,80 @@ | |||||||
|  | package siprp.higiene.gestao; | ||||||
|  | 
 | ||||||
|  | import java.awt.Dimension; | ||||||
|  | 
 | ||||||
|  | import javax.swing.JFrame; | ||||||
|  | import javax.swing.JTabbedPane; | ||||||
|  | import javax.swing.SwingUtilities; | ||||||
|  | 
 | ||||||
|  | import com.evolute.utils.tracker.TrackableWindow; | ||||||
|  | 
 | ||||||
|  | import static com.evolute.utils.strings.UnicodeLatin1Map.*; | ||||||
|  | 
 | ||||||
|  | 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 long serialVersionUID = 1L; | ||||||
|  | 	 | ||||||
|  | 	private final JTabbedPane tabs = new JTabbedPane(); | ||||||
|  | 	 | ||||||
|  | 	private final GlobalPanel panelGlobal = new GlobalPanel(); | ||||||
|  | 	 | ||||||
|  | 	private final EmpresaPanel panelEmpresa = new EmpresaPanel(); | ||||||
|  | 
 | ||||||
|  | 	public static void main( String[] args ) | ||||||
|  | 	{ | ||||||
|  | 		GestaoRelatorioWindow window = new GestaoRelatorioWindow(); | ||||||
|  | 		window.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); | ||||||
|  | 		window.open(); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	public GestaoRelatorioWindow() | ||||||
|  | 	{ | ||||||
|  | 		this.setTitle( TITLE ); | ||||||
|  | 		this.setSize( SIZE ); | ||||||
|  | 		placeComponents(); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private void placeComponents() | ||||||
|  | 	{ | ||||||
|  | 		tabs.addTab( "Global", panelGlobal ); | ||||||
|  | 		tabs.addTab( "Por Empresa", panelEmpresa ); | ||||||
|  | 		this.setContentPane( tabs ); | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	@Override | ||||||
|  | 	public void open() | ||||||
|  | 	{ | ||||||
|  | 		setVisible( true ); | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	public void close() | ||||||
|  | 	{ | ||||||
|  | 		SwingUtilities.invokeLater( new Runnable() | ||||||
|  | 		{ | ||||||
|  | 			public void run() | ||||||
|  | 			{ | ||||||
|  | 				setVisible( false ); | ||||||
|  | 				dispose(); | ||||||
|  | 			} | ||||||
|  | 		} ); | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	@Override | ||||||
|  | 	public boolean closeIfPossible() | ||||||
|  | 	{ | ||||||
|  | 		close(); | ||||||
|  | 		return true; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	@Override | ||||||
|  | 	public void refresh() | ||||||
|  | 	{ | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -0,0 +1,38 @@ | |||||||
|  | package siprp.higiene.gestao; | ||||||
|  | 
 | ||||||
|  | import javax.swing.JPanel; | ||||||
|  | 
 | ||||||
|  | public class GlobalPanel extends JPanel | ||||||
|  | { | ||||||
|  | 
 | ||||||
|  | 	private static final long serialVersionUID = 1L; | ||||||
|  | 
 | ||||||
|  | 	public GlobalPanel() | ||||||
|  | 	{ | ||||||
|  | 		startupComponents(); | ||||||
|  | 		setupLayout(); | ||||||
|  | 		placeComponents(); | ||||||
|  | 		startupListeners(); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private void startupComponents() | ||||||
|  | 	{ | ||||||
|  | 		 | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private void setupLayout() | ||||||
|  | 	{ | ||||||
|  | 		 | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private void placeComponents() | ||||||
|  | 	{ | ||||||
|  | 		 | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private void startupListeners() | ||||||
|  | 	{ | ||||||
|  | 		 | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | } | ||||||
| @ -0,0 +1,262 @@ | |||||||
|  | package siprp.higiene.gestao; | ||||||
|  | 
 | ||||||
|  | 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 javax.swing.JDialog; | ||||||
|  | import javax.swing.JLabel; | ||||||
|  | import javax.swing.JScrollPane; | ||||||
|  | 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.ui.LeafButton; | ||||||
|  | import leaf.ui.TreeTools; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | public class TreeInserterDialog extends JDialog | ||||||
|  | { | ||||||
|  | 
 | ||||||
|  | 	private static final long serialVersionUID = 1L; | ||||||
|  | 	 | ||||||
|  | 	private static final Dimension allDimension = new Dimension(300,500); | ||||||
|  | 	 | ||||||
|  | 	private static final Dimension newDimension = new Dimension(300,400); | ||||||
|  | 	 | ||||||
|  | 	private final DefaultMutableTreeNode newRoot = new DefaultMutableTreeNode(); | ||||||
|  | 	 | ||||||
|  | 	private final DefaultTreeModel newModel = new DefaultTreeModel( newRoot ); | ||||||
|  | 	 | ||||||
|  | 	private final JTree newTree = new JTree(newModel); | ||||||
|  | 	 | ||||||
|  | 	private final JScrollPane newScroll = new JScrollPane( newTree ); | ||||||
|  | 	 | ||||||
|  | 	private final DefaultMutableTreeNode allRoot; | ||||||
|  | 	 | ||||||
|  | 	private final DefaultTreeModel allModel; | ||||||
|  | 	 | ||||||
|  | 	private final JTree allTree; | ||||||
|  | 	 | ||||||
|  | 	private final JScrollPane allScroll; | ||||||
|  | 	 | ||||||
|  | 	private final LeafButton buttonAdd = new LeafButton( "->" ); | ||||||
|  | 	 | ||||||
|  | 	private final LeafButton buttonRemove = new LeafButton( "<-" ); | ||||||
|  | 	 | ||||||
|  | 	private final LeafButton buttonOK = new LeafButton( "OK" ); | ||||||
|  | 	 | ||||||
|  | 	private final LeafButton buttonCancel = new LeafButton( "Cancelar" ); | ||||||
|  | 	 | ||||||
|  | 	public TreeInserterDialog( String title, DefaultMutableTreeNode root ) | ||||||
|  | 	{ | ||||||
|  | 		this.allRoot = root; | ||||||
|  | 		this.allModel = new DefaultTreeModel( allRoot ); | ||||||
|  | 		this.allTree = new JTree(allModel); | ||||||
|  | 		this.allScroll =  new JScrollPane( allTree ); | ||||||
|  | 		this.setTitle( title ); | ||||||
|  | 		startupComponents(); | ||||||
|  | 		setupLayout(); | ||||||
|  | 		placeComponents(); | ||||||
|  | 		startupListeners(); | ||||||
|  | 		TreeTools.refreshTree(allTree, allRoot); | ||||||
|  | 		setEnabled(); | ||||||
|  | 		this.setLocationRelativeTo( null ); | ||||||
|  | 		this.setSize( 680, 400 ); | ||||||
|  | 		this.setModal( true ); | ||||||
|  | 		this.setVisible( true ); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private void startupComponents() | ||||||
|  | 	{ | ||||||
|  | 		newTree.setRootVisible( false ); | ||||||
|  | 		newTree.getSelectionModel().setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION ); | ||||||
|  | 		allTree.setRootVisible( false ); | ||||||
|  | 		allTree.getSelectionModel().setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION ); | ||||||
|  | 		allScroll.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ); | ||||||
|  | 		allScroll.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); | ||||||
|  | 		newScroll.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ); | ||||||
|  | 		newScroll.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); | ||||||
|  | 		allScroll.setPreferredSize( allDimension ); | ||||||
|  | 		newScroll.setPreferredSize( newDimension ); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private void setupLayout() | ||||||
|  | 	{ | ||||||
|  | 		TableLayout layout = new TableLayout( | ||||||
|  | 				new double[]{ TableLayout.FILL, TableLayout.MINIMUM, TableLayout.PREFERRED, TableLayout.MINIMUM, TableLayout.MINIMUM }, | ||||||
|  | 				new double[]{ TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.FILL, TableLayout.MINIMUM, TableLayout.MINIMUM } | ||||||
|  | 				); | ||||||
|  | 		layout.setHGap( 5 ); | ||||||
|  | 		layout.setVGap( 5 ); | ||||||
|  | 		getContentPane().setLayout( layout ); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private void placeComponents() | ||||||
|  | 	{ | ||||||
|  | 		getContentPane().add( new JLabel("Todos"), new TableLayoutConstraints( 0,0 ) ); | ||||||
|  | 		getContentPane().add( new JLabel("a adicionar..."), new TableLayoutConstraints( 2,0,4,0 ) ); | ||||||
|  | 		getContentPane().add( allScroll, new TableLayoutConstraints( 0,1,0,4 ) ); | ||||||
|  | 		getContentPane().add( buttonAdd, new TableLayoutConstraints( 1,1 ) ); | ||||||
|  | 		getContentPane().add( buttonRemove, new TableLayoutConstraints( 1,3 ) ); | ||||||
|  | 		getContentPane().add( newScroll, new TableLayoutConstraints( 2,1,4,3 ) ); | ||||||
|  | 		getContentPane().add( buttonOK, new TableLayoutConstraints( 3,4 ) ); | ||||||
|  | 		getContentPane().add( buttonCancel, new TableLayoutConstraints( 4,4 ) ); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private void startupListeners() | ||||||
|  | 	{ | ||||||
|  | 		buttonAdd.addActionListener( new ActionListener() | ||||||
|  | 		{ | ||||||
|  | 			@Override | ||||||
|  | 			public void actionPerformed( ActionEvent e ) | ||||||
|  | 			{ | ||||||
|  | 				move( allTree, newTree ); | ||||||
|  | 			} | ||||||
|  | 		} ); | ||||||
|  | 		buttonRemove.addActionListener( new ActionListener() | ||||||
|  | 		{ | ||||||
|  | 			@Override | ||||||
|  | 			public void actionPerformed( ActionEvent e ) | ||||||
|  | 			{ | ||||||
|  | 				move( newTree, allTree ); | ||||||
|  | 			} | ||||||
|  | 		} ); | ||||||
|  | 		buttonOK.addActionListener( new ActionListener() | ||||||
|  | 		{ | ||||||
|  | 			@Override | ||||||
|  | 			public void actionPerformed( ActionEvent e ) | ||||||
|  | 			{ | ||||||
|  | 				ok(); | ||||||
|  | 			} | ||||||
|  | 		} ); | ||||||
|  | 		buttonCancel.addActionListener( new ActionListener() | ||||||
|  | 		{ | ||||||
|  | 			@Override | ||||||
|  | 			public void actionPerformed( ActionEvent e ) | ||||||
|  | 			{ | ||||||
|  | 				cancel(); | ||||||
|  | 			} | ||||||
|  | 		} ); | ||||||
|  | 		allTree.getSelectionModel().addTreeSelectionListener( new TreeSelectionListener(){ | ||||||
|  | 			@Override | ||||||
|  | 			public void valueChanged( TreeSelectionEvent e ) | ||||||
|  | 			{ | ||||||
|  | 				setEnabled(); | ||||||
|  | 			} | ||||||
|  | 		} ); | ||||||
|  | 		newTree.getSelectionModel().addTreeSelectionListener( new TreeSelectionListener(){ | ||||||
|  | 			@Override | ||||||
|  | 			public void valueChanged( TreeSelectionEvent e ) | ||||||
|  | 			{ | ||||||
|  | 				setEnabled(); | ||||||
|  | 			} | ||||||
|  | 		} ); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	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 ) | ||||||
|  | 		{ | ||||||
|  | 			for( int i = 1; i < path.getPathCount(); ++i ) | ||||||
|  | 			{ | ||||||
|  | 				DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getPathComponent( i ); | ||||||
|  | 				DefaultMutableTreeNode parent = (DefaultMutableTreeNode) path.getPathComponent( i-1 ); | ||||||
|  | 				if( node != null && parent != null ) | ||||||
|  | 				{ | ||||||
|  | 					DefaultMutableTreeNode exists = TreeTools.findNodeWithUserObject( node.getUserObject(), toRoot ); | ||||||
|  | 					if( exists == null ) | ||||||
|  | 					{ | ||||||
|  | 						add(node, parent.getUserObject(), toRoot, path.getPathCount() == i + 1 ); | ||||||
|  | 					} | ||||||
|  | 					else | ||||||
|  | 					{ | ||||||
|  | 						merge( exists, node ); | ||||||
|  | 					} | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
|  | 			removeNode( (DefaultMutableTreeNode) path.getLastPathComponent(), fromRoot ); | ||||||
|  | 		} | ||||||
|  | 		TreeTools.refreshTree( from, fromRoot ); | ||||||
|  | 		TreeTools.refreshTree( to, toRoot ); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private void merge( DefaultMutableTreeNode with, DefaultMutableTreeNode what ) | ||||||
|  | 	{ | ||||||
|  | 		for( int i = 0; i < what.getChildCount(); ++i ) | ||||||
|  | 		{ | ||||||
|  | 			DefaultMutableTreeNode child = (DefaultMutableTreeNode) what.getChildAt( i ); | ||||||
|  | 			DefaultMutableTreeNode exists = TreeTools.findNodeWithUserObject( child.getUserObject(), with ); | ||||||
|  | 			if( exists == null ) | ||||||
|  | 			{ | ||||||
|  | 				with.add( TreeTools.cloneFullNode( child ) ); | ||||||
|  | 			} | ||||||
|  | 			else | ||||||
|  | 			{ | ||||||
|  | 				merge( exists, child ); | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private void removeNode( DefaultMutableTreeNode node, DefaultMutableTreeNode root ) | ||||||
|  | 	{ | ||||||
|  | 		DefaultMutableTreeNode parent = (DefaultMutableTreeNode) node.getParent(); | ||||||
|  | 		node.removeFromParent(); | ||||||
|  | 		if( parent != null && parent.getChildCount() == 0 ) | ||||||
|  | 		{ | ||||||
|  | 			removeNode( parent, root ); | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private void add( DefaultMutableTreeNode node, Object parent, DefaultMutableTreeNode where, boolean fullClone ) | ||||||
|  | 	{ | ||||||
|  | 		DefaultMutableTreeNode parentNode = TreeTools.findNodeWithUserObject( parent, where ); | ||||||
|  | 		if( parentNode == null ) | ||||||
|  | 		{ | ||||||
|  | 			parentNode = where; | ||||||
|  | 		} | ||||||
|  | 		parentNode.add( fullClone ? TreeTools.cloneFullNode(node) : (DefaultMutableTreeNode) node.clone() ); | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	private void ok() | ||||||
|  | 	{ | ||||||
|  | 		close(); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private void cancel() | ||||||
|  | 	{ | ||||||
|  | 		newRoot.removeAllChildren(); | ||||||
|  | 		close(); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private void close() | ||||||
|  | 	{ | ||||||
|  | 		setVisible( false ); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private void setEnabled() | ||||||
|  | 	{ | ||||||
|  | 		boolean allSelected = allTree.getSelectionPath() != null; | ||||||
|  | 		boolean newSelected = newTree.getSelectionPath() != null; | ||||||
|  | 		boolean somethingToAdd = newRoot.getChildCount() > 0; | ||||||
|  | 		buttonAdd.setEnabled( allSelected ); | ||||||
|  | 		buttonRemove.setEnabled( newSelected ); | ||||||
|  | 		buttonOK.setEnabled( somethingToAdd ); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	public DefaultMutableTreeNode getResult() | ||||||
|  | 	{ | ||||||
|  | 		return newRoot; | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | } | ||||||
| @ -0,0 +1,149 @@ | |||||||
|  | package siprp.higiene.gestao.postos; | ||||||
|  | 
 | ||||||
|  | import info.clearthought.layout.TableLayout; | ||||||
|  | import info.clearthought.layout.TableLayoutConstraints; | ||||||
|  | 
 | ||||||
|  | import javax.swing.JPanel; | ||||||
|  | import javax.swing.JScrollPane; | ||||||
|  | import javax.swing.JTree; | ||||||
|  | import javax.swing.tree.DefaultMutableTreeNode; | ||||||
|  | import javax.swing.tree.DefaultTreeModel; | ||||||
|  | import javax.swing.tree.TreeSelectionModel; | ||||||
|  | 
 | ||||||
|  | import leaf.ui.LeafButton; | ||||||
|  | import siprp.database.cayenne.objects.Estabelecimentos; | ||||||
|  | import siprp.database.cayenne.objects.HsArea; | ||||||
|  | import siprp.database.cayenne.objects.HsPosto; | ||||||
|  | import siprp.database.cayenne.objects.HsPostoEstabelecimento; | ||||||
|  | 
 | ||||||
|  | public class AdicionarAreasPanel extends JPanel | ||||||
|  | { | ||||||
|  | 
 | ||||||
|  | 	private static final long serialVersionUID = 1L; | ||||||
|  | 	 | ||||||
|  | 	private final LeafButton buttonAdicionar = new LeafButton("Adicionar"); | ||||||
|  | 	 | ||||||
|  | 	private final LeafButton buttonRemover = 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 Estabelecimentos estabelecimento = null; | ||||||
|  | 
 | ||||||
|  | 	public AdicionarAreasPanel() | ||||||
|  | 	{ | ||||||
|  | 		startupComponents(); | ||||||
|  | 		setupLayout(); | ||||||
|  | 		placeComponents(); | ||||||
|  | 		startupListeners(); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private void startupComponents() | ||||||
|  | 	{ | ||||||
|  | 		buttonAdicionar.setEnabled( false ); | ||||||
|  | 		buttonRemover.setEnabled( false ); | ||||||
|  | 		tree.setRootVisible( false ); | ||||||
|  | 		tree.getSelectionModel().setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION ); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private void setupLayout() | ||||||
|  | 	{ | ||||||
|  | 		TableLayout layout = new TableLayout( | ||||||
|  | 				new double[]{ TableLayout.FILL }, | ||||||
|  | 				new double[]{ TableLayout.MINIMUM, TableLayout.FILL } | ||||||
|  | 				); | ||||||
|  | 		layout.setHGap( 5 ); | ||||||
|  | 		layout.setVGap( 5 ); | ||||||
|  | 		setLayout( layout ); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private void placeComponents() | ||||||
|  | 	{ | ||||||
|  | 		JPanel panel = new JPanel(); | ||||||
|  | 		TableLayout layout = new TableLayout( | ||||||
|  | 				new double[]{ TableLayout.MINIMUM, TableLayout.FILL, TableLayout.MINIMUM }, | ||||||
|  | 				new double[]{ TableLayout.MINIMUM } | ||||||
|  | 				); | ||||||
|  | 		layout.setHGap( 5 ); | ||||||
|  | 		layout.setVGap( 5 ); | ||||||
|  | 		panel.setLayout( layout ); | ||||||
|  | 		panel.add( buttonAdicionar, new TableLayoutConstraints( 0, 0 ) ); | ||||||
|  | 		panel.add( buttonRemover, new TableLayoutConstraints( 2, 0 ) ); | ||||||
|  | 			 | ||||||
|  | 		add( panel, new TableLayoutConstraints( 0, 0 ) ); | ||||||
|  | 		add( scroll, new TableLayoutConstraints( 0, 1 ) ); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private void startupListeners() | ||||||
|  | 	{ | ||||||
|  | 		 | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private void setEnabled() | ||||||
|  | 	{ | ||||||
|  | 		buttonAdicionar.setEnabled( estabelecimento != null ); | ||||||
|  | 		buttonRemover.setEnabled( tree.getSelectionCount() > 0 ); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	public void refresh() | ||||||
|  | 	{ | ||||||
|  | 		root.removeAllChildren(); | ||||||
|  | 		if( estabelecimento != null ) | ||||||
|  | 		{ | ||||||
|  | 			for( HsPostoEstabelecimento rel : estabelecimento.getHsPostoEstabelecimentoArray() ) | ||||||
|  | 			{ | ||||||
|  | 				addPosto( rel.getToHsPosto() ); | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 		setEnabled(); | ||||||
|  | 		((DefaultTreeModel) tree.getModel()).nodeStructureChanged( root ); | ||||||
|  | 		for( int i = 0; i < tree.getRowCount(); ++i) | ||||||
|  | 		{ | ||||||
|  | 			tree.expandPath( tree.getPathForRow( i ) ); | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private void addPosto( HsPosto posto ) | ||||||
|  | 	{ | ||||||
|  | 		if( posto != null ) | ||||||
|  | 		{ | ||||||
|  | 			HsArea area = posto.getToHsArea(); | ||||||
|  | 			AreaNode areaNode = getAreaNodeWith( area ); | ||||||
|  | 			if( areaNode == null ) | ||||||
|  | 			{ | ||||||
|  | 				areaNode = new AreaNode( area ); | ||||||
|  | 				root.add( areaNode ); | ||||||
|  | 			} | ||||||
|  | 			areaNode.add( new PostoNode( posto ) ); | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private AreaNode getAreaNodeWith( HsArea area ) | ||||||
|  | 	{ | ||||||
|  | 		AreaNode result = null; | ||||||
|  | 		if( area != null ) | ||||||
|  | 		{ | ||||||
|  | 			for( int i = 0; i < root.getChildCount(); ++i ) | ||||||
|  | 			{ | ||||||
|  | 				if( area.equals( ( (AreaNode) root.getChildAt( i )).getUserObject() ) ) | ||||||
|  | 				{ | ||||||
|  | 					result = (AreaNode) root.getChildAt( i ); | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 		return result; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 	public void setEstabelecimento( Estabelecimentos estabelecimento ) | ||||||
|  | 	{ | ||||||
|  | 		this.estabelecimento  = estabelecimento; | ||||||
|  | 		refresh(); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | } | ||||||
| @ -0,0 +1,17 @@ | |||||||
|  | package siprp.higiene.gestao.postos; | ||||||
|  | 
 | ||||||
|  | import javax.swing.tree.DefaultMutableTreeNode; | ||||||
|  | 
 | ||||||
|  | import siprp.database.cayenne.objects.HsArea; | ||||||
|  | 
 | ||||||
|  | public class AreaNode extends DefaultMutableTreeNode | ||||||
|  | { | ||||||
|  | 
 | ||||||
|  | 	private static final long serialVersionUID = 1L; | ||||||
|  | 	 | ||||||
|  | 	public AreaNode( HsArea risco ) | ||||||
|  | 	{ | ||||||
|  | 		super( risco ); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | } | ||||||
| @ -0,0 +1,317 @@ | |||||||
|  | package siprp.higiene.gestao.postos; | ||||||
|  | 
 | ||||||
|  | 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 info.clearthought.layout.TableLayout; | ||||||
|  | import info.clearthought.layout.TableLayoutConstraints; | ||||||
|  | 
 | ||||||
|  | import java.awt.Dimension; | ||||||
|  | import java.awt.GridLayout; | ||||||
|  | import java.awt.event.ActionEvent; | ||||||
|  | import java.awt.event.ActionListener; | ||||||
|  | import java.util.Date; | ||||||
|  | 
 | ||||||
|  | import javax.swing.BorderFactory; | ||||||
|  | import javax.swing.JOptionPane; | ||||||
|  | import javax.swing.JPanel; | ||||||
|  | import javax.swing.JScrollPane; | ||||||
|  | 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.TreeNode; | ||||||
|  | import javax.swing.tree.TreePath; | ||||||
|  | import javax.swing.tree.TreeSelectionModel; | ||||||
|  | 
 | ||||||
|  | import leaf.ui.LeafButton; | ||||||
|  | import leaf.ui.TreeTools; | ||||||
|  | import siprp.database.cayenne.objects.Empresas; | ||||||
|  | import siprp.database.cayenne.objects.HsArea; | ||||||
|  | import siprp.database.cayenne.objects.HsPosto; | ||||||
|  | 
 | ||||||
|  | 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 buttonAreaRemover = new LeafButton( "Remover" ); | ||||||
|  | 	 | ||||||
|  | 	public final LeafButton buttonPostoCriar = new LeafButton( "Criar" ); | ||||||
|  | 	 | ||||||
|  | 	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(); | ||||||
|  | 		startupLayout(); | ||||||
|  | 		placeComponents(); | ||||||
|  | 		setupListeners(); | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	 | ||||||
|  | 	private void startupComponents() | ||||||
|  | 	{ | ||||||
|  | 		panelButtons.setPreferredSize( new Dimension( 150, 0 ) ); | ||||||
|  | 		panelTree.setPreferredSize( new Dimension( 300, 0 ) ); | ||||||
|  | 		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 } | ||||||
|  | 				); | ||||||
|  | 		layout.setHGap( 5 ); | ||||||
|  | 		layout.setVGap( 5 ); | ||||||
|  | 		setLayout( layout ); | ||||||
|  | 		 | ||||||
|  | 		layout = new TableLayout( | ||||||
|  | 				new double[]{ TableLayout.MINIMUM, TableLayout.FILL, TableLayout.MINIMUM },  | ||||||
|  | 				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.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.add( buttonAreaCriar ); | ||||||
|  | 		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.add( buttonPostoCriar ); | ||||||
|  | 		panel.add( buttonPostoRemover ); | ||||||
|  | 		panelButtons.add( panel, new TableLayoutConstraints( 2, 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(){ | ||||||
|  | 			@Override | ||||||
|  | 			public void valueChanged( TreeSelectionEvent e ) | ||||||
|  | 			{ | ||||||
|  | 				setEnabled(); | ||||||
|  | 			} | ||||||
|  | 		} ); | ||||||
|  | 		buttonAreaCriar.addActionListener( new ActionListener() | ||||||
|  | 		{ | ||||||
|  | 			@Override | ||||||
|  | 			public void actionPerformed( ActionEvent e ) | ||||||
|  | 			{ | ||||||
|  | 				criarArea(); | ||||||
|  | 			} | ||||||
|  | 		} ); | ||||||
|  | 		buttonAreaRemover.addActionListener( new ActionListener() | ||||||
|  | 		{ | ||||||
|  | 			@Override | ||||||
|  | 			public void actionPerformed( ActionEvent e ) | ||||||
|  | 			{ | ||||||
|  | 				removerArea(); | ||||||
|  | 			} | ||||||
|  | 		} ); | ||||||
|  | 		buttonPostoCriar.addActionListener( new ActionListener() | ||||||
|  | 		{ | ||||||
|  | 			@Override | ||||||
|  | 			public void actionPerformed( ActionEvent e ) | ||||||
|  | 			{ | ||||||
|  | 				criarPosto(); | ||||||
|  | 			} | ||||||
|  | 		} ); | ||||||
|  | 		buttonPostoRemover.addActionListener( new ActionListener() | ||||||
|  | 		{ | ||||||
|  | 			@Override | ||||||
|  | 			public void actionPerformed( ActionEvent e ) | ||||||
|  | 			{ | ||||||
|  | 				removerPosto(); | ||||||
|  | 			} | ||||||
|  | 		} ); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private void criarArea() | ||||||
|  | 	{ | ||||||
|  | 		if( empresa != null ) | ||||||
|  | 		{ | ||||||
|  | 			String areaString = JOptionPane.showInputDialog( this, "Descri" + ccedil + atilde + "o", "Criar nova " + aacute + "rea", JOptionPane.QUESTION_MESSAGE ); | ||||||
|  | 			if( areaString != null ) | ||||||
|  | 			{ | ||||||
|  | 				HsArea area = new HsArea(); | ||||||
|  | 				area.setToEmpresas( empresa ); | ||||||
|  | 				area.setDescription( areaString ); | ||||||
|  | 				area.save(); | ||||||
|  | 				refresh(); | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private void removerArea() | ||||||
|  | 	{ | ||||||
|  | 		HsArea area = getSelectedArea(); | ||||||
|  | 		if( area != null ) | ||||||
|  | 		{ | ||||||
|  | 			area.delete(); | ||||||
|  | 			refresh(); | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private void criarPosto() | ||||||
|  | 	{ | ||||||
|  | 		HsArea area = getSelectedArea(); | ||||||
|  | 		if( area != null ) | ||||||
|  | 		{ | ||||||
|  | 			String postoString = JOptionPane.showInputDialog( this, "Descri" + ccedil + atilde + "o", "Criar novo posto de trabalho", JOptionPane.QUESTION_MESSAGE ); | ||||||
|  | 			if( postoString != null ) | ||||||
|  | 			{ | ||||||
|  | 				HsPosto posto = new HsPosto(); | ||||||
|  | 				posto.setToHsArea( area ); | ||||||
|  | 				posto.setDescription( postoString ); | ||||||
|  | 				posto.save(); | ||||||
|  | 				refresh(); | ||||||
|  | 			} | ||||||
|  | 			refresh(); | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private void removerPosto() | ||||||
|  | 	{ | ||||||
|  | 		HsPosto posto = getSelectedPosto(); | ||||||
|  | 		if( posto != null ) | ||||||
|  | 		{ | ||||||
|  | 			posto.setDeletedDate( new Date() ); | ||||||
|  | 			posto.save(); | ||||||
|  | 			refresh(); | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private HsArea getSelectedArea() | ||||||
|  | 	{ | ||||||
|  | 		HsArea result = null; | ||||||
|  | 		TreePath path = tree.getSelectionPath(); | ||||||
|  | 		if( path != null ) | ||||||
|  | 		{ | ||||||
|  | 			Object leaf = path.getLastPathComponent(); | ||||||
|  | 			if( leaf != null ) | ||||||
|  | 			{ | ||||||
|  | 				if(leaf instanceof AreaNode) | ||||||
|  | 				{ | ||||||
|  | 					result = (HsArea) ((AreaNode)leaf).getUserObject(); | ||||||
|  | 				} | ||||||
|  | 				else if(leaf instanceof PostoNode) | ||||||
|  | 				{ | ||||||
|  | 					result = (HsArea) ((HsPosto)((PostoNode)leaf).getUserObject()).getToHsArea(); | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 		return result; | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private HsPosto getSelectedPosto() | ||||||
|  | 	{ | ||||||
|  | 		HsPosto result = null; | ||||||
|  | 		TreePath path = tree.getSelectionPath(); | ||||||
|  | 		if( path != null ) | ||||||
|  | 		{ | ||||||
|  | 			Object leaf = path.getLastPathComponent(); | ||||||
|  | 			if( leaf != null && ( leaf instanceof PostoNode ) ) | ||||||
|  | 			{ | ||||||
|  | 				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 ); | ||||||
|  | 		buttonPostoCriar.setEnabled( areaSelected || postoSelected ); | ||||||
|  | 		buttonPostoRemover.setEnabled( postoSelected ); | ||||||
|  | 		buttonAreaRemover.setEnabled( areaSelected ); | ||||||
|  | 		buttonAreaCriar.setEnabled( empresa != null ); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	public void refresh() | ||||||
|  | 	{ | ||||||
|  | 		root.removeAllChildren(); | ||||||
|  | 		if( empresa != null ) | ||||||
|  | 		{ | ||||||
|  | 			for( HsArea area : empresa.getHsAreaArray()) | ||||||
|  | 			{ | ||||||
|  | 				addArea( area ); | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 		setEnabled(); | ||||||
|  | 		TreeTools.refreshTree(tree, root); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private void addArea( HsArea area ) | ||||||
|  | 	{ | ||||||
|  | 		if( area != null ) | ||||||
|  | 		{ | ||||||
|  | 			AreaNode areaNode = new AreaNode( area ); | ||||||
|  | 			for ( HsPosto posto : area.getHsPostoArray() ) | ||||||
|  | 			{ | ||||||
|  | 				addPosto( posto, areaNode ); | ||||||
|  | 			} | ||||||
|  | 			root.add( areaNode ); | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private void addPosto( HsPosto posto, AreaNode areaNode ) | ||||||
|  | 	{ | ||||||
|  | 		if( posto != null && posto.getDeletedDate() == null ) | ||||||
|  | 		{ | ||||||
|  | 			PostoNode postoNode = new PostoNode( posto ); | ||||||
|  | 			areaNode.add( postoNode ); | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	public void setEmpresa( Empresas empresa ) | ||||||
|  | 	{ | ||||||
|  | 		this.empresa = empresa; | ||||||
|  | 		refresh(); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | } | ||||||
| @ -0,0 +1,17 @@ | |||||||
|  | package siprp.higiene.gestao.postos; | ||||||
|  | 
 | ||||||
|  | import javax.swing.tree.DefaultMutableTreeNode; | ||||||
|  | 
 | ||||||
|  | import siprp.database.cayenne.objects.HsPosto; | ||||||
|  | 
 | ||||||
|  | public class PostoNode extends DefaultMutableTreeNode | ||||||
|  | { | ||||||
|  | 
 | ||||||
|  | 	private static final long serialVersionUID = 1L; | ||||||
|  | 	 | ||||||
|  | 	public PostoNode( HsPosto risco ) | ||||||
|  | 	{ | ||||||
|  | 		super( risco ); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | } | ||||||
| @ -0,0 +1,256 @@ | |||||||
|  | package siprp.higiene.gestao.riscos; | ||||||
|  | 
 | ||||||
|  | import info.clearthought.layout.TableLayout; | ||||||
|  | import info.clearthought.layout.TableLayoutConstraints; | ||||||
|  | 
 | ||||||
|  | import java.awt.event.ActionEvent; | ||||||
|  | import java.awt.event.ActionListener; | ||||||
|  | import java.util.List; | ||||||
|  | 
 | ||||||
|  | import javax.swing.JPanel; | ||||||
|  | import javax.swing.JScrollPane; | ||||||
|  | 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.ui.LeafButton; | ||||||
|  | import leaf.ui.TreeTools; | ||||||
|  | import siprp.database.cayenne.objects.BaseObject; | ||||||
|  | import siprp.database.cayenne.objects.Empresas; | ||||||
|  | import siprp.database.cayenne.objects.HsMedida; | ||||||
|  | import siprp.database.cayenne.objects.HsPosto; | ||||||
|  | import siprp.database.cayenne.objects.HsPostoRisco; | ||||||
|  | import siprp.database.cayenne.objects.HsRisco; | ||||||
|  | import siprp.database.cayenne.objects.HsRiscoEmpresa; | ||||||
|  | import siprp.database.cayenne.objects.HsRiscoMedida; | ||||||
|  | import siprp.database.cayenne.objects.HsRiscoTema; | ||||||
|  | import siprp.database.cayenne.providers.PlanoActuacaoDAO; | ||||||
|  | import siprp.higiene.gestao.TreeInserterDialog; | ||||||
|  | 
 | ||||||
|  | public class AdicionarRiscosPanel extends JPanel | ||||||
|  | { | ||||||
|  | 
 | ||||||
|  | 	private static final long serialVersionUID = 1L; | ||||||
|  | 	 | ||||||
|  | 	private final LeafButton buttonAdicionar = new LeafButton("Adicionar"); | ||||||
|  | 	 | ||||||
|  | 	private final LeafButton buttonRemover = 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; | ||||||
|  | 	 | ||||||
|  | 	private HsPosto posto = null; | ||||||
|  | 
 | ||||||
|  | 	public AdicionarRiscosPanel() | ||||||
|  | 	{ | ||||||
|  | 		startupComponents(); | ||||||
|  | 		setupLayout(); | ||||||
|  | 		placeComponents(); | ||||||
|  | 		startupListeners(); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private void startupComponents() | ||||||
|  | 	{ | ||||||
|  | 		buttonAdicionar.setEnabled( false ); | ||||||
|  | 		buttonRemover.setEnabled( false ); | ||||||
|  | 		tree.setRootVisible( false ); | ||||||
|  | 		tree.getSelectionModel().setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION ); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private void setupLayout() | ||||||
|  | 	{ | ||||||
|  | 		TableLayout layout = new TableLayout( | ||||||
|  | 				new double[]{ TableLayout.FILL }, | ||||||
|  | 				new double[]{ TableLayout.MINIMUM, TableLayout.FILL } | ||||||
|  | 				); | ||||||
|  | 		layout.setHGap( 5 ); | ||||||
|  | 		layout.setVGap( 5 ); | ||||||
|  | 		setLayout( layout ); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private void placeComponents() | ||||||
|  | 	{ | ||||||
|  | 		JPanel panel = new JPanel(); | ||||||
|  | 		TableLayout layout = new TableLayout( | ||||||
|  | 				new double[]{ TableLayout.MINIMUM, TableLayout.FILL, TableLayout.MINIMUM }, | ||||||
|  | 				new double[]{ TableLayout.MINIMUM } | ||||||
|  | 				); | ||||||
|  | 		layout.setHGap( 5 ); | ||||||
|  | 		layout.setVGap( 5 ); | ||||||
|  | 		panel.setLayout( layout ); | ||||||
|  | 		panel.add( buttonAdicionar, new TableLayoutConstraints( 0, 0 ) ); | ||||||
|  | 		panel.add( buttonRemover, new TableLayoutConstraints( 2, 0 ) ); | ||||||
|  | 			 | ||||||
|  | 		add( panel, new TableLayoutConstraints( 0, 0 ) ); | ||||||
|  | 		add( scroll, new TableLayoutConstraints( 0, 1 ) ); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private void startupListeners() | ||||||
|  | 	{ | ||||||
|  | 		buttonAdicionar.addActionListener( new ActionListener() | ||||||
|  | 		{ | ||||||
|  | 			@Override | ||||||
|  | 			public void actionPerformed( ActionEvent e ) | ||||||
|  | 			{ | ||||||
|  | 				add(); | ||||||
|  | 			} | ||||||
|  | 		} ); | ||||||
|  | 		buttonRemover.addActionListener( new ActionListener() | ||||||
|  | 		{ | ||||||
|  | 			@Override | ||||||
|  | 			public void actionPerformed( ActionEvent e ) | ||||||
|  | 			{ | ||||||
|  | 				rem(); | ||||||
|  | 			} | ||||||
|  | 		} ); | ||||||
|  | 		tree.getSelectionModel().addTreeSelectionListener( new TreeSelectionListener(){ | ||||||
|  | 			@Override | ||||||
|  | 			public void valueChanged( TreeSelectionEvent e ) | ||||||
|  | 			{ | ||||||
|  | 				setEnabled(); | ||||||
|  | 			} | ||||||
|  | 		} ); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private void add() | ||||||
|  | 	{ | ||||||
|  | 		List<HsRiscoTema> temas = new PlanoActuacaoDAO().getAllRiscoTemas(); | ||||||
|  | 		if( temas != null ) | ||||||
|  | 		{ | ||||||
|  | 			DefaultMutableTreeNode allRiscos = new DefaultMutableTreeNode(); | ||||||
|  | 			allRiscos.removeAllChildren(); | ||||||
|  | 			for( HsRiscoTema tema : temas ) | ||||||
|  | 			{ | ||||||
|  | 				NodeRiscoTema temaNode = new NodeRiscoTema( tema ); | ||||||
|  | 				for( HsRisco risco : tema.getHsRiscoArray() ) | ||||||
|  | 				{ | ||||||
|  | 					NodeRisco riscoNode = new NodeRisco( risco ); | ||||||
|  | 					for( HsRiscoMedida rel : risco.getHsRiscoMedidaArray() ) | ||||||
|  | 					{ | ||||||
|  | 						riscoNode.add( new NodeMedida( rel ) ); | ||||||
|  | 					} | ||||||
|  | 					temaNode.add( riscoNode ); | ||||||
|  | 				} | ||||||
|  | 				allRiscos.add( temaNode ); | ||||||
|  | 			} | ||||||
|  | 			TreeInserterDialog dialog = new TreeInserterDialog("Adicionar Riscos",allRiscos); | ||||||
|  | 			DefaultMutableTreeNode result = dialog.getResult(); | ||||||
|  | 			if( result != null ) | ||||||
|  | 			{ | ||||||
|  | 				addResult(result); | ||||||
|  | 				refresh(); | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 		setEnabled(); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private void addResult( DefaultMutableTreeNode root ) | ||||||
|  | 	{ | ||||||
|  | 		if( root != null ) | ||||||
|  | 		{ | ||||||
|  | 			if( root instanceof NodeRisco ) | ||||||
|  | 			{ | ||||||
|  | 				HsRisco risco = (HsRisco) root.getUserObject(); | ||||||
|  | 				if( empresa != null ) | ||||||
|  | 				{ | ||||||
|  | 					HsRiscoEmpresa rel = new HsRiscoEmpresa(); | ||||||
|  | 					rel.setToEmpresa( empresa ); | ||||||
|  | 					rel.setToHsRisco( risco ); | ||||||
|  | 					rel.save(); | ||||||
|  | 				} | ||||||
|  | 				else if( posto != null ) | ||||||
|  | 				{ | ||||||
|  | 					HsPostoRisco rel = new HsPostoRisco(); | ||||||
|  | 					rel.setToHsPosto( posto); | ||||||
|  | 					rel.setToHsRisco( risco ); | ||||||
|  | 					rel.save(); | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
|  | 			for( int i = 0; i < root.getChildCount(); ++i ) | ||||||
|  | 			{ | ||||||
|  | 				DefaultMutableTreeNode child = (DefaultMutableTreeNode) root.getChildAt( i ); | ||||||
|  | 				addResult( child ); | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	 | ||||||
|  | 	private void rem() | ||||||
|  | 	{ | ||||||
|  | 		TreePath path = tree.getSelectionPath(); | ||||||
|  | 		if (path != null) | ||||||
|  | 		{ | ||||||
|  | 			DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); | ||||||
|  | 			Object obj = node.getUserObject(); | ||||||
|  | 			if( obj != null ) | ||||||
|  | 			{ | ||||||
|  | 				((BaseObject) obj).delete(); | ||||||
|  | 				refresh(); | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private void setEnabled() | ||||||
|  | 	{ | ||||||
|  | 		if( empresa != null ) | ||||||
|  | 		{ | ||||||
|  | 			buttonAdicionar.setEnabled( true ); | ||||||
|  | 		} | ||||||
|  | 		else if( posto != null ) | ||||||
|  | 		{ | ||||||
|  | 			buttonAdicionar.setEnabled( true ); | ||||||
|  | 		} | ||||||
|  | 		else | ||||||
|  | 		{ | ||||||
|  | 			buttonAdicionar.setEnabled( false ); | ||||||
|  | 		} | ||||||
|  | 		buttonRemover.setEnabled( tree.getSelectionCount() > 0 ); | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	public void refresh() | ||||||
|  | 	{ | ||||||
|  | 		root.removeAllChildren(); | ||||||
|  | 		if( empresa != null ) | ||||||
|  | 		{ | ||||||
|  | 			for( HsRiscoEmpresa rel : empresa.getHsRiscoEmpresaArray() ) | ||||||
|  | 			{ | ||||||
|  | 				root.add( new DefaultMutableTreeNode( rel ) ); | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 		else if( posto != null ) | ||||||
|  | 		{ | ||||||
|  | 			for( HsPostoRisco rel : posto.getHsPostoRiscoArray() ) | ||||||
|  | 			{ | ||||||
|  | 				root.add( new DefaultMutableTreeNode( rel ) ); | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 		setEnabled(); | ||||||
|  | 		TreeTools.refreshTree( tree, root ); | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	public void setEmpresa( Empresas empresa ) | ||||||
|  | 	{ | ||||||
|  | 		this.empresa = empresa; | ||||||
|  | 		this.posto = null; | ||||||
|  | 		refresh(); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	public void setPosto( HsPosto posto ) | ||||||
|  | 	{ | ||||||
|  | 		this.posto = posto; | ||||||
|  | 		this.empresa = null; | ||||||
|  | 		refresh(); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | } | ||||||
| @ -1,4 +1,4 @@ | |||||||
| package siprp.higiene.riscos; | package siprp.higiene.gestao.riscos; | ||||||
| 
 | 
 | ||||||
| import java.util.Date; | import java.util.Date; | ||||||
| 
 | 
 | ||||||
| @ -1,22 +1,22 @@ | |||||||
| package siprp.higiene.riscos; | package siprp.higiene.gestao.riscos; | ||||||
| 
 | 
 | ||||||
| import static com.evolute.utils.strings.UnicodeLatin1Map.aacute; | import static com.evolute.utils.strings.UnicodeLatin1Map.aacute; | ||||||
| import static com.evolute.utils.strings.UnicodeLatin1Map.atilde; | import static com.evolute.utils.strings.UnicodeLatin1Map.atilde; | ||||||
| import static com.evolute.utils.strings.UnicodeLatin1Map.ccedil; | import static com.evolute.utils.strings.UnicodeLatin1Map.ccedil; | ||||||
| import static leaf.ui.LeafLogic.ACTION_REFRESH; | import static leaf.ui.LeafLogic.ACTION_REFRESH; | ||||||
| import static siprp.higiene.riscos.GestaoRiscosLogic.ACTION_CLEAR_SELECTION; | import static siprp.higiene.gestao.riscos.GestaoRiscosLogic.ACTION_CLEAR_SELECTION; | ||||||
| import static siprp.higiene.riscos.GestaoRiscosLogic.ACTION_LOAD; | import static siprp.higiene.gestao.riscos.GestaoRiscosLogic.ACTION_LOAD; | ||||||
| import static siprp.higiene.riscos.GestaoRiscosLogic.ACTION_MEDIDA_CRIAR; | import static siprp.higiene.gestao.riscos.GestaoRiscosLogic.ACTION_MEDIDA_CRIAR; | ||||||
| import static siprp.higiene.riscos.GestaoRiscosLogic.ACTION_MEDIDA_REMOVER; | import static siprp.higiene.gestao.riscos.GestaoRiscosLogic.ACTION_MEDIDA_REMOVER; | ||||||
| import static siprp.higiene.riscos.GestaoRiscosLogic.ACTION_RISCO_CRIAR; | import static siprp.higiene.gestao.riscos.GestaoRiscosLogic.ACTION_RISCO_CRIAR; | ||||||
| import static siprp.higiene.riscos.GestaoRiscosLogic.ACTION_RISCO_REMOVER; | import static siprp.higiene.gestao.riscos.GestaoRiscosLogic.ACTION_RISCO_REMOVER; | ||||||
| import static siprp.higiene.riscos.GestaoRiscosLogic.ACTION_SAVE; | import static siprp.higiene.gestao.riscos.GestaoRiscosLogic.ACTION_SAVE; | ||||||
| import static siprp.higiene.riscos.GestaoRiscosLogic.ACTION_SELECTION; | import static siprp.higiene.gestao.riscos.GestaoRiscosLogic.ACTION_SELECTION; | ||||||
| import static siprp.higiene.riscos.GestaoRiscosLogic.ACTION_SELECT_MEDIDA; | import static siprp.higiene.gestao.riscos.GestaoRiscosLogic.ACTION_SELECT_MEDIDA; | ||||||
| import static siprp.higiene.riscos.GestaoRiscosLogic.ACTION_SELECT_RISCO; | import static siprp.higiene.gestao.riscos.GestaoRiscosLogic.ACTION_SELECT_RISCO; | ||||||
| import static siprp.higiene.riscos.GestaoRiscosLogic.ACTION_SELECT_TEMA; | import static siprp.higiene.gestao.riscos.GestaoRiscosLogic.ACTION_SELECT_TEMA; | ||||||
| import static siprp.higiene.riscos.GestaoRiscosLogic.ACTION_TEMA_CRIAR; | import static siprp.higiene.gestao.riscos.GestaoRiscosLogic.ACTION_TEMA_CRIAR; | ||||||
| import static siprp.higiene.riscos.GestaoRiscosLogic.ACTION_TEMA_REMOVER; | import static siprp.higiene.gestao.riscos.GestaoRiscosLogic.ACTION_TEMA_REMOVER; | ||||||
| import info.clearthought.layout.TableLayout; | import info.clearthought.layout.TableLayout; | ||||||
| import info.clearthought.layout.TableLayoutConstraints; | import info.clearthought.layout.TableLayoutConstraints; | ||||||
| 
 | 
 | ||||||
| @ -1,4 +1,4 @@ | |||||||
| package siprp.higiene.riscos; | package siprp.higiene.gestao.riscos; | ||||||
| 
 | 
 | ||||||
| import javax.swing.tree.DefaultMutableTreeNode; | import javax.swing.tree.DefaultMutableTreeNode; | ||||||
| 
 | 
 | ||||||
| @ -1,4 +1,4 @@ | |||||||
| package siprp.higiene.riscos; | package siprp.higiene.gestao.riscos; | ||||||
| 
 | 
 | ||||||
| import javax.swing.tree.DefaultMutableTreeNode; | import javax.swing.tree.DefaultMutableTreeNode; | ||||||
| 
 | 
 | ||||||
| @ -1,4 +1,4 @@ | |||||||
| package siprp.higiene.riscos; | package siprp.higiene.gestao.riscos; | ||||||
| 
 | 
 | ||||||
| import javax.swing.tree.DefaultMutableTreeNode; | import javax.swing.tree.DefaultMutableTreeNode; | ||||||
| 
 | 
 | ||||||
| @ -0,0 +1,71 @@ | |||||||
|  | package siprp.update.updates; | ||||||
|  | 
 | ||||||
|  | import com.evolute.utils.Singleton; | ||||||
|  | import com.evolute.utils.db.DBManager; | ||||||
|  | import com.evolute.utils.db.Executer; | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * | ||||||
|  |  * @author fpalma | ||||||
|  |  */ | ||||||
|  | public class V9_8_To_V9_9 | ||||||
|  | 		implements siprp.update.Update | ||||||
|  | { | ||||||
|  | 	 | ||||||
|  | 	public V9_8_To_V9_9() | ||||||
|  | 	{ | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	public String []listChanges() | ||||||
|  | 	{ | ||||||
|  | 		return new String[]{ | ||||||
|  | 		                    "Criacao de tabelas para associacao de emails e riscos a empresas" | ||||||
|  | 		                    }; | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	public double getStartVersion() | ||||||
|  | 	{ | ||||||
|  | 		return 9.8; | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	public double getEndVersion() | ||||||
|  | 	{ | ||||||
|  | 		return 9.9; | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	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( | ||||||
|  | 					"alter table hs_posto_medida add column is_plano_actuacao char(1); " + | ||||||
|  | 					"create table hs_email( " + | ||||||
|  | 					"	id serial PRIMARY KEY, " + | ||||||
|  | 					"	email varchar(128) " + | ||||||
|  | 					"); " + | ||||||
|  | 					"create table hs_email_estabelecimento( " + | ||||||
|  | 					"	email_id int4 REFERENCES hs_email(id), " + | ||||||
|  | 					"	estabelecimento_id int4 REFERENCES estabelecimentos(id), " + | ||||||
|  | 					"	constraint hs_email_estabelecimento_pkey PRIMARY KEY(email_id,estabelecimento_id) " + | ||||||
|  | 					"); " + | ||||||
|  | 					"create table hs_email_empresa( " + | ||||||
|  | 					"	email_id int4 REFERENCES hs_email(id), " + | ||||||
|  | 					"	empresa_id int4 REFERENCES empresas(id), " + | ||||||
|  | 					"	constraint hs_email_empresa_pkey PRIMARY KEY(email_id,empresa_id) " + | ||||||
|  | 					"); " + | ||||||
|  | 					"create table hs_risco_empresa( " + | ||||||
|  | 					"	risco_id int4 REFERENCES hs_risco(id), " + | ||||||
|  | 					"	empresa_id int4 REFERENCES empresas(id), " + | ||||||
|  | 					"	constraint hs_risco_empresa_pkey PRIMARY KEY(risco_id,empresa_id) " + | ||||||
|  | 					");" | ||||||
|  | 		); | ||||||
|  | 		executer.executeQuery( update ); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	public String toString() | ||||||
|  | 	{ | ||||||
|  | 		return "v" + getStartVersion() + " para v" + getEndVersion(); | ||||||
|  | 	} | ||||||
|  | } | ||||||
| @ -0,0 +1,62 @@ | |||||||
|  | package leaf.ui; | ||||||
|  | 
 | ||||||
|  | import javax.swing.JTree; | ||||||
|  | import javax.swing.tree.DefaultMutableTreeNode; | ||||||
|  | import javax.swing.tree.DefaultTreeModel; | ||||||
|  | 
 | ||||||
|  | public class TreeTools | ||||||
|  | { | ||||||
|  | 
 | ||||||
|  | 	 | ||||||
|  | 	public static void refreshTree( JTree tree, DefaultMutableTreeNode node ) | ||||||
|  | 	{ | ||||||
|  | 		((DefaultTreeModel) tree.getModel()).nodeStructureChanged( node ); | ||||||
|  | 		for( int i = 0; i < tree.getRowCount(); ++i) | ||||||
|  | 		{ | ||||||
|  | 			tree.expandPath( tree.getPathForRow( i ) ); | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	 | ||||||
|  | 	public static boolean userObjectExistsOn( Object object, DefaultMutableTreeNode on ) | ||||||
|  | 	{ | ||||||
|  | 		boolean result = false; | ||||||
|  | 		if( object != null && on != null ) | ||||||
|  | 		{ | ||||||
|  | 			result = object.equals( on.getUserObject() ); | ||||||
|  | 			for( int i = 0; i < on.getChildCount() && !result; ++i ) | ||||||
|  | 			{ | ||||||
|  | 				result |= userObjectExistsOn( object, (DefaultMutableTreeNode) on.getChildAt( i ) ); | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 		return result; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 	public static DefaultMutableTreeNode findNodeWithUserObject( Object object, DefaultMutableTreeNode on ) | ||||||
|  | 	{ | ||||||
|  | 		DefaultMutableTreeNode result = null; | ||||||
|  | 		if( object != null && on != null ) | ||||||
|  | 		{ | ||||||
|  | 			result = object.equals( on.getUserObject() ) ? on : null; | ||||||
|  | 			for( int i = 0; i < on.getChildCount() && result == null; ++i ) | ||||||
|  | 			{ | ||||||
|  | 				result = object.equals(((DefaultMutableTreeNode) on.getChildAt( i )).getUserObject()) ? (DefaultMutableTreeNode) on.getChildAt( i ) : findNodeWithUserObject( object, (DefaultMutableTreeNode) on.getChildAt( i ) ); | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 		return result; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 	public static DefaultMutableTreeNode cloneFullNode( DefaultMutableTreeNode node ) | ||||||
|  | 	{ | ||||||
|  | 		DefaultMutableTreeNode result = (DefaultMutableTreeNode) node.clone(); | ||||||
|  | 		for( int i = 0; i < node.getChildCount(); ++i ) | ||||||
|  | 		{ | ||||||
|  | 			DefaultMutableTreeNode child = (DefaultMutableTreeNode) node.getChildAt( i ); | ||||||
|  | 			result.add( cloneFullNode(child) ); | ||||||
|  | 		} | ||||||
|  | 		return result; | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | } | ||||||
| @ -0,0 +1,7 @@ | |||||||
|  | package siprp.database.cayenne.objects; | ||||||
|  | 
 | ||||||
|  | import siprp.database.cayenne.objects.auto._HsEmail; | ||||||
|  | 
 | ||||||
|  | public class HsEmail extends _HsEmail { | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -0,0 +1,7 @@ | |||||||
|  | package siprp.database.cayenne.objects; | ||||||
|  | 
 | ||||||
|  | import siprp.database.cayenne.objects.auto._HsEmailEmpresa; | ||||||
|  | 
 | ||||||
|  | public class HsEmailEmpresa extends _HsEmailEmpresa { | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -0,0 +1,7 @@ | |||||||
|  | package siprp.database.cayenne.objects; | ||||||
|  | 
 | ||||||
|  | import siprp.database.cayenne.objects.auto._HsEmailEstabelecimento; | ||||||
|  | 
 | ||||||
|  | public class HsEmailEstabelecimento extends _HsEmailEstabelecimento { | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -0,0 +1,15 @@ | |||||||
|  | package siprp.database.cayenne.objects; | ||||||
|  | 
 | ||||||
|  | import siprp.database.cayenne.objects.auto._HsRiscoEmpresa; | ||||||
|  | 
 | ||||||
|  | public class HsRiscoEmpresa extends _HsRiscoEmpresa { | ||||||
|  | 
 | ||||||
|  | 	private static final long serialVersionUID = 1L; | ||||||
|  | 	 | ||||||
|  | 	@Override | ||||||
|  | 	public String toString() | ||||||
|  | 	{ | ||||||
|  | 		return super.getToHsRisco().getDescription(); | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -0,0 +1,54 @@ | |||||||
|  | package siprp.database.cayenne.objects.auto; | ||||||
|  | 
 | ||||||
|  | import java.util.List; | ||||||
|  | 
 | ||||||
|  | import siprp.database.cayenne.objects.BaseObject; | ||||||
|  | import siprp.database.cayenne.objects.HsEmailEmpresa; | ||||||
|  | import siprp.database.cayenne.objects.HsEmailEstabelecimento; | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * Class _HsEmail 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 _HsEmail extends BaseObject { | ||||||
|  | 
 | ||||||
|  |     public static final String EMAIL_PROPERTY = "email"; | ||||||
|  |     public static final String HS_EMAIL_EMPRESA_ARRAY_PROPERTY = "hsEmailEmpresaArray"; | ||||||
|  |     public static final String HS_EMAIL_ESTABELECIMENTO_ARRAY_PROPERTY = "hsEmailEstabelecimentoArray"; | ||||||
|  | 
 | ||||||
|  |     public static final String ID_PK_COLUMN = "id"; | ||||||
|  | 
 | ||||||
|  |     public void setEmail(String email) { | ||||||
|  |         writeProperty("email", email); | ||||||
|  |     } | ||||||
|  |     public String getEmail() { | ||||||
|  |         return (String)readProperty("email"); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void addToHsEmailEmpresaArray(HsEmailEmpresa obj) { | ||||||
|  |         addToManyTarget("hsEmailEmpresaArray", obj, true); | ||||||
|  |     } | ||||||
|  |     public void removeFromHsEmailEmpresaArray(HsEmailEmpresa obj) { | ||||||
|  |         removeToManyTarget("hsEmailEmpresaArray", obj, true); | ||||||
|  |     } | ||||||
|  |     @SuppressWarnings("unchecked") | ||||||
|  |     public List<HsEmailEmpresa> getHsEmailEmpresaArray() { | ||||||
|  |         return (List<HsEmailEmpresa>)readProperty("hsEmailEmpresaArray"); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |     public void addToHsEmailEstabelecimentoArray(HsEmailEstabelecimento obj) { | ||||||
|  |         addToManyTarget("hsEmailEstabelecimentoArray", obj, true); | ||||||
|  |     } | ||||||
|  |     public void removeFromHsEmailEstabelecimentoArray(HsEmailEstabelecimento obj) { | ||||||
|  |         removeToManyTarget("hsEmailEstabelecimentoArray", obj, true); | ||||||
|  |     } | ||||||
|  |     @SuppressWarnings("unchecked") | ||||||
|  |     public List<HsEmailEstabelecimento> getHsEmailEstabelecimentoArray() { | ||||||
|  |         return (List<HsEmailEstabelecimento>)readProperty("hsEmailEstabelecimentoArray"); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -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.HsEmail; | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * Class _HsEmailEmpresa 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 _HsEmailEmpresa extends BaseObject { | ||||||
|  | 
 | ||||||
|  |     public static final String TO_EMPRESA_PROPERTY = "toEmpresa"; | ||||||
|  |     public static final String TO_HS_EMAIL_PROPERTY = "toHsEmail"; | ||||||
|  | 
 | ||||||
|  |     public static final String EMAIL_ID_PK_COLUMN = "email_id"; | ||||||
|  |     public static final String EMPRESA_ID_PK_COLUMN = "empresa_id"; | ||||||
|  | 
 | ||||||
|  |     public void setToEmpresa(Empresas toEmpresa) { | ||||||
|  |         setToOneTarget("toEmpresa", toEmpresa, true); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public Empresas getToEmpresa() { | ||||||
|  |         return (Empresas)readProperty("toEmpresa"); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |     public void setToHsEmail(HsEmail toHsEmail) { | ||||||
|  |         setToOneTarget("toHsEmail", toHsEmail, true); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public HsEmail getToHsEmail() { | ||||||
|  |         return (HsEmail)readProperty("toHsEmail"); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -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.HsEmail; | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * Class _HsEmailEstabelecimento 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 _HsEmailEstabelecimento extends BaseObject { | ||||||
|  | 
 | ||||||
|  |     public static final String TO_ESTABELECIMENTO_PROPERTY = "toEstabelecimento"; | ||||||
|  |     public static final String TO_HS_EMAIL_PROPERTY = "toHsEmail"; | ||||||
|  | 
 | ||||||
|  |     public static final String EMAIL_ID_PK_COLUMN = "email_id"; | ||||||
|  |     public static final String ESTABELECIMENTO_ID_PK_COLUMN = "estabelecimento_id"; | ||||||
|  | 
 | ||||||
|  |     public void setToEstabelecimento(Estabelecimentos toEstabelecimento) { | ||||||
|  |         setToOneTarget("toEstabelecimento", toEstabelecimento, true); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public Estabelecimentos getToEstabelecimento() { | ||||||
|  |         return (Estabelecimentos)readProperty("toEstabelecimento"); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |     public void setToHsEmail(HsEmail toHsEmail) { | ||||||
|  |         setToOneTarget("toHsEmail", toHsEmail, true); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public HsEmail getToHsEmail() { | ||||||
|  |         return (HsEmail)readProperty("toHsEmail"); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -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.HsRisco; | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * Class _HsRiscoEmpresa 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 _HsRiscoEmpresa extends BaseObject { | ||||||
|  | 
 | ||||||
|  |     public static final String TO_EMPRESA_PROPERTY = "toEmpresa"; | ||||||
|  |     public static final String TO_HS_RISCO_PROPERTY = "toHsRisco"; | ||||||
|  | 
 | ||||||
|  |     public static final String EMPRESA_ID_PK_COLUMN = "empresa_id"; | ||||||
|  |     public static final String RISCO_ID_PK_COLUMN = "risco_id"; | ||||||
|  | 
 | ||||||
|  |     public void setToEmpresa(Empresas toEmpresa) { | ||||||
|  |         setToOneTarget("toEmpresa", toEmpresa, true); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public Empresas getToEmpresa() { | ||||||
|  |         return (Empresas)readProperty("toEmpresa"); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |     public void setToHsRisco(HsRisco toHsRisco) { | ||||||
|  |         setToOneTarget("toHsRisco", toHsRisco, true); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public HsRisco getToHsRisco() { | ||||||
|  |         return (HsRisco)readProperty("toHsRisco"); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | } | ||||||
					Loading…
					
					
				
		Reference in new issue