Clean up code
This commit is contained in:
parent
203d4e8b2a
commit
c69455545c
@ -167,7 +167,7 @@ public class BasicFrame extends JFrame {
|
|||||||
selectionModel.attachComponentTreeSelectionModel(componentSelectionModel);
|
selectionModel.attachComponentTreeSelectionModel(componentSelectionModel);
|
||||||
selectionModel.attachSimulationListSelectionModel(simulationSelectionModel);
|
selectionModel.attachSimulationListSelectionModel(simulationSelectionModel);
|
||||||
|
|
||||||
actions = new RocketActions(document, selectionModel, this);
|
actions = new RocketActions(document, selectionModel, this, simulationPanel);
|
||||||
|
|
||||||
// Populate the popup menu
|
// Populate the popup menu
|
||||||
popupMenu = new JPopupMenu();
|
popupMenu = new JPopupMenu();
|
||||||
@ -708,7 +708,7 @@ public class BasicFrame extends JFrame {
|
|||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
|
|
||||||
|
|
||||||
item = new JMenuItem(actions.getEditAction(simulationPanel));
|
item = new JMenuItem(actions.getEditAction());
|
||||||
menu.add(item);
|
menu.add(item);
|
||||||
|
|
||||||
item = new JMenuItem(actions.getCutAction());
|
item = new JMenuItem(actions.getCutAction());
|
||||||
|
@ -61,6 +61,7 @@ public class RocketActions {
|
|||||||
private final Rocket rocket;
|
private final Rocket rocket;
|
||||||
private final BasicFrame parentFrame;
|
private final BasicFrame parentFrame;
|
||||||
private final DocumentSelectionModel selectionModel;
|
private final DocumentSelectionModel selectionModel;
|
||||||
|
private final SimulationPanel simulationPanel;
|
||||||
|
|
||||||
|
|
||||||
private final RocketAction deleteComponentAction;
|
private final RocketAction deleteComponentAction;
|
||||||
@ -81,11 +82,12 @@ public class RocketActions {
|
|||||||
|
|
||||||
|
|
||||||
public RocketActions(OpenRocketDocument document, DocumentSelectionModel selectionModel,
|
public RocketActions(OpenRocketDocument document, DocumentSelectionModel selectionModel,
|
||||||
BasicFrame parentFrame) {
|
BasicFrame parentFrame, SimulationPanel simulationPanel) {
|
||||||
this.document = document;
|
this.document = document;
|
||||||
this.rocket = document.getRocket();
|
this.rocket = document.getRocket();
|
||||||
this.selectionModel = selectionModel;
|
this.selectionModel = selectionModel;
|
||||||
this.parentFrame = parentFrame;
|
this.parentFrame = parentFrame;
|
||||||
|
this.simulationPanel = simulationPanel;
|
||||||
|
|
||||||
// Add action also to updateActions()
|
// Add action also to updateActions()
|
||||||
this.deleteAction = new DeleteAction();
|
this.deleteAction = new DeleteAction();
|
||||||
@ -175,10 +177,6 @@ public class RocketActions {
|
|||||||
public Action getEditAction() {
|
public Action getEditAction() {
|
||||||
return editAction;
|
return editAction;
|
||||||
}
|
}
|
||||||
public Action getEditAction(SimulationPanel simulationPanel) {
|
|
||||||
((EditAction) editAction).setSimulationPanel(simulationPanel);
|
|
||||||
return editAction;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Action getEditActionNoIcon() {
|
public Action getEditActionNoIcon() {
|
||||||
return editActionNoIcon;
|
return editActionNoIcon;
|
||||||
@ -884,7 +882,6 @@ public class RocketActions {
|
|||||||
*/
|
*/
|
||||||
private class EditAction extends RocketAction {
|
private class EditAction extends RocketAction {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private SimulationPanel simulationPanel = null;
|
|
||||||
|
|
||||||
public EditAction() {
|
public EditAction() {
|
||||||
//// Edit
|
//// Edit
|
||||||
@ -897,10 +894,6 @@ public class RocketActions {
|
|||||||
clipboardChanged();
|
clipboardChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSimulationPanel(SimulationPanel simulationPanel) {
|
|
||||||
this.simulationPanel = simulationPanel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
List<RocketComponent> components = selectionModel.getSelectedComponents();
|
List<RocketComponent> components = selectionModel.getSelectedComponents();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user