mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2024-11-21 19:42:14 +00:00
Merge remote-tracking branch 'origin/GP-0-dragonmacher-test-fixes-10-12-24'
This commit is contained in:
commit
ddf1efd486
@ -4,9 +4,9 @@
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@ -30,6 +30,7 @@ import javax.swing.tree.TreePath;
|
||||
|
||||
import org.junit.*;
|
||||
|
||||
import docking.KeyEntryPanel;
|
||||
import docking.action.DockingActionIf;
|
||||
import docking.actions.KeyBindingUtils;
|
||||
import docking.options.editor.OptionsDialog;
|
||||
@ -429,7 +430,11 @@ public class KeyBindingUtilsTest extends AbstractGhidraHeadedIntegrationTest {
|
||||
panel = (KeyBindingsPanel) getEditorPanel(keyBindingsNode, optionsDialog);
|
||||
table = findComponent(panel, JTable.class);
|
||||
Object actionBindingPanel = getInstanceField("actionBindingPanel", panel);
|
||||
keyField = (JTextField) getInstanceField("keyEntryField", actionBindingPanel);
|
||||
|
||||
KeyEntryPanel keyEntryPanel =
|
||||
(KeyEntryPanel) getInstanceField("keyEntryPanel", actionBindingPanel);
|
||||
keyField = keyEntryPanel.getTextField();
|
||||
|
||||
model = table.getModel();
|
||||
|
||||
debug("ff");
|
||||
|
@ -4,9 +4,9 @@
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@ -94,8 +94,7 @@ public class KeyBindingsTest extends AbstractGhidraHeadedIntegrationTest {
|
||||
// look for the info panel
|
||||
MultiLineLabel label = findComponent(panel, MultiLineLabel.class);
|
||||
String str = "To add or change a key binding, select an action\n" +
|
||||
"and type any key combination\n" + " \n" +
|
||||
"To remove a key binding, select an action and\n" + "press <Enter> or <Backspace>";
|
||||
"and type any key combination.";
|
||||
|
||||
assertEquals(str, label.getLabel());
|
||||
|
||||
@ -239,18 +238,7 @@ public class KeyBindingsTest extends AbstractGhidraHeadedIntegrationTest {
|
||||
|
||||
selectRowForAction(action1);
|
||||
|
||||
typeKeyStroke(KeyEvent.VK_ENTER);
|
||||
assertNoKeyStrokeText();
|
||||
|
||||
apply();
|
||||
assertNull(getKeyStroke(action1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClearKeyBinding2() throws Exception {
|
||||
|
||||
selectRowForAction(action1);
|
||||
typeBackspace();
|
||||
pressButtonByName(panel, "Clear Key Binding");
|
||||
assertNoKeyStrokeText();
|
||||
|
||||
apply();
|
||||
@ -290,7 +278,6 @@ public class KeyBindingsTest extends AbstractGhidraHeadedIntegrationTest {
|
||||
|
||||
selectRowForAction(action1);
|
||||
typeKeyStroke(reservedKeystroke);
|
||||
|
||||
assertNoKeyStrokeText();
|
||||
assertMessage("F4 in use by System action 'Set KeyBinding'");
|
||||
|
||||
@ -313,7 +300,7 @@ public class KeyBindingsTest extends AbstractGhidraHeadedIntegrationTest {
|
||||
selectRowForAction(action1);
|
||||
assertEquals(validKeyStroke, getKeyStroke(action1));
|
||||
|
||||
typeKeyStroke(reservedKeystroke.getKeyCode());
|
||||
typeKeyStroke(reservedKeystroke);
|
||||
assertNoKeyStrokeText();
|
||||
assertMessage("F4 in use by System action 'Set KeyBinding'");
|
||||
|
||||
@ -384,7 +371,7 @@ public class KeyBindingsTest extends AbstractGhidraHeadedIntegrationTest {
|
||||
assertMessage(systemKsText + " in use by System action 'Show Context Menu'");
|
||||
|
||||
selectRowForAction(systemAction);
|
||||
typeBackspace();
|
||||
pressButtonByName(panel, "Clear Key Binding");
|
||||
apply();
|
||||
assertEquals(null, getKeyStroke(systemAction));
|
||||
|
||||
@ -422,11 +409,6 @@ public class KeyBindingsTest extends AbstractGhidraHeadedIntegrationTest {
|
||||
assertMessage("");
|
||||
}
|
||||
|
||||
private void typeBackspace() {
|
||||
triggerBackspaceKey(keyField);
|
||||
waitForSwing();
|
||||
}
|
||||
|
||||
private void typeKeyStroke(KeyStroke ks) {
|
||||
triggerKey(keyField, ks);
|
||||
waitForSwing();
|
||||
|
@ -4,9 +4,9 @@
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@ -36,6 +36,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.junit.*;
|
||||
|
||||
import docking.DialogComponentProvider;
|
||||
import docking.KeyEntryPanel;
|
||||
import docking.action.DockingActionIf;
|
||||
import docking.actions.KeyBindingUtils;
|
||||
import docking.options.editor.*;
|
||||
@ -1010,7 +1011,9 @@ public class OptionsDialogTest extends AbstractGhidraHeadedIntegrationTest {
|
||||
setToggleButtonSelected(panel, "Enter Mouse Binding", false);
|
||||
|
||||
JPanel actionBindingPanel = (JPanel) getInstanceField("actionBindingPanel", panel);
|
||||
JTextField textField = (JTextField) getInstanceField("keyEntryField", actionBindingPanel);
|
||||
KeyEntryPanel keyEntryPanel =
|
||||
(KeyEntryPanel) getInstanceField("keyEntryPanel", actionBindingPanel);
|
||||
JTextField textField = keyEntryPanel.getTextField();
|
||||
|
||||
triggerKey(textField, modifiers, keyCode, keyChar);
|
||||
waitForSwing();
|
||||
@ -1030,10 +1033,7 @@ public class OptionsDialogTest extends AbstractGhidraHeadedIntegrationTest {
|
||||
|
||||
setToggleButtonSelected(panel, "Enter Mouse Binding", false);
|
||||
|
||||
JPanel actionBindingPanel = (JPanel) getInstanceField("actionBindingPanel", panel);
|
||||
JTextField textField = (JTextField) getInstanceField("keyEntryField", actionBindingPanel);
|
||||
|
||||
triggerBackspaceKey(textField);
|
||||
pressButtonByName(panel, "Clear Key Binding");
|
||||
waitForSwing();
|
||||
|
||||
KeyStroke currentBinding = getKeyBindingFromTable(actionName, actionOwner);
|
||||
|
@ -42,14 +42,22 @@ public class KeyEntryPanel extends JPanel {
|
||||
|
||||
keyEntryField = new KeyEntryTextField(columns, listener);
|
||||
clearButton = new EmptyBorderButton(Icons.DELETE_ICON);
|
||||
clearButton.setToolTipText("Clear the current key binding");
|
||||
clearButton.addActionListener(e -> keyEntryField.clearField());
|
||||
clearButton.setName("Clear Key Binding");
|
||||
clearButton.addActionListener(e -> keyEntryField.clearKeyStroke());
|
||||
|
||||
add(keyEntryField);
|
||||
add(Box.createHorizontalStrut(2));
|
||||
add(clearButton);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the text field used by this class
|
||||
* @return the text field
|
||||
*/
|
||||
public JTextField getTextField() {
|
||||
return keyEntryField;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the key stroke on this panel
|
||||
* @param ks the key stroke
|
||||
|
@ -81,7 +81,21 @@ public class KeyEntryTextField extends HintTextField {
|
||||
setText(KeyBindingUtils.parseKeyStroke(ks));
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the state of this class, but does not notify listeners. This allows clients to
|
||||
* control the state of the field without having a callback change the client state.
|
||||
*/
|
||||
public void clearField() {
|
||||
ksName = null;
|
||||
setText("");
|
||||
currentKeyStroke = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the state of this class and notifies this client. This effectively allows for the
|
||||
* programmatic setting of the keystroke in use to be null, or in the 'no keystroke set' state.
|
||||
*/
|
||||
public void clearKeyStroke() {
|
||||
if (currentKeyStroke == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -455,8 +455,8 @@ public class KeyBindingsPanel extends JPanel {
|
||||
ToolActions toolActions = (ToolActions) tool.getToolActions();
|
||||
String errorMessage = toolActions.validateActionKeyBinding(action, ks);
|
||||
if (errorMessage != null) {
|
||||
statusLabel.setText(errorMessage);
|
||||
actionBindingPanel.clearKeyStroke();
|
||||
statusLabel.setText(errorMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user