java-decompiler: show legal notice only for decompiled files
authorRoman Shevchenko <roman.shevchenko@jetbrains.com>
Wed, 15 Oct 2014 15:26:35 +0000 (17:26 +0200)
committerRoman Shevchenko <roman.shevchenko@jetbrains.com>
Wed, 15 Oct 2014 15:26:35 +0000 (17:26 +0200)
plugins/java-decompiler/plugin/src/org/jetbrains/java/decompiler/IdeaDecompiler.java

index 4a7c3d40657fe520642d25058d4b54297fba08be..d08ea993f01283f73d0a08788746581bc8132ddb 100644 (file)
@@ -23,10 +23,7 @@ import com.intellij.openapi.application.Application;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.application.ModalityState;
 import com.intellij.openapi.application.ex.ApplicationManagerEx;
-import com.intellij.openapi.fileEditor.FileEditor;
-import com.intellij.openapi.fileEditor.FileEditorManager;
-import com.intellij.openapi.fileEditor.FileEditorManagerAdapter;
-import com.intellij.openapi.fileEditor.FileEditorManagerListener;
+import com.intellij.openapi.fileEditor.*;
 import com.intellij.openapi.fileTypes.StdFileTypes;
 import com.intellij.openapi.project.DefaultProjectFactory;
 import com.intellij.openapi.project.Project;
@@ -99,8 +96,11 @@ public class IdeaDecompiler extends ClassFileDecompilers.Light {
         public void fileOpened(@NotNull FileEditorManager source, @NotNull VirtualFile file) {
           if (file.getFileType() == StdFileTypes.CLASS) {
             FileEditor editor = source.getSelectedEditor(file);
-            if (editor != null) {
-              showLegalNotice(source.getProject(), file);
+            if (editor instanceof TextEditor) {
+              CharSequence text = ((TextEditor)editor).getEditor().getDocument().getImmutableCharSequence();
+              if (StringUtil.startsWith(text, BANNER)) {
+                showLegalNotice(source.getProject(), file);
+              }
             }
           }
         }