JMenuItem jMenuItem = null;
if (commands != null) {
for (DataModelCommand m = commands.firstItem(); m != null; m = commands.nextItem()) {
if (m.getCommandName().equals(menuItem)) {
CommandViewer viewer = null;
try {
viewer = (CommandViewer) factory.createDefaultViewer(m);
jMenuItem = viewer.createJMenuItem();
} catch (Exception e) {
e.printStackTrace(); //TODO
}
}
}