CellPosition[] positions = CellPosition.values();
ActionManager actionManager = ActionManager.getInstance();
for (int i = 0; i < positions.length; i++) {
CellPosition cellPosition = positions[i];
String cellName = cellPosition.name();
JMenuItem add_menuItem = new JMenuItem(cellName);
Action addSampleAction = new AddSampleAction(cellPosition, treePath);
actionManager.addAction(addSampleAction);
add_menuItem.setAction(addSampleAction);
addMenu.add(add_menuItem);
}
popupMenu.add(addMenu);
// ----------------------------------------------------------------------
// ---------------------------------
//
// Initiate the deleteMenu for delete samples.
//
// ----------------------------------------------------------------------
// ---------------------------------
JMenu deleteMenu = new JMenu("Delete Samples");
deleteMenu.setIcon(icons.getIcon("samples.remove"));
for (int i = 0; i < positions.length; i++) {
CellPosition cellPosition = positions[i];
String cellName = cellPosition.name();
JMenuItem del_menuItem = new JMenuItem(cellName);
Action deleteSampleAction = new DeleteSampleAction(cellPosition, treePath);
actionManager.addAction(deleteSampleAction);
del_menuItem.setAction(deleteSampleAction);
deleteMenu.add(del_menuItem);
}
popupMenu.add(deleteMenu);
// ----------------------------------------------------------------------
// ---------------------------------
//
// Initiate the moveMenu for change the position of the sample.
//
// ----------------------------------------------------------------------
// ---------------------------------
JMenu moveMenu = new JMenu("Move Sample");
moveMenu.setIcon(icons.getIcon("samples.move"));
for (int i = 0; i < positions.length; i++) {
CellPosition cellPosition = positions[i];
String cellName = cellPosition.name();
JMenuItem mov_menuItem = new JMenuItem(cellName);
Action moveSampleAction = new MoveSampleAction(cellPosition, treePath);
actionManager.addAction(moveSampleAction);
mov_menuItem.setAction(moveSampleAction);
moveMenu.add(mov_menuItem);