|
7 | 7 | import javax.swing.filechooser.FileFilter; |
8 | 8 | import the.bytecode.club.bytecodeviewer.BytecodeViewer; |
9 | 9 | import the.bytecode.club.bytecodeviewer.Configuration; |
| 10 | +import the.bytecode.club.bytecodeviewer.api.ExceptionUI; |
10 | 11 | import the.bytecode.club.bytecodeviewer.api.Plugin; |
11 | 12 | import the.bytecode.club.bytecodeviewer.api.PluginConsole; |
12 | 13 | import the.bytecode.club.bytecodeviewer.gui.components.JFrameConsoleTabbed; |
@@ -55,7 +56,10 @@ public final class PluginManager |
55 | 56 |
|
56 | 57 | private static Plugin activePlugin; |
57 | 58 | private static JFrameConsoleTabbed activeTabbedConsole; |
| 59 | + private static JFrameConsoleTabbed activeTabbedException; |
| 60 | + private static HashMap<String, ExceptionUI> exceptionTabs = new HashMap<>(); |
58 | 61 | private static int consoleCount = 0; |
| 62 | + private static int exceptionCount = 0; |
59 | 63 |
|
60 | 64 | static |
61 | 65 | { |
@@ -85,9 +89,12 @@ public static void runPlugin(Plugin newPluginInstance) |
85 | 89 | { |
86 | 90 | //reset the console count |
87 | 91 | consoleCount = 0; |
| 92 | + exceptionCount = 0; |
88 | 93 |
|
89 | 94 | //reset the active tabbed console |
90 | 95 | activeTabbedConsole = null; |
| 96 | + activeTabbedException = null; |
| 97 | + exceptionTabs.clear(); |
91 | 98 |
|
92 | 99 | //reset the active plugin |
93 | 100 | activePlugin = newPluginInstance; |
@@ -122,6 +129,43 @@ public static void runPlugin(File f) throws Throwable |
122 | 129 | runPlugin(p); |
123 | 130 | } |
124 | 131 |
|
| 132 | + /** |
| 133 | + * Add an active console from a plugin being ran |
| 134 | + */ |
| 135 | + public static void addExceptionUI(ExceptionUI ui, String title) |
| 136 | + { |
| 137 | + if(activePlugin == null) |
| 138 | + { |
| 139 | + ui.setLocationRelativeTo(BytecodeViewer.viewer); |
| 140 | + ui.setVisible(true); |
| 141 | + return; |
| 142 | + } |
| 143 | + |
| 144 | + final String name = (activePlugin == null || activePlugin.activeContainer == null) |
| 145 | + ? ("#" + (activeTabbedException.getTabbedPane().getTabCount() + 1)) : activePlugin.activeContainer.name; |
| 146 | + |
| 147 | + ExceptionUI existingUI = exceptionTabs.get(name); |
| 148 | + |
| 149 | + int id = exceptionCount++; |
| 150 | + if(activeTabbedException == null) |
| 151 | + { |
| 152 | + activeTabbedException = new JFrameConsoleTabbed(title); |
| 153 | + |
| 154 | + if(Configuration.pluginConsoleAsNewTab) |
| 155 | + ComponentViewer.addComponentAsTab(title, activeTabbedException.getComponent(0)); |
| 156 | + else |
| 157 | + activeTabbedException.setVisible(true); |
| 158 | + } |
| 159 | + |
| 160 | + if(existingUI == null) |
| 161 | + { |
| 162 | + activeTabbedException.addConsole(ui.getComponent(0), name); |
| 163 | + exceptionTabs.put(name, ui); |
| 164 | + } |
| 165 | + else |
| 166 | + existingUI.appendText("\n\r" + ui.getTextArea().getText()); |
| 167 | + } |
| 168 | + |
125 | 169 | /** |
126 | 170 | * Add an active console from a plugin being ran |
127 | 171 | */ |
|
0 commit comments