diff --git a/images/src/org/intellij/images/editor/impl/ImageFileEditorProvider.java b/images/src/org/intellij/images/editor/impl/ImageFileEditorProvider.java
index 439661afcfea..56fe8d3c2652 100644
--- a/images/src/org/intellij/images/editor/impl/ImageFileEditorProvider.java
+++ b/images/src/org/intellij/images/editor/impl/ImageFileEditorProvider.java
@@ -15,7 +15,10 @@
*/
package org.intellij.images.editor.impl;
-import com.intellij.openapi.fileEditor.*;
+import com.intellij.openapi.fileEditor.FileEditor;
+import com.intellij.openapi.fileEditor.FileEditorPolicy;
+import com.intellij.openapi.fileEditor.FileEditorProvider;
+import com.intellij.openapi.fileEditor.FileEditorState;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
@@ -58,7 +61,7 @@ final class ImageFileEditorProvider implements FileEditorProvider, DumbAware {
@Override
@NotNull
public FileEditorState readState(@NotNull Element sourceElement, @NotNull Project project, @NotNull VirtualFile file) {
- return new NullFileEditorState();
+ return FileEditorState.INSTANCE;
}
@Override
diff --git a/images/src/org/intellij/images/editor/impl/ImageFileEditorState.java b/images/src/org/intellij/images/editor/impl/ImageFileEditorState.java
index 6a7dab4d116a..2fdb94919abc 100644
--- a/images/src/org/intellij/images/editor/impl/ImageFileEditorState.java
+++ b/images/src/org/intellij/images/editor/impl/ImageFileEditorState.java
@@ -43,6 +43,7 @@ public class ImageFileEditorState implements TransferableFileEditorState, Serial
this.zoomFactor = zoomFactor;
}
+ @Override
public boolean canBeMergedWith(FileEditorState otherState, FileEditorStateLevel level) {
return otherState instanceof ImageFileEditorState;
}
diff --git a/platform/platform-api/src/com/intellij/openapi/fileEditor/FileEditorProvider.java b/platform/platform-api/src/com/intellij/openapi/fileEditor/FileEditorProvider.java
index 8ff35a9f994a..2f6d2f611fe6 100644
--- a/platform/platform-api/src/com/intellij/openapi/fileEditor/FileEditorProvider.java
+++ b/platform/platform-api/src/com/intellij/openapi/fileEditor/FileEditorProvider.java
@@ -63,6 +63,7 @@ public interface FileEditorProvider {
/**
* Deserialize state from the specified sourceElement
+ * Use {@link FileEditorState#INSTANCE} as default implementation
*/
@NotNull
FileEditorState readState(@NotNull Element sourceElement, @NotNull Project project, @NotNull VirtualFile file);
diff --git a/platform/platform-api/src/com/intellij/openapi/fileEditor/NullFileEditorState.java b/platform/platform-api/src/com/intellij/openapi/fileEditor/NullFileEditorState.java
deleted file mode 100644
index d9c822f314cd..000000000000
--- a/platform/platform-api/src/com/intellij/openapi/fileEditor/NullFileEditorState.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright 2000-2013 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.openapi.fileEditor;
-
-public final class NullFileEditorState implements FileEditorState {
- @Override
- public boolean canBeMergedWith(FileEditorState otherState, FileEditorStateLevel level) {
- return false;
- }
-}
\ No newline at end of file
diff --git a/platform/testFramework/src/com/intellij/mock/Mock.java b/platform/testFramework/src/com/intellij/mock/Mock.java
index 9e2a14be0711..87e13adf2473 100644
--- a/platform/testFramework/src/com/intellij/mock/Mock.java
+++ b/platform/testFramework/src/com/intellij/mock/Mock.java
@@ -78,12 +78,7 @@ public class Mock {
@Override
@NotNull
public FileEditorState getState(@NotNull FileEditorStateLevel level) {
- return new FileEditorState() {
- @Override
- public boolean canBeMergedWith(FileEditorState fileEditorState, FileEditorStateLevel fileEditorStateLevel) {
- return false;
- }
- };
+ return FileEditorState.INSTANCE;
}
@Override
@@ -316,10 +311,10 @@ public class Mock {
@Override
@NotNull
- public Pair openFileWithProviders(@NotNull VirtualFile file,
- boolean focusEditor,
- boolean searchForSplitter) {
- return Pair.create (new FileEditor[0], new FileEditorProvider [0]);
+ public Pair openFileWithProviders(@NotNull VirtualFile file,
+ boolean focusEditor,
+ boolean searchForSplitter) {
+ return Pair.create(new FileEditor[0], new FileEditorProvider[0]);
}
@Override
@@ -387,11 +382,11 @@ public class Mock {
}
@Override
- public void removeEditorAnnotation(@NotNull FileEditor editor, @NotNull JComponent annotationComoponent) {
+ public void removeEditorAnnotation(@NotNull FileEditor editor, @NotNull JComponent annotationComponent) {
}
@Override
- public void showEditorAnnotation(@NotNull FileEditor editor, @NotNull JComponent annotationComoponent) {
+ public void showEditorAnnotation(@NotNull FileEditor editor, @NotNull JComponent annotationComponent) {
}
@Override
diff --git a/platform/util/src/com/intellij/openapi/util/Disposer.java b/platform/util/src/com/intellij/openapi/util/Disposer.java
index bb999e5a2d1f..4ddf0278a2f4 100644
--- a/platform/util/src/com/intellij/openapi/util/Disposer.java
+++ b/platform/util/src/com/intellij/openapi/util/Disposer.java
@@ -108,8 +108,8 @@ public class Disposer {
ourTree.executeAll(disposable, true, ourDisposeAction, processUnregistered);
}
- public static void disposeChildAndReplace(@NotNull Disposable toDipose, @NotNull Disposable toReplace) {
- ourTree.executeChildAndReplace(toDipose, toReplace, true, ourDisposeAction);
+ public static void disposeChildAndReplace(@NotNull Disposable toDispose, @NotNull Disposable toReplace) {
+ ourTree.executeChildAndReplace(toDispose, toReplace, true, ourDisposeAction);
}
@NotNull
diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/editor/MyEditorState.java b/plugins/ui-designer/src/com/intellij/uiDesigner/editor/MyEditorState.java
index fef1e13ecf91..4ecd1e465669 100644
--- a/plugins/ui-designer/src/com/intellij/uiDesigner/editor/MyEditorState.java
+++ b/plugins/ui-designer/src/com/intellij/uiDesigner/editor/MyEditorState.java
@@ -50,6 +50,7 @@ final class MyEditorState implements FileEditorState{
return (int)(myDocumentModificationStamp ^ (myDocumentModificationStamp >>> 32));
}
+ @Override
public boolean canBeMergedWith(FileEditorState otherState, FileEditorStateLevel level) {
return otherState instanceof MyEditorState;
}
diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/PerspectiveFileEditor.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/PerspectiveFileEditor.java
index 5cd00515a754..7e57a41074d4 100644
--- a/xml/dom-openapi/src/com/intellij/util/xml/ui/PerspectiveFileEditor.java
+++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/PerspectiveFileEditor.java
@@ -18,13 +18,13 @@ package com.intellij.util.xml.ui;
import com.intellij.codeHighlighting.BackgroundEditorHighlighter;
import com.intellij.ide.structureView.StructureViewBuilder;
+import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.ScrollType;
import com.intellij.openapi.fileEditor.*;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.UserDataHolderBase;
import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.openapi.application.ApplicationManager;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
@@ -46,7 +46,7 @@ import java.beans.PropertyChangeSupport;
* @author Sergey.Vasiliev
*/
abstract public class PerspectiveFileEditor extends UserDataHolderBase implements DocumentsEditor, Committable {
- private final Wrapper myWrapprer = new Wrapper();
+ private final Wrapper myWrapper = new Wrapper();
private boolean myInitialised = false;
private final PropertyChangeSupport myPropertyChangeSupport = new PropertyChangeSupport(this);
@@ -55,22 +55,18 @@ abstract public class PerspectiveFileEditor extends UserDataHolderBase implement
private final UndoHelper myUndoHelper;
private boolean myInvalidated;
- private static final FileEditorState FILE_EDITOR_STATE = new FileEditorState() {
- public boolean canBeMergedWith(FileEditorState otherState, FileEditorStateLevel level) {
- return true;
- }
- };
-
protected PerspectiveFileEditor(final Project project, final VirtualFile file) {
myProject = project;
myUndoHelper = new UndoHelper(project, this);
myFile = file;
FileEditorManager.getInstance(myProject).addFileEditorManagerListener(new FileEditorManagerAdapter() {
+ @Override
public void selectionChanged(@NotNull FileEditorManagerEvent event) {
if (!isValid()) return;
ApplicationManager.getApplication().invokeLater(new Runnable() {
+ @Override
public void run() {
if (myUndoHelper.isShowing() && !getComponent().isShowing()) {
deselectNotify();
@@ -183,6 +179,7 @@ abstract public class PerspectiveFileEditor extends UserDataHolderBase implement
return PsiManager.getInstance(myProject).findFile(myFile);
}
+ @Override
public final Document[] getDocuments() {
return myUndoHelper.getDocuments();
}
@@ -195,20 +192,24 @@ abstract public class PerspectiveFileEditor extends UserDataHolderBase implement
return myFile;
}
+ @Override
public void dispose() {
if (myInvalidated) return;
myInvalidated = true;
myUndoHelper.stopListeningDocuments();
}
+ @Override
public final boolean isModified() {
return FileDocumentManager.getInstance().isFileModified(getVirtualFile());
}
+ @Override
public boolean isValid() {
return getVirtualFile().isValid();
}
+ @Override
public void selectNotify() {
if (!checkIsValid() || myInvalidated) return;
ensureInitialized();
@@ -222,50 +223,60 @@ abstract public class PerspectiveFileEditor extends UserDataHolderBase implement
protected final synchronized void ensureInitialized() {
if (!isInitialised()) {
- myWrapprer.setContent(createCustomComponent());
+ myWrapper.setContent(createCustomComponent());
myInitialised = true;
}
}
+ @Override
public void deselectNotify() {
if (!checkIsValid() || myInvalidated) return;
setShowing(false);
commit();
}
+ @Override
public BackgroundEditorHighlighter getBackgroundHighlighter() {
return null;
}
+ @Override
public FileEditorLocation getCurrentLocation() {
return new FileEditorLocation() {
+ @Override
@NotNull
public FileEditor getEditor() {
return PerspectiveFileEditor.this;
}
- public int compareTo(final FileEditorLocation fileEditorLocation) {
+ @Override
+ public int compareTo(@NotNull final FileEditorLocation fileEditorLocation) {
return 0;
}
};
}
+ @Override
public StructureViewBuilder getStructureViewBuilder() {
return null;
}
+ @Override
@NotNull
public FileEditorState getState(@NotNull FileEditorStateLevel level) {
- return FILE_EDITOR_STATE;
+ return FileEditorState.INSTANCE;
}
+ @Override
public void setState(@NotNull FileEditorState state) {
}
+ @Override
public void addPropertyChangeListener(@NotNull PropertyChangeListener listener) {
myPropertyChangeSupport.addPropertyChangeListener(listener);
}
+ @Override
public void removePropertyChangeListener(@NotNull PropertyChangeListener listener) {
myPropertyChangeSupport.removePropertyChangeListener(listener);
}
@@ -278,6 +289,7 @@ abstract public class PerspectiveFileEditor extends UserDataHolderBase implement
return !myInvalidated;
}
+ @Override
@NotNull
public JComponent getComponent() {
return getWrapper();
@@ -287,7 +299,7 @@ abstract public class PerspectiveFileEditor extends UserDataHolderBase implement
protected abstract JComponent createCustomComponent();
public Wrapper getWrapper() {
- return myWrapprer;
+ return myWrapper;
}
protected final synchronized boolean isInitialised() {
diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/PerspectiveFileEditorProvider.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/PerspectiveFileEditorProvider.java
index c9650fc48d8e..7e4ba4cf0563 100644
--- a/xml/dom-openapi/src/com/intellij/util/xml/ui/PerspectiveFileEditorProvider.java
+++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/PerspectiveFileEditorProvider.java
@@ -15,7 +15,10 @@
*/
package com.intellij.util.xml.ui;
-import com.intellij.openapi.fileEditor.*;
+import com.intellij.openapi.fileEditor.FileEditor;
+import com.intellij.openapi.fileEditor.FileEditorPolicy;
+import com.intellij.openapi.fileEditor.FileEditorState;
+import com.intellij.openapi.fileEditor.WeighedFileEditorProvider;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.vfs.VirtualFile;
@@ -39,12 +42,7 @@ public abstract class PerspectiveFileEditorProvider extends WeighedFileEditorPro
@Override
@NotNull
public FileEditorState readState(@NotNull Element sourceElement, @NotNull Project project, @NotNull VirtualFile file) {
- return new FileEditorState() {
- @Override
- public boolean canBeMergedWith(FileEditorState otherState, FileEditorStateLevel level) {
- return true;
- }
- };
+ return FileEditorState.INSTANCE;
}
@Override