JMenu addMenu = new JMenu("Add Sample");
addMenu.setIcon(icons.getIcon("samples.add"));
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);
}
popupMenu.add(moveMenu);
popupMenu.addSeparator();
// ----------------------------------------------------------------------
// ---------------------------------
//
// Initiate the getPositionMenu to find the sample.
//
// ----------------------------------------------------------------------
// ---------------------------------
Icon getPositionIcon = icons.getIcon("samples.getPosition");
Action getPositionAction = new GetPositionAction("Get Position",
getPositionIcon, treePath, treeTableModel);
actionManager.addAction(getPositionAction);
popupMenu.add(getPositionAction);
// ----------------------------------------------------------------------
// ---------------------------------
//
// Initiate the cleanLineMenu to clean the sample.
//
// ----------------------------------------------------------------------
// ---------------------------------
Icon cleanLineIcon = icons.getIcon("samples.clearLine");
Action cleanLineAction = new CleanLineAction("Clean Line",
cleanLineIcon, treePath, treeTableModel);
actionManager.addAction(cleanLineAction);
popupMenu.add(cleanLineAction);
return popupMenu;
}