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

0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
Tiago Simão 16 years ago
parent 0dc6148dc6
commit 6438cbe35b

Binary file not shown.

@ -1,21 +1,16 @@
package siprp.higiene.relatorio; package siprp.higiene.relatorio;
import static com.evolute.utils.strings.UnicodeLatin1Map.aacute;
import info.clearthought.layout.TableLayout; import info.clearthought.layout.TableLayout;
import info.clearthought.layout.TableLayoutConstraints; import info.clearthought.layout.TableLayoutConstraints;
import java.awt.CardLayout; import java.awt.CardLayout;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener; import java.beans.PropertyChangeListener;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JPanel; import javax.swing.JPanel;
import leaf.ui.LeafButton;
import leaf.ui.LeafIconButton;
import siprp.database.cayenne.objects.Estabelecimentos; import siprp.database.cayenne.objects.Estabelecimentos;
import siprp.database.cayenne.objects.HsArea; import siprp.database.cayenne.objects.HsArea;
import siprp.database.cayenne.objects.HsPosto; import siprp.database.cayenne.objects.HsPosto;
@ -28,8 +23,6 @@ import siprp.database.cayenne.objects.HsRelatorioPostoRisco;
import siprp.database.cayenne.objects.MarcacoesEstabelecimento; import siprp.database.cayenne.objects.MarcacoesEstabelecimento;
import siprp.logic.HigieneSegurancaLogic; import siprp.logic.HigieneSegurancaLogic;
import com.evolute.utils.error.ErrorLogger;
public class PlanoActuacaoPanel extends JPanel public class PlanoActuacaoPanel extends JPanel
{ {
@ -49,7 +42,7 @@ public class PlanoActuacaoPanel extends JPanel
private final GerirMedidaRelatorioPanel valoresMedida = new GerirMedidaRelatorioPanel(); private final GerirMedidaRelatorioPanel valoresMedida = new GerirMedidaRelatorioPanel();
private final LeafButton refreshAreasButton = LeafIconButton.createButton( "Actualizar nomes de " + aacute + "reas/postos", PanelRelatorio.ICON_NAME_UNDO ); // private final LeafButton refreshAreasButton = LeafIconButton.createButton( "Actualizar nomes de " + aacute + "reas/postos", PanelRelatorio.ICON_NAME_UNDO );
private final JPanel emptyPanel = new JPanel(); private final JPanel emptyPanel = new JPanel();
@ -125,21 +118,21 @@ public class PlanoActuacaoPanel extends JPanel
riscos.refresh(); riscos.refresh();
} }
} ); } );
refreshAreasButton.addActionListener( new ActionListener() // refreshAreasButton.addActionListener( new ActionListener()
{ // {
@Override // @Override
public void actionPerformed( ActionEvent e ) // public void actionPerformed( ActionEvent e )
{ // {
try // try
{ // {
refreshAreas(); // refreshAreas();
} // }
catch ( Exception ex ) // catch ( Exception ex )
{ // {
ErrorLogger.logException( ex ); // ErrorLogger.logException( ex );
} // }
} // }
} ); // } );
} }
private void refreshAreas() throws Exception private void refreshAreas() throws Exception
@ -254,7 +247,7 @@ public class PlanoActuacaoPanel extends JPanel
valoresPanel.add( valoresRisco, RISCO_PANEL ); valoresPanel.add( valoresRisco, RISCO_PANEL );
valoresPanel.add( valoresMedida, MEDIDA_PANEL ); valoresPanel.add( valoresMedida, MEDIDA_PANEL );
valoresPanel.add( emptyPanel, EMPTY_PANEL ); valoresPanel.add( emptyPanel, EMPTY_PANEL );
add( refreshAreasButton, new TableLayoutConstraints( 0, 0, 1, 0 ) ); // add( refreshAreasButton, new TableLayoutConstraints( 0, 0, 1, 0 ) );
add( areas, new TableLayoutConstraints( 0, 1, 1, 1 ) ); add( areas, new TableLayoutConstraints( 0, 1, 1, 1 ) );
add( riscos, new TableLayoutConstraints( 2, 1 ) ); add( riscos, new TableLayoutConstraints( 2, 1 ) );
add( valoresPanel, new TableLayoutConstraints( 3, 1 ) ); add( valoresPanel, new TableLayoutConstraints( 3, 1 ) );
@ -262,7 +255,7 @@ public class PlanoActuacaoPanel extends JPanel
private void setEnabled() private void setEnabled()
{ {
refreshAreasButton.setEnabled(relatorio != null && relatorio.getIsSubmetido() == null ); // refreshAreasButton.setEnabled(relatorio != null && relatorio.getIsSubmetido() == null );
} }
public void setRelatorio( HsRelatorio relatorio ) public void setRelatorio( HsRelatorio relatorio )

@ -5,7 +5,11 @@ import info.clearthought.layout.TableLayoutConstraints;
import java.awt.Color; import java.awt.Color;
import java.awt.Component; import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JOptionPane;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JScrollPane; import javax.swing.JScrollPane;
import javax.swing.JTree; import javax.swing.JTree;
@ -19,11 +23,14 @@ import javax.swing.tree.TreeSelectionModel;
import leaf.ui.LeafTree; import leaf.ui.LeafTree;
import siprp.database.cayenne.objects.HsRelatorio; import siprp.database.cayenne.objects.HsRelatorio;
import siprp.database.cayenne.objects.HsRelatorioArea;
import siprp.database.cayenne.objects.HsRelatorioPosto; import siprp.database.cayenne.objects.HsRelatorioPosto;
import siprp.database.cayenne.objects.HsRelatorioPostoRisco; import siprp.database.cayenne.objects.HsRelatorioPostoRisco;
import siprp.logic.HigieneSegurancaLogic; import siprp.logic.HigieneSegurancaLogic;
import siprp.logic.node.PostoRelatorioNode; import siprp.logic.node.PostoRelatorioNode;
import com.evolute.utils.error.ErrorLogger;
import com.evolute.utils.images.ImageIconLoader;
import com.evolute.utils.ui.trees.TreeTools; import com.evolute.utils.ui.trees.TreeTools;
public class VerAreasRelatorioPanel extends JPanel public class VerAreasRelatorioPanel extends JPanel
@ -33,6 +40,8 @@ public class VerAreasRelatorioPanel extends JPanel
public static final String SELECTION_CHANGED = "SELECTION_CHANGED"; public static final String SELECTION_CHANGED = "SELECTION_CHANGED";
private final JButton buttonEdit = new JButton( "Editar Nome", ImageIconLoader.loadImageIconSilent( "siprp/higiene/relatorio/edit.png" ) );
private final DefaultMutableTreeNode root = new DefaultMutableTreeNode(); private final DefaultMutableTreeNode root = new DefaultMutableTreeNode();
private final DefaultTreeModel model = new DefaultTreeModel( root ); private final DefaultTreeModel model = new DefaultTreeModel( root );
@ -43,6 +52,8 @@ public class VerAreasRelatorioPanel extends JPanel
private HsRelatorio relatorio = null; private HsRelatorio relatorio = null;
private DefaultMutableTreeNode selectedNode = null;
public VerAreasRelatorioPanel() public VerAreasRelatorioPanel()
{ {
startupComponents(); startupComponents();
@ -53,6 +64,7 @@ public class VerAreasRelatorioPanel extends JPanel
private void startupComponents() private void startupComponents()
{ {
buttonEdit.setEnabled( false );
tree.setRootVisible( false ); tree.setRootVisible( false );
tree.getSelectionModel().setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION ); tree.getSelectionModel().setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION );
tree.setCellRenderer(new DefaultTreeCellRenderer() tree.setCellRenderer(new DefaultTreeCellRenderer()
@ -60,6 +72,7 @@ public class VerAreasRelatorioPanel extends JPanel
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Override
public Component getTreeCellRendererComponent( JTree pTree, Object pValue, boolean pIsSelected, boolean pIsExpanded, boolean pIsLeaf, int pRow, boolean pHasFocus ) public Component getTreeCellRendererComponent( JTree pTree, Object pValue, boolean pIsSelected, boolean pIsExpanded, boolean pIsLeaf, int pRow, boolean pHasFocus )
{ {
super.getTreeCellRendererComponent( pTree, pValue, pIsSelected, pIsExpanded, pIsLeaf, pRow, pHasFocus ); super.getTreeCellRendererComponent( pTree, pValue, pIsSelected, pIsExpanded, pIsLeaf, pRow, pHasFocus );
@ -94,12 +107,13 @@ public class VerAreasRelatorioPanel extends JPanel
return(this); return(this);
} }
} ); } );
TreeTools.registerTreeKeepExpandState( tree );
} }
private void setupLayout() private void setupLayout()
{ {
TableLayout layout = new TableLayout( TableLayout layout = new TableLayout(
new double[]{ TableLayout.FILL }, new double[]{ TableLayout.MINIMUM, TableLayout.FILL },
new double[]{ TableLayout.MINIMUM, TableLayout.FILL } new double[]{ TableLayout.MINIMUM, TableLayout.FILL }
); );
layout.setHGap( 5 ); layout.setHGap( 5 );
@ -109,21 +123,13 @@ public class VerAreasRelatorioPanel extends JPanel
private void placeComponents() private void placeComponents()
{ {
JPanel panel = new JPanel(); add( buttonEdit, new TableLayoutConstraints( 0, 0 ) );
TableLayout layout = new TableLayout( add( scroll, new TableLayoutConstraints( 0, 1, 1, 1 ) );
new double[]{ TableLayout.MINIMUM, TableLayout.FILL, TableLayout.MINIMUM },
new double[]{ TableLayout.MINIMUM }
);
layout.setHGap( 5 );
layout.setVGap( 5 );
panel.setLayout( layout );
add( panel, new TableLayoutConstraints( 0, 0 ) );
add( scroll, new TableLayoutConstraints( 0, 1 ) );
} }
private void startupListeners() private void startupListeners()
{ {
tree.getSelectionModel().addTreeSelectionListener( new TreeSelectionListener(){ tree.getSelectionModel().addTreeSelectionListener( new TreeSelectionListener(){
@Override @Override
public void valueChanged( TreeSelectionEvent e ) public void valueChanged( TreeSelectionEvent e )
@ -131,9 +137,48 @@ public class VerAreasRelatorioPanel extends JPanel
TreePath path = tree.getSelectionPath(); TreePath path = tree.getSelectionPath();
Object object = path == null ? null : path.getLastPathComponent(); Object object = path == null ? null : path.getLastPathComponent();
HsRelatorioPosto posto = object == null ? null : ( (object instanceof PostoRelatorioNode) ? (HsRelatorioPosto) ((PostoRelatorioNode) object).getUserObject() : null); HsRelatorioPosto posto = object == null ? null : ( (object instanceof PostoRelatorioNode) ? (HsRelatorioPosto) ((PostoRelatorioNode) object).getUserObject() : null);
selectedNode = (object instanceof DefaultMutableTreeNode) ? (DefaultMutableTreeNode) object : null;
buttonEdit.setEnabled( selectedNode != null );
firePropertyChange( SELECTION_CHANGED, null, posto ); firePropertyChange( SELECTION_CHANGED, null, posto );
} }
} ); } );
buttonEdit.addActionListener( new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
Object object = selectedNode == null ? null : selectedNode.getUserObject();
if( object != null )
{
String message = "Novo valor";
String title = "Editar nome";
String result = JOptionPane.showInputDialog( VerAreasRelatorioPanel.this, message, title, JOptionPane.QUESTION_MESSAGE );
if( result != null && !result.trim().isEmpty() )
{
try
{
if( object instanceof HsRelatorioArea )
{
((HsRelatorioArea) object).setDescription( result );
((HsRelatorioArea) object).save();
refresh();
}
else if( object instanceof HsRelatorioPosto )
{
((HsRelatorioPosto) object).setDescription( result );
((HsRelatorioPosto) object).save();
refresh();
}
}
catch( Exception ex )
{
ErrorLogger.logException( ex );
}
}
}
}
} );
} }
public void refresh() public void refresh()
@ -146,7 +191,6 @@ public class VerAreasRelatorioPanel extends JPanel
TreeTools.refreshTree( tree, root, false ); TreeTools.refreshTree( tree, root, false );
} }
public void setRelatorio( HsRelatorio relatorio ) public void setRelatorio( HsRelatorio relatorio )
{ {
this.relatorio = relatorio; this.relatorio = relatorio;

Binary file not shown.

After

Width:  |  Height:  |  Size: 928 B

Loading…
Cancel
Save