AbstractContentProvider.java

Go to the documentation of this file.
00001 package edu.rice.cs.hpc.viewer.scope;
00002 
00003 import org.eclipse.jface.viewers.ITreeContentProvider;
00004 import org.eclipse.jface.viewers.Viewer;
00005 
00006 import edu.rice.cs.hpc.data.experiment.scope.Scope;
00007 
00008 public abstract class AbstractContentProvider implements ITreeContentProvider 
00009 {
00010     protected ScopeTreeViewer viewer;
00011     protected boolean enableFilter = false;
00012     
00013     public void setEnableFilter(boolean isFilterEnabled)
00014     {
00015         this.enableFilter = isFilterEnabled;
00016     }
00017     
00021     public Object[] getElements(Object inputElement) {
00022             return getChildren(inputElement);
00023     }
00024 
00028     public Object[] getChildren(Object parentElement) {
00029         if(parentElement instanceof Scope) {
00030             // normal mode
00031             Scope parent = ((Scope) parentElement);
00032             Object arrChildren[] = parent.getChildren();
00033             // if the database has empty data, the children is null
00034             if (arrChildren != null && arrChildren.length>0)
00035             {
00036                 return arrChildren;
00037             }
00038         }
00039         return null;
00040     }
00041     
00042 
00043     /*
00044      * (non-Javadoc)
00045      * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
00046      */
00047     public Object getParent(Object element) {
00048         if(element instanceof Scope)
00049             return ((Scope) element).getParent();
00050         else
00051             return null;
00052     }
00053 
00054     /*
00055      * (non-Javadoc)
00056      * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
00057      */
00058     public boolean hasChildren(Object element) {
00059         if(element instanceof Scope)
00060             return ((Scope) element).hasChildren(); // !((Scope.Node) element).isLeaf();
00061         else
00062             return false;
00063     }
00064 
00075     public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
00076         if (viewer instanceof ScopeTreeViewer)
00077             this.viewer = (ScopeTreeViewer)viewer;
00078     }
00079  
00080     /*
00081      * (non-Javadoc)
00082      * @see org.eclipse.jface.viewers.IContentProvider#dispose()
00083      */
00084     public void dispose() {}
00085 }

Generated on 5 May 2015 for HPCVIEWER by  doxygen 1.6.1