KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > edit > provider > ItemProvider


1 /**
2  * <copyright>
3  *
4  * Copyright (c) 2002-2004 IBM Corporation and others.
5  * All rights reserved. This program and the accompanying materials
6  * are made available under the terms of the Eclipse Public License v1.0
7  * which accompanies this distribution, and is available at
8  * http://www.eclipse.org/legal/epl-v10.html
9  *
10  * Contributors:
11  * IBM - Initial API and implementation
12  *
13  * </copyright>
14  *
15  * $Id: ItemProvider.java,v 1.3 2005/06/08 06:17:05 nickb Exp $
16  */

17 package org.eclipse.emf.edit.provider;
18
19
20 import java.util.Collection JavaDoc;
21 import java.util.Collections JavaDoc;
22
23 import org.eclipse.emf.common.command.Command;
24 import org.eclipse.emf.common.command.UnexecutableCommand;
25 import org.eclipse.emf.common.notify.AdapterFactory;
26 import org.eclipse.emf.common.notify.Notification;
27 import org.eclipse.emf.common.notify.NotificationChain;
28 import org.eclipse.emf.common.notify.impl.NotificationImpl;
29 import org.eclipse.emf.common.notify.impl.NotifyingListImpl;
30 import org.eclipse.emf.common.util.EList;
31 import org.eclipse.emf.edit.command.CommandParameter;
32 import org.eclipse.emf.edit.domain.EditingDomain;
33
34
35 /**
36  * This item provider implementation is a convenient reusable base
37  * that can be used for an item provider that isn't an adapter for an EMF object.
38  *
39  * This default implemention is highly functional and is plastic enough for a wide variety of uses
40  * (as will be illustrated in the examples to come).
41  * The plasticity is the reason for providing a huge number of constructors.
42  *
43  * <p>
44  * The {@link #children} list is implemented using {@link ItemProviderNotifyingArrayList}.
45  * As a result, any modification of the collection (using the stanandard {@link java.util.List} interface)
46  * will automatically fire the correct call to each {@link INotifyChangedListener} in the {@link #changeNotifier}.
47  * Furthermore, {@link IUpdateableItemParent#setParent IUpdateableItemParent.setParent}
48  * is called to update {@link #parent} for the objects that are added to or removed from the list,
49  * but optionally, i.e., only if the interface is implemented---the {@link #adapterFactory} is used if it isn't null.
50  *
51  * <p>
52  * There is also a {@link #text} and an {@link #image},
53  * which can be set via {@link #setText setText} and {@link #setImage setImage}
54  * to cause appropriate domain event notifications to be fired.
55  * The set methods use the stateless adapter signature for uniformity and to support
56  * {@link IUpdateableItemText#setText(Object, String)}.
57  *
58  * <p>
59  * This class is useful as a convenient wrapper object to act as the input to a view, e.g.,
60  * <pre>
61  * viewer.setInput(new ItemProvider(text, image, collection));
62  * </pre>
63  * lets you take a mixed collection of model objects and item providers,
64  * and show it as the elements of a structured view, i.e., as the visible roots of the view.
65  * Although a structured viewer <bf>does not</bf> show it's input object within the view,
66  * it <bf>does</bf> show the imput object on the pane title.
67  * The above pattern allows you to inject a collection or the object itself into the structured viewer
68  * and to control the pane title at the same time, e.g.,
69  * <pre>
70  * viewer.setInput(new ItemProvider(Collections.singleton(object)));
71  * </pre>
72  * will leave the pane title blank and show the object as the root of the structured view.
73  *
74  * <p>
75  * One could use more of these item providers to build up a scaffolding within views.
76  * Consider the following block of code
77  * which has access to a collection of {@link INotifyChangedListener}s.
78  * <pre>
79  * // final Collection listeners = ...;
80  * // final StructuredContentViewer contentViewer = ...;
81  * //
82  * // These create the items and build up the structure.
83  * //
84  * final ItemProvider child11 = new ItemProvider(listeners, "Child 1");
85  * final ItemProvider child12 = new ItemProvider(listeners, "Child 2");
86  * final ItemProvider parent1 = new ItemProvider(listeners, "Parent 1", Arrays.asList(new Object [] {child11, child12}));
87  * final ItemProvider child21 = new ItemProvider(listeners, "Child 1");
88  * final ItemProvider child22 = new ItemProvider(listeners, "Child 2");
89  * final ItemProvider parent2 = new ItemProvider(listeners, "Parent 2", Arrays.asList(new Object [] {child21, child22}));
90  * final ItemProvider grandParent = new ItemProvider(listeners, "Grand Parent", Arrays.asList(new Object [] {parent1, parent2}));
91  *
92  * // Set the items into the visible roots of the structured content viewer.
93  * //
94  * contentViewer.setInput(new ItemProvider("Pane Tile", Collections.singleton(grandParent)));
95  *
96  * // Create some delayed actions that modify the item structure.
97  * //
98  * if (contentViewer.isControlOkToUse())
99  * {
100  * contentViewer.getControl().getDisplay().asyncExec
101  * (new Runnable()
102  * {
103  * public void run()
104  * {
105  * // Use standard list modification that has the effect of producing a domain event notification.
106  * //
107  * parent1.getChildren().removeAll(Arrays.asList(new Object [] {child11, child12}));
108  *
109  * contentViewer.getControl().getDisplay().asyncExec
110  * (new Runnable()
111  * {
112  * public void run()
113  * {
114  * // This also as the effect of producing a correct a domain event notification.
115  * //
116  * parent2.setText("Parent 2!");
117  * }
118  * });
119  * }
120  * });
121  * }
122  * </pre>
123  * The structure will be displayed within the contentViewer and will then change a little bit later;
124  * the flickering should be noticeable if the viewer is set to auto expand.
125  *
126  * <p>
127  * Another common pattern of usage will be to inject scaffolding within an EMF structure.
128  * In the following example, a new factory is defined to replace the adapters for Company and Department
129  * so as to inject an <em>item</em> that acts as the child of the Company and the parent of each Department.
130  * (Normally, this would not be done with all these inner classes.)
131  * <pre>
132  * ItemProviderAdapterFactory myItemProviderAdapterFactory =
133  * new ItemProviderAdapterFactory()
134  * {
135  * public Adapter createCompanyAdapter()
136  * {
137  * // This returns a new instance each time.
138  * // The instance stores an injected child that in turn will have this original object's children as its children.
139  * //
140  * return
141  * new CompanyItemProvider(this)
142  * {
143  * // Keep track of the new child added below company.
144  * //
145  * ItemProvider injectedChild;
146  *
147  * public Collection getChildren(final Object object)
148  * {
149  * // Create one on demand.
150  * //
151  * if (injectedChild == null)
152  * {
153  * injectedChild =
154  * (new ItemProvider("Injected Child")
155  * {
156  * public Collection getChildren(Object o)
157  * {
158  * // Return the department of the company.
159  * // Note that we ignore o in favour of object.
160  * //
161  * return ((Company)object).getDepartment();
162  * }
163  * public boolean hasChildren(Object o)
164  * {
165  * // You have to make sure you override this method to match the above.
166  * //
167  * return !((Company)object).getDepartment().isEmpty();
168  * }
169  * });
170  * }
171  *
172  * return Collections.singleton(injectedChild);
173  * }
174  *
175  * public boolean hasChildren(Object object)
176  * {
177  * // You have to make sure you override this method to match the above.
178  * //
179  * return true;
180  * }
181  *
182  * public void notifyChanged(Notification msg)
183  * {
184  * // If the departments are affected...
185  * //
186  * Company company = (Company)msg.getNotifier();
187  * if (msg.getStructuralFeature() == company.ePackageCompany().getCompany_Deparment())
188  * {
189  * // If there's a child around to care...
190  * //
191  * if (injectedChild != null)
192  * {
193  * // Fire the domain event as if it came from the child.
194  * //
195  * // EATM TODO
196  * fireNotifyChanged(injectedChild, msg.getEventType(), msg.getStructuralFeature(), msg.getOldValue(), msg.getNewValue(), msg.getPostition());
197  * }
198  * }
199  * else
200  * {
201  * // Behave as normal.
202  * //
203  * super.notifyChanged(msg);
204  * }
205  * }
206  * };
207  * }
208  *
209  * public Adapter createDepartmentAdapter()
210  * {
211  * // This is still stateless.
212  * //
213  * if (departmentItemProvider == null)
214  * {
215  * departmentItemProvider =
216  * new DepartmentItemProvider(this)
217  * {
218  * public Object getParent(Object object)
219  * {
220  * // Use the stateful adapter of the containing parent to determine the injected item.
221  * //
222  * Company company = ((Department)object).getCompany();
223  * ITreeItemContentProvider companyAdapter =
224  * (ITreeItemContentProvider)this.adapterFactory.adapt(company, ITreeItemContentProvider.class);
225  * if (companyAdapter != null)
226  * {
227  * // Get the first child of the company's adapter.
228  * //
229  * return companyAdapter.getChildren(company).iterator().next();
230  * }
231  * else
232  * {
233  * return null;
234  * }
235  * }
236  * };
237  * }
238  *
239  * // Return the single factory instance.
240  * //
241  * return departmentItemProvider;
242  * }
243  * };
244  * </pre>
245  *
246  */

247 public class ItemProvider
248   implements
249     IChangeNotifier,
250     IDisposable,
251     IItemLabelProvider,
252     IStructuredItemContentProvider,
253     ITreeItemContentProvider,
254     IUpdateableItemParent
255 {
256   /**
257    * This is the text returned by {@link IItemLabelProvider#getText getText(Object)}.
258    */

259   protected String JavaDoc text;
260
261   /**
262    * This is the image returned by {@link IItemLabelProvider#getImage getImage(Object)}.
263    */

264   protected Object JavaDoc image;
265
266   /**
267    * This is the parent returned by {@link ITreeItemContentProvider#getParent getParent(Object)}.
268    */

269   protected Object JavaDoc parent;
270
271   /**
272    * This is the children returned by {@link ITreeItemContentProvider#getChildren getChildren(Object)}.
273    */

274   protected ItemProviderNotifyingArrayList children;
275
276   /**
277    * This is the optional adapter factory that is used to get adapters for parent or child objects.
278    */

279   protected AdapterFactory adapterFactory;
280
281   /**
282    * This is the optional collection used for changes to the text, parent, or children.
283    */

284   protected IChangeNotifier changeNotifier;
285
286   /**
287    * This class implements a Notification for an ItemProvider.
288    */

289   public class ItemProviderNotification extends NotificationImpl
290   {
291     public ItemProviderNotification(int eventType, Object JavaDoc oldValue, Object JavaDoc newValue, int position)
292     {
293       this(eventType, oldValue, newValue, position, false);
294     }
295
296     public ItemProviderNotification(int eventType, Object JavaDoc oldValue, Object JavaDoc newValue, int position, boolean wasSet)
297     {
298       super(eventType, oldValue, newValue, position, wasSet);
299     }
300
301     public Object JavaDoc getNotifier()
302     {
303       return ItemProvider.this;
304     }
305
306     public void dispatch()
307     {
308       Object JavaDoc notifier = getNotifier();
309       if (notifier != null && getEventType() != -1)
310       {
311         ((IChangeNotifier)notifier).fireNotifyChanged(this);
312       }
313
314       if (next != null)
315       {
316         next.dispatch();
317       }
318     }
319   }
320
321   /**
322    * This class overrides the "notify" methods to fire {@link org.eclipse.emf.edit.provider.INotifyChangedListener} calls
323    * and it overrides the "inverse basic" methods to maintain referential integrity
324    * by calling {@link IUpdateableItemParent#setParent IUpdateableItemParent.setParent}.
325    */

326   public class ItemProviderNotifyingArrayList extends NotifyingListImpl
327   {
328     /**
329      * This constructs an empty instance.
330      */

331     public ItemProviderNotifyingArrayList()
332     {
333     }
334
335     /**
336      * This constructs an instance with this initial capacity.
337      */

338     public ItemProviderNotifyingArrayList(int initialCapacity)
339     {
340       super(initialCapacity);
341     }
342
343     /**
344      * This always notifies.
345      */

346     protected boolean isNotificationRequired()
347     {
348       return true;
349     }
350
351     /**
352      * This has an inverse
353      */

354     protected boolean hasInverse()
355     {
356       return true;
357     }
358
359     /**
360      * This constructs an instance with the same initial content as the given collection.
361      * Note that the add methods are called to do this and hence calls to basic methods are produced.
362      * This means there will be notification,
363      * but you can make sure the domain notifier is null during this constructor invocation to change that behaviour.
364      * All the basic item provider constructors ensure that no domain events are fired.
365      */

366     public ItemProviderNotifyingArrayList(Collection JavaDoc collection)
367     {
368       super();
369       addAll(collection);
370     }
371
372     /**
373      * This implementation directs the notification the containing item provider.
374      */

375     protected void dispatchNotification(Notification notification)
376     {
377       ((IChangeNotifier)notification.getNotifier()).fireNotifyChanged(notification);
378     }
379
380     /**
381      * This implementation creates an {@link ItemProvider.ItemProviderNotification}.
382      */

383     protected NotificationImpl createNotification(int eventType, Object JavaDoc oldObject, Object JavaDoc newObject, int index, boolean wasSet)
384     {
385       return new ItemProviderNotification(eventType, oldObject, newObject, index, wasSet);
386     }
387
388     /**
389      * This implementation will call {@link IUpdateableItemParent#setParent IUpdateableItemParent.setParent}, if appropriate.
390      */

391     protected NotificationChain inverseAdd(Object JavaDoc object, NotificationChain notifications)
392     {
393       Object JavaDoc adapter = object;
394       if (adapterFactory != null)
395       {
396         adapter = adapterFactory.adapt(object, IUpdateableItemParent.class);
397       }
398
399       if (adapter instanceof IUpdateableItemParent)
400       {
401         ((IUpdateableItemParent)adapter).setParent(object, ItemProvider.this);
402       }
403
404       return notifications;
405     }
406   
407     /**
408      * This implementation will call {@link IUpdateableItemParent#setParent IUpdateableItemParent.setParent}, if appropriate.
409      */

410     protected NotificationChain inverseRemove(Object JavaDoc object, NotificationChain notifications)
411     {
412       Object JavaDoc adapter = object;
413       if (adapterFactory != null)
414       {
415         adapter = adapterFactory.adapt(object, IUpdateableItemParent.class);
416       }
417
418       if (adapter instanceof IUpdateableItemParent)
419       {
420         ((IUpdateableItemParent)adapter).setParent(object, null);
421       }
422
423       return notifications;
424     }
425   }
426   
427   /**
428    * This creates an instance with an empty text that yields no children.
429    */

430   public ItemProvider()
431   {
432     this.text = "";
433     this.children = new ItemProviderNotifyingArrayList();
434   }
435
436   /**
437    * This creates an instance with an empty text that yields the given children.
438    */

439   public ItemProvider(Collection JavaDoc children)
440   {
441     this.text = "";
442     this.children = new ItemProviderNotifyingArrayList(children);
443   }
444
445   /**
446    * This creates an instance with the given text that yields the no children.
447    */

448   public ItemProvider(String JavaDoc text)
449   {
450     this.text = text;
451     this.children = new ItemProviderNotifyingArrayList();
452   }
453
454   /**
455    * This creates an instance with the given text that yields the given children.
456    */

457   public ItemProvider(String JavaDoc text, Collection JavaDoc children)
458   {
459     this.text = text;
460     this.children = new ItemProviderNotifyingArrayList(children);
461   }
462
463   /**
464    * This creates an instance with the given text and image that yields the no children.
465    */

466   public ItemProvider(String JavaDoc text, Object JavaDoc image)
467   {
468     this.text = text;
469     this.image = image;
470     this.children = new ItemProviderNotifyingArrayList();
471   }
472
473   /**
474    * This creates an instance with the given text and image that yields the given children.
475    */

476   public ItemProvider(String JavaDoc text, Object JavaDoc image, Collection JavaDoc children)
477   {
478     this.text = text;
479     this.image = image;
480     this.children = new ItemProviderNotifyingArrayList(children);
481   }
482
483   /**
484    * This creates an instance with the given text, image, and parent that yields no children.
485    */

486   public ItemProvider(String JavaDoc text, Object JavaDoc image, Object JavaDoc parent)
487   {
488     this.text = text;
489     this.image = image;
490     this.parent = parent;
491     this.children = new ItemProviderNotifyingArrayList();
492   }
493
494   /**
495    * This creates an instance with the given text, image, and parent that yields the given children.
496    */

497   public ItemProvider(String JavaDoc text, Object JavaDoc image, Object JavaDoc parent, Collection JavaDoc children)
498   {
499     this.text = text;
500     this.image = image;
501     this.parent = parent;
502     this.children = new ItemProviderNotifyingArrayList(children);
503   }
504
505   /**
506    * This creates an instance with the given adapter factory and an empty text that yields no children.
507    */

508   public ItemProvider(AdapterFactory adapterFactory)
509   {
510     this.adapterFactory = adapterFactory;
511     this.text = "";
512     this.children = new ItemProviderNotifyingArrayList();
513   }
514
515   /**
516    * This creates an instance with the given adapter factor and text that yields no children.
517    */

518   public ItemProvider(AdapterFactory adapterFactory, String JavaDoc text)
519   {
520     this.adapterFactory = adapterFactory;
521     this.text = text;
522     this.children = new ItemProviderNotifyingArrayList();
523   }
524
525   /**
526    * This creates an instance with the given adapter factory, text, and image that yields no children.
527    */

528   public ItemProvider(AdapterFactory adapterFactory, String JavaDoc text, Object JavaDoc image)
529   {
530     this.adapterFactory = adapterFactory;
531     this.text = text;
532     this.image = image;
533     this.children = new ItemProviderNotifyingArrayList();
534   }
535
536   /**
537    * This creates an instance with the given adapter factory, text, image, and parent that yields no children.
538    */

539   public ItemProvider(AdapterFactory adapterFactory, String JavaDoc text, Object JavaDoc image, Object JavaDoc parent)
540   {
541     this.adapterFactory = adapterFactory;
542     this.text = text;
543     this.image = image;
544     this.parent = parent;
545     this.children = new ItemProviderNotifyingArrayList();
546   }
547
548   /**
549    * This creates an instance with the given adapter factory that yields the given children.
550    */

551   public ItemProvider(AdapterFactory adapterFactory, Collection JavaDoc children)
552   {
553     this.adapterFactory = adapterFactory;
554     this.text = "";
555     this.children = new ItemProviderNotifyingArrayList(children);
556   }
557
558   /**
559    * This creates an instance with the given adapter factory and text that yields the given children.
560    */

561   public ItemProvider(AdapterFactory adapterFactory, String JavaDoc text, Collection JavaDoc children)
562   {
563     this.adapterFactory = adapterFactory;
564     this.text = text;
565     this.children = new ItemProviderNotifyingArrayList(children);
566   }
567
568   /**
569    * This creates an instance with the given adapter factory, text and image that yields the given children.
570    */

571   public ItemProvider
572     (AdapterFactory adapterFactory, String JavaDoc text, Object JavaDoc image, Collection JavaDoc children)
573   {
574     this.adapterFactory = adapterFactory;
575     this.text = text;
576     this.image = image;
577     this.children = new ItemProviderNotifyingArrayList(children);
578   }
579
580   /**
581    * This creates an instance with the given adapter factory, notifier, text, image, and parent that yields the given children.
582    * This is a fully specified instance.
583    */

584   public ItemProvider
585     (AdapterFactory adapterFactory,
586      String JavaDoc text,
587      Object JavaDoc image,
588      Object JavaDoc parent,
589      Collection JavaDoc children)
590   {
591     this.adapterFactory = adapterFactory;
592     this.text = text;
593     this.image = image;
594     this.parent = parent;
595     this.children = new ItemProviderNotifyingArrayList(children);
596   }
597
598   /**
599    * This yields the optional adapter factory.
600    */

601   public AdapterFactory getAdapterFactory()
602   {
603     return adapterFactory;
604   }
605
606   /**
607    * This sets the optional adapter factory.
608    */

609   public void setAdapterFactory(AdapterFactory adapterFactory)
610   {
611     this.adapterFactory = adapterFactory;
612   }
613
614   public void addListener(INotifyChangedListener listener)
615   {
616     if (changeNotifier == null)
617     {
618       changeNotifier = new ChangeNotifier();
619     }
620     changeNotifier.addListener(listener);
621   }
622
623   public void removeListener(INotifyChangedListener listener)
624   {
625     if (changeNotifier != null)
626     {
627       changeNotifier.removeListener(listener);
628     }
629   }
630
631   public void fireNotifyChanged(Notification notification)
632   {
633     if (changeNotifier != null)
634     {
635       changeNotifier.fireNotifyChanged(notification);
636     }
637
638     if (adapterFactory instanceof IChangeNotifier)
639     {
640       ((IChangeNotifier)adapterFactory).fireNotifyChanged(notification);
641     }
642   }
643
644   /**
645    * This implements {@link IStructuredItemContentProvider#getElements IStructuredItemContentProvider.getElements}
646    * by returning {@link #getChildren(Object)}.
647    * It seems that you almost always want getElements and getChildren to return the same thing, so this makes that easy.
648    */

649   public Collection JavaDoc getElements(Object JavaDoc object)
650   {
651     return getChildren(object);
652   }
653
654   /**
655    * This returns {@link #getChildren()}.
656    * It seems that you almost always want getElements and getChildren to return the same thing, so this makes that easy.
657    */

658   public EList getElements()
659   {
660     return getChildren();
661   }
662
663   /**
664    * This implements {@link ITreeItemContentProvider#getChildren ITreeItemContentProvider.getChildren}
665    * return {@link #children}.
666    * You can also choose to ignore the {@link #children} entirely and implement a virtual collection;
667    * In this case, you must implement notification is some other way yourself,
668    * and you should override {@link #hasChildren(Object)} appropriately.
669    */

670   public Collection JavaDoc getChildren(Object JavaDoc object)
671   {
672     return children;
673   }
674
675   /**
676    * This returns {@link #getChildren() getChildren(this)}.
677    */

678   public EList getChildren()
679   {
680     return children;
681   }
682
683   /**
684    * This implements {@link ITreeItemContentProvider#hasChildren ITreeItemContentProvider.hasChildren}
685    * by simply testing whether {@link #children} is empty.
686    * This implementation will always be right,
687    * however, for efficiency you may want to override it to return false for a leaf item, or true for an item that always has children.
688    */

689   public boolean hasChildren(Object JavaDoc object)
690   {
691     return !children.isEmpty();
692   }
693
694   /**
695    * This returns {@link #hasChildren() hasChildren(this)}.
696    */

697   public boolean hasChildren()
698   {
699     return hasChildren(this);
700   }
701
702   /**
703    * This implements {@link ITreeItemContentProvider#getParent ITreeItemContentProvider.getParent}
704    * by returning {@link #parent}.
705    */

706   public Object JavaDoc getParent(Object JavaDoc object)
707   {
708     return parent;
709   }
710
711   /**
712    * This returns {@link #getParent() getParent(this)}.
713    */

714   public Object JavaDoc getParent()
715   {
716     return getParent(this);
717   }
718
719   /**
720    * This implements {@link IUpdateableItemParent#setParent IUpdateableItemParent.setParent}
721    * by delegating to {@link #setParent(Object)}.
722    */

723   public void setParent(Object JavaDoc object, Object JavaDoc parent)
724   {
725     this.parent = parent;
726   }
727
728   /**
729    * This calls {@link #setParent(Object, Object) setParent(this, parent)}.
730    */

731   public void setParent(Object JavaDoc parent)
732   {
733     setParent(this, parent);
734   }
735
736   /**
737    * This implements {@link IItemLabelProvider#getImage IItemLabelProvider.getImage}
738    * by returning {@link #image}.
739    */

740   public Object JavaDoc getImage(Object JavaDoc object)
741   {
742     return image;
743   }
744
745   /**
746    * This delegates to {@link #getImage(Object) getImage(this)}.
747    */

748   public Object JavaDoc getImage()
749   {
750     return getImage(this);
751   }
752
753   /**
754    * This allows {@link #image} to be set.
755    * If there is a domain notifier, it fires the appropriate domain event.
756    */

757   public void setImage(Object JavaDoc object, Object JavaDoc image)
758   {
759     this.image = image;
760
761     fireNotifyChanged(new ItemProviderNotification(Notification.SET, null, image, Notification.NO_INDEX));
762   }
763
764   /**
765    * This delegates to {@link #setImage(Object, Object) setImage(this, image)}.
766    */

767   public void setImage(Object JavaDoc image)
768   {
769     setImage(this, image);
770   }
771
772   /**
773    * This implements {@link IItemLabelProvider#getText IItemLabelProvider.getText} by returning {@link #text}.
774    */

775   public String JavaDoc getText(Object JavaDoc object)
776   {
777     return text;
778   }
779
780   /**
781    * This delegates to {@link #getText(Object) getText(this)}.
782    */

783   public String JavaDoc getText()
784   {
785     return getText(this);
786   }
787
788   /**
789    * This implements {@link IUpdateableItemText#getUpdateableText IUpdateableItemText.getUpdateableText},
790    * although the class doesn't declare that it implements this interface.
791    */

792   public String JavaDoc getUpdateableText(Object JavaDoc object)
793   {
794     return getText(object);
795   }
796
797   /**
798    * This implements {@link IUpdateableItemText#setText IUpdateableItemText.setText},
799    * although the class doesn't declare that it implements this interface.
800    * If there is a domain notifier, it fires the appropriate domain event.
801    */

802   public void setText(Object JavaDoc object, String JavaDoc text)
803   {
804     this.text = text;
805
806     fireNotifyChanged(new ItemProviderNotification(Notification.SET, null, text, Notification.NO_INDEX));
807   }
808
809   /**
810    * This delegates to {@link #setText(Object, String) setText(this, text)}.
811    */

812   public void setText(String JavaDoc text)
813   {
814     setText(this, text);
815   }
816
817   /**
818    * This returns the super result with the {@link #text} appended to it.
819    */

820   public String JavaDoc toString()
821   {
822     return super.toString() + "[text=\"" + text + "\"]";
823   }
824
825   public void dispose()
826   {
827   }
828
829   /**
830    * This implements {@link IEditingDomainItemProvider#getNewChildDescriptors
831    * IEditingDomainItemProvider.getNewChildDescriptors}, returning an empty
832    * list.
833    */

834   public Collection JavaDoc getNewChildDescriptors(Object JavaDoc object, EditingDomain editingDomain, Object JavaDoc sibling)
835   {
836     return Collections.EMPTY_LIST;
837   }
838
839   /**
840    * This implements {@link IEditingDomainItemProvider#createCommand
841    * IEditingDomainItemProvider.createCommand()}, returning the unexecutable
842    * command.
843    */

844   public Command createCommand(Object JavaDoc object, EditingDomain editingDomain, Class JavaDoc commandClass, CommandParameter commandParameter)
845   {
846     return UnexecutableCommand.INSTANCE;
847   }
848 }
849
Popular Tags