1919import com .microsoft .azure .toolkit .intellij .link .mysql .JdbcUrl ;
2020import com .microsoft .azure .toolkit .intellij .link .po .LinkPO ;
2121import com .microsoft .azure .toolkit .intellij .link .po .MySQLResourcePO ;
22+ import com .microsoft .azuretools .authmanage .AuthMethodManager ;
2223import com .microsoft .azuretools .core .mvp .model .mysql .MySQLMvpModel ;
2324import com .microsoft .intellij .AzureLinkStorage ;
2425import com .microsoft .intellij .AzureMySQLStorage ;
@@ -36,6 +37,10 @@ public class SpringDatasourceLineMarkerProvider implements LineMarkerProvider {
3637
3738 @ Override
3839 public LineMarkerInfo getLineMarkerInfo (@ NotNull PsiElement element ) {
40+ // Do not show azure line marker if not signed in
41+ if (!AuthMethodManager .getInstance ().isSignedIn ()) {
42+ return null ;
43+ }
3944 if (element instanceof PropertyImpl ) {
4045 PropertyImpl property = (PropertyImpl ) element ;
4146 String value = property .getValue ();
@@ -85,6 +90,12 @@ public class SpringDatasourceNavigationHandler implements GutterIconNavigationHa
8590
8691 @ Override
8792 public void navigate (MouseEvent mouseEvent , PsiElement psiElement ) {
93+ if (!AuthMethodManager .getInstance ().isSignedIn ()) {
94+ final String resourceName = ResourceId .fromString (resourceId ).name ();
95+ final String message = String .format ("Failed to connect Azure Database for MySQL (%s) , please sign in Azure first." , resourceName );
96+ DefaultLoader .getUIHelper ().showError (message , "Connect to Azure Datasource for MySQL" );
97+ return ;
98+ }
8899 ResourceId resourceIdObject = ResourceId .fromString (resourceId );
89100 Server server = MySQLMvpModel .findServer (resourceIdObject .subscriptionId (), resourceIdObject .resourceGroupName (), resourceIdObject .name ());
90101 if (Objects .nonNull (server )) {
0 commit comments