/trunk/src/org/tela_botanica/client/AutoCompleteAsyncTextBox.java |
---|
21,10 → 21,13 |
// TODO : traiter latence (augmenter en fonction rapidité saisie + texte vide) |
// TODO : traitement espace apres l'espece (%20) |
// TODO : traiter Tab (selection) |
// TODO : revoir traitement keyup, keydown |
// TODO : reactiver le cache (du design à revoir dans ce cas la) |
import com.google.gwt.user.client.HTTPRequest; |
import com.google.gwt.user.client.ResponseTextHandler; |
import com.google.gwt.user.client.ui.ChangeListener; |
import com.google.gwt.user.client.ui.KeyboardListener; |
import com.google.gwt.user.client.ui.ListBox; |
import com.google.gwt.user.client.ui.PopupPanel; |
31,8 → 34,6 |
import com.google.gwt.user.client.ui.RootPanel; |
import com.google.gwt.user.client.ui.TextBox; |
import com.google.gwt.user.client.ui.Widget; |
import com.google.gwt.user.client.DOM; |
import com.google.gwt.user.client.Event; |
import java.util.Vector; |
import java.util.HashMap; |
40,7 → 41,7 |
public class AutoCompleteAsyncTextBox extends TextBox |
implements KeyboardListener, SourcesAutoCompleteAsyncTextBoxEvents { |
implements KeyboardListener, ChangeListener, SourcesAutoCompleteAsyncTextBoxEvents { |
private String searchUrl = null; |
private AutoCompleteAsyncTextBoxListenerCollection autoCompleteAsyncTextBoxListeners=null; |
50,13 → 51,7 |
private ResponseTextHandler responseTextHandler=null; |
protected PopupPanel choicesPopup = new PopupPanel(true); |
protected ListBox choices = new ListBox() { |
public void onBrowserEvent(Event event) { |
if (Event.ONCLICK == DOM.eventGetType(event)) { |
complete(); |
} |
} |
}; |
protected ListBox choices = new ListBox(); |
protected Vector items = new Vector(); |
protected boolean popupAdded = false; |
protected boolean visible = false; |
63,7 → 58,6 |
protected String currentValue = null; |
/** |
* Default Constructor |
* |
73,7 → 67,7 |
super(); |
responseTextHandler=rsp; |
this.addKeyboardListener(this); |
choices.sinkEvents(Event.ONCLICK); |
choices.addChangeListener(this); |
this.setStyleName("AutoCompleteAsyncTextBox"); |
choicesPopup.add(choices); |
118,38 → 112,15 |
* Not used at all |
*/ |
public void onKeyDown(Widget arg0, char arg1, int arg2) { |
if(arg1 == KEY_ENTER) |
{ |
enterKey(arg0, arg1, arg2); |
} |
else if(arg1 == KEY_DOWN) |
{ |
downKey(arg0, arg1, arg2); |
} |
else if(arg1 == KEY_UP) |
{ |
upKey(arg0, arg1, arg2); |
} |
else if(arg1 == KEY_ESCAPE) |
{ |
escapeKey(arg0, arg1, arg2); |
} |
} |
/** |
* Not used at all (probleme avec ie, qui ne comprend pas les touches meta) |
* Not used at all |
*/ |
public void onKeyPress(Widget arg0, char arg1, int arg2) { |
} |
// The down key was pressed. |
protected void downKey(Widget arg0, char arg1, int arg2) { |
if(arg1 == KEY_DOWN) |
{ |
int selectedIndex = choices.getSelectedIndex(); |
selectedIndex++; |
if (selectedIndex >= choices.getItemCount()) |
157,10 → 128,12 |
selectedIndex = 0; |
} |
choices.setSelectedIndex(selectedIndex); |
return; |
} |
// The up key was pressed. |
protected void upKey(Widget arg0, char arg1, int arg2) { |
if(arg1 == KEY_UP) |
{ |
int selectedIndex = choices.getSelectedIndex(); |
selectedIndex--; |
if(selectedIndex < 0) |
168,16 → 141,40 |
selectedIndex = choices.getItemCount() - 1; |
} |
choices.setSelectedIndex(selectedIndex); |
return; |
} |
// The enter key was pressed. |
protected void enterKey(Widget arg0, char arg1, int arg2) { |
} |
/** |
* A key was released, start autocompletion |
*/ |
public void onKeyUp(Widget arg0, char arg1, int arg2) { |
if(arg1 == KEY_DOWN) |
{ |
return; |
} |
if(arg1 == KEY_UP) |
{ |
return; |
} |
if(arg1 == KEY_ENTER) |
{ |
if(visible) |
{ |
complete(); |
} |
else { |
// Validation de l'entree : appel asynchrone |
// Validation de l'entree : |
if (autoCompleteAsyncTextBoxListeners!= null) { |
autoCompleteAsyncTextBoxListeners.fireTextBoxEnter(this,this.getText(),currentValue); |
} |
185,29 → 182,25 |
this.setText(""); |
} |
return; |
} |
//The escape key was pressed. |
protected void escapeKey(Widget arg0, char arg1, int arg2) { |
if(arg1 == KEY_ESCAPE) |
{ |
choices.clear(); |
items.clear(); |
choicesPopup.hide(); |
visible = false; |
return; |
} |
// Any other non-special key was pressed. |
protected void otherKey(Widget arg0, char arg1, int arg2) { |
// Lancement appel |
String text = this.getText(); |
if(text.length() > 0) |
{ |
items.clear(); |
if (getFromCache(text)!=null) { |
219,38 → 212,9 |
this.doFetchURL(text); |
} |
} |
} |
public void onKeyUp(Widget arg0, char arg1, int arg2) { |
switch(arg1) { |
case KEY_ALT: |
case KEY_CTRL: |
case KEY_DOWN: |
case KEY_END: |
case KEY_ENTER: |
case KEY_ESCAPE: |
case KEY_HOME: |
case KEY_LEFT: |
case KEY_PAGEDOWN: |
case KEY_PAGEUP: |
case KEY_RIGHT: |
case KEY_SHIFT: |
case KEY_TAB: |
case KEY_UP: |
break; |
default: |
otherKey(arg0, arg1, arg2); |
break; |
} |
} |
// Display assistant |
public void displayList() { |
271,10 → 235,10 |
// if there is only one match and it is what is in the |
// text field anyways there is no need to show autocompletion |
// if(items.size() == 1 && (((String []) items.get(0))[0]).compareTo(this.getText()) == 0) |
// { |
// choicesPopup.hide(); |
// } else { |
if(items.size() == 1 && (((String []) items.get(0))[0]).compareTo(this.getText()) == 0) |
{ |
choicesPopup.hide(); |
} else { |
choices.setSelectedIndex(0); |
choices.setVisibleItemCount(items.size()); |
287,9 → 251,9 |
visible = true; |
choicesPopup.setPopupPosition(this.getAbsoluteLeft(), |
this.getAbsoluteTop() + this.getOffsetHeight()); |
choicesPopup.setWidth(this.getOffsetWidth() + "px"); |
//choicesPopup.setWidth(this.getOffsetWidth() + "px"); |
choices.setWidth(this.getOffsetWidth() + "px"); |
// } |
} |
} else { |
visible = false; |
304,7 → 268,6 |
complete(); |
} |
public void onClick(Widget arg0) { |
complete(); |
} |
/trunk/src/org/tela_botanica/client/CenterPanel.java |
---|
1,9 → 1,10 |
package org.tela_botanica.client; |
import com.google.gwt.user.client.ui.Composite; |
import com.google.gwt.user.client.ui.DockPanel; |
import com.google.gwt.user.client.ui.HTML; |
import com.google.gwt.user.client.ui.VerticalPanel; |
import com.google.gwt.user.client.ui.Button; |
import com.google.gwt.user.client.ui.ClickListener; |
import com.google.gwt.user.client.ui.Widget; |
import org.tela_botanica.client.TaxonList; |
22,20 → 23,23 |
public CenterPanel() { |
VerticalPanel outer = new VerticalPanel(); |
DockPanel inner = new DockPanel(); |
VerticalPanel inner = new VerticalPanel(); |
inner.add(nameAssistant); |
inner.add(new Button("Suppression", |
new ClickListener() { |
public void onClick(Widget sender) { |
taxonList.deleteElement(); |
} |
} |
) |
); |
nameAssistant.setWidth("50%"); |
inner.add(new HTML("Nom: "),DockPanel.WEST); |
inner.add (nameAssistant,DockPanel.CENTER); |
nameAssistant.setWidth("40%"); |
inner.setCellWidth(nameAssistant,"100%"); |
outer.add(inner); |
inner.setWidth("100%"); |
outer.add(inner); |
outer.add(taxonList); |
taxonList.setWidth("100%"); |
43,4 → 47,3 |
} |
} |
/trunk/src/org/tela_botanica/client/TaxonList.java |
---|
36,8 → 36,6 |
import com.google.gwt.user.client.ui.ClickListener; |
import com.google.gwt.user.client.ui.HasHorizontalAlignment; |
import com.google.gwt.user.client.ui.HasVerticalAlignment; |
import com.google.gwt.user.client.ui.Label; |
import com.google.gwt.user.client.Window; |
/* |
* Le retour de getUser appelle getCount qui appelle update pour veiller à une |
64,7 → 62,6 |
public final HTML status = new HTML(); |
public NavBar() { |
initWidget(bar); |
bar.setStyleName("navbar"); |
71,15 → 68,6 |
status.setStyleName("status"); |
HorizontalPanel buttons = new HorizontalPanel(); |
buttons.add(status); |
buttons.setCellHorizontalAlignment(status, |
HasHorizontalAlignment.ALIGN_RIGHT); |
buttons.setCellVerticalAlignment(status, |
HasVerticalAlignment.ALIGN_MIDDLE); |
buttons.setCellWidth(status, "100%"); |
buttons.add(gotoFirst); |
buttons.add(gotoPrev); |
buttons.add(gotoNext); |
86,82 → 74,14 |
buttons.add(gotoEnd); |
bar.add(buttons, DockPanel.EAST); |
bar.setCellHorizontalAlignment(buttons, DockPanel.ALIGN_RIGHT); |
VerticalPanel actions = new VerticalPanel(); |
HorizontalPanel actionButton = new HorizontalPanel(); |
/* |
actionButton.add(new Button("Ajout", |
new ClickListener() { |
public void onClick(Widget sender) { |
deleteElement(); |
} |
} |
)); |
*/ |
actionButton.add(new Button("Suppression", |
new ClickListener() { |
public void onClick(Widget sender) { |
deleteElement(); |
} |
} |
)); |
actionButton.add(new Button("Tout exporter", |
new ClickListener() { |
public void onClick(Widget sender) { |
exportAll(); |
} |
} |
)); |
actions.add(actionButton); |
HorizontalPanel selections = new HorizontalPanel(); |
selections.setSpacing(3); |
actions.add(selections); |
selections.add(new HTML("Sélection : ")); |
Label all = new Label("Tous,"); |
Label none = new Label("Aucun"); |
selections.add(all); |
all.addClickListener( |
new ClickListener() { |
public void onClick(Widget sender) { |
selectAll(); |
} |
} |
); |
selections.add(none); |
none.addClickListener( |
new ClickListener() { |
public void onClick(Widget sender) { |
deselectAll(); |
} |
} |
); |
bar.add(actions, DockPanel.WEST); |
bar.setCellHorizontalAlignment(buttons, DockPanel.ALIGN_LEFT); |
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 void onClick(Widget sender) { |
387,27 → 307,7 |
} |
/** |
* Selection de l'ensemble des elements affichés |
* |
*/ |
public void selectAll() { |
for (int i = table.getRowCount() - 1; i >= 0; i--) { |
((CheckBox) table.getWidget(i, 0)).setChecked(true); |
} |
} |
public void deselectAll() { |
for (int i = table.getRowCount() - 1; i >= 0; i--) { |
((CheckBox) table.getWidget(i, 0)).setChecked(false); |
} |
} |
/** |
* |
* 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 |
597,9 → 497,9 |
navBar.gotoNext.setEnabled(true); |
navBar.gotoEnd.setEnabled(true); |
setStatusText((startIndex + 1) + " - " |
+ (startIndex + VISIBLE_TAXON_COUNT) + " sur " + count ); |
+ (startIndex + VISIBLE_TAXON_COUNT)); |
} else { // Derniere page |
setStatusText((startIndex + 1) + " - " + count + " sur " + count ); |
setStatusText((startIndex + 1) + " - " + count); |
} |
} else { // Premiere page |
if (count > VISIBLE_TAXON_COUNT) { // Des pages derrieres |
606,19 → 506,19 |
navBar.gotoNext.setEnabled(true); |
navBar.gotoEnd.setEnabled(true); |
setStatusText((startIndex + 1) + " - " |
+ (startIndex + VISIBLE_TAXON_COUNT) + " sur " + count); |
+ (startIndex + VISIBLE_TAXON_COUNT)); |
} else { |
setStatusText((startIndex + 1) + " - " + count + " sur " + count); |
setStatusText((startIndex + 1) + " - " + count); |
} |
} |
} |
else { // Pas d'inventaire, pas de navigation |
setStatusText("0 - 0 sur 0"); |
setStatusText(0 + " - " + 0); |
} |
} |
/* |
/** |
* Positionnement index de parcours (this.startIndex) pour affichage de la |
* dernière page |
* |
636,17 → 536,4 |
} |
/* |
* Export du releve affiche dans un format tableur |
* |
* @param |
* @return void |
*/ |
private void exportAll() { |
Window.open(serviceBaseUrl+"/InventoryExport/" +user + "/","_self",""); |
} |
} |
/trunk/src/org/tela_botanica/client/NameAssistant.java |
---|
28,7 → 28,6 |
public NameAssistant(AutoCompleteAsyncTextBoxListener listener) { |
// autoCompletebox.setFocus(true); |
autoCompletebox.setSearchUrl(getServiceBaseUrl()+"/NameSearch/"); |
panel.add(autoCompletebox); |
/trunk/src/org/tela_botanica/public/Cel.html |
---|
19,7 → 19,7 |
<script type="text/javascript"> |
var Parameters = { |
serviceBaseUrl: "http://192.168.0.32/david/jrest" |
serviceBaseUrl: "http://localhost/david/jrest" |
}; |