forked from Coded/SIPRP
no message
git-svn-id: https://svn.coded.pt/svn/SIPRP@65 bb69d46d-e84e-40c8-a05a-06db0d6337410'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
parent
2777bce631
commit
3bd8ad31b5
@ -0,0 +1,127 @@
|
|||||||
|
/*
|
||||||
|
* 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 + 20 * 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 );
|
||||||
|
}*/
|
||||||
|
}
|
||||||
Loading…
Reference in new issue