Java Code Examples for org.jdom.Element#removeAttribute()

The following examples show how to use org.jdom.Element#removeAttribute() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BlazeAndroidBinaryRunConfigurationState.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Override
public void writeExternal(Element element) throws WriteExternalException {
  commonState.writeExternal(element);

  // Group profiler settings under its own section. Previously written profiler info
  // are replaced manually because ProfilerState#writeExternal does not handle the removal
  // process; unlike i.e, implementers of RunConfigurationState.
  Element profilersElement = new Element(PROFILERS_ELEMENT_NAME);
  element.removeChildren(PROFILERS_ELEMENT_NAME);
  element.addContent(profilersElement);
  profilerState.writeExternal(profilersElement);

  element.setAttribute(DEEP_LINK, deepLink);
  element.setAttribute(ACTIVITY_CLASS, activityClass);
  element.setAttribute(MODE, mode);
  element.setAttribute(LAUNCH_METHOD_ATTR, launchMethod.name());
  element.setAttribute(USE_SPLIT_APKS_IF_POSSIBLE, Boolean.toString(useSplitApksIfPossible));
  element.setAttribute(WORK_PROFILE_ATTR, Boolean.toString(useWorkProfileIfPresent));
  element.setAttribute(SHOW_LOGCAT_AUTOMATICALLY, Boolean.toString(showLogcatAutomatically));
  element.setAttribute(AM_START_OPTIONS, amStartOptions);

  if (userId != null) {
    element.setAttribute(USER_ID_ATTR, Integer.toString(userId));
  } else {
    element.removeAttribute(USER_ID_ATTR);
  }
}
 
Example 2
Source File: BlazeCommandState.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Override
public void writeExternal(Element element) {
  if (command != null) {
    element.setAttribute(COMMAND_ATTR, command.toString());
  } else {
    element.removeAttribute(COMMAND_ATTR);
  }
}
 
Example 3
Source File: DebugPortState.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Override
public void writeExternal(Element element) throws WriteExternalException {
  if (port != defaultPort) {
    element.setAttribute(ATTRIBUTE_TAG, Integer.toString(port));
  } else {
    element.removeAttribute(ATTRIBUTE_TAG);
  }
}
 
Example 4
Source File: BlazeBinaryState.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Override
public void writeExternal(Element element) {
  if (!Strings.isNullOrEmpty(blazeBinary)) {
    element.setAttribute(BLAZE_BINARY_ATTR, blazeBinary);
  } else {
    element.removeAttribute(BLAZE_BINARY_ATTR);
  }
}
 
Example 5
Source File: BlazeCommandRunConfiguration.java    From intellij with Apache License 2.0 5 votes vote down vote up
private static Element getBlazeSettingsCopy(Element element) {
  Element blazeSettings = element.getChild(BLAZE_SETTINGS_TAG);
  if (blazeSettings != null) {
    return blazeSettings.clone();
  }
  // migrate an old-style run configuration
  blazeSettings = element.clone();
  blazeSettings.setName(BLAZE_SETTINGS_TAG);
  for (String common : COMMON_SETTINGS) {
    blazeSettings.removeChildren(common);
    blazeSettings.removeAttribute(common);
  }
  return blazeSettings;
}
 
Example 6
Source File: StorageData.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void load(@Nonnull Element rootElement, @Nullable PathMacroSubstitutor pathMacroSubstitutor, boolean intern) {
  if (pathMacroSubstitutor != null) {
    pathMacroSubstitutor.expandPaths(rootElement);
  }

  StringInterner interner = intern ? new StringInterner() : null;
  for (Iterator<Element> iterator = rootElement.getChildren(COMPONENT).iterator(); iterator.hasNext(); ) {
    Element element = iterator.next();
    String name = getComponentNameIfValid(element);
    if (name == null || !(element.getAttributes().size() > 1 || !element.getChildren().isEmpty())) {
      continue;
    }

    iterator.remove();
    if (interner != null) {
      JDOMUtil.internStringsInElement(element, interner);
    }

    myStates.put(name, element);

    if (pathMacroSubstitutor instanceof TrackingPathMacroSubstitutor) {
      ((TrackingPathMacroSubstitutor)pathMacroSubstitutor).addUnknownMacros(name, PathMacrosService.getInstance().getMacroNames(element));
    }

    // remove only after "getMacroNames" - some PathMacroFilter requires element name attribute
    element.removeAttribute(NAME);
  }
}