예제 #1
0
  /**
   * Processes a {@link IMarker} change.
   *
   * @param markerDeltas the list of {@link IMarkerDelta}
   */
  private void processMarkerChanges(IMarkerDelta[] markerDeltas) {
    AndroidManifestDescriptors descriptors = getManifestDescriptors();
    if (descriptors != null && descriptors.getApplicationElement() != null) {
      UiElementNode app_ui_node =
          mUiManifestNode.findUiChildNode(descriptors.getApplicationElement().getXmlName());
      List<UiElementNode> children = app_ui_node.getUiChildren();

      for (IMarkerDelta markerDelta : markerDeltas) {
        processMarker(markerDelta.getMarker(), children, markerDelta.getKind());
      }
    }
  }
예제 #2
0
  /**
   * Creates the initial UI Root Node, including the known mandatory elements.
   *
   * @param force if true, a new UiManifestNode is recreated even if it already exists.
   */
  @Override
  protected void initUiRootNode(boolean force) {
    // The manifest UI node is always created, even if there's no corresponding XML node.
    if (mUiManifestNode != null && force == false) {
      return;
    }

    AndroidManifestDescriptors manifestDescriptor = getManifestDescriptors();

    if (manifestDescriptor != null) {
      ElementDescriptor manifestElement = manifestDescriptor.getManifestElement();
      mUiManifestNode = manifestElement.createUiNode();
      mUiManifestNode.setEditor(this);

      // Similarly, always create the /manifest/uses-sdk followed by /manifest/application
      // (order of the elements now matters)
      ElementDescriptor element = manifestDescriptor.getUsesSdkElement();
      boolean present = false;
      for (UiElementNode ui_node : mUiManifestNode.getUiChildren()) {
        if (ui_node.getDescriptor() == element) {
          present = true;
          break;
        }
      }
      if (!present) {
        mUiManifestNode.appendNewUiChild(element);
      }

      element = manifestDescriptor.getApplicationElement();
      present = false;
      for (UiElementNode ui_node : mUiManifestNode.getUiChildren()) {
        if (ui_node.getDescriptor() == element) {
          present = true;
          break;
        }
      }
      if (!present) {
        mUiManifestNode.appendNewUiChild(element);
      }

      onDescriptorsChanged();
    } else {
      // create a dummy descriptor/uinode until we have real descriptors
      ElementDescriptor desc =
          new ElementDescriptor(
              "manifest", //$NON-NLS-1$
              "temporary descriptors due to missing decriptors", //$NON-NLS-1$
              null /*tooltip*/,
              null /*sdk_url*/,
              null /*attributes*/,
              null /*children*/,
              false /*mandatory*/);
      mUiManifestNode = desc.createUiNode();
      mUiManifestNode.setEditor(this);
    }
  }
예제 #3
0
  /**
   * Processes the markers of the specified {@link IFile} and updates the error status of {@link
   * UiElementNode}s and {@link UiAttributeNode}s.
   *
   * @param inputFile the file being edited.
   */
  private void updateFromExistingMarkers(IFile inputFile) {
    try {
      // get the markers for the file
      IMarker[] markers =
          inputFile.findMarkers(AdtConstants.MARKER_ANDROID, true, IResource.DEPTH_ZERO);

      AndroidManifestDescriptors desc = getManifestDescriptors();
      if (desc != null) {
        ElementDescriptor appElement = desc.getApplicationElement();

        if (appElement != null && mUiManifestNode != null) {
          UiElementNode appUiNode = mUiManifestNode.findUiChildNode(appElement.getXmlName());
          List<UiElementNode> children = appUiNode.getUiChildren();

          for (IMarker marker : markers) {
            processMarker(marker, children, IResourceDelta.ADDED);
          }
        }
      }

    } catch (CoreException e) {
      // findMarkers can throw an exception, in which case, we'll do nothing.
    }
  }