Subversion Repositories eFlore/Applications.coel

Rev

Rev 69 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 69 Rev 133
1
package org.tela_botanica.client.vues;
1
package org.tela_botanica.client.vues;
2
 
2
 
3
import java.util.ArrayList;
3
import java.util.ArrayList;
4
import java.util.Iterator;
4
import java.util.Iterator;
5
import java.util.List;
5
import java.util.List;
6
 
6
 
7
import org.tela_botanica.client.ComposantClass;
7
import org.tela_botanica.client.ComposantClass;
8
import org.tela_botanica.client.Mediateur;
8
import org.tela_botanica.client.Mediateur;
9
import org.tela_botanica.client.RegistreId;
9
import org.tela_botanica.client.RegistreId;
10
import org.tela_botanica.client.interfaces.Rafraichissable;
10
import org.tela_botanica.client.interfaces.Rafraichissable;
-
 
11
import org.tela_botanica.client.modeles.Information;
11
import org.tela_botanica.client.modeles.Structure;
12
import org.tela_botanica.client.modeles.Structure;
12
import org.tela_botanica.client.modeles.StructureListe;
13
import org.tela_botanica.client.modeles.StructureListe;
13
 
14
 
14
import com.extjs.gxt.ui.client.Registry;
15
import com.extjs.gxt.ui.client.Registry;
15
import com.extjs.gxt.ui.client.Style.SelectionMode;
16
import com.extjs.gxt.ui.client.Style.SelectionMode;
16
import com.extjs.gxt.ui.client.binder.TableBinder;
17
import com.extjs.gxt.ui.client.binder.TableBinder;
17
import com.extjs.gxt.ui.client.event.ComponentEvent;
18
import com.extjs.gxt.ui.client.event.ComponentEvent;
18
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
19
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
19
import com.extjs.gxt.ui.client.event.SelectionChangedListener;
20
import com.extjs.gxt.ui.client.event.SelectionChangedListener;
20
import com.extjs.gxt.ui.client.event.SelectionListener;
21
import com.extjs.gxt.ui.client.event.SelectionListener;
21
import com.extjs.gxt.ui.client.store.ListStore;
22
import com.extjs.gxt.ui.client.store.ListStore;
22
import com.extjs.gxt.ui.client.widget.ContentPanel;
23
import com.extjs.gxt.ui.client.widget.ContentPanel;
-
 
24
import com.extjs.gxt.ui.client.widget.Info;
23
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
25
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
24
import com.extjs.gxt.ui.client.widget.table.Table;
26
import com.extjs.gxt.ui.client.widget.table.Table;
25
import com.extjs.gxt.ui.client.widget.table.TableColumn;
27
import com.extjs.gxt.ui.client.widget.table.TableColumn;
26
import com.extjs.gxt.ui.client.widget.table.TableColumnModel;
28
import com.extjs.gxt.ui.client.widget.table.TableColumnModel;
27
import com.extjs.gxt.ui.client.widget.toolbar.TextToolItem;
29
import com.extjs.gxt.ui.client.widget.toolbar.TextToolItem;
28
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
30
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
-
 
31
import com.google.gwt.core.client.GWT;
29
import com.google.gwt.user.client.Window;
32
import com.google.gwt.user.client.Window;
30
 
33
 
31
public class StructureListePanneauVue extends ContentPanel implements Rafraichissable {
34
public class StructureListePanneauVue extends ContentPanel implements Rafraichissable {
-
 
35
	
32
	
36
	private Rafraichissable structureListePanneauVue = null ;
33
	private Mediateur coelMediateur = null ;
37
	private Mediateur coelMediateur = null ;
34
	private Table table = null;
38
	private Table table = null;
35
	private ListStore<Structure> store = null;
39
	private ListStore<Structure> store = null;
36
	private TableBinder<Structure> binder = null;
40
	private TableBinder<Structure> binder = null;
37
 
41
 
38
	public StructureListePanneauVue() {
42
	public StructureListePanneauVue() {
39
		coelMediateur = Registry.get(RegistreId.MEDIATEUR);
43
		coelMediateur = Registry.get(RegistreId.MEDIATEUR);
-
 
44
		structureListePanneauVue = this;
40
		
45
		
41
		ToolBar toolBar = new ToolBar();
46
		ToolBar toolBar = new ToolBar();
42
		TextToolItem ajouter = new TextToolItem("Ajouter");
47
		TextToolItem ajouter = new TextToolItem("Ajouter");
43
		ajouter.setIconStyle(ComposantClass.ICONE_AJOUTER);
48
		ajouter.setIconStyle(ComposantClass.ICONE_AJOUTER);
44
		ajouter.addSelectionListener(new SelectionListener<ComponentEvent>() {  
49
		ajouter.addSelectionListener(new SelectionListener<ComponentEvent>() {  
45
			public void componentSelected(ComponentEvent ce) {  
50
			public void componentSelected(ComponentEvent ce) {  
46
				coelMediateur.clicAjouterStructure();
51
				coelMediateur.clicAjouterStructure();
47
			}  
52
			}
48
		});
53
		});
49
		toolBar.add(ajouter);
54
		toolBar.add(ajouter);
50
 
55
 
51
		TextToolItem modifier = new TextToolItem("Modifier");
56
		TextToolItem modifier = new TextToolItem("Modifier");
52
		modifier.setIconStyle(ComposantClass.ICONE_MODIFIER);
57
		modifier.setIconStyle(ComposantClass.ICONE_MODIFIER);
53
		toolBar.add(modifier);
58
		toolBar.add(modifier);
54
		
59
		
55
		TextToolItem supprimer = new TextToolItem("Supprimer");
60
		TextToolItem supprimer = new TextToolItem("Supprimer");
56
		supprimer.setIconStyle(ComposantClass.ICONE_SUPPRIMER);
61
		supprimer.setIconStyle(ComposantClass.ICONE_SUPPRIMER);
-
 
62
		supprimer.addSelectionListener(new SelectionListener<ComponentEvent>() {
-
 
63
			public void componentSelected(ComponentEvent ce) {
-
 
64
				coelMediateur.clicSupprimerStructure(structureListePanneauVue, binder.getSelection());
-
 
65
			}
-
 
66
		});
57
		toolBar.add(supprimer);
67
		toolBar.add(supprimer);
58
 
68
 
59
		setTopComponent(toolBar);
69
		setTopComponent(toolBar);
60
 
70
 
61
		List<TableColumn> columns = new ArrayList<TableColumn>();
71
		List<TableColumn> columns = new ArrayList<TableColumn>();
62
		// ATTENTION : les noms des colonnes doivent correspondrent aux noms variables de la classe utilisée dans la liste
72
		// ATTENTION : les noms des colonnes doivent correspondrent aux noms variables de la classe utilisée dans la liste
63
		columns.add(new TableColumn("ville", "Ville", .3f));
73
		columns.add(new TableColumn("ville", "Ville", .3f));
64
		columns.add(new TableColumn("nom", "Nom", .7f));
74
		columns.add(new TableColumn("nom", "Nom", .7f));
65
		
75
		
66
		TableColumnModel cm = new TableColumnModel(columns);
76
		TableColumnModel cm = new TableColumnModel(columns);
67
 
77
 
68
		table = new Table(cm);
78
		table = new Table(cm);
69
		table.setSelectionMode(SelectionMode.MULTI);
79
		table.setSelectionMode(SelectionMode.MULTI);
70
		table.setBorders(false);
80
		table.setBorders(false);
71
 
81
 
72
		add(table);
82
		add(table);
73
 
83
 
74
		store = new ListStore<Structure>();
84
		store = new ListStore<Structure>();
75
 
85
 
76
		binder = new TableBinder<Structure>(table, store);
86
		binder = new TableBinder<Structure>(table, store);
77
		binder.setAutoSelect(true);
87
		binder.setAutoSelect(true);
78
		binder.addSelectionChangedListener(new SelectionChangedListener<Structure>() {
88
		binder.addSelectionChangedListener(new SelectionChangedListener<Structure>() {
79
			public void selectionChanged(SelectionChangedEvent<Structure> event) {
89
			public void selectionChanged(SelectionChangedEvent<Structure> event) {
80
				Structure m = (Structure) event.getSelectedItem();
90
				Structure m = (Structure) event.getSelectedItem();
81
				clicListe(m);
91
				clicListe(m);
82
			}
92
			}
83
		});
93
		});
84
 
94
 
85
		setLayout(new FitLayout());
95
		setLayout(new FitLayout());
86
	}
96
	}
87
 
97
 
88
	public ListStore<Structure> getStore() {
98
	public ListStore<Structure> getStore() {
89
		return store;
99
		return store;
90
	}
100
	}
91
 
101
 
92
	public TableBinder<Structure> getBinder() {
102
	public TableBinder<Structure> getBinder() {
93
		return binder;
103
		return binder;
94
	}
104
	}
95
 
105
 
96
	private void clicListe(Structure institution) {
106
	private void clicListe(Structure institution) {
97
		coelMediateur.clicListeInstitution(institution);
107
		coelMediateur.clicListeInstitution(institution);
98
	}
108
	}
99
 
109
 
100
	public void rafraichir(Object nouvelleDonnees) {
110
	public void rafraichir(Object nouvelleDonnees) {
101
		if (nouvelleDonnees instanceof StructureListe) {
111
		if (nouvelleDonnees instanceof StructureListe) {
102
			StructureListe listeInstitutions = (StructureListe) nouvelleDonnees;
112
			StructureListe listeInstitutions = (StructureListe) nouvelleDonnees;
103
			setHeading("Institutions");
113
			setHeading("Institutions");
104
 
114
 
105
			List<Structure> liste = new ArrayList<Structure>();
115
			List<Structure> liste = new ArrayList<Structure>();
106
			for (Iterator<String> it = listeInstitutions.keySet().iterator(); it.hasNext();) {
116
			for (Iterator<String> it = listeInstitutions.keySet().iterator(); it.hasNext();) {
107
				liste.add(listeInstitutions.get(it.next()));
117
				liste.add(listeInstitutions.get(it.next()));
108
			}
118
			}
109
			
119
			
110
			store.removeAll();
120
			store.removeAll();
111
			store.add((List<Structure>) liste);
121
			store.add((List<Structure>) liste);
112
			
122
			
113
			// Test pour savoir si la liste contient des éléments
123
			// Test pour savoir si la liste contient des éléments
114
			if (listeInstitutions.size() > 0) {
124
			if (listeInstitutions.size() > 0) {
115
				binder.setSelection((Structure) listeInstitutions.get(0));
125
				binder.setSelection((Structure) listeInstitutions.get(0));
116
			}
126
			}
-
 
127
		} else if (nouvelleDonnees instanceof Information) {
-
 
128
			Information info = (Information) nouvelleDonnees;
-
 
129
			if (info.getType().equals("suppression_structure")) {
-
 
130
				GWT.log(info.getMessages().toString(), null);
-
 
131
				Info.display("Suppression Structure", info.toString());
-
 
132
			}
117
		}
133
		}
118
		
134
		
119
	}
135
	}
120
}
136
}