|  |  | @ -24,6 +24,7 @@ import info.clearthought.layout.TableLayout; | 
			
		
	
		
		
			
				
					
					|  |  |  | import info.clearthought.layout.TableLayoutConstraints; |  |  |  | import info.clearthought.layout.TableLayoutConstraints; | 
			
		
	
		
		
			
				
					
					|  |  |  | import java.awt.Dimension; |  |  |  | import java.awt.Dimension; | 
			
		
	
		
		
			
				
					
					|  |  |  | import java.util.Arrays; |  |  |  | import java.util.Arrays; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import java.util.Hashtable; | 
			
		
	
		
		
			
				
					
					|  |  |  | import java.util.List; |  |  |  | import java.util.List; | 
			
		
	
		
		
			
				
					
					|  |  |  | import java.util.Vector; |  |  |  | import java.util.Vector; | 
			
		
	
		
		
			
				
					
					|  |  |  | import javax.swing.BorderFactory; |  |  |  | import javax.swing.BorderFactory; | 
			
		
	
	
		
		
			
				
					|  |  | @ -55,12 +56,17 @@ public class PrestadoresWindow extends EditorWindow | 
			
		
	
		
		
			
				
					
					|  |  |  | 	protected JTextField localidadeCodigoPostalText; |  |  |  | 	protected JTextField localidadeCodigoPostalText; | 
			
		
	
		
		
			
				
					
					|  |  |  | 	protected JTextField localidadeText; |  |  |  | 	protected JTextField localidadeText; | 
			
		
	
		
		
			
				
					
					|  |  |  | 	protected ContactoPanel contactoPanel; |  |  |  | 	protected ContactoPanel contactoPanel; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	protected JTextField contribuinteText; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	 | 
			
		
	
		
		
			
				
					
					|  |  |  | 	 |  |  |  | 	 | 
			
		
	
		
		
			
				
					
					|  |  |  | 	protected PrestadoresDataProvider provider; |  |  |  | 	protected PrestadoresDataProvider provider; | 
			
		
	
		
		
			
				
					
					|  |  |  | 	protected ClientesDataProvider clientesProvider; |  |  |  | 	protected ClientesDataProvider clientesProvider; | 
			
		
	
		
		
			
				
					
					|  |  |  | 	 |  |  |  | 	 | 
			
		
	
		
		
			
				
					
					|  |  |  | 	protected ComponentsHashtable components; |  |  |  | 	protected ComponentsHashtable components; | 
			
		
	
		
		
			
				
					
					|  |  |  | 	 |  |  |  | 	 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	protected PrestadoresData prestador; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	protected Integer gruposProtocolo[]; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	 | 
			
		
	
		
		
			
				
					
					|  |  |  | 	/** Creates a new instance of PrestadoresWindow */ |  |  |  | 	/** Creates a new instance of PrestadoresWindow */ | 
			
		
	
		
		
			
				
					
					|  |  |  | 	public PrestadoresWindow() |  |  |  | 	public PrestadoresWindow() | 
			
		
	
		
		
			
				
					
					|  |  |  | 		throws Exception |  |  |  | 		throws Exception | 
			
		
	
	
		
		
			
				
					|  |  | @ -113,13 +119,16 @@ public class PrestadoresWindow extends EditorWindow | 
			
		
	
		
		
			
				
					
					|  |  |  | 		localidadeCodigoPostalText.setPreferredSize( new Dimension( 150, 50 ) ); |  |  |  | 		localidadeCodigoPostalText.setPreferredSize( new Dimension( 150, 50 ) ); | 
			
		
	
		
		
			
				
					
					|  |  |  | 		JLabel localidadeLabel = new JLabel( "Localidade" ); |  |  |  | 		JLabel localidadeLabel = new JLabel( "Localidade" ); | 
			
		
	
		
		
			
				
					
					|  |  |  | 		localidadeText = new JTextField(); |  |  |  | 		localidadeText = new JTextField(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		JLabel contribuinteLabel = new JLabel( "Contribuinte" ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		contribuinteText = new JTextField(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		contribuinteText.setPreferredSize( new Dimension( 100, 50 ) ); | 
			
		
	
		
		
			
				
					
					|  |  |  | 		 |  |  |  | 		 | 
			
		
	
		
		
			
				
					
					|  |  |  | 		double cols[] =  |  |  |  | 		double cols[] =  | 
			
		
	
		
		
			
				
					
					|  |  |  | 				new double[]{ TableLayout.MINIMUM, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.FILL }; |  |  |  | 				new double[]{ TableLayout.MINIMUM, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.FILL }; | 
			
		
	
		
		
			
				
					
					|  |  |  | 		double rows[] =  |  |  |  | 		double rows[] =  | 
			
		
	
		
		
			
				
					
					|  |  |  | 				new double[]{ TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM, |  |  |  | 				new double[]{ TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM, | 
			
		
	
		
		
			
				
					
					|  |  |  | 								TableLayout.FILL, TableLayout.PREFERRED, TableLayout.PREFERRED, |  |  |  | 								TableLayout.FILL, TableLayout.PREFERRED, TableLayout.PREFERRED, | 
			
		
	
		
		
			
				
					
					|  |  |  | 								TableLayout.MINIMUM, TableLayout.MINIMUM }; |  |  |  | 								TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM }; | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 		TableLayout tableLayout = new TableLayout( cols,rows ); |  |  |  | 		TableLayout tableLayout = new TableLayout( cols,rows ); | 
			
		
	
		
		
			
				
					
					|  |  |  | 		getContentPane().setLayout( tableLayout ); |  |  |  | 		getContentPane().setLayout( tableLayout ); | 
			
		
	
		
		
			
				
					
					|  |  |  | 		 |  |  |  | 		 | 
			
		
	
	
		
		
			
				
					|  |  | @ -138,7 +147,8 @@ public class PrestadoresWindow extends EditorWindow | 
			
		
	
		
		
			
				
					
					|  |  |  | 		getContentPane().add( localidadeCodigoPostalText, new TableLayoutConstraints( 2, 6, 3, 6 ) ); |  |  |  | 		getContentPane().add( localidadeCodigoPostalText, new TableLayoutConstraints( 2, 6, 3, 6 ) ); | 
			
		
	
		
		
			
				
					
					|  |  |  | 		getContentPane().add( localidadeLabel, new TableLayoutConstraints( 0, 7 ) ); |  |  |  | 		getContentPane().add( localidadeLabel, new TableLayoutConstraints( 0, 7 ) ); | 
			
		
	
		
		
			
				
					
					|  |  |  | 		getContentPane().add( localidadeText, new TableLayoutConstraints( 1, 7, 3, 7 ) ); |  |  |  | 		getContentPane().add( localidadeText, new TableLayoutConstraints( 1, 7, 3, 7 ) ); | 
			
		
	
		
		
			
				
					
					|  |  |  | 		 |  |  |  | 		getContentPane().add( contribuinteLabel, new TableLayoutConstraints( 0, 8 ) ); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		getContentPane().add( contribuinteText, new TableLayoutConstraints( 1, 8 ) ); | 
			
		
	
		
		
			
				
					
					|  |  |  | 		pack(); |  |  |  | 		pack(); | 
			
		
	
		
		
			
				
					
					|  |  |  | 	} |  |  |  | 	} | 
			
		
	
		
		
			
				
					
					|  |  |  | 	 |  |  |  | 	 | 
			
		
	
	
		
		
			
				
					|  |  | @ -146,11 +156,12 @@ public class PrestadoresWindow extends EditorWindow | 
			
		
	
		
		
			
				
					
					|  |  |  | 	{ |  |  |  | 	{ | 
			
		
	
		
		
			
				
					
					|  |  |  | 		components = new ComponentsHashtable(); |  |  |  | 		components = new ComponentsHashtable(); | 
			
		
	
		
		
			
				
					
					|  |  |  | 		components.putComponent( PrestadoresData.NOME, nomeText ); |  |  |  | 		components.putComponent( PrestadoresData.NOME, nomeText ); | 
			
		
	
		
		
			
				
					
					|  |  |  | 		components.putComponent( PrestadoresData.NOME, new JTextComponentPlainFillerSaver( nomeText ) ); |  |  |  | 		components.putComponent( PrestadoresData.NOME_PLAIN, new JTextComponentPlainFillerSaver( nomeText ) ); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 		components.putComponent( PrestadoresData.MORADA, moradaText ); |  |  |  | 		components.putComponent( PrestadoresData.MORADA, moradaText ); | 
			
		
	
		
		
			
				
					
					|  |  |  | 		components.putComponent( PrestadoresData.CODIGO_POSTAL, codigoPostalText ); |  |  |  | 		components.putComponent( PrestadoresData.CODIGO_POSTAL, codigoPostalText ); | 
			
		
	
		
		
			
				
					
					|  |  |  | 		components.putComponent( PrestadoresData.LOCALIDADE_CP, localidadeCodigoPostalText ); |  |  |  | 		components.putComponent( PrestadoresData.LOCALIDADE_CP, localidadeCodigoPostalText ); | 
			
		
	
		
		
			
				
					
					|  |  |  | 		components.putComponent( PrestadoresData.LOCALIDADE, localidadeText ); |  |  |  | 		components.putComponent( PrestadoresData.LOCALIDADE, localidadeText ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		components.putComponent( PrestadoresData.CONTRIBUINTE, contribuinteText ); | 
			
		
	
		
		
			
				
					
					|  |  |  | 		components.putComponent( PrestadoresData.ACTIVO, activoCheck ); |  |  |  | 		components.putComponent( PrestadoresData.ACTIVO, activoCheck ); | 
			
		
	
		
		
			
				
					
					|  |  |  | 		components.putComponent( PrestadoresData.FAZ_CONSULTAS, consultasCheck ); |  |  |  | 		components.putComponent( PrestadoresData.FAZ_CONSULTAS, consultasCheck ); | 
			
		
	
		
		
			
				
					
					|  |  |  | 		components.putComponent( PrestadoresData.FAZ_ECDS, ecdsCheck ); |  |  |  | 		components.putComponent( PrestadoresData.FAZ_ECDS, ecdsCheck ); | 
			
		
	
	
		
		
			
				
					|  |  | @ -172,6 +183,9 @@ public class PrestadoresWindow extends EditorWindow | 
			
		
	
		
		
			
				
					
					|  |  |  | 		clear( 0 ); |  |  |  | 		clear( 0 ); | 
			
		
	
		
		
			
				
					
					|  |  |  | 		try |  |  |  | 		try | 
			
		
	
		
		
			
				
					
					|  |  |  | 		{ |  |  |  | 		{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			prestador = provider.getPrestadorByID( id ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			gruposProtocolo = provider.getGruposProtocoloIDByPrestadorID( id ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			reload( 0 ); | 
			
		
	
		
		
			
				
					
					|  |  |  | 		} |  |  |  | 		} | 
			
		
	
		
		
			
				
					
					|  |  |  | 		catch( Exception ex ) |  |  |  | 		catch( Exception ex ) | 
			
		
	
		
		
			
				
					
					|  |  |  | 		{ |  |  |  | 		{ | 
			
		
	
	
		
		
			
				
					|  |  | @ -191,9 +205,11 @@ public class PrestadoresWindow extends EditorWindow | 
			
		
	
		
		
			
				
					
					|  |  |  | 	 |  |  |  | 	 | 
			
		
	
		
		
			
				
					
					|  |  |  | 	public void reload( int index ) |  |  |  | 	public void reload( int index ) | 
			
		
	
		
		
			
				
					
					|  |  |  | 	{ |  |  |  | 	{ | 
			
		
	
		
		
			
				
					
					|  |  |  | 		clear( 0 ); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 		try |  |  |  | 		try | 
			
		
	
		
		
			
				
					
					|  |  |  | 		{ |  |  |  | 		{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			String names[] = (String[])components.keySet().toArray( new String[0] ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			ComponentController.fill( names, prestador.getHashData(), components ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			ecdsPanel.setSelected( gruposProtocolo ); | 
			
		
	
		
		
			
				
					
					|  |  |  | 		} |  |  |  | 		} | 
			
		
	
		
		
			
				
					
					|  |  |  | 		catch( Exception ex ) |  |  |  | 		catch( Exception ex ) | 
			
		
	
		
		
			
				
					
					|  |  |  | 		{ |  |  |  | 		{ | 
			
		
	
	
		
		
			
				
					|  |  | @ -207,6 +223,8 @@ public class PrestadoresWindow extends EditorWindow | 
			
		
	
		
		
			
				
					
					|  |  |  | 		String names[] = (String[])components.keySet().toArray( new String[0] ); |  |  |  | 		String names[] = (String[])components.keySet().toArray( new String[0] ); | 
			
		
	
		
		
			
				
					
					|  |  |  | 		ComponentController.clear( names, components ); |  |  |  | 		ComponentController.clear( names, components ); | 
			
		
	
		
		
			
				
					
					|  |  |  | 		ecdsPanel.clear(); |  |  |  | 		ecdsPanel.clear(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		prestador = null; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		gruposProtocolo = null; | 
			
		
	
		
		
			
				
					
					|  |  |  | 	} |  |  |  | 	} | 
			
		
	
		
		
			
				
					
					|  |  |  | 	 |  |  |  | 	 | 
			
		
	
		
		
			
				
					
					|  |  |  | 	public boolean newItem( int index ) |  |  |  | 	public boolean newItem( int index ) | 
			
		
	
	
		
		
			
				
					|  |  | @ -216,6 +234,26 @@ public class PrestadoresWindow extends EditorWindow | 
			
		
	
		
		
			
				
					
					|  |  |  | 	 |  |  |  | 	 | 
			
		
	
		
		
			
				
					
					|  |  |  | 	public boolean save( int index ) |  |  |  | 	public boolean save( int index ) | 
			
		
	
		
		
			
				
					
					|  |  |  | 	{ |  |  |  | 	{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		if( prestador == null ) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			prestador = new PrestadoresData(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		String names[] = (String[])components.keySet().toArray( new String[0] ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		Hashtable data = prestador.getHashData(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		ComponentController.save( names, data, components ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		prestador.setHashData( data ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		gruposProtocolo = ecdsPanel.getSelected(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		try | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			provider.savePrestador( prestador ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			provider.setGruposProtocoloForPrestador( ( Integer ) prestador.get( PrestadoresData.ID ), | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 														gruposProtocolo ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		catch( Exception ex ) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			DialogException.showExceptionMessage( ex, "Erro a guardar dados", true ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			return false; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		} | 
			
		
	
		
		
			
				
					
					|  |  |  | 		return true; |  |  |  | 		return true; | 
			
		
	
		
		
			
				
					
					|  |  |  | 	} |  |  |  | 	} | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
	
		
		
			
				
					|  |  | 
 |