13,11 → 13,9 |
import org.tela_botanica.client.modeles.Information; |
import org.tela_botanica.client.util.Debug; |
|
import com.extjs.gxt.ui.client.GXT; |
import com.extjs.gxt.ui.client.event.ButtonEvent; |
import com.extjs.gxt.ui.client.event.SelectionListener; |
import com.extjs.gxt.ui.client.widget.ContentPanel; |
import com.extjs.gxt.ui.client.widget.Info; |
import com.extjs.gxt.ui.client.widget.LayoutContainer; |
import com.extjs.gxt.ui.client.widget.button.Button; |
import com.extjs.gxt.ui.client.widget.custom.Portal; |
74,9 → 72,7 |
|
portail = creerPortail(); |
panneauPrincipal.add(portail); |
|
chargerParametres(); |
|
|
add(panneauPrincipal); |
mediateur.desactiverChargement(this); |
} |
101,7 → 97,6 |
|
private void chargerParametres() { |
viderPortail(); |
|
Document paramXml = XMLParser.parse(mediateur.getUtilisateur().getParametre()); |
NodeList listeAccueilNoeud = paramXml.getElementsByTagName("accueil"); |
int nbreAccueilNoeud = listeAccueilNoeud.getLength(); |
109,37 → 104,41 |
// Récupération du noeud accueil |
Node accueilNoeud = null; |
if (nbreAccueilNoeud == 0) { |
ajouterPortlet(); |
ajouterPortletsDefaut(); |
} else if (nbreAccueilNoeud == 1) { |
accueilNoeud = listeAccueilNoeud.item(0); |
|
// Lecture des noeuds "applette" |
NodeList listeAppletteNoeud = accueilNoeud.getChildNodes(); |
int nbreAppletteNoeud = listeAppletteNoeud.getLength(); |
TreeMap<String, HashMap<String, String>> tableApplettes = new TreeMap<String, HashMap<String, String>>(); |
for (int i = 0; i < nbreAppletteNoeud ; i++) { |
Element appletteNoeud = (Element) listeAppletteNoeud.item(i); |
int colonne = Integer.parseInt(appletteNoeud.getAttribute("colonne")); |
int index = Integer.parseInt(appletteNoeud.getAttribute("index")); |
HashMap<String, String> infoApplette = new HashMap<String, String>(); |
infoApplette.put("reduite", appletteNoeud.getAttribute("reduite")); |
infoApplette.put("epingle", appletteNoeud.getAttribute("epingle")); |
infoApplette.put("type", appletteNoeud.getAttribute("type")); |
infoApplette.put("colonne", appletteNoeud.getAttribute("colonne")); |
infoApplette.put("index", appletteNoeud.getAttribute("index")); |
infoApplette.put("contenu", appletteNoeud.getAttribute("contenu")); |
tableApplettes.put(colonne+"-"+index, infoApplette); |
// un noeud de type vide indique que l'utilisateur a explicité effacé les applettes de la page d'accueil |
if(listeAppletteNoeud.getLength() > 0 && !listeAppletteNoeud.item(0).getNodeName().equals("vide")) { |
// Lecture des noeuds "applette" |
int nbreAppletteNoeud = listeAppletteNoeud.getLength(); |
TreeMap<String, HashMap<String, String>> tableApplettes = new TreeMap<String, HashMap<String, String>>(); |
for (int i = 0; i < nbreAppletteNoeud ; i++) { |
Element appletteNoeud = (Element) listeAppletteNoeud.item(i); |
int colonne = Integer.parseInt(appletteNoeud.getAttribute("colonne")); |
int index = Integer.parseInt(appletteNoeud.getAttribute("index")); |
HashMap<String, String> infoApplette = new HashMap<String, String>(); |
infoApplette.put("reduite", appletteNoeud.getAttribute("reduite")); |
infoApplette.put("epingle", appletteNoeud.getAttribute("epingle")); |
infoApplette.put("type", appletteNoeud.getAttribute("type")); |
infoApplette.put("colonne", appletteNoeud.getAttribute("colonne")); |
infoApplette.put("index", appletteNoeud.getAttribute("index")); |
infoApplette.put("contenu", appletteNoeud.getAttribute("contenu")); |
tableApplettes.put(colonne+"-"+index, infoApplette); |
} |
Iterator<String> it = tableApplettes.keySet().iterator(); |
while (it.hasNext()) { |
String id = it.next(); |
HashMap<String, String> infoApplette = tableApplettes.get(id); |
boolean reduite = (infoApplette.get("reduite") != null && infoApplette.get("reduite").equals("true")) ? true : false; |
boolean epingle = (infoApplette.get("epingle") != null && infoApplette.get("epingle").equals("true")) ? true : false; |
int index = Integer.parseInt(infoApplette.get("index")); |
int colonne = Integer.parseInt(infoApplette.get("colonne")); |
ajouterPortlet(reduite, epingle, infoApplette.get("type"), colonne, index, infoApplette.get("contenu")); |
} |
} else if(listeAppletteNoeud.getLength() == 0) { |
ajouterPortletsDefaut(); |
} |
Iterator<String> it = tableApplettes.keySet().iterator(); |
while (it.hasNext()) { |
String id = it.next(); |
HashMap<String, String> infoApplette = tableApplettes.get(id); |
boolean reduite = (infoApplette.get("reduite") != null && infoApplette.get("reduite").equals("true")) ? true : false; |
boolean epingle = (infoApplette.get("epingle") != null && infoApplette.get("epingle").equals("true")) ? true : false; |
int index = Integer.parseInt(infoApplette.get("index")); |
int colonne = Integer.parseInt(infoApplette.get("colonne")); |
ajouterPortlet(reduite, epingle, infoApplette.get("type"), colonne, index, infoApplette.get("contenu")); |
} |
} |
layout(); |
} |
172,24 → 171,31 |
accueilNoeud = paramXml.getElementsByTagName("accueil").item(0); |
} |
|
// Ajout des noeuds "applette" au noeud "accueil" |
while (it.hasNext()) { |
Portlet applette = it.next(); |
String reduite = (applette.isCollapsed() ? "true" : "false"); |
String epingle = (applette.isPinned() ? "true" : "false"); |
String index = Integer.toString(portail.getPortletIndex(applette)); |
String colonne = Integer.toString(portail.getPortletColumn(applette)); |
String contenu = applette.getData("contenu"); |
|
Element appletteElement = paramXml.createElement("applette"); |
appletteElement.setAttribute("reduite", reduite); |
appletteElement.setAttribute("epingle", epingle); |
appletteElement.setAttribute("type", "statistique"); |
appletteElement.setAttribute("colonne", colonne); |
appletteElement.setAttribute("index", index); |
appletteElement.setAttribute("contenu", contenu); |
|
accueilNoeud.appendChild(appletteElement); |
// si il existe des applettes ouvertes |
if(it.hasNext()) { |
// Ajout des noeuds "applette" au noeud "accueil" |
while (it.hasNext()) { |
Portlet applette = it.next(); |
String reduite = (applette.isCollapsed() ? "true" : "false"); |
String epingle = (applette.isPinned() ? "true" : "false"); |
String index = Integer.toString(portail.getPortletIndex(applette)); |
String colonne = Integer.toString(portail.getPortletColumn(applette)); |
String contenu = applette.getData("contenu"); |
|
Element appletteElement = paramXml.createElement("applette"); |
appletteElement.setAttribute("reduite", reduite); |
appletteElement.setAttribute("epingle", epingle); |
appletteElement.setAttribute("type", "statistique"); |
appletteElement.setAttribute("colonne", colonne); |
appletteElement.setAttribute("index", index); |
appletteElement.setAttribute("contenu", contenu); |
|
accueilNoeud.appendChild(appletteElement); |
} |
} else { |
// sinon ajout d'un noeud vide |
Element videElement = paramXml.createElement("vide"); |
accueilNoeud.appendChild(videElement); |
} |
|
enregistrementEnCours = true; |
227,6 → 233,24 |
layout(); |
} |
|
private void ajouterPortletsDefaut() { |
//TODO créer une énum des différents types de portlet puis faire une boucle |
// dessus |
Applette applette = new AppletteStatistique(mediateur, "NombreDonnees"); |
portail.insert(applette, 0, 0); |
applette.setEpingler(true); |
|
applette = new AppletteStatistique(mediateur, "MesDonnees"); |
portail.insert(applette, 0, 1); |
|
applette = new AppletteStatistique(mediateur, "TypeDepot"); |
portail.insert(applette, 0, 2); |
|
applette = new AppletteStatistique(mediateur, "NombreCollectionParStructure"); |
portail.insert(applette, 1, 0); |
layout(); |
} |
|
public void rafraichir(Object nouvellesDonnees) { |
if (nouvellesDonnees instanceof Information) { |
Information info = (Information) nouvellesDonnees; |