[#2485] Add show all action
This commit is contained in:
parent
3f3352302f
commit
a9456be0fb
@ -50,6 +50,7 @@ RocketActions.MoveDownAct.ttip.Movedown = Move this component downwards.
|
|||||||
RocketActions.ExportOBJAct.ExportOBJ = Export as OBJ (.obj)
|
RocketActions.ExportOBJAct.ExportOBJ = Export as OBJ (.obj)
|
||||||
RocketActions.ExportOBJAct.ttip.ExportOBJ = Export the selected components as a Wavefront OBJ 3D file.
|
RocketActions.ExportOBJAct.ttip.ExportOBJ = Export the selected components as a Wavefront OBJ 3D file.
|
||||||
|
|
||||||
|
RocketActions.Visibility = Visibility
|
||||||
RocketActions.VisibilityAct.ShowAll = Show all
|
RocketActions.VisibilityAct.ShowAll = Show all
|
||||||
RocketActions.VisibilityAct.ttip.ShowAll = Show all components.
|
RocketActions.VisibilityAct.ttip.ShowAll = Show all components.
|
||||||
RocketActions.VisibilityAct.HideAll = Hide all
|
RocketActions.VisibilityAct.HideAll = Hide all
|
||||||
|
@ -607,9 +607,15 @@ public class BasicFrame extends JFrame {
|
|||||||
item = new JMenuItem(actions.getScaleAction());
|
item = new JMenuItem(actions.getScaleAction());
|
||||||
editMenu.add(item);
|
editMenu.add(item);
|
||||||
|
|
||||||
|
//// Visibility
|
||||||
|
JMenu visibilitySubMenu = new JMenu(trans.get("RocketActions.Visibility"));
|
||||||
|
editMenu.add(visibilitySubMenu);
|
||||||
item = new JMenuItem(actions.getToggleVisibilityAction());
|
item = new JMenuItem(actions.getToggleVisibilityAction());
|
||||||
editMenu.add(item);
|
visibilitySubMenu.add(item);
|
||||||
|
item = new JMenuItem(actions.getShowAllComponentsAction());
|
||||||
|
visibilitySubMenu.add(item);
|
||||||
|
|
||||||
|
editMenu.addSeparator();
|
||||||
|
|
||||||
//// Preferences
|
//// Preferences
|
||||||
item = new JMenuItem(trans.get("main.menu.edit.preferences"));
|
item = new JMenuItem(trans.get("main.menu.edit.preferences"));
|
||||||
|
@ -75,6 +75,7 @@ public class RocketActions {
|
|||||||
private final RocketAction moveDownAction;
|
private final RocketAction moveDownAction;
|
||||||
private final RocketAction exportOBJAction;
|
private final RocketAction exportOBJAction;
|
||||||
private final RocketAction toggleVisibilityAction;
|
private final RocketAction toggleVisibilityAction;
|
||||||
|
private final RocketAction showAllComponentsAction;
|
||||||
private static final Translator trans = Application.getTranslator();
|
private static final Translator trans = Application.getTranslator();
|
||||||
private static final Logger log = LoggerFactory.getLogger(RocketActions.class);
|
private static final Logger log = LoggerFactory.getLogger(RocketActions.class);
|
||||||
|
|
||||||
@ -101,6 +102,7 @@ public class RocketActions {
|
|||||||
this.moveDownAction = new MoveDownAction();
|
this.moveDownAction = new MoveDownAction();
|
||||||
this.exportOBJAction = new ExportOBJAction();
|
this.exportOBJAction = new ExportOBJAction();
|
||||||
this.toggleVisibilityAction = new ToggleVisibilityAction();
|
this.toggleVisibilityAction = new ToggleVisibilityAction();
|
||||||
|
this.showAllComponentsAction = new ShowAllComponentsAction();
|
||||||
|
|
||||||
OpenRocketClipboard.addClipboardListener(new ClipboardListener() {
|
OpenRocketClipboard.addClipboardListener(new ClipboardListener() {
|
||||||
@Override
|
@Override
|
||||||
@ -150,6 +152,7 @@ public class RocketActions {
|
|||||||
moveDownAction.clipboardChanged();
|
moveDownAction.clipboardChanged();
|
||||||
exportOBJAction.clipboardChanged();
|
exportOBJAction.clipboardChanged();
|
||||||
toggleVisibilityAction.clipboardChanged();
|
toggleVisibilityAction.clipboardChanged();
|
||||||
|
showAllComponentsAction.clipboardChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -207,6 +210,10 @@ public class RocketActions {
|
|||||||
return toggleVisibilityAction;
|
return toggleVisibilityAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Action getShowAllComponentsAction() {
|
||||||
|
return showAllComponentsAction;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tie an action to a JButton, without using the icon or text of the action for the button.
|
* Tie an action to a JButton, without using the icon or text of the action for the button.
|
||||||
*
|
*
|
||||||
@ -482,7 +489,26 @@ public class RocketActions {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all descendants of the specified component.
|
||||||
|
*
|
||||||
|
* @param component Component to query
|
||||||
|
* @return All descendants
|
||||||
|
* @apiNote Returns an empty set if the component does not have children.
|
||||||
|
*/
|
||||||
|
private Set<RocketComponent> getDescendants(RocketComponent component) {
|
||||||
|
Objects.requireNonNull(component);
|
||||||
|
|
||||||
|
var result = new LinkedHashSet<RocketComponent>();
|
||||||
|
var queue = new ArrayDeque<>(component.getChildren());
|
||||||
|
|
||||||
|
while (!queue.isEmpty()) {
|
||||||
|
var node = queue.pop();
|
||||||
|
result.add(node);
|
||||||
|
node.getChildren().stream().filter(c -> !result.contains(c)).forEach(queue::add);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/////// Action classes
|
/////// Action classes
|
||||||
@ -1343,26 +1369,24 @@ public class RocketActions {
|
|||||||
var allComponentsSelected = getDescendants(rocket).size() == components.size();
|
var allComponentsSelected = getDescendants(rocket).size() == components.size();
|
||||||
return rocketSelected || allComponentsSelected;
|
return rocketSelected || allComponentsSelected;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
private class ShowAllComponentsAction extends RocketAction {
|
||||||
* Returns all descendants of the specified component.
|
public ShowAllComponentsAction() {
|
||||||
*
|
super.putValue(NAME, trans.get("RocketActions.VisibilityAct.ShowAll"));
|
||||||
* @param component Component to query
|
super.putValue(SHORT_DESCRIPTION, trans.get("RocketActions.VisibilityAct.ttip.ShowAll"));
|
||||||
* @return All descendants
|
super.putValue(SMALL_ICON, GUIUtil.getUITheme().getVisibilityShowingIcon());
|
||||||
* @apiNote Returns an empty set if the component does not have children.
|
clipboardChanged();
|
||||||
*/
|
}
|
||||||
private Set<RocketComponent> getDescendants(RocketComponent component) {
|
|
||||||
Objects.requireNonNull(component);
|
|
||||||
|
|
||||||
var result = new LinkedHashSet<RocketComponent>();
|
@Override
|
||||||
var queue = new ArrayDeque<>(component.getChildren());
|
public void clipboardChanged() {
|
||||||
|
super.setEnabled(getDescendants(rocket).stream().anyMatch(c -> !c.isVisible()));
|
||||||
|
}
|
||||||
|
|
||||||
while (!queue.isEmpty()) {
|
@Override
|
||||||
var node = queue.pop();
|
public void actionPerformed(ActionEvent e) {
|
||||||
result.add(node);
|
getDescendants(rocket).forEach(descendant -> descendant.setVisible(true));
|
||||||
node.getChildren().stream().filter(c -> !result.contains(c)).forEach(queue::add);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -101,6 +101,7 @@ public class UITheme {
|
|||||||
Icon getCDOverrideSubcomponentIcon();
|
Icon getCDOverrideSubcomponentIcon();
|
||||||
|
|
||||||
Icon getVisibilityHiddenIcon();
|
Icon getVisibilityHiddenIcon();
|
||||||
|
Icon getVisibilityShowingIcon();
|
||||||
|
|
||||||
Border getBorder();
|
Border getBorder();
|
||||||
Border getMarginBorder();
|
Border getMarginBorder();
|
||||||
@ -437,6 +438,11 @@ public class UITheme {
|
|||||||
return Icons.COMPONENT_HIDDEN_LIGHT;
|
return Icons.COMPONENT_HIDDEN_LIGHT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Icon getVisibilityShowingIcon() {
|
||||||
|
return Icons.COMPONENT_SHOWING_LIGHT;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Border getBorder() {
|
public Border getBorder() {
|
||||||
return new FlatBorder();
|
return new FlatBorder();
|
||||||
@ -833,6 +839,11 @@ public class UITheme {
|
|||||||
return Icons.COMPONENT_HIDDEN_DARK;
|
return Icons.COMPONENT_HIDDEN_DARK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Icon getVisibilityShowingIcon() {
|
||||||
|
return Icons.COMPONENT_SHOWING_DARK;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Border getBorder() {
|
public Border getBorder() {
|
||||||
return new FlatBorder();
|
return new FlatBorder();
|
||||||
@ -1229,6 +1240,11 @@ public class UITheme {
|
|||||||
return Icons.COMPONENT_HIDDEN_DARK;
|
return Icons.COMPONENT_HIDDEN_DARK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Icon getVisibilityShowingIcon() {
|
||||||
|
return Icons.COMPONENT_SHOWING_DARK;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Border getBorder() {
|
public Border getBorder() {
|
||||||
return new FlatBorder();
|
return new FlatBorder();
|
||||||
@ -1644,6 +1660,11 @@ public class UITheme {
|
|||||||
return getCurrentTheme().getVisibilityHiddenIcon();
|
return getCurrentTheme().getVisibilityHiddenIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Icon getVisibilityShowingIcon() {
|
||||||
|
return getCurrentTheme().getVisibilityHiddenIcon();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Border getBorder() {
|
public Border getBorder() {
|
||||||
return getCurrentTheme().getBorder();
|
return getCurrentTheme().getBorder();
|
||||||
|
@ -120,6 +120,8 @@ public class Icons {
|
|||||||
public static final Icon COMPONENT_HIDDEN = loadImageIcon("pix/icons/component-hidden.png", "Component Hidden");
|
public static final Icon COMPONENT_HIDDEN = loadImageIcon("pix/icons/component-hidden.png", "Component Hidden");
|
||||||
public static final Icon COMPONENT_HIDDEN_DARK = loadImageIcon("pix/icons/component-hidden_dark.png", "Component Hidden");
|
public static final Icon COMPONENT_HIDDEN_DARK = loadImageIcon("pix/icons/component-hidden_dark.png", "Component Hidden");
|
||||||
public static final Icon COMPONENT_HIDDEN_LIGHT = loadImageIcon("pix/icons/component-hidden_light.png", "Component Hidden");
|
public static final Icon COMPONENT_HIDDEN_LIGHT = loadImageIcon("pix/icons/component-hidden_light.png", "Component Hidden");
|
||||||
|
public static final Icon COMPONENT_SHOWING_DARK = loadImageIcon("pix/icons/component-showing_dark.png", "Component Showing");
|
||||||
|
public static final Icon COMPONENT_SHOWING_LIGHT = loadImageIcon("pix/icons/component-showing_light.png", "Component Showing");
|
||||||
|
|
||||||
// MANUFACTURERS ICONS
|
// MANUFACTURERS ICONS
|
||||||
public static final Icon RASAERO = loadImageIcon("pix/icons/RASAero_16.png", "RASAero Icon");
|
public static final Icon RASAERO = loadImageIcon("pix/icons/RASAero_16.png", "RASAero Icon");
|
||||||
|
BIN
swing/src/main/resources/pix/icons/component-showing_dark.png
Normal file
BIN
swing/src/main/resources/pix/icons/component-showing_dark.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
BIN
swing/src/main/resources/pix/icons/component-showing_light.png
Normal file
BIN
swing/src/main/resources/pix/icons/component-showing_light.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 306 B |
Loading…
x
Reference in New Issue
Block a user