mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-85274 Tasks: the detached editors are not affected by context change
This commit is contained in:
+2
-2
@@ -146,7 +146,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
|
||||
myQueue.setTrackUiActivity(true);
|
||||
}
|
||||
|
||||
void initDockableContentFactory() {
|
||||
public void initDockableContentFactory() {
|
||||
if (myContentFactory != null) return;
|
||||
|
||||
myContentFactory = new DockableEditorContainerFactory(myProject, this, myDockManager);
|
||||
@@ -653,7 +653,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
|
||||
return openFileImpl2(wndToOpenIn, file, focusEditor);
|
||||
}
|
||||
|
||||
public Pair<FileEditor[], FileEditorProvider[]> openFileInNewWindow(VirtualFile file) {
|
||||
public Pair<FileEditor[], FileEditorProvider[]> openFileInNewWindow(@NotNull VirtualFile file) {
|
||||
return ((DockManagerImpl)DockManager.getInstance(getProject())).createNewDockContainerFor(file, this);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.intellij.ide.ui.UISettings;
|
||||
import com.intellij.ide.ui.UISettingsListener;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.actionSystem.Presentation;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.components.PersistentStateComponent;
|
||||
import com.intellij.openapi.components.State;
|
||||
import com.intellij.openapi.components.Storage;
|
||||
@@ -116,9 +117,15 @@ public class DockManagerImpl extends DockManager implements PersistentStateCompo
|
||||
readStateFor(id);
|
||||
}
|
||||
|
||||
public void readState() {
|
||||
for (String id : myFactories.keySet()) {
|
||||
readStateFor(id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<DockContainer> getContainers() {
|
||||
return Collections.unmodifiableSet(myContainers);
|
||||
return Collections.unmodifiableSet(new HashSet<DockContainer>(myContainers));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -394,7 +401,7 @@ public class DockManagerImpl extends DockManager implements PersistentStateCompo
|
||||
});
|
||||
}
|
||||
|
||||
public Pair<FileEditor[], FileEditorProvider[]> createNewDockContainerFor(VirtualFile file, FileEditorManagerImpl fileEditorManager) {
|
||||
public Pair<FileEditor[], FileEditorProvider[]> createNewDockContainerFor(@NotNull VirtualFile file, FileEditorManagerImpl fileEditorManager) {
|
||||
DockContainer container = getFactory(DockableEditorContainerFactory.TYPE).createContainer(null);
|
||||
register(container);
|
||||
|
||||
@@ -458,7 +465,7 @@ public class DockManagerImpl extends DockManager implements PersistentStateCompo
|
||||
center.add(myDockContentUiContainer, BorderLayout.CENTER);
|
||||
|
||||
myUiContainer.add(center, BorderLayout.CENTER);
|
||||
if (!(container instanceof DockContainer.Dialog)) {
|
||||
if (myStatusBar != null) {
|
||||
myUiContainer.add(myStatusBar.getComponent(), BorderLayout.SOUTH);
|
||||
}
|
||||
|
||||
@@ -498,6 +505,7 @@ public class DockManagerImpl extends DockManager implements PersistentStateCompo
|
||||
}
|
||||
|
||||
private void updateNorthPanel() {
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) return;
|
||||
myNorthPanel.setVisible(UISettings.getInstance().SHOW_NAVIGATION_BAR
|
||||
&& !(myContainer instanceof DockContainer.Dialog)
|
||||
&& !UISettings.getInstance().PRESENTATION_MODE);
|
||||
|
||||
+4
-1
@@ -69,7 +69,10 @@ public abstract class FileEditorManagerTestCase extends LightPlatformCodeInsight
|
||||
}
|
||||
|
||||
protected VirtualFile getFile(String path) {
|
||||
return LocalFileSystem.getInstance().refreshAndFindFileByPath(getTestDataPath() + path);
|
||||
String fullPath = getTestDataPath() + path;
|
||||
VirtualFile file = LocalFileSystem.getInstance().refreshAndFindFileByPath(fullPath);
|
||||
assertNotNull("Can't find " + fullPath, file);
|
||||
return file;
|
||||
}
|
||||
|
||||
protected void openFiles(String s) throws IOException, JDOMException, InterruptedException, ExecutionException {
|
||||
|
||||
+19
-1
@@ -18,17 +18,24 @@ package com.intellij.tasks.context;
|
||||
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager;
|
||||
import com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl;
|
||||
import com.intellij.ui.docking.DockContainer;
|
||||
import com.intellij.ui.docking.DockManager;
|
||||
import com.intellij.ui.docking.impl.DockManagerImpl;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Dmitry Avdeev
|
||||
*/
|
||||
public class OpenEditorsContextProvider extends WorkingContextProvider {
|
||||
|
||||
private final FileEditorManagerImpl myFileEditorManager;
|
||||
private final DockManagerImpl myDockManager;
|
||||
|
||||
public OpenEditorsContextProvider(FileEditorManager fileEditorManager) {
|
||||
public OpenEditorsContextProvider(FileEditorManager fileEditorManager, DockManager dockManager) {
|
||||
myDockManager = (DockManagerImpl)dockManager;
|
||||
myFileEditorManager = fileEditorManager instanceof FileEditorManagerImpl ? (FileEditorManagerImpl)fileEditorManager : null;
|
||||
}
|
||||
|
||||
@@ -48,6 +55,8 @@ public class OpenEditorsContextProvider extends WorkingContextProvider {
|
||||
if (myFileEditorManager != null) {
|
||||
myFileEditorManager.writeExternal(element);
|
||||
}
|
||||
Element state = myDockManager.getState();
|
||||
element.addContent(state);
|
||||
}
|
||||
|
||||
public void loadContext(Element element) {
|
||||
@@ -55,6 +64,11 @@ public class OpenEditorsContextProvider extends WorkingContextProvider {
|
||||
myFileEditorManager.readExternal(element);
|
||||
myFileEditorManager.getMainSplitters().openFiles();
|
||||
}
|
||||
Element dockState = element.getChild("DockManager");
|
||||
if (dockState != null) {
|
||||
myDockManager.loadState(dockState);
|
||||
myDockManager.readState();
|
||||
}
|
||||
}
|
||||
|
||||
public void clearContext() {
|
||||
@@ -62,5 +76,9 @@ public class OpenEditorsContextProvider extends WorkingContextProvider {
|
||||
myFileEditorManager.closeAllFiles();
|
||||
myFileEditorManager.getMainSplitters().clear();
|
||||
}
|
||||
Set<DockContainer> containers = myDockManager.getContainers();
|
||||
for (DockContainer container : containers) {
|
||||
container.closeAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ public class WorkingContextManager {
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
private void loadContext(Element fromElement) {
|
||||
public void loadContext(Element fromElement) {
|
||||
for (WorkingContextProvider provider : Extensions.getExtensions(WorkingContextProvider.EP_NAME, myProject)) {
|
||||
try {
|
||||
Element child = fromElement.getChild(provider.getId());
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
<orderEntry type="module" module-name="git4idea" scope="TEST" />
|
||||
<orderEntry type="library" name="gson" level="project" />
|
||||
<orderEntry type="module" module-name="jira" scope="TEST" />
|
||||
<orderEntry type="module" module-name="testFramework" scope="TEST" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.tasks.context;
|
||||
|
||||
import com.intellij.openapi.editor.EditorFactory;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.testFramework.FileEditorManagerTestCase;
|
||||
import com.intellij.ui.docking.DockManager;
|
||||
import org.jdom.Element;
|
||||
|
||||
/**
|
||||
* @author Dmitry Avdeev
|
||||
*/
|
||||
public class EditorsContextTest extends FileEditorManagerTestCase {
|
||||
|
||||
public void testDockableContainer() throws Exception {
|
||||
|
||||
VirtualFile file = getFile("/foo.txt");
|
||||
myManager.openFile(file, false);
|
||||
DockManager dockManager = DockManager.getInstance(getProject());
|
||||
assertEquals(1, dockManager.getContainers().size());
|
||||
myManager.initDockableContentFactory();
|
||||
|
||||
myManager.openFileInNewWindow(file);
|
||||
assertEquals(2, dockManager.getContainers().size());
|
||||
|
||||
Element context = new Element("context");
|
||||
WorkingContextManager contextManager = WorkingContextManager.getInstance(getProject());
|
||||
contextManager.saveContext(context);
|
||||
assertEquals(2, context.getChild("editors").getChildren().size());
|
||||
assertEquals(2, EditorFactory.getInstance().getAllEditors().length);
|
||||
|
||||
contextManager.clearContext();
|
||||
assertEquals(1, dockManager.getContainers().size());
|
||||
assertEquals(0, EditorFactory.getInstance().getAllEditors().length);
|
||||
|
||||
//contextManager.loadContext(context);
|
||||
//assertEquals(2, dockManager.getContainers().size());
|
||||
//Editor[] editors = EditorFactory.getInstance().getAllEditors();
|
||||
//assertEquals(2, editors.length);
|
||||
//
|
||||
//contextManager.clearContext();
|
||||
}
|
||||
|
||||
protected String getBasePath() {
|
||||
return "/plugins/tasks/tasks-tests/testData/context";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isCommunity() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
Reference in New Issue
Block a user