Ejemplo n.º 1
0
  @Override
  public void writeExternal(Element rootElement) throws WriteExternalException {
    LOG.assertTrue(!isDisposed(), "Already disposed!");

    Element element = new Element(ELEMENT);
    if (myName != null) {
      element.setAttribute(LIBRARY_NAME_ATTR, myName);
    }
    if (myKind != null) {
      element.setAttribute(LIBRARY_TYPE_ATTR, myKind.getKindId());
      final Object state = myProperties.getState();
      if (state != null) {
        final Element propertiesElement = XmlSerializer.serialize(state, SERIALIZATION_FILTERS);
        if (propertiesElement != null
            && (!propertiesElement.getContent().isEmpty()
                || !propertiesElement.getAttributes().isEmpty())) {
          element.addContent(propertiesElement.setName(PROPERTIES_ELEMENT));
        }
      }
    }
    ArrayList<OrderRootType> storableRootTypes = new ArrayList<OrderRootType>();
    storableRootTypes.addAll(Arrays.asList(OrderRootType.getAllTypes()));
    if (myKind != null) {
      storableRootTypes.addAll(Arrays.asList(myKind.getAdditionalRootTypes()));
    }
    for (OrderRootType rootType : sortRootTypes(storableRootTypes)) {
      final VirtualFilePointerContainer roots = myRoots.get(rootType);
      if (roots.size() == 0 && rootType.skipWriteIfEmpty()) continue; // compatibility iml/ipr
      final Element rootTypeElement = new Element(rootType.name());
      roots.writeExternal(rootTypeElement, ROOT_PATH_ELEMENT);
      element.addContent(rootTypeElement);
    }
    myJarDirectories.writeExternal(element);
    rootElement.addContent(element);
  }
Ejemplo n.º 2
0
 private Set<OrderRootType> getAllRootTypes() {
   Set<OrderRootType> rootTypes = new HashSet<OrderRootType>();
   rootTypes.addAll(Arrays.asList(OrderRootType.getAllTypes()));
   if (myKind != null) {
     rootTypes.addAll(Arrays.asList(myKind.getAdditionalRootTypes()));
   }
   return rootTypes;
 }
Ejemplo n.º 3
0
 @Override
 @NotNull
 public String[] getUrls(@NotNull OrderRootType rootType) {
   Set<String> originalUrls =
       new LinkedHashSet<String>(Arrays.asList(LibraryImpl.this.getUrls(rootType)));
   for (VirtualFile file : getFiles(rootType)) { // Add those expanded with jar directories.
     originalUrls.add(file.getUrl());
   }
   return ArrayUtil.toStringArray(originalUrls);
 }