mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Show advertiser only once
This commit is contained in:
@@ -20,5 +20,6 @@
|
||||
overrides="true"/>
|
||||
|
||||
<annotator language="Python" implementationClass="com.jetbrains.python.PyCharmProfessionalAdvertiser"/>
|
||||
<projectService serviceImplementation="com.jetbrains.python.PyCharmProfessionalAdvertiserSettings"/>
|
||||
</extensions>
|
||||
</idea-plugin>
|
||||
|
||||
@@ -40,27 +40,29 @@ public class PyCharmProfessionalAdvertiser implements Annotator {
|
||||
|
||||
@Override
|
||||
public void annotate(@NotNull PsiElement element, @NotNull AnnotationHolder holder) {
|
||||
|
||||
if (element instanceof PyFile) {
|
||||
|
||||
final PyFile pyFile = (PyFile)element;
|
||||
final Project project = element.getProject();
|
||||
|
||||
if (getSettings(project).shown) {
|
||||
return;
|
||||
}
|
||||
getSettings(project).shown = true;
|
||||
|
||||
final VirtualFile vFile = pyFile.getVirtualFile();
|
||||
if (vFile != null && FileIndexFacade.getInstance(project).isInLibraryClasses(vFile)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final Boolean showingFlag = project.getUserData(DONT_SHOW_BALLOON);
|
||||
if (showingFlag != null && showingFlag.booleanValue()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!moduleUsesPythonSdk(pyFile)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (PyCellUtil.hasCells(pyFile)) {
|
||||
showInspectionAdvertisement(project, "code cells in editor");
|
||||
showInspectionAdvertisement(project, "code cells in the editor");
|
||||
}
|
||||
|
||||
if (containsImport(pyFile, "django")) {
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.jetbrains.python;
|
||||
|
||||
import com.intellij.openapi.components.PersistentStateComponent;
|
||||
import com.intellij.openapi.components.State;
|
||||
import com.intellij.util.xmlb.XmlSerializerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author traff
|
||||
*/
|
||||
@State(name = "PyCharmProfessionalAdvertiser")
|
||||
public class PyCharmProfessionalAdvertiserSettings implements PersistentStateComponent<PyCharmProfessionalAdvertiserSettings> {
|
||||
public boolean shown = false;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public PyCharmProfessionalAdvertiserSettings getState() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadState(@NotNull PyCharmProfessionalAdvertiserSettings state) {
|
||||
XmlSerializerUtil.copyBean(state, this);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user