Files
TpMazeJava/src/ui/BoxTypeEditionMenu.java
T
regar42 024a4f70c3 Fix add column/line and spinners, cleanup Maintest
* Remove legacy test code in MainTest

maze:
* Add methods to add/del lines and columns
* Add various calls to matrixDeepCopy, allowing to overwrite only a part
  of a matrix

model:
* Better delegation to Maze : let Maze handle column/line
  adds/deletions

ui:
* Add buttons to context menu to add/remove lines and columns
* Add buttons to Maze Menu to delete lines and columns
* Fix the spinners, it used to call a new instance of itself, which made
  impossible to simple get the values from the spinners
2017-12-31 20:25:16 +01:00

35 lines
1.1 KiB
Java

package ui;
import javax.swing.JPopupMenu;
import javax.swing.JMenuItem;
import maze.Box;
public class BoxTypeEditionMenu extends JPopupMenu {
JMenuItem setWBox;
JMenuItem setEBox;
JMenuItem setDBox;
JMenuItem setABox;
JMenuItem addRow;
JMenuItem addLine;
JMenuItem delRow;
JMenuItem delLine;
public BoxTypeEditionMenu(MazeApp mazeApp, int boxLine, int boxRow) {
add(setEBox = new SetEBoxMenuItem(mazeApp, boxLine, boxRow));
add(setWBox = new SetWBoxMenuItem(mazeApp, boxLine, boxRow));
add(setDBox = new SetDBoxMenuItem(mazeApp, boxLine, boxRow));
add(setABox = new SetABoxMenuItem(mazeApp, boxLine, boxRow));
Box box = (Box) mazeApp.getMazeAppModel().getMaze().getMaze()[boxLine][boxRow];
setEBox.setEnabled((box.isWalkable() && (box.isDeparture() ||
box.isArrival())) || ! box.isWalkable());
setWBox.setEnabled(box.isWalkable());
setDBox.setEnabled(! box.isDeparture());
setABox.setEnabled(! box.isArrival());
add(addRow = new AddRowMenuItem(mazeApp, boxRow));
add(addLine = new AddLineMenuItem(mazeApp, boxLine));
add(delRow = new DelRowMenuItem(mazeApp, boxRow));
add(delLine = new DelLineMenuItem(mazeApp, boxLine));
}
}