Added GetLastActiveClass
To make temporary plugins work with the BCV.getCurrentlyOpenedClassNode() API, we have to store the last active class viewer in memory There is probably a better way of doing this, but the only code using these APIs are user plugins, so it shouldn't impact the rest of the program if we have a resource mismatch
This commit is contained in:
parent
269aed29b2
commit
d0b075ca1b
|
@ -350,7 +350,15 @@ public class BytecodeViewer
|
|||
*/
|
||||
public static ClassNode getCurrentlyOpenedClassNode()
|
||||
{
|
||||
return getActiveResource().resource.getResourceClassNode();
|
||||
return getActiveClass().resource.getResourceClassNode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the currently opened & viewed resource
|
||||
*/
|
||||
public static ResourceViewer getActiveClass()
|
||||
{
|
||||
return BytecodeViewer.viewer.workPane.getLastActiveClass();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -54,6 +54,7 @@ public class Workspace extends TranslatedVisibleComponent
|
|||
public final JButton refreshClass;
|
||||
public final Set<String> openedTabs = new HashSet<>();
|
||||
public HashMap<String, ClassFileContainer> classFiles = new HashMap<>();
|
||||
private ResourceViewer lastActiveClassViewer;
|
||||
|
||||
public Workspace()
|
||||
{
|
||||
|
@ -61,6 +62,14 @@ public class Workspace extends TranslatedVisibleComponent
|
|||
|
||||
this.tabs = new DraggableTabbedPane();
|
||||
|
||||
tabs.addChangeListener(e ->
|
||||
{
|
||||
ResourceViewer viewer = (ResourceViewer) tabs.getSelectedComponent();
|
||||
|
||||
if(viewer instanceof ClassViewer)
|
||||
lastActiveClassViewer = viewer;
|
||||
});
|
||||
|
||||
// configure popup menu of close tabs
|
||||
JTabbedPanePopupMenuTabsCloser popupMenuTabsCloser = new JTabbedPanePopupMenuTabsCloser(this.tabs);
|
||||
PopupMenuTabsCloseConfiguration.Builder builder = new PopupMenuTabsCloseConfiguration.Builder();
|
||||
|
@ -173,6 +182,11 @@ public class Workspace extends TranslatedVisibleComponent
|
|||
return (ResourceViewer) tabs.getSelectedComponent();
|
||||
}
|
||||
|
||||
public ResourceViewer getLastActiveClass()
|
||||
{
|
||||
return lastActiveClassViewer;
|
||||
}
|
||||
|
||||
public Component[] getLoadedViewers()
|
||||
{
|
||||
return tabs.getComponents();
|
||||
|
|
Loading…
Reference in New Issue
Block a user