Correct merge

This commit is contained in:
Rustam.Vishnyakov
2011-10-11 12:01:50 +04:00
parent febc8b1b5c
commit e8432991fe
@@ -24,7 +24,7 @@ import com.intellij.openapi.roots.RootProvider;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.ArrayUtil;
import com.intellij.util.Function;
import com.intellij.util.NullableFunction;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
@@ -37,7 +37,6 @@ abstract class LibraryOrderEntryBaseImpl extends OrderEntryBaseImpl {
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.roots.impl.LibraryOrderEntryBaseImpl");
protected final ProjectRootManagerImpl myProjectRootManagerImpl;
@NotNull protected DependencyScope myScope = DependencyScope.COMPILE;
private final MyRootSetChangedListener myRootSetChangedListener = new MyRootSetChangedListener();
private RootProvider myCurrentlySubscribedRootProvider = null;
LibraryOrderEntryBaseImpl(RootModelImpl rootModel, ProjectRootManagerImpl instanceImpl) {
@@ -92,7 +91,7 @@ abstract class LibraryOrderEntryBaseImpl extends OrderEntryBaseImpl {
}
protected VirtualFile[] filterDirectories(VirtualFile[] files) {
List<VirtualFile> filtered = ContainerUtil.mapNotNull(files, new Function<VirtualFile, VirtualFile>() {
List<VirtualFile> filtered = ContainerUtil.mapNotNull(files, new NullableFunction<VirtualFile, VirtualFile>() {
public VirtualFile fun(VirtualFile file) {
return file.isDirectory() ? file : null;
}
@@ -128,37 +127,19 @@ abstract class LibraryOrderEntryBaseImpl extends OrderEntryBaseImpl {
private void subscribe(RootProvider wrapper) {
if (wrapper != null) {
addListenerToWrapper(wrapper, myRootSetChangedListener);
myProjectRootManagerImpl.subscribeToRootProvider(this, wrapper);
}
myCurrentlySubscribedRootProvider = wrapper;
}
private void addListenerToWrapper(final RootProvider wrapper,
final RootProvider.RootSetChangedListener rootSetChangedListener) {
myProjectRootManagerImpl.addRootSetChangedListener(rootSetChangedListener, wrapper);
}
private void unsubscribe() {
if (myCurrentlySubscribedRootProvider != null) {
final RootProvider wrapper = myCurrentlySubscribedRootProvider;
removeListenerFromWrapper(wrapper, myRootSetChangedListener);
myProjectRootManagerImpl.unsubscribeFromRootProvider(this, myCurrentlySubscribedRootProvider);
}
myCurrentlySubscribedRootProvider = null;
}
protected void removeListenerFromWrapper(final RootProvider wrapper,
final RootProvider.RootSetChangedListener rootSetChangedListener) {
myProjectRootManagerImpl.removeRootSetChangedListener(rootSetChangedListener, wrapper);
}
private class MyRootSetChangedListener implements RootProvider.RootSetChangedListener {
public void rootSetChanged(RootProvider wrapper) {
updateFromRootProviderAndSubscribe();
}
}
@Override
public void dispose() {
unsubscribe();