Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/selection/TextEditorSelectionParticipant.java')
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/selection/TextEditorSelectionParticipant.java76
1 files changed, 38 insertions, 38 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/selection/TextEditorSelectionParticipant.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/selection/TextEditorSelectionParticipant.java
index 3750cb371c..8cef83aa58 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/selection/TextEditorSelectionParticipant.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/selection/TextEditorSelectionParticipant.java
@@ -3,7 +3,7 @@
* 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
******************************************************************************/
@@ -14,10 +14,10 @@ import org.eclipse.jface.viewers.IPostSelectionProvider;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jpt.core.internal.IJpaContentNode;
import org.eclipse.jpt.core.internal.IJpaFile;
import org.eclipse.jpt.core.internal.ITextRange;
import org.eclipse.jpt.core.internal.JptCorePlugin;
+import org.eclipse.jpt.core.internal.context.base.IJpaContextNode;
import org.eclipse.jpt.ui.internal.views.AbstractJpaView;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
@@ -25,23 +25,23 @@ import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.IPropertyListener;
import org.eclipse.ui.texteditor.ITextEditor;
-public class TextEditorSelectionParticipant
- implements ISelectionParticipant
+public class TextEditorSelectionParticipant
+ implements IJpaSelectionParticipant
{
- private final ISelectionManager selectionManager;
+ private final IJpaSelectionManager selectionManager;
final ITextEditor textEditor;
-
+
private final IPropertyListener editorInputListener;
-
+
private final ISelectionChangedListener editorSelectionListener;
-
- private Selection currentSelection;
-
+
+ private IJpaSelection currentSelection;
+
private boolean forwardSelection = true; // TODO this just smells wrong ~bjv
-
-
- public TextEditorSelectionParticipant(ISelectionManager selectionManager, ITextEditor textEditor) {
+
+
+ public TextEditorSelectionParticipant(IJpaSelectionManager selectionManager, ITextEditor textEditor) {
super();
this.selectionManager = selectionManager;
this.textEditor = textEditor;
@@ -52,20 +52,20 @@ public class TextEditorSelectionParticipant
this.currentSelection = this.calculateSelection();
}
- // ********** ISelectionParticipant implementation **********
+ // ********** IJpaSelectionParticipant implementation **********
- public Selection getSelection() {
+ public IJpaSelection getSelection() {
return this.currentSelection;
}
-
- public void selectionChanged(SelectionEvent evt) {
- Selection newSelection = evt.getSelection();
-
- if ((newSelection == Selection.NULL_SELECTION)
+
+ public void selectionChanged(JpaSelectionEvent evt) {
+ IJpaSelection newSelection = evt.getSelection();
+
+ if ((newSelection == IJpaSelection.NULL_SELECTION)
|| newSelection.equals(this.currentSelection)) {
return;
}
-
+
this.forwardSelection = false;
ITextRange textRange = newSelection.getSelectedNode().selectionTextRange();
if (textRange != null) {
@@ -73,11 +73,11 @@ public class TextEditorSelectionParticipant
}
this.forwardSelection = true;
}
-
+
public boolean disposeOnHide() {
return true;
}
-
+
public void dispose() {
this.textEditor.removePropertyListener(this.editorInputListener);
this.postSelectionProvider().removePostSelectionChangedListener(this.editorSelectionListener);
@@ -86,25 +86,25 @@ public class TextEditorSelectionParticipant
// ********** internal methods **********
- private Selection calculateSelection() {
+ private IJpaSelection calculateSelection() {
ISelection selection = this.textEditor.getSelectionProvider().getSelection();
if (! (selection instanceof ITextSelection)) {
- return Selection.NULL_SELECTION;
+ return IJpaSelection.NULL_SELECTION;
}
IJpaFile jpaFile = this.jpaFile();
if (jpaFile == null) {
- return Selection.NULL_SELECTION;
+ return IJpaSelection.NULL_SELECTION;
}
- IJpaContentNode selectedNode = jpaFile.getContentNode(((ITextSelection) selection).getOffset());
+ IJpaContextNode selectedNode = jpaFile.contextNode(((ITextSelection) selection).getOffset());
if (selectedNode == null) {
- return Selection.NULL_SELECTION;
+ return IJpaSelection.NULL_SELECTION;
}
- return new Selection(selectedNode);
+ return new JpaSelection(selectedNode);
}
-
+
private IJpaFile jpaFile() {
IEditorInput input = this.textEditor.getEditorInput();
if ( ! (input instanceof IFileEditorInput)) {
@@ -112,7 +112,7 @@ public class TextEditorSelectionParticipant
}
return JptCorePlugin.jpaFile(((IFileEditorInput) input).getFile());
}
-
+
private IPostSelectionProvider postSelectionProvider() {
return (IPostSelectionProvider) this.textEditor.getSelectionProvider();
}
@@ -121,7 +121,7 @@ public class TextEditorSelectionParticipant
// ********** listener callbacks **********
void editorInputChanged() {
- Selection newSelection = this.calculateSelection();
+ IJpaSelection newSelection = this.calculateSelection();
if (newSelection.equals(this.currentSelection)) {
return;
}
@@ -130,15 +130,15 @@ public class TextEditorSelectionParticipant
this.selectionManager.select(newSelection);
}
}
-
+
void editorSelectionChanged(SelectionChangedEvent event) {
- Selection newSelection = this.calculateSelection();
+ IJpaSelection newSelection = this.calculateSelection();
if (newSelection.equals(this.currentSelection)) {
return;
}
this.currentSelection = newSelection;
- // bug 188344 - won't actively change selection manager selection if
+ // bug 188344 - won't actively change selection manager selection if
// a "JPA" view is the active (and presumably selecting) view
if (this.textEditor.getEditorSite().getPage().getActivePart() instanceof AbstractJpaView) {
return;
@@ -148,7 +148,7 @@ public class TextEditorSelectionParticipant
this.selectionManager.select(newSelection);
}
}
-
+
// ********** listeners **********
@@ -163,8 +163,8 @@ public class TextEditorSelectionParticipant
}
}
}
-
-
+
+
private class EditorSelectionListener implements ISelectionChangedListener {
EditorSelectionListener() {
super();

Back to the top