IDEA-127739 Navigation Tab clion/138.1995 dbe/138.1991 idea/138.1996 phpstorm/138.1993 pycharm/138.1994 rubymine/138.1992 webstorm/138.1988
authorVassiliy.Kudryashov <Vassiliy.Kudryashov@jetbrains.com>
Mon, 1 Sep 2014 23:01:01 +0000 (03:01 +0400)
committerVassiliy.Kudryashov <Vassiliy.Kudryashov@jetbrains.com>
Mon, 1 Sep 2014 23:02:21 +0000 (03:02 +0400)
Stage 3

platform/editor-ui-api/src/com/intellij/ide/ui/UISettings.java
platform/platform-impl/src/com/intellij/ide/actions/PinActiveTabAction.java
platform/platform-impl/src/com/intellij/ide/actions/SplitAction.java
platform/platform-impl/src/com/intellij/ide/ui/AppearanceConfigurable.java
platform/platform-impl/src/com/intellij/ide/ui/AppearancePanel.form
platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorEmptyTextPainter.java
platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorsSplitters.java
platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorManagerImpl.java
platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/PreviewPanel.java
platform/platform-resources-en/src/messages/IdeBundle.properties
platform/util/resources/misc/registry.properties

index 9f5f5d5720dad1b5a0b5b190dcafb0d7572064e7..c61ce5f8f946779c7d78a37fcba3c9c4de767412 100644 (file)
@@ -121,6 +121,7 @@ public class UISettings extends SimpleModificationTracker implements PersistentS
   public boolean MARK_MODIFIED_TABS_WITH_ASTERISK = false;
   public boolean SHOW_TABS_TOOLTIPS = true;
   public boolean SHOW_DIRECTORY_FOR_NON_UNIQUE_FILENAMES = true;
+  public boolean NAVIGATE_TO_PREVIEW = false;
 
   private final EventDispatcher<UISettingsListener> myDispatcher = EventDispatcher.create(UISettingsListener.class);
 
index ddfc1a3989aa332ec71e86404c2ec20822b3303b..560082bf9e642040486d62ad5a939d20bf28381c 100644 (file)
@@ -116,12 +116,17 @@ public class PinActiveTabAction extends ToggleAction implements DumbAware {
     super.update(e);
     Presentation presentation = e.getPresentation();
     DataContext context = e.getDataContext();
-    if (getFile(context) != null) {
-      presentation.setEnabledAndVisible(true);
-    }
-    else {
-      Content content = getContent(context);
-      presentation.setEnabledAndVisible(content != null && content.isPinnable());
+    EditorWindow window = getEditorWindow(context);
+    if (window == null || window.getOwner().isPreview()) {
+      presentation.setEnabledAndVisible(false);
+    } else {
+      if (getFile(context) != null) {
+        presentation.setEnabledAndVisible(true);
+      }
+      else {
+        Content content = getContent(context);
+        presentation.setEnabledAndVisible(content != null && content.isPinnable());
+      }
     }
     if (ActionPlaces.EDITOR_TAB_POPUP.equals(e.getPlace()) ||
         ViewContext.CELL_POPUP_PLACE.equals(e.getPlace())) {
index fb55f3649484463e10387c75527486962dab405f..9e9a349bb3fd16aa3d22d3ad371cbd60125cb340 100644 (file)
@@ -60,7 +60,8 @@ public abstract class SplitAction extends AnAction implements DumbAware {
     final int minimum = myCloseSource ? 2 : 1;
     final boolean enabled = project != null
                             && window != null
-                            && window.getTabCount() >= minimum;
+                            && window.getTabCount() >= minimum
+                            && !window.getOwner().isPreview();
     event.getPresentation().setEnabled(enabled);
   }
 }
index cc6e16aba6c24e4401090b0dee4f38f43a928aa2..9accbc5bc6c8366cc878e7e51f5c50cd09be5ccf 100644 (file)
@@ -174,6 +174,9 @@ public class AppearanceConfigurable extends BaseConfigurable implements Searchab
     update |= settings.SHOW_EDITOR_TOOLTIP != myComponent.myEditorTooltipCheckBox.isSelected();
     settings.SHOW_EDITOR_TOOLTIP = myComponent.myEditorTooltipCheckBox.isSelected();
 
+    update |= settings.NAVIGATE_TO_PREVIEW != myComponent.myNavigateToPreviewCheckBox.isSelected();
+    settings.NAVIGATE_TO_PREVIEW = myComponent.myNavigateToPreviewCheckBox.isSelected();
+
     update |= settings.DISABLE_MNEMONICS_IN_CONTROLS != myComponent.myDisableMnemonicInControlsCheckBox.isSelected();
     settings.DISABLE_MNEMONICS_IN_CONTROLS = myComponent.myDisableMnemonicInControlsCheckBox.isSelected();
 
@@ -280,6 +283,7 @@ public class AppearanceConfigurable extends BaseConfigurable implements Searchab
     myComponent.myLeftLayoutCheckBox.setSelected(settings.LEFT_HORIZONTAL_SPLIT);
     myComponent.myRightLayoutCheckBox.setSelected(settings.RIGHT_HORIZONTAL_SPLIT);
     myComponent.myEditorTooltipCheckBox.setSelected(settings.SHOW_EDITOR_TOOLTIP);
+    myComponent.myNavigateToPreviewCheckBox.setSelected(settings.NAVIGATE_TO_PREVIEW);
     myComponent.myDisableMnemonicInControlsCheckBox.setSelected(settings.DISABLE_MNEMONICS_IN_CONTROLS);
 
     boolean alphaModeEnabled = WindowManagerEx.getInstanceEx().isAlphaModeSupported();
@@ -325,6 +329,7 @@ public class AppearanceConfigurable extends BaseConfigurable implements Searchab
     isModified |= myComponent.myLeftLayoutCheckBox.isSelected() != settings.LEFT_HORIZONTAL_SPLIT;
     isModified |= myComponent.myRightLayoutCheckBox.isSelected() != settings.RIGHT_HORIZONTAL_SPLIT;
     isModified |= myComponent.myEditorTooltipCheckBox.isSelected() != settings.SHOW_EDITOR_TOOLTIP;
+    isModified |= myComponent.myNavigateToPreviewCheckBox.isSelected() != settings.NAVIGATE_TO_PREVIEW;
 
     isModified |= myComponent.myHideIconsInQuickNavigation.isSelected() != settings.SHOW_ICONS_IN_QUICK_NAVIGATION;
 
@@ -397,6 +402,7 @@ public class AppearanceConfigurable extends BaseConfigurable implements Searchab
     private JSlider myInitialTooltipDelaySlider;
     private ComboBox myPresentationModeFontSize;
     private JCheckBox myEditorTooltipCheckBox;
+    private JCheckBox myNavigateToPreviewCheckBox;
     private JCheckBox myAllowStatusBar;
     private JCheckBox myAllowLineNumbers;
     private JCheckBox myAllowAnnotations;
index 550e8e2482e117ed2f105da44d185fdb3289192b..7590feba2ad811ef28be30a9d1578553690c7e0e 100644 (file)
                   <text resource-bundle="messages/IdeBundle" key="checkbox.show.editor.preview.popup"/>
                 </properties>
               </component>
+              <component id="3e39" class="javax.swing.JCheckBox" binding="myNavigateToPreviewCheckBox" default-binding="true">
+                <constraints>
+                  <grid row="6" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
+                </constraints>
+                <properties>
+                  <text resource-bundle="messages/IdeBundle" key="checkbox.use.preview.window"/>
+                </properties>
+              </component>
             </children>
           </grid>
           <grid id="e3cc0" layout-manager="GridLayoutManager" row-count="2" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
index 4807812e50477dd7e7823a287155dfed8c7b76be..101f4a7ddfeda35a5622c476318ac90baa9b50d2 100644 (file)
@@ -54,9 +54,12 @@ public class EditorEmptyTextPainter {
     UIUtil.TextPainter painter = new UIUtil.TextPainter().withLineSpacing(1.5f);
     painter.withShadow(true, new JBColor(Gray._200.withAlpha(100), Gray._0.withAlpha(255)));
 
-    painter.appendLine("No files are open").underlined(new JBColor(Gray._150, Gray._180));
+    painter.appendLine("No files are open");
 
-    advertiseActions(splitters, painter);
+    if (!splitters.isPreview()) {
+      painter.underlined(new JBColor(Gray._150, Gray._180));
+      advertiseActions(splitters, painter);
+    }
 
     painter.draw(g, new PairFunction<Integer, Integer, Couple<Integer>>() {
       @Override
index b9e38809faab33dc375328d1d86a23119bce2f6e..fa0a4dbd6fe4b9a346d1613468c488d8db77b9b4 100644 (file)
@@ -744,6 +744,10 @@ public class EditorsSplitters extends IdePanePanel implements UISettingsListener
     return false;
   }
 
+  public boolean isPreview() {
+    return false;
+  }
+
   private final class MyFocusWatcher extends FocusWatcher {
     @Override
     protected void focusedComponentChanged(final Component component, final AWTEvent cause) {
index 65adf52041b97707365bcfc7b39c2d9b5e93ee60..d7080b4f6b85e1f6e4eb2be16dbb58b1ea7d602b 100644 (file)
@@ -179,7 +179,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
 
   public Set<EditorsSplitters> getAllSplitters() {
     HashSet<EditorsSplitters> all = new LinkedHashSet<EditorsSplitters>();
-    if (Registry.is("editor.use.preview")) {
+    if (PreviewPanel.isAvailable()) {
       initUI();
       all.add(myPreviewPanel.getWindow().getOwner());
     }
@@ -255,7 +255,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
         }
       }
     }
-    if (myPreviewPanel == null && Registry.is("editor.use.preview")) {
+    if (myPreviewPanel == null && PreviewPanel.isAvailable()) {
       synchronized (myInitLock) {
         myPreviewPanel = new PreviewPanel(myProject, this, myDockManager);
       }
@@ -661,10 +661,10 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
   @Nullable
   private EditorWindow getPreviewWindow(@NotNull VirtualFile virtualFile, final boolean focusEditor, final boolean searchForSplitter) {
     EditorWindow wndToOpenIn = null;
-    if (Registry.is("editor.use.preview") && !myPreviewBlocker.get()) {
+    if (PreviewPanel.isAvailable() && !myPreviewBlocker.get()) {
       wndToOpenIn = myPreviewPanel.getWindow();
-      if (virtualFile.equals(myPreviewPanel.getCurrentFile())) return wndToOpenIn;
-      final VirtualFile modifiedFile = myPreviewPanel.closeCurrentFile();
+      if (myPreviewPanel.hasCurrentFile(virtualFile)) return wndToOpenIn;
+      final VirtualFile modifiedFile = myPreviewPanel.getCurrentModifiedFile();
       ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.PREVIEW).activate(null, false);
       if (modifiedFile != null) {
         CommandProcessor.getInstance().executeCommand(myProject, new Runnable() {
index a9634d5a335acf0d8372a9cd29f78fbf6398bec4..ade7001fc27949a3a723ea4b3429f81fb1d92589 100644 (file)
@@ -19,21 +19,22 @@ import com.intellij.icons.AllIcons;
 import com.intellij.ide.ui.UISettings;
 import com.intellij.openapi.actionSystem.AnAction;
 import com.intellij.openapi.actionSystem.AnActionEvent;
-import com.intellij.openapi.editor.Document;
-import com.intellij.openapi.editor.event.DocumentEvent;
-import com.intellij.openapi.editor.event.DocumentListener;
-import com.intellij.openapi.fileEditor.FileDocumentManager;
+import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.fileEditor.FileEditorManager;
 import com.intellij.openapi.fileEditor.FileEditorManagerListener;
 import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.Key;
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.openapi.wm.ToolWindowAnchor;
-import com.intellij.openapi.wm.ToolWindowId;
-import com.intellij.openapi.wm.ToolWindowManager;
+import com.intellij.openapi.wm.*;
 import com.intellij.openapi.wm.impl.ToolWindowImpl;
-import com.intellij.ui.JBColor;
+import com.intellij.openapi.wm.impl.content.ToolWindowContentUi;
+import com.intellij.ui.content.Content;
+import com.intellij.ui.content.ContentManager;
+import com.intellij.ui.content.ContentManagerAdapter;
+import com.intellij.ui.content.ContentManagerEvent;
 import com.intellij.ui.docking.DockManager;
+import com.intellij.util.ArrayUtil;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
@@ -41,133 +42,195 @@ import javax.swing.*;
 import java.awt.*;
 import java.util.ArrayList;
 
-class PreviewPanel extends JPanel implements DocumentListener, FileEditorManagerListener.Before {
+class PreviewPanel extends JPanel {
+  private static final Key<VirtualFile> FILE_KEY = Key.create("v_file");
   private static final int HISTORY_LIMIT = 10;
 
   private final Project myProject;
   private final FileEditorManagerImpl myManager;
   private final DockManager myDockManager;
   private EditorWindow myWindow;
-  private boolean myInitialized = false;
   private EditorsSplitters myEditorsSplitters;
   private ArrayList<VirtualFile> myHistory = new ArrayList<VirtualFile>();
   private VirtualFile myModifiedFile = null;
   private ToolWindowImpl myToolWindow;
   private VirtualFile myAwaitingForOpen = null;
+  private ContentManager myContentManager;
+  private Content myStubContent;
 
-  public PreviewPanel(Project project, FileEditorManagerImpl manager, DockManager dockManager) {
+  static boolean isAvailable() {
+    return UISettings.getInstance().NAVIGATE_TO_PREVIEW;
+  }
+
+  PreviewPanel(Project project, FileEditorManagerImpl manager, DockManager dockManager) {
     myProject = project;
     myManager = manager;
     myDockManager = dockManager;
-    setOpaque(true);
-    setBackground(JBColor.DARK_GRAY);
+  }
+
+  // package-private API
+
+  EditorWindow getWindow() {
+    initToolWindowIfNeed();
+    return myWindow;
+  }
+
+  boolean hasCurrentFile(@NotNull VirtualFile file) {
+    return file.equals(getCurrentFile());
+  }
+
+  @Nullable
+  VirtualFile getCurrentModifiedFile() {
+    VirtualFile file = getCurrentFile();
+    return file != null && file.equals(myModifiedFile) ? file : null;
   }
 
   private void initToolWindowIfNeed() {
-    if (myInitialized) return;
+    if (ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.PREVIEW) != null) return;
 
     myToolWindow = (ToolWindowImpl)ToolWindowManager.getInstance(myProject)
       .registerToolWindow(ToolWindowId.PREVIEW, this, ToolWindowAnchor.RIGHT, myProject, false);
     myToolWindow.setIcon(AllIcons.Actions.PreviewDetails);
-
-    myEditorsSplitters = new EditorsSplitters(myManager, myDockManager, false) {
+    myToolWindow.setContentUiType(ToolWindowContentUiType.COMBO, null);
+    myContentManager = myToolWindow.getContentManager();
+    myStubContent = myContentManager.getContent(0);
+    myContentManager.addContentManagerListener(new ContentManagerAdapter() {
       @Override
-      public void updateFileName(VirtualFile updatedFile) {
-        super.updateFileName(updatedFile);
-        if (updatedFile != null && updatedFile.equals(getCurrentFile())) {
-          updateWindowTitle(updatedFile);
+      public void selectionChanged(ContentManagerEvent event) {
+        final VirtualFile file = event.getContent().getUserData(FILE_KEY);
+        if (event.getOperation() == ContentManagerEvent.ContentOperation.remove && file != null && file.equals(myModifiedFile)) {
+          close(file);
+          return;
         }
-      }
 
-      @Override
-      protected void afterFileOpen(VirtualFile file) {
-        if (file.equals(myAwaitingForOpen)) {
-          updateWindowTitle(file);
-          Document document = FileDocumentManager.getInstance().getDocument(file);
-          if (document != null) {
-            myModifiedFile = null;
-            document.addDocumentListener(PreviewPanel.this, myProject);
+        if (event.getOperation() != ContentManagerEvent.ContentOperation.add) return;
+
+        if (file != null) {
+          event.getContent().setComponent(PreviewPanel.this);//Actually we share the same component between contents
+          if (!file.equals(myWindow.getSelectedFile())) {
+            ApplicationManager.getApplication().invokeLater(new Runnable() {
+              @Override
+              public void run() {
+                myManager.openFileWithProviders(file, false, myWindow);
+              }
+            });
           }
         }
-        myAwaitingForOpen = null;
       }
-
-      @Override
-      public void setTabsPlacement(int tabPlacement) {
-        super.setTabsPlacement(UISettings.TABS_NONE);
-      }
-
-      @Override
-      protected boolean showEmptyText() {
-        return false;
-      }
-    };
-
-    myProject.getMessageBus().connect().subscribe(FileEditorManagerListener.Before.FILE_EDITOR_MANAGER, this);
+    });
+
+    myEditorsSplitters = new MyEditorsSplitters();
+
+    myProject.getMessageBus().connect().subscribe(FileEditorManagerListener.Before.FILE_EDITOR_MANAGER,
+                                                  new FileEditorManagerListener.Before() {
+                                                    @Override
+                                                    public void beforeFileOpened(@NotNull FileEditorManager source,
+                                                                                 @NotNull VirtualFile file) {
+                                                      myAwaitingForOpen = file;
+                                                      VirtualFile currentFile = getCurrentFile();
+                                                      if (currentFile != null &&
+                                                          currentFile.equals(myModifiedFile) &&
+                                                          !currentFile.equals(file)) {
+                                                        close(currentFile);
+                                                      }
+                                                    }
+
+                                                    @Override
+                                                    public void beforeFileClosed(@NotNull FileEditorManager source,
+                                                                                 @NotNull VirtualFile file) {
+                                                      checkStubContent();
+                                                    }
+                                                  });
     myEditorsSplitters.createCurrentWindow();
-
     myWindow = myEditorsSplitters.getCurrentWindow();
     myWindow.setTabsPlacement(UISettings.TABS_NONE);
-
     setLayout(new GridLayout(1, 1));
     add(myEditorsSplitters);
-
     myToolWindow.setTitleActions(new MoveToEditorTabsAction(), new CloseFileAction());
+    myToolWindow.hide(null);
+  }
 
-    myInitialized = true;
+  @Nullable
+  private VirtualFile getCurrentFile() {
+    VirtualFile[] files = myWindow.getFiles();
+    return files.length == 1 ? files[0] : null;
   }
 
-  private void updateWindowTitle(VirtualFile file) {
-    if (myToolWindow == null) return;
-    if (file == null) {
-      myToolWindow.setTitle(": (empty)");
-    }
-    else {
-      myToolWindow.setTitle(": " +
-                            StringUtil.getShortened(EditorTabbedContainer.calcTabTitle(myProject, file),
-                                                    UISettings.getInstance().EDITOR_TAB_TITLE_LIMIT));
+  @NotNull
+  private Content addContent(VirtualFile file) {
+    myHistory.add(file);
+    while (myHistory.size() > HISTORY_LIMIT) {
+      myHistory.remove(0);
     }
+    String title =
+      StringUtil.getShortened(EditorTabbedContainer.calcTabTitle(myProject, file), UISettings.getInstance().EDITOR_TAB_TITLE_LIMIT);
+
+    Content content = myContentManager.getFactory().createContent(this, title, false);
+    content.putUserData(ToolWindow.SHOW_CONTENT_ICON, Boolean.TRUE);
+    content.putUserData(FILE_KEY, file);
+    content.setIcon(file.getFileType().getIcon());
+    content.setPopupIcon(file.getFileType().getIcon());
+
+    myContentManager.addContent(content);
+    checkStubContent();
+    return content;
   }
 
-  @Override
-  public void beforeFileOpened(@NotNull FileEditorManager source, @NotNull VirtualFile file) {
-    myAwaitingForOpen = file;
+  private void setSelected(VirtualFile file) {
+    Content content = getContent(file);
+    if (content == null) {
+      content = addContent(file);
+    }
+    myContentManager.setSelectedContent(content);
   }
 
-  @Override
-  public void beforeFileClosed(@NotNull FileEditorManager source, @NotNull VirtualFile file) {
-    if (file.equals(getCurrentFile())) {
-      updateWindowTitle(null);
-      Document document = FileDocumentManager.getInstance().getDocument(file);
-      if (document != null) {
-        document.removeDocumentListener(this);
+  @Nullable
+  private Content getContent(VirtualFile file) {
+    Content[] contents = myContentManager.getContents();
+    for (Content content : contents) {
+      if (file.equals(content.getUserData(FILE_KEY))) {
+        return content;
       }
     }
+    return null;
   }
 
-
-  @Override
-  public void beforeDocumentChange(DocumentEvent event) {
-
-  }
-
-  @Override
-  public void documentChanged(DocumentEvent event) {
-    VirtualFile file = FileDocumentManager.getInstance().getFile(event.getDocument());
-    if (file != null) {
-      myModifiedFile = file;
+  private void checkStubContent() {
+    if (myContentManager.getContents().length == 0) {
+      myToolWindow.getComponent().putClientProperty(ToolWindowContentUi.HIDE_ID_LABEL, "false");
+      myStubContent.setComponent(this);
+      myContentManager.addContent(myStubContent);
+      ApplicationManager.getApplication().invokeLater(new Runnable() {
+        @Override
+        public void run() {
+          if (myContentManager.getIndexOfContent(myStubContent) != -1) {
+            ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.PREVIEW).hide(null);
+          }
+        }
+      });
+    }
+    else if (myContentManager.getContents().length > 1) {
+      myToolWindow.getComponent().putClientProperty(ToolWindowContentUi.HIDE_ID_LABEL, "true");
+      myContentManager.removeContent(myStubContent, false);
     }
   }
 
-  EditorWindow getWindow() {
-    initToolWindowIfNeed();
-    return myWindow;
-  }
-
-  @Nullable
-  VirtualFile getCurrentFile() {
-    VirtualFile[] files = myWindow.getFiles();
-    return files.length == 1 ? files[0] : null;
+  private void close(@NotNull VirtualFile file) {
+    myHistory.remove(file);
+    if (ArrayUtil.find(myEditorsSplitters.getOpenFiles(), file) != -1) {
+      myEditorsSplitters.closeFile(file, false);
+    }
+    if (file.equals(myAwaitingForOpen)) {
+      myAwaitingForOpen = null;
+    }
+    if (file.equals(myModifiedFile)) {
+      myModifiedFile = null;
+    }
+    Content content = getContent(file);
+    if (content != null) {
+      myContentManager.removeContent(content, false);
+      checkStubContent();
+    }
   }
 
   private class MoveToEditorTabsAction extends AnAction {
@@ -182,63 +245,65 @@ class PreviewPanel extends JPanel implements DocumentListener, FileEditorManager
         return;
       }
 
-      myManager.openFileWithProviders(virtualFile, false, myManager.getCurrentWindow());
-      closeCurrentFile();
+      EditorWindow window = myManager.getCurrentWindow();
+      if (window == null) { //main tab set is still not created, rare situation
+        myManager.getMainSplitters().createCurrentWindow();
+        window = myManager.getCurrentWindow();
+      }
+      myManager.openFileWithProviders(virtualFile, true, window);
+      close(virtualFile);
+      ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.PREVIEW).hide(null);
+    }
+  }
+
+
+  private class CloseFileAction extends AnAction {
+    public CloseFileAction() {
+      super(null, "Close", AllIcons.Actions.Close);
     }
 
     @Override
-    public void update(AnActionEvent e) {
-      super.update(e);
-      VirtualFile currentFile = getCurrentFile();
-      e.getPresentation().setEnabled(currentFile != null);
-      if (currentFile == null) return;
-
-      if (isModified(currentFile)) {
-        e.getPresentation().setIcon(AllIcons.Duplicates.SendToTheLeft);
-      }
-      else {
-        e.getPresentation().setIcon(AllIcons.Duplicates.SendToTheLeftGrayed);
+    public void actionPerformed(AnActionEvent e) {
+      for (VirtualFile file : myHistory.toArray(new VirtualFile[myHistory.size()])) {
+        close(file);
       }
     }
   }
 
-  private boolean isModified(@NotNull VirtualFile file) {
-    return file.equals(myModifiedFile);
-  }
+  private class MyEditorsSplitters extends EditorsSplitters {
+    public MyEditorsSplitters() {
+      super(myManager, myDockManager, false);
+    }
 
-  //returns last open file if it has "modified" status
-  @Nullable
-  VirtualFile closeCurrentFile() {
-    VirtualFile virtualFile = getCurrentFile();
-    if (virtualFile == null) return null;
-    if (!myHistory.contains(virtualFile)) {
-      myHistory.add(virtualFile);
-      while (myHistory.size() > HISTORY_LIMIT) {
-        myHistory.remove(0);
+    @Override
+    protected void afterFileOpen(VirtualFile file) {
+      if (file.equals(myAwaitingForOpen)) {
+        setSelected(file);
       }
+      myAwaitingForOpen = null;
     }
-    myWindow.closeFile(virtualFile);
-    this.revalidate();
-    this.repaint();
-    return isModified(virtualFile) ? virtualFile : null;
-  }
 
-  private class CloseFileAction extends AnAction {
-    public CloseFileAction() {
-      super(null, "Close", AllIcons.Actions.Close);
+    @Override
+    protected void afterFileClosed(VirtualFile file) {
+      close(file);
     }
 
     @Override
-    public void actionPerformed(AnActionEvent e) {
-      if (getCurrentFile() == null) return;
-      closeCurrentFile();
-      ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.PREVIEW).hide(null);
+    public void updateFileIcon(@NotNull VirtualFile file) {
+      EditorWithProviderComposite composite = myWindow.findFileComposite(file);
+      if (composite != null && composite.isModified()) {
+        myModifiedFile = file;
+      }
+    }
+
+    @Override
+    public void setTabsPlacement(int tabPlacement) {
+      super.setTabsPlacement(UISettings.TABS_NONE);
     }
 
     @Override
-    public void update(AnActionEvent e) {
-      super.update(e);
-      e.getPresentation().setEnabled(getCurrentFile() != null);
+    public boolean isPreview() {
+      return true;
     }
   }
 }
index 556b246bc1b774b153c0a808a56f192fb92e8018..889a1383aa9160d6421863e1020e6ab48fd7bdb7 100644 (file)
@@ -641,6 +641,7 @@ checkbox.widescreen.tool.window.layout=Widescreen tool window layout
 checkbox.left.toolwindow.layout=Side-by-side layout on the left
 checkbox.right.toolwindow.layout=Side-by-side layout on the right
 checkbox.show.editor.preview.popup=Show editor preview tooltip
+checkbox.use.preview.window=Navigate to preview
 checkbox.show.tool.window.numbers=Show tool window numbers
 checkbox.animate.windows=Animate windows
 group.transparency=Transparency
index 91346539d242ba8b6540e74d76a9e68e93b6f48e..6599ec8bd8d7b32db9381329bbe9541640201cfa 100644 (file)
@@ -122,7 +122,6 @@ editor.use.scrollable.tabs=true
 editor.smarterSelectionQuoting=true
 editor.skip.copy.and.cut.for.empty.selection=false
 editor.distraction.free.mode=false
-editor.use.preview=false
 editor.add.carets.on.double.control.arrows=true
 
 ide.showIndexRebuildMessage=false