Package org.eclipse.php.internal.ui.editor

Examples of org.eclipse.php.internal.ui.editor.PHPStructuredEditor$InformationDispatchAction


  public void apply(ITextViewer viewer, char trigger, int stateMask,
      int offset) {

   
    IDocument document = viewer.getDocument();
    PHPStructuredEditor textEditor = (PHPStructuredEditor) ((PHPStructuredTextViewer) viewer)
        .getTextEditor();

    if (textEditor instanceof PHPStructuredEditor) {
      IModelElement editorElement = ((PHPStructuredEditor) textEditor)
          .getModelElement();
View Full Code Here


  @Override
  public Object execute(ExecutionEvent event) throws ExecutionException {
    final String commandId = event.getCommand().getId();
    final IEvaluationContext context = (IEvaluationContext) event.getApplicationContext();
   
    final PHPStructuredEditor editor = (PHPStructuredEditor) context.getVariable(ISources.ACTIVE_PART_NAME);
    final ITextSelection selection = (ITextSelection) editor.getSelectionProvider().getSelection();
   
    final StructuredTextInvocationContext assistInvocation = new StructuredTextInvocationContext(editor.getViewer(), selection.getOffset(), selection.getLength(), new HashMap());
   
    final ICompletionProposal[] proposals = phpCorrectionProcessor.computeQuickAssistProposals(assistInvocation);
   
    if (proposals == null || proposals.length == 0) {
      return null;
View Full Code Here

    try {
      IEvaluationContext context = (IEvaluationContext) evaluationContext;
      if (!(context.getVariable(ISources.ACTIVE_PART_NAME) instanceof PHPStructuredEditor)) {
        throw new IllegalArgumentException();
      }
      PHPStructuredEditor editor = (PHPStructuredEditor) context.getVariable(ISources.ACTIVE_PART_NAME);
     
      final ISelection selection = editor.getSelectionProvider().getSelection();
      if (!(selection instanceof ITextSelection)) {
        throw new IllegalArgumentException();
      }
      final int offset = ((ITextSelection)selection).getOffset();
      ITypedRegion partition = editor.getDocument().getPartition(offset);
      if (!partition.getType().equals(DOCUMENT_PART)) {
        setBaseEnabled(false);
      } else {
        setBaseEnabled(true);
      }
View Full Code Here

  }

  private String handleElement(ITextEditor textEditor,
      IModelElement modelElem, IDocument document) {
    if (textEditor instanceof PHPStructuredEditor) {
      PHPStructuredEditor editor = (PHPStructuredEditor) textEditor;
      if (editor.getTextViewer() != null
          && !editor.getTextViewer().isEditable()) {
        return null;
      }
    }
    if (modelElem instanceof ISourceModule) {
      handleFileDocBlock((ISourceModule) modelElem,
View Full Code Here

      IDocument document = getDocument();
      if (document == null)
        return false; // can't compute

      PHPStructuredEditor editor = fEditor;
      if (editor == null || editor.getCachedSelectedRange() == null)
        return false; // can't compute

      int caretLine = 0;
      try {
        caretLine = document.getLineOfOffset(editor
            .getCachedSelectedRange().x) + 1;
      } catch (BadLocationException x) {
        return false; // can't compute
      }
View Full Code Here

   * org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion,
   * boolean)
   */
  public IHyperlink[] detectHyperlinks(ITextViewer textViewer,
      IRegion region, boolean canShowMultipleHyperlinks) {
    final PHPStructuredEditor editor = org.eclipse.php.internal.ui.util.EditorUtility
        .getPHPEditor(textViewer);
    if (editor == null) {
      return null;
    }

    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,
View Full Code Here

public class IncludeHyperlinkDetector extends AbstractHyperlinkDetector {

  public IHyperlink[] detectHyperlinks(ITextViewer textViewer,
      IRegion region, boolean canShowMultipleHyperlinks) {

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

    IModelElement input = org.eclipse.dltk.internal.ui.editor.EditorUtility
View Full Code Here

   * @throws ModelException
   */
  protected IModelElement getCurrentModelElement(ExecutionEvent event)
      throws ExecutionException {
    IEditorPart editorPart = HandlerUtil.getActiveEditor(event);
    PHPStructuredEditor textEditor = null;
    IModelElement modelElement = null;
    if (editorPart instanceof PHPStructuredEditor) {
      textEditor = (PHPStructuredEditor) editorPart;
      modelElement = textEditor.getModelElement();
    } else {
      Object o = editorPart.getAdapter(ITextEditor.class);
      if (o != null) {
        textEditor = (PHPStructuredEditor) o;
        modelElement = textEditor.getModelElement();
      }
    }

    if (textEditor != null && modelElement instanceof ISourceModule) {
      final ISelectionProvider selectionProvider = textEditor
          .getSelectionProvider();
      final ISelection selection = selectionProvider.getSelection();
      if (selection instanceof TextSelection) {
        final TextSelection textSelection = (TextSelection) selection;
        try {
View Full Code Here

      public void run() {
        IWorkbenchPage page = PHPUiPlugin.getActivePage();
        if (page != null) {
          IEditorPart editor = page.getActiveEditor();
          if (editor instanceof PHPStructuredEditor) {
            PHPStructuredEditor phpStructuredEditor = (PHPStructuredEditor) editor;
            if (phpStructuredEditor.getTextViewer() != null
                && phpStructuredEditor != null
                && phpStructuredEditor.getDocument() == document) {
              if (phpStructuredEditor != null
                  && phpStructuredEditor.getTextViewer() != null) {
                sourceModules[0] = (ISourceModule) phpStructuredEditor
                    .getModelElement();
              }
            }
          }
        }
View Full Code Here

   * canToggleLineBreakpoints(org.eclipse.ui.IWorkbenchPart,
   * org.eclipse.jface.viewers.ISelection)
   */
  public boolean canToggleLineBreakpoints(IWorkbenchPart part,
      ISelection selection) {
    PHPStructuredEditor textEditor = getEditor(part);

    if (textEditor != null) {
      return true;
    }

View Full Code Here

TOP

Related Classes of org.eclipse.php.internal.ui.editor.PHPStructuredEditor$InformationDispatchAction

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.