diff --git a/trunk/SIPRPSoft/lib/shst.jar b/trunk/SIPRPSoft/lib/shst.jar index ca4e5f7d..4d66b288 100644 Binary files a/trunk/SIPRPSoft/lib/shst.jar and b/trunk/SIPRPSoft/lib/shst.jar differ diff --git a/trunk/SIPRPSoft/src/siprp/SIPRPTracker.java b/trunk/SIPRPSoft/src/siprp/SIPRPTracker.java index 82d43be9..de245dc5 100644 --- a/trunk/SIPRPSoft/src/siprp/SIPRPTracker.java +++ b/trunk/SIPRPSoft/src/siprp/SIPRPTracker.java @@ -15,9 +15,9 @@ import javax.swing.tree.DefaultMutableTreeNode; import shst.SHSTPropertiesConstants; import shst.SHSTTrackerInterface; import shst.cursos.CursosWindowAdapter; -import shst.higiene.mapa.MapaHigieneWindow; import shst.higiene.marcacoes.MarcacoesHigieneInterface; import shst.higiene.marcacoes.MarcacoesHigieneWindow; + import shst.medicina.MedicinaWindowInterface; import shst.medicina.multi.MultiMarcacoesWindow; import siprp.clientes.AvisosPanel; @@ -26,6 +26,7 @@ import siprp.cursos.SIPRPCursosInit; import siprp.estatistica.EstatisticaWindow; import siprp.ficha.FichaWindow; import siprp.higiene.gestao.GestaoRelatorioWindow; +import siprp.higiene.mapa.MapaHigieneWindow; import siprp.higiene.relatorio.RelatorioHigieneSegurancaWindow; import siprp.impressaofichas.ImpressaoFichasWindow; import siprp.lembretes.LembretesWindow; diff --git a/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/CorTecnicoCellRenderer.java b/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/CorTecnicoCellRenderer.java deleted file mode 100644 index ad536467..00000000 --- a/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/CorTecnicoCellRenderer.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * CorTecnicoCellRenderer.java - * - * Created on February 1, 2006, 11:13 PM - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.higiene.marcacoes; - -import java.awt.Color; -import java.awt.Component; - -import javax.swing.JLabel; -import javax.swing.JList; -import javax.swing.ListCellRenderer; - -import siprp.higiene.HigieneDataProvider; - -/** - * - * @author fpalma - */ -public class CorTecnicoCellRenderer extends JLabel implements ListCellRenderer -{ - - public CorTecnicoCellRenderer() - { - setOpaque(true); - } - - public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) - { - setText( " " ); - Color color = HigieneDataProvider.CORES_TECNICOS[ ( ( Integer ) value ).intValue() ]; - if( cellHasFocus ) - { - color = color.darker().darker(); - } - setBackground( color ); - - return this; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/MarcacaoVisitaHSTPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/MarcacaoVisitaHSTPanel.java deleted file mode 100644 index 15d0a55b..00000000 --- a/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/MarcacaoVisitaHSTPanel.java +++ /dev/null @@ -1,353 +0,0 @@ -package siprp.higiene.marcacoes; - -import info.clearthought.layout.TableLayout; -import info.clearthought.layout.TableLayoutConstraints; - -import java.awt.BorderLayout; - -import javax.swing.BorderFactory; -import javax.swing.JButton; -import javax.swing.JComboBox; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JScrollPane; - -import siprp.data.outer.MarcacoesEstabelecimentoData; - -import com.evolute.swing.component.EvoDatePicker; -import com.evolute.utils.Singleton; -import com.evolute.utils.data.IDObject; -import com.evolute.utils.data.MappableObject; -import com.evolute.utils.dataui.ComponentController; -import com.evolute.utils.dataui.ComponentsHashtable; -import com.evolute.utils.dataui.DataClassAware; -import com.evolute.utils.db.DBManager; -import com.evolute.utils.db.SQLExecuter; -import com.evolute.utils.ui.panel.RadioButtonFixedPanel; -import com.evolute.utils.ui.text.StateTextArea; - -public class MarcacaoVisitaHSTPanel extends JPanel implements DataClassAware -{ - - private static final long serialVersionUID = 1L; - private MarcacoesEstabelecimentoData marcacaoEstabelecimentosData; - private final ComponentsHashtable components = new ComponentsHashtable(); - - protected final SQLExecuter EXECUTER; - - private final JLabel dataLabel = new JLabel( "Data da visita", JLabel.RIGHT ); - private final EvoDatePicker dataPanel = new EvoDatePicker(); - private final JButton emailButton = new JButton( "Enviar Email" ); - private final JLabel dataFichaLabel = new JLabel( "Data do Relat\u00f3rio(externo)", JLabel.RIGHT ); - private final EvoDatePicker dataFichaPanel = new EvoDatePicker(); - private final JLabel tecnicoLabel = new JLabel( "T\u00e9cnico", JLabel.RIGHT ); - private final JLabel tecnicoSuperiorLabel = new JLabel( "T\u00e9cnico Superior", JLabel.RIGHT ); - private final JComboBox tecnicoList = new JComboBox(); - private final JComboBox tecnicoSuperiorList = new JComboBox(); - private RadioButtonFixedPanel estadoList; - private final JScrollPane observacoesTextScroll = new JScrollPane(); - private final StateTextArea observacoesText = new StateTextArea(); - - public MarcacaoVisitaHSTPanel() - throws Exception - { - DBManager dbm = ( DBManager )Singleton.getInstance( Singleton.DEFAULT_DBMANAGER ); - if( dbm != null ) - { - EXECUTER = ( SQLExecuter )dbm.getSharedExecuter( this ); - } - else - { - EXECUTER = null; - } - setupComponents(); - setupComponentsHashtable(); - place(); - } - - public void setupComponents() - throws Exception - { -// emailButton.setMinimumSize( new Dimension( 300, 20 ) ); -// emailButton.setPreferredSize( new Dimension( 200, 20 ) ); - - tecnicoList.addItem( new MappableObject( new Integer( -1 ), "" ) ); - tecnicoList.setSelectedIndex( 0 ); - - tecnicoSuperiorList.addItem( new MappableObject( new Integer( -1 ), "" ) ); - tecnicoSuperiorList.setSelectedIndex( 0 ); - - IDObject estadoListOptions[] = new IDObject[]{ - new MappableObject( new Integer( 0 ), "Por realizar" ), - new MappableObject( new Integer( 2 ), "Realizada" ), - new MappableObject( new Integer( 3 ), "Desmarcada pela empresa" ), - new MappableObject( new Integer( 4 ), "Desmarcada pela SIPRP" ), - }; - estadoList = new RadioButtonFixedPanel( estadoListOptions, 6, 1, RadioButtonFixedPanel.ORIENTATION_VERTICAL, false, null ); - estadoList.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Estado" ) ); - - observacoesText.setLineWrap( true ); - observacoesText.setWrapStyleWord( true ); - observacoesText.setRows( 5 ); - - observacoesTextScroll.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); - observacoesTextScroll.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED ); - observacoesTextScroll.setViewportView( observacoesText ); - - } - - public void place() - { - TableLayout layout = new TableLayout( - new double[]{ TableLayout.FILL, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.FILL }, - new double[]{ TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM, - TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM, - TableLayout.PREFERRED} - ); - layout.setHGap(5); - layout.setVGap(5); - this.setLayout( layout ); - this.add( dataLabel, new TableLayoutConstraints(1,0) ); - this.add( dataPanel, new TableLayoutConstraints(2,0) ); - this.add( emailButton, new TableLayoutConstraints(2,1) ); - this.add( dataFichaLabel, new TableLayoutConstraints(1,2) ); - this.add( dataFichaPanel, new TableLayoutConstraints(2,2) ); - this.add( tecnicoLabel, new TableLayoutConstraints(1,3) ); - this.add( tecnicoList, new TableLayoutConstraints(2,3) ); - this.add( tecnicoSuperiorLabel, new TableLayoutConstraints(1,4) ); - this.add( tecnicoSuperiorList, new TableLayoutConstraints(2,4) ); - this.add( estadoList, new TableLayoutConstraints(1,5,2,5) ); - JPanel panel = new JPanel( new BorderLayout() ); - panel.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Observa\u00e7\u00f5es" ) ); - panel.add( observacoesTextScroll ); - this.add( panel, new TableLayoutConstraints(1,6,2,6) ); -// -// JPanel MarcacaoVisitaHSTPanel = this; -// GridBagConstraints MarcacaoVisitaHSTPanelGBC = new GridBagConstraints(); -// MarcacaoVisitaHSTPanelGBC.insets = new Insets( 1, 1, 1, 1 ); -// GridBagLayout MarcacaoVisitaHSTPanelLayout = new GridBagLayout(); -// MarcacaoVisitaHSTPanel.setLayout( MarcacaoVisitaHSTPanelLayout ); -// MarcacaoVisitaHSTPanelGBC.gridx = 0; -// MarcacaoVisitaHSTPanelGBC.gridy = 0; -// MarcacaoVisitaHSTPanelGBC.gridwidth = 1; -// MarcacaoVisitaHSTPanelGBC.gridheight = 1; -// MarcacaoVisitaHSTPanelGBC.weightx = 0.0; -// MarcacaoVisitaHSTPanelGBC.weighty = 0.0; -// MarcacaoVisitaHSTPanelGBC.fill = GridBagConstraints.HORIZONTAL; -// MarcacaoVisitaHSTPanelLayout.setConstraints( dataLabel, MarcacaoVisitaHSTPanelGBC ); -// MarcacaoVisitaHSTPanel.add( dataLabel ); -// -// MarcacaoVisitaHSTPanelGBC.gridx = 1; -// MarcacaoVisitaHSTPanelGBC.gridy = 0; -// MarcacaoVisitaHSTPanelGBC.gridwidth = 1; -// MarcacaoVisitaHSTPanelGBC.gridheight = 1; -// MarcacaoVisitaHSTPanelGBC.weightx = 0.5; -// MarcacaoVisitaHSTPanelGBC.weighty = 0.0; -// MarcacaoVisitaHSTPanelGBC.fill = GridBagConstraints.HORIZONTAL; -// MarcacaoVisitaHSTPanelLayout.setConstraints( dataPanel, MarcacaoVisitaHSTPanelGBC ); -// MarcacaoVisitaHSTPanel.add( dataPanel ); -// -// MarcacaoVisitaHSTPanelGBC.gridx = 2; -// MarcacaoVisitaHSTPanelGBC.gridy = 0; -// MarcacaoVisitaHSTPanelGBC.gridwidth = 1; -// MarcacaoVisitaHSTPanelGBC.gridheight = 1; -// MarcacaoVisitaHSTPanelGBC.weightx = 0.5; -// MarcacaoVisitaHSTPanelGBC.weighty = 0.0; -// MarcacaoVisitaHSTPanelGBC.fill = GridBagConstraints.NONE; -// MarcacaoVisitaHSTPanelLayout.setConstraints( emailButton, MarcacaoVisitaHSTPanelGBC ); -// MarcacaoVisitaHSTPanel.add( emailButton ); -// -// MarcacaoVisitaHSTPanelGBC.gridx = 0; -// MarcacaoVisitaHSTPanelGBC.gridy = 1; -// MarcacaoVisitaHSTPanelGBC.gridwidth = 1; -// MarcacaoVisitaHSTPanelGBC.gridheight = 1; -// MarcacaoVisitaHSTPanelGBC.weightx = 0.0; -// MarcacaoVisitaHSTPanelGBC.weighty = 0.0; -// MarcacaoVisitaHSTPanelGBC.fill = GridBagConstraints.HORIZONTAL; -// MarcacaoVisitaHSTPanelLayout.setConstraints( dataFichaLabel, MarcacaoVisitaHSTPanelGBC ); -// MarcacaoVisitaHSTPanel.add( dataFichaLabel ); -// -// MarcacaoVisitaHSTPanelGBC.gridx = 1; -// MarcacaoVisitaHSTPanelGBC.gridy = 1; -// MarcacaoVisitaHSTPanelGBC.gridwidth = 1; -// MarcacaoVisitaHSTPanelGBC.gridheight = 1; -// MarcacaoVisitaHSTPanelGBC.weightx = 0.5; -// MarcacaoVisitaHSTPanelGBC.weighty = 0.0; -// MarcacaoVisitaHSTPanelGBC.fill = GridBagConstraints.HORIZONTAL; -// MarcacaoVisitaHSTPanelLayout.setConstraints( dataFichaPanel, MarcacaoVisitaHSTPanelGBC ); -// MarcacaoVisitaHSTPanel.add( dataFichaPanel ); -// -// MarcacaoVisitaHSTPanelGBC.gridx = 0; -// MarcacaoVisitaHSTPanelGBC.gridy = 2; -// MarcacaoVisitaHSTPanelGBC.gridwidth = 1; -// MarcacaoVisitaHSTPanelGBC.gridheight = 1; -// MarcacaoVisitaHSTPanelGBC.weightx = 0.0; -// MarcacaoVisitaHSTPanelGBC.weighty = 0.0; -// MarcacaoVisitaHSTPanelGBC.fill = GridBagConstraints.HORIZONTAL; -// MarcacaoVisitaHSTPanelLayout.setConstraints( tecnicoLabel, MarcacaoVisitaHSTPanelGBC ); -// MarcacaoVisitaHSTPanel.add( tecnicoLabel ); -// -// MarcacaoVisitaHSTPanelGBC.gridx = 1; -// MarcacaoVisitaHSTPanelGBC.gridy = 2; -// MarcacaoVisitaHSTPanelGBC.gridwidth = 1; -// MarcacaoVisitaHSTPanelGBC.gridheight = 1; -// MarcacaoVisitaHSTPanelGBC.weightx = 0.5; -// MarcacaoVisitaHSTPanelGBC.weighty = 0.0; -// MarcacaoVisitaHSTPanelGBC.fill = GridBagConstraints.HORIZONTAL; -// MarcacaoVisitaHSTPanelLayout.setConstraints( tecnicoList, MarcacaoVisitaHSTPanelGBC ); -// MarcacaoVisitaHSTPanel.add( tecnicoList ); -// -// MarcacaoVisitaHSTPanelGBC.gridx = 0; -// MarcacaoVisitaHSTPanelGBC.gridy = 3; -// MarcacaoVisitaHSTPanelGBC.gridwidth = 3; -// MarcacaoVisitaHSTPanelGBC.gridheight = 1; -// MarcacaoVisitaHSTPanelGBC.weightx = 1.0; -// MarcacaoVisitaHSTPanelGBC.weighty = 0.5; -// MarcacaoVisitaHSTPanelGBC.fill = GridBagConstraints.BOTH; -// MarcacaoVisitaHSTPanelLayout.setConstraints( estadoList, MarcacaoVisitaHSTPanelGBC ); -// MarcacaoVisitaHSTPanel.add( estadoList ); -// -// MarcacaoVisitaHSTPanelGBC.gridx = 0; -// MarcacaoVisitaHSTPanelGBC.gridy = 4; -// MarcacaoVisitaHSTPanelGBC.gridwidth = 3; -// MarcacaoVisitaHSTPanelGBC.gridheight = 1; -// MarcacaoVisitaHSTPanelGBC.weightx = 1.0; -// MarcacaoVisitaHSTPanelGBC.weighty = 0.5; -// -// MarcacaoVisitaHSTPanelGBC.fill = GridBagConstraints.BOTH; -// MarcacaoVisitaHSTPanelLayout.setConstraints( observacoesTextScroll, MarcacaoVisitaHSTPanelGBC ); -// MarcacaoVisitaHSTPanel.add( observacoesTextScroll ); - } - - private void setupComponentsHashtable() - { - components.putComponent( MarcacoesEstabelecimentoData.DATA, dataPanel ); - components.putComponent( MarcacoesEstabelecimentoData.DATA_RELATORIO, dataFichaPanel ); - components.putComponent( MarcacoesEstabelecimentoData.TECNICO_HST, tecnicoList ); - components.putComponent( MarcacoesEstabelecimentoData.TECNICO_SUPERIOR_HST, tecnicoSuperiorList ); - components.putComponent( MarcacoesEstabelecimentoData.ESTADO, estadoList ); - components.putComponent( MarcacoesEstabelecimentoData.OBSERVACOES, observacoesText ); - } - - @Override - public void fill( MarcacoesEstabelecimentoData toFill ) - { - marcacaoEstabelecimentosData = toFill; -// if( toFill == null || !( toFill instanceof PropertyObject ) ) -// { -// return; -// } -// Map data = null; -// if( toFill instanceof PropertyObject ) -// { -// data = ( (PropertyObject) toFill ).getHashData(); -// if( toFill instanceof MarcacoesEstabelecimentoData ) -// { -// marcacaoEstabelecimentosData = (MarcacoesEstabelecimentoData) toFill; -// } -// } -// else if( toFill instanceof Hashtable ) -// { -// data = (Hashtable) toFill; -// } -// else -// { -// return; -// } -// if( marcacaoEstabelecimentosData == null ) -// { -// clear(); -// marcacaoEstabelecimentosData = new MarcacoesEstabelecimentoData(); -// marcacaoEstabelecimentosData.setHashData( data ); -// } -// PropertyObject po = (PropertyObject) toFill; -// String properties[] = (String[]) components.keySet().toArray( new String[ 0 ] ); - ComponentController.fillFrom( marcacaoEstabelecimentosData, components ); - } - - @Override - public MarcacoesEstabelecimentoData save() - { - if( marcacaoEstabelecimentosData == null ) - { - marcacaoEstabelecimentosData = new MarcacoesEstabelecimentoData(); - } -// marcacaoEstabelecimentosData.setHashData( ComponentController.save( components ) ); -// if( !( marcacaoEstabelecimentosData instanceof PropertyObject ) ) -// { -// return marcacaoEstabelecimentosData; -// } - return ComponentController.saveTo( marcacaoEstabelecimentosData, components ); -// marcacaoEstabelecimentosData.setHashData( data ); -// return marcacaoEstabelecimentosData; - } - - public void clear() - { - marcacaoEstabelecimentosData = null; - String properties[] = (String[]) components.keySet().toArray( new String[ 0 ] ); - ComponentController.clear( properties, components ); - } - - public void setEnabled( boolean enable ) - { - String properties[] = (String[]) components.keySet().toArray( new String[ 0 ] ); - ComponentController.setEnabled( properties, enable, components ); - } - - public Class getDataClass() - { - return MarcacoesEstabelecimentoData.class; - } - - public JLabel getDataFichaLabel() - { - return dataFichaLabel; - } - - public EvoDatePicker getDataFichaPanel() - { - return dataFichaPanel; - } - - public JLabel getDataLabel() - { - return dataLabel; - } - - public EvoDatePicker getDataPanel() - { - return dataPanel; - } - - public JButton getEmailButton() - { - return emailButton; - } - - public RadioButtonFixedPanel getEstadoList() - { - return estadoList; - } - - public StateTextArea getObservacoesText() - { - return observacoesText; - } - - public JLabel getTecnicoLabel() - { - return tecnicoLabel; - } - - public JComboBox getTecnicoList() - { - return tecnicoList; - } - - public JComboBox getTecnicoSuperiorList() - { - return tecnicoSuperiorList; - } - -} diff --git a/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/MarcacaoVisitaHSTPanel.xml b/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/MarcacaoVisitaHSTPanel.xml deleted file mode 100644 index 04a78a45..00000000 --- a/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/MarcacaoVisitaHSTPanel.xml +++ /dev/null @@ -1,93 +0,0 @@ - - - - - - - siprp.data.* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1 - - - - - - - - Estado - - 6 - - - Por realizar - Realizada - Desmarcada pela empresa - Desmarcada pela SIPRP - - - - - - Observa\u00e7\u00f5es - - - 5 - - - - diff --git a/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/MarcacoesHigieneUpperPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/MarcacoesHigieneUpperPanel.java deleted file mode 100644 index 64c9c2d1..00000000 --- a/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/MarcacoesHigieneUpperPanel.java +++ /dev/null @@ -1,207 +0,0 @@ -/* - * MarcacoesHigieneUpperPanel.java - * - * Created on February 2, 2006, 12:40 AM - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.higiene.marcacoes; - -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.util.Arrays; -import java.util.Vector; - -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.ListSelectionModel; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; - -import siprp.higiene.HigieneDataProvider; - -import com.evolute.utils.dataui.ControllableComponent; -import com.evolute.utils.tables.BaseTable; -import com.evolute.utils.tables.ColumnizedMappable; -import com.evolute.utils.tables.VectorTableModel; -import com.evolute.utils.ui.DialogException; - -/** - * - * @author fpalma - */ -public class MarcacoesHigieneUpperPanel extends JPanel - implements ListSelectionListener, ControllableComponent -{ - protected BaseTable empresasTable; - protected VectorTableModel empresasModel; - protected BaseTable estabelecimentosTable; - protected VectorTableModel estabelecimentosModel; - - protected HigieneDataProvider provider; - - protected final Vector listeners; - - /** Creates a new instance of MedicinaUpperPanel */ - public MarcacoesHigieneUpperPanel() - throws Exception - { - provider = ( HigieneDataProvider ) HigieneDataProvider.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 ); - - 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 = GridBagConstraints.REMAINDER; - constraints.weightx = 0.5; - constraints.weighty = 1; - - gridbag.setConstraints( empresasScroll, constraints ); - - constraints.gridwidth = GridBagConstraints.REMAINDER; - gridbag.setConstraints( estabelecimentosScroll, constraints ); - - add( empresasScroll ); - add( estabelecimentosScroll ); - - 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() ) ) - { - 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 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; - } - } - } - - public Object save() - { - int empresaSelected = empresasTable.getSelectedRow(); - int estabelecimentoSelected = estabelecimentosTable.getSelectedRow(); - return new Integer[]{ - empresaSelected == -1 ? null : ( ( ColumnizedMappable ) empresasModel.getRowAt( empresaSelected ) ).getID(), - estabelecimentoSelected == -1 ? null : ( ( ColumnizedMappable ) estabelecimentosModel.getRowAt( estabelecimentoSelected ) ).getID() - }; - } - - public void setEnabled( boolean enable ) - { - empresasTable.setEnabled( enable ); - estabelecimentosTable.setEnabled( enable ); - } -} diff --git a/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/MarcacoesHigieneWindow.java b/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/MarcacoesHigieneWindow.java deleted file mode 100644 index 5281d1f3..00000000 --- a/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/MarcacoesHigieneWindow.java +++ /dev/null @@ -1,572 +0,0 @@ -/* - * MarcacoesHigieneWindow.java - * - * Created on January 31, 2006, 11:32 PM - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.higiene.marcacoes; - -import java.awt.Dimension; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.text.DateFormat; -import java.util.Date; -import java.util.Hashtable; -import java.util.Locale; - -import javax.swing.JComboBox; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; - -import shst.SHSTTrackerInterface; -import shst.higiene.marcacoes.MarcacoesHigieneInterface; -import siprp.SingletonConstants; -import siprp.clientes.AvisosPanel; -import siprp.companydataloaders.CompanyDataLoader; -import siprp.data.AvisoConstants; -import siprp.data.Marcacao; -import siprp.data.outer.ContactosData; -import siprp.data.outer.EstabelecimentosData; -import siprp.data.outer.MarcacoesEstabelecimentoData; -import siprp.higiene.HigieneDataProvider; -import siprp.ui.SIPRPEditorWindow; - -import com.evolute.entity.ProviderInterface; -import com.evolute.utils.Singleton; -import com.evolute.utils.arrays.Object2DArray; -import com.evolute.utils.data.MappableObject; -import com.evolute.utils.ui.DialogException; -import com.evolute.utils.ui.panel.TableEditorPanel; -import com.evolute.utils.ui.text.CopyPasteHandler; - -/** - * - * @author fpalma - */ -public class MarcacoesHigieneWindow extends SIPRPEditorWindow - implements ItemListener, ActionListener, ListSelectionListener, MarcacoesHigieneInterface -{ - - private static final long serialVersionUID = 1L; - - public final static String TITLE = "Marca\u00e7\u00f5es de Higiene e Seguran\u00e7a"; - - private final static int iPermissionArray[][] = - new int[][]{ {}, { NEW_INDEX, EDIT_INDEX, CANCEL_INDEX, SAVE_INDEX, DELETE_INDEX } }; - - private static final int INDEX_MAIN = 0; - private static final int INDEX_VISITA = 1; - - private static final DateFormat DATE_FORMAT = - DateFormat.getDateInstance( DateFormat.SHORT, new Locale( "PT", "pt" ) ); - - protected MarcacoesHigieneUpperPanel upperPanel; - protected MarcacaoVisitaHSTPanel marcacaoPanel; - protected TableEditorPanel marcacaoEditorPanel; - - protected HigieneDataProvider higieneProvider; - protected ProviderInterface objectProvider; - protected SHSTTrackerInterface tracker; - - private Hashtable tecnicosHash; - - private Integer empresaID; -// protected String empresa; - private Integer estabelecimentoID; - private EstabelecimentosData estabelecimento; - - protected boolean editing = false; - - /** Creates a new instance of MarcacoesHigieneWindow */ - public MarcacoesHigieneWindow() - throws Exception - { - super( iPermissionArray ); - - this.higieneProvider = ( HigieneDataProvider ) HigieneDataProvider.getProvider(); - this.objectProvider = ( ProviderInterface ) Singleton.getInstance( Singleton.DEFAULT_OBJECT_PROVIDER ); - - this.tecnicosHash = new Hashtable(); - this.setupComponents(); - this.setSize( 800, 700 ); - this.setLocationRelativeTo(null); - this.setExtendedState( getExtendedState() | MAXIMIZED_BOTH ); - } - - private void setupComponents() - throws Exception - { - setTitle( TITLE ); - upperPanel = new MarcacoesHigieneUpperPanel(); - JPanel panel = new JPanel(); - - GridBagLayout gridbag = new GridBagLayout(); - GridBagConstraints constraints = new GridBagConstraints(); - getContentPane().setLayout( gridbag ); - constraints.insets = new Insets( 2, 2, 2, 2 ); - constraints.fill = GridBagConstraints.BOTH; - constraints.gridwidth = GridBagConstraints.REMAINDER; - constraints.weightx = 1; - constraints.gridheight = 1; - - constraints.weighty = 1; - gridbag.setConstraints( upperPanel, constraints ); - - constraints.weighty = 0; - gridbag.setConstraints( panel, constraints ); - - getContentPane().add( upperPanel ); - getContentPane().add( panel ); - - changeGroupName( INDEX_VISITA, "Visitas" ); - setActionName( INDEX_VISITA, NEW_INDEX, "Nova" ); - setActionTooltip( INDEX_VISITA, NEW_INDEX, "Nova" ); - JPanel toolbar = getToolbarPanel( INDEX_VISITA ); - - gridbag = new GridBagLayout(); -// GridBagConstraints constraints = new GridBagConstraints(); - panel.setLayout( gridbag ); - constraints.insets = new Insets( 2, 2, 2, 2 ); - constraints.fill = GridBagConstraints.BOTH; - constraints.gridwidth = GridBagConstraints.REMAINDER; - constraints.weightx = 1.0; - constraints.weighty = 0; - - gridbag.setConstraints( toolbar, constraints ); - panel.add( toolbar ); - - constraints.gridheight = 1; - constraints.weighty = 0; - try - { - marcacaoEditorPanel = - new TableEditorPanel( new String[]{ "Data", - "Estado" }, - new int[]{0,2}, new int[]{0,0}, - 0.0, 1.0, new Dimension( 350, 100 ) ); - marcacaoPanel = new MarcacaoVisitaHSTPanel(); - new CopyPasteHandler( marcacaoPanel.getObservacoesText() ); - marcacaoEditorPanel.addComponent( marcacaoPanel, - new int[]{0,2}, new int[]{1,2}, - 1.0, 1.0 ); - marcacaoEditorPanel.addListSelectionListener( new ListSelectionListener() - { - @Override - public void valueChanged(javax.swing.event.ListSelectionEvent listSelectionEvent) - { - if( marcacaoEditorPanel.getID() != null ) - { - reload(INDEX_VISITA); - select(INDEX_VISITA); - } - else - { - clear( INDEX_VISITA ); - } - } - } ); - } - catch( Exception ex ) - { - DialogException.showException( ex ); - return; - } - gridbag.setConstraints( marcacaoEditorPanel, constraints ); - panel.add( marcacaoEditorPanel ); - marcacaoPanel.getEmailButton().addActionListener( this ); - - fillCombos(); - upperPanel.addListSelectionListener( this ); - } - - public void fillCombos() - throws Exception - { - JComboBox tecnicosList = marcacaoPanel.getTecnicoList(); - JComboBox tecnicosSuperioresList = marcacaoPanel.getTecnicoSuperiorList(); - tecnicosHash.clear(); - tecnicosList.removeItemListener( this ); - tecnicosSuperioresList.removeItemListener( this ); - fillTecnicos(tecnicosList,false); - fillTecnicos(tecnicosSuperioresList,true); - tecnicosList.addItemListener( this ); - tecnicosSuperioresList.addItemListener( this ); - } - - private void fillTecnicos( JComboBox tecnicosList, boolean superiores ) throws Exception - { - tecnicosList.removeAllItems(); - Object tecnicos[][] = higieneProvider.getTecnicosHST( superiores ); - tecnicosList.addItem( new MappableObject( new Integer( -2 ), " " ) ); - for( int n = 0; n < tecnicos.length; n++ ) - { - Object tecnico[] = new Object[ 4 ]; - tecnico[ 0 ] = new Integer( ( (Number)tecnicos[n][0] ).intValue() ); - tecnico[ 1 ] = tecnicos[ n ][ 1 ]; - tecnico[ 2 ] = tecnicos[ n ][ 2 ]; - tecnico[ 3 ] = new Integer( n ); - tecnicosHash.put( tecnicos[ n ][ 0 ], tecnico ); - tecnicosList.addItem( new MappableObject( (Integer) tecnico[ 0 ], tecnico[ 1 ] ) ); - } - tecnicosList.setSelectedIndex( 0 ); - - tecnicosList.addItem( new MappableObject( new Integer( -1 ), "Novo/Editar" ) ); - } - - @Override - public void itemStateChanged( ItemEvent itemEvent ) - { - JComboBox tecnicos = null; - if( itemEvent.getSource().equals( marcacaoPanel.getTecnicoList() ) ) - { - tecnicos = marcacaoPanel.getTecnicoList(); - } - else if( itemEvent.getSource().equals( marcacaoPanel.getTecnicoSuperiorList() ) ) - { - tecnicos = marcacaoPanel.getTecnicoSuperiorList(); - } - if( tecnicos != null && itemEvent.getStateChange() == ItemEvent.SELECTED ) - { - int index = tecnicos.getSelectedIndex(); - if( index == tecnicos.getItemCount() - 1 ) - { - try - { - TecnicoEditor te = new TecnicoEditor( this ); - te.setVisible( true ); - Integer id = te.getID(); - if( id == null ) - { - tecnicos.setSelectedIndex( 0 ); - } - else - { - fillCombos(); - if( id != null ) - { - Object[] tecnico = tecnicosHash.get( id ); - tecnicos.setSelectedIndex( ( (Integer)tecnico[ 3 ] ).intValue() + 1 ); - } - } - - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro na janela de edi\u00e7\u00e3o...", true ); - ex.printStackTrace(); - tecnicos.setSelectedIndex( 0 ); - return; - } - } - } - } - - @Override - public boolean save(int index) - { - switch( index ) - { - case INDEX_VISITA: - MarcacoesEstabelecimentoData visita = ( MarcacoesEstabelecimentoData ) marcacaoPanel.save(); - Date data = ( Date ) visita.get( MarcacoesEstabelecimentoData.DATA ); - if( data == null ) - { - JOptionPane.showMessageDialog( this, "Tem de preencher uma data para a visita.", - "Erro", JOptionPane.ERROR_MESSAGE ); - return false; - } - visita.setToEstabelecimento_id( estabelecimento ); - try - { - visita.set( MarcacoesEstabelecimentoData.REALIZADA, - ( ( Integer )visita.get( MarcacoesEstabelecimentoData.ESTADO ) ).intValue() == - HigieneDataProvider.ESTADO_REALIZADO ? "y" : "n" ); - System.out.println( "DATA " + visita.get( MarcacoesEstabelecimentoData.DATA ) ); - Integer tecnico = ( Integer ) visita.get( MarcacoesEstabelecimentoData.TECNICO_HST ); - if( tecnico != null && tecnico.intValue() < 0 ) - { - visita.set( MarcacoesEstabelecimentoData.TECNICO_HST, null ); - } - Integer tecnicoSup = ( Integer ) visita.get( MarcacoesEstabelecimentoData.TECNICO_SUPERIOR_HST ); - if( tecnicoSup != null && tecnicoSup.intValue() < 0 ) - { - visita.set( MarcacoesEstabelecimentoData.TECNICO_SUPERIOR_HST, null ); - } - visita.save(); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a gravar", true ); - return false; - } - - break; - } - reload( INDEX_MAIN ); - editing = false; - return true; - } - - @Override - public boolean delete(int index) - { - int option = JOptionPane.showConfirmDialog( this, "Tem a certeza que quer apagar a marca\u00e7\u00e3o?", - "Apagar", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE ); - if( option == JOptionPane.OK_OPTION ) - { - switch( index ) - { - case INDEX_VISITA: - MarcacoesEstabelecimentoData visita = ( MarcacoesEstabelecimentoData ) marcacaoPanel.save(); - try - { - visita.delete(); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a apagar.", true ); - return false; - } - break; - } - reload( INDEX_MAIN ); - return true; - } - return false; - } - - @Override - public void clear(int index) - { - switch( index ) - { - case INDEX_MAIN: - empresaID = null; - estabelecimentoID = null; - estabelecimento = null; - upperPanel.clear(); - marcacaoEditorPanel.clear(); - break; - - case INDEX_VISITA: - marcacaoPanel.clear(); - marcacaoPanel.getEmailButton().setText( "Enviar email" ); - break; - } - } - - public void enableComponents(int index, boolean enable) - { - switch( index ) - { - case INDEX_MAIN: - - break; - - case INDEX_VISITA: - marcacaoPanel.setEnabled( enable ); - marcacaoPanel.getEmailButton().setEnabled( enable ); - upperPanel.setEnabled( !enable ); - editing = enable; - break; - } - if( tracker != null ) - { - ( ( AvisosPanel ) tracker.getAvisosPanel() ).setEnabled( ! editing, AvisoConstants.TIPO_ESTABELECIMENTO ); - } - } - - @Override - protected void enableSelect( int index, boolean select ) - { - switch( index ) - { - case INDEX_VISITA: - marcacaoEditorPanel.setEnabled( select ); - break; - } - } - - @Override - public void reload( int index ) - { - switch( index ) - { - case INDEX_MAIN: - try - { -// EmpresasData empresa = (EmpresasData) objectProvider.load( EmpresasData.class, empresaID ); - estabelecimento = estabelecimentoID == null ? null : ((EstabelecimentosData) objectProvider.load( EstabelecimentosData.class, estabelecimentoID )); -// upperPanel.getEmpresaText().setText( empresa ); -// upperPanel.getEstabelecimentoText().setText( estabelecimento ); -// upperPanel.getTrabalhadorText().setText( ( String ) trabalhador.get( TrabalhadoresData.NOME ) ); - Object visitas[][] = higieneProvider.getVisitasEstabelecimento( estabelecimentoID ); - if( visitas.length > 0 ) - { - marcacaoEditorPanel.setData( new Object2DArray( visitas ) ); - } - else - { - marcacaoEditorPanel.clear(); - } - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a carregar os dados.", true ); - } - break; - - case INDEX_VISITA: - Integer visitaID = marcacaoEditorPanel.getID(); - if( visitaID == null ) - { - return; - } - try - { - MarcacoesEstabelecimentoData visita = (MarcacoesEstabelecimentoData) objectProvider.load( MarcacoesEstabelecimentoData.class, visitaID ); - marcacaoPanel.fill( visita ); - Date dataEmailVisita = ( Date ) visita.get( MarcacoesEstabelecimentoData.DATA_EMAIL ); - if( dataEmailVisita != null ) - { - marcacaoPanel.getEmailButton().setText( "Enviar email (" + DATE_FORMAT.format( dataEmailVisita ) + ")" ); - } - else - { - marcacaoPanel.getEmailButton().setText( "Enviar email" ); - } - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a carregar os dados da visita.", true ); - } - break; - } - } - - @Override - public void actionPerformed( ActionEvent e ) - { - Object source = e.getSource(); - if( source.equals( marcacaoPanel.getEmailButton() ) ) - { - enviarEmailVisita(); - } - } - - protected void enviarEmailVisita() - { - MarcacoesEstabelecimentoData visita = ( MarcacoesEstabelecimentoData ) marcacaoPanel.save(); - - String subject = ( String ) Singleton.getInstance( SingletonConstants.SUBJECT_VISITA ); - String texto = ( String ) Singleton.getInstance( SingletonConstants.LETTER_VISITA ); - - Date today = new Date(); - marcacaoPanel.getEmailButton().setText( "Enviar email (" + DATE_FORMAT.format( today ) + ")" ); - - try - { - enviarEmail( subject, texto, ( Date )visita.get( MarcacoesEstabelecimentoData.DATA ) ); - visita.set( Marcacao.DATA_EMAIL, today ); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a enviar mail", true ); - } - } - - protected void enviarEmail( String subject, String texto, Date data ) - throws Exception - { - String sede = ( String )estabelecimento.get( EstabelecimentosData.NOME ); - String dataStr = DATE_FORMAT.format( data ); - subject = subject.replaceAll( CompanyDataLoader.NOME, sede ); - String morada = ( String )estabelecimento.get( EstabelecimentosData.MORADA ); - - texto = texto.replaceAll( CompanyDataLoader.DATA, dataStr ); - texto = texto.replaceAll( CompanyDataLoader.NOME, sede ); - texto = texto.replaceAll( CompanyDataLoader.MORADA, morada ); - - ContactosData contacto = estabelecimento.toContacto_id(); - String mail = ""; - if( contacto != null ) - { - mail = ( String )contacto.get( ContactosData.EMAIL ); - } - - if( System.getProperty( "os.name" ).startsWith( "Windows" ) ) - { - mail = mail.replaceAll( " ", "%20" ); - subject = subject.replaceAll( " ", "%20" ); - texto = texto.replaceAll( " ", "%20" ); - Process proc = Runtime.getRuntime().exec( "cmd.exe /c start mailto:\"" + mail - + "?subject=" + subject + "&body=" - - + texto - ); - } - else - { - mail = mail.replaceAll( " ", "%20" ); - subject = subject.replaceAll( " ", "%20" ); - texto = texto.replaceAll( " ", "%20" ); - - Process proc = Runtime.getRuntime().exec( new String[]{ "/usr/bin/open", "/Applications/Mail.app", "mailto:" + mail - + "?subject=" + subject + "&body=" - + texto } ); - } - } - - @Override - public void valueChanged( ListSelectionEvent e ) - { - Object source = e.getSource(); - if( source.equals( upperPanel ) ) - { - Integer ids[] = ( Integer [] ) upperPanel.save(); - empresaID = ids[ 0 ]; - estabelecimentoID = ids[ 1 ]; - if( ids[ 1 ] == null ) - { - clear( INDEX_MAIN ); - unselect( INDEX_MAIN ); - } - else - { - reload( INDEX_MAIN ); - select( INDEX_MAIN ); - } - } - } - - @Override - public void setEmpresaAndEstabelecimento( Integer empresaID, Integer estabelecimentoID ) - { - if( editing ) - { - JOptionPane.showMessageDialog( this, "Esta janela est\u00e1 em edi\u00e7\u00e3o.", "Erro...", - JOptionPane.ERROR_MESSAGE ); - } - else - { - upperPanel.fill( new Integer[]{ empresaID, estabelecimentoID } ); - } - } - - @Override - public void setTracker( SHSTTrackerInterface tracker ) - { - this.tracker = tracker; - } - -} diff --git a/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/TecnicoEditor.java b/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/TecnicoEditor.java deleted file mode 100644 index 54c8123c..00000000 --- a/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/TecnicoEditor.java +++ /dev/null @@ -1,323 +0,0 @@ -package siprp.higiene.marcacoes; - - -import static com.evolute.utils.strings.UnicodeLatin1Map.eacute; - -import java.awt.Dimension; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.GridLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.Vector; - -import javax.swing.BoxLayout; -import javax.swing.JButton; -import javax.swing.JCheckBox; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JRadioButton; -import javax.swing.JScrollPane; -import javax.swing.JTextField; -import javax.swing.ListSelectionModel; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; - -import siprp.data.outer.MarcacoesTecnicosHstData; -import siprp.higiene.HigieneDataProvider; -import siprp.ui.SIPRPEditorWindow; - -import com.evolute.entity.ProviderInterface; -import com.evolute.utils.Singleton; -import com.evolute.utils.tables.BaseTable; -import com.evolute.utils.tables.ColumnizedObjectArray; -import com.evolute.utils.tables.VectorTableModel; -import com.evolute.utils.ui.CustomJDialog; -import com.evolute.utils.ui.DialogException; -import com.evolute.utils.ui.button.BetterButtonGroup; -import com.evolute.utils.ui.text.CopyPasteHandler; - -/** - * - * @author fpalma - */ -public class TecnicoEditor extends CustomJDialog - implements ActionListener, ListSelectionListener -{ - - private static final long serialVersionUID = 1L; - - private ProviderInterface JDO; - private HigieneDataProvider provider; - private BaseTable table; - private VectorTableModel model; - private JButton okButton; - private JButton cancelarButton; - private JButton novoButton; - private JTextField nomeText; - private JTextField iniciaisText; - private JCheckBox checkSuperior; - private Integer id; - private boolean isNew = false; - private BetterButtonGroup corGroup; - private JRadioButton cores[]; - - /** Creates a new instance of MedicoEditor */ - public TecnicoEditor( SIPRPEditorWindow owner ) - throws Exception - { - super( owner, true ); - provider = (HigieneDataProvider)HigieneDataProvider.getProvider(); - JDO = ( ProviderInterface ) Singleton.getInstance( Singleton.DEFAULT_EVO_DATA_PROVIDER ); - setupComponents(); - } - - private void setupComponents() - throws Exception - { - setSize( 600, 300 ); - setResizable( false ); - setTitle( "Criar/Editar T\u00e9cnico" ); - centerSuper(); - - model = new VectorTableModel( new String[]{ "Nome", "Iniciais", "Cor", "Superior" } ); - table = new BaseTable( model ); - table.setSelectionMode( ListSelectionModel.SINGLE_SELECTION ); - table.setTableCellRenderer( new TecnicoRenderer() ); - JScrollPane scp = new JScrollPane(); - scp.setMinimumSize( new Dimension( 300, 200 ) ); - scp.setMaximumSize( new Dimension( 300, 200 ) ); - scp.setPreferredSize( new Dimension( 300, 200 ) ); - scp.setSize( new Dimension( 300, 200 ) ); - scp.setViewportView( table ); - scp.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); - scp.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ); - table.fixColumnWidth( 0, 200 ); - table.setNonResizableNorReordable(); - table.getSelectionModel().addListSelectionListener( this ); - Object obj[][] = provider.getAllTecnicosHST(); - Vector tecnicosHST = new Vector(); - for( int n = 0; n < obj.length; n++ ) - { - tecnicosHST.add( new ColumnizedObjectArray( obj[ n ], true ) ); - } - model.setValues( tecnicosHST ); - - okButton = new JButton( "OK" ); - cancelarButton = new JButton( "Cancelar" ); - novoButton = new JButton( "Novo" ); - okButton.addActionListener( this ); - cancelarButton.addActionListener( this ); - novoButton.addActionListener( this ); - - nomeText = new JTextField(); - nomeText.setEnabled( false ); - iniciaisText = new JTextField(); - iniciaisText.setEnabled( false ); - checkSuperior = new JCheckBox( "T" + eacute + "cnico Superior" ); - checkSuperior.setEnabled( false ); - JPanel corPanel = new JPanel(); - corPanel.setLayout( new BoxLayout( corPanel, BoxLayout.Y_AXIS ) ); - corGroup = new BetterButtonGroup( false ); - cores = new JRadioButton[ HigieneDataProvider.CORES_TECNICOS.length ]; - for( int n = 0; n < HigieneDataProvider.CORES_TECNICOS.length; n++ ) - { - cores[ n ] = new JRadioButton( " " ); - cores[ n ].setBackground( HigieneDataProvider.CORES_TECNICOS[ n ] ); - corPanel.add( cores[ n ] ); - corGroup.add( cores[ n ] ); - } - JScrollPane corScroll = - new JScrollPane( corPanel, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, - JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); - - GridBagLayout gridbag = new GridBagLayout(); - getContentPane().setLayout( gridbag ); - GridBagConstraints constraints = new GridBagConstraints(); - constraints.insets = new Insets( 1, 1, 1, 1 ); - constraints.fill = GridBagConstraints.BOTH; - constraints.weighty = 1; - constraints.weightx = 1; - constraints.gridwidth = GridBagConstraints.REMAINDER; - constraints.gridheight = 1; - - JPanel upperPanel = new JPanel(); - upperPanel.setLayout( new GridLayout( 1, 2 ) ); - upperPanel.add( scp ); - JPanel textPanel = new JPanel(); - upperPanel.add( textPanel ); - gridbag.setConstraints( upperPanel, constraints ); - getContentPane().add( upperPanel ); - - constraints.fill = GridBagConstraints.HORIZONTAL; - constraints.weighty = 0; - constraints.weightx = 0.3; - constraints.gridwidth = 1; - constraints.gridheight = GridBagConstraints.REMAINDER;; - - gridbag.setConstraints( novoButton, constraints ); - getContentPane().add( novoButton ); - - gridbag.setConstraints( okButton, constraints ); - getContentPane().add( okButton ); - - constraints.gridwidth = GridBagConstraints.REMAINDER; - gridbag.setConstraints( cancelarButton, constraints ); - getContentPane().add( cancelarButton ); - - gridbag = new GridBagLayout(); - textPanel.setLayout( gridbag ); - constraints.weighty = 0; - constraints.weightx = 1; - constraints.gridwidth = GridBagConstraints.REMAINDER; - constraints.gridheight = 1; - - JLabel nomeLabel = new JLabel( "Nome" ); - gridbag.setConstraints( nomeLabel, constraints ); - textPanel.add( nomeLabel ); - - gridbag.setConstraints( nomeText, constraints ); - textPanel.add( nomeText ); - - JLabel iniciaisLabel = new JLabel( "Iniciais" ); - gridbag.setConstraints( iniciaisLabel, constraints ); - textPanel.add( iniciaisLabel ); - - gridbag.setConstraints( iniciaisText, constraints ); - textPanel.add( iniciaisText ); - - gridbag.setConstraints( checkSuperior, constraints ); - textPanel.add( checkSuperior ); - - JLabel corLabel = new JLabel( "Cor" ); - gridbag.setConstraints( corLabel, constraints ); - textPanel.add( corLabel ); - - constraints.weighty = 1; - constraints.gridheight = GridBagConstraints.REMAINDER; - constraints.fill = GridBagConstraints.BOTH; - - gridbag.setConstraints( corScroll, constraints ); - textPanel.add( corScroll ); - - new CopyPasteHandler( nomeText ); - new CopyPasteHandler( iniciaisText ); - } - - @Override - public void actionPerformed( ActionEvent e ) - { - if( e.getSource().equals( okButton ) ) - { - if( save() ) - { - close(); - } - } - else if( e.getSource().equals( cancelarButton ) ) - { - id = null; - close(); - } - if( e.getSource().equals( novoButton ) ) - { - table.getSelectionModel().removeListSelectionListener( this ); - nomeText.setText( "" ); - iniciaisText.setText( "" ); - corGroup.setIntSelected( 0 ); - nomeText.setEnabled( true ); - iniciaisText.setEnabled( true ); - corGroup.setEnabled( true ); - checkSuperior.setSelected( false ); - checkSuperior.setEnabled( true ); - id = null; - isNew = true; - } - } - - @Override - public void valueChanged( ListSelectionEvent listSelectionEvent ) - { - int selected = table.getSelectedRow(); - if( selected == -1 ) - { - return; - } - ColumnizedObjectArray row = model.getRowAt( selected ); - id = row.getID(); - String nome = (String) row.getValue( 0 ); - String iniciais = (String) row.getValue( 1 ); - Integer cor = ( Integer ) row.getValue( 2 ); - String superior = ( String) row.getValue( 3 ); - nomeText.setText( nome ); - iniciaisText.setText( iniciais ); - corGroup.setIntSelected( cor.intValue() ); - nomeText.setEnabled( true ); - iniciaisText.setEnabled( true ); - corGroup.setEnabled( true ); - checkSuperior.setEnabled( true ); - checkSuperior.setSelected( superior != null && "y".equals(superior) ); - } - - private void close() - { - setVisible( false ); - dispose(); - } - - public boolean getIsNew() - { - return isNew; - } - - public Integer getID() - { - return id; - } - - private boolean save() - { - String nome = nomeText.getText().trim(); - String nomePlain = com.evolute.utils.strings.StringPlainer.convertString( nome ); - String iniciais = iniciaisText.getText().trim(); - Integer cor = new Integer( corGroup.getIntSelected() ); - if( nome.length() == 0 || iniciais.length() == 0 ) - { - JOptionPane.showMessageDialog( this, "O Nome e as iniciais n\u00e3o podem ser vazios.", "Erro...", - JOptionPane.ERROR_MESSAGE ); - return false; - } - try - { - MarcacoesTecnicosHstData tecnico; - if( id != null ) - { - tecnico = ( MarcacoesTecnicosHstData ) JDO.load( MarcacoesTecnicosHstData.class, id ); - } - else - { - tecnico = new MarcacoesTecnicosHstData(); - } - tecnico.set( MarcacoesTecnicosHstData.IS_SUPERIOR, checkSuperior.isSelected() ? "y" : "n" ); - tecnico.set( MarcacoesTecnicosHstData.NOME, nome ); - tecnico.set( MarcacoesTecnicosHstData.NOME_PLAIN, nomePlain ); - tecnico.set( MarcacoesTecnicosHstData.INICIAIS, iniciais ); - tecnico.set( MarcacoesTecnicosHstData.IDENTIFICADOR, cor ); - tecnico.save(); - if( id == null ) - { - id = (Integer)tecnico.get( MarcacoesTecnicosHstData.ID ); - } - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a gravar...", false ); - return false; - } - - return true; - } - -} diff --git a/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/TecnicoRenderer.java b/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/TecnicoRenderer.java deleted file mode 100644 index 5510e309..00000000 --- a/trunk/SIPRPSoft/src/siprp/higiene/marcacoes/TecnicoRenderer.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * DiaRenderer.java - * - * Created on 8 de Fevereiro de 2006, 21:45 - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.higiene.marcacoes; - -import java.awt.Color; -import java.awt.Component; - -import javax.swing.JLabel; -import javax.swing.JTable; -import javax.swing.table.TableCellRenderer; - -import siprp.higiene.HigieneDataProvider; - -/** - * - * @author Frederico - */ -public class TecnicoRenderer - implements TableCellRenderer -{ - protected JLabel labels[]; - protected Color defaultColor; - - /** Creates a new instance of DiaRenderer */ - public TecnicoRenderer() - { - labels = new JLabel[ 4 ]; - for( int n = 0; n < 4; n++ ) - { - labels[ n ] = new JLabel(); - } - defaultColor = labels[ 0 ].getBackground(); - labels[ 2 ].setOpaque( true ); - } - - public Component getTableCellRendererComponent( JTable table, Object value, - boolean isSelected, - boolean hasFocus, - int row, int column ) - { - switch( column ) - { - case 2: - labels[ 2 ].setText( " " ); - labels[ 2 ].setBackground( value == null ? defaultColor : - HigieneDataProvider.CORES_TECNICOS[ ( ( Integer ) value ).intValue() ] ); - break; - default: - labels[ column ].setText( ( String ) value ); - break; - } - return labels[ column ]; - } -}