forked from Coded/SIPRP
git-svn-id: https://svn.coded.pt/svn/SIPRP@931 bb69d46d-e84e-40c8-a05a-06db0d633741
parent
4274512250
commit
4458a60983
@ -1,10 +1,74 @@
|
|||||||
package siprp.higiene.relatorio;
|
package siprp.higiene.relatorio;
|
||||||
|
|
||||||
|
import static com.evolute.utils.strings.UnicodeLatin1Map.atilde;
|
||||||
|
import static com.evolute.utils.strings.UnicodeLatin1Map.ccedil;
|
||||||
|
import info.clearthought.layout.TableLayout;
|
||||||
|
import info.clearthought.layout.TableLayoutConstraints;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
|
import leaf.ui.SimpleTable;
|
||||||
|
import siprp.database.cayenne.objects.HsRelatorio;
|
||||||
|
import siprp.database.cayenne.objects.HsRelatorioLegislacao;
|
||||||
|
|
||||||
|
import com.evolute.utils.tables.ColumnizedObjectArray;
|
||||||
|
|
||||||
public class RelatorioLegislacaoPanel extends JPanel
|
public class RelatorioLegislacaoPanel extends JPanel
|
||||||
{
|
{
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private HsRelatorio relatorio = null;
|
||||||
|
|
||||||
|
private final SimpleTable<ColumnizedObjectArray> table = new SimpleTable<ColumnizedObjectArray>( "Categoria", "Legisla" + ccedil + atilde + "o" );
|
||||||
|
|
||||||
|
public RelatorioLegislacaoPanel()
|
||||||
|
{
|
||||||
|
startupComponents();
|
||||||
|
setupLayout();
|
||||||
|
placeComponents();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void startupComponents()
|
||||||
|
{
|
||||||
|
table.getTable().fixColumnWidth(0,200);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupLayout()
|
||||||
|
{
|
||||||
|
TableLayout layout = new TableLayout( new double[]{ TableLayout.FILL }, new double[]{ TableLayout.FILL } );
|
||||||
|
this.setLayout( layout );
|
||||||
|
}
|
||||||
|
|
||||||
|
private void placeComponents()
|
||||||
|
{
|
||||||
|
this.add( table, new TableLayoutConstraints( 0, 0 ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRelatorio( HsRelatorio relatorio )
|
||||||
|
{
|
||||||
|
this.relatorio = relatorio;
|
||||||
|
refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void refresh()
|
||||||
|
{
|
||||||
|
table.clear();
|
||||||
|
if( relatorio != null )
|
||||||
|
{
|
||||||
|
List<HsRelatorioLegislacao> legislacoes = relatorio.getHsRelatorioLegislacaoArray();
|
||||||
|
Collections.sort( legislacoes );
|
||||||
|
Vector<ColumnizedObjectArray> rows = new Vector<ColumnizedObjectArray>();
|
||||||
|
for( HsRelatorioLegislacao legislacao : legislacoes )
|
||||||
|
{
|
||||||
|
rows.add( new ColumnizedObjectArray( new Object[]{ legislacao, legislacao.getCategoria(), legislacao.getDescricao() }, true ) );
|
||||||
|
}
|
||||||
|
table.setRows( rows );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,10 +1,77 @@
|
|||||||
package siprp.higiene.relatorio;
|
package siprp.higiene.relatorio;
|
||||||
|
|
||||||
|
import static com.evolute.utils.strings.UnicodeLatin1Map.atilde;
|
||||||
|
import static com.evolute.utils.strings.UnicodeLatin1Map.ccedil;
|
||||||
|
import static com.evolute.utils.strings.UnicodeLatin1Map.oacute;
|
||||||
|
|
||||||
|
import info.clearthought.layout.TableLayout;
|
||||||
|
import info.clearthought.layout.TableLayoutConstraints;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
|
import leaf.ui.SimpleTable;
|
||||||
|
import siprp.database.cayenne.objects.HsRelatorio;
|
||||||
|
import siprp.database.cayenne.objects.HsRelatorioNormalizacao;
|
||||||
|
|
||||||
|
import com.evolute.utils.tables.ColumnizedObjectArray;
|
||||||
|
|
||||||
public class RelatorioNormalizacaoPanel extends JPanel
|
public class RelatorioNormalizacaoPanel extends JPanel
|
||||||
{
|
{
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private HsRelatorio relatorio = null;
|
||||||
|
|
||||||
|
private final SimpleTable<ColumnizedObjectArray> table = new SimpleTable<ColumnizedObjectArray>( "C" + oacute + "digo", "Normaliza" + ccedil + atilde + "o", "" );
|
||||||
|
|
||||||
|
public RelatorioNormalizacaoPanel()
|
||||||
|
{
|
||||||
|
startupComponents();
|
||||||
|
setupLayout();
|
||||||
|
placeComponents();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void startupComponents()
|
||||||
|
{
|
||||||
|
table.getTable().fixColumnWidth(0,50);
|
||||||
|
table.getTable().fixColumnWidth(2,100);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupLayout()
|
||||||
|
{
|
||||||
|
TableLayout layout = new TableLayout( new double[]{ TableLayout.FILL }, new double[]{ TableLayout.FILL } );
|
||||||
|
this.setLayout( layout );
|
||||||
|
}
|
||||||
|
|
||||||
|
private void placeComponents()
|
||||||
|
{
|
||||||
|
this.add( table, new TableLayoutConstraints( 0, 0 ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRelatorio( HsRelatorio relatorio )
|
||||||
|
{
|
||||||
|
this.relatorio = relatorio;
|
||||||
|
refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void refresh()
|
||||||
|
{
|
||||||
|
table.clear();
|
||||||
|
if( relatorio != null )
|
||||||
|
{
|
||||||
|
List<HsRelatorioNormalizacao> normalizacoes = relatorio.getHsRelatorioNormalizacaoArray();
|
||||||
|
Collections.sort( normalizacoes );
|
||||||
|
Vector<ColumnizedObjectArray> rows = new Vector<ColumnizedObjectArray>();
|
||||||
|
for( HsRelatorioNormalizacao normalizacao : normalizacoes )
|
||||||
|
{
|
||||||
|
rows.add( new ColumnizedObjectArray( new Object[]{ normalizacao, normalizacao.getCodigo(), normalizacao.getDescricao(), normalizacao.getPortuguesa() ? "Portuguesa" : "Internacional" }, true ) );
|
||||||
|
}
|
||||||
|
table.setRows( rows );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,84 @@
|
|||||||
|
package leaf.ui;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
|
import javax.swing.BorderFactory;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
import javax.swing.ListSelectionModel;
|
||||||
|
import javax.swing.event.ListSelectionListener;
|
||||||
|
|
||||||
|
import com.evolute.utils.tables.BaseTable;
|
||||||
|
import com.evolute.utils.tables.VectorTableModel;
|
||||||
|
|
||||||
|
public class SimpleTable<ROW_CLASS> extends JScrollPane
|
||||||
|
{
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private final VectorTableModel<ROW_CLASS> model;
|
||||||
|
|
||||||
|
private final BaseTable table;
|
||||||
|
|
||||||
|
public SimpleTable( String ... columnName )
|
||||||
|
{
|
||||||
|
model = new VectorTableModel<ROW_CLASS>( columnName );
|
||||||
|
table = new BaseTable( model );
|
||||||
|
setViewportView(table);
|
||||||
|
setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
|
||||||
|
setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
|
||||||
|
table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||||
|
}
|
||||||
|
|
||||||
|
public VectorTableModel<ROW_CLASS> getModel()
|
||||||
|
{
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BaseTable getTable()
|
||||||
|
{
|
||||||
|
return table;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title)
|
||||||
|
{
|
||||||
|
setBorder(BorderFactory.createTitledBorder(title));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addListSelectionListener(ListSelectionListener listener){
|
||||||
|
table.getSelectionModel().addListSelectionListener(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRows( Vector<ROW_CLASS> rows )
|
||||||
|
{
|
||||||
|
model.setValues( rows );
|
||||||
|
}
|
||||||
|
|
||||||
|
public ROW_CLASS getSelectedRow()
|
||||||
|
{
|
||||||
|
ROW_CLASS result = null;
|
||||||
|
int index = table.getSelectedRow();
|
||||||
|
if( index > -1 )
|
||||||
|
{
|
||||||
|
result = model.getRowAt( index );
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ROW_CLASS> getSelectedRows()
|
||||||
|
{
|
||||||
|
List<ROW_CLASS> result = null;
|
||||||
|
int [] index = table.getSelectedRows();
|
||||||
|
for( int i = 0; i < index.length; ++i )
|
||||||
|
{
|
||||||
|
result.add( model.getRowAt( index[i] ) );
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clear()
|
||||||
|
{
|
||||||
|
model.clearAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in new issue