Skip to content

Commit

Permalink
Merge pull request #1550 from SiboVG/issue-1549
Browse files Browse the repository at this point in the history
[#1549] Ctrl/Cmd + A select all shortcut in simulation table and component tree
  • Loading branch information
SiboVG committed Jul 27, 2022
2 parents b7589a0 + 651ba88 commit 15aff43
Show file tree
Hide file tree
Showing 4 changed files with 417 additions and 354 deletions.
12 changes: 6 additions & 6 deletions swing/src/net/sf/openrocket/gui/main/BasicFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -418,18 +418,18 @@ public void valueChanged(TreeSelectionEvent e) {
button = new SelectColorButton(actions.getMoveDownAction());
panel.add(button, "sizegroup buttons, aligny 0%");

button = new SelectColorButton(actions.getEditAction());
button.setIcon(null);
button = new SelectColorButton();
RocketActions.tieActionToButtonNoIcon(button, actions.getEditAction());
button.setMnemonic(0);
panel.add(button, "sizegroup buttons, gaptop 20%");

button = new SelectColorButton(actions.getDuplicateAction());
button.setIcon(null);
button = new SelectColorButton();
RocketActions.tieActionToButtonNoIcon(button, actions.getDuplicateAction());
button.setMnemonic(0);
panel.add(button, "sizegroup buttons");

button = new SelectColorButton(actions.getDeleteAction());
button.setIcon(null);
button = new SelectColorButton();
RocketActions.tieActionToButtonNoIcon(button, actions.getDeleteAction());
button.setMnemonic(0);
panel.add(button, "sizegroup buttons");

Expand Down
30 changes: 30 additions & 0 deletions swing/src/net/sf/openrocket/gui/main/RocketActions.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
Expand Down Expand Up @@ -189,6 +190,35 @@ public Action getMoveDownAction() {
return moveDownAction;
}

/**
* Tie an action to a JButton, without using the icon or text of the action for the button.
*
* For any smartass that wants to know why you don't just initialize the JButton with the action and then set the
* icon to null and set the button text: this causes a bug where the text of the icon becomes much smaller than is intended.
*
* @param button button to tie the action to
* @param action action to tie to the button
* @param text text to display on the button
*/
public static void tieActionToButtonNoIcon(JButton button, Action action, String text) {
button.setAction(action);
button.setIcon(null);
button.setText(text);
}

/**
* Tie an action to a JButton, without using the icon of the action for the button.
*
* For any smartass that wants to know why you don't just initialize the JButton with the action and then set the
* icon to null: this causes a bug where the text of the icon becomes much smaller than is intended.
*
* @param button button to tie the action to
* @param action action to tie to the button
*/
public static void tieActionToButtonNoIcon(JButton button, Action action) {
button.setAction(action);
button.setIcon(null);
}


//////// Helper methods for the actions
Expand Down

0 comments on commit 15aff43

Please sign in to comment.