forked from Coded/SIPRP
				
			
			You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							128 lines
						
					
					
						
							3.0 KiB
						
					
					
				
			
		
		
	
	
							128 lines
						
					
					
						
							3.0 KiB
						
					
					
				| /*
 | |
|  * DataChooserWindow.java
 | |
|  *
 | |
|  * Created on 29 de Abril de 2004, 16:53
 | |
|  */
 | |
| 
 | |
| package siprp.importer;
 | |
| 
 | |
| import java.awt.*;
 | |
| import java.awt.event.*;
 | |
| import java.util.*;
 | |
| import javax.swing.*;
 | |
| 
 | |
| import com.evolute.utils.ui.*;
 | |
| /**
 | |
|  *
 | |
|  * @author  lflores
 | |
|  */
 | |
| public class DataChooserWindow extends CustomJDialog
 | |
| {
 | |
| 	private final String labels[];
 | |
| 	private final String items[];
 | |
| 	private final JComboBox combos[];
 | |
| 	
 | |
| 	private boolean canceled = false;
 | |
| 	
 | |
| 	/** Creates a new instance of DataChooserWindow */
 | |
| 	public DataChooserWindow( JFrame modalFrame, String names[], String data[] )
 | |
| 	{
 | |
| 		super( modalFrame, true );
 | |
| 		labels = names;
 | |
| 		items = data;
 | |
| 		combos = new JComboBox[ labels.length ];
 | |
| 		setupComponents();
 | |
| 		if( modalFrame == null )
 | |
| 		{
 | |
| 			center();
 | |
| 		}
 | |
| 		else
 | |
| 		{
 | |
| 			centerSuper();
 | |
| 		}
 | |
| 		show();
 | |
| 	}
 | |
| 	
 | |
| 	private void setupComponents()
 | |
| 	{
 | |
| 		setTitle( "Escolha os campos correspondentes:" );
 | |
| 		setSize(300, 100 + 25 * labels.length );
 | |
| 		GridBagLayout gbl = new GridBagLayout();
 | |
| 		GridBagConstraints gbc = new GridBagConstraints();
 | |
| 		gbc.insets = new Insets( 2, 2, 2, 2 );
 | |
| 		gbc.fill = GridBagConstraints.HORIZONTAL;
 | |
| 		Container cont = getContentPane();
 | |
| 		cont.setLayout( gbl );
 | |
| 		for( int i = 0; i < labels.length; ++i )
 | |
| 		{
 | |
| 			gbc.weightx = 0;
 | |
| 			gbc.gridwidth = 1;
 | |
| 			JLabel label = new JLabel( labels[ i ] );
 | |
| 			gbl.setConstraints( label, gbc );
 | |
| 			cont.add( label );
 | |
| /*			gbc.weightx = 1;
 | |
| 			JPanel pad = new JPanel();
 | |
| 			gbl.setConstraints( pad, gbc );
 | |
| 			cont.add( pad );
 | |
| */			gbc.weightx = 1;
 | |
| 			gbc.gridwidth = GridBagConstraints.REMAINDER;
 | |
| 			JComboBox combo = new JComboBox( items );
 | |
| 			combos[ i ] = combo;
 | |
| 			gbl.setConstraints( combo, gbc );
 | |
| 			cont.add( combo );
 | |
| 		}
 | |
| 		gbc.insets = new Insets( 10, 2, 2, 2 );
 | |
| 		gbc.weightx = 1;
 | |
| 		gbc.gridwidth = 2;
 | |
| 		JPanel pad = new JPanel();
 | |
| 		gbl.setConstraints( pad, gbc );
 | |
| 		cont.add( pad );
 | |
| 		gbc.weightx = 0;
 | |
| 		gbc.gridwidth = 1;
 | |
| 		JButton butOK = new JButton( "OK" );
 | |
| 		gbl.setConstraints( butOK, gbc );
 | |
| 		cont.add( butOK );
 | |
| 		gbc.weightx = 0;
 | |
| 		gbc.gridwidth = GridBagConstraints.REMAINDER;
 | |
| 		JButton butCancel = new JButton( "Cancelar" );
 | |
| 		gbl.setConstraints( butCancel, gbc );
 | |
| 		cont.add( butCancel );
 | |
| 		butOK.addActionListener( new ActionListener() {
 | |
| 				public void actionPerformed( ActionEvent e )
 | |
| 				{
 | |
| 					setVisible( false );
 | |
| 					dispose();
 | |
| 				}
 | |
| 			});
 | |
| 		butCancel.addActionListener( new ActionListener() {
 | |
| 				public void actionPerformed( ActionEvent e )
 | |
| 				{
 | |
| 					setVisible( false );
 | |
| 					dispose();
 | |
| 					canceled = true;
 | |
| 				}
 | |
| 			});
 | |
| 	}
 | |
| 	
 | |
| 	public Hashtable getData()
 | |
| 	{
 | |
| 		if( canceled )
 | |
| 		{
 | |
| 			return null;
 | |
| 		}
 | |
| 		Hashtable hash = new Hashtable();
 | |
| 		for( int i = 0; i < labels.length; ++i )
 | |
| 		{
 | |
| 			hash.put( labels[ i ], combos[ i ].getSelectedItem() );
 | |
| 		}
 | |
| 		return hash;
 | |
| 	}
 | |
| /*	
 | |
| 	public static void main( String arg[] )
 | |
| 	{
 | |
| 		String names[] = new String[] { "Nome:", "Morada:", "Telefone:" };
 | |
| 		String data[] = new String[] { "Joao Catita", "Damaiasdg sdfg sdf gsdfs hgf h", "nao tem", "so a noite", "" };
 | |
| 		DataChooserWindow dcw = new DataChooserWindow( null, names, data );
 | |
| 	}*/
 | |
| }
 |