forked from Coded/SIPRP
git-svn-id: https://svn.coded.pt/svn/SIPRP@907 bb69d46d-e84e-40c8-a05a-06db0d633741
parent
e21c235069
commit
52cf46002a
@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<driver project-version="3.0" class="org.postgresql.Driver">
|
||||
<url value="jdbc:postgresql://storage:5432/siprp_local"/>
|
||||
<connectionPool min="1" max="1"/>
|
||||
<login userName="postgres" password="Typein"/>
|
||||
</driver>
|
||||
@ -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<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
|
||||
|
||||
}
|
||||
|
||||
public void setEstabelecimento( Estabelecimentos estabelecimento )
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -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 );
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in new issue