build folding for current file only

This commit is contained in:
Dmitry Avdeev
2009-11-06 15:45:11 +03:00
parent c56a9b15bb
commit e40a0335d4
6 changed files with 28 additions and 13 deletions
@@ -41,6 +41,10 @@ public class PsiAwareTextEditorImpl extends TextEditorImpl {
return new PsiAwareTextEditorComponent(project, file, this);
}
public void initFolding() {
CodeFoldingManager.getInstance(myProject).buildInitialFoldings(getEditor());
}
public BackgroundEditorHighlighter getBackgroundHighlighter() {
if (myBackgroundHighlighter == null) {
myBackgroundHighlighter = new TextEditorBackgroundHighlighter(myProject, getEditor());
@@ -58,7 +62,6 @@ public class PsiAwareTextEditorImpl extends TextEditorImpl {
super(project, file, textEditor);
myProject = project;
myFile = file;
CodeFoldingManager.getInstance(project).buildInitialFoldings(getEditor());
}
@Override
@@ -442,7 +442,7 @@ public class EditorWindow {
*/
// open only selected file in the new splitter instead of opening all tabs
final VirtualFile file = selectedEditor.getFile();
fileEditorManager.openFileImpl3(res, file, false, null);
fileEditorManager.openFileImpl3(res, file, false, null, true);
res.setFilePinned (file, isFilePinned (file));
res.setSelectedEditor(selectedEditor, true);
@@ -457,8 +457,8 @@ public class EditorWindow {
splitter.setSecondComponent(res.myPanel);
panel.revalidate();
final VirtualFile file = firstEC.getFile();
fileEditorManager.openFileImpl3(this, file, true, null);
fileEditorManager.openFileImpl3(res, file, false, null);
fileEditorManager.openFileImpl3(this, file, true, null, true);
fileEditorManager.openFileImpl3(res, file, false, null, true);
}
}
}
@@ -22,9 +22,11 @@ import com.intellij.openapi.fileEditor.FileEditorProvider;
import com.intellij.openapi.fileEditor.FileEditorState;
import com.intellij.openapi.fileEditor.FileEditorStateLevel;
import com.intellij.openapi.fileEditor.impl.text.FileDropHandler;
import com.intellij.openapi.fileEditor.impl.text.TextEditorImpl;
import com.intellij.openapi.ui.Splitter;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.wm.FocusWatcher;
import com.intellij.openapi.wm.IdeFocusManager;
@@ -192,9 +194,9 @@ public final class EditorsSplitters extends JPanel {
if (comp != null) {
removeAll();
add(comp, BorderLayout.CENTER);
final EditorComposite lastSelected = getManager ().getLastSelected();
final EditorComposite lastSelected = getManager().getLastSelected();
if(lastSelected != null) {
getManager().openFileImpl3(myCurrentWindow, lastSelected.getFile(), true, null);
getManager().openFileImpl3(myCurrentWindow, lastSelected.getFile(), true, null, true);
//lastSelected.getComponent().requestFocus();
//ToolWindowManager.getInstance(getManager().myProject).activateEditorComponent();
}
@@ -248,13 +250,14 @@ public final class EditorsSplitters extends JPanel {
VirtualFile currentFile = null;
for (final Element file : children) {
final HistoryEntry entry = new HistoryEntry(getManager().getProject(), file.getChild(HistoryEntry.TAG));
getManager().openFileImpl3(window, entry.myFile, false, entry);
boolean isCurrent = Boolean.valueOf(file.getAttributeValue("current")).booleanValue();
getManager().openFileImpl3(window, entry.myFile, false, entry, isCurrent);
if (getManager().isFileOpen(entry.myFile)) {
window.setFilePinned(entry.myFile, Boolean.valueOf(file.getAttributeValue("pinned")).booleanValue());
if (Boolean.valueOf(file.getAttributeValue("current-in-tab")).booleanValue()) {
currentFile = entry.myFile;
}
if (Boolean.valueOf(file.getAttributeValue("current")).booleanValue()) {
if (isCurrent) {
setCurrentWindow(window, false);
}
}
@@ -35,6 +35,7 @@ import com.intellij.openapi.fileEditor.*;
import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx;
import com.intellij.openapi.fileEditor.ex.FileEditorProviderManager;
import com.intellij.openapi.fileEditor.ex.IdeDocumentHistory;
import com.intellij.openapi.fileEditor.impl.text.TextEditorImpl;
import com.intellij.openapi.fileEditor.impl.text.TextEditorProvider;
import com.intellij.openapi.fileTypes.FileTypeEvent;
import com.intellij.openapi.fileTypes.FileTypeListener;
@@ -436,7 +437,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
final Ref<Pair<FileEditor[], FileEditorProvider[]>> resHolder = new Ref<Pair<FileEditor[], FileEditorProvider[]>>();
CommandProcessor.getInstance().executeCommand(myProject, new Runnable() {
public void run() {
resHolder.set(openFileImpl3(window, file, focusEditor, entry));
resHolder.set(openFileImpl3(window, file, focusEditor, entry, true));
}
}, "", null);
return resHolder.get();
@@ -449,10 +450,13 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
* invalid file become selected. That's why we do not require that
* passed file is valid.
* @param entry map between FileEditorProvider and FileEditorState. If this parameter
* is not <code>null</code> then it's used to restore state for the newly created
* @param current
*/
@NotNull Pair<FileEditor[], FileEditorProvider[]> openFileImpl3(final EditorWindow window, @NotNull final VirtualFile file, final boolean focusEditor,
final HistoryEntry entry) {
@NotNull Pair<FileEditor[], FileEditorProvider[]> openFileImpl3(final EditorWindow window,
@NotNull final VirtualFile file,
final boolean focusEditor,
final HistoryEntry entry,
boolean current) {
// Open file
FileEditor[] editors;
FileEditorProvider[] providers;
@@ -494,6 +498,9 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
LOG.assertTrue(provider != null);
LOG.assertTrue(provider.accept(myProject, file));
final FileEditor editor = provider.createEditor(myProject, file);
if (current && editor instanceof TextEditorImpl) {
((TextEditorImpl)editor).initFolding();
}
editors[i] = editor;
LOG.assertTrue(editor != null);
LOG.assertTrue(editor.isValid());
@@ -40,7 +40,7 @@ public class MoveEditorToOppositeTabGroupAction extends AnAction implements Dumb
final EditorWindow[] siblings = window.findSiblings ();
if (siblings != null && siblings.length == 1) {
((FileEditorManagerImpl)FileEditorManagerEx.getInstanceEx(project)).openFileImpl3 (siblings [0], vFile, true, null);
((FileEditorManagerImpl)FileEditorManagerEx.getInstanceEx(project)).openFileImpl3 (siblings [0], vFile, true, null, true);
window.closeFile(vFile);
}
}
@@ -50,6 +50,8 @@ public class TextEditorImpl extends UserDataHolderBase implements TextEditor{
return new TextEditorComponent(project, file, this);
}
public void initFolding() {}
public void dispose(){
myComponent.dispose();
}