Search in sources :

Example 21 with OrderRootType

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

the class SdkEditor method reset.

@Override
public void reset() {
    if (mySdk == null) {
        setHomePathValue("");
        for (SdkPathEditor pathEditor : myPathEditors.values()) {
            pathEditor.reset(null);
        }
    } else {
        final SdkModificator sdkModificator = mySdk.getSdkModificator();
        for (OrderRootType type : myPathEditors.keySet()) {
            myPathEditors.get(type).reset(sdkModificator);
        }
        sdkModificator.commitChanges();
        setHomePathValue(mySdk.getHomePath().replace('/', File.separatorChar));
    }
    myVersionString = null;
    myHomeFieldLabel.setText(getHomeFieldLabelValue());
    updateAdditionalDataComponent();
    for (final AdditionalDataConfigurable configurable : getAdditionalDataConfigurable()) {
        configurable.reset();
    }
    myHomeComponent.setEnabled(mySdk != null);
    for (int i = 0; i < myTabbedPane.getTabCount(); i++) {
        myTabbedPane.setEnabledAt(i, mySdk != null);
    }
}
Also used : OrderRootType(com.intellij.openapi.roots.OrderRootType)

Example 22 with OrderRootType

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

the class SdkEditor method createMainPanel.

private void createMainPanel() {
    myMainPanel = new JPanel(new GridBagLayout());
    myTabbedPane = new TabbedPaneWrapper(myDisposable);
    for (OrderRootType type : OrderRootType.getAllTypes()) {
        if (mySdk == null || showTabForType(type)) {
            final SdkPathEditor pathEditor = OrderRootTypeUIFactory.FACTORY.getByKey(type).createPathEditor(mySdk);
            if (pathEditor != null) {
                pathEditor.setAddBaseDir(mySdk.getHomeDirectory());
                myTabbedPane.addTab(pathEditor.getDisplayName(), pathEditor.createComponent());
                myPathEditors.put(type, pathEditor);
            }
        }
    }
    myTabbedPane.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(final ChangeEvent e) {
            myHistory.pushQueryPlace();
        }
    });
    myHomeComponent = createHomeComponent();
    myHomeComponent.getTextField().setEditable(false);
    myHomeFieldLabel = new JLabel(getHomeFieldLabelValue());
    final int leftInset = 10;
    final int rightInset = 10;
    myMainPanel.add(myHomeFieldLabel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, JBUI.insets(2, leftInset, 2, 2), 0, 0));
    myMainPanel.add(myHomeComponent, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, JBUI.insets(2, 2, 2, rightInset), 0, 0));
    myAdditionalDataPanel = new JPanel(new BorderLayout());
    myMainPanel.add(myAdditionalDataPanel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, JBUI.insets(2, leftInset, 0, rightInset), 0, 0));
    myMainPanel.add(myTabbedPane.getComponent(), new GridBagConstraints(0, GridBagConstraints.RELATIVE, 2, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, JBUI.insetsTop(2), 0, 0));
}
Also used : ChangeEvent(javax.swing.event.ChangeEvent) TabbedPaneWrapper(com.intellij.ui.TabbedPaneWrapper) OrderRootType(com.intellij.openapi.roots.OrderRootType) ChangeListener(javax.swing.event.ChangeListener)

Example 23 with OrderRootType

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

the class JarDirectories method writeExternal.

@Override
public void writeExternal(Element element) {
    final List<OrderRootType> rootTypes = LibraryImpl.sortRootTypes(getRootTypes());
    for (OrderRootType rootType : rootTypes) {
        final List<String> urls = new ArrayList<>(getDirectories(rootType));
        Collections.sort(urls, String.CASE_INSENSITIVE_ORDER);
        for (String url : urls) {
            final Element jarDirElement = new Element(JAR_DIRECTORY_ELEMENT);
            jarDirElement.setAttribute(URL_ATTR, url);
            jarDirElement.setAttribute(RECURSIVE_ATTR, Boolean.toString(isRecursive(rootType, url)));
            if (!rootType.equals(DEFAULT_JAR_DIRECTORY_TYPE)) {
                jarDirElement.setAttribute(ROOT_TYPE_ATTR, rootType.name());
            }
            element.addContent(jarDirElement);
        }
    }
}
Also used : PersistentOrderRootType(com.intellij.openapi.roots.PersistentOrderRootType) OrderRootType(com.intellij.openapi.roots.OrderRootType) Element(org.jdom.Element) ArrayList(java.util.ArrayList)

Example 24 with OrderRootType

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

the class ProjectRootContainerImpl method readExternal.

@Override
public void readExternal(Element element) {
    for (PersistentOrderRootType type : OrderRootType.getAllPersistentTypes()) {
        read(element, type);
    }
    ApplicationManager.getApplication().runReadAction(() -> {
        myFiles = new HashMap<>();
        for (OrderRootType rootType : myRoots.keySet()) {
            CompositeProjectRoot root = myRoots.get(rootType);
            if (myNoCopyJars) {
                setNoCopyJars(root);
            }
            myFiles.put(rootType, root.getVirtualFiles());
        }
    });
    for (OrderRootType type : OrderRootType.getAllTypes()) {
        final VirtualFile[] newRoots = getRootFiles(type);
        final VirtualFile[] oldRoots = VirtualFile.EMPTY_ARRAY;
        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)

Example 25 with OrderRootType

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

the class LibraryImpl method copyRootsFrom.

private void copyRootsFrom(LibraryImpl fromModel) {
    Map<OrderRootType, VirtualFilePointerContainer> clonedRoots = ContainerUtil.newHashMap();
    for (Map.Entry<OrderRootType, VirtualFilePointerContainer> entry : fromModel.myRoots.entrySet()) {
        OrderRootType rootType = entry.getKey();
        VirtualFilePointerContainer container = entry.getValue();
        VirtualFilePointerContainer clone = container.clone(myPointersDisposable);
        clonedRoots.put(rootType, clone);
    }
    myRoots.clear();
    myRoots.putAll(clonedRoots);
    VirtualFilePointerContainer excludedRoots = fromModel.myExcludedRoots;
    myExcludedRoots = excludedRoots != null ? excludedRoots.clone(myPointersDisposable) : null;
}
Also used : OrderRootType(com.intellij.openapi.roots.OrderRootType) HashMap(com.intellij.util.containers.HashMap) 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