Subversion Repositories eFlore/Archives.cel-v2

Rev

Rev 28 | Rev 36 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 28 Rev 30
Line 22... Line 22...
22
import com.gwtext.client.widgets.Container;
22
import com.gwtext.client.widgets.Container;
23
import com.gwtext.client.widgets.Editor;
23
import com.gwtext.client.widgets.Editor;
24
import com.gwtext.client.widgets.Panel;
24
import com.gwtext.client.widgets.Panel;
25
import com.gwtext.client.widgets.event.ButtonListener;
25
import com.gwtext.client.widgets.event.ButtonListener;
26
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
26
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
-
 
27
import com.gwtext.client.widgets.event.ComponentListener;
-
 
28
import com.gwtext.client.widgets.event.ComponentListenerAdapter;
-
 
29
import com.gwtext.client.widgets.event.ContainerListener;
-
 
30
import com.gwtext.client.widgets.event.ContainerListenerAdapter;
27
import com.gwtext.client.widgets.event.EditorListener;
31
import com.gwtext.client.widgets.event.EditorListener;
28
import com.gwtext.client.widgets.event.EditorListenerAdapter;
32
import com.gwtext.client.widgets.event.EditorListenerAdapter;
-
 
33
import com.gwtext.client.widgets.event.PanelListenerAdapter;
29
import com.gwtext.client.widgets.form.Field;
34
import com.gwtext.client.widgets.form.Field;
30
import com.gwtext.client.widgets.form.TextField;
35
import com.gwtext.client.widgets.form.TextField;
31
import com.gwtext.client.widgets.layout.RowLayout;
36
import com.gwtext.client.widgets.layout.RowLayout;
32
import com.gwtext.client.widgets.layout.RowLayoutData;
37
import com.gwtext.client.widgets.layout.RowLayoutData;
33
import com.gwtext.client.widgets.menu.Menu;
38
import com.gwtext.client.widgets.menu.Menu;
Line 45... Line 50...
45
	private TreePanel arbreMotsCles = null ;
50
	private TreePanel arbreMotsCles = null ;
46
	private TreeEditor te = null ;
51
	private TreeEditor te = null ;
47
	private TextField tfEdit = null ;
52
	private TextField tfEdit = null ;
48
	private Button valider = null ;
53
	private Button valider = null ;
49
	private String motsClesEnCours = "" ;
54
	private String motsClesEnCours = "" ;
-
 
55
	private String[] motsClesEnAttente ; 
50
	private boolean ajoutNoeud = false ;
56
	private boolean ajoutNoeud = false ;
51
	private boolean modifNoeud = false ;
57
	private boolean modifNoeud = false ;
-
 
58
	private boolean estInstancie = false ;
-
 
59
	private boolean motsCleInitialises ;
Line 52... Line 60...
52
	
60
	
53
	public ArbreMotsClesVue(ImageMediateur im)
61
	public ArbreMotsClesVue(ImageMediateur im)
54
	{
62
	{
55
		super("Mots clés") ;
63
		super("Mots clés") ;
56
		this.setLayout(new RowLayout());
64
		this.setLayout(new RowLayout());
Line 57... Line 65...
57
		iMediateur = im ;
65
		iMediateur = im ;
58
		
66
		
Line 59... Line 67...
59
		arbreMotsCles = new TreePanel() ;
67
		arbreMotsCles = new TreePanel() ;
60
		arbreMotsCles.setEnableDD(true) ;
68
		arbreMotsCles.setEnableDD(true) ;
61
		
69
		
62
		TreeNode root = new TreeNode("Mots clés") ;
70
		TreeNode root = new TreeNode("Tags") ;
Line 63... Line 71...
63
		root.setId("racine") ;
71
		root.setId("racine") ;
64
		String[] usObject = {"Mots clés" , "racine" } ;
72
		String[] usObject = {"Mots clés" , "racine" } ;
65
		root.setUserObject(usObject) ;
73
		root.setUserObject(usObject) ;
Line 66... Line 74...
66
		
74
		
67
		arbreMotsCles.setRootNode(root) ;
75
		arbreMotsCles.setRootNode(root) ;
68
		arbreMotsCles.setRootVisible(true) ;
76
		arbreMotsCles.setRootVisible(false) ;
69
		arbreMotsCles.getRootNode().setIcon("tela.png") ;
77
		arbreMotsCles.getRootNode().setIcon("tela.png") ;
70
		
78
		
71
		tfEdit = new TextField() ;
79
		tfEdit = new TextField() ;
Line 72... Line 80...
72
		te = new TreeEditor(arbreMotsCles,tfEdit) ;
80
		te = new TreeEditor(arbreMotsCles,tfEdit) ;
-
 
81
		valider = new Button("Appliquer") ;
73
		valider = new Button("Appliquer") ;
82
		arbreMotsCles.add(te) ;
Line 74... Line 83...
74
		arbreMotsCles.add(te) ;
83
		this.add(arbreMotsCles,new RowLayoutData("90%")) ;
Line 75... Line 84...
75
		this.add(arbreMotsCles,new RowLayoutData("90%")) ;
84
		this.add(valider,new RowLayoutData("10%")) ;
Line 116... Line 125...
116
			}
125
			}
Line 117... Line 126...
117
 
126
 
Line 118... Line 127...
118
			
127
			
119
			public void onContextMenu(TreeNode node, EventObject e) {
128
			public void onContextMenu(TreeNode node, EventObject e) {
Line 120... Line 129...
120
				
129
				
Line 121... Line 130...
121
				e.stopEvent() ;
130
					e.stopEvent() ;
Line 155... Line 164...
155
			{
164
			{
156
				GetIMediateur().deplacerMotCleDansArbre(node, getArbreMotsCles().getTree()) ;
165
				GetIMediateur().deplacerMotCleDansArbre(node, getArbreMotsCles().getTree()) ;
157
			}
166
			}
Line 158... Line -...
158
 
-
 
159
 
167
 
Line 160... Line 168...
160
			
168
 
161
			public void onCheckChange(TreeNode node, boolean checked) {
169
			public void onCheckChange(TreeNode node, boolean checked) {
162
				
170
				
Line 172... Line 180...
172
							return true ;
180
							return true ;
173
						}
181
						}
174
					}) ;
182
					}) ;
175
				}
183
				}
176
			}
184
			}
-
 
185
			
177
		}) ;
186
		}) ;
Line 178... Line -...
178
		
-
 
179
		
187
		
Line 180... Line 188...
180
		valider.addListener(new ButtonListenerAdapter() {
188
		valider.addListener(new ButtonListenerAdapter() {
Line 181... Line 189...
181
 
189
 
Line 205... Line 213...
205
			}
213
			}
206
		}) ;
214
		}) ;
Line 207... Line 215...
207
		
215
		
Line -... Line 216...
-
 
216
	}
-
 
217
	
-
 
218
	public void obtenirArbreMotsCles() {
-
 
219
		
-
 
220
		GetIMediateur().obtenirArbreMotsCles(this) ;
-
 
221
		
-
 
222
	}
208
	}
223
 
209
	
224
 
-
 
225
	public void supprimerNoeud(TreeNode n)
-
 
226
	{
-
 
227
		
210
	public void supprimerNoeud(TreeNode n)
228
		if(!n.getId().equals(getArbreMotsCles().getRootNode().getId()))
211
	{
229
		{
212
		n.getParentNode().removeChild(n);
230
			n.getParentNode().removeChild(n);
-
 
231
			n.destroy() ;
-
 
232
			GetIMediateur().supprimerMotCleDansArbre(n, arbreMotsCles.getTree()) ;
-
 
233
		}
-
 
234
		else
-
 
235
		{
213
		n.destroy() ;
236
			Window.alert("Impossible de supprimer la racine de l'arbre") ;
Line 214... Line 237...
214
		GetIMediateur().supprimerMotCleDansArbre(n, arbreMotsCles.getTree()) ;
237
		}
215
	}
238
	}
Line 243... Line 266...
243
		}
266
		}
244
	}
267
	}
Line 245... Line 268...
245
	
268
	
246
	public void cocherMotsCles(final String[] motsClesIds)
269
	public void cocherMotsCles(final String[] motsClesIds)
247
	{
270
	{
248
		getArbreMotsCles().getRootNode().cascade(new NodeTraversalCallback() {
271
		if(getArbreMotsCles() != null && getArbreMotsCles().getRootNode() != null)
249
 
272
		{
250
			public boolean execute(Node node) {
273
			getArbreMotsCles().getRootNode().cascade(new NodeTraversalCallback() {
251
				
-
 
252
				for(int i = 0 ; i < motsClesIds.length ; i++)
-
 
253
				{	
-
 
254
					String usObject[] = (String[])node.getUserObject() ;
274
	
Line -... Line 275...
-
 
275
				public boolean execute(Node node) {
-
 
276
					
-
 
277
						for(int i = 0 ; i < motsClesIds.length ; i++)
-
 
278
						{
-
 
279
							String usObject[] = (String[])node.getUserObject() ;
255
					String nodeId = usObject[1] ;
280
							String nodeId = usObject[1] ;
256
					
281
							
257
					getArbreMotsCles().getNodeById(node.getId()).getUI().toggleCheck(false) ;
282
							getArbreMotsCles().getNodeById(node.getId()).getUI().toggleCheck(false) ;
258
								
283
										
259
					if(nodeId.equals(motsClesIds[i]))
284
							if(nodeId.equals(motsClesIds[i]))
260
					{
285
							{
-
 
286
								getArbreMotsCles().getNodeById(nodeId).getUI().toggleCheck(true) ;
261
						getArbreMotsCles().getNodeById(nodeId).getUI().toggleCheck(true) ;
287
								return true ;
-
 
288
							}
262
						return true ;
289
						}
263
					}
-
 
264
				}
-
 
265
				return true;
290
						return true;
266
			}
291
				}
-
 
292
				
267
			
293
			}) ;
Line 268... Line 294...
268
		}) ;
294
		}
269
	}
295
	}
Line 270... Line 296...
270
	
296
	
271
	public void rafraichir(Object nouvelleDonnees,
297
	public void rafraichir(Object nouvelleDonnees,
272
			boolean repandreRafraichissement) {
298
			boolean repandreRafraichissement) {
-
 
299
		
273
		
300
		if(nouvelleDonnees instanceof Tree)
-
 
301
		{
-
 
302
				Tree nouvelArbre = (Tree)nouvelleDonnees ;
-
 
303
				
-
 
304
					getArbreMotsCles().getRootNode().appendChild(nouvelArbre.getRootNode()) ;
-
 
305
					getArbreMotsCles().expandAll() ;
-
 
306
					estInstancie = true ;
-
 
307
					
-
 
308
					if(motsCleInitialises == false && motsClesEnAttente != null)
274
		if(nouvelleDonnees instanceof Tree)
309
					{
Line 275... Line 310...
275
		{
310
						cocherMotsCles(motsClesEnAttente) ;
276
			Tree nouvelArbre = (Tree)nouvelleDonnees ;
311
						motsCleInitialises = true ; 
-
 
312
					}
-
 
313
		}
277
			getArbreMotsCles().setRootNode(nouvelArbre.getRootNode()) ;
314
		
278
		}
315
		if(nouvelleDonnees instanceof String[])
-
 
316
		{
-
 
317
			if(estInstancie && nouvelleDonnees != null)
-
 
318
			{
-
 
319
				String[] motsClesIds = (String[])nouvelleDonnees ;		
-
 
320
				cocherMotsCles(motsClesIds) ;
-
 
321
				
279
		
322
			}
Line 280... Line 323...
280
		if(nouvelleDonnees instanceof String[])
323
			else
Line 281... Line 324...
281
		{
324
			{