Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scripts: Use main output panel for output #6044

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion addOns/scripts/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ All notable changes to this add-on will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## Unreleased

### Changed
- Use the main Output panel for script output.

## [45.8.0] - 2025-01-10
### Added
Expand Down
2 changes: 1 addition & 1 deletion addOns/scripts/scripts.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ zapAddOn {
dependencies {
addOns {
register("commonlib") {
version.set(">=1.29.0")
version.set(">=1.31.0")
}
register("pscan") {
version.set(">= 0.1.0 & < 1.0.0")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JSplitPane;
import javax.swing.JToolBar;
import javax.swing.KeyStroke;
import javax.swing.border.EmptyBorder;
Expand Down Expand Up @@ -86,7 +85,6 @@ public class ConsolePanel extends AbstractPanel {
private JButton optionsButton;
private JLabel scriptTitle = null;
private CommandPanel commandPanel = null;
private OutputPanel outputPanel = null;
private KeyListener listener = null;

private ScriptWrapper script = null;
Expand Down Expand Up @@ -135,15 +133,8 @@ public ConsolePanel(ExtensionScriptsUI extension) {
panelContent = new JPanel(new GridBagLayout());
this.add(panelContent, BorderLayout.CENTER);

JSplitPane splitPane = new JSplitPane();
splitPane.setDividerSize(3);
splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
splitPane.setResizeWeight(0.5D);
splitPane.setTopComponent(getCommandPanel());
splitPane.setBottomComponent(getOutputPanel());

panelContent.add(this.getPanelToolbar(), LayoutHelper.getGBC(0, 0, 1, 1.0D, 0.0D));
panelContent.add(splitPane, LayoutHelper.getGBC(0, 1, 1, 1.0D, 1.0D));
panelContent.add(getCommandPanel(), LayoutHelper.getGBC(0, 1, 1, 1.0D, 1.0D));
}

private boolean isScriptUpdatedOnDisk() {
Expand Down Expand Up @@ -456,8 +447,6 @@ private void runScript() {

getRunButton().setEnabled(false);

getOutputPanel().preScriptInvoke();

// Update it, in case its been changed
script.setContents(getCommandScript());

Expand Down Expand Up @@ -546,19 +535,6 @@ public void actionPerformed(ActionEvent e) {
return commandPanel;
}

protected OutputPanel getOutputPanel() {
if (outputPanel == null) {
outputPanel = new OutputPanel(extension);
resetOutputPanel();
}
return outputPanel;
}

protected void resetOutputPanel() {
outputPanel.clear();
outputPanel.append(Constant.messages.getString("scripts.welcome.results"));
}

public String getCommandScript() {
return this.getCommandPanel().getCommandScript();
}
Expand Down Expand Up @@ -796,7 +772,14 @@ public void run() {
try {
extension.getExtScript().invokeScript(script);
} catch (Exception e) {
getOutputPanel().append(e);
if (extension.getView() != null) {
extension
.getView()
.getOutputPanel()
.append(
ExtensionScriptsUI.extractScriptExceptionMessage(e),
script.getName());
}
} finally {
WeakReference<ScriptExecutorThread> refScriptExecutorThread =
runnableScriptsToThreadMap.remove(script);
Expand Down
Loading
Loading