no message

git-svn-id: https://svn.coded.pt/svn/SIPRP@69 bb69d46d-e84e-40c8-a05a-06db0d633741
0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
P Santos 22 years ago
parent 2677ecaa1e
commit 7217ce161a

@ -46,7 +46,7 @@ public class DataChooserWindow extends CustomJDialog
private void setupComponents() private void setupComponents()
{ {
setTitle( "Escolha os campos correspondentes:" ); setTitle( "Escolha os campos correspondentes:" );
setSize(300, 100 + 20 * labels.length ); setSize(300, 100 + 25 * labels.length );
GridBagLayout gbl = new GridBagLayout(); GridBagLayout gbl = new GridBagLayout();
GridBagConstraints gbc = new GridBagConstraints(); GridBagConstraints gbc = new GridBagConstraints();
gbc.insets = new Insets( 2, 2, 2, 2 ); gbc.insets = new Insets( 2, 2, 2, 2 );

@ -8,10 +8,12 @@ package siprp.importer;
import com.evolute.utils.arrays.*; import com.evolute.utils.arrays.*;
import com.evolute.utils.tables.*; import com.evolute.utils.tables.*;
import com.evolute.utils.ui.*;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import java.io.*; import java.io.*;
import java.util.*;
import javax.swing.*; import javax.swing.*;
import javax.swing.table.*; import javax.swing.table.*;
@ -21,48 +23,168 @@ import jxl.*;
* *
* @author psantos * @author psantos
*/ */
public class Importer extends JFrame public class Importer extends CustomJDialog
{ {
private JPanel panel; private JPanel panel;
private BaseTable table;
private Excel2DArray e2da;
private boolean canceled = false;
private DataChooserWindow dcw;
private String vals[];
/** Creates a new instance of Importer */ /** Creates a new instance of Importer */
public Importer( String filename ) public Importer( JFrame modalFrame, String filename )
throws Exception throws Exception
{ {
System.out.println( "File: " + filename ); super( modalFrame, true );
setupComponents( filename ); setupComponents( filename );
addWindowListener( new WindowAdapter(){ if( modalFrame == null )
public void windowClosing( WindowEvent e ) {
center();
}
else
{ {
System.exit( 0 ); centerSuper();
} }
} );
show();
} }
private void setupComponents( String filename ) private void setupComponents( String filename )
{ {
setSize( 100, 100 ); setSize( 600, 500 );
GridBagLayout gblGridBag = new GridBagLayout();
GridBagConstraints gbcConstraints = new GridBagConstraints();
panel = ( JPanel ) getContentPane(); panel = ( JPanel ) getContentPane();
Excel2DArray e2da = new Excel2DArray( filename ); panel.setLayout( gblGridBag );
Virtual2DTableModel tm = new Virtual2DTableModel( new String[ e2da.rowLength() ], null ); e2da = new Excel2DArray( filename );
String colNames[] = new String[ e2da.rowLength() ];
for( int i = 0; i < colNames.length; i++ )
{
colNames[ i ] = " ";
}
Virtual2DTableModel tm = new Virtual2DTableModel( colNames, null );
tm.setValues( e2da ); tm.setValues( e2da );
BaseTable table = new BaseTable( tm ); table = new BaseTable( tm );
table.getTableHeader().setResizingAllowed( true );
table.getTableHeader().setReorderingAllowed( false );
// table.setAutoResizeMode( JTable.AUTO_RESIZE_OFF );
for( int i = 0; i < e2da.rowLength(); i++ ) for( int i = 0; i < e2da.rowLength(); i++ )
{ {
table.getColumn( i ).setMinWidth( 50 ); table.getColumn( i ).setMinWidth( 50 );
table.getColumn( i ).setResizable( true ); //table.getColumn( i ).setResizable( true );
} }
// TableColumn col = table.getColumnModel().getColumn( 0 );
// col.setHeaderRenderer( new ComboBoxHeaderRenderer() );
JScrollPane sp = new JScrollPane( table, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); JScrollPane sp = new JScrollPane( table, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
gbcConstraints.anchor = GridBagConstraints.CENTER;
gbcConstraints.fill = GridBagConstraints.BOTH;
gbcConstraints.insets = new Insets(5, 5, 5, 5);
gbcConstraints.gridwidth = 3;
gbcConstraints.gridheight = 3;
gbcConstraints.weighty = 3;
gbcConstraints.gridx = 0;
gbcConstraints.gridy = 3;
gblGridBag.setConstraints( sp, gbcConstraints );
panel.add( sp ); panel.add( sp );
JPanel jpButtons = new JPanel();
final JButton jbOK = new JButton( "Escolher" );
jbOK.setEnabled( false );
jpButtons.add( jbOK );
JButton jbCancel = new JButton( "Cancelar" );
jpButtons.add( jbCancel );
gbcConstraints.gridheight = 1;
gbcConstraints.weightx = 1;
gbcConstraints.weighty = 0;
gbcConstraints.anchor = GridBagConstraints.SOUTH;
gbcConstraints.fill = GridBagConstraints.BOTH;
gbcConstraints.insets = new Insets( 2, 2, 2, 2 );
gbcConstraints.gridwidth = 3;
gbcConstraints.gridx = 0;
gbcConstraints.gridy = 6;
gblGridBag.setConstraints( jpButtons, gbcConstraints );
panel.add( jpButtons );
table.addMouseListener( new MouseAdapter() {
public void mouseClicked( MouseEvent e ) {
jbOK.setEnabled( true );
if( e.getButton() == MouseEvent.BUTTON1
&& e.getClickCount() == 2
&& table.columnAtPoint( e.getPoint() ) != -1
&& table.rowAtPoint( e.getPoint() ) != -1 )
{
acceptResult();
}
}
public void mousePressed( MouseEvent e ) {
jbOK.setEnabled( true );
}
});
jbOK.addActionListener( new ActionListener() {
public void actionPerformed( ActionEvent a ) {
acceptResult();
}
});
jbCancel.addActionListener( new ActionListener() {
public void actionPerformed( ActionEvent a ) {
setVisible( false );
dispose();
canceled = true;
}
});
}
private void acceptResult()
{
vals = e2da.getRow( table.getSelectedRow() );
/*
System.out.println( "row: " + table.getSelectedRow() );
System.out.print( "vals: " );
for( int i = 0; i < vals.length; i++ )
{
System.out.print( "[" + vals[ i ] + "]" );
}
System.out.println();
*/
setVisible( false );
dispose();
}
public Hashtable getData()
{
String names[] = new String[]{ "Nome do Funcion\u00e1rio",
"Data Nascimento",
"Sexo",
"Nacionalidade",
"Data Admiss\u00e3o",
"Categoria",
"Fun\u00e7\u00e3o",
"Local Trabalho"
};
dcw = new DataChooserWindow( null, names, vals );
if( canceled || ( dcw == null ) )
{
return null;
}
return dcw.getData();
} }
public static void main( String args[] ) public static void main( String args[] )
@ -70,26 +192,20 @@ System.out.println( "File: " + filename );
Importer im = null; Importer im = null;
try try
{ {
im = new Importer( im = new Importer( null,
// "E:\\test.xls" // "E:\\test.xls"
"C:\\Documents and Settings\\psantos\\My Documents\\Devel\\teste_2.xls" "C:\\Documents and Settings\\psantos\\My Documents\\Devel\\teste.xls"
// "C:\\Documents and Settings\\psantos\\My Documents\\Devel\\Docs\\jexcelapi\\jxlrwtest.xls" // "C:\\Documents and Settings\\psantos\\My Documents\\Devel\\Docs\\jexcelapi\\jxlrwtest.xls"
); );
System.out.println( "Escolhido: " + im.getData() );
} }
catch( Exception e ) catch( Exception e )
{ {
e.printStackTrace(); e.printStackTrace();
} }
if( im == null )
{
System.out.println( "O im e' null" );
}
else
{
im.show();
}
// String[][] all = (String[][]) e.getObjects(); // String[][] all = (String[][]) e.getObjects();
// //
// for( int j = 0; j < e.rowLength(); j++ ) // for( int j = 0; j < e.rowLength(); j++ )

Loading…
Cancel
Save