Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Vosburgh2016-07-12 22:13:41 +0000
committerBrian Vosburgh2017-05-17 20:34:49 +0000
commit5d0b6143a28738fbbb1be563d75741bd1436ca80 (patch)
tree9e5ab9570a77212b898a32a33ff23b347bcce982
parentba298370c5733ad57420ff626177332f3d2ad140 (diff)
downloadwebtools.dali-5d0b6143a28738fbbb1be563d75741bd1436ca80.tar.gz
webtools.dali-5d0b6143a28738fbbb1be563d75741bd1436ca80.tar.xz
webtools.dali-5d0b6143a28738fbbb1be563d75741bd1436ca80.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.java18
1 files changed, 15 insertions, 3 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..c298bc321a 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
@@ -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,19 @@ 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
+ * <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 +299,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