Search in sources :

Example 1 with SUCCESSFUL

use of org.stepik.core.metrics.MetricsStatus.SUCCESSFUL in project intellij-plugins by StepicOrg.

the class StepikAuthManager method setState.

private static void setState(@NotNull StepikAuthState value) {
    StepikAuthState oldState = state;
    state = value;
    if (state == NOT_AUTH) {
        stepikApiClient.setTokenInfo(null);
        user = null;
        long userId = getLastUser();
        setTokenInfo(userId, new TokenInfo());
        setLastUser(0);
    }
    if (oldState != state) {
        if (state == AUTH) {
            Metrics.authenticate(SUCCESSFUL);
        }
        executor.execute(() -> listeners.forEach(listener -> listener.stateChanged(oldState, state)));
    }
}
Also used : AUTH(org.stepik.core.stepik.StepikAuthState.AUTH) Application(com.intellij.openapi.application.Application) CredentialAttributes(com.intellij.credentialStore.CredentialAttributes) PLUGIN_ID(org.stepik.core.utils.PluginUtils.PLUGIN_ID) ModalityState(com.intellij.openapi.application.ModalityState) StepikClientException(org.stepik.api.exceptions.StepikClientException) CompletableFuture(java.util.concurrent.CompletableFuture) ProductGroup(org.stepik.core.utils.ProductGroup) PluginUtils.getCurrentProduct(org.stepik.core.utils.PluginUtils.getCurrentProduct) User(org.stepik.api.objects.users.User) ArrayList(java.util.ArrayList) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException) Credentials(com.intellij.credentialStore.Credentials) Metrics(org.stepik.core.metrics.Metrics) Map(java.util.Map) Logger(com.intellij.openapi.diagnostic.Logger) PluginUtils.getVersion(org.stepik.core.utils.PluginUtils.getVersion) SUCCESSFUL(org.stepik.core.metrics.MetricsStatus.SUCCESSFUL) HttpConfigurable(com.intellij.util.net.HttpConfigurable) ExecutorService(java.util.concurrent.ExecutorService) PropertiesComponent(com.intellij.ide.util.PropertiesComponent) SHOW_DIALOG(org.stepik.core.stepik.StepikAuthState.SHOW_DIALOG) PluginUtils.getCurrentProductVersion(org.stepik.core.utils.PluginUtils.getCurrentProductVersion) NOT_AUTH(org.stepik.core.stepik.StepikAuthState.NOT_AUTH) Executors(java.util.concurrent.Executors) UNKNOWN(org.stepik.core.stepik.StepikAuthState.UNKNOWN) InvocationTargetException(java.lang.reflect.InvocationTargetException) PluginUtils(org.stepik.core.utils.PluginUtils) AuthDialog(org.stepik.plugin.auth.ui.AuthDialog) HttpTransportClient(org.stepik.api.client.HttpTransportClient) TokenInfo(org.stepik.api.objects.auth.TokenInfo) List(java.util.List) PasswordSafe(com.intellij.ide.passwordSafe.PasswordSafe) ApplicationManager(com.intellij.openapi.application.ApplicationManager) StepikProjectManager(org.stepik.core.StepikProjectManager) StepikApiClient(org.stepik.api.client.StepikApiClient) NotNull(org.jetbrains.annotations.NotNull) javax.swing(javax.swing) TokenInfo(org.stepik.api.objects.auth.TokenInfo)

Aggregations

CredentialAttributes (com.intellij.credentialStore.CredentialAttributes)1 Credentials (com.intellij.credentialStore.Credentials)1 PasswordSafe (com.intellij.ide.passwordSafe.PasswordSafe)1 PropertiesComponent (com.intellij.ide.util.PropertiesComponent)1 Application (com.intellij.openapi.application.Application)1 ApplicationManager (com.intellij.openapi.application.ApplicationManager)1 ModalityState (com.intellij.openapi.application.ModalityState)1 Logger (com.intellij.openapi.diagnostic.Logger)1 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)1 HttpConfigurable (com.intellij.util.net.HttpConfigurable)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 ExecutorService (java.util.concurrent.ExecutorService)1 Executors (java.util.concurrent.Executors)1 javax.swing (javax.swing)1 NotNull (org.jetbrains.annotations.NotNull)1 HttpTransportClient (org.stepik.api.client.HttpTransportClient)1