menu.addSeparator();
}
// Add module change items
AdvancedCALEditor calEditor = gemCodePanel.getCALEditorPane();
if (isCodeQualified) {
if (locallyResolved) {
// We can switch local qualifications to arguments
if (isQualificationFormChangeAllowed(type)) {
JMenuItem toArgumentItem = new ToArgumentMenuItem(unqualifiedName, moduleName, false);
toArgumentItem.setToolTipText(GemCutter.getResourceString("CGE_To_Argument"));
menu.add(toArgumentItem);
}
// Or keep in the current form
{
JCheckBoxMenuItem newItem = new ModuleChangeMenuItem(unqualifiedName, moduleName, type, true);
newItem.setToolTipText(calEditor.getMetadataToolTipText(unqualifiedName, moduleName, type, perspective.getWorkingModuleTypeInfo()));
menu.add(newItem);
}
} else {
// Cannot change form; just display grayed current form
JCheckBoxMenuItem newItem = new ModuleChangeMenuItem(unqualifiedName, moduleName, type, true);
newItem.setToolTipText(calEditor.getMetadataToolTipText(unqualifiedName, moduleName, type, perspective.getWorkingModuleTypeInfo()));
newItem.setEnabled(false);
menu.add(newItem);
}
} else {
// If this is an unqualified symbol
// Add to-argument change item
if (isQualificationFormChangeAllowed(type)) {
JMenuItem toArgumentItem = new ToArgumentMenuItem(unqualifiedName, moduleName, false);
toArgumentItem.setToolTipText(GemCutter.getResourceString("CGE_To_Argument"));
menu.add(toArgumentItem);
}
// Add module change items
List<ModuleName> candidateModules = CodeAnalyser.getModulesContainingIdentifier(unqualifiedName, type,
perspective.getWorkingModuleTypeInfo());
for (final ModuleName newModule : candidateModules) {
JCheckBoxMenuItem newItem = new ModuleChangeMenuItem(
unqualifiedName, newModule, type, (newModule
.equals(moduleName)));
newItem.setToolTipText(calEditor.getMetadataToolTipText(
unqualifiedName, newModule, type, perspective
.getWorkingModuleTypeInfo()));
menu.add(newItem);
}
}