Package org.eclipse.dltk.core

Examples of org.eclipse.dltk.core.IModelElement


    setEnabled(false);
  }

  private static boolean canEnable(IStructuredSelection selection)
      throws CoreException {
    IModelElement element = getPHPElement(selection);
    if (element == null)
      return false;
    return isRenameAvailable(element);
  }
View Full Code Here


      return null;
    return (IModelElement) first;
  }

  public void run(IStructuredSelection selection) {
    IModelElement element = getPHPElement(selection);
    if (element == null) {
      super.run(selection);
      return;
    }
    try {
View Full Code Here

    setEnabled(true);
  }

  public void run(ITextSelection selection) {
    try {
      IModelElement element = getPHPElement();
      if (element != null && isRenameAvailable(element)) {
        run(element);
        return;
      }
    } catch (CoreException e) {
View Full Code Here

        PHPUIMessages.RenamePHPElementAction_name,
        PHPUIMessages.RenamePHPElementAction_not_available);
  }

  public boolean canRun() throws ModelException {
    IModelElement element = getPHPElement();
    if (element == null)
      return false;
    try {
      return isRenameAvailable(element);
    } catch (CoreException e) {
View Full Code Here

    ITextEditor editorPart = (ITextEditor) adaptableObject;

    boolean isPHPFile = false;

    if (editorPart instanceof PHPStructuredEditor) {
      IModelElement modelElement = ((PHPStructuredEditor) editorPart)
          .getModelElement();
      isPHPFile = modelElement != null
          && PHPToolkitUtil.isPhpElement(modelElement);
    } else {
      IResource resource = (IResource) editorPart.getEditorInput()
View Full Code Here

      if (!(obj instanceof IModelElement))
        // the selection contains an object that is not a model element
        return null;

      IModelElement element = (IModelElement) obj;
      IResource resource = element.getResource();

      if (resource == null)
        // the selection contains a model element without a
        // corresponding resource on the file system
        return null;
View Full Code Here

   *
   * @return the IFile that this strategy is operating on
   */
  protected IFile getFile(ITextEditor textEditor) {
    if (textEditor != null) {
      IModelElement modelElement = EditorUtility
          .getEditorInputModelElement(textEditor, false);
      if (modelElement != null) {
        return (IFile) modelElement.getResource();
      }
    }
    return null;
  }
View Full Code Here

    if (region == null) {
      return null;
    }

    IModelElement input = EditorUtility.getEditorInputModelElement(editor,
        false);
    if (input == null) {
      return null;
    }

    PHPVersion phpVersion = ProjectOptions.getPhpVersion(input
        .getScriptProject().getProject());
    boolean namespacesSupported = phpVersion.isGreaterThan(PHPVersion.PHP5); // PHP
                                          // 5.3
                                          // and
                                          // greater

    IDocument document = textViewer.getDocument();
    int offset = region.getOffset();
    try {
      IRegion wordRegion = findWord(document, offset, namespacesSupported);
      if (wordRegion == null)
        return null;

      try {
        String text = document.get(wordRegion.getOffset(),
            wordRegion.getLength());
        if (text.equals(NEW)) {
          return null;
        }
      } catch (BadLocationException e) {
      }
      IModelElement[] elements = null;
      elements = ((ICodeAssist) input).codeSelect(wordRegion.getOffset(),
          wordRegion.getLength());
      if ((elements == null || elements.length == 0)
          && input instanceof ISourceModule) {
        elements = PHPModelUtils.getTypeInString((ISourceModule) input,
            wordRegion);

      }
      if (elements != null && elements.length > 0) {
        final IHyperlink link;
        if (elements.length == 1) {
          link = new ModelElementHyperlink(wordRegion, elements[0],
              new OpenAction(editor));
        } else {
          link = new ModelElementHyperlink(wordRegion,
              new ModelElementArray(elements), new OpenAction(
                  editor) {

                public void selectAndOpen(
                    IModelElement[] elements) {
                  if (elements == null
                      || elements.length == 0) {
                    IEditorStatusLine statusLine = null;
                    if (editor != null)
                      statusLine = (IEditorStatusLine) editor
                          .getAdapter(IEditorStatusLine.class);
                    if (statusLine != null)
                      statusLine
                          .setMessage(
                              true,
                              ActionMessages.OpenAction_error_messageBadSelection,
                              null);
                    getShell().getDisplay().beep();
                    return;
                  }
                  IModelElement element = elements[0];
                  if (elements.length > 1) {
                    element = OpenActionUtil
                        .selectModelElement(
                            elements,
                            getShell(),
                            ActionMessages.OpenAction_error_title,
                            ActionMessages.OpenAction_select_element);
                    if (element == null)
                      return;
                  }

                  int type = element.getElementType();
                  if (type == IModelElement.SCRIPT_PROJECT
                      || type == IModelElement.PROJECT_FRAGMENT
                      || type == IModelElement.SCRIPT_FOLDER)
                    element = EditorUtility
                        .getEditorInputModelElement(
View Full Code Here

    PHPStructuredEditor editor = EditorUtility.getPHPEditor(textViewer);
    if (editor == null) {
      return null;
    }

    IModelElement input = org.eclipse.dltk.internal.ui.editor.EditorUtility
        .getEditorInputModelElement(editor, false);
    if (!(input instanceof ISourceModule)) {
      return null;
    }
View Full Code Here

    if (fEditor == null || selection == null)
      return false;
    if (fEditor.getModelElement() instanceof ISourceModule) {
      ISourceModule sourceModule = (ISourceModule) fEditor
          .getModelElement();
      IModelElement element = getSelectionModelElement(
          selection.getOffset(), selection.getLength(), sourceModule);
      if (element == null) {
        return false;
      }
      switch (element.getElementType()) {
      case IModelElement.METHOD:
        return true;
      default:
        return false;
      }
View Full Code Here

TOP

Related Classes of org.eclipse.dltk.core.IModelElement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.