public void actionPerformed(ActionEvent e) {
String oC = selectedPlane.getActiveController();
String nC = "???";
selectedPlane.setActiveController(nC);
IPlaneUpdateObject tmp = new PlaneUpdateObject(selectedPlane);
atmcModel.handlePlaneUpdate(selectedPlane, oC, nC);
atmcModel.sendObject(tmp);
flightListModel.fireTableDataChanged();
}
});
this.add(tmp);
for (int i = 0; i < functions.length; i++) {
if (!functions[i].equals("Pilot") && !functions[i].equals("-no function-")) {
final int k = i;
tmp = new JMenuItem(functions[i]);
tmp.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String oC = selectedPlane.getActiveController();
String nC = functions[k];
selectedPlane.setActiveController(nC);
IPlaneUpdateObject tmp = new PlaneUpdateObject(selectedPlane);
atmcModel.handlePlaneUpdate(selectedPlane, oC, nC);
atmcModel.sendObject(tmp);
flightListModel.fireTableDataChanged();
}
});
this.add(tmp);
}
}
} else {
JMenuItem tmp = new JMenuItem("Myself");
tmp.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String oC = selectedPlane.getActiveController();
String nC = atmcModel.getFunction();
selectedPlane.setActiveController(nC);
IPlaneUpdateObject tmp = new PlaneUpdateObject(selectedPlane);
atmcModel.handlePlaneUpdate(selectedPlane, oC, nC);
atmcModel.sendObject(tmp);
flightListModel.fireTableDataChanged();
}
});