aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDawid Pakuła2018-08-01 10:22:25 -0400
committerDawid Pakuła2018-08-01 10:22:25 -0400
commit0c44267ea3b3a812400c07a24538b60dc025104f (patch)
treeefe9acd2f8633950a222e2c39a3e9bc99a9187f5
parentc828e85f9b7e28588f2ae04c057e87c4f747fd9c (diff)
downloadorg.eclipse.pdt-0c44267ea3b3a812400c07a24538b60dc025104f.tar.gz
org.eclipse.pdt-0c44267ea3b3a812400c07a24538b60dc025104f.tar.xz
org.eclipse.pdt-0c44267ea3b3a812400c07a24538b60dc025104f.zip
No bug - Fix selection support
Signed-off-by: Dawid Pakuła <zulus@w3des.net>
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/dialogs/PHPSourceActionDialog.java24
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/handlers/GettersSettersHandler.java5
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/handlers/OverrideImplementHandler.java5
3 files changed, 18 insertions, 16 deletions
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/dialogs/PHPSourceActionDialog.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/dialogs/PHPSourceActionDialog.java
index 00f673f78..505d5a54a 100644
--- a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/dialogs/PHPSourceActionDialog.java
+++ b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/dialogs/PHPSourceActionDialog.java
@@ -23,10 +23,7 @@ import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.resource.StringConverter;
import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.viewers.CheckboxTreeViewer;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.*;
import org.eclipse.php.internal.ui.PHPUiPlugin;
import org.eclipse.php.internal.ui.preferences.PHPCodeTemplatePreferencePage;
import org.eclipse.swt.SWT;
@@ -153,7 +150,7 @@ public class PHPSourceActionDialog extends CheckedTreeSelectionDialog {
try {
restoreWidgetsValue(methods);
} catch (ModelException e) {
-
+ PHPUiPlugin.log(e);
}
}
@@ -189,7 +186,18 @@ public class PHPSourceActionDialog extends CheckedTreeSelectionDialog {
if (editor == null) {
return -1;
}
- int offset = ((ITextSelection) editor.getSelectionProvider().getSelection()).getOffset();
+ ISelection selection = editor.getSelectionProvider().getSelection();
+ int offset = -1;
+ if (selection instanceof IStructuredSelection) {
+ Object firstElement = ((IStructuredSelection) selection).getFirstElement();
+ if (firstElement instanceof ISourceReference) {
+ offset = ((ISourceReference) firstElement).getSourceRange().getOffset() + 1;
+ }
+ }
+ if (offset == -1 && selection instanceof ITextSelection) {
+ offset = ((ITextSelection) selection).getOffset();
+
+ }
for (int i = 0; i < members.length; i++) {
IMember curr = (IMember) members[i];
@@ -506,8 +514,8 @@ public class PHPSourceActionDialog extends CheckedTreeSelectionDialog {
}
/***
- * Set insert position valid input is 0 for the first position, 1 for the last
- * position, > 1 for all else.
+ * Set insert position valid input is 0 for the first position, 1 for the
+ * last position, > 1 for all else.
*/
private void setInsertPosition(int insert) {
fCurrentPositionIndex = insert;
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/handlers/GettersSettersHandler.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/handlers/GettersSettersHandler.java
index 248232fe4..619654034 100644
--- a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/handlers/GettersSettersHandler.java
+++ b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/handlers/GettersSettersHandler.java
@@ -74,10 +74,7 @@ public class GettersSettersHandler extends AbstractHandler {
// The action is run from a view.
if (selection instanceof IStructuredSelection) {
execute((IStructuredSelection) selection);
- }
-
- // The action is run from a editor.
- if (selection instanceof ITextSelection) {
+ } else if (selection instanceof ITextSelection) {
execute(event, (ITextSelection) selection);
}
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/handlers/OverrideImplementHandler.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/handlers/OverrideImplementHandler.java
index 1d67a28d1..8e243656f 100644
--- a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/handlers/OverrideImplementHandler.java
+++ b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/handlers/OverrideImplementHandler.java
@@ -72,10 +72,7 @@ public class OverrideImplementHandler extends AbstractHandler {
// Selection are on view.
if (selection instanceof IStructuredSelection) {
execute(event, ((IStructuredSelection) selection));
- }
-
- // Selection are on editor.
- if (selection instanceof ITextSelection) {
+ } else if (selection instanceof ITextSelection) {
execute(event, (ITextSelection) selection);
}