Search in sources :

Example 1 with StringUtils.firstNonBlank

use of org.apache.commons.lang3.StringUtils.firstNonBlank in project azure-tools-for-java by Microsoft.

the class AzurePlugin method runActivity.

@Override
public void runActivity(@NotNull Project project) {
    // read legacy settings from old data.xml
    final String installationId = "wangmi-azure-intellij-plugin-base";
    final String pluginVersion = "0.0.1-SNAPSHOT";
    // check non-empty for valid data.xml
    if (StringUtils.isNoneBlank(installationId, pluginVersion)) {
        final IntellijStore.AzureConfigurationData config = IntellijStore.getInstance().getState();
        IntellijStore.getInstance().loadState(config);
    }
    final IntellijStore.AzureConfigurationData config = IntellijStore.getInstance().getState();
    String installationID = InstallationIdUtils.getHashMac();
    if (StringUtils.isBlank(installationID)) {
        installationID = StringUtils.firstNonBlank(InstallationIdUtils.getHashMac(), InstallationIdUtils.hash(PermanentInstallationID.get()));
    }
    final String userAgent = String.format(USER_AGENT, PLUGIN_VERSION, installationID);
    Azure.az().config().setLogLevel("NONE");
    Azure.az().config().setUserAgent(userAgent);
    final AnAction action = ActionManager.getInstance().getAction(WhatsNewAction.ID);
    final DataContext context = dataId -> CommonDataKeys.PROJECT.getName().equals(dataId) ? project : null;
    AzureTaskManager.getInstance().runLater(() -> ActionUtil.invokeAction(action, context, "AzurePluginStartupActivity", null, null));
}
Also used : Azure(com.microsoft.azure.toolkit.lib.Azure) WhatsNewAction(com.microsoft.azure.toolkit.intellij.common.action.WhatsNewAction) DataContext(com.intellij.openapi.actionSystem.DataContext) PermanentInstallationID(com.intellij.openapi.application.PermanentInstallationID) ActionUtil(com.intellij.openapi.actionSystem.ex.ActionUtil) StartupActivity(com.intellij.openapi.startup.StartupActivity) PluginManagerCore(com.intellij.ide.plugins.PluginManagerCore) PlatformUtils(com.intellij.util.PlatformUtils) AnAction(com.intellij.openapi.actionSystem.AnAction) StringUtils(org.apache.commons.lang3.StringUtils) SystemInfo(com.intellij.openapi.util.SystemInfo) IntellijStore(com.microsoft.azure.toolkit.intellij.common.settings.IntellijStore) ActionManager(com.intellij.openapi.actionSystem.ActionManager) InstallationIdUtils(com.microsoft.azure.toolkit.lib.common.utils.InstallationIdUtils) Objects(java.util.Objects) PluginStateListener(com.intellij.ide.plugins.PluginStateListener) EventListenerList(javax.swing.event.EventListenerList) Project(com.intellij.openapi.project.Project) CommonDataKeys(com.intellij.openapi.actionSystem.CommonDataKeys) Logger(com.intellij.openapi.diagnostic.Logger) NotNull(org.jetbrains.annotations.NotNull) PluginId(com.intellij.openapi.extensions.PluginId) AzureTaskManager(com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager) DataContext(com.intellij.openapi.actionSystem.DataContext) IntellijStore(com.microsoft.azure.toolkit.intellij.common.settings.IntellijStore) AnAction(com.intellij.openapi.actionSystem.AnAction)

Aggregations

PluginManagerCore (com.intellij.ide.plugins.PluginManagerCore)1 PluginStateListener (com.intellij.ide.plugins.PluginStateListener)1 ActionManager (com.intellij.openapi.actionSystem.ActionManager)1 AnAction (com.intellij.openapi.actionSystem.AnAction)1 CommonDataKeys (com.intellij.openapi.actionSystem.CommonDataKeys)1 DataContext (com.intellij.openapi.actionSystem.DataContext)1 ActionUtil (com.intellij.openapi.actionSystem.ex.ActionUtil)1 PermanentInstallationID (com.intellij.openapi.application.PermanentInstallationID)1 Logger (com.intellij.openapi.diagnostic.Logger)1 PluginId (com.intellij.openapi.extensions.PluginId)1 Project (com.intellij.openapi.project.Project)1 StartupActivity (com.intellij.openapi.startup.StartupActivity)1 SystemInfo (com.intellij.openapi.util.SystemInfo)1 PlatformUtils (com.intellij.util.PlatformUtils)1 WhatsNewAction (com.microsoft.azure.toolkit.intellij.common.action.WhatsNewAction)1 IntellijStore (com.microsoft.azure.toolkit.intellij.common.settings.IntellijStore)1 Azure (com.microsoft.azure.toolkit.lib.Azure)1 AzureTaskManager (com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager)1 InstallationIdUtils (com.microsoft.azure.toolkit.lib.common.utils.InstallationIdUtils)1 Objects (java.util.Objects)1