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

@ -5,7 +5,11 @@ import info.clearthought.layout.TableLayoutConstraints;
import java.awt.Color;
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.JScrollPane;
import javax.swing.JTree;
@ -19,11 +23,14 @@ import javax.swing.tree.TreeSelectionModel;
import leaf.ui.LeafTree;
import siprp.database.cayenne.objects.HsRelatorio;
import siprp.database.cayenne.objects.HsRelatorioArea;
import siprp.database.cayenne.objects.HsRelatorioPosto;
import siprp.database.cayenne.objects.HsRelatorioPostoRisco;
import siprp.logic.HigieneSegurancaLogic;
import siprp.logic.node.PostoRelatorioNode;
import com.evolute.utils.error.ErrorLogger;
import com.evolute.utils.images.ImageIconLoader;
import com.evolute.utils.ui.trees.TreeTools;
public class VerAreasRelatorioPanel extends JPanel
@ -33,6 +40,8 @@ public class VerAreasRelatorioPanel extends JPanel
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 DefaultTreeModel model = new DefaultTreeModel( root );
@ -43,6 +52,8 @@ public class VerAreasRelatorioPanel extends JPanel
private HsRelatorio relatorio = null;
private DefaultMutableTreeNode selectedNode = null;
public VerAreasRelatorioPanel()
{
startupComponents();
@ -53,6 +64,7 @@ public class VerAreasRelatorioPanel extends JPanel
private void startupComponents()
{
buttonEdit.setEnabled( false );
tree.setRootVisible( false );
tree.getSelectionModel().setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION );
tree.setCellRenderer(new DefaultTreeCellRenderer()
@ -60,9 +72,10 @@ public class VerAreasRelatorioPanel extends JPanel
private static final long serialVersionUID = 1L;
public Component getTreeCellRendererComponent(JTree pTree, Object pValue, boolean pIsSelected, boolean pIsExpanded, boolean pIsLeaf, int pRow, boolean pHasFocus)
@Override
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 );
boolean highlight= false;
Color highColor = null;
Color lowColor = null;
@ -94,12 +107,13 @@ public class VerAreasRelatorioPanel extends JPanel
return(this);
}
} );
TreeTools.registerTreeKeepExpandState( tree );
}
private void setupLayout()
{
TableLayout layout = new TableLayout(
new double[]{ TableLayout.FILL },
new double[]{ TableLayout.MINIMUM, TableLayout.FILL },
new double[]{ TableLayout.MINIMUM, TableLayout.FILL }
);
layout.setHGap( 5 );
@ -109,21 +123,13 @@ public class VerAreasRelatorioPanel extends JPanel
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 );
add( panel, new TableLayoutConstraints( 0, 0 ) );
add( scroll, new TableLayoutConstraints( 0, 1 ) );
add( buttonEdit, new TableLayoutConstraints( 0, 0 ) );
add( scroll, new TableLayoutConstraints( 0, 1, 1, 1 ) );
}
private void startupListeners()
{
tree.getSelectionModel().addTreeSelectionListener( new TreeSelectionListener(){
@Override
public void valueChanged( TreeSelectionEvent e )
@ -131,9 +137,48 @@ public class VerAreasRelatorioPanel extends JPanel
TreePath path = tree.getSelectionPath();
Object object = path == null ? null : path.getLastPathComponent();
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 );
}
} );
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()
@ -146,7 +191,6 @@ public class VerAreasRelatorioPanel extends JPanel
TreeTools.refreshTree( tree, root, false );
}
public void setRelatorio( HsRelatorio relatorio )
{
this.relatorio = relatorio;

Binary file not shown.

After

Width:  |  Height:  |  Size: 928 B

Loading…
Cancel
Save