-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d340e54
commit 95a8482
Showing
11 changed files
with
209 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* To change this license header, choose License Headers in Project Properties. | ||
* To change this template file, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
package com.spej.model; | ||
|
||
import com.spej.dao.UsuarioDao; | ||
import java.util.ArrayList; | ||
import javax.swing.table.AbstractTableModel; | ||
|
||
/** | ||
* | ||
* @author Higor | ||
*/ | ||
public class UsuarioTableModel extends AbstractTableModel { | ||
|
||
private ArrayList<Usuario> users; | ||
|
||
public UsuarioTableModel() { | ||
this( new UsuarioDao().getAll("matricula > 0") ); | ||
} | ||
public UsuarioTableModel(ArrayList<Usuario> users) { | ||
super(); | ||
this.users = users; | ||
} | ||
|
||
@Override | ||
public int getRowCount() { | ||
return this.users.size(); | ||
} | ||
@Override | ||
public int getColumnCount() { | ||
return 2; | ||
} | ||
|
||
@Override | ||
public Object getValueAt(int rowIndex, int columnIndex) { | ||
try { | ||
if(columnIndex == 0) return this.users.get(rowIndex).getMatricula(); | ||
else if(columnIndex == 1) return this.users.get(rowIndex).getNome(); | ||
} | ||
catch(IndexOutOfBoundsException e) { | ||
} | ||
return ""; | ||
} | ||
|
||
@Override | ||
public String getColumnName(int column) { | ||
if(column == 0) return "Matricula"; | ||
else return "Nome"; | ||
} | ||
|
||
|
||
@Override | ||
public boolean isCellEditable(int row, int col) { | ||
return false; | ||
} | ||
|
||
public Usuario getRowObject(int rowIndex) { | ||
try { | ||
return this.users.get(rowIndex); | ||
} | ||
catch(IndexOutOfBoundsException e) { | ||
} | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.