diff --git a/trunk/siprp/medicina/MedicinaConstants.java b/trunk/siprp/medicina/MedicinaConstants.java index 702d8523..a3f22da9 100644 --- a/trunk/siprp/medicina/MedicinaConstants.java +++ b/trunk/siprp/medicina/MedicinaConstants.java @@ -15,6 +15,9 @@ package siprp.medicina; */ public interface MedicinaConstants { + public static final int TIPO_ECDS = 0; + public static final int TIPO_CONSULTA = 1; + public static final int MOTIVO_ADMISSAO = 1; public static final Integer MOTIVO_ADMISSAO_INTEGER = new Integer( MOTIVO_ADMISSAO ); public static final int MOTIVO_PERIODICO = 2; @@ -24,10 +27,23 @@ public interface MedicinaConstants public static final int MOTIVO_PERIODICO_INICIAL = 5; public static final Integer MOTIVO_PERIODICO_INICIAL_INTEGER = new Integer( MOTIVO_PERIODICO_INICIAL ); - public static final int ESTADO_POR_REALIZAR = 0; - public static final int ESTADO_PARCIALMENTE_REALIZADO = 1; - public static final int ESTADO_REALIZADO = 2; - public static final int ESTADO_DESMARCADO_TRABALHADOR = 3; - public static final int ESTADO_DESMARCADO_EMPRESA = 4; - public static final int ESTADO_FALTOU = 5; + public static final int ESTADO_POR_REALIZAR = 0; + public static final int ESTADO_PARCIALMENTE_REALIZADO = 1; + public static final int ESTADO_REALIZADO = 2; + public static final int ESTADO_DESMARCADO_TRABALHADOR = 3; + public static final int ESTADO_DESMARCADO_EMPRESA = 4; + public static final int ESTADO_FALTOU = 5; + + public static final String ESTADOS_CONSULTA_STR[] = + new String[]{ "Por Realizar", "Parcialmente Realizada", "Realizada", + "Desmarcada pelo Trabalhador", "Desmarcada pela SIPRP", + "Trabalhador Faltou" }; + + public static final String ESTADOS_ECDS_STR[] = + new String[]{ "Por Realizar", "Parcialmente Realizados", "Realizados", + "Desmarcados pelo Trabalhador", "Desmarcados pela SIPRP", + "Trabalhador Faltou" }; + + public static final String ESTADOS_STR[][] = + new String[][]{ ESTADOS_ECDS_STR, ESTADOS_CONSULTA_STR }; } diff --git a/trunk/siprp/medicina/processo/ProcessoController.java b/trunk/siprp/medicina/processo/ProcessoController.java index d6de045a..d49abc0e 100644 --- a/trunk/siprp/medicina/processo/ProcessoController.java +++ b/trunk/siprp/medicina/processo/ProcessoController.java @@ -9,7 +9,7 @@ package siprp.medicina.processo; -import siprp.medicina.processo.data.MarcacoesProcessoData; +import siprp.medicina.processo.data.TrabalhadoresProcessoData; import siprp.medicina.processo.detalhes.DetalhesProcessoPanel; import siprp.medicina.processo.estrutura.EstruturaProcessoPanel; diff --git a/trunk/siprp/medicina/processo/ProcessoDataProvider.java b/trunk/siprp/medicina/processo/ProcessoDataProvider.java index 94831c71..1723747f 100644 --- a/trunk/siprp/medicina/processo/ProcessoDataProvider.java +++ b/trunk/siprp/medicina/processo/ProcessoDataProvider.java @@ -19,7 +19,7 @@ import com.evolute.utils.sql.Field; import com.evolute.utils.sql.Select; import com.evolute.utils.sql.Select2; import java.util.HashMap; -import siprp.medicina.processo.data.MarcacoesProcessoData; +import siprp.medicina.processo.data.TrabalhadoresProcessoData; /** * @@ -95,13 +95,13 @@ public class ProcessoDataProvider return ids; } - public MarcacoesProcessoData getProcessoByID( Integer id ) + public TrabalhadoresProcessoData getProcessoByID( Integer id ) throws Exception { - return ( MarcacoesProcessoData ) JDO.load( MarcacoesProcessoData.class, id ); + return ( TrabalhadoresProcessoData ) JDO.load( TrabalhadoresProcessoData.class, id ); } - public void saveProcesso( MarcacoesProcessoData processo ) + public void saveProcesso( TrabalhadoresProcessoData processo ) throws Exception { processo.save(); diff --git a/trunk/siprp/medicina/processo/ProcessoPanel.java b/trunk/siprp/medicina/processo/ProcessoPanel.java index 03acecaa..e349c612 100644 --- a/trunk/siprp/medicina/processo/ProcessoPanel.java +++ b/trunk/siprp/medicina/processo/ProcessoPanel.java @@ -22,7 +22,7 @@ import java.util.Date; import java.util.Locale; import java.util.Vector; import javax.swing.*; -import siprp.medicina.processo.data.MarcacoesProcessoData; +import siprp.medicina.processo.data.TrabalhadoresProcessoData; /** * @@ -213,19 +213,19 @@ public class ProcessoPanel extends JPanel { try { - MarcacoesProcessoData processo = provider.getProcessoByID( ( Integer ) value ); + TrabalhadoresProcessoData processo = provider.getProcessoByID( ( Integer ) value ); enableButtons( false ); - Date dataInicio = ( Date ) processo.get( MarcacoesProcessoData.DATA_INICIO ); + Date dataInicio = ( Date ) processo.get( TrabalhadoresProcessoData.DATA_INICIO ); if( dataInicio != null ) { inicioText.setText( D_F.format( dataInicio ) ); } - Date dataFim = ( Date ) processo.get( MarcacoesProcessoData.DATA_FIM ); + Date dataFim = ( Date ) processo.get( TrabalhadoresProcessoData.DATA_FIM ); if( dataFim != null ) { fimText.setText( D_F.format( dataFim ) ); } - String estado = ( String ) processo.get( MarcacoesProcessoData.ESTADO ); + String estado = ( String ) processo.get( TrabalhadoresProcessoData.ESTADO ); if( estado == null ) { estadoText.setText( ProcessoDataProvider.PROCESSO_POR_ABRIR_DESCRIPTION ); diff --git a/trunk/siprp/medicina/processo/ProcessoUpperPanel.java b/trunk/siprp/medicina/processo/ProcessoUpperPanel.java new file mode 100644 index 00000000..1c08a592 --- /dev/null +++ b/trunk/siprp/medicina/processo/ProcessoUpperPanel.java @@ -0,0 +1,254 @@ +/* + * ProcessoUpperPanel.java + * + * Created on February 1, 2006, 6:48 PM + * + * To change this template, choose Tools | Template Manager + * and open the template in the editor. + */ + +package siprp.medicina.processo; + +import java.awt.*; +import javax.swing.*; +import javax.swing.event.*; +import java.util.*; +import com.evolute.utils.dataui.*; +import com.evolute.utils.tables.*; +import com.evolute.utils.ui.*; +import siprp.medicina.MedicinaDataProvider; + +/** + * + * @author fpalma + */ +public class ProcessoUpperPanel extends JPanel + implements ListSelectionListener, ControllableComponent +{ + protected BaseTable empresasTable; + protected VectorTableModel empresasModel; + protected BaseTable estabelecimentosTable; + protected VectorTableModel estabelecimentosModel; + protected BaseTable trabalhadoresTable; + protected VectorTableModel trabalhadoresModel; + + protected MedicinaDataProvider provider; + + protected final Vector listeners; + + protected boolean editing = false; + + /** + * Creates a new instance of ProcessoUpperPanel + */ + public ProcessoUpperPanel() + throws Exception + { + provider = ( MedicinaDataProvider ) MedicinaDataProvider.getProvider(); + listeners = new Vector(); + setupComponents(); + } + + private void setupComponents() + throws Exception + { + empresasModel = new VectorTableModel( new String[]{ "empresas" } ); + empresasTable = new BaseTable( empresasModel ); + empresasTable.setSelectionMode( ListSelectionModel.SINGLE_SELECTION ); + empresasTable.setNonResizableNorReordable(); + JScrollPane empresasScroll = + new JScrollPane( empresasTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, + JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); + empresasTable.getSelectionModel().addListSelectionListener( this ); + estabelecimentosModel = new VectorTableModel( new String[]{ "estabelecimentos" } ); + estabelecimentosTable = new BaseTable( estabelecimentosModel ); + estabelecimentosTable.setSelectionMode( ListSelectionModel.SINGLE_SELECTION ); + estabelecimentosTable.setNonResizableNorReordable(); + JScrollPane estabelecimentosScroll = + new JScrollPane( estabelecimentosTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, + JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); + estabelecimentosTable.getSelectionModel().addListSelectionListener( this ); + trabalhadoresModel = new VectorTableModel( new String[]{ "trabalhadores" } ); + trabalhadoresTable = new BaseTable( trabalhadoresModel ); + trabalhadoresTable.setSelectionMode( ListSelectionModel.SINGLE_SELECTION ); + trabalhadoresTable.setNonResizableNorReordable(); + JScrollPane trabalhadoresScroll = + new JScrollPane( trabalhadoresTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, + JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); + trabalhadoresTable.getSelectionModel().addListSelectionListener( this ); + + GridBagLayout gridbag = new GridBagLayout(); + setLayout( gridbag ); + GridBagConstraints constraints = new GridBagConstraints(); + constraints.insets = new Insets( 1, 1, 1, 1 ); + constraints.fill = GridBagConstraints.BOTH; + constraints.gridwidth = 1; + constraints.gridheight = 1; + constraints.weightx = 0.3; + constraints.weighty = 1; + + gridbag.setConstraints( empresasScroll, constraints ); + + gridbag.setConstraints( estabelecimentosScroll, constraints ); + + constraints.weightx = 0.4; + constraints.gridheight = GridBagConstraints.REMAINDER; + gridbag.setConstraints( trabalhadoresScroll, constraints ); + + add( empresasScroll ); + add( estabelecimentosScroll ); + add( trabalhadoresScroll ); + + ColumnizedMappable empresas[] = provider.getAllEmpresas(); + Vector values = empresasModel.getValues(); + values.addAll( Arrays.asList( empresas ) ); + empresasModel.setValues( values ); + } + + public void valueChanged( ListSelectionEvent e ) + { + Object source = e.getSource(); + if( e.getValueIsAdjusting() ) + { + return; + } + if( source.equals( empresasTable.getSelectionModel() ) ) + { + carregarEstabelecimentos(); + } + else if( source.equals( estabelecimentosTable.getSelectionModel() ) ) + { + carregarTrabalhadores(); + } + else if( source.equals( trabalhadoresTable.getSelectionModel() ) ) + { + notifyListeners( e ); + } + } + + protected void carregarEstabelecimentos() + { + estabelecimentosTable.clearSelection(); + int selected = empresasTable.getSelectedRow(); + estabelecimentosModel.clearAll(); + if( selected > -1 ) + { + try + { + Integer empresaID = ( ( ColumnizedMappable ) empresasModel.getRowAt( selected ) ).getID(); + ColumnizedMappable estabelecimentos[] = provider.getAllEstabelecimentosForEmpresa( empresaID); + Vector values = estabelecimentosModel.getValues(); + values.addAll( Arrays.asList( estabelecimentos ) ); + estabelecimentosModel.setValues( values ); + } + catch( Exception ex ) + { + DialogException.showExceptionMessage( ex, "Erro a carregar os estabelecimentos.", true ); + estabelecimentosModel.clearAll(); + } + } + } + + protected void carregarTrabalhadores() + { + trabalhadoresTable.clearSelection(); + int selected = estabelecimentosTable.getSelectedRow(); + trabalhadoresModel.clearAll(); + if( selected > -1 ) + { + try + { + Integer estabelecimentoID = ( ( ColumnizedMappable ) estabelecimentosModel.getRowAt( selected ) ).getID(); + ColumnizedMappable trabalhadores[] = provider.getAllTrabalhadoresForEstabelecimento( estabelecimentoID ); + Vector values = trabalhadoresModel.getValues(); + values.addAll( Arrays.asList( trabalhadores ) ); + trabalhadoresModel.setValues( values ); + } + catch( Exception ex ) + { + DialogException.showExceptionMessage( ex, "Erro a carregar trabalhadores.", true ); + trabalhadoresModel.clearAll(); + } + } + } + + protected void notifyListeners( ListSelectionEvent e ) + { + for( int n = 0; n < listeners.size(); n++ ) + { + ListSelectionEvent event = + new ListSelectionEvent( this, e.getFirstIndex(), e.getLastIndex(), e.getValueIsAdjusting() ); + ( ( ListSelectionListener ) listeners.elementAt( n ) ).valueChanged( event ); + } + } + + public void addListSelectionListener( ListSelectionListener listener ) + { + listeners.add( listener ); + } + + public void removeSelectionListener( ListSelectionListener listener ) + { + listeners.remove( listener ); + } + + public void clear() + { +// empresasTable.clearSelection(); + } + + public void fill( Object value ) + { + if( value == null ) + { + clear(); + } + Integer ids[] = ( Integer [] ) value; + for( int n = 0; n < empresasTable.getRowCount(); n++ ) + { + if( ( ( ColumnizedMappable ) empresasModel.getRowAt( n ) ).getID().equals( ids[ 0 ] ) ) + { + empresasTable.setRowSelectionInterval( n, n ); + break; + } + } + + for( int n = 0; n < estabelecimentosTable.getRowCount(); n++ ) + { + if( ( ( ColumnizedMappable ) estabelecimentosModel.getRowAt( n ) ).getID().equals( ids[ 1 ] ) ) + { + estabelecimentosTable.setRowSelectionInterval( n, n ); + break; + } + } + + for( int n = 0; n < trabalhadoresTable.getRowCount(); n++ ) + { + if( ( ( ColumnizedMappable ) trabalhadoresModel.getRowAt( n ) ).getID().equals( ids[ 2 ] ) ) + { + trabalhadoresTable.setRowSelectionInterval( n, n ); + break; + } + } + } + + public Object save() + { + int empresaSelected = empresasTable.getSelectedRow(); + int estabelecimentoSelected = estabelecimentosTable.getSelectedRow(); + int trabalhadorSelected = trabalhadoresTable.getSelectedRow(); + return new Integer[]{ + empresaSelected == -1 ? null : ( ( ColumnizedMappable ) empresasModel.getRowAt( empresaSelected ) ).getID(), + estabelecimentoSelected == -1 ? null : ( ( ColumnizedMappable ) estabelecimentosModel.getRowAt( estabelecimentoSelected ) ).getID(), + trabalhadorSelected == -1 ? null : ( ( ColumnizedMappable ) trabalhadoresModel.getRowAt( trabalhadorSelected ) ).getID() + }; + } + + public void setEnabled( boolean enable ) + { + editing = !enable; + empresasTable.setEnabled( enable ); + estabelecimentosTable.setEnabled( enable ); + trabalhadoresTable.setEnabled( enable ); + } +} diff --git a/trunk/siprp/medicina/processo/ProcessoWindow.java b/trunk/siprp/medicina/processo/ProcessoWindow.java index 113a445c..3f9a86d3 100644 --- a/trunk/siprp/medicina/processo/ProcessoWindow.java +++ b/trunk/siprp/medicina/processo/ProcessoWindow.java @@ -12,6 +12,7 @@ package siprp.medicina.processo; import com.evolute.utils.tracker.TrackableWindow; import info.clearthought.layout.TableLayout; import info.clearthought.layout.TableLayoutConstraints; +import java.awt.Dimension; import javax.swing.BorderFactory; import javax.swing.JFrame; import javax.swing.JPanel; @@ -27,6 +28,7 @@ public class ProcessoWindow extends JFrame { public static final String TITLE = "Processos de trabalhadores"; + private ProcessoUpperPanel upperPanel; private EstruturaProcessoPanel estruturaPanel; private ProcessoPanel processoPanel; private JPanel detalhesPanel; @@ -41,9 +43,11 @@ public class ProcessoWindow extends JFrame private void setupComponents() throws Exception { - setSize( 1024, 768 ); + setSize( 1024, 700 ); setTitle( TITLE ); + upperPanel = new ProcessoUpperPanel(); + upperPanel.setPreferredSize( new Dimension( 1024, 200 ) ); estruturaPanel = new EstruturaProcessoPanel(); processoPanel = new ProcessoPanel(); processoPanel.setBorder( BorderFactory.createEtchedBorder() ); @@ -52,14 +56,15 @@ public class ProcessoWindow extends JFrame double cols[] = new double[]{ TableLayout.FILL, TableLayout.PREFERRED }; double rows[] = - new double[]{ TableLayout.PREFERRED, TableLayout.FILL }; + new double[]{ TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.FILL }; TableLayout tableLayout = new TableLayout( cols, rows ); setLayout( tableLayout ); - add( estruturaPanel, new TableLayoutConstraints( 0, 0, 0, 1 ) ); - add( processoPanel, new TableLayoutConstraints( 1, 0 ) ); - add( detalhesPanel, new TableLayoutConstraints( 1, 1 ) ); + add( upperPanel, new TableLayoutConstraints( 0, 0, 1, 0 ) ); + add( estruturaPanel, new TableLayoutConstraints( 0, 1, 0, 2 ) ); + add( processoPanel, new TableLayoutConstraints( 1, 1 ) ); + add( detalhesPanel, new TableLayoutConstraints( 1, 2 ) ); } public void refresh() diff --git a/trunk/siprp/medicina/processo/detalhes/ConsultaPanel.java b/trunk/siprp/medicina/processo/detalhes/ConsultaPanel.java index 0154370a..df2f5167 100644 --- a/trunk/siprp/medicina/processo/detalhes/ConsultaPanel.java +++ b/trunk/siprp/medicina/processo/detalhes/ConsultaPanel.java @@ -16,42 +16,27 @@ import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import siprp.medicina.MedicinaConstants; /** * * @author fpalma */ public class ConsultaPanel extends JPanel - implements ActionListener + implements ActionListener, MedicinaConstants, ChangeListener { + protected JFrame owner; protected JCalendarPanel dataConsultaPanel; - protected JToggleButton porRealizarButton; - protected JToggleButton realizadaButton; - protected JToggleButton desmarcadaTrabalhadorButton; - protected JToggleButton desmarcadaSHSTButton; - protected JToggleButton faltouButton; + protected JButton estadoButton; protected JButton emailButton; protected JButton observacoesButton; - public static void main( String args[] ) - throws Exception - { - JFrame frm = new JFrame(); - frm.getContentPane().setLayout( new GridLayout( 1, 1 ) ); - frm.getContentPane().add( new ConsultaPanel() ); - frm.pack(); - frm.addWindowListener( new java.awt.event.WindowAdapter(){ - public void windowClosing( java.awt.event.WindowEvent e ) - { - System.exit( 0 ); - } - } ); - frm.setVisible( true ); - } - /** Creates a new instance of ConsultaPanel */ - public ConsultaPanel() + public ConsultaPanel( JFrame owner ) { + this.owner = owner; setupComponents(); } @@ -59,48 +44,38 @@ public class ConsultaPanel extends JPanel { JLabel dataLabel = new JLabel( "Data" ); dataConsultaPanel = new JCalendarPanel( null ); - ButtonGroup estadoGroup = new ButtonGroup(); - porRealizarButton = new JToggleButton( "Por Realizar" ); - estadoGroup.add( porRealizarButton ); - realizadaButton = new JToggleButton( "Realizada" ); - estadoGroup.add( realizadaButton ); - desmarcadaTrabalhadorButton = new JToggleButton( "Desmarcada pelo Trabalhador" ); - estadoGroup.add( desmarcadaTrabalhadorButton ); - desmarcadaSHSTButton = new JToggleButton( "Desmarcada pela S.I.P.R.P." ); - estadoGroup.add( desmarcadaSHSTButton ); - faltouButton = new JToggleButton( "Faltou" ); - estadoGroup.add( faltouButton ); - JPanel estadoPanel = new JPanel(); + dataConsultaPanel.addChangeListener( this ); + estadoButton = new JButton( " " ); + estadoButton.addActionListener( this ); emailButton = new JButton( "Email" ); + emailButton.addActionListener( this ); observacoesButton = new JButton( "Coment\u00e1rio" ); - - estadoPanel.setLayout( new GridLayout( 5, 1 ) ); - estadoPanel.setBorder( - BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), - "Estado" ) ); - estadoPanel.add( porRealizarButton ); - estadoPanel.add( realizadaButton ); - estadoPanel.add( desmarcadaTrabalhadorButton ); - estadoPanel.add( desmarcadaSHSTButton ); - estadoPanel.add( faltouButton ); + observacoesButton.addActionListener( this ); double cols[] = - new double[]{ TableLayout.MINIMUM, TableLayout.PREFERRED, TableLayout.PREFERRED }; + new double[]{ TableLayout.MINIMUM, TableLayout.FILL }; double rows[] = - new double[]{ TableLayout.MINIMUM, TableLayout.FILL, + new double[]{ TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM }; TableLayout tableLayout = new TableLayout( cols, rows ); + tableLayout.setVGap( 5 ); setLayout( tableLayout ); add( dataLabel, new TableLayoutConstraints( 0, 0 ) ); add( dataConsultaPanel, new TableLayoutConstraints( 1, 0 ) ); - add( estadoPanel, new TableLayoutConstraints( 0, 1, 1, 3 ) ); - add( emailButton, new TableLayoutConstraints( 2, 2 ) ); - add( observacoesButton, new TableLayoutConstraints( 2, 3 ) ); + add( estadoButton, new TableLayoutConstraints( 0, 1, 1, 1 ) ); + add( emailButton, new TableLayoutConstraints( 0, 2, 1, 2 ) ); + add( observacoesButton, new TableLayoutConstraints( 0, 3, 1, 3 ) ); } public void actionPerformed(ActionEvent e) { } + + public void stateChanged(ChangeEvent e) + { + } + + } diff --git a/trunk/siprp/medicina/processo/detalhes/EstadoChooser.java b/trunk/siprp/medicina/processo/detalhes/EstadoChooser.java new file mode 100644 index 00000000..d1d3feb6 --- /dev/null +++ b/trunk/siprp/medicina/processo/detalhes/EstadoChooser.java @@ -0,0 +1,92 @@ +/* + * EstadoChooser.java + * + * Created on 13 de Maio de 2007, 11:54 + * + * To change this template, choose Tools | Template Manager + * and open the template in the editor. + */ + +package siprp.medicina.processo.detalhes; + +import com.evolute.utils.ui.CustomJDialog; +import java.awt.Color; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.HashMap; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.SwingUtilities; +import siprp.medicina.MedicinaConstants; + +/** + * + * @author Frederico + */ +public class EstadoChooser extends CustomJDialog + implements MedicinaConstants, ActionListener +{ + protected int tipo; + protected int estado; + protected HashMap buttonMap; + + /** Creates a new instance of EstadoChooser */ + public EstadoChooser( JFrame owner, int tipo, int estadoActual ) + { + super( owner, true ); + this.tipo = tipo; + estado = estadoActual; + setupComponents(); + + if( owner != null ) + { + centerSuper(); + } + else + { + center(); + } + } + + private void setupComponents() + { + setTitle( "Escolha o novo estado" ); + setLayout( new GridLayout( ESTADOS_STR[ tipo ].length, 1 ) ); + for( int n = 0; n < ESTADOS_STR[ tipo ].length; n++ ) + { + JButton button = new JButton( ESTADOS_STR[ tipo ][ n ] ); + if( n == estado ) + { + button.setForeground( Color.green ); + } + buttonMap.put( button, new Integer( n ) ); + add( button ); + button.addActionListener( this ); + } + pack(); + } + + public void actionPerformed( ActionEvent e ) + { + JButton source = ( JButton ) e.getSource(); + estado = buttonMap.get( source ).intValue(); + close(); + } + + public void close() + { + SwingUtilities.invokeLater( new Runnable(){ + public void run() + { + setVisible( false ); + dispose(); + } + } ); + } + + public int getEstado() + { + return estado; + } +} diff --git a/trunk/siprp/medicina/processo/detalhes/ObservacoesDialog.java b/trunk/siprp/medicina/processo/detalhes/ObservacoesDialog.java new file mode 100644 index 00000000..64e314a9 --- /dev/null +++ b/trunk/siprp/medicina/processo/detalhes/ObservacoesDialog.java @@ -0,0 +1,116 @@ +/* + * ObservacoesDialog.java + * + * Created on 13 de Maio de 2007, 13:13 + * + * To change this template, choose Tools | Template Manager + * and open the template in the editor. + */ + +package siprp.medicina.processo.detalhes; + +import com.evolute.utils.ui.CustomJDialog; +import java.awt.BorderLayout; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; +import javax.swing.SwingUtilities; + +/** + * + * @author Frederico + */ +public class ObservacoesDialog extends CustomJDialog + implements ActionListener +{ + protected JTextArea observacoesText; + protected JButton okButton; + protected JButton cancelButton; + + protected boolean ok = false; + + public static void main( String args[] ) + { + ObservacoesDialog dialog = new ObservacoesDialog( null ); + dialog.editarObservacao( "ISto e a observba" ); + System.exit( 0 ); + } + + /** Creates a new instance of ObservacoesDialog */ + public ObservacoesDialog( JFrame owner ) + { + super( owner, true ); + setupComponents(); + + if( owner != null ) + { + centerSuper(); + } + else + { + center(); + } + } + + private void setupComponents() + { + setTitle( "Coment\u00e1rio" ); + setSize( 400, 200 ); + observacoesText = new JTextArea(); + observacoesText.setLineWrap( true ); + observacoesText.setWrapStyleWord( true ); + JScrollPane scp = new JScrollPane( observacoesText, + JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); + okButton = new JButton( "Ok" ); + okButton.addActionListener( this ); + cancelButton = new JButton( "Cancelar" ); + cancelButton.addActionListener( this ); + JPanel buttonPanel = new JPanel(); + + setLayout( new BorderLayout() ); + add( scp, BorderLayout.CENTER ); + add( buttonPanel, BorderLayout.SOUTH ); + + buttonPanel.setLayout( new GridLayout( 1, 2 ) ); + buttonPanel.add( okButton ); + buttonPanel.add( cancelButton ); + } + + public void actionPerformed( ActionEvent e ) + { + Object source = e.getSource(); + if( source.equals( okButton ) ) + { + ok = true; + close(); + } + else + { + ok = false; + close(); + } + } + + public String editarObservacao( String observacao ) + { + observacoesText.setText( observacao ); + setVisible( true ); + return ok ? observacoesText.getText() : null; + } + + public void close() + { + SwingUtilities.invokeLater( new Runnable(){ + public void run() + { + setVisible( false ); + dispose(); + } + } ); + } +}