Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbvosburgh2012-04-24 18:25:36 +0000
committerbvosburgh2012-04-24 18:25:36 +0000
commitf28293aef3fef38c82529caa16dbe710b50c2cfc (patch)
tree868d6ffb57a285c092d54789d61b2b3e697462cd
parentfbc9be3cae33183dd17c6935954f13d71fdaf07c (diff)
downloadwebtools.dali-f28293aef3fef38c82529caa16dbe710b50c2cfc.tar.gz
webtools.dali-f28293aef3fef38c82529caa16dbe710b50c2cfc.tar.xz
webtools.dali-f28293aef3fef38c82529caa16dbe710b50c2cfc.zip
[377064] fix CCE when ITextEditor does not return an IPostSelectionProvider - patch contributed by S. Ptaszkiewicz (IBM)
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/selection/TextEditorSelectionParticipant.java17
1 files changed, 13 insertions, 4 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/selection/TextEditorSelectionParticipant.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/selection/TextEditorSelectionParticipant.java
index dbc24cc8b2..208e8198a5 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/selection/TextEditorSelectionParticipant.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/selection/TextEditorSelectionParticipant.java
@@ -1,11 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved.
+ * Copyright (c) 2006, 2012 Oracle 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:
* Oracle - initial API and implementation
+ * IBM Corporation - modified to fix bug 377064
******************************************************************************/
package org.eclipse.jpt.jpa.ui.internal.selection;
@@ -13,6 +14,7 @@ import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.viewers.IPostSelectionProvider;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jpt.common.core.utility.TextRange;
import org.eclipse.jpt.jpa.core.JpaFile;
@@ -49,7 +51,9 @@ public class TextEditorSelectionParticipant
this.editorInputListener = new EditorInputListener();
this.textEditor.addPropertyListener(this.editorInputListener);
this.editorSelectionListener = new EditorSelectionListener();
- this.getPostSelectionProvider().addPostSelectionChangedListener(this.editorSelectionListener);
+ IPostSelectionProvider postSelectionProvider = this.getPostSelectionProvider();
+ if (postSelectionProvider != null)
+ postSelectionProvider.addPostSelectionChangedListener(this.editorSelectionListener);
this.currentSelection = this.calculateSelection();
}
@@ -86,7 +90,9 @@ public class TextEditorSelectionParticipant
public void dispose() {
this.textEditor.removePropertyListener(this.editorInputListener);
- this.getPostSelectionProvider().removePostSelectionChangedListener(this.editorSelectionListener);
+ IPostSelectionProvider postSelectionProvider = this.getPostSelectionProvider();
+ if (postSelectionProvider != null)
+ postSelectionProvider.removePostSelectionChangedListener(this.editorSelectionListener);
}
@@ -141,7 +147,10 @@ public class TextEditorSelectionParticipant
}
protected IPostSelectionProvider getPostSelectionProvider() {
- return (IPostSelectionProvider) this.textEditor.getSelectionProvider();
+ ISelectionProvider selectionProvider = this.textEditor.getSelectionProvider();
+ if (selectionProvider instanceof IPostSelectionProvider)
+ return (IPostSelectionProvider) selectionProvider;
+ return null;
}

Back to the top