Package tool.navigator.pex

Source Code of tool.navigator.pex.SystemLibraryContentProvider

package tool.navigator.pex;

import java.util.Collection;

import org.eclipse.core.resources.IFolder;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jface.viewers.Viewer;

import tool.ToolProjectSupport;
import tool.model.IClassComponent;
import tool.model.ToolCType;
import tool.model.ToolClass;
import tool.model.ToolComponent;
import tool.model.ToolConstant;
import tool.model.ToolCursor;
import tool.model.ToolInterface;
import tool.model.ToolPlan;
import tool.model.ToolServiceObject;
import tool.model.ToolType;

public class SystemLibraryContentProvider implements ITreeContentProvider{
  private static final Object[] NO_CHILDREN = new Object[0];
  private StructuredViewer viewer;
 
  @Override
  public void dispose() {
   
  }

  @Override
  public void inputChanged(Viewer aViewer, Object oldInput, Object newInput) {
    if (oldInput != null && !oldInput.equals(newInput))
      viewer = (StructuredViewer) aViewer;
  }

  @Override
  public Object[] getChildren(Object parentElement) {
    Object[] children = null;
    if (parentElement instanceof ToolConstant) {
      return NO_CHILDREN;
    } else if (parentElement instanceof ToolPlan){
      ToolPlan plan = (ToolPlan)parentElement;
      return plan.getComponents();
    } else if (parentElement instanceof ToolClass){
      ToolComponent cls = (ToolComponent)parentElement;
      return cls.getComponents();
    } else if (parentElement instanceof ToolInterface){
      ToolComponent cls = (ToolComponent)parentElement;
      return cls.getComponents();
    } else if (parentElement instanceof ToolCType){
      ToolComponent cls = (ToolComponent)parentElement;
      return cls.getComponents();
    } else if (parentElement instanceof IClassComponent){
      return NO_CHILDREN;
    } else if (parentElement instanceof IFolder &&
        ((IFolder)parentElement).getName().equals(ToolProjectSupport.UDS_LIBRARY_FOLDER_NAME)) {
      Collection <ToolPlan> plans = ToolPlan.getForteLibraryCache().values();
      return plans.toArray();
    }
    return children != null ? children : NO_CHILDREN;
  }

  @Override
  public Object[] getElements(Object inputElement) {
    return getChildren(inputElement);
  }

  @Override
  public Object getParent(Object element) {
    if (element instanceof ToolConstant) {
      ToolConstant data = (ToolConstant) element;
      return data.getParent();
    }
    return null;
  }

  @Override
  public boolean hasChildren(Object element) {
    if (element instanceof ToolConstant) {
      return false;   
    }else if (element instanceof IClassComponent) {
      return false;   
    } else if (element instanceof ToolType){
      return true;
    } else if (element instanceof ToolPlan){
      return true;
    } else if (element instanceof ToolServiceObject){
      return false;
    } else if (element instanceof ToolCursor){
      return false;
    } else if (element instanceof ToolCType){
      return true;
    }
    return false;
  }

}
TOP

Related Classes of tool.navigator.pex.SystemLibraryContentProvider

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.