From 9eaaca6270d8659d480ee8fddae9b381c8fb9c6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tiago=20Sim=C3=A3o?= Date: Fri, 7 Mar 2008 18:22:19 +0000 Subject: [PATCH] ordenacao na listagem de ECDs por receber git-svn-id: https://svn.coded.pt/svn/SIPRP@712 bb69d46d-e84e-40c8-a05a-06db0d633741 --- .../exames/logic/RecepcaoExamesLogic.java | 3 ++ .../exames/ui/RecepcaoExamesWindow.java | 41 +++++++++++++++++-- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/trunk/SIPRPSoft/src/siprp/medicina/exames/logic/RecepcaoExamesLogic.java b/trunk/SIPRPSoft/src/siprp/medicina/exames/logic/RecepcaoExamesLogic.java index c1a3b672..ee46f546 100644 --- a/trunk/SIPRPSoft/src/siprp/medicina/exames/logic/RecepcaoExamesLogic.java +++ b/trunk/SIPRPSoft/src/siprp/medicina/exames/logic/RecepcaoExamesLogic.java @@ -25,6 +25,9 @@ public class RecepcaoExamesLogic extends LeafLogic @Action(isSave=true) public final static String ACTION_RECEBER_EXAMES = "ACTION_RECEBER_EXAMES"; + @Action(isSave=false) + public final static String ACTION_SORT = "ACTION_SORT"; + public Prestadores currentAnalisador = null; private MedicinaDAO dao = new MedicinaDAO(); diff --git a/trunk/SIPRPSoft/src/siprp/medicina/exames/ui/RecepcaoExamesWindow.java b/trunk/SIPRPSoft/src/siprp/medicina/exames/ui/RecepcaoExamesWindow.java index 1b7e0a5d..973f282d 100644 --- a/trunk/SIPRPSoft/src/siprp/medicina/exames/ui/RecepcaoExamesWindow.java +++ b/trunk/SIPRPSoft/src/siprp/medicina/exames/ui/RecepcaoExamesWindow.java @@ -9,6 +9,7 @@ import java.awt.Dimension; import java.util.ArrayList; import java.util.Collection; import java.util.Date; +import java.util.HashMap; import java.util.List; import javax.swing.JLabel; @@ -38,6 +39,9 @@ public class RecepcaoExamesWindow extends LeafWindow private static final long serialVersionUID = 1L; public static final String TITLE = "Recep" + ccedil + atilde + "o de ECDs"; + + private static final String TRABALHADOR = "Trabalhador"; + private static final String EMPRESA = "Empresa"; public final JLabel labelAnalisador = new JLabel( "Analisador" ); @@ -51,6 +55,10 @@ public class RecepcaoExamesWindow extends LeafWindow public final JLabel labelData = new JLabel( "Data de recep" + ccedil + atilde + "o" ); public final LeafInputField fieldData = new LeafInputField(); + + public final JLabel labelOrder = new JLabel("Ordenar por: "); + @ActionActivation(onSelect="", onChange=RecepcaoExamesLogic.ACTION_SORT) + public final LeafInputField> fieldOrder = new LeafInputField>(); @ActionActivation(onSelect=RecepcaoExamesLogic.ACTION_RECEBER_EXAMES, onChange="") public final LeafButton buttonReceber = new LeafButton( "Receber" ); @@ -73,7 +81,7 @@ public class RecepcaoExamesWindow extends LeafWindow TableLayout.PREFERRED, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.FILL, TableLayout.MINIMUM, TableLayout.PREFERRED }; double[] rows = new double[] { - TableLayout.PREFERRED, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.FILL, TableLayout.PREFERRED + TableLayout.PREFERRED, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.FILL, TableLayout.MINIMUM, TableLayout.PREFERRED }; TableLayout layout = new TableLayout( cols, rows ); layout.setHGap( 5 ); @@ -91,6 +99,13 @@ public class RecepcaoExamesWindow extends LeafWindow examesTable.setSelectionMode( ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); examesTable.setNonResizableNorReordable(); examesScroll = new JScrollPane( examesTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); + examesTable.setAutoCreateRowSorter(true); + + OrderedMap orderOptions = new OrderedMap(); + orderOptions.putLast( EMPRESA, EMPRESA ); + orderOptions.putLast( TRABALHADOR, TRABALHADOR ); + fieldOrder.setObject( orderOptions, EMPRESA ); + fieldOrder.setEditable( true ); } private JPanel createMargin(boolean horizontal, int marginSize) @@ -105,15 +120,17 @@ public class RecepcaoExamesWindow extends LeafWindow private void placeComponents() { pane.add( createMargin(true, 20), new TableLayoutConstraints(0,0,0,5)); - pane.add( createMargin(true, 20), new TableLayoutConstraints(6,0,6,5)); - pane.add( createMargin(false, 20), new TableLayoutConstraints(0,0,6,0)); - pane.add( createMargin(false, 20), new TableLayoutConstraints(0,5,6,5)); + pane.add( createMargin(true, 20), new TableLayoutConstraints(7,0,7,5)); + pane.add( createMargin(false, 20), new TableLayoutConstraints(0,0,7,0)); + pane.add( createMargin(false, 20), new TableLayoutConstraints(0,5,7,5)); pane.add( labelAnalisador, new TableLayoutConstraints( 1, 1, 2, 1 ) ); pane.add( fieldAnalisador, new TableLayoutConstraints( 1, 2, 4, 2 ) ); pane.add( labelData, new TableLayoutConstraints( 1, 3 ) ); pane.add( fieldData, new TableLayoutConstraints( 1, 4, 2, 4 ) ); pane.add( buttonReceber, new TableLayoutConstraints( 4, 4 ) ); pane.add( examesScroll, new TableLayoutConstraints( 1, 5, 4, 5 ) ); + pane.add( labelOrder, new TableLayoutConstraints( 1, 6 ) ); + pane.add( fieldOrder, new TableLayoutConstraints( 2, 6, 3, 6 ) ); } @LeafUIActionBinding(action = RecepcaoExamesLogic.ACTION_FILL_EXAMES) @@ -154,6 +171,22 @@ public class RecepcaoExamesWindow extends LeafWindow } } + @LeafUIActionBinding(action=RecepcaoExamesLogic.ACTION_SORT) + public void sort() + { + Object selected = fieldOrder.getSelectedObject(); + if( selected != null ) + { + if(selected.toString().equals( TRABALHADOR )) + { + examesModel.order( 2, 3 ); + }else + { + examesModel.order( 0, 1, 2, 3 ); + } + } + } + @LeafUIActionBinding(action = RecepcaoExamesLogic.ACTION_SELECT_ANALISADOR) public Prestadores selectAnalisador() {