mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
favorites: fix classloader when a bookmark node class is contained in some plugin (IDEA-147470, IDEA-149853)
This commit is contained in:
+9
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -18,14 +18,16 @@ package com.intellij.ide.favoritesTreeView;
|
||||
|
||||
import com.intellij.ide.projectView.impl.AbstractUrl;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public class AbstractUrlFavoriteAdapter extends AbstractUrl {
|
||||
@NotNull
|
||||
private final FavoriteNodeProvider myNodeProvider;
|
||||
|
||||
public AbstractUrlFavoriteAdapter(final String url, final String moduleName, final FavoriteNodeProvider nodeProvider) {
|
||||
public AbstractUrlFavoriteAdapter(String url, String moduleName, @NotNull FavoriteNodeProvider nodeProvider) {
|
||||
super(url, moduleName, nodeProvider.getFavoriteTypeId());
|
||||
myNodeProvider = nodeProvider;
|
||||
}
|
||||
@@ -44,4 +46,9 @@ public class AbstractUrlFavoriteAdapter extends AbstractUrl {
|
||||
public AbstractUrl createUrlByElement(Object element) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
FavoriteNodeProvider getNodeProvider() {
|
||||
return myNodeProvider;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -93,10 +93,16 @@ public class FavoritesListNode extends AbstractTreeNode<String> {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
final String className = pair.getData().getSecond();
|
||||
|
||||
ClassLoader loader;
|
||||
if (abstractUrl instanceof AbstractUrlFavoriteAdapter) {
|
||||
FavoriteNodeProvider provider = ((AbstractUrlFavoriteAdapter)abstractUrl).getNodeProvider();
|
||||
loader = provider.getClass().getClassLoader();
|
||||
} else {
|
||||
loader = FavoritesListNode.class.getClass().getClassLoader();
|
||||
}
|
||||
String className = pair.getData().getSecond();
|
||||
@SuppressWarnings("unchecked")
|
||||
final Class<? extends AbstractTreeNode> nodeClass = (Class<? extends AbstractTreeNode>)Class.forName(className);
|
||||
final Class<? extends AbstractTreeNode> nodeClass = (Class<? extends AbstractTreeNode>)loader.loadClass(className);
|
||||
|
||||
final AbstractTreeNode node = ProjectViewNode
|
||||
.createTreeNode(nodeClass, project, path[path.length - 1], FavoritesManager.getInstance(project).getViewSettings());
|
||||
|
||||
Reference in New Issue
Block a user