diff --git a/trunk/SIPRPSoft/lib/evolute.jar b/trunk/SIPRPSoft/lib/evolute.jar index 20967ce9..17c4a395 100644 Binary files a/trunk/SIPRPSoft/lib/evolute.jar and b/trunk/SIPRPSoft/lib/evolute.jar differ diff --git a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/PlanoActuacaoPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/PlanoActuacaoPanel.java index 4dd6390b..c40a16e0 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/PlanoActuacaoPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/PlanoActuacaoPanel.java @@ -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 ) diff --git a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/VerAreasRelatorioPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/VerAreasRelatorioPanel.java index 63b8f654..65dea21f 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/VerAreasRelatorioPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/VerAreasRelatorioPanel.java @@ -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,20 +23,25 @@ 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 { - + private static final long serialVersionUID = 1L; - + 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 ); @@ -40,9 +49,11 @@ public class VerAreasRelatorioPanel extends JPanel public final LeafTree tree = new LeafTree( model ); private final JScrollPane scroll = new JScrollPane( tree ); - + private HsRelatorio relatorio = null; - + + private DefaultMutableTreeNode selectedNode = null; + public VerAreasRelatorioPanel() { startupComponents(); @@ -53,16 +64,18 @@ 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() { 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,31 +123,62 @@ 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 ) { TreePath path = tree.getSelectionPath(); 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 ); } } ); + + 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() @@ -145,8 +190,7 @@ public class VerAreasRelatorioPanel extends JPanel } TreeTools.refreshTree( tree, root, false ); } - - + public void setRelatorio( HsRelatorio relatorio ) { this.relatorio = relatorio; diff --git a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/edit.png b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/edit.png new file mode 100644 index 00000000..ae851759 Binary files /dev/null and b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/edit.png differ