Package org.eclipse.jdt.core.dom

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


  public void dragStart(DragSourceEvent event) {
    selection = viewer.getTree().getSelection();
    if (selection == null || selection.length == 0) {
      event.doit = false;
    }
    BodyDeclaration selectedElement = (BodyDeclaration) selection[0]
        .getData();
    logger.debug("URI: "
        + selectedElement.getProperty(ResultProperty.URI.name()));
  }
View Full Code Here


  @Override
  public void dragSetData(DragSourceEvent event) {
    logger.debug(event.dataType + " requested by drop target.");

    try {
      BodyDeclaration selectedElement = (BodyDeclaration) selection[0]
          .getData();
      if (PluginTransfer.getInstance().isSupportedType(event.dataType)) {
        // For a PluginTransfer, we transmit the URI of the element.
        // The DropListener is responsible for handling this.
        Object uri = selectedElement.getProperty(ResultProperty.URI
            .name());
        if (uri != null)
          event.data = new PluginTransferData(
              "de.uni_mannheim.swt.codeconjurer.ui.dnd.pluginDropAction",
              (((String) uri).getBytes()));
        logger.debug("PluginTransfer triggered for " + uri);
      } else if (TextTransfer.getInstance().isSupportedType(
          event.dataType)) {
        // TextTransfer simply transfers the selected code element.
        String sourceLink = "@origin \r\n * "
            + selectedElement.getProperty(ResultProperty.SHORT_URL
                .name()) + "";
        String data = selectedElement.toString();
        if (data.startsWith("/**") && data.contains("*/")) {
          event.data = data.substring(0, data.indexOf("*/") - 2)
              + "\r\n * \r\n * " + sourceLink + "\r\n *"
              + data.substring(data.indexOf("*/"), data.length());
        } else {
          event.data = "/** " + sourceLink + "\r\n */"
              + selectedElement.toString();
        }
        logger.debug("TextTransfer triggered");
      }
    } catch (Exception e) {
      CrashReporter.reportException(e);
View Full Code Here

      if (!Activator.getDefault().getPreferenceStore()
          .getBoolean(PreferenceConstants.P_SHOW_NEGATIVES)) {
        noShowNegatives = true;
      }
      for (ResultItem result : results) {
        BodyDeclaration typeRoot = result.getTypeRoot();
        if (noShowNegatives
            && result.getProperty(ResultProperty.TEST_RESULT)
                .startsWith("// No adapter created")) {
          logger.trace("Skip negative result.");
        } else {
          logger.trace("Add result.");
          if (typeRoot != null) {
            elements.add(typeRoot);
          }
        }
      }
    } else {
      for (ResultItem result : results) {
        BodyDeclaration typeRoot = result.getTypeRoot();
        if (typeRoot != null) {
          elements.add(typeRoot);
        }
      }
    }
View Full Code Here

   * org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.
   * Object)
   */
  @Override
  public Object[] getChildren(Object parentElement) {
    BodyDeclaration element = (BodyDeclaration) parentElement;
    ArrayList<MethodDeclaration> methods = new ArrayList<MethodDeclaration>();
    if (element.getNodeType() == ASTNode.TYPE_DECLARATION) {
      for (MethodDeclaration method : ((TypeDeclaration) element)
          .getMethods()) {
        // Copy properties from class to methods
        Set<?> properties = element.properties().keySet();
        for (String property : (String[]) properties
            .toArray(new String[element.properties().size()])) {
          method.setProperty(property, element.getProperty(property));
        }
        // Set a unique identifier (required for DND)
        String sign = "" + method.getReturnType2() + method.getName();
        for (Object p : method.parameters()) {
          sign += p.toString();
        }
        // Replace the copied parent's URI from above with a new URI
        // extended with the signature of the child and a mark
        method.setProperty(ResultProperty.URI.name(),
            method.getProperty(ResultProperty.URI.name())
                + CodeConjurer.URI_DELIMITER + sign);
        methods.add(method);
      }
      return methods.toArray();
    }
    if (element.getNodeType() == ASTNode.ENUM_DECLARATION) {
      for (Object declaration : ((EnumDeclaration) element)
          .bodyDeclarations()) {
        if (declaration instanceof MethodDeclaration) {
          MethodDeclaration method = (MethodDeclaration) declaration;
          // Copy properties from class to methods
          Set<?> properties = element.properties().keySet();
          for (String property : (String[]) properties
              .toArray(new String[element.properties().size()])) {
            method.setProperty(property,
                element.getProperty(property));
          }
          // Set a unique identifier (required for DND)
          String sign = "" + method.getReturnType2()
              + method.getName();
          for (Object p : method.parameters()) {
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

  // private Logger logger = Logger.getLogger(ResultLabelProvider.class);

  @Override
  public Image getColumnImage(Object item, int columnIndex) {
    Image img = null;
    BodyDeclaration element = (BodyDeclaration) item;
    if (columnIndex == 0) {
      if (element.getNodeType() == ASTNode.TYPE_DECLARATION) {
        img = JavaUI.getSharedImages().getImage(
            ISharedImages.IMG_OBJS_CLASS_DEFAULT);
      }
      if (element.getNodeType() == ASTNode.ENUM_DECLARATION) {
        img = JavaUI.getSharedImages().getImage(
            ISharedImages.IMG_OBJS_ENUM);
      }
      if (element.getNodeType() == ASTNode.METHOD_DECLARATION) {
        MethodDeclaration method = (MethodDeclaration) element;
        if (method.isConstructor()) {
          img = JavaUI.getSharedImages().getImage(
              ISharedImages.IMG_OBJS_INNER_CLASS_DEFAULT);
        } else {
View Full Code Here

    return img;
  }

  @Override
  public String getColumnText(Object item, int columnIndex) {
    BodyDeclaration element = (BodyDeclaration) item;
    if (element.getNodeType() == ASTNode.TYPE_DECLARATION) {
      if (columnIndex == 0) {
        return ((TypeDeclaration) element).getName()
            .getFullyQualifiedName();
      }
      if (columnIndex == 1) {
        String license = ""
            + element.getProperty(ResultProperty.LICENSE.name());
        if (!license.contains("null")) {
          return license;
        }
      }
      if (columnIndex == 2) {
        // Was testing / adaptation successful?
        if (((String) element.getProperty(ResultProperty.EXECUTABILITY
            .name())).equals(Executability.TESTED.value())) {
          // Set color to green if no adapter is necessary, yellow
          // otherwise
          if (((String) element
              .getProperty(ResultProperty.TEST_RESULT.name()))
              .startsWith("// No adapter necessary")) {
            return "TESTED";
          } else {
            return "ADAPTED";
          }
        } else {
          return "FAILED";
        }
      }
    }
    if (element.getNodeType() == ASTNode.ENUM_DECLARATION
        && columnIndex == 0) {
      return ((EnumDeclaration) element).getName()
          .getFullyQualifiedName();
    }
    if (element.getNodeType() == ASTNode.METHOD_DECLARATION
        && columnIndex == 0) {
      return ((MethodDeclaration) element).getName()
          .getFullyQualifiedName();
    }
    return null;
View Full Code Here

    return null;
  }

  @Override
  public Color getForeground(Object item, int columnIndex) {
    BodyDeclaration element = (BodyDeclaration) item;
    Color color = Display.getCurrent().getSystemColor(SWT.COLOR_BLACK);
    if (columnIndex == 2) {
      if (((String) element.getProperty(ResultProperty.EXECUTABILITY
          .name())).equals(Executability.TESTED.value())) {
        color = Display.getCurrent().getSystemColor(SWT.COLOR_WHITE);
      }
    }
    return color;
View Full Code Here

    return color;
  }

  @Override
  public Color getBackground(Object item, int columnIndex) {
    BodyDeclaration element = (BodyDeclaration) item;
    Color color = Display.getCurrent().getSystemColor(SWT.COLOR_WHITE);
    if (element.getNodeType() == ASTNode.TYPE_DECLARATION
        || element.getNodeType() == ASTNode.ENUM_DECLARATION) {
      color = Display.getCurrent().getSystemColor(
          SWT.COLOR_WIDGET_LIGHT_SHADOW);
    }
    if (columnIndex == 2
        && element.getNodeType() == ASTNode.TYPE_DECLARATION) {
      // Was testing / adaptation successful?
      if (((String) element.getProperty(ResultProperty.EXECUTABILITY
          .name())).equals(Executability.TESTED.value())) {
        // Set color to green if no adapter is necessary, yellow
        // otherwise
        if (((String) element.getProperty(ResultProperty.TEST_RESULT
            .name())).startsWith("// No adapter necessary")) {
          color = Display.getCurrent().getSystemColor(
              SWT.COLOR_DARK_GREEN);
        } else {
          color = Display.getCurrent().getSystemColor(
View Full Code Here

    return color;
  }

  @Override
  public Font getFont(Object item, int columnIndex) {
    BodyDeclaration element = (BodyDeclaration) item;
    if (element.getNodeType() == ASTNode.TYPE_DECLARATION
        && columnIndex == 0) {
      return JFaceResources.getFontRegistry().getBold(
          JFaceResources.DEFAULT_FONT);
    }
    return null;
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.