Skip to content
Merged
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
6 changes: 3 additions & 3 deletions docker/chrome/chrome.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
tests:
- name: "At least one URL found"
onFail: "WARN"
statistic: "spiderAjax.urls.added"
statistic: "stats.client.spider.urls"
site: ""
operator: ">="
value: 1
type: "stats"
name: "spiderAjax"
type: "spiderAjax"
name: "spiderClient"
type: "spiderClient"
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@
import java.awt.HeadlessException;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.awt.event.WindowEvent;
import javax.swing.AbstractAction;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.KeyStroke;
Expand All @@ -54,6 +56,8 @@ public abstract class AbstractDialog extends JDialog {

protected AbstractDialog thisDialog = null;

private JButton defaultButton;

/**
* Constructs an {@code AbstractDialog} with no owner and not modal.
*
Expand Down Expand Up @@ -114,6 +118,39 @@ public void actionPerformed(ActionEvent e) {
};
getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(escape, "ESCAPE");
getRootPane().getActionMap().put("ESCAPE", escapeAction);

// Handle ctrl+enter to trigger the dialog's default button, regardless of which
// component (e.g. a text area or table) currently has focus.
KeyStroke ctrlEnter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.CTRL_DOWN_MASK);
AbstractAction ctrlEnterAction =
new AbstractAction() {
private static final long serialVersionUID = 1L;

@Override
public void actionPerformed(ActionEvent e) {
JButton button = getRootPane().getDefaultButton();
if (button != null && button.isEnabled()) {
button.doClick();
}
}
};
getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(ctrlEnter, "CTRL_ENTER");
getRootPane().getActionMap().put("CTRL_ENTER", ctrlEnterAction);
}

/**
* Sets the button to use as this dialog's main action (e.g. OK, Apply, Save), giving it the
* current look and feel's "default button" highlight and binding it to Ctrl+Enter.
*
* <p>Disposing a dialog clears its root pane's default button (see {@link
* JButton#removeNotify()}), so this is re-applied every time the dialog is shown, which matters
* for dialogs that are constructed once and reused across multiple show/dispose cycles.
*
* @param button the button to use as this dialog's main action, or {@code null} for none.
*/
protected void setDefaultButton(JButton button) {
this.defaultButton = button;
getRootPane().setDefaultButton(button);
}

/**
Expand All @@ -132,6 +169,7 @@ public void setVisible(boolean show) {
== 0) {
centreDialog();
}
getRootPane().setDefaultButton(defaultButton);
}
super.setVisible(show);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,7 @@ public void purgeHistory(List<HistoryReference> hrefs) {
" ",
removeWithoutConfirmationCheckBox
};
String confirmButtonLabel = Constant.messages.getString("history.purge.confirm");
int result =
JOptionPane.showOptionDialog(
View.getSingleton().getMainFrame(),
Expand All @@ -951,10 +952,10 @@ public void purgeHistory(List<HistoryReference> hrefs) {
JOptionPane.QUESTION_MESSAGE,
null,
new String[] {
Constant.messages.getString("history.purge.confirm"),
confirmButtonLabel,
Constant.messages.getString("history.purge.cancel")
},
null);
confirmButtonLabel);
if (result != JOptionPane.YES_OPTION) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1002,7 +1002,7 @@ public boolean showRemoveDialogue(DomainMatcher e) {
REMOVE_DIALOG_CONFIRM_BUTTON_LABEL,
REMOVE_DIALOG_CANCEL_BUTTON_LABEL
},
null);
REMOVE_DIALOG_CONFIRM_BUTTON_LABEL);

if (option == JOptionPane.OK_OPTION) {
setRemoveWithoutConfirmation(removeWithoutConfirmationCheckBox.isSelected());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ private javax.swing.JPanel getJContentPane() {
GridBagConstraints.NONE,
GridBagConstraints.EAST,
new Insets(2, 2, 2, 2)));
this.setDefaultButton(getBtnOK());

jContentPane.add(footerPane, LayoutHelper.getGBC(0, 1, 1, 1.0, 0.0));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ private void initialize() {
this.setContentPane(getJPanel());
centreDialog();
txtFind.requestFocus();
this.getRootPane().setDefaultButton(btnFind);
this.setDefaultButton(getBtnFind());
pack();
this.setVisible(true);
}
Expand Down
7 changes: 4 additions & 3 deletions zap/src/main/java/org/parosproxy/paros/view/SiteMapPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,8 @@ public void actionPerformed(ActionEvent e) {
" ",
removeWithoutConfirmationCheckBox
};
String confirmButtonLabel =
Constant.messages.getString("sites.purge.confirm");
int result =
JOptionPane.showOptionDialog(
View.getSingleton().getMainFrame(),
Expand All @@ -481,12 +483,11 @@ public void actionPerformed(ActionEvent e) {
JOptionPane.QUESTION_MESSAGE,
null,
new String[] {
Constant.messages.getString(
"sites.purge.confirm"),
confirmButtonLabel,
Constant.messages.getString(
"sites.purge.cancel")
},
null);
confirmButtonLabel);
if (result != JOptionPane.YES_OPTION) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ private JPanel getJPanel() {
jPanel.add(jLabel2, gridBagConstraints13);
jPanel.add(getBtnCancel(), gridBagConstraints2);
jPanel.add(getBtnOk(), gridBagConstraints3);
this.setDefaultButton(getBtnOk());
}
return jPanel;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public boolean showRemoveDialogue(AntiCsrfParamToken e) {
REMOVE_DIALOG_CONFIRM_BUTTON_LABEL,
REMOVE_DIALOG_CANCEL_BUTTON_LABEL
},
null);
REMOVE_DIALOG_CONFIRM_BUTTON_LABEL);

if (option == JOptionPane.OK_OPTION) {
setRemoveWithoutConfirmation(removeWithoutConfirmationCheckBox.isSelected());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public void actionPerformed(java.awt.event.ActionEvent e) {
new String[] {
confirmButtonLabel, cancelButtonLabel
},
null);
confirmButtonLabel);

if (option != JOptionPane.YES_OPTION) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ public boolean showRemoveDialogue(DomainMatcher e) {
REMOVE_DIALOG_CONFIRM_BUTTON_LABEL,
REMOVE_DIALOG_CANCEL_BUTTON_LABEL
},
null);
REMOVE_DIALOG_CONFIRM_BUTTON_LABEL);

if (option == JOptionPane.OK_OPTION) {
setRemoveWithoutConfirmation(removeWithoutConfirmationCheckBox.isSelected());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,7 @@ public boolean showRemoveDialogue(ScannerParamFilter e) {
REMOVE_DIALOG_CONFIRM_BUTTON_LABEL,
REMOVE_DIALOG_CANCEL_BUTTON_LABEL
},
null);
REMOVE_DIALOG_CONFIRM_BUTTON_LABEL);

return (option == JOptionPane.OK_OPTION);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,17 @@ public void actionPerformed(ActionEvent e) {
getRootPane().getActionMap().put("ESCAPE", escapeAction);
}

@Override
public void setVisible(boolean visible) {
if (visible) {
// This dialog is created once and reused, and disposing it (as the close buttons do)
// clears the root pane's default button (see JButton#removeNotify()), so it must be
// re-applied every time the dialog is shown.
getRootPane().setDefaultButton(getCheckForUpdatesButton());
}
super.setVisible(visible);
}

private JPanel getTopPanel() {
if (topPanel == null) {
topPanel = new JPanel();
Expand Down Expand Up @@ -266,6 +277,7 @@ private JPanel getCorePanel(boolean update) {
corePanel.add(new JLabel(this.currentVersion), LayoutHelper.getGBC(0, 0, 1, 0.0D));
corePanel.add(new JLabel(""), LayoutHelper.getGBC(1, 0, 1, 1.0D));
corePanel.add(this.getCheckForUpdatesButton(), LayoutHelper.getGBC(2, 0, 1, 0.0D));
getRootPane().setDefaultButton(this.getCheckForUpdatesButton());
refresh = false;
}
} else if (latestInfo != null && this.latestInfo.getZapRelease() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ public boolean showRemoveDialogue(File f) {
REMOVE_DIALOG_CONFIRM_BUTTON_LABEL,
REMOVE_DIALOG_CANCEL_BUTTON_LABEL
},
null);
REMOVE_DIALOG_CONFIRM_BUTTON_LABEL);

if (option == JOptionPane.OK_OPTION) {
setRemoveWithoutConfirmation(removeWithoutConfirmationCheckBox.isSelected());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ private int askForDropConfirmation() {
JOptionPane.QUESTION_MESSAGE,
null,
new String[] {confirmButtonLabel, cancelButtonLabel},
null);
confirmButtonLabel);

if (checkBox.isSelected()) {
breakpointsParams.setConfirmDropMessage(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public boolean showRemoveDialogue(CustomPage customPage) {
REMOVE_DIALOG_CONFIRM_BUTTON_LABEL,
REMOVE_DIALOG_CANCEL_BUTTON_LABEL
},
null);
REMOVE_DIALOG_CONFIRM_BUTTON_LABEL);

if (option == JOptionPane.OK_OPTION) {
setRemoveWithoutConfirmation(removeWithoutConfirmationCheckBox.isSelected());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public boolean showRemoveDialogue(GlobalExcludeURLParamToken e) {
REMOVE_DIALOG_CONFIRM_BUTTON_LABEL,
REMOVE_DIALOG_CANCEL_BUTTON_LABEL
},
null);
REMOVE_DIALOG_CONFIRM_BUTTON_LABEL);

if (option == JOptionPane.OK_OPTION) {
setRemoveWithoutConfirmation(removeWithoutConfirmationCheckBox.isSelected());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ private void initialize() {
this.setSize(600, 300);
}
centreDialog();
this.getRootPane().setDefaultButton(btnApply);
this.setDefaultButton(getBtnApply());
this.pack();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ private JPanel getJPanel() {
jPanel.add(getBtnDelete(), gridBagConstraints31);
jPanel.add(getBtnCancel(), gridBagConstraints40);
jPanel.add(getBtnSave(), gridBagConstraints41);
this.setDefaultButton(getBtnSave());
}
return jPanel;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ private void initialize() {

setContentPane(panel);

this.setDefaultButton(getBtnOk());

this.addWindowListener(
new java.awt.event.WindowAdapter() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public void performHistoryReferenceActions(List<HistoryReference> hrefs) {
" ",
removeWithoutConfirmationCheckBox
};
String confirmButtonLabel = Constant.messages.getString("sites.purge.confirm");
int result =
JOptionPane.showOptionDialog(
View.getSingleton().getMainFrame(),
Expand All @@ -86,10 +87,10 @@ public void performHistoryReferenceActions(List<HistoryReference> hrefs) {
JOptionPane.QUESTION_MESSAGE,
null,
new String[] {
Constant.messages.getString("sites.purge.confirm"),
confirmButtonLabel,
Constant.messages.getString("sites.purge.cancel")
},
null);
confirmButtonLabel);
if (result != JOptionPane.YES_OPTION) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ public boolean showRemoveDialogue(HttpSessionToken e) {
REMOVE_DIALOG_CONFIRM_BUTTON_LABEL,
REMOVE_DIALOG_CANCEL_BUTTON_LABEL
},
null);
REMOVE_DIALOG_CONFIRM_BUTTON_LABEL);

if (option == JOptionPane.OK_OPTION) {
setRemoveWithoutConfirmation(removeWithoutConfirmationCheckBox.isSelected());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ public boolean showRemoveDialogue(ProxiesParamProxy e) {
REMOVE_DIALOG_CONFIRM_BUTTON_LABEL,
REMOVE_DIALOG_CANCEL_BUTTON_LABEL
},
null);
REMOVE_DIALOG_CONFIRM_BUTTON_LABEL);

if (option == JOptionPane.OK_OPTION) {
setRemoveWithoutConfirmation(removeWithoutConfirmationCheckBox.isSelected());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public boolean showRemoveDialogue(
REMOVE_DIALOG_CONFIRM_BUTTON_LABEL,
REMOVE_DIALOG_CANCEL_BUTTON_LABEL
},
null);
REMOVE_DIALOG_CONFIRM_BUTTON_LABEL);

if (option == JOptionPane.OK_OPTION) {
setRemoveWithoutConfirmation(removeWithoutConfirmationCheckBox.isSelected());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public boolean showRemoveDialogue(File f) {
REMOVE_DIALOG_CONFIRM_BUTTON_LABEL,
REMOVE_DIALOG_CANCEL_BUTTON_LABEL
},
null);
REMOVE_DIALOG_CONFIRM_BUTTON_LABEL);

if (option == JOptionPane.OK_OPTION) {
setRemoveWithoutConfirmation(removeWithoutConfirmationCheckBox.isSelected());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,9 @@ private void doSearch() {
}

if (pattern.matcher("").find()) {
String searchButtonLabel =
Constant.messages.getString(
"search.toolbar.warn.regex.match.empty.string.button.search");
int option =
JOptionPane.showOptionDialog(
View.getSingleton().getMainFrame(),
Expand All @@ -479,12 +482,11 @@ private void doSearch() {
JOptionPane.QUESTION_MESSAGE,
null,
new String[] {
Constant.messages.getString(
"search.toolbar.warn.regex.match.empty.string.button.search"),
searchButtonLabel,
Constant.messages.getString(
"search.toolbar.warn.regex.match.empty.string.button.cancel")
},
null);
searchButtonLabel);
if (option != JOptionPane.OK_OPTION) {
regEx.requestFocusInWindow();
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public boolean showRemoveDialogue(User e) {
REMOVE_DIALOG_CONFIRM_BUTTON_LABEL,
REMOVE_DIALOG_CANCEL_BUTTON_LABEL
},
null);
REMOVE_DIALOG_CONFIRM_BUTTON_LABEL);

if (option == JOptionPane.OK_OPTION) {
setRemoveWithoutConfirmation(removeWithoutConfirmationCheckBox.isSelected());
Expand Down
Loading
Loading