Home | History | Annotate | Download | only in editors
      1 /*
      2  * Copyright (C) 2011 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package com.android.ide.eclipse.gltrace.editors;
     18 
     19 import com.android.ide.eclipse.gltrace.state.GLCompositeProperty;
     20 import com.android.ide.eclipse.gltrace.state.GLListProperty;
     21 import com.android.ide.eclipse.gltrace.state.GLSparseArrayProperty;
     22 import com.android.ide.eclipse.gltrace.state.IGLProperty;
     23 
     24 import org.eclipse.jface.viewers.ITreeContentProvider;
     25 import org.eclipse.jface.viewers.Viewer;
     26 
     27 public class StateContentProvider implements ITreeContentProvider {
     28     @Override
     29     public void dispose() {
     30     }
     31 
     32     @Override
     33     public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
     34     }
     35 
     36     @Override
     37     public Object[] getElements(Object inputElement) {
     38         return getChildren(inputElement);
     39     }
     40 
     41     @Override
     42     public Object[] getChildren(Object parentElement) {
     43         if (parentElement instanceof GLListProperty) {
     44             return ((GLListProperty) parentElement).getList().toArray();
     45         }
     46 
     47         if (parentElement instanceof GLCompositeProperty) {
     48             return ((GLCompositeProperty) parentElement).getProperties().toArray();
     49         }
     50 
     51         if (parentElement instanceof GLSparseArrayProperty) {
     52             return ((GLSparseArrayProperty) parentElement).getValues().toArray();
     53         }
     54 
     55         return null;
     56     }
     57 
     58     @Override
     59     public Object getParent(Object element) {
     60         if (element instanceof IGLProperty) {
     61             return ((IGLProperty) element).getParent();
     62         }
     63 
     64         return null;
     65     }
     66 
     67     @Override
     68     public boolean hasChildren(Object element) {
     69         if (element instanceof IGLProperty) {
     70             return ((IGLProperty) element).isComposite();
     71         }
     72 
     73         return false;
     74     }
     75 }
     76