return factory.menu;
}
public void menuItemState(final XJMenuItem item) {
GrammarWindowTab tab = window.getSelectedTab();
switch(item.getTag()) {
case XJMainMenuBar.MI_UNDO:
case XJMainMenuBar.MI_REDO:
if(isDebuggerRunning()) {
// FIX AW-79
// Note: that's weird, but I have to invoke this later otherwise the menu is not disabled
SwingUtilities.invokeLater(new Runnable() {
public void run() {
item.setEnabled(false);
}
});
}
break;
case XJMainMenuBar.MI_CUT:
case XJMainMenuBar.MI_PASTE:
item.setEnabled(window.isFileWritable());
break;
case MI_RENAME:
case MI_REPLACE_LITERAL_WITH_TOKEN_LABEL:
case MI_LITERAL_TO_SINGLEQUOTE:
case MI_LITERAL_TO_DOUBLEQUOTE:
case MI_LITERAL_TO_CSTYLEQUOTE:
case MI_REMOVE_LEFT_RECURSION:
case MI_REMOVE_ALL_LEFT_RECURSION:
case MI_EXTRACT_RULE:
case MI_INLINE_RULE:
case MI_GROUP_RULE:
case MI_UNGROUP_RULE:
case MI_EXPAND_COLLAPSE_RULE:
case MI_EXPAND_COLLAPSE_ACTION:
case MI_CHECK_GRAMMAR:
case MI_FIND:
case MI_RUN_INTERPRETER:
item.setEnabled(!isDebuggerRunning());
break;
case MI_DEBUG_AGAIN:
item.setEnabled(!isDebuggerRunning() && debugMenu.canDebugAgain());
break;
case MI_EDIT_TEST_RIG:
item.setTitle(getEditTestRigTitle());
boolean enabled = (XJApplication.shared().getActiveWindow() != null) &&
(XJApplication.shared().getActiveWindow().getDocument() != null) &&
XJApplication.shared().getActiveWindow().getDocument().getDocumentName() != null;
item.setEnabled(!isDebuggerRunning() && enabled);
break;
case MI_RUN:
case MI_DEBUG:
case MI_DEBUG_REMOTE:
item.setEnabled(!isDebuggerRunning());
break;
case MI_GOTO_BACK:
item.setEnabled(window.goToHistory.canGoBack());
break;
case MI_GOTO_FORWARD:
item.setEnabled(window.goToHistory.canGoForward());
break;
case MI_EXPORT_AS_IMAGE:
item.setEnabled(tab != null && tab.canExportToBitmap());
break;
case MI_EXPORT_AS_EPS:
item.setEnabled(tab != null && tab.canExportToEPS());
break;
case MI_EXPORT_AS_DOT:
item.setEnabled(tab != null && tab.canExportToDOT());
break;
case MI_DEBUG_SHOW_INPUT_TOKENS:
item.setTitle(debugMenu.isInputTokenVisible()?
resourceBundle.getString("menu.item.hideInputTokens") : resourceBundle.getString("menu.item.showInputTokens"));