aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Elder2013-10-11 13:21:41 (EDT)
committerDani Megert2013-10-18 11:14:27 (EDT)
commit69fa5ef99e4c20aa47314f505d6385c1afa2b303 (patch)
tree863ccf7a812618ddab6dce38b043c5330993f240
parent49bc03a9c1ed82926b6849c8590f1498be22959f (diff)
downloadeclipse.platform.ui-69fa5ef99e4c20aa47314f505d6385c1afa2b303.zip
eclipse.platform.ui-69fa5ef99e4c20aa47314f505d6385c1afa2b303.tar.gz
eclipse.platform.ui-69fa5ef99e4c20aa47314f505d6385c1afa2b303.tar.bz2
Bug 407422: Mylyn context deactivation does not always close editors I20131022-1300I20131022-0800refs/changes/17/17317/4
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java5
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/ApiTestSuite.java1
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/Bug407422Test.java119
3 files changed, 123 insertions, 2 deletions
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java
index 8f006aa..cf3029f 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java
@@ -2265,10 +2265,11 @@ public class WorkbenchPage extends CompatibleWorkbenchPage implements
* @see org.eclipse.ui.IWorkbenchPage#getEditors()
*/
public IEditorPart[] getEditors() {
- int length = editorReferences.size();
+ final IEditorReference[] editorReferences = getEditorReferences();
+ int length = editorReferences.length;
IEditorPart[] editors = new IEditorPart[length];
for (int i = 0; i < length; i++) {
- editors[i] = editorReferences.get(i).getEditor(true);
+ editors[i] = editorReferences[i].getEditor(true);
}
return editors;
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/ApiTestSuite.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/ApiTestSuite.java
index d6d499d..2c09199 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/ApiTestSuite.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/ApiTestSuite.java
@@ -81,5 +81,6 @@ public class ApiTestSuite extends TestSuite {
//addTest(new TestSuite(IWorkbenchPartTestableTests.class));
addTest(new TestSuite(ArbitraryPropertyTest.class));
addTest(new TestSuite(LifecycleViewTest.class));
+ addTest(new TestSuite(Bug407422Test.class));
}
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/Bug407422Test.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/Bug407422Test.java
new file mode 100644
index 0000000..b222f0d
--- /dev/null
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/Bug407422Test.java
@@ -0,0 +1,119 @@
+/*******************************************************************************
+ * Copyright (c) 2013 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+
+package org.eclipse.ui.tests.api;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IEditorReference;
+import org.eclipse.ui.IPartListener2;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPartReference;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.ui.tests.harness.util.FileUtil;
+import org.eclipse.ui.tests.harness.util.UITestCase;
+import org.junit.Test;
+
+/**
+ * @since 3.5
+ *
+ */
+public class Bug407422Test extends UITestCase {
+
+ /**
+ * @param testName
+ */
+ public Bug407422Test(String testName) {
+ super(testName);
+ }
+
+ @Test
+ public void test() throws CoreException {
+ final IWorkbenchWindow window = openTestWindow();
+ final IWorkbenchPage page = window.getActivePage();
+ final String EDITOR_ID = "org.eclipse.ui.DefaultTextEditor";
+
+ final IProject project = FileUtil.createProject("Bug407422Test");
+ final IFile file1 = FileUtil.createFile("file1.txt", project);
+ final IFile file2 = FileUtil.createFile("file2.txt", project);
+ final IFile file3 = FileUtil.createFile("file3.txt", project);
+
+ final FileEditorInput input1 = new FileEditorInput(file1);
+ final FileEditorInput input2 = new FileEditorInput(file2);
+ final FileEditorInput input3 = new FileEditorInput(file3);
+
+ final List<IWorkbenchPartReference> openedParts = new ArrayList<IWorkbenchPartReference>();
+
+ page.addPartListener(new IPartListener2() {
+
+ public void partVisible(IWorkbenchPartReference partRef) { }
+
+ public void partOpened(IWorkbenchPartReference partRef) {
+ openedParts.add(partRef);
+ }
+
+ public void partInputChanged(IWorkbenchPartReference partRef) {}
+
+ public void partHidden(IWorkbenchPartReference partRef) {}
+
+ public void partDeactivated(IWorkbenchPartReference partRef) {}
+
+ public void partClosed(IWorkbenchPartReference partRef) {
+ openedParts.remove(partRef);
+ }
+
+ public void partBroughtToTop(IWorkbenchPartReference partRef) { }
+
+ public void partActivated(IWorkbenchPartReference partRef) {}
+ });
+
+ // With nothing open, getEditors should return an empty array
+ final IEditorPart[] editorParts0 = page.getEditors();
+ assertEquals(0, editorParts0.length);
+
+ // open some editors
+ final IEditorReference[] openRefs = page.openEditors(new IEditorInput[] {input1, input2, input3},
+ new String[] {EDITOR_ID,EDITOR_ID,EDITOR_ID}, 0);
+ assertEquals(3, openRefs.length);
+
+ // openEditors will only 'open' the first editor. The others will lazily
+ // opened, if the user clicks on their tabs...
+ assertEquals(1, openedParts.size());
+
+ // Close all editors...
+ page.closeAllEditors(true);
+ // Verify that there are no editors open...
+ final IEditorReference[] editorReferences2 = page.getEditorReferences();
+ assertEquals(0, editorReferences2.length);
+ // ... and that the one we did open was closed...
+ assertEquals(0, openedParts.size());
+
+ // getEditors() should return an empty array, again.
+ final IEditorPart[] editorParts = page.getEditors();
+ // In bug 407422, the actual returned array has length 2,
+ // one editor part for each of the lazily loaded editors.
+ assertEquals(0, editorParts.length);
+
+
+
+
+
+
+ }
+
+}