KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > compare > CompareConfiguration


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.compare;
12
13 import java.util.*;
14
15 import org.eclipse.compare.internal.*;
16 import org.eclipse.compare.structuremergeviewer.Differencer;
17 import org.eclipse.compare.structuremergeviewer.ICompareInput;
18 import org.eclipse.core.runtime.ListenerList;
19 import org.eclipse.jface.preference.IPreferenceStore;
20 import org.eclipse.jface.resource.ImageDescriptor;
21 import org.eclipse.jface.util.IPropertyChangeListener;
22 import org.eclipse.jface.util.PropertyChangeEvent;
23 import org.eclipse.jface.viewers.*;
24 import org.eclipse.swt.graphics.Image;
25
26 /**
27  * A <code>CompareConfiguration</code> object
28  * controls various UI aspects of compare/merge viewers like
29  * title labels and images, or whether a side of a merge viewer is editable.
30  * In addition to these fixed properties <code>ICompareConfiguration</code> provides
31  * API for an open ended set of properties. Different viewers which share the same
32  * configuration can communicate via this mechanism. E.g. if a compare editor
33  * has a button for controlling whether compare viewers ignore white space,
34  * the button would trigger a change of the boolean <code>IGNORE_WHITESPACE</code> property
35  * and all interested viewers would receive notification.
36  * <p>
37  * Suitable default labels are provided (without images); both the left and right sides
38  * are editable.
39  * </p>
40  * <p>
41  * Clients may use this class as is, or subclass to add new state and behavior.
42  * </p>
43  */

44 public class CompareConfiguration {
45
46     /**
47      * Name of the ignore whitespace property (value <code>"IGNORE_WHITESPACE"</code>).
48      */

49     public static final String JavaDoc IGNORE_WHITESPACE= "IGNORE_WHITESPACE"; //$NON-NLS-1$
50
/**
51      * Name of the show pseudo conflicts property (value <code>"SHOW_PSEUDO_CONFLICTS"</code>).
52      */

53     public static final String JavaDoc SHOW_PSEUDO_CONFLICTS= "SHOW_PSEUDO_CONFLICTS"; //$NON-NLS-1$
54
/**
55      * Name of the use outline view property (value <code>"USE_OUTLINE_VIEW"</code>).
56      * @since 3.0
57      */

58     public static final String JavaDoc USE_OUTLINE_VIEW= "USE_OUTLINE_VIEW"; //$NON-NLS-1$
59

60     private static ImageDescriptor[] fgImages= new ImageDescriptor[16];
61     private static Object JavaDoc fgDummy= new Object JavaDoc();
62     private static HashMap fgMap= new HashMap(20);
63     private static boolean fLeftIsLocal= true;
64
65     static {
66         if (fLeftIsLocal) {
67             fgImages[Differencer.ADDITION]= CompareUIPlugin.getImageDescriptor("ovr16/del_ov.gif"); //$NON-NLS-1$
68
fgImages[Differencer.LEFT + Differencer.ADDITION]= CompareUIPlugin.getImageDescriptor("ovr16/r_inadd_ov.gif"); //$NON-NLS-1$
69
fgImages[Differencer.RIGHT + Differencer.ADDITION]= CompareUIPlugin.getImageDescriptor("ovr16/r_outadd_ov.gif"); //$NON-NLS-1$
70

71             fgImages[Differencer.DELETION]= CompareUIPlugin.getImageDescriptor("ovr16/add_ov.gif"); //$NON-NLS-1$
72
fgImages[Differencer.LEFT + Differencer.DELETION]= CompareUIPlugin.getImageDescriptor("ovr16/r_indel_ov.gif"); //$NON-NLS-1$
73
fgImages[Differencer.RIGHT + Differencer.DELETION]= CompareUIPlugin.getImageDescriptor("ovr16/r_outdel_ov.gif"); //$NON-NLS-1$
74

75             fgImages[Differencer.LEFT + Differencer.CHANGE]= CompareUIPlugin.getImageDescriptor("ovr16/r_inchg_ov.gif"); //$NON-NLS-1$
76
fgImages[Differencer.RIGHT + Differencer.CHANGE]= CompareUIPlugin.getImageDescriptor("ovr16/r_outchg_ov.gif"); //$NON-NLS-1$
77
} else {
78             fgImages[Differencer.ADDITION]= CompareUIPlugin.getImageDescriptor("ovr16/add_ov.gif"); //$NON-NLS-1$
79
fgImages[Differencer.LEFT + Differencer.ADDITION]= CompareUIPlugin.getImageDescriptor("ovr16/inadd_ov.gif"); //$NON-NLS-1$
80
fgImages[Differencer.RIGHT + Differencer.ADDITION]= CompareUIPlugin.getImageDescriptor("ovr16/outadd_ov.gif"); //$NON-NLS-1$
81

82             fgImages[Differencer.DELETION]= CompareUIPlugin.getImageDescriptor("ovr16/del_ov.gif"); //$NON-NLS-1$
83
fgImages[Differencer.LEFT + Differencer.DELETION]= CompareUIPlugin.getImageDescriptor("ovr16/indel_ov.gif"); //$NON-NLS-1$
84
fgImages[Differencer.RIGHT + Differencer.DELETION]= CompareUIPlugin.getImageDescriptor("ovr16/outdel_ov.gif"); //$NON-NLS-1$
85

86             fgImages[Differencer.LEFT + Differencer.CHANGE]= CompareUIPlugin.getImageDescriptor("ovr16/inchg_ov.gif"); //$NON-NLS-1$
87
fgImages[Differencer.RIGHT + Differencer.CHANGE]= CompareUIPlugin.getImageDescriptor("ovr16/outchg_ov.gif"); //$NON-NLS-1$
88
}
89
90         fgImages[Differencer.CONFLICTING + Differencer.ADDITION]= CompareUIPlugin.getImageDescriptor("ovr16/confadd_ov.gif"); //$NON-NLS-1$
91
fgImages[Differencer.CONFLICTING + Differencer.DELETION]= CompareUIPlugin.getImageDescriptor("ovr16/confdel_ov.gif"); //$NON-NLS-1$
92
fgImages[Differencer.CONFLICTING + Differencer.CHANGE]= CompareUIPlugin.getImageDescriptor("ovr16/confchg_ov.gif"); //$NON-NLS-1$
93
}
94
95     private IPreferenceStore fPreferenceStore;
96     private ListenerList fListeners= new ListenerList();
97     private HashMap fProperties= new HashMap();
98     private boolean fLeftEditable= true;
99     private boolean fRightEditable= true;
100     private String JavaDoc fAncestorLabel;
101     private String JavaDoc fLeftLabel;
102     private String JavaDoc fRightLabel;
103     private Image fAncestorImage;
104     private Image fRightImage;
105     private Image fLeftImage;
106     private Image[] fImages= new Image[16];
107     private ICompareContainer fContainer;
108     private DefaultLabelProvider labelProvider = new DefaultLabelProvider();
109     
110     private class DefaultLabelProvider extends LabelProvider implements ICompareInputLabelProvider, ILabelProviderListener {
111         private Map labelProviders = new HashMap();
112         private ICompareInputLabelProvider defaultLabelProvider;
113         public Image getAncestorImage(Object JavaDoc input) {
114             ICompareInputLabelProvider provider = getLabelProvider(input);
115             if (provider != null) {
116                 Image image = provider.getAncestorImage(input);
117                 if (image != null)
118                     return image;
119             }
120             return fAncestorImage;
121         }
122         public String JavaDoc getAncestorLabel(Object JavaDoc input) {
123             ICompareInputLabelProvider provider = getLabelProvider(input);
124             if (provider != null) {
125                 String JavaDoc label = provider.getAncestorLabel(input);
126                 if (label != null)
127                     return label;
128             }
129             return fAncestorLabel;
130         }
131         public Image getLeftImage(Object JavaDoc input) {
132             ICompareInputLabelProvider provider = getLabelProvider(input);
133             if (provider != null) {
134                 Image image = provider.getLeftImage(input);
135                 if (image != null)
136                     return image;
137             }
138             return fLeftImage;
139         }
140         public String JavaDoc getLeftLabel(Object JavaDoc input) {
141             ICompareInputLabelProvider provider = getLabelProvider(input);
142             if (provider != null) {
143                 String JavaDoc label = provider.getLeftLabel(input);
144                 if (label != null)
145                     return label;
146             }
147             return fLeftLabel;
148         }
149         public Image getRightImage(Object JavaDoc input) {
150             ICompareInputLabelProvider provider = getLabelProvider(input);
151             if (provider != null) {
152                 Image image = provider.getRightImage(input);
153                 if (image != null)
154                     return image;
155             }
156             return fRightImage;
157         }
158         public String JavaDoc getRightLabel(Object JavaDoc input) {
159             ICompareInputLabelProvider provider = getLabelProvider(input);
160             if (provider != null) {
161                 String JavaDoc label = provider.getRightLabel(input);
162                 if (label != null)
163                     return label;
164             }
165             return fRightLabel;
166         }
167         public ICompareInputLabelProvider getLabelProvider(Object JavaDoc input) {
168             ICompareInputLabelProvider lp = (ICompareInputLabelProvider)labelProviders.get(input);
169             if (lp == null)
170                 return defaultLabelProvider;
171             return lp;
172         }
173         public void setLabelProvider(ICompareInput input, ICompareInputLabelProvider labelProvider) {
174             ICompareInputLabelProvider old = (ICompareInputLabelProvider)labelProviders.get(input);
175             if (old != null)
176                 old.removeListener(this);
177             labelProviders.put(input, labelProvider);
178             labelProvider.addListener(this);
179         }
180         public Image getImage(Object JavaDoc element) {
181             ICompareInputLabelProvider provider = getLabelProvider(element);
182             if (provider != null) {
183                 Image image = provider.getImage(element);
184                 if (image != null)
185                     return image;
186             }
187             if (element instanceof ICompareInput) {
188                 ICompareInput ci = (ICompareInput) element;
189                 Image image = ci.getImage();
190                 if (image != null)
191                     return image;
192             }
193             return super.getImage(element);
194         }
195         public String JavaDoc getText(Object JavaDoc element) {
196             ICompareInputLabelProvider provider = getLabelProvider(element);
197             if (provider != null) {
198                 String JavaDoc label = provider.getText(element);
199                 if (label != null)
200                     return label;
201             }
202             if (element instanceof ICompareInput) {
203                 ICompareInput ci = (ICompareInput) element;
204                 String JavaDoc label = ci.getName();
205                 if (label != null)
206                     return label;
207             }
208             return super.getText(element);
209         }
210         
211         public void dispose() {
212             for (Iterator iterator = labelProviders.values().iterator(); iterator.hasNext();) {
213                 ICompareInputLabelProvider lp = (ICompareInputLabelProvider) iterator.next();
214                 lp.removeListener(this);
215             }
216             if (defaultLabelProvider != null)
217                 defaultLabelProvider.removeListener(this);
218             defaultLabelProvider = null;
219             labelProviders.clear();
220         }
221             
222         public void labelProviderChanged(LabelProviderChangedEvent event) {
223             fireLabelProviderChanged(new LabelProviderChangedEvent(this, event.getElements()));
224         }
225         public void setDefaultLabelProvider(ICompareInputLabelProvider labelProvider) {
226             if (defaultLabelProvider != null)
227                 defaultLabelProvider.removeListener(this);
228             defaultLabelProvider = labelProvider;
229             if (defaultLabelProvider != null)
230                 defaultLabelProvider.addListener(this);
231         }
232     }
233
234     /**
235      * Creates a new configuration with editable left and right sides,
236      * suitable default labels, and no images.
237      * The given preference store is used to connect this configuration
238      * with the Compare preference page properties <code>ComparePreferencePage.INITIALLY_SHOW_ANCESTOR_PANE</code>,
239      * and <code>CompareConfiguration.IGNORE_WHITESPACE</code>.
240      *
241      * @param prefStore the preference store which this configuration holds onto.
242      * @since 2.0
243      */

244     public CompareConfiguration(IPreferenceStore prefStore) {
245         
246         setProperty("LEFT_IS_LOCAL", Boolean.valueOf(fLeftIsLocal)); //$NON-NLS-1$
247

248         fPreferenceStore= prefStore;
249         if (fPreferenceStore != null) {
250             boolean b= fPreferenceStore.getBoolean(ComparePreferencePage.INITIALLY_SHOW_ANCESTOR_PANE);
251             setProperty(ICompareUIConstants.PROP_ANCESTOR_VISIBLE, new Boolean JavaDoc(b));
252             
253             b= fPreferenceStore.getBoolean(ComparePreferencePage.IGNORE_WHITESPACE);
254             setProperty(CompareConfiguration.IGNORE_WHITESPACE, new Boolean JavaDoc(b));
255         }
256     }
257     
258     /**
259      * Creates a new configuration with editable left and right sides,
260      * suitable default labels, and no images.
261      * This configuration uses the preference store of the Compare plug-in
262      * (<code>CompareUIPlugin.getDefault().getPreferenceStore()</code>).
263      */

264     public CompareConfiguration() {
265         this(CompareUIPlugin.getDefault().getPreferenceStore());
266     }
267     
268     /**
269      * Returns the preference store of this configuration.
270      * @return the preference store of this configuration.
271      * @since 2.0
272      */

273     public IPreferenceStore getPreferenceStore() {
274         return fPreferenceStore;
275     }
276     
277     /**
278      * Returns an image showing the specified change kind.
279      * The different kind of changes are defined in the <code>Differencer</code>.
280      * Newly created images are remembered by this class and
281      * disposed when the <code>dispose</code> method is called.
282      *
283      * @param kind the kind of change as defined in <code>Differencer</code>.
284      * @return an modification of the base image reflecting the kind of change.
285      * @see org.eclipse.compare.structuremergeviewer.Differencer
286      * @since 2.0
287      */

288     public Image getImage(int kind) {
289         if (fImages == null)
290             // The configuration has been disposed
291
return null;
292         Image image= fImages[kind & 15];
293         if (image == null) {
294             ImageDescriptor id= fgImages[kind & 15];
295             if (id != null)
296                 image= id.createImage();
297             fImages[kind & 15]= image;
298         }
299         return image;
300     }
301     
302     /**
303      * Returns an image showing the specified change kind applied to a
304      * given base image. The different kind of changes are defined in the <code>Differencer</code>.
305      * Typically an implementation would build a composite image
306      * from the given base image and an image representing the change kind.
307      * Newly created images are remembered by this class and
308      * disposed when the <code>dispose</code> method is called.
309      *
310      * @param base the image which is modified to reflect the kind of change
311      * @param kind the kind of change as defined in <code>Differencer</code>.
312      * @return an modification of the base image reflecting the kind of change.
313      * @see org.eclipse.compare.structuremergeviewer.Differencer
314      */

315     public Image getImage(Image base, int kind) {
316
317         Object JavaDoc key= base;
318         if (key == null)
319             key= fgDummy;
320
321         kind &= 15;
322
323         Image[] a= (Image[]) fgMap.get(key);
324         if (a == null) {
325             a= new Image[16];
326             fgMap.put(key, a);
327         }
328         Image b= a[kind];
329         if (b == null) {
330             b= new DiffImage(base, fgImages[kind], ICompareUIConstants.COMPARE_IMAGE_WIDTH, !fLeftIsLocal).createImage();
331             CompareUI.disposeOnShutdown(b);
332             a[kind]= b;
333         }
334         return b;
335     }
336     
337     /**
338      * Dispose of this compare configuration.
339      * This method is called if the compare configuration is no longer used.
340      * An implementation must dispose of all resources.
341      */

342     public void dispose() {
343         if (fImages != null) {
344             for (int i= 0; i < fImages.length; i++){
345                 Image image= fImages[i];
346                 if (image != null && !image.isDisposed())
347                     image.dispose();
348             }
349         }
350         fImages= null;
351         labelProvider.dispose();
352     }
353
354     /**
355      * Fires a <code>PropertyChangeEvent</code> to registered listeners.
356      *
357      * @param propertyName the name of the property that has changed
358      * @param oldValue the property's old value
359      * @param newValue the property's new value
360      */

361     private void fireChange(String JavaDoc propertyName, Object JavaDoc oldValue, Object JavaDoc newValue) {
362         PropertyChangeEvent event= null;
363         Object JavaDoc[] listeners= fListeners.getListeners();
364         if (listeners != null) {
365             for (int i= 0; i < listeners.length; i++) {
366                 IPropertyChangeListener l= (IPropertyChangeListener) listeners[i];
367                 if (event == null)
368                     event= new PropertyChangeEvent(this, propertyName, oldValue, newValue);
369                 l.propertyChange(event);
370             }
371         }
372     }
373
374     /* (non javadoc)
375      * see IPropertyChangeNotifier.addListener
376      */

377     public void addPropertyChangeListener(IPropertyChangeListener listener) {
378         fListeners.add(listener);
379     }
380
381     /* (non javadoc)
382      * see IPropertyChangeNotifier.removeListener
383      */

384     public void removePropertyChangeListener(IPropertyChangeListener listener) {
385         fListeners.remove(listener);
386     }
387
388     /**
389      * Sets the property with the given name.
390      * If the new value differs from the old a <code>PropertyChangeEvent</code>
391      * is sent to registered listeners.
392      *
393      * @param key the name of the property to set
394      * @param newValue the new value of the property
395      */

396     public void setProperty(String JavaDoc key, Object JavaDoc newValue) {
397         Object JavaDoc oldValue= fProperties.get(key);
398         fProperties.put(key, newValue);
399         if (oldValue == null || !oldValue.equals(newValue))
400             fireChange(key, oldValue, newValue);
401     }
402
403     /**
404      * Returns the property with the given name, or <code>null</code>
405      * if no such property exists.
406      *
407      * @param key the name of the property to retrieve
408      * @return the property with the given name, or <code>null</code> if not found
409      */

410     public Object JavaDoc getProperty(String JavaDoc key) {
411         return fProperties.get(key);
412     }
413
414     //---- ancestor
415

416     /**
417      * Sets the label to use for the ancestor of compare/merge viewers.
418      * This label will be used if the element for which a label
419      * is requested does not have an ancestor or the element does not have
420      * a registered label provider or the label provider returns <code>null</code>
421      * as the label.
422      *
423      * @param label the new label for the ancestor of compare/merge viewers
424      */

425     public void setAncestorLabel(String JavaDoc label) {
426         fAncestorLabel= label;
427     }
428
429     /**
430      * Returns the label for the ancestor side of compare/merge viewers.
431      * This label is typically shown in the title of the ancestor area in a compare viewer.
432      *
433      * @param element the input object of a compare/merge viewer or <code>null</code>
434      * @return the label for the ancestor side or <code>null</code>
435      */

436     public String JavaDoc getAncestorLabel(Object JavaDoc element) {
437         return labelProvider.getAncestorLabel(element);
438     }
439
440     /**
441      * Sets the image to use for the ancestor of compare/merge viewers.
442      * The CompareConfiguration does not automatically dispose the old image.
443      * This image will be used if the element for which a image
444      * is requested does not have an ancestor or the element does not have
445      * a registered label provider or the label provider returns <code>null</code>
446      * as the image.
447      *
448      * @param image the new image for the ancestor of compare/merge viewers
449      */

450     public void setAncestorImage(Image image) {
451         fAncestorImage= image;
452     }
453
454     /**
455      * Returns the image for the ancestor side of compare/merge viewers.
456      * This image is typically shown in the title of the ancestor area in a compare viewer.
457      *
458      * @param element the input object of a compare/merge viewer or <code>null</code>
459      * @return the image for the ancestor side or <code>null</code>
460      */

461     public Image getAncestorImage(Object JavaDoc element) {
462         return labelProvider.getAncestorImage(element);
463     }
464
465     //---- left side
466

467     /**
468      * Controls whether the left side of a merge viewer is editable.
469      *
470      * @param editable if the value is <code>true</code> left side is editable
471      */

472     public void setLeftEditable(boolean editable) {
473         fLeftEditable= editable;
474     }
475     
476     /**
477      * Returns whether the left hand side of a merge viewer is editable.
478      *
479      * @return <code>true</code> if the left hand side is editable
480      */

481     public boolean isLeftEditable() {
482         return fLeftEditable;
483     }
484
485     /**
486      * Sets the label to use for the left side of compare/merge viewers.
487      * This label will be used if the element for which a label
488      * is requested does not have a left contributor or the element does not have
489      * a registered label provider or the label provider returns <code>null</code>
490      * as the label.
491      *
492      * @param label the new label for the left side of compare/merge viewers
493      */

494     public void setLeftLabel(String JavaDoc label) {
495         fLeftLabel= label;
496     }
497     
498     /**
499      * Returns the label for the left hand side of compare/merge viewers.
500      * This label is typically shown in the title of the left side of a compare viewer.
501      *
502      * @param element the input object of a compare/merge viewer or <code>null</code>
503      * @return the label for the left hand side or <code>null</code>
504      */

505     public String JavaDoc getLeftLabel(Object JavaDoc element) {
506         return labelProvider.getLeftLabel(element);
507     }
508
509     /**
510      * Sets the image to use for the left side of compare/merge viewers.
511      * The compare configuration does not automatically dispose the old image.
512      * This image will be used if the element for which a image
513      * is requested does not have an left contributor or the element does not have
514      * a registered label provider or the label provider returns <code>null</code>
515      * as the image.
516      *
517      * @param image the new image for the left side of compare/merge viewers
518      */

519     public void setLeftImage(Image image) {
520         fLeftImage= image;
521     }
522
523     /**
524      * Returns the image for the left hand side of compare/merge viewers.
525      * This image is typically shown in the title of the left side of a compare viewer.
526      *
527      * @param element the input object of a compare/merge viewer or <code>null</code>
528      * @return the image for the left hand side or <code>null</code>
529      */

530     public Image getLeftImage(Object JavaDoc element) {
531         return labelProvider.getLeftImage(element);
532     }
533     
534     //---- right side
535

536     /**
537      * Controls whether the right side of a merge viewer is editable.
538      *
539      * @param editable if the value is <code>true</code> right side is editable
540      */

541     public void setRightEditable(boolean editable) {
542         fRightEditable= editable;
543     }
544     
545     /**
546      * Returns whether the right hand side of a merge viewer is editable.
547      *
548      * @return <code>true</code> if the right hand side is editable
549      */

550     public boolean isRightEditable() {
551         return fRightEditable;
552     }
553
554     /**
555      * Sets the label to use for the right side of compare/merge viewers.
556      * This label will be used if the element for which a label
557      * is requested does not have an right contributor or the element does not have
558      * a registered label provider or the label provider returns <code>null</code>
559      * as the label.
560      *
561      * @param label the new label for the right side of compare/merge viewers
562      */

563     public void setRightLabel(String JavaDoc label) {
564         fRightLabel= label;
565     }
566
567     /**
568      * Returns the label for the right hand side of compare/merge viewers.
569      * This label is typically shown in the title of the right side of a compare viewer.
570      *
571      * @param element the input object of a compare/merge viewer or <code>null</code>
572      * @return the label for the right hand side or <code>null</code>
573      */

574     public String JavaDoc getRightLabel(Object JavaDoc element) {
575         return labelProvider.getRightLabel(element);
576     }
577
578     /**
579      * Sets the image to use for the right side of compare/merge viewers.
580      * The compare configuration does not automatically dispose the old image.
581      * This image will be used if the element for which a image
582      * is requested does not have an right contributor or the element does not have
583      * a registered label provider or the label provider returns <code>null</code>
584      * as the image.
585      *
586      * @param image the new image for the right side of compare/merge viewers
587      */

588     public void setRightImage(Image image) {
589         fRightImage= image;
590     }
591
592     /**
593      * Returns the image for the right hand side of compare/merge viewers.
594      * This image is typically shown in the title of the right side of a compare viewer.
595      *
596      * @param element the input object of a compare/merge viewer or <code>null</code>
597      * @return the image for the right hand side or <code>null</code>
598      */

599     public Image getRightImage(Object JavaDoc element) {
600         return labelProvider.getRightImage(element);
601     }
602     
603     /**
604      * Return the container of the compare associated with this configuration.
605      * @return the container of the compare associated with this configuration
606      * @since 3.3
607      */

608     public ICompareContainer getContainer() {
609         if (fContainer == null) {
610             // Create a default container in case one is not provided
611
fContainer= new CompareContainer();
612         }
613         return fContainer;
614     }
615
616     /**
617      * Set the container of the compare associated with this configuration.
618      * @param container the container of the compare associated with this configuration.
619      * @since 3.3
620      */

621     public void setContainer(ICompareContainer container) {
622         fContainer = container;
623     }
624     
625     /**
626      * Return the label provider that is used to determine the
627      * text and labels return by this compare configuration.
628      * @return the label provider that is used to determine the
629      * text and labels return by this compare configuration
630      * @see #getAncestorImage(Object)
631      * @see #getAncestorLabel(Object)
632      * @see #getLeftImage(Object)
633      * @see #getLeftLabel(Object)
634      * @see #getRightImage(Object)
635      * @see #getRightLabel(Object)
636      * @since 3.3
637      */

638     public ICompareInputLabelProvider getLabelProvider() {
639         return labelProvider;
640     }
641     
642     /**
643      * Set the label provider for the given compare input. The compare configuration
644      * will not dispose of the label provider when the configuration is disposed.
645      * It is up to the provider of the label provider to ensure that it is
646      * disposed when it is no longer needed.
647      * @param input the compare input
648      * @param labelProvider the label provider for the compare input
649      * @since 3.3
650      */

651     public void setLabelProvider(ICompareInput input, ICompareInputLabelProvider labelProvider) {
652         this.labelProvider.setLabelProvider(input, labelProvider);
653     }
654     
655     /**
656      * Set the default label provider for this configuration. The default label
657      * provider is used when a particular label provider has not been assigned
658      * using
659      * {@link #setLabelProvider(ICompareInput, ICompareInputLabelProvider)}.
660      * The compare configuration will not dispose of the label provider when the
661      * configuration is disposed. It is up to the provider of the label provider
662      * to ensure that it is disposed when it is no longer needed.
663      *
664      * @param labelProvider the default label provider
665      * @since 3.3
666      */

667     public void setDefaultLabelProvider(ICompareInputLabelProvider labelProvider) {
668         this.labelProvider.setDefaultLabelProvider(labelProvider);
669     }
670     
671 }
672
673
Popular Tags