mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'master' of git.labs.intellij.net:idea/community
This commit is contained in:
+1
-1
@@ -136,7 +136,7 @@ public class LibraryDefinitionsGeneratorFactory {
|
||||
libraryPath.add(new PathElement(path));
|
||||
}
|
||||
else if (url.startsWith(LocalFileSystem.PROTOCOL_PREFIX)) {
|
||||
if (library.isJarDirectory(url)) {
|
||||
if (library.isJarDirectory(url, OrderRootType.CLASSES)) {
|
||||
final FileSet fileSet = new FileSet(path);
|
||||
fileSet.add(new PatternSetRef(BuildProperties.PROPERTY_LIBRARIES_PATTERNS));
|
||||
libraryPath.add(fileSet);
|
||||
|
||||
+31
-2
@@ -46,8 +46,10 @@ public class DefaultLibraryRootsComponentDescriptor extends LibraryRootsComponen
|
||||
@NotNull
|
||||
@Override
|
||||
public List<? extends AttachRootButtonDescriptor> createAttachButtons() {
|
||||
return Arrays.asList(new AttachClassesDescriptor(), new AttachJarDirectoriesDescriptor(), new AttachSourcesDescriptor(),
|
||||
new AttachAnnotationsDescriptor(), new AttachJavadocDescriptor(), new AttachUrlJavadocDescriptor());
|
||||
return Arrays.asList(new AttachClassesDescriptor(), new AttachJarDirectoriesDescriptor(),
|
||||
new AttachSourcesDescriptor(), new AttachJarSourcesDirectoriesDescriptor(),
|
||||
new AttachAnnotationsDescriptor(), new AttachJavadocDescriptor(),
|
||||
new AttachUrlJavadocDescriptor());
|
||||
}
|
||||
|
||||
public static OrderRootTypePresentation getDefaultPresentation(OrderRootType type) {
|
||||
@@ -105,6 +107,33 @@ public class DefaultLibraryRootsComponentDescriptor extends LibraryRootsComponen
|
||||
}
|
||||
}
|
||||
|
||||
private static class AttachJarSourcesDirectoriesDescriptor extends ChooserBasedAttachRootButtonDescriptor {
|
||||
private AttachJarSourcesDirectoriesDescriptor() {
|
||||
super(OrderRootType.SOURCES, ProjectBundle.message("module.libraries.attach.jar.sources.directories.button"));
|
||||
}
|
||||
|
||||
public FileChooserDescriptor createChooserDescriptor() {
|
||||
return new FileChooserDescriptor(false, true, false, false, false, true);
|
||||
}
|
||||
|
||||
public boolean addAsJarDirectories() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getChooserTitle(final String libraryName) {
|
||||
if (StringUtil.isEmpty(libraryName)) {
|
||||
return ProjectBundle.message("library.attach.jar.sources.directory.action");
|
||||
}
|
||||
else {
|
||||
return ProjectBundle.message("library.attach.jar.sources.directory.to.library.action", libraryName);
|
||||
}
|
||||
}
|
||||
|
||||
public String getChooserDescription() {
|
||||
return ProjectBundle.message("library.attach.jar.sources.directory.description");
|
||||
}
|
||||
}
|
||||
|
||||
private static class AttachSourcesDescriptor extends ChooserBasedAttachRootButtonDescriptor {
|
||||
private AttachSourcesDescriptor() {
|
||||
super(OrderRootType.SOURCES, ProjectBundle.message("module.libraries.attach.sources.button"));
|
||||
|
||||
+19
-4
@@ -125,6 +125,16 @@ public class ExistingLibraryEditor implements LibraryEditor, Disposable {
|
||||
getModel().addJarDirectory(url, recursive);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addJarDirectory(VirtualFile file, boolean recursive, OrderRootType rootType) {
|
||||
getModel().addJarDirectory(file, recursive, rootType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addJarDirectory(String url, boolean recursive, OrderRootType rootType) {
|
||||
getModel().addJarDirectory(url, recursive, rootType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeRoot(String url, OrderRootType rootType) {
|
||||
while (getModel().removeRoot(url, rootType)) ;
|
||||
@@ -156,13 +166,18 @@ public class ExistingLibraryEditor implements LibraryEditor, Disposable {
|
||||
}
|
||||
return myLibraryProperties != null && !myLibraryProperties.equals(getOriginalProperties());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isJarDirectory(String url) {
|
||||
return isJarDirectory(url, OrderRootType.CLASSES);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isJarDirectory(String url, OrderRootType rootType) {
|
||||
if (myModel != null) {
|
||||
return myModel.isJarDirectory(url);
|
||||
return myModel.isJarDirectory(url, rootType);
|
||||
}
|
||||
return myLibrary.isJarDirectory(url);
|
||||
return myLibrary.isJarDirectory(url, rootType);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -170,6 +185,6 @@ public class ExistingLibraryEditor implements LibraryEditor, Disposable {
|
||||
if (myModel != null) {
|
||||
return myModel.isValid(url, orderRootType);
|
||||
}
|
||||
return myLibrary.isValid(url, orderRootType);
|
||||
return myLibrary.isValid(url, orderRootType);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -325,7 +325,7 @@ public class LibraryRootsComponent implements Disposable, LibraryEditorComponent
|
||||
final LibraryEditor libraryEditor = getLibraryEditor();
|
||||
for (VirtualFile file : filesToAttach) {
|
||||
if (isJarDirectories) {
|
||||
libraryEditor.addJarDirectory(file, false);
|
||||
libraryEditor.addJarDirectory(file, false, rootType);
|
||||
}
|
||||
else {
|
||||
libraryEditor.addRoot(file, rootType);
|
||||
|
||||
+1
-1
@@ -77,7 +77,7 @@ public class LibraryTreeStructure extends AbstractTreeStructure {
|
||||
final String[] urls = libraryEditor.getUrls(orderRootType).clone();
|
||||
Arrays.sort(urls, LibraryRootsComponent.ourUrlComparator);
|
||||
for (String url : urls) {
|
||||
items.add(new ItemElement(rootTypeElement, url, orderRootType, libraryEditor.isJarDirectory(url), libraryEditor.isValid(url, orderRootType)));
|
||||
items.add(new ItemElement(rootTypeElement, url, orderRootType, libraryEditor.isJarDirectory(url, orderRootType), libraryEditor.isValid(url, orderRootType)));
|
||||
}
|
||||
return items.toArray();
|
||||
}
|
||||
|
||||
+36
-14
@@ -16,6 +16,7 @@
|
||||
package com.intellij.openapi.roots.ui.configuration.libraryEditor;
|
||||
|
||||
import com.intellij.openapi.roots.OrderRootType;
|
||||
import com.intellij.openapi.roots.impl.libraries.JarDirectories;
|
||||
import com.intellij.openapi.roots.impl.libraries.LibraryImpl;
|
||||
import com.intellij.openapi.roots.libraries.Library;
|
||||
import com.intellij.openapi.roots.libraries.LibraryProperties;
|
||||
@@ -28,7 +29,9 @@ import com.intellij.util.containers.MultiMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
@@ -36,7 +39,7 @@ import java.util.*;
|
||||
public class NewLibraryEditor implements LibraryEditor {
|
||||
private String myLibraryName;
|
||||
private final MultiMap<OrderRootType, LightFilePointer> myRoots;
|
||||
private final Map<String, Boolean> myJarDirectories = new HashMap<String, Boolean>();
|
||||
private final JarDirectories myJarDirectories = new JarDirectories();
|
||||
private final LibraryType myType;
|
||||
private LibraryProperties myProperties;
|
||||
|
||||
@@ -86,9 +89,9 @@ public class NewLibraryEditor implements LibraryEditor {
|
||||
}
|
||||
|
||||
if (file.isDirectory()) {
|
||||
final Boolean recursively = myJarDirectories.get(file.getUrl());
|
||||
if (recursively != null) {
|
||||
LibraryImpl.collectJarFiles(file, result, recursively);
|
||||
final String url = file.getUrl();
|
||||
if (myJarDirectories.contains(rootType, url)) {
|
||||
LibraryImpl.collectJarFiles(file, result, myJarDirectories.isRecursive(rootType, url));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -114,19 +117,29 @@ public class NewLibraryEditor implements LibraryEditor {
|
||||
|
||||
@Override
|
||||
public void addJarDirectory(VirtualFile file, boolean recursive) {
|
||||
addJarDirectory(file.getUrl(), recursive);
|
||||
addJarDirectory(file.getUrl(), recursive, OrderRootType.CLASSES);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addJarDirectory(final String url, boolean recursive) {
|
||||
addRoot(url, OrderRootType.CLASSES);
|
||||
myJarDirectories.put(url, recursive);
|
||||
addJarDirectory(url, recursive, OrderRootType.CLASSES);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addJarDirectory(VirtualFile file, boolean recursive, OrderRootType rootType) {
|
||||
addJarDirectory(file.getUrl(), recursive, rootType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addJarDirectory(final String url, boolean recursive, OrderRootType rootType) {
|
||||
addRoot(url, rootType);
|
||||
myJarDirectories.add(rootType, url, recursive);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeRoot(String url, OrderRootType rootType) {
|
||||
myRoots.removeValue(rootType, new LightFilePointer(url));
|
||||
myJarDirectories.remove(url);
|
||||
myJarDirectories.remove(rootType, url);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -136,7 +149,12 @@ public class NewLibraryEditor implements LibraryEditor {
|
||||
|
||||
@Override
|
||||
public boolean isJarDirectory(String url) {
|
||||
return myJarDirectories.containsKey(url);
|
||||
return isJarDirectory(url, OrderRootType.CLASSES);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isJarDirectory(String url, OrderRootType rootType) {
|
||||
return myJarDirectories.contains(rootType, url);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -161,8 +179,10 @@ public class NewLibraryEditor implements LibraryEditor {
|
||||
model.addRoot(pointer.getUrl(), type);
|
||||
}
|
||||
}
|
||||
for (Map.Entry<String, Boolean> entry : myJarDirectories.entrySet()) {
|
||||
model.addJarDirectory(entry.getKey(), entry.getValue());
|
||||
for (OrderRootType rootType : myJarDirectories.getRootTypes()) {
|
||||
for (String url : myJarDirectories.getDirectories(rootType)) {
|
||||
model.addJarDirectory(url, myJarDirectories.isRecursive(rootType, url), rootType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,8 +192,10 @@ public class NewLibraryEditor implements LibraryEditor {
|
||||
editor.addRoot(pointer.getUrl(), type);
|
||||
}
|
||||
}
|
||||
for (Map.Entry<String, Boolean> entry : myJarDirectories.entrySet()) {
|
||||
editor.addJarDirectory(entry.getKey(), entry.getValue());
|
||||
for (OrderRootType rootType : myJarDirectories.getRootTypes()) {
|
||||
for (String url : myJarDirectories.getDirectories(rootType)) {
|
||||
editor.addJarDirectory(url, myJarDirectories.isRecursive(rootType, url), rootType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public interface Library extends JDOMExternalizable, Disposable {
|
||||
@NotNull VirtualFile[] getFiles(@NotNull OrderRootType rootType);
|
||||
|
||||
/**
|
||||
* As soon as you obtaining modifiable model you will have to commit it or call Disposer.dispose(model)!
|
||||
* As soon as you obtaining modifiable model you will have to commit it or call Disposer.dispose(model)!
|
||||
*/
|
||||
@NotNull ModifiableModel getModifiableModel();
|
||||
|
||||
@@ -45,9 +45,11 @@ public interface Library extends JDOMExternalizable, Disposable {
|
||||
@NotNull RootProvider getRootProvider();
|
||||
|
||||
boolean isJarDirectory(@NotNull String url);
|
||||
|
||||
|
||||
boolean isJarDirectory(@NotNull String url, @NotNull OrderRootType rootType);
|
||||
|
||||
boolean isValid(@NotNull String url, @NotNull OrderRootType rootType);
|
||||
|
||||
|
||||
interface ModifiableModel extends Disposable {
|
||||
@NotNull String[] getUrls(@NotNull OrderRootType rootType);
|
||||
|
||||
@@ -56,13 +58,17 @@ public interface Library extends JDOMExternalizable, Disposable {
|
||||
String getName();
|
||||
|
||||
void addRoot(@NonNls @NotNull String url, @NotNull OrderRootType rootType);
|
||||
|
||||
|
||||
void addJarDirectory(@NotNull String url, boolean recursive);
|
||||
|
||||
void addJarDirectory(@NotNull String url, boolean recursive, @NotNull OrderRootType rootType);
|
||||
|
||||
void addRoot(@NotNull VirtualFile file, @NotNull OrderRootType rootType);
|
||||
|
||||
|
||||
void addJarDirectory(@NotNull VirtualFile file, boolean recursive);
|
||||
|
||||
void addJarDirectory(@NotNull VirtualFile file, boolean recursive, @NotNull OrderRootType rootType);
|
||||
|
||||
void moveRootUp(@NotNull String url, @NotNull OrderRootType rootType);
|
||||
|
||||
void moveRootDown(@NotNull String url, @NotNull OrderRootType rootType);
|
||||
@@ -74,9 +80,11 @@ public interface Library extends JDOMExternalizable, Disposable {
|
||||
@NotNull VirtualFile[] getFiles(@NotNull OrderRootType rootType);
|
||||
|
||||
boolean isChanged();
|
||||
|
||||
|
||||
boolean isJarDirectory(@NotNull String url);
|
||||
|
||||
|
||||
boolean isJarDirectory(@NotNull String url, @NotNull OrderRootType rootType);
|
||||
|
||||
boolean isValid(@NotNull String url, @NotNull OrderRootType rootType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.openapi.roots.impl.libraries;
|
||||
|
||||
import com.intellij.openapi.roots.OrderRootType;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class JarDirectories {
|
||||
private MultiMap<OrderRootType, String> myDirectories = new MultiMap<OrderRootType, String>();
|
||||
private MultiMap<OrderRootType, String> myRecursivelyIncluded = new MultiMap<OrderRootType, String>();
|
||||
|
||||
public void copyFrom(JarDirectories other) {
|
||||
myDirectories.clear();
|
||||
myDirectories.putAllValues(other.myDirectories);
|
||||
myRecursivelyIncluded.clear();
|
||||
myRecursivelyIncluded.putAllValues(other.myRecursivelyIncluded);
|
||||
}
|
||||
|
||||
public boolean contains(OrderRootType rootType, String url) {
|
||||
return myDirectories.get(rootType).contains(url);
|
||||
}
|
||||
|
||||
public boolean isRecursive(OrderRootType rootType, String url) {
|
||||
return myRecursivelyIncluded.get(rootType).contains(url);
|
||||
}
|
||||
|
||||
public void add(OrderRootType rootType, String url, boolean recursively) {
|
||||
myDirectories.putValue(rootType, url);
|
||||
if (recursively) {
|
||||
myRecursivelyIncluded.putValue(rootType, url);
|
||||
}
|
||||
}
|
||||
|
||||
public void remove(OrderRootType rootType, String url) {
|
||||
myDirectories.removeValue(rootType, url);
|
||||
myRecursivelyIncluded.removeValue(rootType, url);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
myDirectories.clear();
|
||||
myRecursivelyIncluded.clear();
|
||||
}
|
||||
|
||||
public Collection<OrderRootType> getRootTypes() {
|
||||
return myDirectories.keySet();
|
||||
}
|
||||
|
||||
public Collection<String> getDirectories(OrderRootType rootType) {
|
||||
return myDirectories.get(rootType);
|
||||
}
|
||||
|
||||
public Collection<? extends String> getAllDirectories() {
|
||||
return myDirectories.values();
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return myDirectories.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof JarDirectories)) return false;
|
||||
|
||||
JarDirectories that = (JarDirectories)o;
|
||||
return myDirectories.equals(that.myDirectories) && myRecursivelyIncluded.equals(that.myRecursivelyIncluded);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 31 * myDirectories.hashCode() + myRecursivelyIncluded.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Jar dirs: " + myDirectories.values();
|
||||
}
|
||||
}
|
||||
@@ -65,12 +65,14 @@ public class LibraryImpl implements LibraryEx.ModifiableModelEx, LibraryEx {
|
||||
@NonNls private static final String JAR_DIRECTORY_ELEMENT = "jarDirectory";
|
||||
@NonNls private static final String URL_ATTR = "url";
|
||||
@NonNls private static final String RECURSIVE_ATTR = "recursive";
|
||||
@NonNls private static final String ROOT_TYPE_ATTR = "type";
|
||||
@NonNls private static final String PROPERTIES_ELEMENT = "properties";
|
||||
private static final OrderRootType DEFAULT_JAR_DIRECTORY_TYPE = OrderRootType.CLASSES;
|
||||
private static final SkipDefaultValuesSerializationFilters SERIALIZATION_FILTERS = new SkipDefaultValuesSerializationFilters();
|
||||
private String myName;
|
||||
private final LibraryTable myLibraryTable;
|
||||
private final Map<OrderRootType, VirtualFilePointerContainer> myRoots;
|
||||
private final Map<String, Boolean> myJarDirectories = new HashMap<String, Boolean>();
|
||||
private final JarDirectories myJarDirectories = new JarDirectories();
|
||||
private final List<LocalFileSystem.WatchRequest> myWatchRequests = new ArrayList<LocalFileSystem.WatchRequest>();
|
||||
private final LibraryImpl mySource;
|
||||
private LibraryType<?> myType;
|
||||
@@ -106,7 +108,7 @@ public class LibraryImpl implements LibraryEx.ModifiableModelEx, LibraryEx {
|
||||
myRoots = initRoots();
|
||||
mySource = null;
|
||||
}
|
||||
|
||||
|
||||
private Set<OrderRootType> getAllRootTypes() {
|
||||
Set<OrderRootType> rootTypes = new HashSet<OrderRootType>();
|
||||
rootTypes.addAll(Arrays.asList(OrderRootType.getAllTypes()));
|
||||
@@ -114,7 +116,7 @@ public class LibraryImpl implements LibraryEx.ModifiableModelEx, LibraryEx {
|
||||
rootTypes.addAll(Arrays.asList(myType.getAdditionalRootTypes()));
|
||||
}
|
||||
return rootTypes;
|
||||
}
|
||||
}
|
||||
|
||||
private LibraryImpl(LibraryImpl from, LibraryImpl newSource, ModifiableRootModel rootModel) {
|
||||
assert !from.isDisposed();
|
||||
@@ -134,7 +136,7 @@ public class LibraryImpl implements LibraryEx.ModifiableModelEx, LibraryEx {
|
||||
final VirtualFilePointerContainer thatContainer = from.myRoots.get(rootType);
|
||||
thisContainer.addAll(thatContainer);
|
||||
}
|
||||
myJarDirectories.putAll(from.myJarDirectories);
|
||||
myJarDirectories.copyFrom(from.myJarDirectories);
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
@@ -171,9 +173,8 @@ public class LibraryImpl implements LibraryEx.ModifiableModelEx, LibraryEx {
|
||||
final List<VirtualFile> expanded = new ArrayList<VirtualFile>();
|
||||
for (VirtualFile file : myRoots.get(rootType).getFiles()) {
|
||||
if (file.isDirectory()) {
|
||||
final Boolean expandRecursively = myJarDirectories.get(file.getUrl());
|
||||
if (expandRecursively != null) {
|
||||
collectJarFiles(file, expanded, expandRecursively.booleanValue());
|
||||
if (myJarDirectories.contains(rootType, file.getUrl())) {
|
||||
collectJarFiles(file, expanded, myJarDirectories.isRecursive(rootType, file.getUrl()));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -242,7 +243,7 @@ public class LibraryImpl implements LibraryEx.ModifiableModelEx, LibraryEx {
|
||||
|
||||
private Map<OrderRootType, VirtualFilePointerContainer> initRoots() {
|
||||
Disposer.register(this, myPointersDisposable);
|
||||
|
||||
|
||||
Map<OrderRootType, VirtualFilePointerContainer> result = new HashMap<OrderRootType, VirtualFilePointerContainer>(5);
|
||||
|
||||
for (OrderRootType rootType : getAllRootTypes()) {
|
||||
@@ -301,16 +302,25 @@ public class LibraryImpl implements LibraryEx.ModifiableModelEx, LibraryEx {
|
||||
final Element jarDir = (Element)item;
|
||||
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) {
|
||||
myJarDirectories.put(url, Boolean.valueOf(Boolean.parseBoolean(recursive)));
|
||||
myJarDirectories.add(rootType, url, Boolean.valueOf(Boolean.parseBoolean(recursive)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//TODO<rv> Remove the next two methods as a temporary solution. Sort in OrderRootType.
|
||||
private static OrderRootType getJarDirectoryRootType(@Nullable String type) {
|
||||
for (PersistentOrderRootType rootType : OrderRootType.getAllPersistentTypes()) {
|
||||
if (rootType.name().equals(type)) {
|
||||
return rootType;
|
||||
}
|
||||
}
|
||||
return DEFAULT_JAR_DIRECTORY_TYPE;
|
||||
}
|
||||
|
||||
//TODO<rv> Remove the next two methods as a temporary solution. Sort in OrderRootType.
|
||||
//
|
||||
private static List<OrderRootType> sortRootTypes(List<OrderRootType> rootTypes) {
|
||||
private static List<OrderRootType> sortRootTypes(Collection<OrderRootType> rootTypes) {
|
||||
List<OrderRootType> allTypes = new ArrayList<OrderRootType>(rootTypes);
|
||||
Collections.sort(allTypes, new Comparator<OrderRootType>() {
|
||||
public int compare(final OrderRootType o1, final OrderRootType o2) {
|
||||
@@ -319,7 +329,7 @@ public class LibraryImpl implements LibraryEx.ModifiableModelEx, LibraryEx {
|
||||
});
|
||||
return allTypes;
|
||||
}
|
||||
|
||||
|
||||
private static String getSortKey(OrderRootType orderRootType) {
|
||||
if (orderRootType instanceof PersistentOrderRootType) {
|
||||
return ((PersistentOrderRootType)orderRootType).getSdkRootName();
|
||||
@@ -359,17 +369,19 @@ public class LibraryImpl implements LibraryEx.ModifiableModelEx, LibraryEx {
|
||||
roots.writeExternal(rootTypeElement, ROOT_PATH_ELEMENT);
|
||||
element.addContent(rootTypeElement);
|
||||
}
|
||||
List<String> urls = new ArrayList<String>(myJarDirectories.keySet());
|
||||
Collections.sort(urls, new Comparator<String>() {
|
||||
public int compare(final String url1, final String url2) {
|
||||
return url1.compareToIgnoreCase(url2);
|
||||
final List<OrderRootType> rootTypes = sortRootTypes(myJarDirectories.getRootTypes());
|
||||
for (OrderRootType rootType : rootTypes) {
|
||||
final List<String> urls = new ArrayList<String>(myJarDirectories.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(myJarDirectories.isRecursive(rootType, url)));
|
||||
if (!rootType.equals(DEFAULT_JAR_DIRECTORY_TYPE)) {
|
||||
jarDirElement.setAttribute(ROOT_TYPE_ATTR, rootType.name());
|
||||
}
|
||||
element.addContent(jarDirElement);
|
||||
}
|
||||
});
|
||||
for (String url : urls) {
|
||||
final Element jarDirElement = new Element(JAR_DIRECTORY_ELEMENT);
|
||||
jarDirElement.setAttribute(URL_ATTR, url);
|
||||
jarDirElement.setAttribute(RECURSIVE_ATTR, myJarDirectories.get(url).toString());
|
||||
element.addContent(jarDirElement);
|
||||
}
|
||||
rootElement.addContent(element);
|
||||
}
|
||||
@@ -405,23 +417,35 @@ public class LibraryImpl implements LibraryEx.ModifiableModelEx, LibraryEx {
|
||||
}
|
||||
|
||||
public void addJarDirectory(@NotNull final String url, final boolean recursive) {
|
||||
assert !isDisposed();
|
||||
LOG.assertTrue(isWritable());
|
||||
final VirtualFilePointerContainer container = myRoots.get(OrderRootType.CLASSES);
|
||||
container.add(url);
|
||||
myJarDirectories.put(url, Boolean.valueOf(recursive));
|
||||
addJarDirectory(url, recursive, DEFAULT_JAR_DIRECTORY_TYPE);
|
||||
}
|
||||
|
||||
public void addJarDirectory(@NotNull final VirtualFile file, final boolean recursive) {
|
||||
addJarDirectory(file, recursive, DEFAULT_JAR_DIRECTORY_TYPE);
|
||||
}
|
||||
|
||||
public void addJarDirectory(@NotNull final String url, final boolean recursive, @NotNull OrderRootType rootType) {
|
||||
assert !isDisposed();
|
||||
LOG.assertTrue(isWritable());
|
||||
final VirtualFilePointerContainer container = myRoots.get(OrderRootType.CLASSES);
|
||||
final VirtualFilePointerContainer container = myRoots.get(rootType);
|
||||
container.add(url);
|
||||
myJarDirectories.add(rootType, url, recursive);
|
||||
}
|
||||
|
||||
public void addJarDirectory(@NotNull final VirtualFile file, final boolean recursive, @NotNull OrderRootType rootType) {
|
||||
assert !isDisposed();
|
||||
LOG.assertTrue(isWritable());
|
||||
final VirtualFilePointerContainer container = myRoots.get(rootType);
|
||||
container.add(file);
|
||||
myJarDirectories.put(file.getUrl(), Boolean.valueOf(recursive));
|
||||
myJarDirectories.add(rootType, file.getUrl(), recursive);
|
||||
}
|
||||
|
||||
public boolean isJarDirectory(@NotNull final String url) {
|
||||
return myJarDirectories.containsKey(url);
|
||||
return isJarDirectory(url, DEFAULT_JAR_DIRECTORY_TYPE);
|
||||
}
|
||||
|
||||
public boolean isJarDirectory(@NotNull final String url, @NotNull final OrderRootType rootType) {
|
||||
return myJarDirectories.contains(rootType, url);
|
||||
}
|
||||
|
||||
public boolean isValid(@NotNull final String url, @NotNull final OrderRootType rootType) {
|
||||
@@ -437,7 +461,7 @@ public class LibraryImpl implements LibraryEx.ModifiableModelEx, LibraryEx {
|
||||
final VirtualFilePointer byUrl = container.findByUrl(url);
|
||||
if (byUrl != null) {
|
||||
container.remove(byUrl);
|
||||
myJarDirectories.remove(url);
|
||||
myJarDirectories.remove(rootType, url);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -510,8 +534,7 @@ public class LibraryImpl implements LibraryEx.ModifiableModelEx, LibraryEx {
|
||||
if (areRootsChanged(fromModel)) {
|
||||
disposeMyPointers();
|
||||
copyRootsFrom(fromModel);
|
||||
myJarDirectories.clear();
|
||||
myJarDirectories.putAll(fromModel.myJarDirectories);
|
||||
myJarDirectories.copyFrom(fromModel.myJarDirectories);
|
||||
updateWatchedRoots();
|
||||
myRootProvider.fireRootSetChanged();
|
||||
}
|
||||
@@ -543,12 +566,13 @@ public class LibraryImpl implements LibraryEx.ModifiableModelEx, LibraryEx {
|
||||
}
|
||||
if (!myJarDirectories.isEmpty()) {
|
||||
final VirtualFileManager fm = VirtualFileManager.getInstance();
|
||||
for (Map.Entry<String, Boolean> entry : myJarDirectories.entrySet()) {
|
||||
String url = entry.getKey();
|
||||
if (fm.getFileSystem(VirtualFileManager.extractProtocol(url)) instanceof LocalFileSystem) {
|
||||
final boolean watchRecursively = entry.getValue().booleanValue();
|
||||
final LocalFileSystem.WatchRequest request = fs.addRootToWatch(VirtualFileManager.extractPath(url), watchRecursively);
|
||||
myWatchRequests.add(request);
|
||||
for (OrderRootType rootType : myJarDirectories.getRootTypes()) {
|
||||
for (String url : myJarDirectories.getDirectories(rootType)) {
|
||||
if (fm.getFileSystem(VirtualFileManager.extractProtocol(url)) instanceof LocalFileSystem) {
|
||||
final boolean watchRecursively = myJarDirectories.isRecursive(rootType, url);
|
||||
final LocalFileSystem.WatchRequest request = fs.addRootToWatch(VirtualFileManager.extractPath(url), watchRecursively);
|
||||
myWatchRequests.add(request);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (myBusConnection == null) {
|
||||
@@ -599,7 +623,7 @@ public class LibraryImpl implements LibraryEx.ModifiableModelEx, LibraryEx {
|
||||
}
|
||||
|
||||
private boolean isUnderJarDirectory(String url) {
|
||||
for (String rootUrl : myJarDirectories.keySet()) {
|
||||
for (String rootUrl : myJarDirectories.getAllDirectories()) {
|
||||
if (FileUtil.startsWith(url, rootUrl)) {
|
||||
return true;
|
||||
}
|
||||
@@ -666,7 +690,7 @@ public class LibraryImpl implements LibraryEx.ModifiableModelEx, LibraryEx {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Library: name:" + myName + "; jars:" + myJarDirectories.keySet() + "; roots:" + myRoots.values();
|
||||
return "Library: name:" + myName + "; jars:" + myJarDirectories + "; roots:" + myRoots.values();
|
||||
}
|
||||
|
||||
@Nullable("will return non-null value only for module level libraries")
|
||||
|
||||
+6
@@ -41,12 +41,18 @@ public interface LibraryEditor {
|
||||
|
||||
void addJarDirectory(String url, boolean recursive);
|
||||
|
||||
void addJarDirectory(VirtualFile file, boolean recursive, OrderRootType rootType);
|
||||
|
||||
void addJarDirectory(String url, boolean recursive, OrderRootType rootType);
|
||||
|
||||
void removeRoot(String url, OrderRootType rootType);
|
||||
|
||||
boolean hasChanges();
|
||||
|
||||
boolean isJarDirectory(String url);
|
||||
|
||||
boolean isJarDirectory(String url, OrderRootType rootType);
|
||||
|
||||
boolean isValid(String url, OrderRootType orderRootType);
|
||||
|
||||
LibraryProperties getProperties();
|
||||
|
||||
@@ -74,14 +74,6 @@ public class RenameUtil {
|
||||
result.add(new MoveRenameUsageInfo(referenceElement, ref, ref.getRangeInElement().getStartOffset(),
|
||||
ref.getRangeInElement().getEndOffset(), element,
|
||||
ref.resolve() == null));
|
||||
if (!isValidName(element.getProject(), ref.getElement(), newName)) {
|
||||
result.add(new UnresolvableCollisionUsageInfo(ref.getElement(), element) {
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return RefactoringBundle.message("0.is.not.an.identifier", newName, ref.getElement().getText());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
processor.findCollisions(element, newName, allRenames, result);
|
||||
|
||||
@@ -170,6 +170,9 @@ library.attach.classes.description=Select jar/zip files or directories in which
|
||||
library.attach.jar.directory.to.library.action=Attach Jar Directories to Library \"{0}\"
|
||||
library.attach.jar.directory.action=Attach Jar Directories
|
||||
library.attach.jar.directory.description=Select directories in which jar/zip files are located
|
||||
library.attach.jar.sources.directory.to.library.action=Attach Source Archive Directories to Library \"{0}\"
|
||||
library.attach.jar.sources.directory.action=Attach Source Archive Directories
|
||||
library.attach.jar.sources.directory.description=Select directories in which source jar/zip files are located
|
||||
library.sources.not.found=Sources not found
|
||||
library.sources.not.attached=Sources not attached
|
||||
library.attach.sources.action=Attach Sources
|
||||
@@ -179,6 +182,7 @@ library.attach.javadoc.action=Attach Javadoc
|
||||
library.attach.javadoc.description=Select jar/zip files or directories in which library javadoc documentation is located
|
||||
|
||||
module.libraries.attach.jar.directories.button=Attach Jar &Directories...
|
||||
module.libraries.attach.jar.sources.directories.button=Attach Source Archive D&irectories...
|
||||
library.attach.external.annotations.action=Attach external annotations
|
||||
library.attach.external.annotations.description=Select root where external annotations is located
|
||||
|
||||
@@ -459,7 +463,7 @@ label.text.framework.support.description=This will download all needed libraries
|
||||
file.chooser.directory.for.downloaded.libraries.title=Directory for Downloaded Libraries
|
||||
file.chooser.directory.for.downloaded.libraries.description=Downloaded libraries will be copied to selected directory
|
||||
dialog.title.library.downloading.settings=Library Downloading Settings
|
||||
directory.roots.copy.label=Copy library content to directory (optional):
|
||||
directory.roots.copy.label=Copy library content to directory (optional):
|
||||
combobox.item.global.library=Global Library
|
||||
combobox.item.project.library=Project Library
|
||||
combobox.item.module.library=Module Library
|
||||
@@ -481,4 +485,4 @@ project.new.wizard.import.footnote=Import from external model is available from
|
||||
loading.components.for=Loading components for ''{0}''
|
||||
initializing.components=Initializing components
|
||||
|
||||
library.docs.node=Documentation
|
||||
library.docs.node=Documentation
|
||||
|
||||
@@ -206,4 +206,16 @@ public class MultiMap<K, V> {
|
||||
public static <K, V> MultiMap<K, V> emptyInstance() {
|
||||
return EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof MultiMap)) return false;
|
||||
return myMap.equals(((MultiMap)o).myMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return myMap.hashCode();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1778,5 +1778,16 @@ public class UIUtil {
|
||||
});
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static <T extends JComponent> T findComponentOfType(JComponent parent, Class<T> cls) {
|
||||
if (parent == null || cls.isAssignableFrom(parent.getClass())) return (T)parent;
|
||||
for (Component component : parent.getComponents()) {
|
||||
if (component instanceof JComponent) {
|
||||
T comp = findComponentOfType((JComponent)component, cls);
|
||||
if (comp != null) return comp;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user