diff --git a/trunk/SIPRPSoft/src/SIPRPNode.driver.xml b/trunk/SIPRPSoft/src/SIPRPNode.driver.xml
deleted file mode 100644
index 3c75ecb8..00000000
--- a/trunk/SIPRPSoft/src/SIPRPNode.driver.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
diff --git a/trunk/SIPRPSoft/src/siprp/Main.java b/trunk/SIPRPSoft/src/siprp/Main.java
index fb2b2c58..abd9e993 100644
--- a/trunk/SIPRPSoft/src/siprp/Main.java
+++ b/trunk/SIPRPSoft/src/siprp/Main.java
@@ -10,8 +10,8 @@ import static siprp.ProcessoConstants.PROCESSO_FECHADO_DESCRIPTION;
import java.awt.Color;
import java.awt.GraphicsEnvironment;
+import java.sql.SQLException;
import java.util.Date;
-import java.util.Properties;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
@@ -20,6 +20,18 @@ import javax.swing.plaf.ColorUIResource;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.MutableTreeNode;
+import org.apache.cayenne.access.DataContext;
+import org.apache.cayenne.access.DataDomain;
+import org.apache.cayenne.access.DataNode;
+import org.apache.cayenne.conf.Configuration;
+import org.apache.cayenne.conf.DefaultConfiguration;
+import org.apache.cayenne.conf.DriverDataSourceFactory;
+import org.apache.cayenne.conn.DataSourceInfo;
+import org.apache.cayenne.conn.DriverDataSource;
+import org.apache.cayenne.conn.PoolManager;
+import org.apache.cayenne.dba.AutoAdapter;
+import org.apache.cayenne.map.DataMap;
+
import siprp.clientes.AvisosPanel;
import siprp.companydataloaders.SIPRPDataLoader;
import siprp.data.ActualizacaoSaveHandler;
@@ -44,7 +56,6 @@ import com.evolute.utils.error.ErrorLogger;
import com.evolute.utils.jdbc.DBStatementExecuter;
import com.evolute.utils.jdbc.StatementExecuterFactory;
import com.evolute.utils.jdo.JDOObject;
-import com.evolute.utils.jdo.JDOProvider;
import com.evolute.utils.sql.Insert;
import com.evolute.utils.sql.SQLQuery;
import com.evolute.utils.strings.UnicodeChecker;
@@ -279,10 +290,18 @@ public class Main implements com.evolute.utils.ui.window.Connector
return siprpTracker.getRoot();
}
- public void initializeCayenne(String url, String user, String password)
+ public void initializeCayenne(String url, String user, String password) throws SQLException
{
- // TODO: override DB location, user and password
+ DataDomain domain = DefaultConfiguration.getSharedConfiguration().getDomain();
+ DataMap map = domain.getMap( "SIPRPMap" );
+ DriverDataSource dataSource = new DriverDataSource((String) Singleton.getInstance( SingletonConstants.LOCAL_DRIVER_NAME ), url, user, password );
+ DataNode node = new DataNode("SIPRPNode");
+ node.setDataSource( dataSource );
+ node.setAdapter( new AutoAdapter(dataSource) );
+ node.addDataMap( map );
+ node.setEntityResolver( domain.getEntityResolver() );
+ domain.reset();
+ domain.addNode( node );
}
-
}
diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/AdicionarEmailsPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/AdicionarEmailsPanel.java
deleted file mode 100644
index 1189cac6..00000000
--- a/trunk/SIPRPSoft/src/siprp/higiene/gestao/AdicionarEmailsPanel.java
+++ /dev/null
@@ -1,98 +0,0 @@
-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 siprp.database.cayenne.objects.Estabelecimentos;
-
-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 model = new VectorTableModel( 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
-
- }
-
- public void setEstabelecimento( Estabelecimentos estabelecimento )
- {
- // TODO Auto-generated method stub
-
- }
-
-}
diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/GerirEmpresaPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/GerirEmpresaPanel.java
index 972e693e..c0f7891d 100644
--- a/trunk/SIPRPSoft/src/siprp/higiene/gestao/GerirEmpresaPanel.java
+++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/GerirEmpresaPanel.java
@@ -9,6 +9,7 @@ import javax.swing.BorderFactory;
import javax.swing.JPanel;
import siprp.database.cayenne.objects.Empresas;
+import siprp.higiene.gestao.email.AdicionarEmailsPanel;
import siprp.higiene.gestao.legislacao.AdicionarLegislacaoPanel;
import siprp.higiene.gestao.normalizacao.AdicionarNormalizacaoPanel;
import siprp.higiene.gestao.postos.GerirAreasPanel;
@@ -48,7 +49,7 @@ public class GerirEmpresaPanel extends JPanel
private void setupLayout()
{
double [] cols = new double[]{ TableLayout.FILL, TableLayout.FILL, TableLayout.FILL, };
- double [] rows = new double[]{ TableLayout.FILL, TableLayout.FILL, TableLayout.PREFERRED };
+ double [] rows = new double[]{ TableLayout.FILL, TableLayout.FILL };
TableLayout layout = new TableLayout( cols, rows );
layout.setHGap( 5 );
layout.setVGap( 5 );
@@ -57,11 +58,10 @@ public class GerirEmpresaPanel extends JPanel
private void placeComponents()
{
- this.add( panelAreas, new TableLayoutConstraints( 0, 0, 0, 2 ) );
- this.add( panelRiscos, new TableLayoutConstraints( 1, 0, 1, 2 ) );
+ 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( panelNormalizacao, new TableLayoutConstraints( 2, 1 ) );
- this.add( panelEmails, new TableLayoutConstraints( 2, 2 ) );
}
private void startupListeners()
@@ -72,7 +72,6 @@ public class GerirEmpresaPanel extends JPanel
public void setEmpresa( Empresas empresa )
{
panelAreas.setEmpresa( empresa );
- panelEmails.setEmpresa( empresa );
panelLegislacao.setEmpresa( empresa );
panelRiscos.setEmpresa( empresa );
panelNormalizacao.setEmpresa( empresa );
diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/GerirEstabelecimentosPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/GerirEstabelecimentosPanel.java
index 13494e1a..6889a1b1 100644
--- a/trunk/SIPRPSoft/src/siprp/higiene/gestao/GerirEstabelecimentosPanel.java
+++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/GerirEstabelecimentosPanel.java
@@ -19,6 +19,7 @@ import javax.swing.JPanel;
import siprp.database.cayenne.objects.Empresas;
import siprp.database.cayenne.objects.Estabelecimentos;
import siprp.database.cayenne.objects.HsPosto;
+import siprp.higiene.gestao.email.AdicionarEmailsPanel;
import siprp.higiene.gestao.legislacao.AdicionarLegislacaoPanel;
import siprp.higiene.gestao.normalizacao.AdicionarNormalizacaoPanel;
import siprp.higiene.gestao.postos.AdicionarAreasPanel;
diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/GlobalPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/GlobalPanel.java
index ade737c9..de5ca494 100644
--- a/trunk/SIPRPSoft/src/siprp/higiene/gestao/GlobalPanel.java
+++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/GlobalPanel.java
@@ -36,7 +36,6 @@ public class GlobalPanel extends JTabbedPane
addTab( "Legisla" + ccedil + atilde + "o", panelLegislacao );
addTab( "Normaliza" + ccedil + atilde + "o", panelNormalizacao );
addTab( "Equipamentos", panelEquipamentos );
- setEnabledAt( 3, false );
}
private void setupLayout()
diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/email/AdicionarEmailsPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/email/AdicionarEmailsPanel.java
new file mode 100644
index 00000000..73365d95
--- /dev/null
+++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/email/AdicionarEmailsPanel.java
@@ -0,0 +1,98 @@
+package siprp.higiene.gestao.email;
+
+import javax.swing.JOptionPane;
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.TreePath;
+
+import leaf.ui.LeafError;
+import leaf.ui.TreeTools;
+import siprp.database.cayenne.objects.Estabelecimentos;
+import siprp.database.cayenne.objects.HsEmail;
+import siprp.database.cayenne.objects.HsEmailEstabelecimento;
+import siprp.higiene.gestao.AdicionarPanel;
+import siprp.logic.HigieneSegurancaLogic;
+
+public class AdicionarEmailsPanel extends AdicionarPanel
+{
+
+ private static final long serialVersionUID = 1L;
+
+ private Estabelecimentos estabelecimento = null;
+
+ public void setEstabelecimento( Estabelecimentos estabelecimento )
+ {
+ this.estabelecimento = estabelecimento;
+ refresh();
+ setEnabled();
+ }
+
+ @Override
+ protected void add()
+ {
+ try
+ {
+ if( estabelecimento != null )
+ {
+ String emailString = JOptionPane.showInputDialog( this, "Email", "Adicionar novo Email", JOptionPane.QUESTION_MESSAGE );
+ if( emailString != null )
+ {
+ HsEmail email = new HsEmail();
+ email.setEmail( emailString );
+ email.save();
+ HsEmailEstabelecimento rel = new HsEmailEstabelecimento();
+ rel.setToHsEmail( email );
+ rel.setToEstabelecimento( estabelecimento );
+ rel.save();
+ refresh();
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ LeafError.error( e );
+ }
+ }
+
+
+ @Override
+ protected void rem()
+ {
+ try
+ {
+ TreePath path = tree.getSelectionPath();
+ if( path != null )
+ {
+ DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
+ if( node != null )
+ {
+ Object obj = node.getUserObject();
+ if( obj instanceof HsEmailEstabelecimento )
+ {
+ ((HsEmailEstabelecimento) obj).delete();
+ refresh();
+ }
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ LeafError.error( e );
+ }
+ }
+
+ @Override
+ public void refresh()
+ {
+ root.removeAllChildren();
+ TreeTools.merge( root, HigieneSegurancaLogic.getEmailsForEstabelecimento( estabelecimento ) );
+ TreeTools.refreshTree( tree, root );
+ }
+
+ @Override
+ protected void setEnabled()
+ {
+ buttonAdicionar.setEnabled( estabelecimento != null );
+ buttonRemover.setEnabled( tree.getSelectionCount() > 0 );
+ }
+
+}
diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/equipamentos/GerirEquipamentosPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/equipamentos/GerirEquipamentosPanel.java
index 484d1192..ba714cc8 100644
--- a/trunk/SIPRPSoft/src/siprp/higiene/gestao/equipamentos/GerirEquipamentosPanel.java
+++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/equipamentos/GerirEquipamentosPanel.java
@@ -7,11 +7,16 @@ 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.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.CaretEvent;
+import javax.swing.event.CaretListener;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.DefaultMutableTreeNode;
@@ -19,17 +24,25 @@ 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.LeafTextAreaEditor;
+import leaf.ui.LeafError;
+import leaf.ui.LeafIconButton;
import leaf.ui.TreeTools;
import siprp.database.cayenne.objects.HsEquipamento;
import siprp.logic.HigieneSegurancaLogic;
-public class GerirEquipamentosPanel extends JPanel
+public class GerirEquipamentosPanel extends JPanel implements CaretListener
{
private static final long serialVersionUID = 1L;
+
+ private static final String ICON_NAME_SAVE = "leaf/ui/icons/save.png";
+
+ private static final String ICON_NAME_REVERT = "leaf/ui/icons/revert.png";
+
+ private LeafIconButton buttonSaveRequesito = LeafIconButton.createButton( ICON_NAME_SAVE );
+
+ private LeafIconButton buttonRevertRequesito = LeafIconButton.createButton( ICON_NAME_REVERT );
private final JPanel panelButtons = new JPanel();
@@ -37,28 +50,14 @@ public class GerirEquipamentosPanel extends JPanel
private final JPanel panelData = new JPanel();
- private final LeafTextAreaEditor textMarca = new LeafTextAreaEditor( new Validator()
- {
- @Override
- public boolean isValid( String object )
- {
- return isMarcaValida( object );
- }
- }, true );
+ private final JTextField textTipo = new JTextField(20);
- private final LeafTextAreaEditor textModelo = new LeafTextAreaEditor( new Validator()
- {
- @Override
- public boolean isValid( String object )
- {
- return isModeloValido( object );
- }
- }, true );
+ private final JTextField textMarca = new JTextField(20);
+
+ private final JTextField textModelo = new JTextField(20);
private final LeafButton buttonCriar = new LeafButton( "Criar" );
- private final LeafButton buttonEditar = new LeafButton( "Editar" );
-
private final LeafButton buttonRemover = new LeafButton( "Remover" );
private final DefaultMutableTreeNode root = new DefaultMutableTreeNode();
@@ -88,20 +87,28 @@ public class GerirEquipamentosPanel extends JPanel
criar();
}
} );
- buttonEditar.addActionListener( new ActionListener()
+ buttonRemover.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
- editar();
+ remover();
}
} );
- buttonRemover.addActionListener( new ActionListener()
+ buttonSaveRequesito.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
- remover();
+ save();
+ }
+ } );
+ buttonRevertRequesito.addActionListener( new ActionListener()
+ {
+ @Override
+ public void actionPerformed( ActionEvent e )
+ {
+ revert();
}
} );
tree.getSelectionModel().addTreeSelectionListener( new TreeSelectionListener()
@@ -109,21 +116,98 @@ public class GerirEquipamentosPanel extends JPanel
@Override
public void valueChanged( TreeSelectionEvent e )
{
+ TreePath path = e.getNewLeadSelectionPath();
+ if( path != null )
+ {
+ DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
+ Object obj = node.getUserObject();
+ if( obj instanceof HsEquipamento )
+ {
+ textTipo.setText( ((HsEquipamento)obj).getTipo() );
+ textMarca.setText( ((HsEquipamento)obj).getMarca() );
+ textModelo.setText( ((HsEquipamento)obj).getModelo());
+ }
+ }
+ else
+ {
+ textTipo.setText( "" );
+ textMarca.setText( "" );
+ textModelo.setText( "" );
+ }
setEnabled();
}
} );
+ textTipo.addCaretListener( this );
+ textMarca.addCaretListener( this );
+ textModelo.addCaretListener( this );
}
private void criar()
{
+ try
+ {
+ String tipo = JOptionPane.showInputDialog( this, "Tipo", "Criar novo equipamento", JOptionPane.QUESTION_MESSAGE );
+ if( tipo != null )
+ {
+ HsEquipamento equipamento = new HsEquipamento();
+ equipamento.setTipo( tipo );
+ equipamento.save();
+ refresh();
+ }
+ }
+ catch( Exception e )
+ {
+ LeafError.error( e );
+ }
}
- private void editar()
+ private void remover()
+ {
+ try
+ {
+ HsEquipamento equipamento = getSelected();
+ if( equipamento != null )
+ {
+ equipamento.setDeletedDate( new Date() );
+ equipamento.save();
+ refresh();
+ }
+ }
+ catch( Exception e )
+ {
+ LeafError.error( e );
+ }
+ }
+
+ private void save()
{
+ try
+ {
+ HsEquipamento equipamento = getSelected();
+ if( equipamento != null )
+ {
+ equipamento.setTipo( textTipo.getText() );
+ equipamento.setMarca( textMarca.getText() );
+ equipamento.setModelo( textModelo.getText() );
+ equipamento.save();
+ refresh();
+ }
+ }
+ catch( Exception e )
+ {
+ LeafError.error( e );
+ }
}
-
- private void remover()
+
+ private void revert()
{
+ HsEquipamento equipamento = getSelected();
+ if( equipamento != null )
+ {
+ textTipo.setText( equipamento.getTipo() );
+ textMarca.setText( equipamento.getMarca() );
+ textModelo.setText( equipamento.getModelo() );
+ }
}
private HsEquipamento getSelected()
@@ -154,8 +238,20 @@ public class GerirEquipamentosPanel extends JPanel
private void setEnabled()
{
HsEquipamento equipamento = getSelected();
- buttonEditar.setEnabled( equipamento != null );
buttonRemover.setEnabled( equipamento != null );
+ textTipo.setEnabled( equipamento != null );
+ textMarca.setEnabled( equipamento != null );
+ textModelo.setEnabled( equipamento != null );
+ buttonSaveRequesito.setEnabled( false );
+ buttonRevertRequesito.setEnabled( false );
+ if( equipamento != null )
+ {
+ boolean changed = !textTipo.getText().equals( equipamento.getTipo() );
+ changed |= !textMarca.getText().equals( equipamento.getMarca() == null ? "" : equipamento.getMarca() );
+ changed |= !textModelo.getText().equals( equipamento.getModelo() == null ? "" : equipamento.getModelo() );
+ buttonSaveRequesito.setEnabled( changed );
+ buttonRevertRequesito.setEnabled( changed );
+ }
}
private void startupLayout()
@@ -172,16 +268,16 @@ public class GerirEquipamentosPanel extends JPanel
layout = new TableLayout( new double[] {
TableLayout.MINIMUM
}, new double[] {
- TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM
+ TableLayout.MINIMUM, TableLayout.MINIMUM
} );
layout.setHGap( 5 );
layout.setVGap( 5 );
panelButtons.setLayout( layout );
layout = new TableLayout( new double[] {
- TableLayout.MINIMUM, TableLayout.FILL
+ TableLayout.MINIMUM, TableLayout.FILL,TableLayout.MINIMUM,TableLayout.MINIMUM
}, new double[] {
- TableLayout.MINIMUM, TableLayout.MINIMUM
+ TableLayout.MINIMUM,TableLayout.MINIMUM,TableLayout.MINIMUM, TableLayout.MINIMUM
} );
layout.setHGap( 5 );
layout.setVGap( 5 );
@@ -193,15 +289,18 @@ public class GerirEquipamentosPanel extends JPanel
private void placeComponents()
{
panelButtons.add( buttonCriar, new TableLayoutConstraints( 0, 0 ) );
- panelButtons.add( buttonEditar, new TableLayoutConstraints( 0, 1 ) );
- panelButtons.add( buttonRemover, new TableLayoutConstraints( 0, 2 ) );
+ panelButtons.add( buttonRemover, new TableLayoutConstraints( 0, 1 ) );
panelTree.add( scroll, new TableLayoutConstraints( 0, 0 ) );
- panelData.add( new JLabel("Marca"), new TableLayoutConstraints( 0, 0 ) );
- panelData.add( textMarca, new TableLayoutConstraints( 1, 0 ) );
- panelData.add( new JLabel("Modelo"), new TableLayoutConstraints( 0, 1 ) );
- panelData.add( textModelo, new TableLayoutConstraints( 1, 1 ) );
+ panelData.add( buttonSaveRequesito, new TableLayoutConstraints( 2, 0 ) );
+ panelData.add( buttonRevertRequesito, new TableLayoutConstraints( 3, 0 ) );
+ panelData.add( new JLabel("Tipo"), new TableLayoutConstraints( 0, 1 ) );
+ panelData.add( textTipo, new TableLayoutConstraints( 1, 1, 3, 1 ) );
+ panelData.add( new JLabel("Marca"), new TableLayoutConstraints( 0, 2 ) );
+ panelData.add( textMarca, new TableLayoutConstraints( 1, 2, 3, 2 ) );
+ panelData.add( new JLabel("Modelo"), new TableLayoutConstraints( 0, 3 ) );
+ panelData.add( textModelo, new TableLayoutConstraints( 1, 3, 3, 3 ) );
add( panelButtons, new TableLayoutConstraints( 0, 0 ) );
add( panelTree, new TableLayoutConstraints( 1, 0 ) );
@@ -215,15 +314,11 @@ public class GerirEquipamentosPanel extends JPanel
TreeTools.refreshTree( tree, root );
setEnabled();
}
-
- private boolean isMarcaValida( String marca )
- {
- return true;
- }
-
- private boolean isModeloValido( String modelo )
+
+ @Override
+ public void caretUpdate( CaretEvent e )
{
- return true;
+ setEnabled();
}
}
diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirMedidaPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirMedidaPanel.java
index c4a758a7..80775c91 100644
--- a/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirMedidaPanel.java
+++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirMedidaPanel.java
@@ -29,9 +29,9 @@ public class GerirMedidaPanel extends JPanel
private static final long serialVersionUID = 1L;
- private static final String ICON_NAME_SAVE = "siprp/higiene/gestao/riscos/save.png";
+ private static final String ICON_NAME_SAVE = "leaf/ui/icons/save.png";
- private static final String ICON_NAME_REVERT = "siprp/higiene/gestao/riscos/revert.png";
+ private static final String ICON_NAME_REVERT = "leaf/ui/icons/revert.png";
private LeafButton buttonSaveRequesito;
diff --git a/trunk/common/src/cayenne.xml b/trunk/common/src/cayenne.xml
index f91ca29c..ffac5a63 100644
--- a/trunk/common/src/cayenne.xml
+++ b/trunk/common/src/cayenne.xml
@@ -4,11 +4,5 @@
-
-
-
-
diff --git a/trunk/common/src/leaf/ui/TreeTools.java b/trunk/common/src/leaf/ui/TreeTools.java
index 25cb6ea3..c6ad5236 100644
--- a/trunk/common/src/leaf/ui/TreeTools.java
+++ b/trunk/common/src/leaf/ui/TreeTools.java
@@ -57,17 +57,20 @@ public class TreeTools
public static void merge( DefaultMutableTreeNode with, DefaultMutableTreeNode what )
{
- for( int i = 0; i < what.getChildCount(); ++i )
+ if( what != null )
{
- DefaultMutableTreeNode child = (DefaultMutableTreeNode) what.getChildAt( i );
- DefaultMutableTreeNode exists = TreeTools.findNodeWithUserObject( child.getUserObject(), with );
- if( exists == null )
- {
- with.add( TreeTools.cloneFullNode( child ) );
- }
- else
+ for( int i = 0; i < what.getChildCount(); ++i )
{
- merge( exists, child );
+ 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 );
+ }
}
}
}
diff --git a/trunk/common/src/siprp/database/cayenne/objects/HsEmailEmpresa.java b/trunk/common/src/siprp/database/cayenne/objects/HsEmailEmpresa.java
index f2bc61cf..dfb9395f 100644
--- a/trunk/common/src/siprp/database/cayenne/objects/HsEmailEmpresa.java
+++ b/trunk/common/src/siprp/database/cayenne/objects/HsEmailEmpresa.java
@@ -4,4 +4,12 @@ import siprp.database.cayenne.objects.auto._HsEmailEmpresa;
public class HsEmailEmpresa extends _HsEmailEmpresa {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public String toString()
+ {
+ return getToHsEmail().toString();
+ }
+
}
diff --git a/trunk/common/src/siprp/database/cayenne/objects/HsEmailEstabelecimento.java b/trunk/common/src/siprp/database/cayenne/objects/HsEmailEstabelecimento.java
index addeaca1..67c3c686 100644
--- a/trunk/common/src/siprp/database/cayenne/objects/HsEmailEstabelecimento.java
+++ b/trunk/common/src/siprp/database/cayenne/objects/HsEmailEstabelecimento.java
@@ -4,4 +4,12 @@ import siprp.database.cayenne.objects.auto._HsEmailEstabelecimento;
public class HsEmailEstabelecimento extends _HsEmailEstabelecimento {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public String toString()
+ {
+ return getToHsEmail().toString();
+ }
+
}
diff --git a/trunk/common/src/siprp/database/cayenne/objects/HsEquipamento.java b/trunk/common/src/siprp/database/cayenne/objects/HsEquipamento.java
index e4cc8f9c..4c597f8c 100644
--- a/trunk/common/src/siprp/database/cayenne/objects/HsEquipamento.java
+++ b/trunk/common/src/siprp/database/cayenne/objects/HsEquipamento.java
@@ -45,7 +45,9 @@ public class HsEquipamento extends _HsEquipamento {
@Override
public String toString()
{
- return getTipo();
+ String marca = getMarca() == null ? "" : getMarca();
+ String modelo = getModelo() == null ? "" : getModelo();
+ return getTipo() + ": " + marca + "-" + modelo;
}
diff --git a/trunk/common/src/siprp/database/cayenne/providers/PlanoActuacaoDAO.java b/trunk/common/src/siprp/database/cayenne/providers/PlanoActuacaoDAO.java
index fd54f3cc..b530983b 100644
--- a/trunk/common/src/siprp/database/cayenne/providers/PlanoActuacaoDAO.java
+++ b/trunk/common/src/siprp/database/cayenne/providers/PlanoActuacaoDAO.java
@@ -10,6 +10,7 @@ import org.apache.cayenne.query.SelectQuery;
import siprp.database.cayenne.objects.EmailPlanoDeActuacao;
import siprp.database.cayenne.objects.Estabelecimentos;
+import siprp.database.cayenne.objects.HsEmailEstabelecimento;
import siprp.database.cayenne.objects.HsEquipamento;
import siprp.database.cayenne.objects.HsLegislacao;
import siprp.database.cayenne.objects.HsLegislacaoCategoria;
@@ -343,4 +344,11 @@ public class PlanoActuacaoDAO extends MainDAO
return context.performQuery( query );
}
+ public List getEmailsForEstabelecimento( Estabelecimentos estabelecimento )
+ {
+ SelectQuery query = new SelectQuery( HsEmailEstabelecimento.class );
+ query.andQualifier( ExpressionFactory.matchExp( HsEmailEstabelecimento.TO_ESTABELECIMENTO_PROPERTY, estabelecimento ) );
+ return context.performQuery( query );
+ }
+
}
diff --git a/trunk/common/src/siprp/logic/HigieneSegurancaLogic.java b/trunk/common/src/siprp/logic/HigieneSegurancaLogic.java
index f976d4d4..84179db1 100644
--- a/trunk/common/src/siprp/logic/HigieneSegurancaLogic.java
+++ b/trunk/common/src/siprp/logic/HigieneSegurancaLogic.java
@@ -10,6 +10,7 @@ import leaf.ui.TreeTools;
import siprp.database.cayenne.objects.Empresas;
import siprp.database.cayenne.objects.Estabelecimentos;
import siprp.database.cayenne.objects.HsArea;
+import siprp.database.cayenne.objects.HsEmailEstabelecimento;
import siprp.database.cayenne.objects.HsEquipamento;
import siprp.database.cayenne.objects.HsLegislacao;
import siprp.database.cayenne.objects.HsLegislacaoCategoria;
@@ -516,5 +517,19 @@ public class HigieneSegurancaLogic
}
return result;
}
+
+ public static DefaultMutableTreeNode getEmailsForEstabelecimento( Estabelecimentos estabelecimento )
+ {
+ DefaultMutableTreeNode result = new DefaultMutableTreeNode();
+ List emails = planoProvider.getEmailsForEstabelecimento( estabelecimento );
+ if( emails != null )
+ {
+ for( HsEmailEstabelecimento rel : emails )
+ {
+ result.add( new DefaultMutableTreeNode( rel ) );
+ }
+ }
+ return result;
+ }
}