mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-05-27 10:29:36 +08:00
GP-5769 - Updated dialogs with combo boxes to have consistent behavior
when the Enter key is pressed
This commit is contained in:
+1
-1
@@ -154,7 +154,7 @@ public class FunctionStartRFParamsDialog extends ReusableDialogComponentProvider
|
|||||||
private RandomForestTableModel tableModel;
|
private RandomForestTableModel tableModel;
|
||||||
private Program trainingSource;
|
private Program trainingSource;
|
||||||
private FunctionStartRFParams params;
|
private FunctionStartRFParams params;
|
||||||
private Vector<Long> moduli = new Vector<>(Arrays.asList(new Long[] { 4l, 8l, 16l, 32l }));
|
private List<Long> moduli = Arrays.asList(new Long[] { 4l, 8l, 16l, 32l });
|
||||||
private GComboBox<Long> modBox;
|
private GComboBox<Long> modBox;
|
||||||
private JButton trainButton;
|
private JButton trainButton;
|
||||||
private JCheckBox includeBeforeAndAfterBox;
|
private JCheckBox includeBeforeAndAfterBox;
|
||||||
|
|||||||
-1
@@ -115,7 +115,6 @@ public class CreateBookmarkDialog extends DialogComponentProvider {
|
|||||||
|
|
||||||
categoryComboBox = new GhidraComboBox<>(getModel());
|
categoryComboBox = new GhidraComboBox<>(getModel());
|
||||||
categoryComboBox.setEditable(true);
|
categoryComboBox.setEditable(true);
|
||||||
categoryComboBox.setEnterKeyForwarding(true);
|
|
||||||
descriptionTextField = new JTextField(20);
|
descriptionTextField = new JTextField(20);
|
||||||
|
|
||||||
panel.add(new JLabel("Address: ", SwingConstants.RIGHT));
|
panel.add(new JLabel("Address: ", SwingConstants.RIGHT));
|
||||||
|
|||||||
+7
-3
@@ -235,7 +235,13 @@ public abstract class AbstractSettingsDialog extends DialogComponentProvider {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void okCallback() {
|
protected void okCallback() {
|
||||||
settingsTable.editingStopped(null);
|
|
||||||
|
// prevent users from closing the dialog when pressing Enter to confirm an edit
|
||||||
|
if (settingsTable.isEditing()) {
|
||||||
|
settingsTable.editingStopped(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
apply();
|
apply();
|
||||||
close();
|
close();
|
||||||
dispose();
|
dispose();
|
||||||
@@ -694,8 +700,6 @@ public abstract class AbstractSettingsDialog extends DialogComponentProvider {
|
|||||||
private SettingsRowObject rowobject;
|
private SettingsRowObject rowobject;
|
||||||
|
|
||||||
SettingsEditor() {
|
SettingsEditor() {
|
||||||
comboBox.setEnterKeyForwarding(false);
|
|
||||||
comboBox.addActionListener(e -> fireEditingStopped());
|
|
||||||
intTextField.addChangeListener(e -> updateHexMode());
|
intTextField.addChangeListener(e -> updateHexMode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-10
@@ -4,9 +4,9 @@
|
|||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
@@ -16,8 +16,6 @@
|
|||||||
package ghidra.app.plugin.core.datamgr.actions;
|
package ghidra.app.plugin.core.datamgr.actions;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
@@ -72,12 +70,6 @@ class AnnotationHandlerDialog extends DialogComponentProvider {
|
|||||||
outerPanel.getAccessibleContext().setAccessibleName("Annotation Handler");
|
outerPanel.getAccessibleContext().setAccessibleName("Annotation Handler");
|
||||||
handlerComboBox = new GhidraComboBox<>(handlerList);
|
handlerComboBox = new GhidraComboBox<>(handlerList);
|
||||||
handlerComboBox.getAccessibleContext().setAccessibleName("Combo Box");
|
handlerComboBox.getAccessibleContext().setAccessibleName("Combo Box");
|
||||||
handlerComboBox.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent evt) {
|
|
||||||
okCallback();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
outerPanel.add(handlerComboBox, BorderLayout.NORTH);
|
outerPanel.add(handlerComboBox, BorderLayout.NORTH);
|
||||||
return outerPanel;
|
return outerPanel;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -63,7 +63,7 @@ public class OperandLabelDialog extends DialogComponentProvider {
|
|||||||
myChoice = new GhidraComboBox<>();
|
myChoice = new GhidraComboBox<>();
|
||||||
myChoice.setName("MYCHOICE");
|
myChoice.setName("MYCHOICE");
|
||||||
myChoice.setEditable(true);
|
myChoice.setEditable(true);
|
||||||
myChoice.addActionListener(ev -> okCallback());
|
|
||||||
myChoice.getAccessibleContext().setAccessibleName("My Choice");
|
myChoice.getAccessibleContext().setAccessibleName("My Choice");
|
||||||
mainPanel.add(label);
|
mainPanel.add(label);
|
||||||
mainPanel.add(myChoice);
|
mainPanel.add(myChoice);
|
||||||
|
|||||||
+2
-8
@@ -4,9 +4,9 @@
|
|||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
@@ -192,12 +192,6 @@ class SearchTextDialog extends ReusableDialogComponentProvider {
|
|||||||
valueComboBox = new GhidraComboBox<>();
|
valueComboBox = new GhidraComboBox<>();
|
||||||
valueComboBox.setEditable(true);
|
valueComboBox.setEditable(true);
|
||||||
valueComboBox.setColumns(20);
|
valueComboBox.setColumns(20);
|
||||||
valueComboBox.addActionListener(ev -> {
|
|
||||||
if (nextButton.isEnabled()) {
|
|
||||||
nextPrevious(true); // go forward
|
|
||||||
valueComboBox.requestFocus();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
valueComboBox.addEditorKeyListener(new KeyAdapter() {
|
valueComboBox.addEditorKeyListener(new KeyAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void keyPressed(KeyEvent e) {
|
public void keyPressed(KeyEvent e) {
|
||||||
|
|||||||
+2
-30
@@ -16,7 +16,8 @@
|
|||||||
package ghidra.app.plugin.core.strings;
|
package ghidra.app.plugin.core.strings;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.*;
|
import java.awt.event.ItemEvent;
|
||||||
|
import java.awt.event.ItemListener;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.Character.UnicodeScript;
|
import java.lang.Character.UnicodeScript;
|
||||||
@@ -449,35 +450,6 @@ public class EncodedStringsDialog extends DialogComponentProvider {
|
|||||||
EncodedStringsPlugin.CHARSET_DEFAULT_VALUE));
|
EncodedStringsPlugin.CHARSET_DEFAULT_VALUE));
|
||||||
charsetComboBox.addItemListener(itemListener);
|
charsetComboBox.addItemListener(itemListener);
|
||||||
charsetComboBox.setToolTipText("Which character set to use to decode the raw bytes.");
|
charsetComboBox.setToolTipText("Which character set to use to decode the raw bytes.");
|
||||||
charsetComboBox.addKeyListener(new KeyListener() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void keyTyped(KeyEvent e) {
|
|
||||||
// empty
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void keyReleased(KeyEvent e) {
|
|
||||||
// empty
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void keyPressed(KeyEvent e) {
|
|
||||||
// Note: we override the [ENTER] key handling to allow the user to invoke the
|
|
||||||
// dialog and just hit enter to create the string without having to do any
|
|
||||||
// clicking (otherwise the charset combobox consumes the keystroke)
|
|
||||||
if (e.getKeyChar() == '\n') {
|
|
||||||
e.consume();
|
|
||||||
if (charsetComboBox.isPopupVisible()) {
|
|
||||||
charsetComboBox.setPopupVisible(false);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
EncodedStringsDialog.this.createButton.doClick();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buildOptionsButtonComponents() {
|
private void buildOptionsButtonComponents() {
|
||||||
|
|||||||
@@ -563,7 +563,6 @@ public class AddEditDialog extends ReusableDialogComponentProvider {
|
|||||||
labelNameChoices.setColumns(20);
|
labelNameChoices.setColumns(20);
|
||||||
labelNameChoices.setName("label.name.choices");
|
labelNameChoices.setName("label.name.choices");
|
||||||
GhidraComboBox<NamespaceWrapper> comboBox = new GhidraComboBox<>();
|
GhidraComboBox<NamespaceWrapper> comboBox = new GhidraComboBox<>();
|
||||||
comboBox.setEnterKeyForwarding(true);
|
|
||||||
namespaceChoices = comboBox;
|
namespaceChoices = comboBox;
|
||||||
|
|
||||||
primaryCheckBox = new GCheckBox("Primary");
|
primaryCheckBox = new GCheckBox("Primary");
|
||||||
|
|||||||
+4
-4
@@ -199,7 +199,7 @@ public class GoToAddressLabelDialog extends ReusableDialogComponentProvider
|
|||||||
|
|
||||||
comboBox = new GhidraComboBox<>();
|
comboBox = new GhidraComboBox<>();
|
||||||
comboBox.setEditable(true);
|
comboBox.setEditable(true);
|
||||||
comboBox.addActionListener(evt -> okCallback());
|
|
||||||
String comboName = "Go To Address or Label Text Field / Combobox";
|
String comboName = "Go To Address or Label Text Field / Combobox";
|
||||||
comboBox.setName(comboName);
|
comboBox.setName(comboName);
|
||||||
comboBox.getAccessibleContext().setAccessibleName(comboName);
|
comboBox.getAccessibleContext().setAccessibleName(comboName);
|
||||||
@@ -243,9 +243,9 @@ public class GoToAddressLabelDialog extends ReusableDialogComponentProvider
|
|||||||
private void readHistory(SaveState saveState) {
|
private void readHistory(SaveState saveState) {
|
||||||
String[] strs = saveState.getStrings("GO_TO_HISTORY", null);
|
String[] strs = saveState.getStrings("GO_TO_HISTORY", null);
|
||||||
if (strs != null) {
|
if (strs != null) {
|
||||||
for (int i = 0; i < strs.length; i++) {
|
for (String str : strs) {
|
||||||
if (!history.contains(strs[i])) {
|
if (!history.contains(str)) {
|
||||||
history.add(strs[i]);
|
history.add(str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
truncateHistoryAsNeeded();
|
truncateHistoryAsNeeded();
|
||||||
|
|||||||
@@ -266,7 +266,6 @@ public class ImporterDialog extends DialogComponentProvider {
|
|||||||
Set<Loader> orderedLoaders = new LinkedHashSet<>(loaderMap.keySet()); // maintain order
|
Set<Loader> orderedLoaders = new LinkedHashSet<>(loaderMap.keySet()); // maintain order
|
||||||
loaderComboBox = new GhidraComboBox<>(orderedLoaders);
|
loaderComboBox = new GhidraComboBox<>(orderedLoaders);
|
||||||
loaderComboBox.addItemListener(e -> selectedLoaderChanged());
|
loaderComboBox.addItemListener(e -> selectedLoaderChanged());
|
||||||
loaderComboBox.setEnterKeyForwarding(true);
|
|
||||||
loaderComboBox.getAccessibleContext().setAccessibleName("Loader Choices");
|
loaderComboBox.getAccessibleContext().setAccessibleName("Loader Choices");
|
||||||
loaderComboBox.setRenderer(
|
loaderComboBox.setRenderer(
|
||||||
GComboBoxCellRenderer.createDefaultTextRenderer(loader -> loader.getName()));
|
GComboBoxCellRenderer.createDefaultTextRenderer(loader -> loader.getName()));
|
||||||
|
|||||||
@@ -4,9 +4,9 @@
|
|||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
@@ -157,7 +157,7 @@ public class DbViewer extends JFrame {
|
|||||||
tables[i].getName() + " (" + Integer.toString(tables[i].getRecordCount()) + ")";
|
tables[i].getName() + " (" + Integer.toString(tables[i].getRecordCount()) + ")";
|
||||||
}
|
}
|
||||||
combo = new GComboBox<>(names);
|
combo = new GComboBox<>(names);
|
||||||
combo.addActionListener(e -> updateTable());
|
combo.addItemListener(e -> updateTable());
|
||||||
subNorthPanel.add(combo);
|
subNorthPanel.add(combo);
|
||||||
northPanel.add(subNorthPanel);
|
northPanel.add(subNorthPanel);
|
||||||
mainPanel.add(northPanel, BorderLayout.NORTH);
|
mainPanel.add(northPanel, BorderLayout.NORTH);
|
||||||
|
|||||||
-1
@@ -77,7 +77,6 @@ public class DecompilerTextFinderDialog extends ReusableDialogComponentProvider
|
|||||||
|
|
||||||
textCombo = new GhidraComboBox<>();
|
textCombo = new GhidraComboBox<>();
|
||||||
textCombo.setEditable(true);
|
textCombo.setEditable(true);
|
||||||
textCombo.addActionListener(e -> doSearch());
|
|
||||||
|
|
||||||
textCombo.setColumns(20);
|
textCombo.setColumns(20);
|
||||||
textCombo.addDocumentListener(new DocumentListener() {
|
textCombo.addDocumentListener(new DocumentListener() {
|
||||||
|
|||||||
+1
-1
@@ -257,7 +257,7 @@ public class PopulateFidDialog extends DialogComponentProvider {
|
|||||||
List<FidFile> fidFileList = FidFileManager.getInstance().getUserAddedFiles();
|
List<FidFile> fidFileList = FidFileManager.getInstance().getUserAddedFiles();
|
||||||
FidFile[] files = fidFileList.toArray(new FidFile[fidFileList.size()]);
|
FidFile[] files = fidFileList.toArray(new FidFile[fidFileList.size()]);
|
||||||
fidFileComboBox = new GComboBox<>(files);
|
fidFileComboBox = new GComboBox<>(files);
|
||||||
fidFileComboBox.addActionListener(e -> updateLibraryChoices());
|
fidFileComboBox.addItemListener(e -> updateLibraryChoices());
|
||||||
fidFileComboBox.getAccessibleContext().setAccessibleName("Fid File");
|
fidFileComboBox.getAccessibleContext().setAccessibleName("Fid File");
|
||||||
return fidFileComboBox;
|
return fidFileComboBox;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-10
@@ -4,9 +4,9 @@
|
|||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
@@ -127,7 +127,6 @@ public class ChooseMatchTagAction extends DockingAction {
|
|||||||
tagComboBox = new MatchTagComboBox(session, matches, component, selectedTag);
|
tagComboBox = new MatchTagComboBox(session, matches, component, selectedTag);
|
||||||
Dimension dim = new Dimension(50, tagComboBox.getPreferredSize().height);
|
Dimension dim = new Dimension(50, tagComboBox.getPreferredSize().height);
|
||||||
tagComboBox.setMinimumSize(dim);
|
tagComboBox.setMinimumSize(dim);
|
||||||
tagComboBox.addActionListener(e -> fieldEdited());
|
|
||||||
panel.add(tagComboBox, BorderLayout.CENTER);
|
panel.add(tagComboBox, BorderLayout.CENTER);
|
||||||
return panel;
|
return panel;
|
||||||
}
|
}
|
||||||
@@ -148,12 +147,5 @@ public class ChooseMatchTagAction extends DockingAction {
|
|||||||
VTMatchTag getSelectedTag() {
|
VTMatchTag getSelectedTag() {
|
||||||
return selectedTag;
|
return selectedTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* An address edit action occurred in the panel so handle it as if ok button were pressed.
|
|
||||||
*/
|
|
||||||
public void fieldEdited() {
|
|
||||||
okCallback();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-13
@@ -1,13 +1,12 @@
|
|||||||
/* ###
|
/* ###
|
||||||
* IP: GHIDRA
|
* IP: GHIDRA
|
||||||
* REVIEWED: YES
|
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
@@ -16,10 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package ghidra.feature.vt.gui.editors;
|
package ghidra.feature.vt.gui.editors;
|
||||||
|
|
||||||
import ghidra.feature.vt.api.main.*;
|
|
||||||
import ghidra.feature.vt.gui.plugin.VTController;
|
|
||||||
import ghidra.util.SystemUtilities;
|
|
||||||
|
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.awt.event.*;
|
import java.awt.event.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -29,6 +24,9 @@ import javax.swing.table.TableCellEditor;
|
|||||||
import javax.swing.table.TableModel;
|
import javax.swing.table.TableModel;
|
||||||
|
|
||||||
import docking.widgets.table.RowObjectTableModel;
|
import docking.widgets.table.RowObjectTableModel;
|
||||||
|
import ghidra.feature.vt.api.main.*;
|
||||||
|
import ghidra.feature.vt.gui.plugin.VTController;
|
||||||
|
import ghidra.util.SystemUtilities;
|
||||||
|
|
||||||
public class MatchTagCellEditor extends AbstractCellEditor implements TableCellEditor {
|
public class MatchTagCellEditor extends AbstractCellEditor implements TableCellEditor {
|
||||||
|
|
||||||
@@ -55,12 +53,6 @@ public class MatchTagCellEditor extends AbstractCellEditor implements TableCellE
|
|||||||
VTSession session = controller.getSession();
|
VTSession session = controller.getSession();
|
||||||
tag = match.getTag();
|
tag = match.getTag();
|
||||||
matchTagChoices = new MatchTagComboBox(session, matches, theTable, tag);
|
matchTagChoices = new MatchTagComboBox(session, matches, theTable, tag);
|
||||||
matchTagChoices.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
stopCellEditing();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
matchTagChoices.addItemListener(new ItemListener() {
|
matchTagChoices.addItemListener(new ItemListener() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+1
-1
@@ -831,7 +831,7 @@ public class ApplyMarkupPropertyEditor implements OptionsEditor {
|
|||||||
Enum<?>[] enums = editor.getEnums();
|
Enum<?>[] enums = editor.getEnums();
|
||||||
|
|
||||||
final JComboBox<Enum<?>> applyComboBox = new GComboBox<>(enums);
|
final JComboBox<Enum<?>> applyComboBox = new GComboBox<>(enums);
|
||||||
applyComboBox.addActionListener(e -> changesMade(true));
|
applyComboBox.addItemListener(e -> changesMade(true));
|
||||||
|
|
||||||
return applyComboBox;
|
return applyComboBox;
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-12
@@ -16,7 +16,7 @@
|
|||||||
package docking.options.editor;
|
package docking.options.editor;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ItemListener;
|
||||||
import java.beans.PropertyEditorSupport;
|
import java.beans.PropertyEditorSupport;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -65,7 +65,7 @@ public class FontPropertyEditor extends PropertyEditorSupport {
|
|||||||
private GComboBox<FontWrapper> fontCombo;
|
private GComboBox<FontWrapper> fontCombo;
|
||||||
private GComboBox<Integer> sizeCombo;
|
private GComboBox<Integer> sizeCombo;
|
||||||
private GComboBox<String> styleCombo;
|
private GComboBox<String> styleCombo;
|
||||||
private ActionListener actionListener = e -> fontChanged();
|
private ItemListener itemListener = e -> fontChanged();
|
||||||
private List<FontWrapper> systemFontNames;
|
private List<FontWrapper> systemFontNames;
|
||||||
|
|
||||||
public FontChooserPanel() {
|
public FontChooserPanel() {
|
||||||
@@ -78,9 +78,9 @@ public class FontPropertyEditor extends PropertyEditorSupport {
|
|||||||
}
|
}
|
||||||
updatePreviewLabel(font);
|
updatePreviewLabel(font);
|
||||||
|
|
||||||
fontCombo.removeActionListener(actionListener);
|
fontCombo.removeItemListener(itemListener);
|
||||||
sizeCombo.removeActionListener(actionListener);
|
sizeCombo.removeItemListener(itemListener);
|
||||||
styleCombo.removeActionListener(actionListener);
|
styleCombo.removeItemListener(itemListener);
|
||||||
|
|
||||||
FontWrapper fontWrapper = new FontWrapper(font.getName());
|
FontWrapper fontWrapper = new FontWrapper(font.getName());
|
||||||
updateComboBoxModeIfNeeded(fontWrapper);
|
updateComboBoxModeIfNeeded(fontWrapper);
|
||||||
@@ -91,10 +91,9 @@ public class FontPropertyEditor extends PropertyEditorSupport {
|
|||||||
sizeCombo.setSelectedItem(size);
|
sizeCombo.setSelectedItem(size);
|
||||||
styleCombo.setSelectedIndex(styleChoice);
|
styleCombo.setSelectedIndex(styleChoice);
|
||||||
|
|
||||||
fontCombo.addActionListener(actionListener);
|
fontCombo.addItemListener(itemListener);
|
||||||
sizeCombo.addActionListener(actionListener);
|
sizeCombo.addItemListener(itemListener);
|
||||||
styleCombo.addActionListener(actionListener);
|
styleCombo.addItemListener(itemListener);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateComboBoxModeIfNeeded(FontWrapper fontWrapper) {
|
private void updateComboBoxModeIfNeeded(FontWrapper fontWrapper) {
|
||||||
@@ -144,7 +143,7 @@ public class FontPropertyEditor extends PropertyEditorSupport {
|
|||||||
styleCombo =
|
styleCombo =
|
||||||
new GComboBox<>(new String[] { "PLAIN", "BOLD", "ITALIC", "BOLD & ITALIC" });
|
new GComboBox<>(new String[] { "PLAIN", "BOLD", "ITALIC", "BOLD & ITALIC" });
|
||||||
styleCombo.setMaximumRowCount(9);
|
styleCombo.setMaximumRowCount(9);
|
||||||
styleCombo.addActionListener(actionListener);
|
styleCombo.addItemListener(itemListener);
|
||||||
styleCombo.getAccessibleContext().setAccessibleName("Style");
|
styleCombo.getAccessibleContext().setAccessibleName("Style");
|
||||||
panel.add(styleCombo);
|
panel.add(styleCombo);
|
||||||
panel.getAccessibleContext().setAccessibleName("Style");
|
panel.getAccessibleContext().setAccessibleName("Style");
|
||||||
@@ -163,7 +162,7 @@ public class FontPropertyEditor extends PropertyEditorSupport {
|
|||||||
sizeCombo =
|
sizeCombo =
|
||||||
new GComboBox<>(IntStream.rangeClosed(1, 72).boxed().toArray(Integer[]::new));
|
new GComboBox<>(IntStream.rangeClosed(1, 72).boxed().toArray(Integer[]::new));
|
||||||
sizeCombo.setMaximumRowCount(9);
|
sizeCombo.setMaximumRowCount(9);
|
||||||
sizeCombo.addActionListener(actionListener);
|
sizeCombo.addItemListener(itemListener);
|
||||||
sizeCombo.getAccessibleContext().setAccessibleName("Size");
|
sizeCombo.getAccessibleContext().setAccessibleName("Size");
|
||||||
panel.add(sizeCombo);
|
panel.add(sizeCombo);
|
||||||
panel.getAccessibleContext().setAccessibleName("Size");
|
panel.getAccessibleContext().setAccessibleName("Size");
|
||||||
@@ -182,7 +181,7 @@ public class FontPropertyEditor extends PropertyEditorSupport {
|
|||||||
systemFontNames = getSystemFontNames();
|
systemFontNames = getSystemFontNames();
|
||||||
fontCombo = new GComboBox<>(systemFontNames.toArray(new FontWrapper[0]));
|
fontCombo = new GComboBox<>(systemFontNames.toArray(new FontWrapper[0]));
|
||||||
fontCombo.setMaximumRowCount(9);
|
fontCombo.setMaximumRowCount(9);
|
||||||
fontCombo.addActionListener(actionListener);
|
fontCombo.addItemListener(itemListener);
|
||||||
fontCombo.getAccessibleContext().setAccessibleName("Font");
|
fontCombo.getAccessibleContext().setAccessibleName("Font");
|
||||||
panel.add(fontCombo);
|
panel.add(fontCombo);
|
||||||
panel.getAccessibleContext().setAccessibleName("Font");
|
panel.getAccessibleContext().setAccessibleName("Font");
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package docking.widgets.combobox;
|
package docking.widgets.combobox;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
@@ -71,8 +72,8 @@ public class GComboBox<E> extends JComboBox<E> implements GComponent {
|
|||||||
*
|
*
|
||||||
* @param items a vector containing objects of generic type {@code E} to insert into the combo box
|
* @param items a vector containing objects of generic type {@code E} to insert into the combo box
|
||||||
*/
|
*/
|
||||||
public GComboBox(Vector<E> items) {
|
public GComboBox(Collection<E> items) {
|
||||||
super(items);
|
super(new Vector<>(items));
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -64,8 +64,6 @@ public class GhidraComboBox<E> extends JComboBox<E> implements GComponent {
|
|||||||
private List<KeyListener> keyListeners = new ArrayList<>();
|
private List<KeyListener> keyListeners = new ArrayList<>();
|
||||||
private boolean setSelectedFlag = false;
|
private boolean setSelectedFlag = false;
|
||||||
|
|
||||||
private boolean forwardEnter;
|
|
||||||
private Action defaultSystemEnterForwardingAction;
|
|
||||||
private Document document;
|
private Document document;
|
||||||
private PassThroughActionListener passThroughActionListener;
|
private PassThroughActionListener passThroughActionListener;
|
||||||
private PassThroughKeyListener passThroughKeyListener;
|
private PassThroughKeyListener passThroughKeyListener;
|
||||||
@@ -125,20 +123,6 @@ public class GhidraComboBox<E> extends JComboBox<E> implements GComponent {
|
|||||||
setDocument(document);
|
setDocument(document);
|
||||||
}
|
}
|
||||||
|
|
||||||
// HACK ALERT: see setEnterKeyForwarding(boolean)
|
|
||||||
ActionMap am = getActionMap();
|
|
||||||
if (am != null) {
|
|
||||||
defaultSystemEnterForwardingAction = am.get("enterPressed");
|
|
||||||
am.put("enterPressed", new AbstractAction() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
if (forwardEnter) {
|
|
||||||
defaultSystemEnterForwardingAction.actionPerformed(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// As mentioned above, the default editor gets replaced. In that case, restore the columns
|
// As mentioned above, the default editor gets replaced. In that case, restore the columns
|
||||||
// if the client has set the value.
|
// if the client has set the value.
|
||||||
if (oldColumns > 0) {
|
if (oldColumns > 0) {
|
||||||
@@ -147,23 +131,6 @@ public class GhidraComboBox<E> extends JComboBox<E> implements GComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* HACK ALERT: By default, the JComboBoxUI forwards the <Enter> key actions to the root
|
|
||||||
* pane of the JComboBox's container (which is used primarily by any installed 'default
|
|
||||||
* button'). The problem is that the forwarding does not happen always. In the case that the
|
|
||||||
* <Enter> key will trigger a selection in the combo box, the action is NOT forwarded.
|
|
||||||
* <p>
|
|
||||||
* By default Ghidra disables the forwarding altogether, since most users of
|
|
||||||
* {@link GhidraComboBox} will add an action listener to handle <Enter> actions.
|
|
||||||
* <p>
|
|
||||||
* To re-enable the default behavior, set the <code>forwardEnter</code> value to true.
|
|
||||||
*
|
|
||||||
* @param forwardEnter true to enable default <Enter> key handling.
|
|
||||||
*/
|
|
||||||
public void setEnterKeyForwarding(boolean forwardEnter) {
|
|
||||||
this.forwardEnter = forwardEnter;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the text in combobox's editor text component
|
* Returns the text in combobox's editor text component
|
||||||
* @return the text in combobox's editor text component
|
* @return the text in combobox's editor text component
|
||||||
|
|||||||
+1
-1
@@ -97,7 +97,7 @@ public interface SettingsDefinition {
|
|||||||
public String getDescription();
|
public String getDescription();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes any values in the given settings object assocated with this settings definition
|
* Removes any values in the given settings object associated with this settings definition
|
||||||
* @param settings the settings object to be cleared.
|
* @param settings the settings object to be cleared.
|
||||||
*/
|
*/
|
||||||
public void clear(Settings settings);
|
public void clear(Settings settings);
|
||||||
|
|||||||
Reference in New Issue
Block a user