/trunk/src/org/tela_botanica/client/StationList.java |
---|
File deleted |
/trunk/src/org/tela_botanica/client/LoginDialog.java |
---|
File deleted |
/trunk/src/org/tela_botanica/client/Cel.java |
---|
3,7 → 3,6 |
import com.google.gwt.core.client.EntryPoint; |
import com.google.gwt.user.client.Command; |
import com.google.gwt.user.client.DeferredCommand; |
import com.google.gwt.user.client.History; |
import com.google.gwt.user.client.Window; |
import com.google.gwt.user.client.WindowResizeListener; |
import com.google.gwt.user.client.ui.DockPanel; |
39,7 → 38,7 |
mediator.registerCel(this); |
mediator.initUser(); // Appelle initAsync suivant |
} |
public void initAsync() { |
63,11 → 62,12 |
entryPanel.setStyleName("item-Input"); |
rightPanel.add(searchPanel); |
rightPanel.add(actionPanel); |
rightPanel.add(centerPanel); |
rightPanel.add(entryPanel); |
rightPanel.add(centerPanel); |
rightPanel.add(actionPanel); |
rightPanel.setWidth("100%"); |
centerPanel.setWidth("100%"); |
93,7 → 93,7 |
outer.setWidth("100%"); |
outer.setSpacing(2); |
outer.setSpacing(4); |
outer.setCellWidth(rightPanel, "100%"); |
// Window.enableScrolling(false); |
/trunk/src/org/tela_botanica/client/LocationList.java |
---|
144,6 → 144,7 |
private String serviceBaseUrl = null; |
private String location = "all"; |
private NavBar navBar=null; |
234,11 → 235,9 |
selectRow(row); |
String loc=table.getText(row,cell); |
if (loc.compareTo(VALUE_UNKNOWN)!=0) { |
location=loc; |
mediator.onLocationSelected(table.getText(row,cell)); |
} |
else { |
location="000null"; |
mediator.onLocationSelected("000null"); |
} |
269,8 → 268,7 |
setStatusDisabled(); |
// HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryLocationList/" + user + "/" + location + "/" , |
HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryLocationList/" + user , |
HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryLocationList/" + user + "/" + location , |
new ResponseTextHandler() { |
public void onCompletion(String str) { |
278,6 → 276,7 |
JSONNumber jsonNumber; |
if ((jsonNumber = jsonValue.isNumber()) != null) { |
count = (int) jsonNumber.getValue(); |
mediator.onLocationUpdate(location); |
update(); |
} |
} |
322,8 → 321,7 |
setStatusDisabled(); |
// HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryLocationList/" + user + "/" + location + "/" + |
HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryLocationList/" + user + "/" + |
HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryLocationList/" + user + "/" + location + "/" |
+ startIndex + "/" + VISIBLE_LOCATION_COUNT, |
new ResponseTextHandler() { |
480,9 → 478,5 |
private void setStatusText(String text) { |
navBar.status.setText(text); |
} |
public void setUser(String user) { |
this.user = user; |
} |
} |
/trunk/src/org/tela_botanica/client/Mediator.java |
---|
5,14 → 5,11 |
// TODO : sortie les boutons supprimer et exporter et inclure ici |
import com.google.gwt.i18n.client.Dictionary; |
import com.google.gwt.json.client.JSONArray; |
import com.google.gwt.json.client.JSONBoolean; |
import com.google.gwt.json.client.JSONParser; |
import com.google.gwt.json.client.JSONString; |
import com.google.gwt.json.client.JSONValue; |
import com.google.gwt.user.client.HTTPRequest; |
import com.google.gwt.user.client.ResponseTextHandler; |
import com.google.gwt.user.client.ui.Label; |
import com.google.gwt.user.client.ui.TextBox; |
public class Mediator { |
23,7 → 20,6 |
private InventoryItemList inventoryItemList = null; |
private LocationList locationList = null; |
private DateList dateList = null; |
private StationList stationList = null; |
private NameAssistant nameAssistant=null; |
private LocationAssistant locationAssistant=null; |
private InventoryItem inventoryItem=null; |
30,14 → 26,12 |
private EntryPanel entryPanel=null; |
private ActionPanel actionPanel=null; |
private SearchPanel searchPanel=null; |
private LoginDialog loginDialog=null; |
private TopPanel topPanel=null; |
private TextBox date = null; |
private TextBox complementLocation = null; |
private TextBox comment = null; |
boolean connected=false; |
private Cel cel = null; |
66,31 → 60,12 |
public void onInit() { |
locationList.setLocation("all"); |
locationList.updateCount(); |
this.onLocationSelected("all"); |
} |
/** |
* Action suite ajout, modification, suppression element inventaire |
*/ |
public void onInventoryUpdated(String location) { |
locationList.setLocation(location); |
locationList.updateCount(); |
this.onLocationSelected(location); |
} |
/** |
* Action sur selection d'une observation : affichage du detail |
*/ |
105,7 → 80,7 |
/** |
* Action sur recherche : affichage de la liste des taxons correspondants |
* Action sur selection d'un lieu : affichage de la liste des taxons correspondants |
*/ |
public void onSearch(String search) { |
122,7 → 97,6 |
/** |
* Action sur selection d'un lieu : affichage de la liste des taxons correspondants |
* TODO : gerer asynchronicite ? |
*/ |
public void onLocationSelected(String loc) { |
129,86 → 103,68 |
inventoryItemList.setLocation(loc); |
inventoryItemList.setDate("all"); |
inventoryItemList.setStation("all"); |
inventoryItemList.updateCount(); |
dateList.setLocation(loc); |
dateList.setDate("all"); |
dateList.updateCount(); |
stationList.setLocation(loc); |
stationList.setStation("all"); |
stationList.updateCount(); |
if ((loc.compareTo("000null")==0) || (loc.compareTo("all")==0)) { |
locationAssistant.setText(""); |
} |
else { |
locationAssistant.setText(loc); |
} |
} |
/** |
* Action sur login |
* @param user |
* Action sur selection d'une date : affichage de la liste des taxons correspondants |
*/ |
public void onDateSelected(String date) { |
inventoryItemList.setDate(date); |
inventoryItemList.updateCount(); |
/* |
if ((loc.compareTo("000null")==0) || (loc.compareTo("all")==0)) { |
locationAssistant.setText(""); |
} |
else { |
locationAssistant.setText(loc); |
} |
*/ |
public void onLogin(String user) { |
this.user=user; |
topPanel.getSignLabel().setText(user+ " (deconnexion)"); |
inventoryItemList.setUser(user); |
dateList.setUser(user); |
stationList.setUser(user); |
entryPanel.setUser(user); |
locationList.setUser(user); |
this.onInit(); |
} |
/** |
* Action sur logoff |
* @param user |
* Action posterieure à l'affichage des observations : mise a jour affichage des localites |
*/ |
public void onLogoff(String user) { |
this.user=user; |
topPanel.getSignLabel().setText("Connexion"); |
inventoryItemList.setUser(user); |
dateList.setUser(user); |
stationList.setUser(user); |
entryPanel.setUser(user); |
locationList.setUser(user); |
this.onInit(); |
} |
public void onInventoryItemUpdate(String loc) { |
/** |
* Action sur selection d'une station : affichage de la liste des taxons correspondants |
*/ |
locationList.setLocation(loc); |
locationList.updateCount(); |
public void onStationSelected(String station) { |
inventoryItemList.setStation(station); |
inventoryItemList.updateCount(); |
} |
/** |
* Action sur selection d'une date : affichage de la liste des taxons correspondants |
* Action posterieure à l'affichage des localites : mise a jour affichage des dates |
*/ |
public void onDateSelected(String date) { |
inventoryItemList.setDate(date); |
inventoryItemList.updateCount(); |
public void onLocationUpdate(String loc) { |
dateList.setLocation(loc); |
dateList.updateCount(); |
} |
/** |
* Action prealable à l'ajout d'une observation : controle presence champs requis et lancement mise a jour |
* |
296,18 → 252,7 |
} |
/** |
* Declaration StationList |
* @param locationList |
*/ |
public void registerStationList(StationList stationList) { |
this.stationList=stationList; |
} |
/** |
* Declaration Cel |
* @param cel |
380,18 → 325,7 |
this.searchPanel=searchPanel; |
} |
public void registerTopPanel(TopPanel topPanel) { |
this.topPanel=topPanel; |
} |
public void registerLoginDialog(LoginDialog loginDialog) { |
this.loginDialog=loginDialog; |
} |
/** |
* Declaration commentaire |
* @param commentaire |
419,10 → 353,9 |
public void onCompletion(String str) { |
JSONValue jsonValue = JSONParser.parse(str); |
JSONArray jsonArray; |
if ((jsonArray = jsonValue.isArray()) != null) { |
user = ((JSONString) jsonArray.get(0)).stringValue(); |
connected = ((JSONBoolean) jsonArray.get(1)).booleanValue(); |
JSONString jsonString; |
if ((jsonString = jsonValue.isString()) != null) { |
user = jsonString.stringValue(); |
} |
cel.initAsync(); |
} |
463,14 → 396,8 |
public String getUser() { |
return user; |
} |
public void setUser(String user) { |
this.user=user; |
} |
public InventoryItemList getInventoryItemList() { |
return inventoryItemList; |
502,15 → 429,5 |
} |
public void setConnected(boolean connected) { |
this.connected=connected; |
} |
public boolean getConnected() { |
return this.connected; |
} |
} |
/trunk/src/org/tela_botanica/client/InventoryItemList.java |
---|
30,7 → 30,6 |
import com.google.gwt.user.client.ui.Grid; |
import com.google.gwt.user.client.ui.HTML; |
import com.google.gwt.user.client.ui.HorizontalPanel; |
import com.google.gwt.user.client.ui.Image; |
import com.google.gwt.user.client.ui.SourcesTableEvents; |
import com.google.gwt.user.client.ui.TableListener; |
import com.google.gwt.user.client.ui.VerticalPanel; |
159,7 → 158,6 |
private String location = "all"; |
private String date = "all"; |
private String search = "all"; |
private String station = "all"; |
private boolean add=false; |
215,7 → 213,7 |
if (table.getWidget(row, 0)!=null) { |
selectRow(row); |
// Numero d'ordre |
mediator.onInventoryItemSelected(table.getText(row, 5)); |
mediator.onInventoryItemSelected(table.getText(row, 4)); |
} |
} |
427,7 → 425,6 |
location="000null"; |
} |
add=true; |
mediator.onInventoryUpdated(location); |
updateCount(); |
} |
}); |
457,8 → 454,8 |
String num_nom_ret, String num_taxon, String famille,final String loc, String id_location,String dat, String complementLocation, String comment) { |
HTTPRequest.asyncPost(serviceBaseUrl + "/Inventory/" + user + "/" +ordre + "/", |
"&nom_sel=" + nom_sel + "&num_nom_sel=" + num_nom_sel |
HTTPRequest.asyncPost(serviceBaseUrl + "/Inventory/" +ordre + "/", "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 + "&location=" + loc + "&id_location=" + id_location + "&date_observation=" + dat |
+ "&station="+ complementLocation + "&commentaire="+ comment, |
467,58 → 464,12 |
public void onCompletion(String str) { |
add=false; |
mediator.onInventoryUpdated(location); |
update(); |
} |
}); |
} |
/** |
* Transmission de releve à Tela |
* |
*/ |
public void transmitElement() { |
setStatusDisabled(); |
Vector parseChecked = new Vector(); |
// TODO : optimiser |
// Lifo ... |
for (int i = table.getRowCount() - 1; i >= 0; i--) { |
if (table.getWidget(i, 0)!=null) { |
if (((CheckBox) table.getWidget(i, 0)).isChecked()) { |
// Numero ordre |
parseChecked.add(table.getText(i, 5)); |
} |
} |
} |
StringBuffer ids=new StringBuffer(); |
for (Iterator it = parseChecked.iterator(); it.hasNext();) { |
ids.append((String)it.next()); |
if (it.hasNext()) ids.append(","); |
} |
if (ids.length()>0) { |
HTTPRequest.asyncPost(serviceBaseUrl + "/InventoryTransmit/" + user |
+ "/" + ids.toString(), "transmission=1", |
new ResponseTextHandler() { |
public void onCompletion(String str) { |
update(); |
} |
}); |
} |
setStatusEnabled(); |
} |
/** |
* Suppression d'un element lde l'inventaire, a partir de son numero d'ordre |
* |
527,6 → 478,7 |
public void deleteElement() { |
setStatusDisabled(); |
boolean checked = false; |
Vector parseChecked = new Vector(); |
// TODO : optimiser |
534,8 → 486,9 |
for (int i = table.getRowCount() - 1; i >= 0; i--) { |
if (table.getWidget(i, 0)!=null) { |
if (((CheckBox) table.getWidget(i, 0)).isChecked()) { |
checked = true; |
// Numero ordre |
parseChecked.add(table.getText(i, 5)); |
parseChecked.add(table.getText(i, 4)); |
count--; |
} |
} |
545,20 → 498,18 |
ids.append((String)it.next()); |
if (it.hasNext()) ids.append(","); |
} |
if (ids.length()>0) { |
HTTPRequest.asyncPost(serviceBaseUrl + "/Inventory/" + user |
+ "/" + ids.toString(), "action=DELETE", |
new ResponseTextHandler() { |
public void onCompletion(String str) { |
mediator.onInventoryUpdated("all"); |
updateCount(); |
} |
}); |
HTTPRequest.asyncPost(serviceBaseUrl + "/Inventory/" + user |
+ "/" + ids.toString(), "action=DELETE", |
new ResponseTextHandler() { |
public void onCompletion(String str) { |
updateCount(); |
} |
}); |
if (!checked) { |
setStatusEnabled(); |
} |
setStatusEnabled(); |
} |
/** |
599,7 → 550,7 |
adate=date.substring(6,10)+"-"+date.substring(3,5)+"-"+date.substring(0,2)+" 00:00:00"; |
} |
HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryItemList/" + user + "/" + location + "/" + adate + "/" + search + "/" + station, |
HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryItemList/" + user + "/" + location + "/" + adate + "/" + search, |
new ResponseTextHandler() { |
public void onCompletion(String str) { |
615,7 → 566,7 |
*/ |
if (location.compareTo("")==0) |
location="000null"; |
// mediator.onInventoryItemUpdate(location); |
mediator.onInventoryItemUpdate(location); |
gotoEnd(); // Derniere page |
update(); |
} |
655,7 → 606,7 |
} |
else { |
if (location.compareTo("000null")==0) { |
com="Communes non renseignées"; |
com="Communes non précisées"; |
} |
else { |
com="Commune de "+location; |
666,36 → 617,20 |
String dat; |
if (date.compareTo("all")==0) { |
dat=", toutes périodes"; |
dat=", toute période"; |
} |
else { |
if (date.compareTo("00/00/0000")==0) { |
dat=", périodes non renseignées"; |
dat=", période non précisé"; |
} |
else { |
dat=", le "+ date; |
} |
} |
String stat; |
header.setHTML(0, 0, com + dat ); |
if (station.compareTo("all")==0) { |
stat=", toutes stations"; |
} |
else { |
if (station.compareTo("000null")==0) { |
stat=", stations non renseignées"; |
} |
else { |
stat=", station "+ station; |
} |
} |
header.setHTML(0, 0, com + dat + stat ); |
HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryItemList/" + user + "/" + location +"/" + adate + "/" + search + "/" + station + "/" |
HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryItemList/" + user + "/" + location +"/" + adate + "/" + search + "/" + |
+ startIndex + "/" + VISIBLE_TAXON_COUNT, |
new ResponseTextHandler() { |
709,8 → 644,6 |
StringBuffer left=new StringBuffer(); |
StringBuffer center=new StringBuffer(); |
StringBuffer right=new StringBuffer(); |
int row=0; |
732,20 → 665,8 |
// Case a cocher |
table.setWidget(row, 0, new CheckBox()); |
// Observation transmise |
String atransmit=((JSONString) jsonArrayNested .get(11)).stringValue(); |
if (atransmit.compareTo("1")==0) { |
table.setWidget(row,1,new Image("tela.gif")); |
} |
else { |
table.setWidget(row,1,new HTML(" ")); |
} |
// Nom saisi |
left.append("<b>"+((JSONString) jsonArrayNested .get(0)).stringValue()+"</b>"); |
// Nom retenu |
816,7 → 737,7 |
// Localisation - Lieu dit |
if (alieudit.compareTo("000null")!=0) { |
if (alieudit.compareTo("null")!=0) { |
center.append(", "+alieudit); |
} |
826,8 → 747,11 |
if (acomment.compareTo("null")!=0) { |
center.append(", "+acomment); |
} |
String adate=((JSONString) jsonArrayNested .get(8)).stringValue(); |
// Date |
839,28 → 763,28 |
} |
table.setHTML(row, 2, subLeft(" "+left,40)); |
table.setHTML(row, 3, subLeft(" "+center,120)); |
table.setHTML(row, 4, subLeft(" "+right,25)); |
table.setHTML(row, 1, subLeft(" "+left,40)); |
table.setHTML(row, 2, subLeft(" "+center,120)); |
table.setHTML(row, 3, subLeft(" "+right,25)); |
table.getRowFormatter().removeStyleName(row, "inventoryItem-SelectedRow"); |
table.getCellFormatter().setWidth(row,0,"2%"); |
table.getCellFormatter().setWidth(row,1,"2%"); |
table.getCellFormatter().setWordWrap(row,1,false); |
table.getCellFormatter().setWidth(row,1,"10%"); |
table.getCellFormatter().setWordWrap(row,2,false); |
table.getCellFormatter().setWidth(row,2,"10%"); |
table.getCellFormatter().setWordWrap(row,3,false); |
table.getCellFormatter().setWordWrap(row,4,false); |
table.getCellFormatter().setWidth(row,4,"7%"); |
table.getCellFormatter().setWidth(row,3,"7%"); |
String aordre=((JSONString) jsonArrayNested.get(7)).stringValue(); |
// Numero d'ordre (caché) |
table.setText(row, 5, aordre); |
table.setText(row, 4, aordre); |
if (add){ |
if (i ==(arraySize -1)) { |
875,7 → 799,7 |
} |
} |
table.getCellFormatter().setVisible(row, 5, false); |
table.getCellFormatter().setVisible(row, 4, false); |
} |
891,8 → 815,7 |
table.setHTML(j,2," "); |
table.setHTML(j,3," "); |
table.setHTML(j,4," "); |
table.setHTML(j,5," "); |
table.getCellFormatter().setVisible(j, 5, false); |
table.getCellFormatter().setVisible(j, 4, false); |
table.getRowFormatter().removeStyleName(j, "inventoryItem-SelectedRow"); |
} |
1010,18 → 933,7 |
public void setDate(String date) { |
this.date = date; |
} |
public void setUser(String user) { |
this.user = user; |
} |
public void setStation(String station) { |
this.station = station; |
} |
/trunk/src/org/tela_botanica/client/DateList.java |
---|
237,10 → 237,10 |
public void onCellClicked(SourcesTableEvents sender, int row, int cell) { |
selectRow(row); |
String adate=table.getText(row,cell); |
if (adate.compareTo(VALUE_UNKNOWN)!=0) { |
date=adate; |
mediator.onDateSelected(adate); |
String loc=table.getText(row,cell); |
date=loc; |
if (loc.compareTo(VALUE_UNKNOWN)!=0) { |
mediator.onDateSelected(table.getText(row,cell)); |
} |
else { |
date="00/00/0000"; |
273,8 → 273,7 |
setStatusDisabled(); |
// HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryDateList/" + user + "/" + location + "/"+ station, |
HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryDateList/" + user + "/" + location , |
HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryDateList/" + user + "/" + location, |
new ResponseTextHandler() { |
public void onCompletion(String str) { |
326,7 → 325,6 |
setStatusDisabled(); |
// HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryDateList/" + user + "/" + location + "/" + station + "/" |
HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryDateList/" + user + "/" + location + "/" |
+ startIndex + "/" + VISIBLE_DATE_COUNT, |
486,17 → 484,5 |
private void setStatusText(String text) { |
navBar.status.setText(text); |
} |
public void setUser(String user) { |
this.user = user; |
} |
public void setDate(String date) { |
this.date = date; |
} |
} |
/trunk/src/org/tela_botanica/client/LeftPanel.java |
---|
27,24 → 27,22 |
private LocationList locationList = null; |
private DateList dateList = null; |
private StationList stationList = null; |
public LeftPanel(Mediator mediator) { |
dateList = new DateList(mediator); |
locationList = new LocationList(mediator); |
stationList = new StationList(mediator); |
dateList.setStyleName("dateList"); |
locationList.setStyleName("locationList"); |
locationList.setStyleName("stationList"); |
StackPanel outer = new StackPanel(); |
outer.add(locationList,"Communes"); |
outer.add(dateList,"Dates"); |
// Create the groups within the stack panel. |
outer.add(locationList, "<b>Localités</b>", true); |
outer.add(stationList,"<b>Stations</b>",true); |
outer.add(dateList, "<b>Dates</b>", true); |
/trunk/src/org/tela_botanica/client/EntryPanel.java |
---|
18,14 → 18,11 |
import java.util.Date; |
import com.google.gwt.json.client.JSONArray; |
import com.google.gwt.json.client.JSONNull; |
import com.google.gwt.json.client.JSONParser; |
import com.google.gwt.json.client.JSONString; |
import com.google.gwt.json.client.JSONValue; |
import com.google.gwt.user.client.HTTPRequest; |
import com.google.gwt.user.client.History; |
import com.google.gwt.user.client.ResponseTextHandler; |
import com.google.gwt.user.client.Window; |
import com.google.gwt.user.client.ui.Button; |
import com.google.gwt.user.client.ui.ChangeListener; |
import com.google.gwt.user.client.ui.CheckBox; |
86,7 → 83,7 |
VerticalPanel outer = new VerticalPanel(); |
outer.add(new HTML("<b>Saisir un relevé :</b>")); |
// outer.add(new HTML("<b>Nouvelle observation:</b>")); |
104,8 → 101,6 |
locationAssistant = new LocationAssistant(mediator); |
// Saisie Nom |
HTML labelNameAssistant = new HTML("Espèce: "); |
291,51 → 286,14 |
outer.add(inner); |
outer.setCellWidth(inner, "100%"); |
outer.setSpacing(10); |
outer.setSpacing(20); |
outer.setHorizontalAlignment(HorizontalPanel.ALIGN_CENTER); |
outer.add(buttonPanel); |
// Initialisation si provenance d'un lien |
if (History.getToken().length()>0) { |
final String anum=History.getToken(); |
HTTPRequest.asyncGet(serviceBaseUrl + "/Name/" + anum, |
new ResponseTextHandler() { |
public void onCompletion(String strcomplete) { |
JSONValue jsonValue = JSONParser.parse(strcomplete); |
JSONArray jsonArray; |
if ((jsonArray = jsonValue.isArray()) != null) { |
String aname = ((JSONString) jsonArray.get(0)).stringValue(); |
// Nom |
if (aname.compareTo("null")!=0) { |
nameAssistant.setText(((JSONString) jsonArray.get(0)).stringValue()); |
// Numero nomenclatural |
nameAssistant.setValue(anum); |
} |
} |
} |
}); |
} |
initWidget(outer); |
415,7 → 373,7 |
String astation=((JSONString) jsonArray .get(9)).stringValue(); |
// Station |
if (astation.compareTo("000null")!=0) { |
if (astation.compareTo("null")!=0) { |
complementLocation.setText(astation); |
} |
else { |
441,8 → 399,5 |
} |
public void setUser(String user) { |
this.user = user; |
} |
} |
/trunk/src/org/tela_botanica/client/TopPanel.java |
---|
15,117 → 15,32 |
*/ |
package org.tela_botanica.client; |
import com.google.gwt.json.client.JSONArray; |
import com.google.gwt.json.client.JSONBoolean; |
import com.google.gwt.json.client.JSONParser; |
import com.google.gwt.json.client.JSONString; |
import com.google.gwt.json.client.JSONValue; |
import com.google.gwt.user.client.HTTPRequest; |
import com.google.gwt.user.client.ResponseTextHandler; |
import com.google.gwt.user.client.Window; |
import com.google.gwt.user.client.ui.ClickListener; |
import com.google.gwt.user.client.ui.Composite; |
import com.google.gwt.user.client.ui.HTML; |
import com.google.gwt.user.client.ui.HorizontalPanel; |
import com.google.gwt.user.client.ui.Label; |
import com.google.gwt.user.client.ui.Widget; |
import com.google.gwt.user.client.ui.VerticalPanel; |
/** |
* Composite permet de wrapper des Widget pour creer un nouveau Widget cf methode initWidget() |
*/ |
public class TopPanel extends Composite { |
private Mediator mediator=null; |
private String user =null; |
private Label signLabel = new Label() ; |
private String serviceBaseUrl = null; |
public TopPanel(final Mediator med) { |
mediator=med; |
mediator.registerTopPanel(this); |
user=mediator.getUser(); |
signLabel.setStyleName("selection_label"); |
serviceBaseUrl = mediator.getServiceBaseUrl(); |
if (!mediator.getConnected()) { |
signLabel.setText("Connexion"); |
} |
else { |
signLabel.setText(user+ " (deconnexion)"); |
} |
HorizontalPanel outer = new HorizontalPanel(); |
HorizontalPanel inner = new HorizontalPanel(); |
VerticalPanel outer = new VerticalPanel(); |
outer.setHorizontalAlignment(HorizontalPanel.ALIGN_RIGHT); |
inner.add(signLabel); |
inner.add(new HTML("<b>Carnet en ligne</b>")); |
inner.setSpacing(3); |
outer.add(inner); |
outer.add(new HTML("<b>Carnet en ligne</b>")); |
signLabel.addClickListener( |
new ClickListener() { |
public void onClick(Widget sender) { |
if (!mediator.getConnected()) { |
LoginDialog loginDialog = new LoginDialog(med); |
// Position it roughly in the middle of the screen. |
int left = (Window.getClientWidth() - 512) / 2; |
int top = (Window.getClientHeight() - 256) / 2; |
loginDialog.setPopupPosition(left, top); |
loginDialog.show(); |
} |
else { |
HTTPRequest.asyncGet(serviceBaseUrl + "/User/" + user , |
new ResponseTextHandler() { |
public void onCompletion(String str) { |
JSONValue jsonValue = JSONParser.parse(str); |
JSONArray jsonArray; |
if ((jsonArray = jsonValue.isArray()) != null) { |
user = ((JSONString) jsonArray.get(0)).stringValue(); |
mediator.setConnected(((JSONBoolean) jsonArray.get(1)).booleanValue()); |
} |
if (!mediator.getConnected()) { |
mediator.onLogoff(user); |
} |
} |
}); |
} |
} |
} |
); |
initWidget(outer); |
} |
public Label getSignLabel() { |
return signLabel; |
} |
} |
/trunk/src/org/tela_botanica/client/SearchPanel.java |
---|
30,8 → 30,10 |
public class SearchPanel extends Composite { |
private Mediator mediator=null; |
Mediator mediator=null; |
private String serviceBaseUrl = null; |
private String user= null; |
private TextBox search = null; |
48,8 → 50,8 |
// Recherche |
HTML searchButton=new HTML("Rechercher dans les relevés"); |
searchButton.setStyleName("html_button_long"); |
HTML searchButton=new HTML("Rechercher"); |
searchButton.setStyleName("html_button"); |
searchButton.addClickListener( |
new ClickListener() { |
public void onClick(Widget sender) { |
87,6 → 89,9 |
outer.add(searchButton); |
user=mediator.getUser(); |
serviceBaseUrl = mediator.getServiceBaseUrl(); |
initWidget(outer); |
/trunk/src/org/tela_botanica/client/ActionPanel.java |
---|
16,7 → 16,6 |
package org.tela_botanica.client; |
import com.google.gwt.user.client.Window; |
import com.google.gwt.user.client.ui.ClickListener; |
import com.google.gwt.user.client.ui.Composite; |
import com.google.gwt.user.client.ui.HTML; |
41,30 → 40,8 |
HorizontalPanel outer = new HorizontalPanel(); |
HorizontalPanel buttons = new HorizontalPanel(); |
buttons.setSpacing(3); |
outer.setHorizontalAlignment(HorizontalPanel.ALIGN_LEFT); |
// Transmission d'elements |
HTML transButton=new HTML("Transmettre Tela Botanica"); |
transButton.setStyleName("html_button_long"); |
transButton.addClickListener( |
new ClickListener() { |
public void onClick(Widget sender) { |
// TODO : une action dans le mediator |
if (mediator.getConnected()) { |
mediator.getInventoryItemList().transmitElement(); |
} |
else { |
Window.alert("Identifiez-vous pour transmettre"); |
} |
} |
} |
); |
buttons.add(transButton); |
// Suppression d'elements |
HTML delButton=new HTML("Suppression"); |
78,19 → 55,21 |
} |
); |
buttons.add(delButton); |
outer.add(delButton); |
// Export de la totalité |
HTML exportButton=new HTML("<a href=\""+mediator.getServiceBaseUrl()+"/InventoryExport/" +mediator.getUser()+"\">"+"Tout exporter</a>"); |
buttons.add(exportButton); |
HTML exportButton=new HTML("<a href=\""+mediator.getServiceBaseUrl()+"/InventoryExport/" +mediator.getUser()+"\">"+"Tout exporter</a>"); |
outer.add(exportButton); |
exportButton.setStyleName("html_button"); |
outer.setSpacing(5); |
// Selections de l'affichage |
HorizontalPanel selections = new HorizontalPanel(); |
selections.setHorizontalAlignment(HorizontalPanel.ALIGN_LEFT); |
selections.setSpacing(3); |
127,7 → 106,6 |
); |
outer.add(buttons); |
outer.add(selections); |
initWidget(outer); |