15,6 → 15,7 |
*/ |
package org.tela_botanica.client; |
|
|
import com.google.gwt.i18n.client.Dictionary; |
import com.google.gwt.json.client.JSONArray; |
import com.google.gwt.json.client.JSONNumber; |
37,503 → 38,495 |
import com.google.gwt.user.client.ui.HasHorizontalAlignment; |
import com.google.gwt.user.client.ui.HasVerticalAlignment; |
|
/* |
* Le retour de getUser appelle getCount qui appelle update pour veiller à une |
* initialisation correcte |
* |
*/ |
import java.util.Vector; |
|
public class TaxonList extends Composite implements |
AutoCompleteAsyncTextBoxListener { |
|
/* Le retour de getUser appelle getCount qui appelle update pour veiller à une initialisation correcte |
|
// Barre de navigation |
*/ |
|
private class NavBar extends Composite implements ClickListener { |
public class TaxonList extends Composite implements AutoCompleteAsyncTextBoxListener { |
|
public final DockPanel bar = new DockPanel(); |
|
public final Button gotoFirst = new Button("<<", this); |
|
// Barre de navigation |
|
private class NavBar extends Composite implements ClickListener { |
|
public final DockPanel bar = new DockPanel(); |
public final Button gotoFirst = new Button("<<", this); |
public final Button gotoNext = new Button(">", this); |
public final Button gotoPrev = new Button("<", this); |
public final Button gotoEnd = new Button(">>", this); |
public final HTML status = new HTML(); |
|
|
public final Button gotoNext = new Button(">", this); |
public NavBar() { |
initWidget(bar); |
bar.setStyleName("navbar"); |
status.setStyleName("status"); |
|
public final Button gotoPrev = new Button("<", this); |
HorizontalPanel buttons = new HorizontalPanel(); |
buttons.add(gotoFirst); |
buttons.add(gotoPrev); |
buttons.add(gotoNext); |
buttons.add(gotoEnd); |
bar.add(buttons, DockPanel.EAST); |
bar.setCellHorizontalAlignment(buttons, DockPanel.ALIGN_RIGHT); |
bar.add(status, DockPanel.CENTER); |
bar.setVerticalAlignment(DockPanel.ALIGN_MIDDLE); |
bar.setCellHorizontalAlignment(status, HasHorizontalAlignment.ALIGN_RIGHT); |
bar.setCellVerticalAlignment(status, HasVerticalAlignment.ALIGN_MIDDLE); |
bar.setCellWidth(status, "100%"); |
|
public final Button gotoEnd = new Button(">>", this); |
} |
|
public final HTML status = new HTML(); |
|
public void onClick(Widget sender) { |
if (sender == gotoNext) { |
// Move forward a page. |
startIndex += VISIBLE_TAXON_COUNT; |
if (startIndex >= count) |
startIndex -= VISIBLE_TAXON_COUNT; |
} |
else { |
if (sender == gotoPrev) { |
// Move back a page. |
startIndex -= VISIBLE_TAXON_COUNT; |
if (startIndex < 0) |
startIndex = 0; |
} |
else { |
if (sender==gotoEnd) { |
gotoEnd(); |
} |
else { |
if (sender== gotoFirst) { |
startIndex = 0; |
} |
} |
} |
} |
update(); |
} |
|
public NavBar() { |
initWidget(bar); |
bar.setStyleName("navbar"); |
status.setStyleName("status"); |
} |
|
HorizontalPanel buttons = new HorizontalPanel(); |
buttons.add(gotoFirst); |
buttons.add(gotoPrev); |
buttons.add(gotoNext); |
buttons.add(gotoEnd); |
bar.add(buttons, DockPanel.EAST); |
bar.setCellHorizontalAlignment(buttons, DockPanel.ALIGN_RIGHT); |
bar.add(status, DockPanel.CENTER); |
bar.setVerticalAlignment(DockPanel.ALIGN_MIDDLE); |
bar.setCellHorizontalAlignment(status, |
HasHorizontalAlignment.ALIGN_RIGHT); |
bar.setCellVerticalAlignment(status, |
HasVerticalAlignment.ALIGN_MIDDLE); |
bar.setCellWidth(status, "100%"); |
private void setStatusText(String text) { |
navBar.status.setText(text); |
} |
|
} |
|
public void onClick(Widget sender) { |
if (sender == gotoNext) { |
// Move forward a page. |
startIndex += VISIBLE_TAXON_COUNT; |
if (startIndex >= count) |
startIndex -= VISIBLE_TAXON_COUNT; |
} else { |
if (sender == gotoPrev) { |
// Move back a page. |
startIndex -= VISIBLE_TAXON_COUNT; |
if (startIndex < 0) |
startIndex = 0; |
} else { |
if (sender == gotoEnd) { |
gotoEnd(); |
} else { |
if (sender == gotoFirst) { |
startIndex = 0; |
} |
} |
} |
} |
update(); |
} |
private static final int VISIBLE_TAXON_COUNT = 15; |
|
private Grid header = new Grid(1,6); |
private FlexTable table = new FlexTable(); |
private VerticalPanel panel = new VerticalPanel(); |
|
private int startIndex=0; |
private String serviceBaseUrl=getServiceBaseUrl(); |
private int count=65000; |
|
private Vector complements=null; |
private String element=null; |
private String complement=null; |
|
private String user; |
|
private NavBar navBar = new NavBar(); |
|
public TaxonList(Vector comps) { |
|
} |
|
initAsync(); |
|
// Information complementaire : un tableau associe au retour de l'assistant de saisie |
|
complements=comps; |
|
// Mise en forme du header |
|
header.setCellSpacing(0); |
header.setCellPadding(2); |
header.setWidth("100%"); |
|
private void setStatusText(String text) { |
navBar.status.setText(text); |
} |
header.setStyleName("taxon-ListHeader"); |
|
header.setText(0, 0, ""); |
header.setText(0, 1, "Nom saisi"); |
header.setText(0, 2, "Nom retenu"); |
header.setHTML(0, 3, "Code<br>Nomenclatural"); |
header.setHTML(0, 4, "Code<br>Taxonomique"); |
header.setText(0, 5, "Famille"); |
|
header.getCellFormatter().setWidth(0,0,"2%"); |
header.getCellFormatter().setWidth(0,1,"31%"); |
header.getCellFormatter().setWidth(0,2,"31%"); |
header.getCellFormatter().setWidth(0,3,"9%"); |
header.getCellFormatter().setWidth(0,4,"9%"); |
header.getCellFormatter().setWidth(0,5,"18%"); |
|
private static final int VISIBLE_TAXON_COUNT = 15; |
// Mise en forme de la table. |
|
table.setCellSpacing(0); |
table.setBorderWidth(0); |
table.setCellPadding(2); |
table.setWidth("100%"); |
|
private Grid header = new Grid(1, 6); |
// Mise en forme barre navigation |
|
navBar.setWidth("100%"); |
|
private FlexTable table = new FlexTable(); |
|
table.setStyleName("taxon-List"); |
|
private VerticalPanel panel = new VerticalPanel(); |
panel.add(navBar); |
panel.add(header); |
panel.add(table); |
|
initWidget(panel); |
|
|
} |
|
private int startIndex = 0; |
/** |
* Action lancee par la selection d'un nom dans l'assistant de saisie. Lance la recherche d'informations |
* complémentaires (famille, numero nomenclaturaux etc) et met a jour l'inventaire (addelement()) |
* @return void |
*/ |
public void onValidate(SourcesAutoCompleteAsyncTextBoxEvents sender,int pos, String str) { |
|
setStatusDisabled(); |
|
// Il y a surement une meilleure facon de faire que de passer par une variable de classe |
// pour atteindre une inner classe |
|
element=str; |
|
// Saisie assistée |
|
if (pos>=0) { |
|
// Le vecteur complements contient les informations complémentaires associées à un nom. |
|
complement=(String) complements.get(pos); |
|
HTTPRequest.asyncGet(serviceBaseUrl+"/NameValid/"+complement, |
new ResponseTextHandler(){ |
|
private String serviceBaseUrl = getServiceBaseUrl(); |
public void onCompletion(String str) { |
|
JSONValue jsonValue= JSONParser.parse(str); |
JSONArray jsonArray; |
|
complements.clear(); |
|
if ((jsonArray = jsonValue.isArray()) != null) { |
// Nom retenu, Num Nomen nom retenu, Num Taxon, Famille |
addElement(element,complement,((JSONString) jsonArray.get(0)).stringValue(), |
((JSONString) jsonArray.get(1)).stringValue(),((JSONString) jsonArray.get(2)).stringValue(), |
((JSONString) jsonArray.get(3)).stringValue()); |
} |
} |
|
private int count = 65000; |
}); |
} |
// Saisie libre |
else { |
complements.clear(); |
|
private String user; |
addElement(element," "," "," "," "," "); |
} |
} |
|
/** |
* Ajoute un element à l'inventaire |
* @param nom_sel : nom selectionne |
* @param num_nom_sel : numero nomenclatural nom selectionne |
* @param nom_ret : nom retenu |
* @param num_nom_ret : numero nomenclaturel nom retenu |
* @param num_taxon : numero taxonomique |
* @param famille : famille |
*/ |
|
private NavBar navBar = new NavBar(); |
public void addElement(String nom_sel, String num_nom_sel, String nom_ret, String num_nom_ret, String num_taxon, String famille) { |
|
// Calcul du nouveau numéro d'ordre |
|
/* int order=1; |
if (table.getRowCount()>0) { |
order=new Integer(table.getText(table.getRowCount()-1,6)).intValue()+1; |
}*/ |
|
count++; |
HTTPRequest.asyncPost(serviceBaseUrl+"/Inventory/", "identifiant="+user+"&nom_sel="+nom_sel+"&num_nom_sel="+num_nom_sel |
+"&nom_ret="+nom_ret+"&num_nom_ret="+num_nom_ret+"&num_taxon="+num_taxon+"&famille="+famille, |
|
new ResponseTextHandler(){ |
|
public void onCompletion(String str) { |
gotoEnd(); |
update(); |
} |
}); |
} |
|
public TaxonList() { |
/** |
* Suppression d'un element lde l'inventaire, a partir de son numero d'ordre |
* |
*/ |
|
initAsync(); |
|
public void deleteElement() { |
|
// Information complementaire : un tableau associe au retour de |
// l'assistant de saisie |
|
setStatusDisabled(); |
boolean checked=false; |
|
// Mise en forme du header |
// Lifo ... |
for (int i=table.getRowCount()-1; i>=0;i--){ |
if (((CheckBox) table.getWidget(i,0)).isChecked()) { |
checked=true; |
String str=table.getText(i,6); |
count--; |
HTTPRequest.asyncPost(serviceBaseUrl+"/Inventory/"+user+"/"+str, "action=DELETE", |
new ResponseTextHandler(){ |
|
header.setCellSpacing(0); |
header.setCellPadding(2); |
header.setWidth("100%"); |
public void onCompletion(String str) { |
gotoEnd(); |
update(); |
} |
}); |
|
header.setStyleName("taxon-ListHeader"); |
} |
} |
if (!checked) { |
setStatusEnabled(); |
} |
} |
|
header.setText(0, 0, ""); |
header.setText(0, 1, "Nom saisi"); |
header.setText(0, 2, "Nom retenu"); |
header.setHTML(0, 3, "Code<br>Nomenclatural"); |
header.setHTML(0, 4, "Code<br>Taxonomique"); |
header.setText(0, 5, "Famille"); |
/** |
* |
* Lancement des initialisations dependantes de réponses asynchrones : le retour d'une demande d'initialisation declanche |
* la demande d'initialisation suivantes |
* user : resultat recherche nom d'utilisateur |
* count : resultat nombre d'enregistrements d'inventaires |
* affichage enregistrements trouvés |
* |
*/ |
private void initAsync() { |
|
getUser(); |
// getCount() |
// update() |
|
} |
|
/** |
* Recherche utilisateur en cours |
* |
*/ |
private void getUser() { |
|
|
setStatusDisabled(); |
|
header.getCellFormatter().setWidth(0, 0, "2%"); |
header.getCellFormatter().setWidth(0, 1, "31%"); |
header.getCellFormatter().setWidth(0, 2, "31%"); |
header.getCellFormatter().setWidth(0, 3, "9%"); |
header.getCellFormatter().setWidth(0, 4, "9%"); |
header.getCellFormatter().setWidth(0, 5, "18%"); |
HTTPRequest.asyncGet(serviceBaseUrl+"/User/", |
new ResponseTextHandler(){ |
|
// Mise en forme de la table. |
public void onCompletion(String str) { |
JSONValue jsonValue= JSONParser.parse(str); |
JSONString jsonString; |
if ((jsonString = jsonValue.isString()) != null) { |
user = jsonString.stringValue(); |
} |
getCount(); |
} |
}); |
|
|
|
table.setCellSpacing(0); |
table.setBorderWidth(0); |
table.setCellPadding(2); |
table.setWidth("100%"); |
} |
|
// Mise en forme barre navigation |
/** |
* Recherche nombre d'enregistrement pour l'utilisateur en cours |
* |
*/ |
private void getCount() { |
|
navBar.setWidth("100%"); |
HTTPRequest.asyncGet(serviceBaseUrl+"/InventoryList/"+user+"/", |
new ResponseTextHandler(){ |
|
table.setStyleName("taxon-List"); |
public void onCompletion(String str) { |
|
panel.add(navBar); |
panel.add(header); |
panel.add(table); |
JSONValue jsonValue= JSONParser.parse(str); |
JSONNumber jsonNumber; |
if ((jsonNumber = jsonValue.isNumber()) != null) { |
count=(int) jsonNumber.getValue(); |
gotoEnd(); // Derniere page |
update(); |
} |
} |
}); |
|
initWidget(panel); |
} |
|
} |
/** |
* Mise a jour de l'affichage, à partir des données d'inventaire deja saisies. |
* La valeur de this.startIndex permet de determiner quelles données seront affichées |
* |
*/ |
|
private void update() { |
|
|
/** |
* Action lancee par la selection d'un nom dans l'assistant de saisie. Lance |
* la recherche d'informations complémentaires (famille, numero |
* nomenclaturaux etc) et met a jour l'inventaire (addelement()) |
* |
* @return void |
*/ |
public void onValidate(SourcesAutoCompleteAsyncTextBoxEvents sender, |
final String str,final String value) { |
setStatusDisabled(); |
|
// TODO : optimisation : ne supprimer que les lignes qui ne seront pas alimentes . |
|
setStatusDisabled(); |
HTTPRequest.asyncGet(serviceBaseUrl+"/InventoryList/"+user+"/"+startIndex+"/"+VISIBLE_TAXON_COUNT, |
|
new ResponseTextHandler(){ |
|
// Saisie assistée |
public void onCompletion(String str) { |
|
if (value !=null) { |
JSONValue jsonValue= JSONParser.parse(str); |
JSONArray jsonArray; |
JSONArray jsonArrayNested; |
|
// Lifo ... |
for (int i=table.getRowCount()-1; i>=0;i--){ |
table.removeRow(i); |
} |
|
|
HTTPRequest.asyncGet(serviceBaseUrl + "/NameValid/" + value, |
new ResponseTextHandler() { |
int j=0; |
if ((jsonArray = jsonValue.isArray()) != null) { |
for (int i = 0; i < jsonArray.size(); ++i) { |
if ((jsonArrayNested = jsonArray.get(i).isArray()) != null) { |
int row=table.insertRow(table.getRowCount()); |
// Case a cocher |
table.setWidget(row,0,new CheckBox()); |
// Nom saisi |
table.setText(row,1,((JSONString) jsonArrayNested.get(0)).stringValue()); |
// Nom retenu |
table.setText(row,2,((JSONString) jsonArrayNested.get(2)).stringValue()); |
// Num nomenclatural |
table.setText(row,3,((JSONString) jsonArrayNested.get(1)).stringValue()); |
// Num Taxonomique |
table.setText(row,4,((JSONString) jsonArrayNested.get(4)).stringValue()); |
// Famille |
table.setText(row,5,((JSONString) jsonArrayNested.get(5)).stringValue()); |
// Numero d'ordre |
table.setText(row,6,((JSONString) jsonArrayNested.get(6)).stringValue()); |
|
table.getCellFormatter().setVisible(row,6,false); |
|
table.getFlexCellFormatter().setWidth(row,0,"2%"); |
table.getFlexCellFormatter().setWidth(row,1,"31%"); |
table.getFlexCellFormatter().setWidth(row,2,"31%"); |
table.getFlexCellFormatter().setWidth(row,3,"9%"); |
table.getFlexCellFormatter().setWidth(row,4,"9%"); |
table.getFlexCellFormatter().setWidth(row,5,"18%"); |
j++; |
} |
|
} |
} |
setStatusEnabled(); |
|
} |
}); |
|
public void onCompletion(String strcomplete) { |
} |
|
JSONValue jsonValue = JSONParser.parse(strcomplete); |
JSONArray jsonArray; |
|
if ((jsonArray = jsonValue.isArray()) != null) { |
// Nom retenu, Num Nomen nom retenu, Num Taxon, |
// Famille |
addElement(str, value, |
((JSONString) jsonArray.get(0)) |
.stringValue(), |
((JSONString) jsonArray.get(1)) |
.stringValue(), |
((JSONString) jsonArray.get(2)) |
.stringValue(), |
((JSONString) jsonArray.get(3)) |
.stringValue()); |
} |
} |
|
}); |
} |
// Saisie libre |
else { |
addElement(str, " ", " ", " ", " ", " "); |
} |
} |
|
/** |
* Ajoute un element à l'inventaire |
* |
* @param nom_sel : |
* nom selectionne |
* @param num_nom_sel : |
* numero nomenclatural nom selectionne |
* @param nom_ret : |
* nom retenu |
* @param num_nom_ret : |
* numero nomenclaturel nom retenu |
* @param num_taxon : |
* numero taxonomique |
* @param famille : |
* famille |
*/ |
|
public void addElement(String nom_sel, String num_nom_sel, String nom_ret, |
String num_nom_ret, String num_taxon, String famille) { |
|
// Calcul du nouveau numéro d'ordre |
|
/* |
* int order=1; if (table.getRowCount()>0) { order=new |
* Integer(table.getText(table.getRowCount()-1,6)).intValue()+1; } |
*/ |
|
count++; |
HTTPRequest.asyncPost(serviceBaseUrl + "/Inventory/", "identifiant=" |
+ user + "&nom_sel=" + nom_sel + "&num_nom_sel=" + num_nom_sel |
+ "&nom_ret=" + nom_ret + "&num_nom_ret=" + num_nom_ret |
+ "&num_taxon=" + num_taxon + "&famille=" + famille, |
|
new ResponseTextHandler() { |
|
public void onCompletion(String str) { |
gotoEnd(); |
update(); |
} |
}); |
} |
|
/** |
* Suppression d'un element lde l'inventaire, a partir de son numero d'ordre |
* |
*/ |
|
public void deleteElement() { |
|
setStatusDisabled(); |
boolean checked = false; |
|
// Lifo ... |
for (int i = table.getRowCount() - 1; i >= 0; i--) { |
if (((CheckBox) table.getWidget(i, 0)).isChecked()) { |
checked = true; |
String str = table.getText(i, 6); |
count--; |
HTTPRequest.asyncPost(serviceBaseUrl + "/Inventory/" + user |
+ "/" + str, "action=DELETE", |
new ResponseTextHandler() { |
|
public void onCompletion(String str) { |
gotoEnd(); |
update(); |
} |
}); |
|
} |
} |
if (!checked) { |
setStatusEnabled(); |
} |
} |
|
/** |
* |
* Lancement des initialisations dependantes de réponses asynchrones : le |
* retour d'une demande d'initialisation declanche la demande |
* d'initialisation suivantes user : resultat recherche nom d'utilisateur |
* count : resultat nombre d'enregistrements d'inventaires affichage |
* enregistrements trouvés |
* |
*/ |
private void initAsync() { |
|
getUser(); |
// getCount() |
// update() |
|
} |
|
/** |
* Recherche utilisateur en cours |
* |
*/ |
private void getUser() { |
|
setStatusDisabled(); |
|
HTTPRequest.asyncGet(serviceBaseUrl + "/User/", |
new ResponseTextHandler() { |
|
public void onCompletion(String str) { |
JSONValue jsonValue = JSONParser.parse(str); |
JSONString jsonString; |
if ((jsonString = jsonValue.isString()) != null) { |
user = jsonString.stringValue(); |
} |
getCount(); |
} |
}); |
|
} |
|
/** |
* Recherche nombre d'enregistrement pour l'utilisateur en cours |
* |
*/ |
private void getCount() { |
|
HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryList/" + user + "/", |
new ResponseTextHandler() { |
|
public void onCompletion(String str) { |
|
JSONValue jsonValue = JSONParser.parse(str); |
JSONNumber jsonNumber; |
if ((jsonNumber = jsonValue.isNumber()) != null) { |
count = (int) jsonNumber.getValue(); |
gotoEnd(); // Derniere page |
update(); |
} |
} |
}); |
|
} |
|
/** |
* Mise a jour de l'affichage, à partir des données d'inventaire deja |
* saisies. La valeur de this.startIndex permet de determiner quelles |
* données seront affichées |
* |
*/ |
|
private void update() { |
|
setStatusDisabled(); |
|
// TODO : optimisation : ne supprimer que les lignes qui ne seront pas |
// alimentes . |
|
HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryList/" + user + "/" |
+ startIndex + "/" + VISIBLE_TAXON_COUNT, |
|
new ResponseTextHandler() { |
|
public void onCompletion(String str) { |
|
JSONValue jsonValue = JSONParser.parse(str); |
JSONArray jsonArray; |
JSONArray jsonArrayNested; |
|
// Lifo ... |
for (int i = table.getRowCount() - 1; i >= 0; i--) { |
table.removeRow(i); |
} |
|
int j = 0; |
if ((jsonArray = jsonValue.isArray()) != null) { |
for (int i = 0; i < jsonArray.size(); ++i) { |
if ((jsonArrayNested = jsonArray.get(i).isArray()) != null) { |
int row = table.insertRow(table.getRowCount()); |
// Case a cocher |
table.setWidget(row, 0, new CheckBox()); |
// Nom saisi |
table.setText(row, 1, ((JSONString) jsonArrayNested |
.get(0)).stringValue()); |
// Nom retenu |
table.setText(row, 2, ((JSONString) jsonArrayNested |
.get(2)).stringValue()); |
// Num nomenclatural |
table.setText(row, 3, ((JSONString) jsonArrayNested |
.get(1)).stringValue()); |
// Num Taxonomique |
table.setText(row, 4, ((JSONString) jsonArrayNested |
.get(4)).stringValue()); |
// Famille |
table.setText(row, 5, ((JSONString) jsonArrayNested |
.get(5)).stringValue()); |
// Numero d'ordre |
table.setText(row, 6, ((JSONString) jsonArrayNested |
.get(6)).stringValue()); |
|
table.getCellFormatter().setVisible(row, 6, false); |
|
table.getFlexCellFormatter().setWidth(row, 0, "2%"); |
table.getFlexCellFormatter() |
.setWidth(row, 1, "31%"); |
table.getFlexCellFormatter() |
.setWidth(row, 2, "31%"); |
table.getFlexCellFormatter().setWidth(row, 3, "9%"); |
table.getFlexCellFormatter().setWidth(row, 4, "9%"); |
table.getFlexCellFormatter() |
.setWidth(row, 5, "18%"); |
j++; |
} |
|
} |
} |
setStatusEnabled(); |
|
} |
}); |
|
} |
|
/** |
* Recuperation du prefixe d'appel des services |
*/ |
|
/** |
* Recuperation du prefixe d'appel des services |
*/ |
|
private String getServiceBaseUrl() { |
|
Dictionary theme = Dictionary.getDictionary("Parameters"); |
return theme.get("serviceBaseUrl"); |
|
} |
|
|
Dictionary theme = Dictionary.getDictionary("Parameters"); |
return theme.get("serviceBaseUrl"); |
|
|
} |
|
|
/** |
* Affichage message d'attente et désactivation navigation |
* |
* @param |
* @return void |
* @param |
* @return void |
*/ |
|
|
private void setStatusDisabled() { |
|
|
navBar.gotoFirst.setEnabled(false); |
navBar.gotoPrev.setEnabled(false); |
navBar.gotoNext.setEnabled(false); |
navBar.gotoEnd.setEnabled(false); |
|
|
setStatusText("Patientez ..."); |
} |
|
|
/** |
* Affichage numero de page et gestion de la navigation |
* |
* |
*/ |
|
|
private void setStatusEnabled() { |
|
|
// Il y a forcemment un disabled avant d'arriver ici |
|
if (count > 0) { |
|
if (startIndex >= VISIBLE_TAXON_COUNT) { // Au dela de la |
// premiere page |
|
if (count > 0 ) { |
|
if (startIndex >= VISIBLE_TAXON_COUNT) { // Au dela de la premiere page |
navBar.gotoPrev.setEnabled(true); |
navBar.gotoFirst.setEnabled(true); |
if (startIndex < (count - VISIBLE_TAXON_COUNT)) { // Pas la |
// derniere |
// page |
if (startIndex<(count-VISIBLE_TAXON_COUNT)) { // Pas la derniere page |
navBar.gotoNext.setEnabled(true); |
navBar.gotoEnd.setEnabled(true); |
setStatusText((startIndex + 1) + " - " |
+ (startIndex + VISIBLE_TAXON_COUNT)); |
} else { // Derniere page |
setStatusText((startIndex + 1) + " - " + (startIndex + VISIBLE_TAXON_COUNT)); |
} |
else { // Derniere page |
setStatusText((startIndex + 1) + " - " + count); |
} |
} else { // Premiere page |
} |
else { // Premiere page |
if (count > VISIBLE_TAXON_COUNT) { // Des pages derrieres |
navBar.gotoNext.setEnabled(true); |
navBar.gotoEnd.setEnabled(true); |
setStatusText((startIndex + 1) + " - " |
+ (startIndex + VISIBLE_TAXON_COUNT)); |
} else { |
setStatusText((startIndex + 1) + " - " + (startIndex + VISIBLE_TAXON_COUNT)); |
} |
else { |
setStatusText((startIndex + 1) + " - " + count); |
} |
} |
} |
|
|
|
else { // Pas d'inventaire, pas de navigation |
setStatusText(0 + " - " + 0); |
setStatusText(0 + " - " + 0); |
} |
} |
|
|
|
/** |
* Positionnement index de parcours (this.startIndex) pour affichage de la |
* dernière page |
* |
* @param |
* @return void |
* Positionnement index de parcours (this.startIndex) pour affichage de la dernière page |
* @param |
* @return void |
*/ |
|
|
private void gotoEnd() { |
|
if ((count == 0) || (count % VISIBLE_TAXON_COUNT) > 0) { |
startIndex = count - (count % VISIBLE_TAXON_COUNT); |
} else { |
startIndex = count - VISIBLE_TAXON_COUNT; |
} |
|
|
if ( (count==0) || (count%VISIBLE_TAXON_COUNT)>0) { |
startIndex=count-(count%VISIBLE_TAXON_COUNT); |
} |
else { |
startIndex=count-VISIBLE_TAXON_COUNT; |
} |
|
} |
|
|
} |