summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerge Beauchamp2013-09-24 08:26:52 (EDT)
committerSergey Prigogin2013-09-25 12:28:14 (EDT)
commit1e450cdd3761d49e8cfebaf5eaa11506762b9c71 (patch)
tree3fe930424cbce8f02b79d0f318cfd3886dc1eb31
parentaf8f41dd1bfad6fe41888ae310049d3fc59452fd (diff)
downloadorg.eclipse.cdt-1e450cdd3761d49e8cfebaf5eaa11506762b9c71.zip
org.eclipse.cdt-1e450cdd3761d49e8cfebaf5eaa11506762b9c71.tar.gz
org.eclipse.cdt-1e450cdd3761d49e8cfebaf5eaa11506762b9c71.tar.bz2
Bug 417909 - Opening a large file from a progress dialog causes therefs/changes/21/16721/7
scalability dialog to disappear Change-Id: I1840fe1ac53a78c2d8d7c540474436faab08d8b1 Signed-off-by: Serge Beauchamp <sergebeauchamp@mac.com> Reviewed-on: https://git.eclipse.org/r/16721 Reviewed-by: Sergey Prigogin <eclipse.sprigogin@gmail.com> IP-Clean: Sergey Prigogin <eclipse.sprigogin@gmail.com> Tested-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/BasicCEditorTest.java65
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java5
2 files changed, 67 insertions, 3 deletions
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/BasicCEditorTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/BasicCEditorTest.java
index f30cdf9..b5ab03b 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/BasicCEditorTest.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/BasicCEditorTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2012 Wind River Systems, Inc. and others.
+ * Copyright (c) 2006, 2013 Wind River Systems, Inc. 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
@@ -8,6 +8,7 @@
* Contributors:
* Anton Leherbauer (Wind River Systems) - initial API and implementation
* Andrew Eidsness - fix and test for bug 278632
+ * Serge Beauchamp (Freescale Semiconductor) - Bug 417909
*******************************************************************************/
package org.eclipse.cdt.ui.tests.text;
@@ -27,6 +28,8 @@ import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.text.DocumentEvent;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IDocumentListener;
@@ -37,10 +40,13 @@ import org.eclipse.swt.custom.StyleRange;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorRegistry;
import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.ide.IDE;
@@ -65,6 +71,7 @@ import org.eclipse.cdt.ui.text.IColorManager;
import org.eclipse.cdt.internal.core.model.ExternalTranslationUnit;
import org.eclipse.cdt.internal.ui.editor.CEditor;
+import org.eclipse.cdt.internal.ui.editor.CEditorMessages;
import org.eclipse.cdt.internal.ui.util.EditorUtility;
/**
@@ -517,4 +524,60 @@ public class BasicCEditorTest extends BaseUITestCase {
int newOffset= ((ITextSelection)fEditor.getSelectionProvider().getSelection()).getOffset();
assertEquals(offset, newOffset);
}
+
+ // See Bug 417909 - Opening a large file from a progress dialog causes the scalability dialog to disappear
+ public void testScalabilityDialogNotDismissedInadvertently()
+ throws Exception {
+
+ // 1. Create a project with a very large source file.
+ fCProject = EditorTestHelper.createCProject("ceditor",
+ "resources/ceditor", false, false);
+
+ // 1a. Dynamically create the large source file.
+ String originalFile = "/ceditor/src/main.cpp";
+ String file = "/ceditor/src/large_main.cpp";
+ ResourceTestHelper.copy(originalFile, file);
+
+ setUpEditor(file);
+
+ StringBuilder buffer = new StringBuilder(fDocument.get());
+
+ buffer.append("unsigned long c[250000] = {\n");
+ for (int i = 0; i < 12499; i++)
+ buffer.append(" 0x0,0x1,0x0,0x1,0x0,0x1,0x0,0x1,0x0,0x1,0x0,0x1,0x0,0x1,0x0,0x1,0x0,0x1,0x0,0x1,\n");
+ buffer.append(" 0x0,0x1,0x0,0x1,0x0,0x1,0x0,0x1,0x0,0x1,0x0,0x1,0x0,0x1,0x0,0x1,0x0,0x1,0x0,0x1\n};\n");
+
+ fDocument.set(buffer.toString());
+ fEditor.doSave(new NullProgressMonitor());
+ EditorTestHelper.closeEditor(fEditor);
+
+ // 2. Create and open a progress dialog window.
+ IWorkbenchWindow window = EditorTestHelper.getActiveWorkbenchWindow();
+ ProgressMonitorDialog dialog = new ProgressMonitorDialog(
+ window.getShell());
+ dialog.open();
+
+ // 3. Open the large source file in the editor, which should cause the
+ // scalability dialog to be displayed.
+ setUpEditor(file);
+
+ // 4. Close the progress dialog window
+ dialog.close();
+
+ // 5. Verify that the scalability dialog has not been closed
+ // unexpectedly.
+ Shell scalabilityDialog = null;
+ Shell[] shells = Display.getCurrent().getShells();
+ for (Shell shell : shells) {
+ if (shell.getText().equals(CEditorMessages.Scalability_info)) {
+ scalabilityDialog = shell;
+ break;
+ }
+ }
+
+ assertNotNull(scalabilityDialog);
+ scalabilityDialog.close();
+ EditorTestHelper.closeEditor(fEditor);
+ }
+
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java
index c829a0f..5388643 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java
@@ -13,6 +13,7 @@
* Sergey Prigogin (Google)
* Axel Mueller - [289339] Surround with
* Tomasz Wesolowski - [320561] Override indicators
+ * Serge Beauchamp (Freescale Semiconductor) - Bug 417909
*******************************************************************************/
package org.eclipse.cdt.internal.ui.editor;
@@ -1551,7 +1552,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
// Alert users that scalability mode should be turned on
if (getPreferenceStore().getBoolean(PreferenceConstants.SCALABILITY_ALERT)) {
MessageDialogWithToggle dialog = new MessageDialogWithToggle(
- Display.getCurrent().getActiveShell(),
+ getSite().getShell(),
CEditorMessages.Scalability_info,
null,
CEditorMessages.Scalability_message,
@@ -1567,7 +1568,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
PreferenceConstants.getPreferenceStore().setValue(PreferenceConstants.SCALABILITY_ALERT, !getToggleState());
super.buttonPressed(buttonId);
if (buttonId == IDialogConstants.YES_ID) {
- PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(Display.getCurrent().getActiveShell(),
+ PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(getSite().getShell(),
"org.eclipse.cdt.ui.preferences.CScalabilityPreferences", null, null); //$NON-NLS-1$
dialog.open();
}