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
						
					
					
				| /*
 | |
|  * Importer.java
 | |
|  *
 | |
|  * Created on 7 de Abril de 2004, 10:56
 | |
|  */
 | |
| 
 | |
| package siprp.importer;
 | |
| 
 | |
| import com.evolute.utils.arrays.*;
 | |
| import com.evolute.utils.tables.*;
 | |
| 
 | |
| import java.awt.*;
 | |
| import java.awt.event.*;
 | |
| import java.io.*;
 | |
| import javax.swing.*;
 | |
| import javax.swing.table.*;
 | |
| 
 | |
| import jxl.*;
 | |
| 
 | |
| /**
 | |
|  *
 | |
|  * @author  psantos
 | |
|  */
 | |
| public class Importer extends JFrame
 | |
| {
 | |
| 	private JPanel panel;
 | |
| 
 | |
| 	/** Creates a new instance of Importer */
 | |
| 	public Importer( String filename )
 | |
| 		throws Exception
 | |
| 	{
 | |
| 		setupComponents( filename );
 | |
| 
 | |
| 		addWindowListener( new WindowAdapter(){
 | |
| 			public void windowClosing( WindowEvent e )
 | |
| 			{
 | |
| 				System.exit( 0 );
 | |
| 			}
 | |
| 		} );
 | |
| 	}
 | |
| 
 | |
| 	private void setupComponents( String filename )
 | |
| 	{
 | |
| 		setSize( 100, 100 );
 | |
| 
 | |
| 		panel = ( JPanel ) getContentPane();
 | |
| 
 | |
| 		Excel2DArray e2da = new Excel2DArray( filename );
 | |
| 
 | |
| 		Virtual2DTableModel tm = new Virtual2DTableModel( new String[ e2da.rowLength() ], null );
 | |
| 		tm.setValues( e2da );
 | |
| 		BaseTable table = new BaseTable( tm );
 | |
| 		for( int i = 0; i < e2da.rowLength(); i++ )
 | |
| 		{
 | |
| 			table.getColumn( i ).setMinWidth( 50 );
 | |
| 			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);
 | |
| 		
 | |
| 		panel.add( sp );
 | |
| 	}
 | |
| 	
 | |
| 	public static void main( String args[] )
 | |
| 	{
 | |
| 		Importer im = null;
 | |
| 		try
 | |
| 		{
 | |
| 			im = new Importer(
 | |
| 				"C:\\Documents and Settings\\psantos\\My Documents\\Devel\\teste.xls"
 | |
| //				"C:\\Documents and Settings\\psantos\\My Documents\\Devel\\Docs\\jexcelapi\\jxlrwtest.xls"
 | |
| 				);
 | |
| 		}
 | |
| 		catch( Exception e )
 | |
| 		{
 | |
| 			e.printStackTrace();
 | |
| 		}
 | |
| 
 | |
| 		im.show();
 | |
| 
 | |
| //		String[][] all =  (String[][]) e.getObjects();
 | |
| //
 | |
| //		for( int j = 0; j < e.rowLength(); j++ )
 | |
| //		{
 | |
| //			String[] r = e.getRow( j );
 | |
| //			for( int i = 0; i < r.length; i++ )
 | |
| //			{
 | |
| //				System.out.print( "[" + r[ i ] + "]" );
 | |
| //			}
 | |
| //			System.out.println();
 | |
| //		}
 | |
| 	}
 | |
| }
 | |
| 
 | |
| class ComboBoxHeaderRenderer extends JComboBox implements TableCellRenderer
 | |
| {
 | |
| 	public Component getTableCellRendererComponent(JTable table, Object value,
 | |
| 		boolean isSelected, boolean hasFocus, int rowIndex, int vColIndex) {
 | |
| 		// 'value' is column header value of column 'vColIndex'
 | |
| 		// rowIndex is always -1
 | |
| 		// isSelected is always false
 | |
| 		// hasFocus is always false
 | |
| 
 | |
| 		// Configure the component with the specified value
 | |
| //		setText(value.toString());
 | |
| 
 | |
| 		JPopupMenu pm = new JPopupMenu( "Menu" );
 | |
| 		pm.add( "Ola" );
 | |
| 		pm.add( "Adeus" );
 | |
| 		add( pm );
 | |
| 			
 | |
| 		// Set tool tip if desired
 | |
| 		setToolTipText((String)value);
 | |
| 
 | |
| 		// Since the renderer is a component, return itself
 | |
| 		//return this;
 | |
| 		return this;
 | |
| 	}
 | |
| 
 | |
| 	// The following methods override the defaults for performance reasons
 | |
| //	public void validate() {}
 | |
| //	public void revalidate() {}
 | |
| //	protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {}
 | |
| //	public void firePropertyChange(String propertyName, boolean oldValue, boolean newValue) {}
 | |
| } |