KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > ui > mapping > SynchronizationContentProvider


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.team.ui.mapping;
12
13 import java.util.ArrayList JavaDoc;
14 import java.util.HashSet JavaDoc;
15 import java.util.List JavaDoc;
16 import java.util.Set JavaDoc;
17
18 import org.eclipse.core.resources.IResource;
19 import org.eclipse.core.resources.mapping.*;
20 import org.eclipse.core.runtime.*;
21 import org.eclipse.jface.util.IPropertyChangeListener;
22 import org.eclipse.jface.util.PropertyChangeEvent;
23 import org.eclipse.jface.viewers.*;
24 import org.eclipse.team.core.diff.*;
25 import org.eclipse.team.core.mapping.ISynchronizationContext;
26 import org.eclipse.team.core.mapping.ISynchronizationScope;
27 import org.eclipse.team.internal.core.TeamPlugin;
28 import org.eclipse.team.internal.ui.Utils;
29 import org.eclipse.team.internal.ui.synchronize.SynchronizePageConfiguration;
30 import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
31 import org.eclipse.ui.IMemento;
32 import org.eclipse.ui.navigator.*;
33
34 /**
35  * Abstract team aware content provider that delegates to another content provider.
36  *
37  * @since 3.2
38  */

39 public abstract class SynchronizationContentProvider implements ICommonContentProvider, IDiffChangeListener, IPropertyChangeListener {
40
41     private Viewer viewer;
42     private boolean empty;
43     private ICommonContentExtensionSite site;
44     
45     /* (non-Javadoc)
46      * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
47      */

48     public Object JavaDoc[] getChildren(Object JavaDoc parent) {
49         return internalGetChildren(parent, false);
50     }
51
52     /* (non-Javadoc)
53      * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
54      */

55     public Object JavaDoc[] getElements(Object JavaDoc parent) {
56         return internalGetChildren(parent, true);
57     }
58     
59     /* (non-Javadoc)
60      * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
61      */

62     public Object JavaDoc getParent(Object JavaDoc element) {
63         element = internalGetElement(element);
64         if (element instanceof ModelProvider)
65             return null;
66         if (element == getModelRoot())
67             return null;
68         Object JavaDoc parent = getDelegateContentProvider().getParent(element);
69         if (parent == getModelRoot())
70             return getModelProvider();
71         return parent;
72     }
73
74     /* (non-Javadoc)
75      * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
76      */

77     public boolean hasChildren(Object JavaDoc element) {
78         return internalHasChildren(element);
79     }
80     
81     private Object JavaDoc[] internalGetChildren(Object JavaDoc parent, boolean isElement) {
82         Object JavaDoc element = internalGetElement(parent);
83         if (element instanceof ISynchronizationScope) {
84             // If the root is a scope, we want to include all models in the scope
85
ISynchronizationScope rms = (ISynchronizationScope) element;
86             if (rms.getMappings(getModelProviderId()).length > 0) {
87                 empty = false;
88                 return new Object JavaDoc[] { getModelProvider() };
89             }
90             empty = true;
91             return new Object JavaDoc[0];
92         } else if (element instanceof ISynchronizationContext) {
93             ISynchronizationContext context = (ISynchronizationContext)element;
94             // If the root is a context, we want to filter by the context
95
ISynchronizationContext sc = (ISynchronizationContext) element;
96             if (sc.getScope().getMappings(getModelProviderId()).length > 0) {
97                 Object JavaDoc root = getModelRoot();
98                 boolean initialized = isInitialized(context);
99                 if (!initialized || getChildrenInContext(sc, root, getDelegateChildren(root, isElement)).length > 0) {
100                     if (!initialized)
101                         requestInitialization(context);
102                     empty = false;
103                     return new Object JavaDoc[] { getModelProvider() };
104                 }
105             }
106             empty = true;
107             return new Object JavaDoc[0];
108         }
109         if (element == getModelProvider()) {
110             ISynchronizationContext context = getContext();
111             if (context != null && !isInitialized(context)) {
112                 return new Object JavaDoc[0];
113             }
114             element = getModelRoot();
115             if (parent instanceof TreePath) {
116                 parent = TreePath.EMPTY.createChildPath(element);
117             } else {
118                 parent = element;
119             }
120         }
121         Object JavaDoc[] delegateChildren = getDelegateChildren(parent, isElement);
122         ISynchronizationContext context = getContext();
123         if (context == null) {
124             ISynchronizationScope scope = getScope();
125             if (scope == null) {
126                 return delegateChildren;
127             } else {
128                 return getChildrenInScope(scope, parent, delegateChildren);
129             }
130         } else {
131             return getChildrenInContext(context, parent, delegateChildren);
132         }
133     }
134
135     /**
136      * Return whether the content provider has been initialized and is ready to
137      * provide content in the given context. By default, <code>true</code> is returned. Subclasses
138      * that need to perform extra processing to prepare should override this method and
139      * also override {@link #requestInitialization(ISynchronizationContext)}.
140      *
141      * @param context the context
142      * @return whether the content provider has been initialized and is ready to
143      * provide content in he given context.
144      */

145     protected boolean isInitialized(ISynchronizationContext context) {
146         return true;
147     }
148     
149     /**
150      * Subclasses that need to perform extra processing to prepare their model
151      * to be displayed by this content provider should override this method and
152      * launch a background task to prepare what is required to display their
153      * model for the given context. An appropriate viewer refresh on the model
154      * provider should be issued when the model is prepared.
155      *
156      * @param context
157      * the context
158      */

159     protected void requestInitialization(ISynchronizationContext context) {
160         // Do nothing by default
161
}
162
163     /**
164      * Return the children for the given element from the
165      * delegate content provider.
166      * @param parent the parent element
167      * @return the children for the given element from the
168      * delegate content provider
169      */

170     protected Object JavaDoc[] getDelegateChildren(Object JavaDoc parent) {
171         return getDelegateContentProvider().getChildren(internalGetElement(parent));
172     }
173
174     private Object JavaDoc[] getDelegateChildren(Object JavaDoc parent, boolean isElement) {
175         if (isElement)
176             return getDelegateContentProvider().getElements(parent);
177         return getDelegateChildren(parent);
178     }
179
180     private boolean internalHasChildren(Object JavaDoc elementOrPath) {
181         //TODO: What about the context and scope
182
Object JavaDoc element = internalGetElement(elementOrPath);
183         if (element instanceof ModelProvider) {
184             element = getModelRoot();
185         }
186         if (getDelegateContentProvider().hasChildren(element)) {
187             ISynchronizationContext sc = getContext();
188             if (sc == null) {
189                 ISynchronizationScope scope = getScope();
190                 if (scope == null) {
191                     return true;
192                 } else {
193                     return hasChildrenInScope(scope, elementOrPath);
194                 }
195             } else {
196                 return hasChildrenInContext(sc, elementOrPath);
197             }
198         } else {
199             ISynchronizationContext sc = getContext();
200             if (sc != null)
201                 return hasChildrenInContext(sc, elementOrPath);
202         }
203         return false;
204     }
205
206     /**
207      * Return whether the given element has children in the given scope.
208      * By default, true is returned if the given element contains any elements
209      * in the scope or if any of the elements in the scope contain the given
210      * element and the delegate provider returns children for the element.
211      * The {@link ResourceMapping#contains(ResourceMapping)} is used to test
212      * for containment.
213      * Subclasses may override to provide a more efficient implementation.
214      * @param scope the scope
215      * @param element the element
216      * @return whether the given element has children in the given scope
217      */

218     protected boolean hasChildrenInScope(ISynchronizationScope scope, Object JavaDoc element) {
219         ResourceMapping mapping = Utils.getResourceMapping(internalGetElement(element));
220         if (mapping != null) {
221             ResourceMapping[] mappings = scope.getMappings(mapping.getModelProviderId());
222             for (int i = 0; i < mappings.length; i++) {
223                 ResourceMapping sm = mappings[i];
224                 if (mapping.contains(sm)) {
225                     return true;
226                 }
227                 if (sm.contains(mapping)) {
228                     return getDelegateChildren(element).length > 0;
229                 }
230             }
231         }
232         return false;
233     }
234
235     /**
236      * Return whether the given element has children in the given
237      * context. The children may or may not exist locally.
238      * By default, this method returns true if the traversals for
239      * the element contain any diffs. This could result in false
240      * positives. Subclasses can override to provide a more
241      * efficient or precise answer.
242      * @param element a model element.
243      * @return whether the given element has children in the given context
244      */

245     protected boolean hasChildrenInContext(ISynchronizationContext context, Object JavaDoc element) {
246         ResourceTraversal[] traversals = getTraversals(context, element);
247         if (traversals == null)
248             return true;
249         return context.getDiffTree().getDiffs(traversals).length > 0;
250     }
251
252     /* (non-Javadoc)
253      * @see org.eclipse.jface.viewers.IContentProvider#dispose()
254      */

255     public void dispose() {
256         ICommonContentExtensionSite extensionSite = getExtensionSite();
257         if (extensionSite != null) {
258             extensionSite.getExtensionStateModel().removePropertyChangeListener(this);
259         }
260         ISynchronizationContext context = getContext();
261         if (context != null)
262             context.getDiffTree().removeDiffChangeListener(this);
263         ISynchronizePageConfiguration configuration = getConfiguration();
264         if (configuration != null)
265             configuration.removePropertyChangeListener(this);
266     }
267
268     /* (non-Javadoc)
269      * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
270      */

271     public void inputChanged(Viewer viewer, Object JavaDoc oldInput, Object JavaDoc newInput) {
272         this.viewer = viewer;
273         getDelegateContentProvider().inputChanged(viewer, oldInput, newInput);
274     }
275
276     /* (non-Javadoc)
277      * @see org.eclipse.ui.navigator.ICommonContentProvider#init(org.eclipse.ui.navigator.ICommonContentExtensionSite)
278      */

279     public void init(ICommonContentExtensionSite site) {
280         // Set the site
281
this.site = site;
282         // Configure the content provider based on the site and state model
283
site.getExtensionStateModel().addPropertyChangeListener(this);
284         ISynchronizePageConfiguration configuration = getConfiguration();
285         if (configuration != null)
286             configuration.addPropertyChangeListener(this);
287         ITreeContentProvider provider = getDelegateContentProvider();
288         if (provider instanceof ICommonContentProvider) {
289             ((ICommonContentProvider) provider).init(site);
290         }
291         ISynchronizationContext context = getContext();
292         if (context != null)
293             context.getDiffTree().addDiffChangeListener(this);
294     }
295
296     /* (non-Javadoc)
297      * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
298      */

299     public void propertyChange(PropertyChangeEvent event) {
300         // TODO: this could happen at the root as well
301
if (event.getProperty().equals(ISynchronizePageConfiguration.P_MODE)) {
302             refresh();
303         }
304     }
305     
306     /**
307      * Return whether elements with the given direction should be included in
308      * the contents. The direction is one of {@link IThreeWayDiff#INCOMING},
309      * {@link IThreeWayDiff#OUTGOING} or {@link IThreeWayDiff#CONFLICTING}.
310      * This method is invoked by the
311      * {@link #getChildrenInContext(ISynchronizationContext, Object, Object[])}
312      * method to filter the list of children returned when
313      * {@link #getChildren(Object) } is called. It accessing the
314      * <code>ISynchronizePageConfiguration.P_MODE</code> property on the state
315      * model provided by the view to determine what kinds should be included.
316      *
317      * @param direction
318      * the synchronization direction
319      * @return whether elements with the given synchronization kind should be
320      * included in the contents
321      */

322     protected boolean includeDirection(int direction) {
323         ISynchronizePageConfiguration configuration = getConfiguration();
324         if (configuration != null)
325             return ((SynchronizePageConfiguration)configuration).includeDirection(direction);
326         return true;
327     }
328     
329     /**
330      * Return the synchronization context associated with the view to which
331      * this content provider applies. A <code>null</code> is returned if
332      * no context is available.
333      * @return the synchronization context or <code>null</code>
334      */

335     protected ISynchronizationContext getContext() {
336         ICommonContentExtensionSite extensionSite = getExtensionSite();
337         if (extensionSite != null)
338             return (ISynchronizationContext) extensionSite
339                     .getExtensionStateModel()
340                         .getProperty(
341                             ITeamContentProviderManager.P_SYNCHRONIZATION_CONTEXT);
342         return null;
343     }
344
345     /**
346      * Return the resource mapping scope associated with the view to which
347      * this content provider applies. A <code>null</code> is returned if
348      * no scope is available.
349      * @return the resource mapping scope or <code>null</code>
350      */

351     protected ISynchronizationScope getScope() {
352         ICommonContentExtensionSite extensionSite = getExtensionSite();
353         if (extensionSite != null)
354             return (ISynchronizationScope) extensionSite
355                     .getExtensionStateModel()
356                         .getProperty(
357                             ITeamContentProviderManager.P_SYNCHRONIZATION_SCOPE);
358         return null;
359     }
360     
361     /**
362      * Return the synchronization page configuration associated with the view to which
363      * this content provider applies. A <code>null</code> is returned if
364      * no configuration is available.
365      * @return the synchronization page configuration or <code>null</code>
366      */

367     protected ISynchronizePageConfiguration getConfiguration() {
368         ICommonContentExtensionSite extensionSite = getExtensionSite();
369         if (extensionSite != null)
370             return (ISynchronizePageConfiguration) extensionSite
371                     .getExtensionStateModel()
372                         .getProperty(
373                             ITeamContentProviderManager.P_SYNCHRONIZATION_PAGE_CONFIGURATION);
374         return null;
375     }
376     
377     /* (non-Javadoc)
378      * @see org.eclipse.ui.navigator.IMementoAware#restoreState(org.eclipse.ui.IMemento)
379      */

380     public void restoreState(IMemento aMemento) {
381         ITreeContentProvider provider = getDelegateContentProvider();
382         if (provider instanceof ICommonContentProvider) {
383             ((ICommonContentProvider) provider).restoreState(aMemento);
384         }
385     }
386
387     /* (non-Javadoc)
388      * @see org.eclipse.ui.navigator.IMementoAware#saveState(org.eclipse.ui.IMemento)
389      */

390     public void saveState(IMemento aMemento) {
391         ITreeContentProvider provider = getDelegateContentProvider();
392         if (provider instanceof ICommonContentProvider) {
393             ((ICommonContentProvider) provider).saveState(aMemento);
394         }
395     }
396     
397     /* (non-Javadoc)
398      * @see org.eclipse.team.core.delta.ISyncDeltaChangeListener#syncDeltaTreeChanged(org.eclipse.team.core.delta.ISyncDeltaChangeEvent, org.eclipse.core.runtime.IProgressMonitor)
399      */

400     public void diffsChanged(IDiffChangeEvent event, IProgressMonitor monitor) {
401         refresh();
402     }
403     
404     /* (non-Javadoc)
405      * @see org.eclipse.team.core.diff.IDiffChangeListener#propertyChanged(int, org.eclipse.core.runtime.IPath[])
406      */

407     public void propertyChanged(IDiffTree tree, int property, IPath[] paths) {
408         // Property changes only effect labels
409
}
410
411     /**
412      * Refresh the subtree associated with this model.
413      */

414     protected void refresh() {
415         Utils.syncExec(new Runnable JavaDoc() {
416             public void run() {
417                 TreeViewer treeViewer = ((TreeViewer)getViewer());
418                 // TODO: Need to know if the model root is present in order to refresh properly
419
if (empty)
420                     treeViewer.refresh();
421                 else
422                     treeViewer.refresh(getModelProvider());
423             }
424         
425         }, getViewer().getControl());
426     }
427
428     /**
429      * Return the model content provider that the team aware content
430      * provider delegates to.
431      * @return the model content provider
432      */

433     protected abstract ITreeContentProvider getDelegateContentProvider();
434     
435     /**
436      * Return the model provider for this content provider.
437      * @return the model provider for this content provider
438      */

439     protected final ModelProvider getModelProvider() {
440         try {
441             return ModelProvider.getModelProviderDescriptor(getModelProviderId()).getModelProvider();
442         } catch (CoreException e) {
443             // TODO: this is a bit harsh. can we do something less destructive
444
throw new IllegalStateException JavaDoc();
445         }
446     }
447     
448     /**
449      * Return the id of model provider for this content provider.
450      * @return the model provider for this content provider
451      */

452     protected abstract String JavaDoc getModelProviderId();
453     
454     /**
455      * Return the object that acts as the model root. It is used when getting the children
456      * for a model provider.
457      * @return the object that acts as the model root
458      */

459     protected abstract Object JavaDoc getModelRoot();
460
461     /**
462      * Return the viewer to which the content provider is associated.
463      * @return the viewer to which the content provider is associated
464      */

465     protected final Viewer getViewer() {
466         return viewer;
467     }
468     
469     /**
470      * Return the subset of the given children that are in the
471      * given scope or are parents of elements that are in scope.
472      * @param scope the scope
473      * @param parent the parent of the given children
474      * @param children all the children of the parent that are in scope.
475      * @return the subset of the given children that are in the
476      * scope of the content provider
477      */

478     protected Object JavaDoc[] getChildrenInScope(ISynchronizationScope scope, Object JavaDoc parent, Object JavaDoc[] children) {
479         List JavaDoc result = new ArrayList JavaDoc();
480         for (int i = 0; i < children.length; i++) {
481             Object JavaDoc object = children[i];
482             if (object != null && isInScope(scope, parent, object)) {
483                 result.add(object);
484             }
485         }
486         return result.toArray(new Object JavaDoc[result.size()]);
487     }
488     
489     /**
490      * Return the subset of children that are of interest from the given context.
491      * By default, this method returns those children whose traversals contain
492      * a diff in the context. However, it does not include those model elements
493      * that do not exist locally but are within the context (e.g. locally deleted
494      * elements and remotely added elements). Subclasses must override to include
495      * these.
496      * @param context the context
497      * @param parent the parent of the children
498      * @param children the children
499      * @return the subset of children that are of interest from the given context
500      */

501     protected Object JavaDoc[] getChildrenInContext(ISynchronizationContext context, Object JavaDoc parent, Object JavaDoc[] children) {
502         if (children.length != 0)
503             children = getChildrenInScope(context.getScope(), parent, children);
504         if (parent instanceof IResource) {
505             IResource resource = (IResource) parent;
506             children = getChildrenWithPhantoms(context, resource, children);
507         }
508         if (children.length == 0)
509             return children;
510         return internalGetChildren(context, parent, children);
511     }
512
513     private Object JavaDoc[] getChildrenWithPhantoms(ISynchronizationContext context, IResource resource, Object JavaDoc[] children) {
514         IResource[] setChildren = context.getDiffTree().members(resource);
515         if (setChildren.length == 0)
516             return children;
517         if (children.length == 0)
518             return setChildren;
519         Set JavaDoc result = new HashSet JavaDoc(children.length);
520         for (int i = 0; i < children.length; i++) {
521             result.add(children[i]);
522         }
523         for (int i = 0; i < setChildren.length; i++) {
524             result.add(setChildren[i]);
525         }
526         return result.toArray();
527     }
528
529     private Object JavaDoc[] internalGetChildren(ISynchronizationContext context, Object JavaDoc parent, Object JavaDoc[] children) {
530         List JavaDoc result = new ArrayList JavaDoc(children.length);
531         for (int i = 0; i < children.length; i++) {
532             Object JavaDoc object = children[i];
533             // If the parent is a TreePath then the subclass is
534
// TreePath aware and we can send a TrePath to the
535
// isVisible method
536
if (parent instanceof TreePath) {
537                 TreePath tp = (TreePath) parent;
538                 object = tp.createChildPath(object);
539             }
540             if (isVisible(context, object))
541                 result.add(internalGetElement(object));
542         }
543         return result.toArray(new Object JavaDoc[result.size()]);
544     }
545
546     /**
547      * Return whether the given object is visible in the synchronization page
548      * showing this content based on the diffs in the given context. Visibility
549      * is determined by obtaining the diffs for the object from the context by
550      * calling {@link #getTraversals(ISynchronizationContext, Object)} to get
551      * the traversals, then obtaining the diffs from the context's diff tree and
552      * then calling {@link #isVisible(IDiff)} for each diff.
553      *
554      * @param context
555      * the synchronization context
556      * @param object
557      * the object
558      * @return whether the given object is visible in the synchronization page
559      * showing this content
560      */

561     protected boolean isVisible(ISynchronizationContext context, Object JavaDoc object) {
562         ResourceTraversal[] traversals = getTraversals(context, object);
563         IDiff[] deltas = context.getDiffTree().getDiffs(traversals);
564         boolean visible = false;
565         if (isVisible(deltas)) {
566             visible = true;
567         }
568         return visible;
569     }
570
571     private boolean isVisible(IDiff[] diffs) {
572         if (diffs.length > 0) {
573             for (int j = 0; j < diffs.length; j++) {
574                 IDiff diff = diffs[j];
575                 if (isVisible(diff)) {
576                     return true;
577                 }
578             }
579         }
580         return false;
581     }
582     
583     /**
584      * Return whether the given diff should be visible based on the
585      * configuration of the synchronization page showing this content. An
586      * {@link IThreeWayDiff} is visible if the direction of the change matches
587      * the mode of the synchronization page. An {@link ITwoWayDiff} is visible
588      * if it has a kind that represents a change.
589      *
590      * @param diff
591      * the diff
592      * @return whether the diff should be visible
593      */

594     protected boolean isVisible(IDiff diff) {
595         if (diff instanceof IThreeWayDiff) {
596             IThreeWayDiff twd = (IThreeWayDiff) diff;
597             return includeDirection(twd.getDirection());
598         }
599         return diff.getKind() != IDiff.NO_CHANGE;
600     }
601
602     /**
603      * Return the traversals for the given object in the given context. This
604      * method must not be long running. If a long running calculation is required
605      * to calculate the traversals, an empty traversal should be returned and the
606      * content provider should initiate a background task to calculate the
607      * required traversals and update the view according when the task completes.
608      * @param context the synchronization context
609      * @param object the object
610      * @return the traversals for the given object in the given context
611      */

612     protected abstract ResourceTraversal[] getTraversals(ISynchronizationContext context, Object JavaDoc object);
613     
614     /**
615      * Handle the given exception that occurred while calculating the
616      * children for an element.
617      * @param e the exception
618      */

619     protected void handleException(CoreException e) {
620         TeamPlugin.log(e);
621     }
622
623     /**
624      * Return whether the given object is within the scope of this
625      * content provider. The object is in scope if it is part of
626      * a resource mapping in the scope or is the parent of resources
627      * covered by one or more resource mappings in the scope.
628      * By default, this compares the mapping of the given element
629      * with those in the scope using the {@link ResourceMapping#contains(ResourceMapping)}
630      * method to determine if the element is in the scope. Subclasses may
631      * override to provide a more efficient means of doing the check.
632      * @param scope the scope
633      * @param parent the parent of the object
634      * @param element the object
635      * @return whether the given object is within the scope of this
636      * content provider
637      */

638     protected boolean isInScope(ISynchronizationScope scope, Object JavaDoc parent, Object JavaDoc element) {
639         ResourceMapping mapping = Utils.getResourceMapping(internalGetElement(element));
640         if (mapping != null) {
641             ResourceMapping[] mappings = ((ISynchronizationScope)scope).getMappings(mapping.getModelProviderId());
642             for (int i = 0; i < mappings.length; i++) {
643                 ResourceMapping sm = mappings[i];
644                 if (mapping.contains(sm)) {
645                     return true;
646                 }
647                 if (sm.contains(mapping)) {
648                     return true;
649                 }
650             }
651         }
652         return false;
653     }
654
655     /**
656      * Return the Common Navigator extension site for this
657      * content provider.
658      * @return the Common Navigator extension site for this
659      * content provider
660      */

661     public ICommonContentExtensionSite getExtensionSite() {
662         return site;
663     }
664     
665     private Object JavaDoc internalGetElement(Object JavaDoc elementOrPath) {
666         if (elementOrPath instanceof TreePath) {
667             TreePath tp = (TreePath) elementOrPath;
668             return tp.getLastSegment();
669         }
670         return elementOrPath;
671     }
672     
673     /**
674      * Return whether the page has been set to use a flat layout.
675      * @return whether the page has been set to use a flat layout
676      * @since 3.3
677      */

678     protected final boolean isFlatLayout() {
679         ISynchronizePageConfiguration c = getConfiguration();
680         if (c != null) {
681             String JavaDoc p = (String JavaDoc)c.getProperty(ITeamContentProviderManager.PROP_PAGE_LAYOUT);
682             return p != null && p.equals(ITeamContentProviderManager.FLAT_LAYOUT);
683         }
684         return false;
685     }
686 }
687
Popular Tags