|
19 | 19 | */
|
20 | 20 | package org.zaproxy.zap.extension.scripts;
|
21 | 21 |
|
| 22 | +import static org.zaproxy.zap.extension.scripts.ExtensionScriptsUI.extractScriptExceptionMessage; |
| 23 | + |
22 | 24 | import java.awt.BorderLayout;
|
23 | 25 | import java.awt.GridBagLayout;
|
24 | 26 | import java.awt.Toolkit;
|
|
46 | 48 | import javax.swing.JLabel;
|
47 | 49 | import javax.swing.JOptionPane;
|
48 | 50 | import javax.swing.JPanel;
|
49 |
| -import javax.swing.JSplitPane; |
50 | 51 | import javax.swing.JToolBar;
|
51 | 52 | import javax.swing.KeyStroke;
|
52 | 53 | import javax.swing.border.EmptyBorder;
|
@@ -86,7 +87,6 @@ public class ConsolePanel extends AbstractPanel {
|
86 | 87 | private JButton optionsButton;
|
87 | 88 | private JLabel scriptTitle = null;
|
88 | 89 | private CommandPanel commandPanel = null;
|
89 |
| - private OutputPanel outputPanel = null; |
90 | 90 | private KeyListener listener = null;
|
91 | 91 |
|
92 | 92 | private ScriptWrapper script = null;
|
@@ -135,15 +135,8 @@ public ConsolePanel(ExtensionScriptsUI extension) {
|
135 | 135 | panelContent = new JPanel(new GridBagLayout());
|
136 | 136 | this.add(panelContent, BorderLayout.CENTER);
|
137 | 137 |
|
138 |
| - JSplitPane splitPane = new JSplitPane(); |
139 |
| - splitPane.setDividerSize(3); |
140 |
| - splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT); |
141 |
| - splitPane.setResizeWeight(0.5D); |
142 |
| - splitPane.setTopComponent(getCommandPanel()); |
143 |
| - splitPane.setBottomComponent(getOutputPanel()); |
144 |
| - |
145 | 138 | panelContent.add(this.getPanelToolbar(), LayoutHelper.getGBC(0, 0, 1, 1.0D, 0.0D));
|
146 |
| - panelContent.add(splitPane, LayoutHelper.getGBC(0, 1, 1, 1.0D, 1.0D)); |
| 139 | + panelContent.add(getCommandPanel(), LayoutHelper.getGBC(0, 1, 1, 1.0D, 1.0D)); |
147 | 140 | }
|
148 | 141 |
|
149 | 142 | private boolean isScriptUpdatedOnDisk() {
|
@@ -456,8 +449,6 @@ private void runScript() {
|
456 | 449 |
|
457 | 450 | getRunButton().setEnabled(false);
|
458 | 451 |
|
459 |
| - getOutputPanel().preScriptInvoke(); |
460 |
| - |
461 | 452 | // Update it, in case its been changed
|
462 | 453 | script.setContents(getCommandScript());
|
463 | 454 |
|
@@ -546,19 +537,6 @@ public void actionPerformed(ActionEvent e) {
|
546 | 537 | return commandPanel;
|
547 | 538 | }
|
548 | 539 |
|
549 |
| - protected OutputPanel getOutputPanel() { |
550 |
| - if (outputPanel == null) { |
551 |
| - outputPanel = new OutputPanel(extension); |
552 |
| - resetOutputPanel(); |
553 |
| - } |
554 |
| - return outputPanel; |
555 |
| - } |
556 |
| - |
557 |
| - protected void resetOutputPanel() { |
558 |
| - outputPanel.clear(); |
559 |
| - outputPanel.append(Constant.messages.getString("scripts.welcome.results")); |
560 |
| - } |
561 |
| - |
562 | 540 | public String getCommandScript() {
|
563 | 541 | return this.getCommandPanel().getCommandScript();
|
564 | 542 | }
|
@@ -796,7 +774,12 @@ public void run() {
|
796 | 774 | try {
|
797 | 775 | extension.getExtScript().invokeScript(script);
|
798 | 776 | } catch (Exception e) {
|
799 |
| - getOutputPanel().append(e); |
| 777 | + if (extension.getView() != null) { |
| 778 | + extension |
| 779 | + .getView() |
| 780 | + .getOutputPanel() |
| 781 | + .append(extractScriptExceptionMessage(e), script.getName()); |
| 782 | + } |
800 | 783 | } finally {
|
801 | 784 | WeakReference<ScriptExecutorThread> refScriptExecutorThread =
|
802 | 785 | runnableScriptsToThreadMap.remove(script);
|
|
0 commit comments