use of com.intellij.ui.EditorNotificationPanel in project intellij-community by JetBrains.
the class SdkSetupNotificationTest method testModuleSdk.
public void testModuleSdk() throws Exception {
final EditorNotificationPanel panel = configureBySdkAndText(IdeaTestUtil.getMockJdk18(), true, "Sample.java", "class Sample {}");
assertNull(panel);
}
use of com.intellij.ui.EditorNotificationPanel in project intellij-community by JetBrains.
the class SdkSetupNotificationTest method testNoProjectSdk.
public void testNoProjectSdk() throws Exception {
final EditorNotificationPanel panel = configureBySdkAndText(null, false, "Sample.java", "class Sample {}");
assertSdkSetupPanelShown(panel, "Project SDK is not defined");
}
use of com.intellij.ui.EditorNotificationPanel in project intellij-community by JetBrains.
the class UseDistributionWithSourcesNotificationProvider method createNotificationPanel.
@Override
public EditorNotificationPanel createNotificationPanel(@NotNull VirtualFile file, @NotNull FileEditor fileEditor) {
try {
if (GradleConstants.DEFAULT_SCRIPT_NAME.equals(file.getName()) || GradleConstants.SETTINGS_FILE_NAME.equals(file.getName())) {
final Module module = ModuleUtilCore.findModuleForFile(file, myProject);
if (module == null)
return null;
final String rootProjectPath = getRootProjectPath(module);
if (rootProjectPath == null)
return null;
final GradleProjectSettings settings = GradleSettings.getInstance(module.getProject()).getLinkedProjectSettings(rootProjectPath);
if (settings == null || settings.getDistributionType() != DistributionType.DEFAULT_WRAPPED)
return null;
if (settings.isDisableWrapperSourceDistributionNotification())
return null;
if (!showUseDistributionWithSourcesTip(rootProjectPath))
return null;
final EditorNotificationPanel panel = new EditorNotificationPanel();
panel.setText(GradleBundle.message("gradle.notifications.use.distribution.with.sources"));
panel.createActionLabel(GradleBundle.message("gradle.notifications.hide.tip"), () -> {
settings.setDisableWrapperSourceDistributionNotification(true);
EditorNotifications.getInstance(module.getProject()).updateAllNotifications();
});
panel.createActionLabel(GradleBundle.message("gradle.notifications.apply.suggestion"), () -> {
updateDefaultWrapperConfiguration(rootProjectPath);
EditorNotifications.getInstance(module.getProject()).updateAllNotifications();
ExternalSystemUtil.refreshProject(module.getProject(), GradleConstants.SYSTEM_ID, settings.getExternalProjectPath(), false, ProgressExecutionMode.START_IN_FOREGROUND_ASYNC);
});
return panel;
}
} catch (ProcessCanceledException | IndexNotReadyException ignored) {
}
return null;
}
use of com.intellij.ui.EditorNotificationPanel in project intellij-community by JetBrains.
the class MvcConfigureNotification method createConfigureNotificationPanel.
@Override
public EditorNotificationPanel createConfigureNotificationPanel(@NotNull final Module module) {
final EditorNotificationPanel panel = new EditorNotificationPanel();
panel.setText(framework.getFrameworkName() + " SDK is not configured for module '" + module.getName() + '\'');
for (Entry<String, Runnable> action : framework.createConfigureActions(module).entrySet()) {
panel.createActionLabel(action.getKey(), action.getValue());
}
return panel;
}
use of com.intellij.ui.EditorNotificationPanel in project intellij-community by JetBrains.
the class DetectedIndentOptionsNotificationProvider method createNotificationPanel.
@Nullable
@Override
public EditorNotificationPanel createNotificationPanel(@NotNull final VirtualFile file, @NotNull FileEditor fileEditor) {
Boolean notifiedFlag = fileEditor.getUserData(NOTIFIED_FLAG);
if (fileEditor instanceof TextEditor && notifiedFlag != null) {
final Editor editor = ((TextEditor) fileEditor).getEditor();
final Project project = editor.getProject();
if (project != null) {
Document document = editor.getDocument();
PsiDocumentManager documentManager = PsiDocumentManager.getInstance(project);
PsiFile psiFile = documentManager.getPsiFile(document);
final Ref<FileIndentOptionsProvider> indentOptionsProviderRef = new Ref<>();
if (psiFile != null) {
CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(project);
CommonCodeStyleSettings.IndentOptions userOptions = settings.getIndentOptions(psiFile.getFileType());
CommonCodeStyleSettings.IndentOptions detectedOptions = CodeStyleSettingsManager.getSettings(project).getIndentOptionsByFile(psiFile, null, false, provider -> {
indentOptionsProviderRef.set(provider);
return false;
});
final FileIndentOptionsProvider provider = indentOptionsProviderRef.get();
EditorNotificationInfo info = provider != null && !provider.isAcceptedWithoutWarning(project, file) && !userOptions.equals(detectedOptions) ? provider.getNotificationInfo(project, file, fileEditor, userOptions, detectedOptions) : null;
if (info != null) {
EditorNotificationPanel panel = new EditorNotificationPanel().text(info.getTitle());
if (info.getIcon() != null) {
panel.icon(info.getIcon());
}
for (final ActionLabelData actionLabelData : info.getLabelAndActions()) {
Runnable onClickAction = () -> {
actionLabelData.action.run();
EditorNotifications.getInstance(project).updateAllNotifications();
};
panel.createActionLabel(actionLabelData.label, onClickAction);
}
if (ApplicationManager.getApplication().isUnitTestMode()) {
file.putUserData(DETECT_INDENT_NOTIFICATION_SHOWN_KEY, Boolean.TRUE);
}
return panel;
}
}
}
}
return null;
}
Aggregations