misc
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / actions / PHPOpenDeclarationEditorActon.java
index a84c8bf..4d2e8e5 100644 (file)
@@ -77,6 +77,7 @@ public class PHPOpenDeclarationEditorActon extends ActionDelegate implements IEd
       ITextSelection selection = (ITextSelection) fEditor.getSelectionProvider().getSelection();
       IDocument doc = fEditor.getDocumentProvider().getDocument(fEditor.getEditorInput());
       int pos = selection.getOffset();
+    //  System.out.println(selection.getText());
       String word = getPHPIdentifier(doc, pos);
       //      System.out.println(word);
       if (word != null && !word.equals("")) {
@@ -94,7 +95,7 @@ public class PHPOpenDeclarationEditorActon extends ActionDelegate implements IEd
                 new ListContentProvider(),
                 new LabelProvider(),
                 "Select the resources to open.");
-                                               listSelectionDialog.setTitle("Multiple declarations found");
+            listSelectionDialog.setTitle("Multiple declarations found");
             if (listSelectionDialog.open() == Window.OK) {
               Object[] locations = listSelectionDialog.getResult();
               if (locations != null) {
@@ -103,7 +104,11 @@ public class PHPOpenDeclarationEditorActon extends ActionDelegate implements IEd
                     PHPIdentifierLocation location = (PHPIdentifierLocation) locations[i];
                     String filename = workspaceLocation + location.getFilename();
                     //                                 System.out.println(filename);
-                    PHPeclipsePlugin.getDefault().openFileInTextEditor(filename, 0, word);
+                    if (location.getOffset() >= 0) {
+                      PHPeclipsePlugin.getDefault().openFileAndGotoOffset(filename, location.getOffset(), word.length());
+                    } else {
+                      PHPeclipsePlugin.getDefault().openFileAndFindString(filename, word);
+                    }
                   }
                 } catch (CoreException e) {
                   // TODO Auto-generated catch block
@@ -116,8 +121,11 @@ public class PHPOpenDeclarationEditorActon extends ActionDelegate implements IEd
               PHPIdentifierLocation location = (PHPIdentifierLocation) list.get(0);
               String filename = workspaceLocation + location.getFilename();
               //                                       System.out.println(filename);
-              PHPeclipsePlugin.getDefault().openFileInTextEditor(filename, 0, word);
-
+              if (location.getOffset() >= 0) {
+                PHPeclipsePlugin.getDefault().openFileAndGotoOffset(filename, location.getOffset(), word.length());
+              } else {
+                PHPeclipsePlugin.getDefault().openFileAndFindString(filename, word);
+              }
             } catch (CoreException e) {
               // TODO Auto-generated catch block
               e.printStackTrace();
@@ -134,29 +142,6 @@ public class PHPOpenDeclarationEditorActon extends ActionDelegate implements IEd
     }
   }
 
-  //  public static void openContextHelp(String word) {
-  //    IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore();
-  //    if (store.getBoolean(PHPHelpPlugin.PHP_CHM_ENABLED)) {
-  //      String[] arguments = { store.getString(PHPHelpPlugin.PHP_CHM_FILE), word };
-  //      MessageFormat form = new MessageFormat(store.getString(PHPHelpPlugin.PHP_CHM_COMMAND));
-  //      try {
-  //        Runtime runtime = Runtime.getRuntime();
-  //        String command = form.format(arguments);
-  //
-  //        runtime.exec(command);
-  //      } catch (IOException e) {
-  //      }
-  //    } else {
-  //      IHelp help = WorkbenchHelp.getHelpSupport();
-  //      if (help != null) {
-  //        PHPFunctionHelpResource helpResource = new PHPFunctionHelpResource(word);
-  //        WorkbenchHelp.getHelpSupport().displayHelpResource(helpResource);
-  //      } else {
-  //        //   showMessage(shell, dialogTitle, ActionMessages.getString("Open help not available"), false); //$NON-NLS-1$
-  //      }
-  //    }
-  //  }
-
   private String getPHPIdentifier(IDocument doc, int pos) {
     Point word = PHPWordExtractor.findWord(doc, pos);
     if (word != null) {