ObjectsLookupSettings objectsLookupSettings = GlobalProjectSettings.getInstance(project).getNavigationSettings().getObjectsLookupSettings();
if (objectsLookupSettings.getPromptConnectionSelection().value()) {
ConnectionHandler singleConnectionHandler = null;
DefaultActionGroup actionGroup = new DefaultActionGroup();
ConnectionManager connectionManager = ConnectionManager.getInstance(project);
List<ConnectionBundle> connectionBundles = connectionManager.getConnectionBundles();
for (ConnectionBundle connectionBundle : connectionBundles) {
if (connectionBundle.getConnectionHandlers().size() > 0) {
if ((actionGroup.getChildrenCount() > 1)) {
actionGroup.addSeparator();
}
for (ConnectionHandler connectionHandler : connectionBundle.getConnectionHandlers()) {
SelectConnectionAction connectionAction = new SelectConnectionAction(connectionHandler);
actionGroup.add(connectionAction);
singleConnectionHandler = connectionHandler;
}
}
}
if (actionGroup.getChildrenCount() > 1) {
removeActionLock();
ListPopup popupBuilder = JBPopupFactory.getInstance().createActionGroupPopup(
"Select connection for lookup",
actionGroup,
event.getDataContext(),
//JBPopupFactory.ActionSelectionAid.SPEEDSEARCH,
true,
true,
true,
null,
actionGroup.getChildrenCount(),
new Condition<AnAction>() {
public boolean value(AnAction action) {
SelectConnectionAction selectConnectionAction = (SelectConnectionAction) action;
return latestSelection == selectConnectionAction.connectionHandler;
}
});
popupBuilder.showCenteredInCurrentWindow(project);
} else {
showLookupPopup(event, project, singleConnectionHandler, null);
}
} else {
ConnectionManager connectionManager = ConnectionManager.getInstance(project);
ConnectionHandler connectionHandler = connectionManager.getActiveConnection(project);
showLookupPopup(event, project, connectionHandler, null);
}
}
}