Package org.eclipse.jdt.core.dom

Examples of org.eclipse.jdt.core.dom.BodyDeclaration


   * The source code of the selection
   */
  @Override
  public void dragSetData(DragSourceEvent event) {
    TreeItem selection = viewer.getTree().getSelection()[0];
    BodyDeclaration selectionData = (BodyDeclaration) selection.getData();
    if (TextTransfer.getInstance().isSupportedType(event.dataType)) {
      event.data = selectionData.toString();
    }
    logger.debug("Transfer data:\r\n" + event.data);
  }
View Full Code Here


    ISelectionChangedListener listener = new ISelectionChangedListener() {
      public void selectionChanged(SelectionChangedEvent event) {
        IStructuredSelection selection = (IStructuredSelection) event
            .getSelection();
        BodyDeclaration selected = (BodyDeclaration) selection
            .getFirstElement();

        // Show the source code of the selection
        if (preview != null) {
          if (selected != null)
            preview.setCode(selected.toString());
          else
            preview.setCode("");
        }
      }
    };
View Full Code Here

   *         compilation unit was created from, or null if it was not created
   *         from a Java type root.
   */
  public BodyDeclaration getTypeRoot() {
    if (resultCompilationUnit != null) {
      BodyDeclaration typeDec = null;
      for (Object typeObject : resultCompilationUnit.types()) {
        BodyDeclaration typeBodyDec = (BodyDeclaration) typeObject;
        if (typeBodyDec.getNodeType() == BodyDeclaration.TYPE_DECLARATION) {
          TypeDeclaration type = (TypeDeclaration) typeBodyDec;
          if (type.getName().getFullyQualifiedName()
              .equals(getProperty(ResultProperty.NAME)))
            typeDec = type;
        }
        if (typeBodyDec.getNodeType() == BodyDeclaration.ENUM_DECLARATION) {
          EnumDeclaration type = (EnumDeclaration) typeBodyDec;
          if (type.getName().getFullyQualifiedName()
              .equals(getProperty(ResultProperty.NAME)))
            typeDec = type;
        }
View Full Code Here

   * The source code of the selection
   */
  @Override
  public void dragSetData(DragSourceEvent event) {
    TreeItem selection = viewer.getTree().getSelection()[0];
    BodyDeclaration selectionData = (BodyDeclaration) selection.getData();
    if (TextTransfer.getInstance().isSupportedType(event.dataType)) {
      event.data = selectionData.toString();
    }
    logger.debug("Transfer data:\r\n" + event.data);
  }
View Full Code Here

   * org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.
   * Object)
   */
  @Override
  public boolean hasChildren(Object parentElement) {
    BodyDeclaration element = (BodyDeclaration) parentElement;

    // Only AbstractTypeDeclarations may have children
    if (element.getNodeType() == ASTNode.TYPE_DECLARATION) {
      if (((TypeDeclaration) element).getMethods().length > 0) {
        return true;
      }
    }
    if (element.getNodeType() == ASTNode.ENUM_DECLARATION) {
      if (((EnumDeclaration) element).bodyDeclarations().size() > 0) {
        return true;
      }
    }

View Full Code Here

   * The source code of the selection
   */
  @Override
  public void dragSetData(DragSourceEvent event) {
    TreeItem selection = viewer.getTree().getSelection()[0];
    BodyDeclaration selectionData = (BodyDeclaration) selection.getData();
    if (TextTransfer.getInstance().isSupportedType(event.dataType)) {
      event.data = selectionData.toString();
    }
    logger.debug("Transfer data:\r\n" + event.data);
  }
View Full Code Here

    ISelectionChangedListener listener = new ISelectionChangedListener() {
      public void selectionChanged(SelectionChangedEvent event) {
        IStructuredSelection selection = (IStructuredSelection) event
            .getSelection();
        BodyDeclaration selected = (BodyDeclaration) selection
            .getFirstElement();

        // Show the source code of the selection
        if (preview != null) {
          if (selected != null)
            preview.setCode(selected.toString());
          else
            preview.setCode("");
        }
      }
    };
View Full Code Here

  public Object[] getElements(Object inputElement) {
    Search search = (Search) inputElement;
    ResultItem[] results = search.getSearchResult().getResultItems();
    ArrayList<BodyDeclaration> elements = new ArrayList<BodyDeclaration>();
    for (ResultItem result : results) {
      BodyDeclaration typeRoot = result.getTypeRoot();
      if (typeRoot != null)
        elements.add(typeRoot);
    }
    return elements.toArray();
  }
View Full Code Here

   * org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.
   * Object)
   */
  @Override
  public Object[] getChildren(Object parentElement) {
    BodyDeclaration element = (BodyDeclaration) parentElement;
    if (element.getNodeType() == ASTNode.TYPE_DECLARATION) {
      return ((TypeDeclaration) element).getMethods();
    }
    return null;
  }
View Full Code Here

   * org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.
   * Object)
   */
  @Override
  public boolean hasChildren(Object parentElement) {
    BodyDeclaration element = (BodyDeclaration) parentElement;

    // Only Classes may have children
    if (element.getNodeType() == ASTNode.TYPE_DECLARATION)
      if (((TypeDeclaration) element).getMethods().length > 0)
        return true;

    return false;
  }
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.core.dom.BodyDeclaration

Copyright © 2018 www.massapicom. 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.