Java Code Examples for com.intellij.ui.EditorNotificationPanel#icon()

The following examples show how to use com.intellij.ui.EditorNotificationPanel#icon() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IgnoredEditingNotificationProvider.java    From idea-gitignore with MIT License 6 votes vote down vote up
/**
 * Creates notification panel for given file and checks if is allowed to show the notification.
 *
 * @param file       current file
 * @param fileEditor current file editor
 * @return created notification panel
 */
@Nullable
@Override
public EditorNotificationPanel createNotificationPanel(@NotNull final VirtualFile file,
                                                       @NotNull FileEditor fileEditor, @NotNull Project project) {
    if (!settings.isNotifyIgnoredEditing() || Properties.isDismissedIgnoredEditingNotification(project, file)
            || !changeListManager.isIgnoredFile(file) && !manager.isFileIgnored(file)) {
        return null;
    }

    final EditorNotificationPanel panel = new EditorNotificationPanel();

    panel.setText(IgnoreBundle.message("daemon.ignoredEditing"));
    panel.createActionLabel(IgnoreBundle.message("daemon.ok"), () -> {
        Properties.setDismissedIgnoredEditingNotification(project, file);
        notifications.updateAllNotifications();
    });

    try { // ignore if older SDK does not support panel icon
        panel.icon(Icons.IGNORE);
    } catch (NoSuchMethodError ignored) {
    }

    return panel;
}
 
Example 2
Source File: SdkConfigurationNotificationProvider.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@SuppressWarnings("SameReturnValue")
private static EditorNotificationPanel createNoFlutterSdkPanel(Project project) {
  final EditorNotificationPanel panel = new EditorNotificationPanel();
  panel.icon(FlutterIcons.Flutter);
  panel.setText(FlutterBundle.message("flutter.no.sdk.warning"));
  panel.createActionLabel("Dismiss", () -> panel.setVisible(false));
  panel.createActionLabel("Open Flutter settings", () -> FlutterUtils.openFlutterSettings(project));
  return panel;
}
 
Example 3
Source File: SdkConfigurationNotificationProvider.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private EditorNotificationPanel createOutOfDateFlutterSdkPanel(@NotNull FlutterSdk sdk) {
  final FlutterUIConfig settings = FlutterUIConfig.getInstance();
  if (settings.shouldIgnoreOutOfDateFlutterSdks()) return null;

  final EditorNotificationPanel panel = new EditorNotificationPanel();
  panel.icon(FlutterIcons.Flutter);
  panel.setText(FlutterBundle.message("flutter.old.sdk.warning"));
  panel.createActionLabel("Dismiss", () -> {
    settings.setIgnoreOutOfDateFlutterSdks();
    panel.setVisible(false);
  });

  return panel;
}
 
Example 4
Source File: SdkConfigurationNotificationProvider.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@SuppressWarnings("SameReturnValue")
private static EditorNotificationPanel createNoFlutterSdkPanel(Project project) {
  final EditorNotificationPanel panel = new EditorNotificationPanel();
  panel.icon(FlutterIcons.Flutter);
  panel.setText(FlutterBundle.message("flutter.no.sdk.warning"));
  panel.createActionLabel("Dismiss", () -> panel.setVisible(false));
  panel.createActionLabel("Open Flutter settings", () -> FlutterUtils.openFlutterSettings(project));
  return panel;
}
 
Example 5
Source File: SdkConfigurationNotificationProvider.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private EditorNotificationPanel createOutOfDateFlutterSdkPanel(@NotNull FlutterSdk sdk) {
  final FlutterUIConfig settings = FlutterUIConfig.getInstance();
  if (settings.shouldIgnoreOutOfDateFlutterSdks()) return null;

  final EditorNotificationPanel panel = new EditorNotificationPanel();
  panel.icon(FlutterIcons.Flutter);
  panel.setText(FlutterBundle.message("flutter.old.sdk.warning"));
  panel.createActionLabel("Dismiss", () -> {
    settings.setIgnoreOutOfDateFlutterSdks();
    panel.setVisible(false);
  });

  return panel;
}
 
Example 6
Source File: AddUnversionedFilesNotificationProvider.java    From idea-gitignore with MIT License 5 votes vote down vote up
/**
 * Creates notification panel.
 *
 * @param project current project
 * @return notification panel
 */
private EditorNotificationPanel createPanel(@NotNull final Project project) {
    final EditorNotificationPanel panel = new EditorNotificationPanel();
    final IgnoreFileType fileType = GitFileType.INSTANCE;
    panel.setText(IgnoreBundle.message("daemon.addUnversionedFiles"));
    panel.createActionLabel(IgnoreBundle.message("daemon.addUnversionedFiles.create"), () -> {
        final VirtualFile projectDir = Utils.guessProjectDir(project);
        if (projectDir == null) {
            return;
        }
        final VirtualFile virtualFile = projectDir.findChild(GitLanguage.INSTANCE.getFilename());
        final PsiFile file = virtualFile != null ? PsiManager.getInstance(project).findFile(virtualFile) : null;
        if (file != null) {
            final String content = StringUtil.join(unignoredFiles, Constants.NEWLINE);

            try {
                new AppendFileCommandAction(project, file, content, true, false)
                        .execute();
            } catch (Throwable throwable) {
                throwable.printStackTrace();
            }
            handledMap.put(virtualFile, true);
            notifications.updateAllNotifications();
        }
    });
    panel.createActionLabel(IgnoreBundle.message("daemon.cancel"), () -> {
        Properties.setAddUnversionedFiles(project);
        notifications.updateAllNotifications();
    });

    try { // ignore if older SDK does not support panel icon
        Icon icon = fileType.getIcon();
        if (icon != null) {
            panel.icon(icon);
        }
    } catch (NoSuchMethodError ignored) {
    }

    return panel;
}
 
Example 7
Source File: MissingGitignoreNotificationProvider.java    From idea-gitignore with MIT License 5 votes vote down vote up
/**
 * Creates notification panel.
 *
 * @param project    current project
 * @param moduleRoot module root
 * @return notification panel
 */
private EditorNotificationPanel createPanel(@NotNull final Project project, @NotNull VirtualFile moduleRoot) {
    final EditorNotificationPanel panel = new EditorNotificationPanel();
    final IgnoreFileType fileType = GitFileType.INSTANCE;
    panel.setText(IgnoreBundle.message("daemon.missingGitignore"));
    panel.createActionLabel(IgnoreBundle.message("daemon.missingGitignore.create"), () -> {
        PsiDirectory directory = PsiManager.getInstance(project).findDirectory(moduleRoot);
        if (directory != null) {
            try {
                PsiFile file = new CreateFileCommandAction(project, directory, fileType).execute();
                FileEditorManager.getInstance(project).openFile(file.getVirtualFile(), true);
                new GeneratorDialog(project, file).show();
            } catch (Throwable throwable) {
                throwable.printStackTrace();
            }
        }
    });
    panel.createActionLabel(IgnoreBundle.message("daemon.cancel"), () -> {
        Properties.setIgnoreMissingGitignore(project);
        notifications.updateAllNotifications();
    });

    try { // ignore if older SDK does not support panel icon
        Icon icon = fileType.getIcon();
        if (icon != null) {
            panel.icon(icon);
        }
    } catch (NoSuchMethodError ignored) {
    }

    return panel;
}