Implement edit action for simulations
This commit is contained in:
parent
5b90986a8e
commit
203d4e8b2a
@ -708,7 +708,7 @@ public class BasicFrame extends JFrame {
|
|||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
|
|
||||||
|
|
||||||
item = new JMenuItem(actions.getEditAction());
|
item = new JMenuItem(actions.getEditAction(simulationPanel));
|
||||||
menu.add(item);
|
menu.add(item);
|
||||||
|
|
||||||
item = new JMenuItem(actions.getCutAction());
|
item = new JMenuItem(actions.getCutAction());
|
||||||
|
@ -175,6 +175,10 @@ 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;
|
||||||
@ -880,6 +884,7 @@ 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
|
||||||
@ -892,28 +897,35 @@ 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();
|
||||||
if (!checkAllClassesEqual(components))
|
Simulation[] sims = selectionModel.getSelectedSimulations();
|
||||||
return;
|
|
||||||
|
|
||||||
// Do nothing if the config dialog is already visible
|
if ((components != null) && (components.size() > 0) && checkAllClassesEqual(components)) {
|
||||||
if (ComponentConfigDialog.isDialogVisible())
|
// Do nothing if the config dialog is already visible
|
||||||
return;
|
if (ComponentConfigDialog.isDialogVisible())
|
||||||
|
return;
|
||||||
|
|
||||||
List<RocketComponent> listeners = null;
|
List<RocketComponent> listeners = null;
|
||||||
if (components.size() > 1) {
|
if (components.size() > 1) {
|
||||||
listeners = components.subList(1, components.size());
|
listeners = components.subList(1, components.size());
|
||||||
|
}
|
||||||
|
ComponentConfigDialog.showDialog(parentFrame, document, components.get(0), listeners);
|
||||||
|
} else if (sims != null && sims.length > 0 && (simulationPanel != null)) {
|
||||||
|
simulationPanel.editSimulationAction();
|
||||||
}
|
}
|
||||||
ComponentConfigDialog.showDialog(parentFrame, document, components.get(0), listeners);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clipboardChanged() {
|
public void clipboardChanged() {
|
||||||
List<RocketComponent> components = selectionModel.getSelectedComponents();
|
List<RocketComponent> components = selectionModel.getSelectedComponents();
|
||||||
|
|
||||||
this.setEnabled(checkAllClassesEqual(components));
|
this.setEnabled(checkAllClassesEqual(components) || isSimulationSelected());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -604,7 +604,7 @@ public class SimulationPanel extends JPanel {
|
|||||||
fireMaintainSelection();
|
fireMaintainSelection();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void editSimulationAction() {
|
public void editSimulationAction() {
|
||||||
Simulation[] sims = getSelectedSimulations();
|
Simulation[] sims = getSelectedSimulations();
|
||||||
if (sims == null) return;
|
if (sims == null) return;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user