mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
CCE LibraryImpl <-> Proxy
This commit is contained in:
@@ -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();
|
||||
|
||||
+7
-1
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user