boolean overReference = window.getCurrentReference() != null;
boolean overToken = window.getCurrentToken() != null;
boolean overSelection = window.getTextPane().getSelectionStart() != window.getTextPane().getSelectionEnd();
ContextualStringTemplateMenuFactory factory = new ContextualStringTemplateMenuFactory(this);
factory.addItem(MI_GOTO_RULE);
if(overReference)
factory.addItem(MI_GOTO_DECLARATION);
factory.addSeparator();
if(overToken)