Examples of ITextSelection


Examples of org.eclipse.jface.text.ITextSelection

     * Helper method to find out the selected Java Element from a Java Editor
     */
    private IJavaElement getSelectedJavaElement(JavaEditor editor) throws JavaModelException {
        IJavaElement elem = JavaUI.getEditorInputJavaElement(editor.getEditorInput());
        if (elem instanceof ICompilationUnit) {
            ITextSelection selection = (ITextSelection) editor.getSelectionProvider().getSelection();
            if (selection != null)
                return ((ICompilationUnit) elem).getElementAt(selection.getOffset());
        }
        return null;
    }
View Full Code Here

Examples of org.eclipse.jface.text.ITextSelection

            }
        }

        String typeName = ""; //$NON-NLS-1$

        ITextSelection selection = getCurrentTextSelection();
        if (selection != null) {
            String text = selection.getText();
            if (text != null && validateJavaTypeName(text, project).isOK()) {
                typeName = text;
            }
        }
View Full Code Here

Examples of org.eclipse.jface.text.ITextSelection

    ISelection selection = sp.getSelection();
     
    SelectionData result = new SelectionData();
   
    if (selection instanceof ITextSelection) {
      ITextSelection txSel = (ITextSelection) selection;
      result.updateRangeWithLength(txSel.getOffset(), txSel.getLength());
    }
   
    return result;
  }
View Full Code Here

Examples of org.eclipse.jface.text.ITextSelection

    String controllerName = title.replace(".java", "");

    String packageName = "";
    IEditorInput editorInput = editor.textEditor.getEditorInput();
   
    ITextSelection selection = (ITextSelection) editor.textEditor.getSelectionProvider().getSelection();
    IJavaElement elem = JavaUI.getEditorInputJavaElement(editorInput);
    ICompilationUnit unit = null;
    if (elem instanceof ICompilationUnit) {
      unit = (ICompilationUnit) elem;
      try {
        IPackageDeclaration[] packs = unit.getPackageDeclarations();
        if (packs.length < 1) {
          info("This action can only apply to controllers.");
          return null;
        } else {
          packageName = packs[0].getElementName();
          if (!packageName.startsWith("controllers")) {
            info("This action can only apply to controllers.");
            return null;
          }
        }
       
        // get the class declaration line
        IType type = unit.getType(controllerName);
        ITypeHierarchy superTypes = type.newSupertypeHierarchy(null);
//        String name = JapidController.class.getName(); // this will require play.jar
        String name = "cn.bran.play.JapidController";
        IType japidController = jProject.findType(name);
        if (superTypes.contains(japidController)) {
          useJapid = true;
        }
        else {
          useJapid = false;
        }
       
//        String superclassName = type.getSuperclassName();
//        if (superclassName.toLowerCase().contains("japid")) {
//          useJapid = true;
//        }
       
        // current selected elem
            IJavaElement[] elements= unit.codeSelect(selection.getOffset(), selection.getLength());
            if (elements.length > 0) {
              // TODO extract the current selection to tell if the cursor in on renderJapidXXX line
              System.out.println(elements);
            }
View Full Code Here

Examples of org.eclipse.jface.text.ITextSelection

    String controllerName = title.replace(".java", "");

    String packageName = "";
    IEditorInput editorInput = editor.textEditor.getEditorInput();
   
    ITextSelection selection = (ITextSelection) editor.textEditor.getSelectionProvider().getSelection();
    IJavaElement elem = JavaUI.getEditorInputJavaElement(editorInput);
    ICompilationUnit unit = null;
    if (elem instanceof ICompilationUnit) {
      unit = (ICompilationUnit) elem;
      try {
        IPackageDeclaration[] packs = unit.getPackageDeclarations();
        if (packs.length < 1) {
          info("This action can only apply to controllers.");
          return null;
        } else {
          packageName = packs[0].getElementName();
          if (!packageName.startsWith("controllers")) {
            info("This action can only apply to controllers.");
            return null;
          }
        }
       
//        // get the class declaration line
//        IType type = unit.getType(controllerName);
//        ITypeHierarchy superTypes = type.newSupertypeHierarchy(null);
////        String name = JapidController.class.getName(); // this will require play.jar
//        String name = "cn.bran.play.JapidController";
//        IType japidController = jProject.findType(name);
//       
        // current selected elem
            IJavaElement[] elements= unit.codeSelect(selection.getOffset(), selection.getLength());
            if (elements.length > 0) {
              // TODO extract the current selection to tell if the cursor in on renderJapidXXX line
//              System.out.println(elements);
            }
View Full Code Here

Examples of org.eclipse.jface.text.ITextSelection

  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

Examples of org.eclipse.jface.text.ITextSelection

        final IErlModule module = erlangEditor.getModule();
        SearchPatternData initData = initData0;
        if (module != null) {
            final ISelection ssel = erlangEditor.getSite().getSelectionProvider()
                    .getSelection();
            final ITextSelection textSel = (ITextSelection) ssel;
            final int offset = textSel.getOffset();
            OpenResult res;
            try {
                res = ErlangEngine
                        .getInstance()
                        .getService(OpenService.class)
View Full Code Here

Examples of org.eclipse.jface.text.ITextSelection

    @Override
    protected Object getInfoForSelection(final IWorkbenchPart part,
            final ISelection selection) {
        if (selection instanceof ITextSelection && part instanceof ErlangEditor) {
            final ITextSelection sel = (ITextSelection) selection;
            final ErlangEditor editor = (ErlangEditor) part;
            return ErlTextHover.getHoverInfoForOffset(sel.getOffset(), editor);
        }
        return null;
    }
View Full Code Here

Examples of org.eclipse.jface.text.ITextSelection

            final IErlModule module = fEditor.getModule();
            if (module == null) {
                return;
            }
            final ISelection sel = getSelection();
            final ITextSelection textSel = (ITextSelection) sel;
            final int offset = textSel.getOffset();
            final OpenResult res = ErlangEngine
                    .getInstance()
                    .getService(OpenService.class)
                    .open(module.getScannerName(),
                            offset,
View Full Code Here

Examples of org.eclipse.jface.text.ITextSelection

    private ConsoleBackendShellListener consoleBackendShellListener;
    IErlProject project;

    @Override
    public void run(final ITextSelection selection0) {
        ITextSelection selection = selection0;
        IErlangConsole console = null;
        final IProject workspaceProject = project.getWorkspaceProject();
        if (workspaceProject == null) {
            return;
        }
        console = getConsole(workspaceProject);
        if (console == null) {
            final String message = "There is no runtime launched for this backend. Please start a runtime to send commands to.";
            final Exception x = new Exception("No runtime started");
            ErrorDialog.openError(getShell(), "No runtime", message, new Status(
                    IStatus.ERROR, ErlideUIPlugin.PLUGIN_ID, 0, x.getMessage(), x));
            return;
        }
        console.getShell().removeListener(consoleBackendShellListener);
        // if selection is empty, grab the whole line
        selection = getLineSelection(selection, false);
        // try to make the text a full erlang expression, ending with dot
        String text = selection.getText().trim();
        if (text.endsWith(",") || text.endsWith(";")) { //$NON-NLS-1$ //$NON-NLS-2$
            text = text.substring(0, text.length() - 1);
        }
        if (!text.endsWith(".")) { //$NON-NLS-1$
            text += "."; //$NON-NLS-1$
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.