New file |
0,0 → 1,234 |
package org.tela_botanica.client.vues; |
|
import org.tela_botanica.client.CarnetEnLigneMediateur; |
import org.tela_botanica.client.i18n.Msg; |
import org.tela_botanica.client.interfaces.Rafraichissable; |
import org.tela_botanica.client.modeles.objets.Utilisateur; |
|
import com.google.gwt.user.client.Timer; |
import com.gwtext.client.core.EventCallback; |
import com.gwtext.client.core.EventObject; |
import com.gwtext.client.core.ListenerConfig; |
import com.gwtext.client.data.ArrayReader; |
import com.gwtext.client.data.FieldDef; |
import com.gwtext.client.data.MemoryProxy; |
import com.gwtext.client.data.Record; |
import com.gwtext.client.data.RecordDef; |
import com.gwtext.client.data.Store; |
import com.gwtext.client.data.StringFieldDef; |
import com.gwtext.client.widgets.Panel; |
import com.gwtext.client.widgets.Window; |
import com.gwtext.client.widgets.event.ButtonListenerAdapter; |
import com.gwtext.client.widgets.form.ComboBox; |
import com.gwtext.client.widgets.form.event.ComboBoxListenerAdapter; |
import com.gwtext.client.widgets.layout.HorizontalLayout; |
import com.gwtext.client.widgets.layout.RowLayout; |
|
public class ListeUtilisateurAdminVue extends Window implements Rafraichissable { |
|
private CarnetEnLigneMediateur cMediateur = null ; |
private ComboBox listeUtil = null ; |
private Store storeUtil = null ; |
private com.gwtext.client.widgets.Button OK = null; |
private com.gwtext.client.widgets.Button annuler = null; |
private boolean selectionUtilisateur =false; |
|
public String utilisateur = null; |
public String idUtilisateur = null; |
|
private final int KEY_ALT = 18; |
private final int KEY_BACKSPACE = 8; |
private final int KEY_CTRL = 17; |
private final int KEY_DELETE = 46; |
private final int KEY_DOWN = 40; |
private final int KEY_END = 35; |
private final int KEY_ENTER = 13; |
private final int KEY_ESCAPE = 27; |
private final int KEY_HOME = 36; |
private final int KEY_LEFT = 37; |
private final int KEY_PAGEDOWN = 34; |
private final int KEY_PAGEUP = 33; |
private final int KEY_RIGHT = 39; |
private final int KEY_SHIFT = 16; |
private final int KEY_TAB = 9; |
private final int KEY_UP = 38; |
|
private Timer timerCompletion = null; |
|
public ListeUtilisateurAdminVue(CarnetEnLigneMediateur cMed) { |
super(Msg.get("choisir-utilisateur")) ; |
|
this.cMediateur = cMed; |
|
listeUtil=new ComboBox(Msg.get("utilisateurs"),"courriel",280); |
|
this.setLayout(new RowLayout()); |
|
final String resultTplUtil = "<div class=\"search-item-utilisateur\">{courriel}</div>"; |
|
utilisateur = cMediateur.getUtilisateur().getLoginUtilisateurConsulte(); |
idUtilisateur = Utilisateur.getInstance().getIdentifiantUtilisateurConsulte(); |
|
listeUtil.setTpl(resultTplUtil); |
listeUtil.setMode(ComboBox.REMOTE); |
listeUtil.setItemSelector("div.search-item-utilisateur"); |
listeUtil.setHideTrigger(true); |
|
listeUtil.setDisplayField("courriel"); |
|
listeUtil.setLoadingText(Msg.get("en-recherche")+"..."); |
listeUtil.setValue(utilisateur); |
|
OK= new com.gwtext.client.widgets.Button(Msg.get("ok")); |
annuler = new com.gwtext.client.widgets.Button(Msg.get("annuler")); |
|
Panel boutonPanel = new Panel(); |
boutonPanel.setLayout(new HorizontalLayout(0)); |
|
add(listeUtil); |
|
boutonPanel.add(OK); |
boutonPanel.add(annuler); |
|
add(boutonPanel); |
|
this.setSize(300, 75); |
|
OK.addListener(new ButtonListenerAdapter() { |
|
@Override |
public void onClick(com.gwtext.client.widgets.Button button, |
EventObject e) { |
if(valider()) { |
cMediateur.changerIdentite(idUtilisateur,utilisateur); |
close(); |
} |
} |
}); |
|
annuler.addListener(new ButtonListenerAdapter() { |
|
@Override |
public void onClick(com.gwtext.client.widgets.Button button, |
EventObject e) { |
close(); |
} |
}); |
|
ListenerConfig listenerConfigAutocompletion=new ListenerConfig(); |
listenerConfigAutocompletion.setDelay(200); |
listenerConfigAutocompletion.setStopPropagation(false); |
listenerConfigAutocompletion.setStopEvent(false); |
|
listeUtil.addKeyPressListener(new EventCallback() { |
|
@Override |
public void execute(EventObject e) { |
|
switch(e.getKey()) { |
|
case KEY_ALT: |
case KEY_CTRL: |
case KEY_DOWN: |
case KEY_END: |
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; |
|
case KEY_ENTER: |
|
if(selectionUtilisateur) { |
selectionUtilisateur=false; |
} |
else { |
if(valider()) { |
cMediateur.changerIdentite(idUtilisateur,utilisateur); |
} |
close(); |
} |
break; |
|
default: |
if(timerCompletion != null) { |
timerCompletion.cancel(); |
} |
timerCompletion = new Timer() { |
public void run() { |
obtenirListeUtilisateur(); |
} |
}; |
timerCompletion.schedule(250); |
break; |
} |
} |
}, listenerConfigAutocompletion); |
|
listeUtil.addListener(new ComboBoxListenerAdapter() { |
|
@Override |
public void onSelect(ComboBox comboBox, Record record, int index) { |
|
utilisateur = record.getAsString("courriel"); |
idUtilisateur = record.getAsString("id_utilisateur"); |
listeUtil.setValue(utilisateur); |
|
} |
}); |
} |
|
@Override |
public void rafraichir(Object nouvelleDonnees, |
boolean repandreRaffraichissement) { |
|
if(nouvelleDonnees instanceof String[][]) { |
|
Object[][] utilData = (Object[][])nouvelleDonnees ; |
|
FieldDef defId = new StringFieldDef("id_utilisateur"); |
FieldDef defCourriel = new StringFieldDef("courriel"); |
FieldDef[] defTab = {defId,defCourriel}; |
|
RecordDef rd = new RecordDef(defTab); |
|
final MemoryProxy dataProxy = new MemoryProxy(utilData); |
final ArrayReader reader = new ArrayReader(rd); |
|
storeUtil =new Store(dataProxy,reader); |
storeUtil.load() ; |
|
listeUtil.setStore(storeUtil); |
|
// Tentative de corriger un bug insupportable de la taille de la liste |
// mais ça ne marche pas à tous les coups |
listeUtil.collapse(); |
listeUtil.expand(); |
} |
|
} |
|
private boolean valider() { |
if(listeUtil.getValue() != null) { |
return true; |
} |
return false; |
} |
|
public void obtenirListeUtilisateur() { |
|
String valeur = listeUtil.getRawValue(); |
cMediateur.obtenirListeUtilisateurs(valeur,this) ; |
} |
|
public void focusChampUtilisateur() { |
listeUtil.focus(); |
} |
|
} |
Property changes: |
Added: svn:ignore |
+.project |
+tomcat |
Added: svn:mergeinfo |
Merged /branches/v1.0-beche/src/org/tela_botanica/client/vues/ListeUtilisateurAdminVue.java:r290-316 |