Search in sources :

Example 1 with ToggleOfflineModeHyperlink

use of com.android.tools.idea.gradle.project.sync.hyperlink.ToggleOfflineModeHyperlink in project android by JetBrains.

the class CachedDependencyNotFoundErrorHandlerTest method testHandleError.

public void testHandleError() throws Exception {
    GradleSettings settings = GradleSettings.getInstance(getProject());
    // Set "offline mode" on to force the IDE to show quick-fix.
    settings.setOfflineWork(true);
    String expectedNotificationMessage = "No cached version of dependency, available for offline mode.";
    String error = expectedNotificationMessage + "\nExtra error message.";
    registerSyncErrorToSimulate(error);
    loadProjectAndExpectSyncError(SIMPLE_APPLICATION);
    SyncMessagesStub.NotificationUpdate notificationUpdate = mySyncMessagesStub.getNotificationUpdate();
    assertNotNull(notificationUpdate);
    assertThat(notificationUpdate.getText()).contains(expectedNotificationMessage);
    List<NotificationHyperlink> quickFixes = notificationUpdate.getFixes();
    assertThat(quickFixes).hasSize(1);
    // Verify hyperlinks are correct.
    NotificationHyperlink quickFix = quickFixes.get(0);
    assertThat(quickFix).isInstanceOf(ToggleOfflineModeHyperlink.class);
    ToggleOfflineModeHyperlink toggleOfflineModeQuickFix = (ToggleOfflineModeHyperlink) quickFix;
    assertFalse(toggleOfflineModeQuickFix.isEnableOfflineMode());
}
Also used : GradleSettings(org.jetbrains.plugins.gradle.settings.GradleSettings) SyncMessagesStub(com.android.tools.idea.gradle.project.sync.messages.SyncMessagesStub) ToggleOfflineModeHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.ToggleOfflineModeHyperlink) NotificationHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink)

Example 2 with ToggleOfflineModeHyperlink

use of com.android.tools.idea.gradle.project.sync.hyperlink.ToggleOfflineModeHyperlink in project android by JetBrains.

the class MissingDependencyErrorHandler method handleMissingDependency.

private static void handleMissingDependency(@NotNull NotificationData notification, @NotNull Project project, @NotNull String msg, @NotNull String dependency, @NotNull List<NotificationHyperlink> additionalHyperlinks) {
    List<NotificationHyperlink> hyperlinks = new ArrayList<>(additionalHyperlinks);
    ToggleOfflineModeHyperlink disableOfflineMode = ToggleOfflineModeHyperlink.disableOfflineMode(project);
    if (disableOfflineMode != null) {
        hyperlinks.add(0, disableOfflineMode);
    }
    hyperlinks.add(new SearchInBuildFilesHyperlink(dependency));
    SyncMessages.getInstance(project).updateNotification(notification, msg, hyperlinks);
}
Also used : ArrayList(java.util.ArrayList) ToggleOfflineModeHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.ToggleOfflineModeHyperlink) SearchInBuildFilesHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.SearchInBuildFilesHyperlink) NotificationHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink)

Aggregations

NotificationHyperlink (com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink)2 ToggleOfflineModeHyperlink (com.android.tools.idea.gradle.project.sync.hyperlink.ToggleOfflineModeHyperlink)2 SearchInBuildFilesHyperlink (com.android.tools.idea.gradle.project.sync.hyperlink.SearchInBuildFilesHyperlink)1 SyncMessagesStub (com.android.tools.idea.gradle.project.sync.messages.SyncMessagesStub)1 ArrayList (java.util.ArrayList)1 GradleSettings (org.jetbrains.plugins.gradle.settings.GradleSettings)1