Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Vosburgh2016-07-12 18:13:41 -0400
committerBrian Vosburgh2016-07-13 14:27:18 -0400
commit5005859beaec512a193157882ecf6a6c3b8b4781 (patch)
tree4dd422289f78e6b0b80791d9c54947225b44c1e7
parent9ef8eb7e39d4b67a2ea6f3ea0fa955ce3130d07c (diff)
downloadwebtools.dali-5005859beaec512a193157882ecf6a6c3b8b4781.tar.gz
webtools.dali-5005859beaec512a193157882ecf6a6c3b8b4781.tar.xz
webtools.dali-5005859beaec512a193157882ecf6a6c3b8b4781.zip
Fix JPA Selection flakiness in Java editor
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/selection/JpaTextEditorManager.java21
1 files changed, 16 insertions, 5 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/selection/JpaTextEditorManager.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/selection/JpaTextEditorManager.java
index 12bb74a5a4..24b2842dc8 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/selection/JpaTextEditorManager.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/selection/JpaTextEditorManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2012 Oracle. All rights reserved.
+ * Copyright (c) 2006, 2016 Oracle. 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.
@@ -36,6 +36,7 @@ import org.eclipse.jpt.jpa.core.JpaStructureNode;
import org.eclipse.jpt.jpa.ui.JpaFileModel;
import org.eclipse.jpt.jpa.ui.internal.plugin.JptJpaUiPlugin;
import org.eclipse.jpt.jpa.ui.selection.JpaEditorManager;
+import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IFileEditorInput;
@@ -261,12 +262,18 @@ class JpaTextEditorManager
/**
* Pre-condition: executing on the UI thread.
- * If the new JPA selection is not <code>null</code> and it is different
- * from the text editor's current JPA selection, modify the text editor's
- * selection.
+ * <p>
+ * If all the following are true:<ul>
+ * <li>the new JPA selection is non-<code>null</code>
+ * <li>the text editor does <em>not</em> have the current focus
+ * (i.e. the selection change event did not originate from the text editor)
+ * <li>the new JPA selection is different from the text editor's
+ * current JPA selection
+ * </ul>
+ * then modify the text editor's selection.
*/
/* CU private */ void setTextEditorJpaSelection_(JpaStructureNode selection) {
- if ((selection != null) && (selection != this.getTextEditorJpaSelection())) {
+ if ((selection != null) && ( ! this.textEditorHasFocus()) && (selection != this.getTextEditorJpaSelection())) {
this.setTextEditorSelection(selection.getSelectionTextRange());
}
}
@@ -291,6 +298,10 @@ class JpaTextEditorManager
return (selProvider == null) ? null : this.getTextEditorJpaSelection(selProvider.getSelection());
}
+ private boolean textEditorHasFocus() {
+ return this.textEditor.getAdapter(Control.class).isFocusControl();
+ }
+
private JpaStructureNode getTextEditorJpaSelection(ISelection selection) {
return (selection instanceof ITextSelection) ? this.getTextEditorJpaSelection((ITextSelection) selection) : null;
}

Back to the top