Search in sources :

Example 11 with OrderRootType

use of com.intellij.openapi.roots.OrderRootType in project intellij-community by JetBrains.

the class ProjectRootContainerImpl method readOldVersion.

@SuppressWarnings({ "HardCodedStringLiteral" })
void readOldVersion(Element child) {
    for (Element root : child.getChildren("root")) {
        String url = root.getAttributeValue("file");
        SimpleProjectRoot projectRoot = new SimpleProjectRoot(url);
        String type = root.getChild("property").getAttributeValue("value");
        for (PersistentOrderRootType rootType : OrderRootType.getAllPersistentTypes()) {
            if (type.equals(rootType.getOldSdkRootName())) {
                addRoot(projectRoot, rootType);
                break;
            }
        }
    }
    myFiles = new HashMap<>();
    for (OrderRootType rootType : myRoots.keySet()) {
        myFiles.put(rootType, myRoots.get(rootType).getVirtualFiles());
    }
    for (OrderRootType type : OrderRootType.getAllTypes()) {
        final VirtualFile[] oldRoots = VirtualFile.EMPTY_ARRAY;
        final VirtualFile[] newRoots = getRootFiles(type);
        if (!Comparing.equal(oldRoots, newRoots)) {
            fireRootsChanged();
            break;
        }
    }
}
Also used : PersistentOrderRootType(com.intellij.openapi.roots.PersistentOrderRootType) OrderRootType(com.intellij.openapi.roots.OrderRootType) PersistentOrderRootType(com.intellij.openapi.roots.PersistentOrderRootType) Element(org.jdom.Element)

Example 12 with OrderRootType

use of com.intellij.openapi.roots.OrderRootType in project intellij-community by JetBrains.

the class ProjectRootContainerImpl method finishChange.

@Override
public void finishChange() {
    LOG.assertTrue(myInsideChange);
    HashMap<OrderRootType, VirtualFile[]> oldRoots = new HashMap<>(myFiles);
    boolean changes = false;
    for (OrderRootType orderRootType : OrderRootType.getAllTypes()) {
        final VirtualFile[] roots = myRoots.get(orderRootType).getVirtualFiles();
        changes = changes || !Comparing.equal(roots, oldRoots.get(orderRootType));
        myFiles.put(orderRootType, roots);
    }
    if (changes) {
        fireRootsChanged();
    }
    myInsideChange = false;
}
Also used : HashMap(com.intellij.util.containers.HashMap) OrderRootType(com.intellij.openapi.roots.OrderRootType) PersistentOrderRootType(com.intellij.openapi.roots.PersistentOrderRootType)

Example 13 with OrderRootType

use of com.intellij.openapi.roots.OrderRootType in project intellij-community by JetBrains.

the class JarDirectories method readExternal.

@Override
public void readExternal(Element element) throws InvalidDataException {
    clear();
    final List<Element> jarDirs = element.getChildren(JAR_DIRECTORY_ELEMENT);
    for (Element jarDir : jarDirs) {
        final String url = jarDir.getAttributeValue(URL_ATTR);
        final String recursive = jarDir.getAttributeValue(RECURSIVE_ATTR);
        final OrderRootType rootType = getJarDirectoryRootType(jarDir.getAttributeValue(ROOT_TYPE_ATTR));
        if (url != null) {
            add(rootType, url, Boolean.valueOf(Boolean.parseBoolean(recursive)));
        }
    }
}
Also used : PersistentOrderRootType(com.intellij.openapi.roots.PersistentOrderRootType) OrderRootType(com.intellij.openapi.roots.OrderRootType) Element(org.jdom.Element)

Example 14 with OrderRootType

use of com.intellij.openapi.roots.OrderRootType in project intellij-community by JetBrains.

the class LibraryImpl method initRoots.

private Map<OrderRootType, VirtualFilePointerContainer> initRoots() {
    Disposer.register(this, myPointersDisposable);
    Map<OrderRootType, VirtualFilePointerContainer> result = new HashMap<>(4);
    for (OrderRootType rootType : getAllRootTypes()) {
        result.put(rootType, VirtualFilePointerManager.getInstance().createContainer(myPointersDisposable));
    }
    return result;
}
Also used : HashMap(com.intellij.util.containers.HashMap) OrderRootType(com.intellij.openapi.roots.OrderRootType) VirtualFilePointerContainer(com.intellij.openapi.vfs.pointers.VirtualFilePointerContainer)

Example 15 with OrderRootType

use of com.intellij.openapi.roots.OrderRootType in project intellij-community by JetBrains.

the class LibraryImpl method writeExternal.

@Override
public void writeExternal(Element rootElement) {
    checkDisposed();
    Element element = new Element(ELEMENT);
    if (myName != null) {
        element.setAttribute(LIBRARY_NAME_ATTR, myName);
    }
    if (myKind != null) {
        element.setAttribute(LIBRARY_TYPE_ATTR, myKind.getKindId());
        LOG.assertTrue(myProperties != null, "Properties is 'null' in library with kind " + myKind);
        final Object state = myProperties.getState();
        if (state != null) {
            final Element propertiesElement = XmlSerializer.serializeIfNotDefault(state, SERIALIZATION_FILTERS);
            if (!JDOMUtil.isEmpty(propertiesElement)) {
                element.addContent(propertiesElement.setName(PROPERTIES_ELEMENT));
            }
        }
    }
    ArrayList<OrderRootType> storableRootTypes = new ArrayList<>();
    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()) {
            //compatibility iml/ipr
            continue;
        }
        final Element rootTypeElement = new Element(rootType.name());
        roots.writeExternal(rootTypeElement, ROOT_PATH_ELEMENT);
        element.addContent(rootTypeElement);
    }
    if (myExcludedRoots != null && myExcludedRoots.size() > 0) {
        Element excluded = new Element(EXCLUDED_ROOTS_TAG);
        myExcludedRoots.writeExternal(excluded, ROOT_PATH_ELEMENT);
        element.addContent(excluded);
    }
    myJarDirectories.writeExternal(element);
    rootElement.addContent(element);
}
Also used : OrderRootType(com.intellij.openapi.roots.OrderRootType) Element(org.jdom.Element) VirtualFilePointerContainer(com.intellij.openapi.vfs.pointers.VirtualFilePointerContainer)

Aggregations

OrderRootType (com.intellij.openapi.roots.OrderRootType)31 VirtualFile (com.intellij.openapi.vfs.VirtualFile)10 File (java.io.File)7 Element (org.jdom.Element)7 PersistentOrderRootType (com.intellij.openapi.roots.PersistentOrderRootType)6 JavadocOrderRootType (com.intellij.openapi.roots.JavadocOrderRootType)5 Library (com.intellij.openapi.roots.libraries.Library)4 VirtualFilePointerContainer (com.intellij.openapi.vfs.pointers.VirtualFilePointerContainer)4 NotNull (org.jetbrains.annotations.NotNull)4 AnnotationOrderRootType (com.intellij.openapi.roots.AnnotationOrderRootType)3 ArrayList (java.util.ArrayList)3 Nullable (org.jetbrains.annotations.Nullable)3 Disposable (com.intellij.openapi.Disposable)2 LibraryPathType (com.intellij.openapi.externalSystem.model.project.LibraryPathType)2 RootProvider (com.intellij.openapi.roots.RootProvider)2 OrderRoot (com.intellij.openapi.roots.libraries.ui.OrderRoot)2 Pair (com.intellij.openapi.util.Pair)2 VirtualFileManager (com.intellij.openapi.vfs.VirtualFileManager)2 HashMap (com.intellij.util.containers.HashMap)2 HashMap (java.util.HashMap)2