Esempio n. 1
0
  /**
   * Creates the content in the form hosted in this page.
   *
   * @param managedForm the form hosted in this page.
   */
  @Override
  protected void createFormContent(IManagedForm managedForm) {
    super.createFormContent(managedForm);
    ScrolledForm form = managedForm.getForm();
    form.setText("Android Manifest Permissions");
    form.setImage(AdtPlugin.getAndroidLogo());

    UiElementNode manifest = mEditor.getUiRootNode();
    AndroidManifestDescriptors manifestDescriptor = mEditor.getManifestDescriptors();

    ElementDescriptor[] descriptorFilters = null;
    if (manifestDescriptor != null) {
      descriptorFilters =
          new ElementDescriptor[] {
            manifestDescriptor.getPermissionElement(),
            manifestDescriptor.getUsesPermissionElement(),
            manifestDescriptor.getPermissionGroupElement(),
            manifestDescriptor.getPermissionTreeElement()
          };
    }
    mTreeBlock =
        new UiTreeBlock(
            mEditor,
            manifest,
            true /* autoCreateRoot */,
            descriptorFilters,
            "Permissions",
            "List of permissions defined and used by the manifest");
    mTreeBlock.createContent(managedForm);
  }
Esempio n. 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);
    }
  }
Esempio n. 3
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());
      }
    }
  }
Esempio n. 4
0
  /** Changes and refreshes the Application UI node handled by the sub parts. */
  public void refreshUiNode() {
    if (mTreeBlock != null) {
      UiElementNode manifest = mEditor.getUiRootNode();
      AndroidManifestDescriptors manifestDescriptor = mEditor.getManifestDescriptors();

      mTreeBlock.changeRootAndDescriptors(
          manifest,
          new ElementDescriptor[] {
            manifestDescriptor.getPermissionElement(),
            manifestDescriptor.getUsesPermissionElement(),
            manifestDescriptor.getPermissionGroupElement(),
            manifestDescriptor.getPermissionTreeElement()
          },
          true /* refresh */);
    }
  }
Esempio n. 5
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.
    }
  }