diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ModuleEditor.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ModuleEditor.java index d2217e96cea4..d1c7228d7f7f 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ModuleEditor.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ModuleEditor.java @@ -45,6 +45,7 @@ import javax.swing.*; import javax.swing.event.ChangeEvent; import java.awt.*; import java.lang.reflect.InvocationHandler; +import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Proxy; import java.util.*; @@ -394,6 +395,9 @@ public abstract class ModuleEditor implements Place.Navigator, Disposable { } return result; } + catch (InvocationTargetException e) { + throw e.getCause(); + } finally { if (needUpdate) { updateOrderEntriesInEditors(); @@ -433,6 +437,9 @@ public abstract class ModuleEditor implements Place.Navigator, Disposable { } return result; } + catch (InvocationTargetException e) { + throw e.getCause(); + } finally { if (needUpdate) { updateOrderEntriesInEditors(); @@ -450,12 +457,17 @@ public abstract class ModuleEditor implements Place.Navigator, Disposable { } public Object invoke(Object object, Method method, Object[] params) throws Throwable { - final Object result = method.invoke(myDelegateLibrary, unwrapParams(params)); - if (result instanceof Library.ModifiableModel) { - return Proxy.newProxyInstance(getClass().getClassLoader(), new Class[]{Library.ModifiableModel.class}, - new LibraryModifiableModelInvocationHandler((Library.ModifiableModel)result)); + try { + final Object result = method.invoke(myDelegateLibrary, unwrapParams(params)); + if (result instanceof Library.ModifiableModel) { + return Proxy.newProxyInstance(getClass().getClassLoader(), new Class[]{Library.ModifiableModel.class}, + new LibraryModifiableModelInvocationHandler((Library.ModifiableModel)result)); + } + return result; + } + catch (InvocationTargetException e) { + throw e.getCause(); } - return result; } public Object getDelegate() { @@ -475,6 +487,9 @@ public abstract class ModuleEditor implements Place.Navigator, Disposable { try { return method.invoke(myDelegateModel, unwrapParams(params)); } + catch (InvocationTargetException e) { + throw e.getCause(); + } finally { if (needUpdate) { updateOrderEntriesInEditors(); @@ -510,6 +525,9 @@ public abstract class ModuleEditor implements Place.Navigator, Disposable { } return result; } + catch (InvocationTargetException e) { + throw e.getCause(); + } finally { if (needUpdate) { updateOrderEntriesInEditors(); diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/daemon/LibraryProjectStructureElement.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/daemon/LibraryProjectStructureElement.java index 62faa16e5f06..9d64108d6bab 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/daemon/LibraryProjectStructureElement.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/daemon/LibraryProjectStructureElement.java @@ -8,9 +8,12 @@ import com.intellij.openapi.roots.impl.libraries.LibraryImpl; import com.intellij.openapi.roots.libraries.Library; import com.intellij.openapi.roots.libraries.LibraryTable; import com.intellij.openapi.roots.libraries.LibraryTablesRegistrar; +import com.intellij.openapi.roots.ui.configuration.ModuleEditor; import com.intellij.openapi.roots.ui.configuration.projectRoot.StructureConfigurableContext; import org.jetbrains.annotations.NotNull; +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Proxy; import java.util.Collections; import java.util.List; @@ -58,7 +61,10 @@ public class LibraryProjectStructureElement extends ProjectStructureElement { @NotNull private Library getSourceOrThis() { - final Library source = ((LibraryImpl)myLibrary).getSource(); + final InvocationHandler invocationHandler = Proxy.isProxyClass(myLibrary.getClass()) ? Proxy.getInvocationHandler(myLibrary) : null; + final Library realLibrary = invocationHandler instanceof ModuleEditor.ProxyDelegateAccessor ? + (Library)((ModuleEditor.ProxyDelegateAccessor)invocationHandler).getDelegate() : myLibrary; + final Library source = realLibrary instanceof LibraryImpl? ((LibraryImpl)realLibrary).getSource() : null; return source != null ? source : myLibrary; }