Project project = ActionUtil.getProject(component);
return new SelectConnectionActionGroup(project);
}
public synchronized void update(AnActionEvent e) {
Presentation presentation = e.getPresentation();
String text = NAME;
Icon icon = null;
Project project = ActionUtil.getProject(e);
VirtualFile virtualFile = e.getData(PlatformDataKeys.VIRTUAL_FILE);
if (project != null && virtualFile != null) {
FileConnectionMappingManager connectionMappingManager = FileConnectionMappingManager.getInstance(project);
ConnectionHandler activeConnection = connectionMappingManager.getActiveConnection(virtualFile);
if (activeConnection != null) {
text = NamingUtil.enhanceUnderscoresForDisplay(activeConnection.getQualifiedName());
icon = activeConnection.getIcon();
}
boolean isConsole = virtualFile instanceof SQLConsoleFile;
presentation.setVisible(!isConsole);
if (virtualFile.isInLocalFileSystem()) {
DDLFileAttachmentManager fileAttachmentManager = DDLFileAttachmentManager.getInstance(project);
DBSchemaObject editableObject = fileAttachmentManager.getEditableObject(virtualFile);
if (editableObject != null) {
boolean isOpened = DatabaseFileSystem.getInstance().isFileOpened(editableObject);
presentation.setEnabled(!isOpened);
}
}
}
presentation.setText(text);
presentation.setIcon(icon);
}